From: alexalexmax <149889301+alexalexmax@users.noreply.github.com> Date: Tue, 13 Jan 2026 13:30:53 +0000 (-0500) Subject: Adds EMP Resistance component, gives it to ninja suit and headset (#42334) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=738f55c45644e00a0a186be6009d0befac1e0cc5;p=space-station-14.git Adds EMP Resistance component, gives it to ninja suit and headset (#42334) * add comp and apply to ninja gear * cleanup * requested changes --------- Co-authored-by: seanpimble <149889301+seanpimble@users.noreply.github.com> --- diff --git a/Content.Shared/Emp/EmpResistanceComponent.cs b/Content.Shared/Emp/EmpResistanceComponent.cs new file mode 100644 index 0000000000..0768ad744f --- /dev/null +++ b/Content.Shared/Emp/EmpResistanceComponent.cs @@ -0,0 +1,18 @@ +using Content.Shared.FixedPoint; +using Robust.Shared.GameStates; + +namespace Content.Shared.Emp; + +/// +/// An entity with this component resists or is fully immune to EMPs. +/// +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +[Access(typeof(SharedEmpSystem))] +public sealed partial class EmpResistanceComponent : Component +{ + /// + /// The proportion of the EMP effect that is resisted. 1.00 indicates full immunity while 0.00 indicates no resistance. + /// + [DataField, AutoNetworkedField] + public FixedPoint2 Resistance = FixedPoint2.Zero; +} diff --git a/Content.Shared/Emp/SharedEmpSystem.cs b/Content.Shared/Emp/SharedEmpSystem.cs index 7e6ea58dbc..d1c773dd90 100644 --- a/Content.Shared/Emp/SharedEmpSystem.cs +++ b/Content.Shared/Emp/SharedEmpSystem.cs @@ -6,6 +6,7 @@ using Robust.Shared.Map; using Robust.Shared.Timing; using Robust.Shared.Network; using Robust.Shared.Prototypes; +using Robust.Shared.Utility; namespace Content.Shared.Emp; @@ -26,6 +27,9 @@ public abstract class SharedEmpSystem : EntitySystem SubscribeLocalEvent(OnExamine); SubscribeLocalEvent(OnRemove); SubscribeLocalEvent(OnRejuvenate); + + SubscribeLocalEvent(OnResistEmpAttempt); + SubscribeLocalEvent(OnResistEmpPulse); } public static readonly EntProtoId EmpPulseEffectPrototype = "EffectEmpPulse"; @@ -152,6 +156,23 @@ public abstract class SharedEmpSystem : EntitySystem { RemCompDeferred(ent); } + + private void OnResistEmpAttempt(Entity ent, ref EmpAttemptEvent args) + { + if (ent.Comp.Resistance >= 1) + args.Cancelled = true; + } + + private void OnResistEmpPulse(Entity ent, ref EmpPulseEvent args) + { + var empStrengthMultiplier = 1 - ent.Comp.Resistance; + + if (empStrengthMultiplier <= 0) + return; + + args.Duration *= (float) empStrengthMultiplier; + args.EnergyConsumption *= (float) empStrengthMultiplier; + } } /// diff --git a/Content.Shared/Ninja/Systems/SharedNinjaSuitSystem.cs b/Content.Shared/Ninja/Systems/SharedNinjaSuitSystem.cs index f316b16f6b..01f860da12 100644 --- a/Content.Shared/Ninja/Systems/SharedNinjaSuitSystem.cs +++ b/Content.Shared/Ninja/Systems/SharedNinjaSuitSystem.cs @@ -36,7 +36,6 @@ public abstract class SharedNinjaSuitSystem : EntitySystem SubscribeLocalEvent(OnCreateStarAttempt); SubscribeLocalEvent(OnActivateAttempt); SubscribeLocalEvent(OnUnequipped); - SubscribeLocalEvent(OnEmpAttempt); } private void OnEquipped(Entity ent, ref ClothingGotEquippedEvent args) @@ -172,11 +171,4 @@ public abstract class SharedNinjaSuitSystem : EntitySystem if (user.Comp.Gloves is { } uid) _toggle.TryDeactivate(uid, user: user); } - - private void OnEmpAttempt(Entity ent, ref EmpAttemptEvent args) - { - // ninja suit (battery) is immune to emp - // powercell relays the event to suit - args.Cancelled = true; - } } diff --git a/Resources/Prototypes/Entities/Clothing/Ears/headsets.yml b/Resources/Prototypes/Entities/Clothing/Ears/headsets.yml index 8b3154b4ab..30c5c9f295 100644 --- a/Resources/Prototypes/Entities/Clothing/Ears/headsets.yml +++ b/Resources/Prototypes/Entities/Clothing/Ears/headsets.yml @@ -314,3 +314,5 @@ sprite: Clothing/Ears/Headsets/ninja.rsi - type: Clothing sprite: Clothing/Ears/Headsets/ninja.rsi + - type: EmpResistance + resistance: 1 diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml index 068ed1a511..8d3a0ebae4 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml @@ -189,6 +189,8 @@ noPowerPopup: ninja-no-power # core ninja suit stuff - type: NinjaSuit + - type: EmpResistance + resistance: 1 - type: UseDelay delay: 5 # disable time - type: PowerCellSlot