From e1fa07f86fdb16346281b2d0182b2f80df5e4865 Mon Sep 17 00:00:00 2001
From: No Elka <125199100+NoElkaTheGod@users.noreply.github.com>
Date: Sat, 23 Aug 2025 11:39:03 +0300
Subject: [PATCH] Deal ion damage to silicons on EMP instead of draining their
power cells (#4255)
* Change stuff
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* My changes so requested
* Why was that even here
* I can't really build so github will do it for me
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
---
Content.Server/Emp/EmpOnTriggerComponent.cs | 12 ++++++++++
Content.Server/Emp/EmpSystem.cs | 21 ++++++++++------
.../_DV/Silicons/SiliconEmpSystem.cs | 24 +++++++++++++++++++
.../_DV/Silicons/SiliconEmpComponent.cs | 7 ++++++
.../Mobs/Cyborgs/base_borg_chassis.yml | 1 +
.../Objects/Misc/subdermal_implants.yml | 3 +++
.../_EE/Entities/Mobs/Player/silicon_base.yml | 1 +
7 files changed, 62 insertions(+), 7 deletions(-)
create mode 100644 Content.Server/_DV/Silicons/SiliconEmpSystem.cs
create mode 100644 Content.Shared/_DV/Silicons/SiliconEmpComponent.cs
diff --git a/Content.Server/Emp/EmpOnTriggerComponent.cs b/Content.Server/Emp/EmpOnTriggerComponent.cs
index fac509ea9f..e7e30f4e54 100644
--- a/Content.Server/Emp/EmpOnTriggerComponent.cs
+++ b/Content.Server/Emp/EmpOnTriggerComponent.cs
@@ -1,3 +1,5 @@
+using Content.Shared.Damage; // DeltaV - EMP damage
+
namespace Content.Server.Emp;
///
@@ -21,4 +23,14 @@ public sealed partial class EmpOnTriggerComponent : Component
///
[DataField("disableDuration"), ViewVariables(VVAccess.ReadWrite)]
public float DisableDuration = 60f;
+
+ ///
+ /// 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.
+ }
+ };
}
diff --git a/Content.Server/Emp/EmpSystem.cs b/Content.Server/Emp/EmpSystem.cs
index 7b575e4b9a..09345875eb 100644
--- a/Content.Server/Emp/EmpSystem.cs
+++ b/Content.Server/Emp/EmpSystem.cs
@@ -1,4 +1,5 @@
using Content.Server.Explosion.EntitySystems;
+using Content.Shared.Damage; // DeltaV - EMP damage
using Content.Server.Power.EntitySystems;
using Content.Server.Radio;
using Content.Server.SurveillanceCamera;
@@ -41,11 +42,13 @@ public sealed class EmpSystem : SharedEmpSystem
/// The range of the EMP pulse.
/// The amount of energy consumed by the EMP pulse.
/// The duration of the EMP effects.
- public void EmpPulse(MapCoordinates coordinates, float range, float energyConsumption, float duration)
+ /// DeltaV - the damage dealt by the EMP to silicons instead of draining their power cells.
+ public void EmpPulse(MapCoordinates coordinates, float range, float energyConsumption, float duration, DamageSpecifier? damage = null)
{
+ if (damage == null) damage = new() {DamageDict = new() {{"Ion", 130}}}; // DeltaV - EMP damage
foreach (var uid in _lookup.GetEntitiesInRange(coordinates, range))
{
- TryEmpEffects(uid, energyConsumption, duration);
+ TryEmpEffects(uid, energyConsumption, duration, damage);
}
var empBlast = Spawn(EmpPulseEffectPrototype, coordinates); // Frontier: Added visual effect
@@ -64,14 +67,15 @@ public sealed class EmpSystem : SharedEmpSystem
/// The entity to apply the EMP effects on.
/// The amount of energy consumed by the EMP.
/// The duration of the EMP effects.
- public void TryEmpEffects(EntityUid uid, float energyConsumption, float duration)
+ /// DeltaV - the damage dealt by the EMP to silicons instead of draining their power cells.
+ public void TryEmpEffects(EntityUid uid, float energyConsumption, float duration, DamageSpecifier? damage = null)
{
var attemptEv = new EmpAttemptEvent();
RaiseLocalEvent(uid, attemptEv);
if (attemptEv.Cancelled)
return;
- DoEmpEffects(uid, energyConsumption, duration);
+ DoEmpEffects(uid, energyConsumption, duration, damage); // DeltaV - EMP damage
}
///
@@ -80,8 +84,10 @@ public sealed class EmpSystem : SharedEmpSystem
/// The entity to apply the EMP effects on.
/// The amount of energy consumed by the EMP.
/// The duration of the EMP effects.
- public void DoEmpEffects(EntityUid uid, float energyConsumption, float duration)
+ /// DeltaV - the damage dealt by the EMP to silicons instead of draining their power cells.
+ public void DoEmpEffects(EntityUid uid, float energyConsumption, float duration, DamageSpecifier? damage = null)
{
+ if (damage == null) damage = new() {DamageDict = new() {{"Ion", 130}}}; // DeltaV - EMP damage
var ev = new EmpPulseEvent(energyConsumption, false, false, TimeSpan.FromSeconds(duration));
RaiseLocalEvent(uid, ref ev);
if (ev.Affected)
@@ -118,7 +124,7 @@ public sealed class EmpSystem : SharedEmpSystem
private void HandleEmpTrigger(EntityUid uid, EmpOnTriggerComponent comp, TriggerEvent args)
{
- EmpPulse(_transform.GetMapCoordinates(uid), comp.Range, comp.EnergyConsumption, comp.DisableDuration);
+ EmpPulse(_transform.GetMapCoordinates(uid), comp.Range, comp.EnergyConsumption, comp.DisableDuration, comp.Damage); // DeltaV - EMP damage
args.Handled = true;
}
@@ -146,8 +152,9 @@ public sealed class EmpSystem : SharedEmpSystem
///
/// Raised on an entity before . Cancel this to prevent the emp event being raised.
///
-public sealed partial class EmpAttemptEvent : CancellableEntityEventArgs
+public sealed partial class EmpAttemptEvent(DamageSpecifier? damage = null) : CancellableEntityEventArgs // DeltaV - EMP damage
{
+ public DamageSpecifier? Damage = (damage == null) ? new() {DamageDict = new() {{"Ion", 130}}} : damage; // DeltaV - EMP damage;
}
[ByRefEvent]
diff --git a/Content.Server/_DV/Silicons/SiliconEmpSystem.cs b/Content.Server/_DV/Silicons/SiliconEmpSystem.cs
new file mode 100644
index 0000000000..8e9768a7bd
--- /dev/null
+++ b/Content.Server/_DV/Silicons/SiliconEmpSystem.cs
@@ -0,0 +1,24 @@
+using Content.Server.Emp;
+using Content.Shared.Damage;
+using Content.Shared._DV.Silicons;
+
+namespace Content.Server._DV.Silicons;
+
+public sealed class SiliconEmpSystem : EntitySystem
+{
+ [Dependency] private readonly DamageableSystem _damageable = default!;
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeLocalEvent(OnEmp);
+ }
+
+ private void OnEmp(Entity ent, ref EmpAttemptEvent args)
+ {
+ args.Cancel(); // Stop all the normal effects of the EMP
+ if (args.Damage is not { } damage) return;
+ _damageable.TryChangeDamage(ent, damage / 2, true); // 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
+ }
+}
diff --git a/Content.Shared/_DV/Silicons/SiliconEmpComponent.cs b/Content.Shared/_DV/Silicons/SiliconEmpComponent.cs
new file mode 100644
index 0000000000..f27f7e2f91
--- /dev/null
+++ b/Content.Shared/_DV/Silicons/SiliconEmpComponent.cs
@@ -0,0 +1,7 @@
+namespace Content.Shared._DV.Silicons;
+
+///
+///This components prevents the normal EMP effects on an entity, and makes it take ion damage instead
+///
+[RegisterComponent]
+public sealed partial class SiliconEmpComponent : Component;
diff --git a/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml b/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml
index 7184c2f220..a1d0ed0397 100644
--- a/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml
+++ b/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml
@@ -279,6 +279,7 @@
damage:
groups:
Electronic: -0.5
+ - type: SiliconEmp # DeltaV - EMP damage
- type: entity
abstract: true
diff --git a/Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml b/Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml
index f2908fd010..85dea4507c 100644
--- a/Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml
+++ b/Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml
@@ -183,6 +183,9 @@
range: 2.75
energyConsumption: 50000
disableDuration: 10
+ damage: # DeltaV - EMP damage
+ types:
+ Ion: 80 # Would take 2 charges if you want to actually kill with it
- type: entity
parent: BaseSubdermalImplant
diff --git a/Resources/Prototypes/_EE/Entities/Mobs/Player/silicon_base.yml b/Resources/Prototypes/_EE/Entities/Mobs/Player/silicon_base.yml
index e0af8e0812..5cc6c77be8 100644
--- a/Resources/Prototypes/_EE/Entities/Mobs/Player/silicon_base.yml
+++ b/Resources/Prototypes/_EE/Entities/Mobs/Player/silicon_base.yml
@@ -328,3 +328,4 @@
damage:
groups:
Electronic: -0.5
+ - type: SiliconEmp # DeltaV - EMP damage