From 7b3f2cd0d4b4b6535dfecdf8011ff9bc7f2b1c20 Mon Sep 17 00:00:00 2001 From: mhamster <81412348+mhamsterr@users.noreply.github.com> Date: Sat, 5 Aug 2023 11:31:14 +0700 Subject: [PATCH] Add EmpReactionEffect (#18248) Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> --- .../ReactionEffects/EmpReactionEffect.cs | 49 +++++++++++++++++++ .../en-US/guidebook/chemistry/effects.ftl | 6 +++ .../Recipes/Reactions/chemicals.yml | 18 +++++++ 3 files changed, 73 insertions(+) create mode 100644 Content.Server/Chemistry/ReactionEffects/EmpReactionEffect.cs diff --git a/Content.Server/Chemistry/ReactionEffects/EmpReactionEffect.cs b/Content.Server/Chemistry/ReactionEffects/EmpReactionEffect.cs new file mode 100644 index 0000000000..17d868a0e9 --- /dev/null +++ b/Content.Server/Chemistry/ReactionEffects/EmpReactionEffect.cs @@ -0,0 +1,49 @@ +using Content.Server.Emp; +using Content.Shared.Chemistry.Reagent; +using Robust.Shared.Prototypes; + +namespace Content.Server.Chemistry.ReactionEffects; + + +[DataDefinition] +public sealed class EmpReactionEffect : ReagentEffect +{ + /// + /// Impulse range per unit of reagent + /// + [DataField("rangePerUnit")] + public float EmpRangePerUnit = 0.5f; + + /// + /// Maximum impulse range + /// + [DataField("maxRange")] + public float EmpMaxRange = 10; + + /// + /// How much energy will be drain from sources + /// + [DataField("energyConsumption")] + public float EnergyConsumption = 12500; + + /// + /// Amount of time entities will be disabled + /// + [DataField("duration")] + public float DisableDuration = 15; + + protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) + => Loc.GetString("reagent-effect-guidebook-emp-reaction-effect", ("chance", Probability)); + + public override void Effect(ReagentEffectArgs args) + { + var transform = args.EntityManager.GetComponent(args.SolutionEntity); + var range = MathF.Min((float) (args.Quantity*EmpRangePerUnit), EmpMaxRange); + + args.EntityManager.System().EmpPulse( + transform.MapPosition, + range, + EnergyConsumption, + DisableDuration); + } +} diff --git a/Resources/Locale/en-US/guidebook/chemistry/effects.ftl b/Resources/Locale/en-US/guidebook/chemistry/effects.ftl index bde49ab783..6f3645c705 100644 --- a/Resources/Locale/en-US/guidebook/chemistry/effects.ftl +++ b/Resources/Locale/en-US/guidebook/chemistry/effects.ftl @@ -31,6 +31,12 @@ reagent-effect-guidebook-explosion-reaction-effect = *[other] cause } an explosion +reagent-effect-guidebook-emp-reaction-effect = + { $chance -> + [1] Causes + *[other] cause + } an electromagnetic pulse + reagent-effect-guidebook-foam-area-reaction-effect = { $chance -> [1] Creates diff --git a/Resources/Prototypes/Recipes/Reactions/chemicals.yml b/Resources/Prototypes/Recipes/Reactions/chemicals.yml index 73cba1db3c..d69c5cc147 100644 --- a/Resources/Prototypes/Recipes/Reactions/chemicals.yml +++ b/Resources/Prototypes/Recipes/Reactions/chemicals.yml @@ -177,6 +177,24 @@ sound: path: /Audio/Effects/extinguish.ogg +- type: reaction + id: UraniumEmpExplosion + impact: High + priority: 20 + reactants: + Iron: + amount: 1 + Uranium: + amount: 1 + Aluminium: + amount: 1 + effects: + - !type:EmpReactionEffect + rangePerUnit: 0.2 + maxRange: 6 + energyConsumption: 12500 + duration: 15 + - type: reaction id: TableSalt reactants: