From a6847c08e87ee59db6313c4bf892dd679c228a22 Mon Sep 17 00:00:00 2001 From: MetalSage <74924875+MetalSage@users.noreply.github.com> Date: Sun, 12 Jan 2025 14:10:45 +0400 Subject: [PATCH] Add "Mana Wasting" trait (#732) * add trait * Update Resources/Locale/ru-RU/_CP14/magicEnergy/magic-spells.ftl * fix magic item using --------- Co-authored-by: MetalSage Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com> Co-authored-by: Ed --- .../_CP14/MagicSpell/CP14MagicSystem.cs | 5 +- .../CP14MagicAttuningMindComponent.cs | 5 +- .../CP14MagicEnergyContainerComponent.cs | 4 +- .../CP14SharedMagicSystem.Checks.cs | 25 +++--- .../CP14MagicUnsafeDamageComponent.cs | 4 +- .../CP14MagicUnsafeSleepComponent.cs | 4 +- .../en-US/_CP14/magicEnergy/magic-spells.ftl | 2 + Resources/Locale/en-US/_CP14/traits/trait.ftl | 5 +- .../ru-RU/_CP14/magicEnergy/magic-spells.ftl | 2 + Resources/Locale/ru-RU/_CP14/traits/trait.ftl | 5 +- .../_CP14/Loadouts/Jobs/general.yml | 86 ++++++++++++++++++- .../Prototypes/_CP14/Traits/physical.yml | 18 ++++ 12 files changed, 145 insertions(+), 20 deletions(-) diff --git a/Content.Server/_CP14/MagicSpell/CP14MagicSystem.cs b/Content.Server/_CP14/MagicSpell/CP14MagicSystem.cs index 82f8e3d2e8..6bbda67805 100644 --- a/Content.Server/_CP14/MagicSpell/CP14MagicSystem.cs +++ b/Content.Server/_CP14/MagicSpell/CP14MagicSystem.cs @@ -60,10 +60,9 @@ public sealed partial class CP14MagicSystem : CP14SharedMagicSystem if (magicStorage.Energy > 0) { - //TODO: FIX THIS SHIT var cashedEnergy = magicStorage.Energy; - _magicEnergy.TryConsumeEnergy(magicEffect.SpellStorage.Value, requiredMana, magicStorage, false); - requiredMana = MathF.Max(0, (float)(requiredMana - cashedEnergy)); + if (_magicEnergy.TryConsumeEnergy(magicEffect.SpellStorage.Value, requiredMana, magicStorage, false)) + requiredMana = MathF.Max(0, (float)(requiredMana - cashedEnergy)); } } diff --git a/Content.Shared/_CP14/MagicAttuning/CP14MagicAttuningMindComponent.cs b/Content.Shared/_CP14/MagicAttuning/CP14MagicAttuningMindComponent.cs index 9fa7175bf9..a6e04797f0 100644 --- a/Content.Shared/_CP14/MagicAttuning/CP14MagicAttuningMindComponent.cs +++ b/Content.Shared/_CP14/MagicAttuning/CP14MagicAttuningMindComponent.cs @@ -1,9 +1,12 @@ +using Robust.Shared.GameStates; + namespace Content.Shared._CP14.MagicAttuning; /// /// A mind that can focus on objects /// -[RegisterComponent, Access(typeof(CP14SharedMagicAttuningSystem))] +[RegisterComponent, NetworkedComponent] +[Access(typeof(CP14SharedMagicAttuningSystem))] public sealed partial class CP14MagicAttuningMindComponent : Component { [DataField] diff --git a/Content.Shared/_CP14/MagicEnergy/Components/CP14MagicEnergyContainerComponent.cs b/Content.Shared/_CP14/MagicEnergy/Components/CP14MagicEnergyContainerComponent.cs index adcebc3eca..9b6c7bd2d0 100644 --- a/Content.Shared/_CP14/MagicEnergy/Components/CP14MagicEnergyContainerComponent.cs +++ b/Content.Shared/_CP14/MagicEnergy/Components/CP14MagicEnergyContainerComponent.cs @@ -1,13 +1,15 @@ using Content.Shared.Alert; using Content.Shared.FixedPoint; using Robust.Shared.Prototypes; +using Robust.Shared.GameStates; namespace Content.Shared._CP14.MagicEnergy.Components; /// /// Allows an item to store magical energy within itself. /// -[RegisterComponent, Access(typeof(SharedCP14MagicEnergySystem))] +[RegisterComponent, NetworkedComponent] +[Access(typeof(SharedCP14MagicEnergySystem))] public sealed partial class CP14MagicEnergyContainerComponent : Component { [DataField] diff --git a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.Checks.cs b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.Checks.cs index 551953cab2..24380e5e90 100644 --- a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.Checks.cs +++ b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.Checks.cs @@ -26,24 +26,29 @@ public abstract partial class CP14SharedMagicSystem /// private void OnManaCheck(Entity ent, ref CP14CastMagicEffectAttemptEvent args) { + //Total man required var requiredMana = CalculateManacost(ent, args.Performer); - if (!_magicEffectQuery.TryComp(ent, out var magicEffect)) - return; - - if (magicEffect.SpellStorage is not null) + //First - trying get mana from item + if (_magicEffectQuery.TryComp(ent, out var magicEffect)) { - if (_magicContainerQuery.TryComp(magicEffect.SpellStorage, out var magicContainer)) // We have item that provides this spell + if (magicEffect.SpellStorage is not null && _magicContainerQuery.TryComp(magicEffect.SpellStorage, out var magicContainer)) requiredMana = MathF.Max(0, (float)(requiredMana - magicContainer.Energy)); } - if (requiredMana > 0 && _magicContainerQuery.TryComp(args.Performer, out var playerMana)) + if (requiredMana <= 0) + return; + + //Second - trying get mana from performer + if (!_magicContainerQuery.TryComp(args.Performer, out var playerMana)) { - if (!_magicEnergy.HasEnergy(args.Performer, requiredMana, playerMana, true) && _net.IsServer) - { - _popup.PopupEntity(Loc.GetString("cp14-magic-spell-not-enough-mana-cast-warning-"+_random.Next(5)), args.Performer, args.Performer, PopupType.SmallCaution); - } + args.PushReason(Loc.GetString("cp14-magic-spell-no-mana-component")); + args.Cancel(); + return; } + + if (!_magicEnergy.HasEnergy(args.Performer, requiredMana, playerMana, true) && _net.IsServer) + _popup.PopupEntity(Loc.GetString($"cp14-magic-spell-not-enough-mana-cast-warning-{_random.Next(5)}"), args.Performer, args.Performer, PopupType.SmallCaution); } private void OnStaminaCheck(Entity ent, ref CP14CastMagicEffectAttemptEvent args) diff --git a/Content.Shared/_CP14/MagicWeakness/CP14MagicUnsafeDamageComponent.cs b/Content.Shared/_CP14/MagicWeakness/CP14MagicUnsafeDamageComponent.cs index e87de708ba..88ca27ccf4 100644 --- a/Content.Shared/_CP14/MagicWeakness/CP14MagicUnsafeDamageComponent.cs +++ b/Content.Shared/_CP14/MagicWeakness/CP14MagicUnsafeDamageComponent.cs @@ -1,12 +1,14 @@ using Content.Shared.Damage; using Content.Shared.FixedPoint; +using Robust.Shared.GameStates; namespace Content.Shared._CP14.MagicWeakness; /// /// imposes damage on excessive use of magic /// -[RegisterComponent, Access(typeof(CP14MagicWeaknessSystem))] +[RegisterComponent, NetworkedComponent] +[Access(typeof(CP14MagicWeaknessSystem))] public sealed partial class CP14MagicUnsafeDamageComponent : Component { [DataField] diff --git a/Content.Shared/_CP14/MagicWeakness/CP14MagicUnsafeSleepComponent.cs b/Content.Shared/_CP14/MagicWeakness/CP14MagicUnsafeSleepComponent.cs index 1b8b1a8c99..214bcab11f 100644 --- a/Content.Shared/_CP14/MagicWeakness/CP14MagicUnsafeSleepComponent.cs +++ b/Content.Shared/_CP14/MagicWeakness/CP14MagicUnsafeSleepComponent.cs @@ -1,11 +1,13 @@ using Content.Shared.FixedPoint; +using Robust.Shared.GameStates; namespace Content.Shared._CP14.MagicWeakness; /// /// imposes debuffs on excessive use of magic /// -[RegisterComponent, Access(typeof(CP14MagicWeaknessSystem))] +[RegisterComponent, NetworkedComponent] +[Access(typeof(CP14MagicWeaknessSystem))] public sealed partial class CP14MagicUnsafeSleepComponent : Component { [DataField] diff --git a/Resources/Locale/en-US/_CP14/magicEnergy/magic-spells.ftl b/Resources/Locale/en-US/_CP14/magicEnergy/magic-spells.ftl index 7ce7c58826..99263c8569 100644 --- a/Resources/Locale/en-US/_CP14/magicEnergy/magic-spells.ftl +++ b/Resources/Locale/en-US/_CP14/magicEnergy/magic-spells.ftl @@ -1,5 +1,7 @@ cp14-magic-spell-not-enough-mana = Not enough mana! +cp14-magic-spell-no-mana-component = You're not using magical energy. + cp14-magic-spell-not-enough-mana-cast-warning-0 = Everything inside you starts to whine unpleasantly... cp14-magic-spell-not-enough-mana-cast-warning-1 = Your head starts to buzz... cp14-magic-spell-not-enough-mana-cast-warning-2 = Your hands are shaking... diff --git a/Resources/Locale/en-US/_CP14/traits/trait.ftl b/Resources/Locale/en-US/_CP14/traits/trait.ftl index 1aa92ff174..02c2067afe 100644 --- a/Resources/Locale/en-US/_CP14/traits/trait.ftl +++ b/Resources/Locale/en-US/_CP14/traits/trait.ftl @@ -20,10 +20,13 @@ cp14-trait-muted-desc = All you can do is mumble incoherently. The benefits of v cp14-trait-snoring-name = Loud snoring cp14-trait-snoring-desc = It is simply impossible to sleep next to you because you snore terribly loudly at everything. +cp14-trait-mana-wasting-name = Magical mediocrity. +cp14-trait-mana-wasting-desc = Fate has decreed that magic is just an empty sound for you. You are unable to store or use magical energy. + # Backgrounds cp14-trait-bg-entertainer-name = Entertainer cp14-trait-bg-entertainer-desc = You have to thrive in front of an audience. You know the way how to entertain them, entrance them and also even how to inspire them. Your poetics able to stir the hearts like those who awakening grief or joy, anger or laughter. Their spirits can be raised by your music and also it captures their sorrow. Actually, your dance steps are captivate and also your humor will cuts to the quick. Finally, your art is your life whatever the techniques you use. cp14-trait-bg-soldier-name = Soldier -cp14-trait-bg-soldier-desc = War has been your life for as long as you care to remember. You trained as a youth, studied the use of weapons and armor, learned basic survival techniques, including how to stay alive on the battlefield. You might have been part of a standing national army or a mercenary company, or perhaps a member of a local militia who rose to prominence during a recent war. \ No newline at end of file +cp14-trait-bg-soldier-desc = War has been your life for as long as you care to remember. You trained as a youth, studied the use of weapons and armor, learned basic survival techniques, including how to stay alive on the battlefield. You might have been part of a standing national army or a mercenary company, or perhaps a member of a local militia who rose to prominence during a recent war. diff --git a/Resources/Locale/ru-RU/_CP14/magicEnergy/magic-spells.ftl b/Resources/Locale/ru-RU/_CP14/magicEnergy/magic-spells.ftl index 50ce689bd0..3744ca5f90 100644 --- a/Resources/Locale/ru-RU/_CP14/magicEnergy/magic-spells.ftl +++ b/Resources/Locale/ru-RU/_CP14/magicEnergy/magic-spells.ftl @@ -1,5 +1,7 @@ cp14-magic-spell-not-enough-mana = Недостаточно магической энергии! +cp14-magic-spell-no-mana-component = Вы не можете пользоваться магией. + cp14-magic-spell-not-enough-mana-cast-warning-0 = Внутри вас все начинает неприятно ныть... cp14-magic-spell-not-enough-mana-cast-warning-1 = Голова начинает шуметь... cp14-magic-spell-not-enough-mana-cast-warning-2 = Ваши руки дрожат... diff --git a/Resources/Locale/ru-RU/_CP14/traits/trait.ftl b/Resources/Locale/ru-RU/_CP14/traits/trait.ftl index 0d354ccec3..2d096ccbc0 100644 --- a/Resources/Locale/ru-RU/_CP14/traits/trait.ftl +++ b/Resources/Locale/ru-RU/_CP14/traits/trait.ftl @@ -20,10 +20,13 @@ cp14-trait-muted-desc = Все что вы можете - бессвязно м cp14-trait-snoring-name = Громкий храп cp14-trait-snoring-desc = Спать рядом с вами просто невозможно, потому что во все вы жутко громко храпите. +cp14-trait-mana-wasting-name = Магическая бездарность +cp14-trait-mana-wasting-desc = Судьба распорядилась так, что магия для вас - лишь пустой звук. Вы не способны ни накапливать, ни использовать магическую энергию. + # Backgrounds cp14-trait-bg-entertainer-name = Артист cp14-trait-bg-entertainer-desc = Вам нравится выступать на публике. Вы знаете, как их развлечь, очаровать и даже воодушевить. Ваша поэзия может трогать сердца слушателей, пробуждать в них горе или радость, смех или гнев. Ваша музыка ободряет их или заставляет скорбеть. Ваши танцы захватывают, а шутки всегда смешны. Чем бы вы ни занимались, ваша жизнь тесно связана с искусством. cp14-trait-bg-soldier-name = Солдат -cp14-trait-bg-soldier-desc = Сколько вы помните, в вашей жизни всегда была война. С молодости вы проходили тренировки, учились использовать оружие и доспехи, изучали технику выживания, включая то, как оставаться живым на поле боя. Вы могли быть частью армии страны или отряда наёмников, а может, были местным ополченцем во время войны. \ No newline at end of file +cp14-trait-bg-soldier-desc = Сколько вы помните, в вашей жизни всегда была война. С молодости вы проходили тренировки, учились использовать оружие и доспехи, изучали технику выживания, включая то, как оставаться живым на поле боя. Вы могли быть частью армии страны или отряда наёмников, а может, были местным ополченцем во время войны. diff --git a/Resources/Prototypes/_CP14/Loadouts/Jobs/general.yml b/Resources/Prototypes/_CP14/Loadouts/Jobs/general.yml index 04845864d9..5ac5e5b092 100644 --- a/Resources/Prototypes/_CP14/Loadouts/Jobs/general.yml +++ b/Resources/Prototypes/_CP14/Loadouts/Jobs/general.yml @@ -440,29 +440,67 @@ - CP14ActionSpellBeerCreation - CP14ActionSpellSprint +- type: loadout + id: CP14ActionSpellBase + effects: + - !type:JobRequirementLoadoutEffect + requirement: + !type:TraitsRequirement + inverted: true + traits: + - CP14ManaWasting + - type: loadout id: CP14ActionSpellFlameCreation dummyEntity: CP14ActionSpellFlameCreation actions: - CP14ActionSpellFlameCreation + effects: + - !type:JobRequirementLoadoutEffect + requirement: + !type:TraitsRequirement + inverted: true + traits: + - CP14ManaWasting - type: loadout id: CP14ActionSpellCureWounds dummyEntity: CP14ActionSpellCureWounds actions: - CP14ActionSpellCureWounds + effects: + - !type:JobRequirementLoadoutEffect + requirement: + !type:TraitsRequirement + inverted: true + traits: + - CP14ManaWasting - type: loadout id: CP14ActionSpellCureBurn dummyEntity: CP14ActionSpellCureBurn actions: - CP14ActionSpellCureBurn + effects: + - !type:JobRequirementLoadoutEffect + requirement: + !type:TraitsRequirement + inverted: true + traits: + - CP14ManaWasting - type: loadout id: CP14ActionSpellBloodPurification dummyEntity: CP14ActionSpellBloodPurification actions: - CP14ActionSpellBloodPurification + effects: + - !type:JobRequirementLoadoutEffect + requirement: + !type:TraitsRequirement + inverted: true + traits: + - CP14ManaWasting - type: loadout id: CP14ActionSpellPlantGrowth @@ -476,12 +514,25 @@ species: - CP14Silva inverted: true # Silvas cannot take this spell, they have buffed version by default + - !type:JobRequirementLoadoutEffect + requirement: + !type:TraitsRequirement + inverted: true + traits: + - CP14ManaWasting - type: loadout id: CP14ActionSpellSphereOfLight dummyEntity: CP14ActionSpellSphereOfLight actions: - CP14ActionSpellSphereOfLight + effects: + - !type:JobRequirementLoadoutEffect + requirement: + !type:TraitsRequirement + inverted: true + traits: + - CP14ManaWasting - type: loadout id: CP14ActionSpellManaConsume @@ -495,24 +546,51 @@ species: - CP14Elf inverted: true # Elves cannot take this spell, they have buffed version by default + - !type:JobRequirementLoadoutEffect + requirement: + !type:TraitsRequirement + inverted: true + traits: + - CP14ManaWasting - type: loadout id: CP14ActionSpellManaGift dummyEntity: CP14ActionSpellManaGift actions: - CP14ActionSpellManaGift + effects: + - !type:JobRequirementLoadoutEffect + requirement: + !type:TraitsRequirement + inverted: true + traits: + - CP14ManaWasting - type: loadout id: CP14ActionSpellShadowGrab dummyEntity: CP14ActionSpellShadowGrab actions: - CP14ActionSpellShadowGrab + effects: + - !type:JobRequirementLoadoutEffect + requirement: + !type:TraitsRequirement + inverted: true + traits: + - CP14ManaWasting - type: loadout id: CP14ActionSpellWaterCreation dummyEntity: CP14ActionSpellWaterCreation actions: - CP14ActionSpellWaterCreation + effects: + - !type:JobRequirementLoadoutEffect + requirement: + !type:TraitsRequirement + inverted: true + traits: + - CP14ManaWasting - type: loadout id: CP14ActionSpellBeerCreation @@ -530,6 +608,12 @@ !type:RoleTimeRequirement role: CP14JobInnkeeper time: 7200 # 2 hour + - !type:JobRequirementLoadoutEffect + requirement: + !type:TraitsRequirement + inverted: true + traits: + - CP14ManaWasting - type: loadout id: CP14ActionSpellSprint @@ -542,4 +626,4 @@ !type:SpeciesRequirement species: - CP14Goblin - inverted: true # Goblins cannot take this spell, they have buffed version by default \ No newline at end of file + inverted: true # Goblins cannot take this spell, they have buffed version by default diff --git a/Resources/Prototypes/_CP14/Traits/physical.yml b/Resources/Prototypes/_CP14/Traits/physical.yml index dbc01ffec2..739e74649d 100644 --- a/Resources/Prototypes/_CP14/Traits/physical.yml +++ b/Resources/Prototypes/_CP14/Traits/physical.yml @@ -13,6 +13,24 @@ components: - type: PermanentBlindness +- type: trait + id: CP14ManaWasting + name: cp14-trait-mana-wasting-name + description: cp14-trait-mana-wasting-desc + category: CP14PhysicalTraits + cost: -2 + whitelist: + components: + - CP14MagicEnergyContainer + components: + - type: Accentless + removes: + - type: CP14MagicEnergyContainer + - type: CP14MagicEnergyDraw + - type: CP14MagicUnsafeDamage + - type: CP14MagicUnsafeSleep + - type: CP14MagicAttuningMind + # -1 - type: trait