diff --git a/Content.Shared/Emp/SharedEmpSystem.cs b/Content.Shared/Emp/SharedEmpSystem.cs index ef2d3ddacb..481a93735a 100644 --- a/Content.Shared/Emp/SharedEmpSystem.cs +++ b/Content.Shared/Emp/SharedEmpSystem.cs @@ -24,6 +24,8 @@ public abstract class SharedEmpSystem : EntitySystem [Dependency] private readonly SharedPvsOverrideSystem _pvs = default!; // Frontier [Dependency] private readonly IConfigurationManager _cfg = default!; // Frontier: EMP Blast PVS + private readonly DamageSpecifier? _defaultEmpDamage = new() { DamageDict = new() { { "Ion", 130 } } }; // DeltaV - EMP damage + private HashSet _entSet = new(); public override void Initialize() @@ -47,13 +49,13 @@ public abstract class SharedEmpSystem : EntitySystem /// The amount of energy consumed by the EMP pulse. In Joule. /// The duration of the EMP effects. /// The player that caused the effect. Used for predicted audio. - public void EmpPulse(MapCoordinates mapCoordinates, float range, float energyConsumption, TimeSpan duration, EntityUid? user = null) + public void EmpPulse(MapCoordinates mapCoordinates, float range, float energyConsumption, TimeSpan duration, EntityUid? user = null, DamageSpecifier? damage = null) // DeltaV - Add Ion Damage { foreach (var uid in _lookup.GetEntitiesInRange(mapCoordinates, range)) { - TryEmpEffects(uid, energyConsumption, duration, user); + TryEmpEffects(uid, energyConsumption, duration, user, damage ?? _defaultEmpDamage); // DeltaV - Add Ion Damage } - // TODO: replace with PredictedSpawn once it works with animated sprites + // TODO: replace with PredictedSpawn once it works with animated sprites if (_net.IsServer) { @@ -79,13 +81,13 @@ public abstract class SharedEmpSystem : EntitySystem /// The amount of energy consumed by the EMP pulse. /// The duration of the EMP effects. /// The player that caused the effect. Used for predicted audio. - public void EmpPulse(EntityCoordinates coordinates, float range, float energyConsumption, TimeSpan duration, EntityUid? user = null) + public void EmpPulse(EntityCoordinates coordinates, float range, float energyConsumption, TimeSpan duration, EntityUid? user = null, DamageSpecifier? damage = null) // DeltaV - Add Ion Damage { _entSet.Clear(); _lookup.GetEntitiesInRange(coordinates, range, _entSet); foreach (var uid in _entSet) { - TryEmpEffects(uid, energyConsumption, duration, user); + TryEmpEffects(uid, energyConsumption, duration, user, damage ?? _defaultEmpDamage); // DeltaV - Add Ion Damage } // TODO: replace with PredictedSpawn once it works with animated sprites if (_net.IsServer) @@ -111,14 +113,14 @@ public abstract class SharedEmpSystem : EntitySystem /// The duration of the EMP effects. /// The player that caused the EMP. For prediction purposes. /// If the entity was affected by the EMP. - public bool TryEmpEffects(EntityUid uid, float energyConsumption, TimeSpan duration, EntityUid? user = null) + public bool TryEmpEffects(EntityUid uid, float energyConsumption, TimeSpan duration, EntityUid? user = null, DamageSpecifier? damage = null) // DeltaV - Add Ion Damage { var attemptEv = new EmpAttemptEvent(); RaiseLocalEvent(uid, ref attemptEv); if (attemptEv.Cancelled) return false; - return DoEmpEffects(uid, energyConsumption, duration, user); + return DoEmpEffects(uid, energyConsumption, duration, user, damage); // DeltaV - Add Ion Damage } /// @@ -129,9 +131,9 @@ public abstract class SharedEmpSystem : EntitySystem /// The duration of the EMP effects. /// The player that caused the EMP. For prediction purposes. /// If the entity was affected by the EMP. - public bool DoEmpEffects(EntityUid uid, float energyConsumption, TimeSpan duration, EntityUid? user = null) + public bool DoEmpEffects(EntityUid uid, float energyConsumption, TimeSpan duration, EntityUid? user = null, DamageSpecifier? damage = null) // DeltaV - Add Ion Damage { - var ev = new EmpPulseEvent(energyConsumption, false, false, duration, user); + var ev = new EmpPulseEvent(energyConsumption, false, false, duration, user, damage); // DeltaV - Add Ion Damage RaiseLocalEvent(uid, ref ev); // TODO: replace with PredictedSpawn once it works with animated sprites diff --git a/Content.Shared/PowerCell/SharedPowerCellSystem.cs b/Content.Shared/PowerCell/SharedPowerCellSystem.cs index 0b71a3c24d..651ccbe068 100644 --- a/Content.Shared/PowerCell/SharedPowerCellSystem.cs +++ b/Content.Shared/PowerCell/SharedPowerCellSystem.cs @@ -1,3 +1,4 @@ +using Content.Shared._DV.Silicons; using Content.Shared.Containers.ItemSlots; using Content.Shared.Emp; using Content.Shared.PowerCell.Components; @@ -12,6 +13,8 @@ public abstract class SharedPowerCellSystem : EntitySystem [Dependency] protected readonly IGameTiming Timing = default!; [Dependency] private readonly ItemSlotsSystem _itemSlots = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly SharedSiliconEmpSystem _siliconEmp = default!; + public override void Initialize() { @@ -77,6 +80,10 @@ public abstract class SharedPowerCellSystem : EntitySystem private void OnCellEmpAttempt(EntityUid uid, PowerCellComponent component, EmpAttemptEvent args) { var parent = Transform(uid).ParentUid; + + if (_siliconEmp.ShouldTakeDamageInsteadOfPowerDrain(parent)) // DeltaV - Silicon EMP + return; + // relay the attempt event to the slot so it can cancel it if (HasComp(parent)) RaiseLocalEvent(parent, ref args); diff --git a/Content.Shared/Trigger/Components/Effects/EmpOnTriggerComponent.cs b/Content.Shared/Trigger/Components/Effects/EmpOnTriggerComponent.cs index 2c4ff36187..a9e5294348 100644 --- a/Content.Shared/Trigger/Components/Effects/EmpOnTriggerComponent.cs +++ b/Content.Shared/Trigger/Components/Effects/EmpOnTriggerComponent.cs @@ -32,10 +32,6 @@ public sealed partial class EmpOnTriggerComponent : BaseXOnTriggerComponent /// /// DeltaV - The damage dealt to silicons instead of draining their power cells /// - [DataField] - public DamageSpecifier Damage = new() { - DamageDict = new() { - { "Ion", 130 } // Most EMP sources should pretty much oneshot silicons. This would kill an IPC and completely disable a borg for a minute. - } - }; + [DataField, AutoNetworkedField] + public DamageSpecifier? Damage; } diff --git a/Content.Shared/Trigger/Systems/EmpOnTriggerSystem.cs b/Content.Shared/Trigger/Systems/EmpOnTriggerSystem.cs index 50fb7a25e4..cd68f8a898 100644 --- a/Content.Shared/Trigger/Systems/EmpOnTriggerSystem.cs +++ b/Content.Shared/Trigger/Systems/EmpOnTriggerSystem.cs @@ -24,7 +24,7 @@ public sealed class EmpOnTriggerSystem : EntitySystem if (target == null) return; - _emp.EmpPulse(Transform(target.Value).Coordinates, ent.Comp.Range, ent.Comp.EnergyConsumption, ent.Comp.DisableDuration, args.User); + _emp.EmpPulse(Transform(target.Value).Coordinates, ent.Comp.Range, ent.Comp.EnergyConsumption, ent.Comp.DisableDuration, args.User, ent.Comp.Damage); // DeltaV - Silicon damage args.Handled = true; } } diff --git a/Content.Shared/_DV/Silicons/SharedSiliconEmpSystem.cs b/Content.Shared/_DV/Silicons/SharedSiliconEmpSystem.cs index 82a9de9826..100ce8769e 100644 --- a/Content.Shared/_DV/Silicons/SharedSiliconEmpSystem.cs +++ b/Content.Shared/_DV/Silicons/SharedSiliconEmpSystem.cs @@ -8,6 +8,19 @@ public abstract class SharedSiliconEmpSystem : EntitySystem { [Dependency] private readonly DamageableSystem _damageable = default!; + /// + /// If the entity has the , then it should take damage instead of draining its battery. + /// + /// The entity to check + /// true if the entity has + public bool ShouldTakeDamageInsteadOfPowerDrain(Entity entity) + { + if (!Resolve(entity, ref entity.Comp, false)) + return false; + + return true; + } + public override void Initialize() { base.Initialize(); @@ -17,7 +30,9 @@ public abstract class SharedSiliconEmpSystem : EntitySystem private void OnEmpPulse(Entity ent, ref EmpPulseEvent args) { - if (args.Damage is not { } damage) return; - _damageable.TryChangeDamage(ent, damage / 2, false); // Damage is divided by 2 because the event is raised twice (once from entity itself, and another is relayed from it's power cell) and I'm too lazy for an actual fix - NoElka | Make EMP not ignore armor. + if (args.Damage is not { } damage) + return; + + _damageable.TryChangeDamage(ent, damage, false); } } diff --git a/Resources/Prototypes/_NF/Entities/Effects/emp.yml b/Resources/Prototypes/_NF/Entities/Effects/emp.yml index 24e775744e..cda1583cdd 100644 --- a/Resources/Prototypes/_NF/Entities/Effects/emp.yml +++ b/Resources/Prototypes/_NF/Entities/Effects/emp.yml @@ -10,7 +10,4 @@ - type: Tag tags: - HideContextMenu - - type: EmitSoundOnSpawn - sound: - path: /Audio/Effects/Lightning/lightningbolt.ogg - type: AnimationPlayer