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>
This commit is contained in:
parent
8abcbc6a76
commit
e1fa07f86f
|
|
@ -1,3 +1,5 @@
|
|||
using Content.Shared.Damage; // DeltaV - EMP damage
|
||||
|
||||
namespace Content.Server.Emp;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -21,4 +23,14 @@ public sealed partial class EmpOnTriggerComponent : Component
|
|||
/// </summary>
|
||||
[DataField("disableDuration"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public float DisableDuration = 60f;
|
||||
|
||||
/// <summary>
|
||||
/// DeltaV - The damage dealt to silicons instead of draining their power cells
|
||||
/// </summary>
|
||||
[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.
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
|||
/// <param name="range">The range of the EMP pulse.</param>
|
||||
/// <param name="energyConsumption">The amount of energy consumed by the EMP pulse.</param>
|
||||
/// <param name="duration">The duration of the EMP effects.</param>
|
||||
public void EmpPulse(MapCoordinates coordinates, float range, float energyConsumption, float duration)
|
||||
/// <param name="damage">DeltaV - the damage dealt by the EMP to silicons instead of draining their power cells.</param>
|
||||
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
|
|||
/// <param name="uid">The entity to apply the EMP effects on.</param>
|
||||
/// <param name="energyConsumption">The amount of energy consumed by the EMP.</param>
|
||||
/// <param name="duration">The duration of the EMP effects.</param>
|
||||
public void TryEmpEffects(EntityUid uid, float energyConsumption, float duration)
|
||||
/// <param name="damage">DeltaV - the damage dealt by the EMP to silicons instead of draining their power cells.</param>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -80,8 +84,10 @@ public sealed class EmpSystem : SharedEmpSystem
|
|||
/// <param name="uid">The entity to apply the EMP effects on.</param>
|
||||
/// <param name="energyConsumption">The amount of energy consumed by the EMP.</param>
|
||||
/// <param name="duration">The duration of the EMP effects.</param>
|
||||
public void DoEmpEffects(EntityUid uid, float energyConsumption, float duration)
|
||||
/// <param name="damage">DeltaV - the damage dealt by the EMP to silicons instead of draining their power cells.</param>
|
||||
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
|
|||
/// <summary>
|
||||
/// Raised on an entity before <see cref="EmpPulseEvent"/>. Cancel this to prevent the emp event being raised.
|
||||
/// </summary>
|
||||
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]
|
||||
|
|
|
|||
|
|
@ -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<SiliconEmpComponent, EmpAttemptEvent>(OnEmp);
|
||||
}
|
||||
|
||||
private void OnEmp(Entity<SiliconEmpComponent> 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
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
namespace Content.Shared._DV.Silicons;
|
||||
|
||||
///<summary>
|
||||
///This components prevents the normal EMP effects on an entity, and makes it take ion damage instead
|
||||
///</summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class SiliconEmpComponent : Component;
|
||||
|
|
@ -279,6 +279,7 @@
|
|||
damage:
|
||||
groups:
|
||||
Electronic: -0.5
|
||||
- type: SiliconEmp # DeltaV - EMP damage
|
||||
|
||||
- type: entity
|
||||
abstract: true
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -328,3 +328,4 @@
|
|||
damage:
|
||||
groups:
|
||||
Electronic: -0.5
|
||||
- type: SiliconEmp # DeltaV - EMP damage
|
||||
|
|
|
|||
Loading…
Reference in New Issue