From 192da818026ea960f7e1a744d218780a97faa37d Mon Sep 17 00:00:00 2001 From: Ed Date: Sat, 9 Nov 2024 15:47:05 +0300 Subject: [PATCH 1/5] scroll spells --- .../_CP14/MagicSpell/CP14SharedMagicSystem.cs | 19 +++- .../Events/CP14CastMagicEffectEvent.cs | 16 ++++ .../CP14SpellStorageSystem.cs | 10 +++ .../CP14SpellStorageUseDamageComponent.cs | 16 ++++ .../Objects/Weapons/Magic/scrolls.yml | 81 ++++++++++++++++++ .../Objects/Bureaucracy/paper.rsi/magic.png | Bin 0 -> 270 bytes .../Objects/Bureaucracy/paper.rsi/meta.json | 3 + 7 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageUseDamageComponent.cs create mode 100644 Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/scrolls.yml create mode 100644 Resources/Textures/_CP14/Objects/Bureaucracy/paper.rsi/magic.png diff --git a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs index 92df201a6a..dc651fec84 100644 --- a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs +++ b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs @@ -122,9 +122,16 @@ private void CastTelegraphy(Entity ent, CP14SpellEffec } } - private bool TryCastSpellDelayed(ICP14DelayedMagicEffect delayedEffect, DoAfterEvent doAfter, EntityUid action, EntityUid performer) + private bool TryCastSpellDelayed(ICP14DelayedMagicEffect delayedEffect, DoAfterEvent doAfter, EntityUid action, EntityUid performer) { - var doAfterEventArgs = new DoAfterArgs(EntityManager, performer, delayedEffect.CastDelay, doAfter, action) + EntityUid? used = null; + + if (TryComp(action, out var provided) && provided.SpellStorage is not null) + { + used = provided.SpellStorage; + } + + var doAfterEventArgs = new DoAfterArgs(EntityManager, performer, delayedEffect.CastDelay, doAfter, action, used: used) { BreakOnMove = delayedEffect.BreakOnMove, BreakOnDamage = delayedEffect.BreakOnDamage, @@ -132,6 +139,8 @@ private bool TryCastSpellDelayed(ICP14DelayedMagicEffect delayedEffect, DoAfterE DistanceThreshold = 100f, CancelDuplicate = true, BlockDuplicate = true, + BreakOnDropItem = true, + NeedHand = true, }; return _doAfter.TryStartDoAfter(doAfterEventArgs); @@ -163,6 +172,12 @@ private void OnAfterCastMagicEffect(Entity ent, ref CP var manaCost = CalculateManacost(ent, args.Performer.Value); _magicEnergy.TryConsumeEnergy(args.Performer.Value, manaCost, safe: ent.Comp.Safe); + + if (TryComp(ent, out var provider) && provider.SpellStorage is not null) + { + var spellEv = new CP14SpellFromSpellStorageUsedEvent(args.Performer, ent, manaCost); + RaiseLocalEvent(provider.SpellStorage.Value, ref spellEv); + } } private FixedPoint2 CalculateManacost(Entity ent, EntityUid caster) diff --git a/Content.Shared/_CP14/MagicSpell/Events/CP14CastMagicEffectEvent.cs b/Content.Shared/_CP14/MagicSpell/Events/CP14CastMagicEffectEvent.cs index 7afaa8412d..5ad7b7788b 100644 --- a/Content.Shared/_CP14/MagicSpell/Events/CP14CastMagicEffectEvent.cs +++ b/Content.Shared/_CP14/MagicSpell/Events/CP14CastMagicEffectEvent.cs @@ -1,4 +1,5 @@ using Content.Shared._CP14.MagicRitual.Prototypes; +using Content.Shared._CP14.MagicSpell.Components; using Content.Shared.FixedPoint; using Content.Shared.Inventory; using Robust.Shared.Prototypes; @@ -97,3 +98,18 @@ public CP14AfterCastMagicEffectEvent(EntityUid? performer) Performer = performer; } } + +[ByRefEvent] +public sealed class CP14SpellFromSpellStorageUsedEvent : EntityEventArgs +{ + public EntityUid? Performer { get; init; } + public Entity Action { get; init; } + public FixedPoint2 Manacost { get; init; } + + public CP14SpellFromSpellStorageUsedEvent(EntityUid? performer, Entity action, FixedPoint2 manacost) + { + Performer = performer; + Action = action; + Manacost = manacost; + } +} diff --git a/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageSystem.cs b/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageSystem.cs index 2ff59c9e93..a20a79ef57 100644 --- a/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageSystem.cs +++ b/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageSystem.cs @@ -1,7 +1,9 @@ using Content.Shared._CP14.MagicAttuning; +using Content.Shared._CP14.MagicSpell.Events; using Content.Shared.Actions; using Content.Shared.Clothing; using Content.Shared.Clothing.Components; +using Content.Shared.Damage; using Content.Shared.Hands; using Content.Shared.Hands.EntitySystems; using Content.Shared.Mind; @@ -20,12 +22,15 @@ public sealed partial class CP14SpellStorageSystem : EntitySystem [Dependency] private readonly CP14SharedMagicAttuningSystem _attuning = default!; [Dependency] private readonly SharedHandsSystem _hands = default!; [Dependency] private readonly INetManager _net = default!; + [Dependency] private readonly DamageableSystem _damageable = default!; public override void Initialize() { SubscribeLocalEvent(OnMagicStorageInit); SubscribeLocalEvent(OnMagicStorageShutdown); + SubscribeLocalEvent(OnSpellUsed); + SubscribeLocalEvent(OnEquippedHand); SubscribeLocalEvent(OnHandAddedAttune); @@ -36,6 +41,11 @@ public override void Initialize() SubscribeLocalEvent(OnRemovedAttune); } + private void OnSpellUsed(Entity ent, ref CP14SpellFromSpellStorageUsedEvent args) + { + _damageable.TryChangeDamage(ent, ent.Comp.DamagePerMana * args.Manacost); + } + /// /// When we initialize, we create action entities, and add them to this item. /// diff --git a/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageUseDamageComponent.cs b/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageUseDamageComponent.cs new file mode 100644 index 0000000000..59281c2ca4 --- /dev/null +++ b/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageUseDamageComponent.cs @@ -0,0 +1,16 @@ +using Content.Shared.Damage; + +namespace Content.Shared._CP14.MagicSpellStorage; + +/// +/// Causes damage to the Spell storage when spells from it are used +/// +[RegisterComponent, Access(typeof(CP14SpellStorageSystem))] +public sealed partial class CP14SpellStorageUseDamageComponent : Component +{ + /// + /// the amount of damage this entity will take per unit manacost of the spell used + /// + [DataField(required: true)] + public DamageSpecifier DamagePerMana = default!; +} diff --git a/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/scrolls.yml b/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/scrolls.yml new file mode 100644 index 0000000000..f13c38763b --- /dev/null +++ b/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/scrolls.yml @@ -0,0 +1,81 @@ +- type: entity + parent: BaseItem + id: CP14BaseSpellScroll + categories: [ ForkFiltered ] + name: spell scroll + description: A piece of paper with a spell embedded in it. The use of magic destroys the fragile paper, making these scrolls short-lived consumables. + abstract: true + components: + - type: Sprite + sprite: _CP14/Objects/Bureaucracy/paper.rsi + layers: + - state: paper_filled + - state: magic + shader: unshaded + - type: Item + size: Tiny + - type: Flammable + fireSpread: true + alwaysCombustible: true + damage: + types: + Heat: 1 + - type: FireVisuals + sprite: Effects/fire.rsi + normalState: fire + - type: Damageable + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 15 + behaviors: + - !type:SpawnEntitiesBehavior + spawn: + Ash: + min: 1 + max: 1 + - !type:DoActsBehavior + acts: [ "Destruction" ] + - type: Food + solution: food + delay: 7 + forceFeedDelay: 7 + - type: FlavorProfile + flavors: + - paper + - CP14Magic + - type: BadFood + - type: SolutionContainerManager + solutions: + food: + maxVol: 1 + reagents: + - ReagentId: Fiber + Quantity: 1 + - type: Tag + tags: + - Document + - type: CP14SpellStorageAccessHolding + - type: CP14SpellStorageUseDamage + damagePerMana: + types: + Heat: 1 + +- type: entity + parent: CP14BaseSpellScroll + id: CP14SpellScrollFireball + name: fireball spell scroll + components: + - type: CP14SpellStorage + spells: + - CP14ActionSpellFireball + +- type: entity + parent: CP14BaseSpellScroll + id: CP14SpellScrollCureWounds + name: cure wounsd spell scroll + components: + - type: CP14SpellStorage + spells: + - CP14ActionSpellCureWounds diff --git a/Resources/Textures/_CP14/Objects/Bureaucracy/paper.rsi/magic.png b/Resources/Textures/_CP14/Objects/Bureaucracy/paper.rsi/magic.png new file mode 100644 index 0000000000000000000000000000000000000000..245c0e4e38ec6927f122140fd80fdea99e74dd84 GIT binary patch literal 270 zcmV+p0rCEcP)Px#$Vo&&R9J=W)3FM|Fc1ddzZDV0rIVAJV>a~(ItHI7i$ho6pzl$-I=Mx~!Ntv0 zTni{If~Yyhy2LoaAupjI7IX5<;GPqL|klI4G~1LJ^rq_5JGg?3n~ax U`n-lp*8l(j07*qoM6N<$f-v%M;Q#;t literal 0 HcmV?d00001 diff --git a/Resources/Textures/_CP14/Objects/Bureaucracy/paper.rsi/meta.json b/Resources/Textures/_CP14/Objects/Bureaucracy/paper.rsi/meta.json index 0e9337c76a..1dfd63b564 100644 --- a/Resources/Textures/_CP14/Objects/Bureaucracy/paper.rsi/meta.json +++ b/Resources/Textures/_CP14/Objects/Bureaucracy/paper.rsi/meta.json @@ -38,6 +38,9 @@ }, { "name": "paper_stamp-generic" + }, + { + "name": "magic" } ] } From e0f29df23efcc20b1facbdfc7c0f4932908b0f8a Mon Sep 17 00:00:00 2001 From: Ed Date: Sat, 9 Nov 2024 17:03:23 +0300 Subject: [PATCH 2/5] refactor magic system --- .../CP14SharedMagicSystem.Actions.cs | 25 ++++-- .../_CP14/MagicSpell/CP14SharedMagicSystem.cs | 88 ++++++++++++------- .../Components/CP14MagicEffectComponent.cs | 9 +- .../CP14ProvidedBySpellStorageComponent.cs | 11 --- .../CP14SpellStorageSystem.cs | 3 +- .../ru-RU/_CP14/magicEnergy/magic-spells.ftl | 4 + .../Actions/Spells/Meta/T0_mana_gift.yml | 4 +- .../_CP14/Entities/Clothing/Rings/ring.yml | 5 ++ .../Objects/Weapons/Magic/scrolls.yml | 35 ++++++-- .../Objects/Weapons/Magic/twoHandedStaffs.yml | 11 ++- 10 files changed, 130 insertions(+), 65 deletions(-) delete mode 100644 Content.Shared/_CP14/MagicSpellStorage/CP14ProvidedBySpellStorageComponent.cs diff --git a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.Actions.cs b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.Actions.cs index cb2407f0a1..0e8d8ac4df 100644 --- a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.Actions.cs +++ b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.Actions.cs @@ -29,16 +29,18 @@ private void OnInstantAction(CP14DelayedInstantActionEvent args) if (args is not ICP14DelayedMagicEffect delayedEffect) return; - if (!CanCastSpell(args.Action, args.Performer)) + if (!TryComp(args.Action, out var magicEffect)) return; - if (!TryComp(args.Action, out var magicEffect)) + Entity spell = (args.Action, magicEffect); + + if (!CanCastSpell(spell, args.Performer)) return; if (args.CastDelay > 0) { var doAfter = new CP14DelayedInstantActionDoAfterEvent(args.Cooldown); - if (!TryCastSpellDelayed(delayedEffect, doAfter, args.Action, args.Performer)) + if (!TryCastSpellDelayed(delayedEffect, doAfter, (args.Action, magicEffect), args.Performer)) return; } @@ -67,12 +69,15 @@ private void OnEntityWorldTargetAction(CP14DelayedEntityWorldTargetActionEvent a if (args is not ICP14DelayedMagicEffect delayedEffect) return; - if (!CanCastSpell(args.Action, args.Performer)) + if (!TryComp(args.Action, out var magicEffect)) return; - if (!TryComp(args.Action, out var magicEffect)) + Entity spell = (args.Action, magicEffect); + + if (!CanCastSpell(spell, args.Performer)) return; + if (args.CastDelay > 0) { var doAfter = new CP14DelayedEntityWorldTargetActionDoAfterEvent( @@ -80,7 +85,7 @@ private void OnEntityWorldTargetAction(CP14DelayedEntityWorldTargetActionEvent a EntityManager.GetNetEntity(args.Entity), args.Cooldown); - if (!TryCastSpellDelayed(delayedEffect, doAfter, args.Action, args.Performer)) + if (!TryCastSpellDelayed(delayedEffect, doAfter, (args.Action, magicEffect), args.Performer)) return; } @@ -109,10 +114,12 @@ private void OnEntityTargetAction(CP14DelayedEntityTargetActionEvent args) if (args is not ICP14DelayedMagicEffect delayedEffect) return; - if (!CanCastSpell(args.Action, args.Performer)) + if (!TryComp(args.Action, out var magicEffect)) return; - if (!TryComp(args.Action, out var magicEffect)) + Entity spell = (args.Action, magicEffect); + + if (!CanCastSpell(spell, args.Performer)) return; if (args.CastDelay > 0) @@ -121,7 +128,7 @@ private void OnEntityTargetAction(CP14DelayedEntityTargetActionEvent args) EntityManager.GetNetEntity(args.Target), args.Cooldown); - if (!TryCastSpellDelayed(delayedEffect, doAfter, args.Action, args.Performer)) + if (!TryCastSpellDelayed(delayedEffect, doAfter, (args.Action, magicEffect), args.Performer)) return; } diff --git a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs index dc651fec84..54fc5e5f8a 100644 --- a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs +++ b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs @@ -76,10 +76,10 @@ private void OnMagicEffectInit(Entity ent, ref MapInit /// /// Checking to see if the spell can be used at all /// - private bool CanCastSpell(EntityUid spell, EntityUid performer) + private bool CanCastSpell(Entity ent, EntityUid performer) { var ev = new CP14CastMagicEffectAttemptEvent(performer); - RaiseLocalEvent(spell, ref ev); + RaiseLocalEvent(ent, ref ev); if (ev.Reason != string.Empty && _net.IsServer) { _popup.PopupEntity(ev.Reason, performer, performer); @@ -92,22 +92,45 @@ private bool CanCastSpell(EntityUid spell, EntityUid performer) /// private void OnBeforeCastMagicEffect(Entity ent, ref CP14CastMagicEffectAttemptEvent args) { - if (!TryComp(args.Performer, out var magicContainer)) + if (ent.Comp.SpellStorage is null) //Dont have spellStorage, we use mana from caster { - args.Cancel(); - return; - } + if (!TryComp(args.Performer, out var magicContainer)) + { + args.Cancel(); + return; + } - var manaCost = CalculateManacost(ent, args.Performer); + var manaCost = CalculateManacost(ent, args.Performer); - if (!_magicEnergy.HasEnergy(args.Performer, manaCost, magicContainer, ent.Comp.Safe)) - { - args.PushReason(Loc.GetString("cp14-magic-spell-not-enough-mana")); - args.Cancel(); + if (!_magicEnergy.HasEnergy(args.Performer, manaCost, magicContainer, ent.Comp.Safe)) + { + args.PushReason(Loc.GetString("cp14-magic-spell-not-enough-mana")); + args.Cancel(); + } + else if(!_magicEnergy.HasEnergy(args.Performer, manaCost, magicContainer, true) && _net.IsServer) //фу какой некрасивый хардкод + { // \/ + _popup.PopupEntity(Loc.GetString("cp14-magic-spell-not-enough-mana-cast-warning-"+_random.Next(5)), args.Performer, args.Performer, PopupType.SmallCaution); + } } - else if(!_magicEnergy.HasEnergy(args.Performer, manaCost, magicContainer, true) && _net.IsServer) //фу какой некрасивый | хардкод - { // \/ - _popup.PopupEntity(Loc.GetString("cp14-magic-spell-not-enough-mana-cast-warning-"+_random.Next(5)), args.Performer, args.Performer, PopupType.SmallCaution); + else //We HAVE SpellStorage, use mana from spellStorage + { + if (!TryComp(ent.Comp.SpellStorage, out var magicContainer)) + { + args.Cancel(); + return; + } + + var manaCost = CalculateManacost(ent, ent.Comp.SpellStorage.Value); + + if (!_magicEnergy.HasEnergy(ent.Comp.SpellStorage.Value, manaCost, magicContainer, ent.Comp.Safe)) + { + args.PushReason(Loc.GetString("cp14-magic-spell-not-enough-mana-item")); + args.Cancel(); + } + else if(!_magicEnergy.HasEnergy(ent.Comp.SpellStorage.Value, manaCost, magicContainer, true) && _net.IsServer) //фу какой некрасивый хардкод + { // \/ + _popup.PopupEntity(Loc.GetString("cp14-magic-spell-not-enough-mana-cast-warning-item-"+_random.Next(3), ("item", MetaData(ent.Comp.SpellStorage.Value).EntityName)), args.Performer, args.Performer, PopupType.SmallCaution); + } } } @@ -122,16 +145,9 @@ private void CastTelegraphy(Entity ent, CP14SpellEffec } } - private bool TryCastSpellDelayed(ICP14DelayedMagicEffect delayedEffect, DoAfterEvent doAfter, EntityUid action, EntityUid performer) + private bool TryCastSpellDelayed(ICP14DelayedMagicEffect delayedEffect, DoAfterEvent doAfter, Entity action, EntityUid performer) { - EntityUid? used = null; - - if (TryComp(action, out var provided) && provided.SpellStorage is not null) - { - used = provided.SpellStorage; - } - - var doAfterEventArgs = new DoAfterArgs(EntityManager, performer, delayedEffect.CastDelay, doAfter, action, used: used) + var doAfterEventArgs = new DoAfterArgs(EntityManager, performer, delayedEffect.CastDelay, doAfter, action, used: action.Comp.SpellStorage) { BreakOnMove = delayedEffect.BreakOnMove, BreakOnDamage = delayedEffect.BreakOnDamage, @@ -167,16 +183,24 @@ private void OnAfterCastMagicEffect(Entity ent, ref CP if (_net.IsClient) return; - if (!HasComp(args.Performer)) - return; - - var manaCost = CalculateManacost(ent, args.Performer.Value); - _magicEnergy.TryConsumeEnergy(args.Performer.Value, manaCost, safe: ent.Comp.Safe); + if (ent.Comp.SpellStorage is null) //We pickup mana from player + { + if (!HasComp(args.Performer)) + return; - if (TryComp(ent, out var provider) && provider.SpellStorage is not null) + var manaCost = CalculateManacost(ent, args.Performer.Value); + _magicEnergy.TryConsumeEnergy(args.Performer.Value, manaCost, safe: ent.Comp.Safe); + } + else //We pickup mana from SpellStorage { + if (!HasComp(ent.Comp.SpellStorage)) + return; + + var manaCost = CalculateManacost(ent, ent.Comp.SpellStorage.Value); + _magicEnergy.TryConsumeEnergy(ent.Comp.SpellStorage.Value, manaCost, safe: ent.Comp.Safe); + var spellEv = new CP14SpellFromSpellStorageUsedEvent(args.Performer, ent, manaCost); - RaiseLocalEvent(provider.SpellStorage.Value, ref spellEv); + RaiseLocalEvent(ent.Comp.SpellStorage.Value, ref spellEv); } } @@ -189,8 +213,8 @@ private FixedPoint2 CalculateManacost(Entity ent, Enti var manaEv = new CP14CalculateManacostEvent(caster, ent.Comp.ManaCost, ent.Comp.MagicType); RaiseLocalEvent(caster, manaEv); - if (TryComp(ent, out var provided) && provided.SpellStorage is not null) - RaiseLocalEvent(provided.SpellStorage.Value, manaEv); + if (ent.Comp.SpellStorage is not null) + RaiseLocalEvent(ent.Comp.SpellStorage.Value, manaEv); manaCost = manaEv.GetManacost(); } diff --git a/Content.Shared/_CP14/MagicSpell/Components/CP14MagicEffectComponent.cs b/Content.Shared/_CP14/MagicSpell/Components/CP14MagicEffectComponent.cs index bfbd69b0b6..3a13161d01 100644 --- a/Content.Shared/_CP14/MagicSpell/Components/CP14MagicEffectComponent.cs +++ b/Content.Shared/_CP14/MagicSpell/Components/CP14MagicEffectComponent.cs @@ -1,5 +1,6 @@ using Content.Shared._CP14.MagicRitual.Prototypes; using Content.Shared._CP14.MagicSpell.Spells; +using Content.Shared._CP14.MagicSpellStorage; using Content.Shared.FixedPoint; using Robust.Shared.Prototypes; @@ -8,9 +9,15 @@ namespace Content.Shared._CP14.MagicSpell.Components; /// /// Restricts the use of this action, by spending mana or user requirements. /// -[RegisterComponent, Access(typeof(CP14SharedMagicSystem))] +[RegisterComponent, Access(typeof(CP14SharedMagicSystem), typeof(CP14SpellStorageSystem))] public sealed partial class CP14MagicEffectComponent : Component { + /// + /// if this effect was provided by an spellstorage, it will be recorded here automatically. + /// + [DataField] + public Entity? SpellStorage; + [DataField] public FixedPoint2 ManaCost = 0f; diff --git a/Content.Shared/_CP14/MagicSpellStorage/CP14ProvidedBySpellStorageComponent.cs b/Content.Shared/_CP14/MagicSpellStorage/CP14ProvidedBySpellStorageComponent.cs deleted file mode 100644 index 4d3ded7f47..0000000000 --- a/Content.Shared/_CP14/MagicSpellStorage/CP14ProvidedBySpellStorageComponent.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Content.Shared._CP14.MagicSpellStorage; - -/// -/// Located on the action entity, stores a reference to the object from which the action was created. -/// -[RegisterComponent, Access(typeof(CP14SpellStorageSystem))] -public sealed partial class CP14ProvidedBySpellStorageComponent : Component -{ - [DataField] - public Entity? SpellStorage; -} diff --git a/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageSystem.cs b/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageSystem.cs index a20a79ef57..dcf728ce37 100644 --- a/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageSystem.cs +++ b/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageSystem.cs @@ -1,4 +1,5 @@ using Content.Shared._CP14.MagicAttuning; +using Content.Shared._CP14.MagicSpell.Components; using Content.Shared._CP14.MagicSpell.Events; using Content.Shared.Actions; using Content.Shared.Clothing; @@ -60,7 +61,7 @@ private void OnMagicStorageInit(Entity mStorage, ref if (spellEnt is null) continue; - var provided = EntityManager.EnsureComponent(spellEnt.Value); + var provided = EntityManager.EnsureComponent(spellEnt.Value); provided.SpellStorage = mStorage; mStorage.Comp.SpellEntities.Add(spellEnt.Value); diff --git a/Resources/Locale/ru-RU/_CP14/magicEnergy/magic-spells.ftl b/Resources/Locale/ru-RU/_CP14/magicEnergy/magic-spells.ftl index e959a853bd..2568a90a02 100644 --- a/Resources/Locale/ru-RU/_CP14/magicEnergy/magic-spells.ftl +++ b/Resources/Locale/ru-RU/_CP14/magicEnergy/magic-spells.ftl @@ -6,6 +6,10 @@ cp14-magic-spell-not-enough-mana-cast-warning-2 = Ваши руки дрожат cp14-magic-spell-not-enough-mana-cast-warning-3 = К горлу подступает ком... cp14-magic-spell-not-enough-mana-cast-warning-4 = Голова наливается свинцом... +cp14-magic-spell-not-enough-mana-cast-warning-item-0 = {$item} дрожит в ваших руках... +cp14-magic-spell-not-enough-mana-cast-warning-item-1 = {$item} начинает неприятно нагреваться... +cp14-magic-spell-not-enough-mana-cast-warning-item-2 = {$item} начинает издавать странный треск... + cp14-magic-energy-damage-burn-out = От нехватки маны боль пронзает ваше тело! cp14-magic-energy-damage-overload = Вы не можете удержать столько маны! cp14-magic-energy-damage-burn-out-fall = Вы теряете сознание от сильной боли! diff --git a/Resources/Prototypes/_CP14/Entities/Actions/Spells/Meta/T0_mana_gift.yml b/Resources/Prototypes/_CP14/Entities/Actions/Spells/Meta/T0_mana_gift.yml index 9d884957be..b1c63828b8 100644 --- a/Resources/Prototypes/_CP14/Entities/Actions/Spells/Meta/T0_mana_gift.yml +++ b/Resources/Prototypes/_CP14/Entities/Actions/Spells/Meta/T0_mana_gift.yml @@ -39,8 +39,8 @@ sprite: _CP14/Effects/Magic/spells_icons.rsi state: mana_gift event: !type:CP14DelayedEntityTargetActionEvent - cooldown: 5 - castDelay: 2 + cooldown: 1 + castDelay: 1 - type: entity id: CP14RuneManaGift diff --git a/Resources/Prototypes/_CP14/Entities/Clothing/Rings/ring.yml b/Resources/Prototypes/_CP14/Entities/Clothing/Rings/ring.yml index dc4617f961..8b5a9ab586 100644 --- a/Resources/Prototypes/_CP14/Entities/Clothing/Rings/ring.yml +++ b/Resources/Prototypes/_CP14/Entities/Clothing/Rings/ring.yml @@ -11,6 +11,11 @@ - ring - type: Sprite sprite: _CP14/Clothing/Rings/rings.rsi + - type: CP14MagicEnergyExaminable + - type: CP14MagicEnergyContainer + energy: 50 + maxEnergy: 50 + - type: CP14MagicUnsafeDamage - type: entity id: CP14ClothingRingIceDagger diff --git a/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/scrolls.yml b/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/scrolls.yml index f13c38763b..1cb4e590be 100644 --- a/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/scrolls.yml +++ b/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/scrolls.yml @@ -28,7 +28,7 @@ thresholds: - trigger: !type:DamageTrigger - damage: 15 + damage: 1 behaviors: - !type:SpawnEntitiesBehavior spawn: @@ -57,10 +57,14 @@ tags: - Document - type: CP14SpellStorageAccessHolding - - type: CP14SpellStorageUseDamage - damagePerMana: - types: - Heat: 1 + #- type: CP14SpellStorageUseDamage + # damagePerMana: + # types: + # Heat: 1 + - type: CP14MagicEnergyContainer + energy: 10 + maxEnergy: 10 + - type: CP14MagicUnsafeDamage - type: entity parent: CP14BaseSpellScroll @@ -74,8 +78,27 @@ - type: entity parent: CP14BaseSpellScroll id: CP14SpellScrollCureWounds - name: cure wounsd spell scroll + name: cure wound spell scroll components: - type: CP14SpellStorage spells: - CP14ActionSpellCureWounds + +- type: entity + parent: CP14BaseSpellScroll + id: CP14SpellScrollIceShards + name: ice shards spell scroll + components: + - type: CP14SpellStorage + spells: + - CP14ActionSpellIceShards + + +- type: entity + parent: CP14BaseSpellScroll + id: CP14SpellScrollManaGift + name: mana gift spell scroll + components: + - type: CP14SpellStorage + spells: + - CP14ActionSpellManaGift diff --git a/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/twoHandedStaffs.yml b/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/twoHandedStaffs.yml index f57597af5a..ae3f83e1d8 100644 --- a/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/twoHandedStaffs.yml +++ b/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/twoHandedStaffs.yml @@ -44,6 +44,11 @@ - type: CP14SpellStorage spells: - CP14ActionSpellCureWounds - - type: CP14MagicManacostModify - modifiers: - Healing: 1.1 \ No newline at end of file + #- type: CP14MagicManacostModify + # modifiers: + # Healing: 1.1 + - type: CP14MagicEnergyExaminable + - type: CP14MagicEnergyContainer + energy: 80 + maxEnergy: 80 + - type: CP14MagicUnsafeDamage \ No newline at end of file From ecccde20b93b1c30c6ef51fd2493b879995cf8d3 Mon Sep 17 00:00:00 2001 From: Ed Date: Sat, 9 Nov 2024 17:04:54 +0300 Subject: [PATCH 3/5] Update spawners.yml --- .../Entities/Markers/Spawners/Random/Loot/spawners.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Resources/Prototypes/_CP14/Entities/Markers/Spawners/Random/Loot/spawners.yml b/Resources/Prototypes/_CP14/Entities/Markers/Spawners/Random/Loot/spawners.yml index 0b33cc4324..72abb13c5a 100644 --- a/Resources/Prototypes/_CP14/Entities/Markers/Spawners/Random/Loot/spawners.yml +++ b/Resources/Prototypes/_CP14/Entities/Markers/Spawners/Random/Loot/spawners.yml @@ -32,6 +32,12 @@ weight: 0.5 - id: CP14CopperCoin1 weight: 1 + - !type:GroupSelector + children: + - id: CP14SpellScrollFireball + - id: CP14SpellScrollCureWounds + - id: CP14SpellScrollIceShards + - id: CP14SpellScrollManaGift - !type:GroupSelector children: - id: CP14DyeRed From 9744a24958585b37dac1753afec2ab300f24cfeb Mon Sep 17 00:00:00 2001 From: Ed Date: Sat, 9 Nov 2024 17:25:38 +0300 Subject: [PATCH 4/5] safe use --- .../MagicEnergy/SharedCP14MagicEnergySystem.cs | 2 +- .../_CP14/MagicSpell/CP14SharedMagicSystem.cs | 8 ++------ .../Locale/en-US/_CP14/magicEnergy/magic-spells.ftl | 2 ++ .../Locale/ru-RU/_CP14/magicEnergy/magic-spells.ftl | 5 +---- .../Entities/Objects/Weapons/Magic/scrolls.yml | 13 ++++++------- .../Objects/Weapons/Magic/twoHandedStaffs.yml | 3 +-- 6 files changed, 13 insertions(+), 20 deletions(-) diff --git a/Content.Shared/_CP14/MagicEnergy/SharedCP14MagicEnergySystem.cs b/Content.Shared/_CP14/MagicEnergy/SharedCP14MagicEnergySystem.cs index 2a426a6d81..72ea496c2b 100644 --- a/Content.Shared/_CP14/MagicEnergy/SharedCP14MagicEnergySystem.cs +++ b/Content.Shared/_CP14/MagicEnergy/SharedCP14MagicEnergySystem.cs @@ -101,7 +101,7 @@ public bool HasEnergy(EntityUid uid, FixedPoint2 energy, CP14MagicEnergyContaine if (safe == false) return true; - return component.Energy > energy; + return component.Energy >= energy; } public bool TryConsumeEnergy(EntityUid uid, FixedPoint2 energy, CP14MagicEnergyContainerComponent? component = null, bool safe = false) diff --git a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs index 54fc5e5f8a..69d243c2a3 100644 --- a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs +++ b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs @@ -122,15 +122,11 @@ private void OnBeforeCastMagicEffect(Entity ent, ref C var manaCost = CalculateManacost(ent, ent.Comp.SpellStorage.Value); - if (!_magicEnergy.HasEnergy(ent.Comp.SpellStorage.Value, manaCost, magicContainer, ent.Comp.Safe)) + if (!_magicEnergy.HasEnergy(ent.Comp.SpellStorage.Value, manaCost, magicContainer, true)) { - args.PushReason(Loc.GetString("cp14-magic-spell-not-enough-mana-item")); + args.PushReason(Loc.GetString("cp14-magic-spell-not-enough-mana-item", ("item", MetaData(ent.Comp.SpellStorage.Value).EntityName))); args.Cancel(); } - else if(!_magicEnergy.HasEnergy(ent.Comp.SpellStorage.Value, manaCost, magicContainer, true) && _net.IsServer) //фу какой некрасивый хардкод - { // \/ - _popup.PopupEntity(Loc.GetString("cp14-magic-spell-not-enough-mana-cast-warning-item-"+_random.Next(3), ("item", MetaData(ent.Comp.SpellStorage.Value).EntityName)), args.Performer, args.Performer, PopupType.SmallCaution); - } } } diff --git a/Resources/Locale/en-US/_CP14/magicEnergy/magic-spells.ftl b/Resources/Locale/en-US/_CP14/magicEnergy/magic-spells.ftl index 74a78f0ade..43a2921ba1 100644 --- a/Resources/Locale/en-US/_CP14/magicEnergy/magic-spells.ftl +++ b/Resources/Locale/en-US/_CP14/magicEnergy/magic-spells.ftl @@ -1,4 +1,6 @@ cp14-magic-spell-not-enough-mana = Not enough mana! +cp14-magic-spell-not-enough-mana = Not enough mana in {$item}! + 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... diff --git a/Resources/Locale/ru-RU/_CP14/magicEnergy/magic-spells.ftl b/Resources/Locale/ru-RU/_CP14/magicEnergy/magic-spells.ftl index 2568a90a02..36f1fbf213 100644 --- a/Resources/Locale/ru-RU/_CP14/magicEnergy/magic-spells.ftl +++ b/Resources/Locale/ru-RU/_CP14/magicEnergy/magic-spells.ftl @@ -1,4 +1,5 @@ cp14-magic-spell-not-enough-mana = Недостаточно магической энергии! +cp14-magic-spell-not-enough-mana-item = Недостаточно магической энергии в {$item}! cp14-magic-spell-not-enough-mana-cast-warning-0 = Внутри вас все начинает неприятно ныть... cp14-magic-spell-not-enough-mana-cast-warning-1 = Голова начинает шуметь... @@ -6,10 +7,6 @@ cp14-magic-spell-not-enough-mana-cast-warning-2 = Ваши руки дрожат cp14-magic-spell-not-enough-mana-cast-warning-3 = К горлу подступает ком... cp14-magic-spell-not-enough-mana-cast-warning-4 = Голова наливается свинцом... -cp14-magic-spell-not-enough-mana-cast-warning-item-0 = {$item} дрожит в ваших руках... -cp14-magic-spell-not-enough-mana-cast-warning-item-1 = {$item} начинает неприятно нагреваться... -cp14-magic-spell-not-enough-mana-cast-warning-item-2 = {$item} начинает издавать странный треск... - cp14-magic-energy-damage-burn-out = От нехватки маны боль пронзает ваше тело! cp14-magic-energy-damage-overload = Вы не можете удержать столько маны! cp14-magic-energy-damage-burn-out-fall = Вы теряете сознание от сильной боли! diff --git a/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/scrolls.yml b/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/scrolls.yml index 1cb4e590be..b7f8ecadaf 100644 --- a/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/scrolls.yml +++ b/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/scrolls.yml @@ -57,13 +57,13 @@ tags: - Document - type: CP14SpellStorageAccessHolding - #- type: CP14SpellStorageUseDamage - # damagePerMana: - # types: - # Heat: 1 + - type: CP14SpellStorageUseDamage + damagePerMana: + types: + Heat: 1 - type: CP14MagicEnergyContainer - energy: 10 - maxEnergy: 10 + energy: 30 + maxEnergy: 50 - type: CP14MagicUnsafeDamage - type: entity @@ -93,7 +93,6 @@ spells: - CP14ActionSpellIceShards - - type: entity parent: CP14BaseSpellScroll id: CP14SpellScrollManaGift diff --git a/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/twoHandedStaffs.yml b/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/twoHandedStaffs.yml index ae3f83e1d8..8418206c21 100644 --- a/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/twoHandedStaffs.yml +++ b/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/twoHandedStaffs.yml @@ -50,5 +50,4 @@ - type: CP14MagicEnergyExaminable - type: CP14MagicEnergyContainer energy: 80 - maxEnergy: 80 - - type: CP14MagicUnsafeDamage \ No newline at end of file + maxEnergy: 80 \ No newline at end of file From 3bae57cb5329eca4adb947d40890c728e2271eda Mon Sep 17 00:00:00 2001 From: Ed Date: Sat, 9 Nov 2024 17:30:02 +0300 Subject: [PATCH 5/5] Update magic-spells.ftl --- Resources/Locale/en-US/_CP14/magicEnergy/magic-spells.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Locale/en-US/_CP14/magicEnergy/magic-spells.ftl b/Resources/Locale/en-US/_CP14/magicEnergy/magic-spells.ftl index 43a2921ba1..a709d3f4a0 100644 --- a/Resources/Locale/en-US/_CP14/magicEnergy/magic-spells.ftl +++ b/Resources/Locale/en-US/_CP14/magicEnergy/magic-spells.ftl @@ -1,5 +1,5 @@ cp14-magic-spell-not-enough-mana = Not enough mana! -cp14-magic-spell-not-enough-mana = Not enough mana in {$item}! +cp14-magic-spell-not-enough-mana-item = Not enough mana in {$item}! cp14-magic-spell-not-enough-mana-cast-warning-0 = Everything inside you starts to whine unpleasantly...