diff --git a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.InstantActions.cs b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.InstantActions.cs new file mode 100644 index 0000000000..acaba35e04 --- /dev/null +++ b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.InstantActions.cs @@ -0,0 +1,69 @@ +using Content.Shared._CP14.MagicSpell.Components; +using Content.Shared._CP14.MagicSpell.Events; +using Content.Shared._CP14.MagicSpell.Spells; + +namespace Content.Shared._CP14.MagicSpell; + +public abstract partial class CP14SharedMagicSystem +{ + private void InitializeInstantActions() + { + SubscribeLocalEvent(OnMagicInstantAction); + SubscribeLocalEvent(OnMagicEntityWorldTargetAction); + SubscribeLocalEvent(OnMagicEntityTargetAction); + } + + private void OnMagicInstantAction(CP14InstantActionEvent args) + { + if (args.Handled) + return; + + if (!TryComp(args.Action, out var magicEffect)) + return; + + if (!CanCastSpell((args.Action, magicEffect), args.Performer)) + return; + + var spellArgs = + new CP14SpellEffectBaseArgs(args.Performer, magicEffect.SpellStorage, args.Performer, Transform(args.Performer).Coordinates); + + CastSpell((args.Action, magicEffect), spellArgs); + _action.CP14StartCustomDelay(args.Action, args.Cooldown); + } + + private void OnMagicEntityWorldTargetAction(CP14EntityWorldTargetActionEvent args) + { + if (args.Handled) + return; + + if (!TryComp(args.Action, out var magicEffect)) + return; + + if (!CanCastSpell((args.Action, magicEffect), args.Performer)) + return; + + var spellArgs = + new CP14SpellEffectBaseArgs(args.Performer, magicEffect.SpellStorage, args.Entity, args.Coords); + + CastSpell((args.Action, magicEffect), spellArgs); + _action.CP14StartCustomDelay(args.Action, args.Cooldown); + } + + private void OnMagicEntityTargetAction(CP14EntityTargetActionEvent args) + { + if (args.Handled) + return; + + if (!TryComp(args.Action, out var magicEffect)) + return; + + if (!CanCastSpell((args.Action, magicEffect), args.Performer)) + return; + + var spellArgs = + new CP14SpellEffectBaseArgs(args.Performer, magicEffect.SpellStorage, args.Target, Transform(args.Target).Coordinates); + + CastSpell((args.Action, magicEffect), spellArgs); + _action.CP14StartCustomDelay(args.Action, args.Cooldown); + } +} diff --git a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.ToggleableActions.cs b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.ToggleableActions.cs index cdfed96270..9c6aeca2d2 100644 --- a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.ToggleableActions.cs +++ b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.ToggleableActions.cs @@ -10,9 +10,9 @@ public abstract partial class CP14SharedMagicSystem { private void InitializeToggleableActions() { - SubscribeLocalEvent(OnInstantAction); - SubscribeLocalEvent(OnEntityWorldTargetAction); - SubscribeLocalEvent(OnEntityTargetAction); + SubscribeLocalEvent(OnToggleableInstantAction); + SubscribeLocalEvent(OnToggleableEntityWorldTargetAction); + SubscribeLocalEvent(OnToggleableEntityTargetAction); SubscribeLocalEvent(OnToggleableInstantActionDoAfterEvent); SubscribeLocalEvent(OnToggleableEntityWorldTargetActionDoAfterEvent); @@ -128,7 +128,7 @@ public abstract partial class CP14SharedMagicSystem /// /// Instant action used from hotkey event /// - private void OnInstantAction(CP14ToggleableInstantActionEvent args) + private void OnToggleableInstantAction(CP14ToggleableInstantActionEvent args) { if (args.Handled) return; @@ -148,7 +148,7 @@ public abstract partial class CP14SharedMagicSystem /// /// Target action used from hotkey event /// - private void OnEntityWorldTargetAction(CP14ToggleableEntityWorldTargetActionEvent args) + private void OnToggleableEntityWorldTargetAction(CP14ToggleableEntityWorldTargetActionEvent args) { if (args.Handled) return; @@ -171,7 +171,7 @@ public abstract partial class CP14SharedMagicSystem /// /// Entity target action used from hotkey event /// - private void OnEntityTargetAction(CP14ToggleableEntityTargetActionEvent args) + private void OnToggleableEntityTargetAction(CP14ToggleableEntityTargetActionEvent args) { if (args.Handled) return; diff --git a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs index 85575b0d8a..b486ef67d5 100644 --- a/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs +++ b/Content.Shared/_CP14/MagicSpell/CP14SharedMagicSystem.cs @@ -43,6 +43,7 @@ public abstract partial class CP14SharedMagicSystem : EntitySystem base.Initialize(); InitializeDelayedActions(); InitializeToggleableActions(); + InitializeInstantActions(); InitializeChecks(); InitializeSlowdown(); diff --git a/Content.Shared/_CP14/MagicSpell/Events/CP14ActionsEvents.cs b/Content.Shared/_CP14/MagicSpell/Events/CP14ActionsEvents.cs new file mode 100644 index 0000000000..5bc14516f5 --- /dev/null +++ b/Content.Shared/_CP14/MagicSpell/Events/CP14ActionsEvents.cs @@ -0,0 +1,27 @@ +using Content.Shared.Actions; + +namespace Content.Shared._CP14.MagicSpell.Events; + +public interface ICP14MagicEffect +{ + public TimeSpan Cooldown { get; } +} + +public sealed partial class CP14EntityWorldTargetActionEvent : EntityWorldTargetActionEvent, ICP14MagicEffect +{ + [DataField] + public TimeSpan Cooldown { get; private set; } = TimeSpan.FromSeconds(1f); +} + +public sealed partial class CP14EntityTargetActionEvent : EntityTargetActionEvent, ICP14MagicEffect +{ + [DataField] + public TimeSpan Cooldown { get; private set; } = TimeSpan.FromSeconds(1f); +} + +public sealed partial class CP14InstantActionEvent : InstantActionEvent, ICP14MagicEffect +{ + [DataField] + public TimeSpan Cooldown { get; private set; } = TimeSpan.FromSeconds(1f); +} + diff --git a/Resources/Prototypes/_CP14/Entities/Actions/Spells/Water/T1_ice_shards.yml b/Resources/Prototypes/_CP14/Entities/Actions/Spells/Water/T1_ice_shards.yml index 6198fa6b6a..dc09a95463 100644 --- a/Resources/Prototypes/_CP14/Entities/Actions/Spells/Water/T1_ice_shards.yml +++ b/Resources/Prototypes/_CP14/Entities/Actions/Spells/Water/T1_ice_shards.yml @@ -15,6 +15,9 @@ effects: - !type:CP14SpellProjectile prototype: CP14IceShard + - !type:CP14SpellSpawnEntityOnUser + spawns: + - CP14ImpactEffectWaterCreation - type: CP14MagicEffectVerbalAspect endSpeech: "Glacies acus!" - type: CP14MagicEffectCastingVisual @@ -30,10 +33,8 @@ icon: sprite: _CP14/Effects/Magic/spells_icons.rsi state: ice_shards - event: !type:CP14DelayedEntityWorldTargetActionEvent - cooldown: 0.25 - castDelay: 0.25 - breakOnMove: false + event: !type:CP14EntityWorldTargetActionEvent + cooldown: 0.5 - type: entity id: CP14RuneIceShards diff --git a/Resources/Prototypes/_CP14/Loadouts/Jobs/general.yml b/Resources/Prototypes/_CP14/Loadouts/Jobs/general.yml index 808d0d7849..32c16963ee 100644 --- a/Resources/Prototypes/_CP14/Loadouts/Jobs/general.yml +++ b/Resources/Prototypes/_CP14/Loadouts/Jobs/general.yml @@ -583,242 +583,3 @@ storage: back: - CP14KeyPersonalHouseAbstract - -# Spells - -- type: loadoutGroup - id: CP14GeneralSpells - name: cp14-loadout-general-spells - minLimit: 0 - maxLimit: 3 - loadouts: - - CP14ActionSpellFlameCreation - - CP14ActionSpellCureWounds - - CP14ActionSpellCureBurn - - CP14ActionSpellBloodPurification - - CP14ActionSpellPlantGrowth - - CP14ActionSpellSphereOfLight - - CP14ActionSpellManaConsume - - CP14ActionSpellManaGift - - CP14ActionSpellCounterSpell - - CP14ActionSpellShadowGrab - - CP14ActionSpellWaterCreation - - CP14ActionSpellFreeze - - CP14ActionSpellBeerCreation - - CP14ActionSpellSprint - - CP14ActionSpellKick - -- 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 - dummyEntity: CP14ActionSpellPlantGrowth - actions: - - CP14ActionSpellPlantGrowth - effects: - - !type:JobRequirementLoadoutEffect - requirement: - !type:SpeciesRequirement - 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 - dummyEntity: CP14ActionSpellManaConsume - actions: - - CP14ActionSpellManaConsume - effects: - - !type:JobRequirementLoadoutEffect - requirement: - !type:SpeciesRequirement - 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: CP14ActionSpellFreeze - dummyEntity: CP14ActionSpellFreeze - actions: - - CP14ActionSpellFreeze - effects: - - !type:JobRequirementLoadoutEffect - requirement: - !type:TraitsRequirement - inverted: true - traits: - - CP14ManaWasting - -- type: loadout - id: CP14ActionSpellCounterSpell - dummyEntity: CP14ActionSpellCounterSpell - actions: - - CP14ActionSpellCounterSpell - effects: - - !type:JobRequirementLoadoutEffect - requirement: - !type:TraitsRequirement - inverted: true - traits: - - CP14ManaWasting - -- type: loadout - id: CP14ActionSpellBeerCreation - dummyEntity: CP14ActionSpellBeerCreation - actions: - - CP14ActionSpellBeerCreation - effects: - - !type:JobRequirementLoadoutEffect - requirement: - !type:SpeciesRequirement - species: - - CP14Dwarf - - !type:JobRequirementLoadoutEffect - requirement: - !type:TraitsRequirement - inverted: true - traits: - - CP14ManaWasting - -- type: loadout - id: CP14ActionSpellSprint - dummyEntity: CP14ActionSpellSprint - actions: - - CP14ActionSpellSprint - effects: - - !type:JobRequirementLoadoutEffect - requirement: - !type:SpeciesRequirement - species: - - CP14Goblin - inverted: true # Goblins cannot take this spell, they have buffed version by default - -- type: loadout - id: CP14ActionSpellKick - dummyEntity: CP14ActionSpellKick - actions: - - CP14ActionSpellKick diff --git a/Resources/Prototypes/_CP14/Loadouts/spells.yml b/Resources/Prototypes/_CP14/Loadouts/spells.yml new file mode 100644 index 0000000000..a930a609e2 --- /dev/null +++ b/Resources/Prototypes/_CP14/Loadouts/spells.yml @@ -0,0 +1,252 @@ +# Spells + +- type: loadoutGroup + id: CP14GeneralSpells + name: cp14-loadout-general-spells + minLimit: 0 + maxLimit: 3 + loadouts: + - CP14ActionSpellFlameCreation + - CP14ActionSpellCureWounds + - CP14ActionSpellCureBurn + - CP14ActionSpellBloodPurification + - CP14ActionSpellPlantGrowth + - CP14ActionSpellSphereOfLight + - CP14ActionSpellManaConsume + - CP14ActionSpellManaGift + - CP14ActionSpellCounterSpell + - CP14ActionSpellShadowGrab + - CP14ActionSpellWaterCreation + - CP14ActionSpellIceShards + - CP14ActionSpellFreeze + - CP14ActionSpellBeerCreation + - CP14ActionSpellSprint + - CP14ActionSpellKick + +- 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 + dummyEntity: CP14ActionSpellPlantGrowth + actions: + - CP14ActionSpellPlantGrowth + effects: + - !type:JobRequirementLoadoutEffect + requirement: + !type:SpeciesRequirement + 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 + dummyEntity: CP14ActionSpellManaConsume + actions: + - CP14ActionSpellManaConsume + effects: + - !type:JobRequirementLoadoutEffect + requirement: + !type:SpeciesRequirement + 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: CP14ActionSpellCounterSpell + dummyEntity: CP14ActionSpellCounterSpell + actions: + - CP14ActionSpellCounterSpell + 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: CP14ActionSpellIceShards + dummyEntity: CP14ActionSpellIceShards + actions: + - CP14ActionSpellIceShards + 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: CP14ActionSpellFreeze + dummyEntity: CP14ActionSpellFreeze + actions: + - CP14ActionSpellFreeze + effects: + - !type:JobRequirementLoadoutEffect + requirement: + !type:TraitsRequirement + inverted: true + traits: + - CP14ManaWasting + +- type: loadout + id: CP14ActionSpellBeerCreation + dummyEntity: CP14ActionSpellBeerCreation + actions: + - CP14ActionSpellBeerCreation + effects: + - !type:JobRequirementLoadoutEffect + requirement: + !type:SpeciesRequirement + species: + - CP14Dwarf + - !type:JobRequirementLoadoutEffect + requirement: + !type:TraitsRequirement + inverted: true + traits: + - CP14ManaWasting + +- type: loadout + id: CP14ActionSpellSprint + dummyEntity: CP14ActionSpellSprint + actions: + - CP14ActionSpellSprint + effects: + - !type:JobRequirementLoadoutEffect + requirement: + !type:SpeciesRequirement + species: + - CP14Goblin + inverted: true # Goblins cannot take this spell, they have buffed version by default + +- type: loadout + id: CP14ActionSpellKick + dummyEntity: CP14ActionSpellKick + actions: + - CP14ActionSpellKick \ No newline at end of file