Files
wwdpublic/Content.Server/Traits/Assorted/KillOnDamageSystem.cs
GNUtopia d1fa7e1711 Even More IPC Negative Traits (#2335)
# Description

Adds two new IPC-exclusive negative traits. For 3 points, Faulty
Waterproofing makes you take shock damage when splashed with or slipping
in water, similarly to slimes. For 4 points, Fragile Circuits makes you
shut down whenever you take shock damage. (yes, you can make it so that
you instantly die for slipping in a puddle)

---

<details><summary><h1>Media</h1></summary>
<p>

![Traits
menu](https://github.com/user-attachments/assets/56b5b973-95f0-41b8-9e42-f04b1153e175)
![Fragile Circuits
description](https://github.com/user-attachments/assets/4a475c82-9685-41ea-98f6-c74522fae298)
![Faulty Waterproofing
description](https://github.com/user-attachments/assets/a9d5dde0-9e6b-40bc-9b56-020f44fc3879)
![High-stakes wire punching with Fragile
Circuits](https://github.com/user-attachments/assets/6fe971cf-85f3-4e93-8046-673a5751644a)
![Faulty Waterproofing damage
example](https://github.com/user-attachments/assets/ce1b32b9-1cd4-40ba-9237-b4290b551b73)

</p>
</details>

---

# Changelog

🆑
- add: Added Faulty Waterproofing trait
- add: Added Fragile Circuits trait

---------

Signed-off-by: GNUtopia <93669372+GNUtopia@users.noreply.github.com>
(cherry picked from commit 1bb6518b24a9f939686db0d08908ec6618145235)
2025-05-16 20:06:55 +03:00

34 lines
1.2 KiB
C#

using Content.Shared.Mobs;
using Content.Shared.Mobs.Systems;
using Content.Shared.Popups;
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
using Content.Shared.IdentityManagement;
using Content.Shared.Mobs.Components;
namespace Content.Server.Traits.Assorted;
public sealed class KillOnDamageSystem : EntitySystem
{
[Dependency] private readonly MobStateSystem _mob = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
public override void Initialize()
{
SubscribeLocalEvent<KillOnDamageComponent, DamageChangedEvent>(OnDamageChanged);
}
private void OnDamageChanged(EntityUid uid, KillOnDamageComponent component, DamageChangedEvent args)
{
if (!TryComp<MobStateComponent>(uid, out var mobState))
return;
if (!_mob.IsDead(uid) && !(args.DamageDelta == null) && args.DamageDelta.DamageDict.TryGetValue(component.DamageType, out FixedPoint2 value) && value >= component.Threshold)
{
var popup = Loc.GetString(component.Popup, ("name", Identity.Name(uid, EntityManager)));
_popup.PopupEntity(popup, uid, PopupType.LargeCaution);
_mob.ChangeMobState(uid, MobState.Dead, mobState);
}
}
}