diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs b/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs index bb3cc42df4..9c5e9ac94c 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs @@ -248,7 +248,7 @@ public sealed partial class AdminVerbSystem } _electrocutionSystem.TryDoElectrocution(args.Target, null, damageToDeal, - TimeSpan.FromSeconds(30), true); + TimeSpan.FromSeconds(30), refresh: true, ignoreInsulation: true); }, Impact = LogImpact.Extreme, Message = Loc.GetString("admin-smite-electrocute-description") diff --git a/Content.Server/Chemistry/ReagentEffects/Electrocute.cs b/Content.Server/Chemistry/ReagentEffects/Electrocute.cs index 4938f401af..d3a5383de7 100644 --- a/Content.Server/Chemistry/ReagentEffects/Electrocute.cs +++ b/Content.Server/Chemistry/ReagentEffects/Electrocute.cs @@ -19,7 +19,7 @@ public sealed class Electrocute : ReagentEffect public override void Effect(ReagentEffectArgs args) { EntitySystem.Get().TryDoElectrocution(args.SolutionEntity, null, - Math.Max((args.Quantity * ElectrocuteDamageScale).Int(), 1), TimeSpan.FromSeconds(ElectrocuteTime), Refresh); + Math.Max((args.Quantity * ElectrocuteDamageScale).Int(), 1), TimeSpan.FromSeconds(ElectrocuteTime), Refresh, ignoreInsulation: true); args.Source?.RemoveReagent(args.Reagent.ID, args.Quantity); } diff --git a/Content.Server/Electrocution/ElectrocuteCommand.cs b/Content.Server/Electrocution/ElectrocuteCommand.cs index dcc0a33b9e..26f3904ba3 100644 --- a/Content.Server/Electrocution/ElectrocuteCommand.cs +++ b/Content.Server/Electrocution/ElectrocuteCommand.cs @@ -48,7 +48,7 @@ namespace Content.Server.Electrocution } entityManager.EntitySysManager.GetEntitySystem() - .TryDoElectrocution(uid, null, damage, TimeSpan.FromSeconds(seconds), true); + .TryDoElectrocution(uid, null, damage, TimeSpan.FromSeconds(seconds), refresh: true, ignoreInsulation: true); } } } diff --git a/Content.Server/Electrocution/ElectrocutionSystem.cs b/Content.Server/Electrocution/ElectrocutionSystem.cs index 9be441de48..1fb7bbaf51 100644 --- a/Content.Server/Electrocution/ElectrocutionSystem.cs +++ b/Content.Server/Electrocution/ElectrocutionSystem.cs @@ -11,6 +11,7 @@ using Content.Shared.Damage.Prototypes; using Content.Shared.Database; using Content.Shared.Electrocution; using Content.Shared.Interaction; +using Content.Shared.Inventory; using Content.Shared.Jittering; using Content.Shared.Maps; using Content.Shared.Popups; @@ -252,18 +253,25 @@ namespace Content.Server.Electrocution } } + /// Entity being electrocuted. + /// Source entity of the electrocution. + /// How much shock damage the entity takes. + /// How long the entity will be stunned. + /// Should time be refreshed (instead of accumilated) if the entity is already electrocuted? + /// How insulated the entity is from the shock. 0 means completely insulated, and 1 means no insulation. + /// Status effect to apply to the entity. + /// Should the electrocution bypass the Insulated component? /// Whether the entity was stunned by the shock. public bool TryDoElectrocution( EntityUid uid, EntityUid? sourceUid, int shockDamage, TimeSpan time, bool refresh, float siemensCoefficient = 1f, - StatusEffectsComponent? statusEffects = null) + StatusEffectsComponent? statusEffects = null, bool ignoreInsulation = false) { - if (!DoCommonElectrocutionAttempt(uid, sourceUid, ref siemensCoefficient) + if (!DoCommonElectrocutionAttempt(uid, sourceUid, ref siemensCoefficient, ignoreInsulation) || !DoCommonElectrocution(uid, sourceUid, shockDamage, time, refresh, siemensCoefficient, statusEffects)) return false; RaiseLocalEvent(uid, new ElectrocutedEvent(uid, sourceUid, siemensCoefficient), true); return true; - } private bool TryDoElectrocutionPowered( @@ -281,7 +289,7 @@ namespace Content.Server.Electrocution return false; // Coefficient needs to be higher than this to do a powered electrocution! - if(siemensCoefficient <= 0.5f) + if (siemensCoefficient <= 0.5f) return DoCommonElectrocution(uid, sourceUid, shockDamage, time, refresh, siemensCoefficient, statusEffects); if (!DoCommonElectrocution(uid, sourceUid, null, time, refresh, siemensCoefficient, statusEffects)) @@ -311,9 +319,11 @@ namespace Content.Server.Electrocution return true; } - private bool DoCommonElectrocutionAttempt(EntityUid uid, EntityUid? sourceUid, ref float siemensCoefficient) + private bool DoCommonElectrocutionAttempt(EntityUid uid, EntityUid? sourceUid, ref float siemensCoefficient, bool ignoreInsulation = false) { - var attemptEvent = new ElectrocutionAttemptEvent(uid, sourceUid, siemensCoefficient); + + var attemptEvent = new ElectrocutionAttemptEvent(uid, sourceUid, siemensCoefficient, + ignoreInsulation ? SlotFlags.NONE : ~SlotFlags.POCKET); RaiseLocalEvent(uid, attemptEvent, true); // Cancel the electrocution early, so we don't recursively electrocute anything. diff --git a/Content.Shared/Electrocution/ElectrocutionEvents.cs b/Content.Shared/Electrocution/ElectrocutionEvents.cs index daefcbb74f..b7dafad1fd 100644 --- a/Content.Shared/Electrocution/ElectrocutionEvents.cs +++ b/Content.Shared/Electrocution/ElectrocutionEvents.cs @@ -4,15 +4,16 @@ namespace Content.Shared.Electrocution { public sealed class ElectrocutionAttemptEvent : CancellableEntityEventArgs, IInventoryRelayEvent { - public SlotFlags TargetSlots { get; } = ~SlotFlags.POCKET; + public SlotFlags TargetSlots { get; } public readonly EntityUid TargetUid; public readonly EntityUid? SourceUid; public float SiemensCoefficient = 1f; - public ElectrocutionAttemptEvent(EntityUid targetUid, EntityUid? sourceUid, float siemensCoefficient) + public ElectrocutionAttemptEvent(EntityUid targetUid, EntityUid? sourceUid, float siemensCoefficient, SlotFlags targetSlots) { TargetUid = targetUid; + TargetSlots = TargetSlots; SourceUid = sourceUid; SiemensCoefficient = siemensCoefficient; }