Skip to content

Commit

Permalink
nerf delayed death
Browse files Browse the repository at this point in the history
  • Loading branch information
deltanedas committed Jan 15, 2025
1 parent 7ca7d9c commit 5eb606d
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions Content.Server/_Shitmed/DelayedDeath/DelayedDeathSystem.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Medical;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Shared.Prototypes;

namespace Content.Server._Shitmed.DelayedDeath;

public partial class DelayedDeathSystem : EntitySystem
{
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly IPrototypeManager _prototypes = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<DelayedDeathComponent, TargetBeforeDefibrillatorZapsEvent>(OnDefibZap);
}

public override void Update(float frameTime)
{
base.Update(frameTime);

using var query = EntityQueryEnumerator<DelayedDeathComponent>();
while (query.MoveNext(out var ent, out var component))
using var query = EntityQueryEnumerator<DelayedDeathComponent, MobStateComponent>();
while (query.MoveNext(out var ent, out var comp, out var mob))
{
component.DeathTimer += frameTime;
comp.DeathTimer += frameTime;

if (component.DeathTimer >= component.DeathTime && !_mobState.IsDead(ent))
if (comp.DeathTimer >= comp.DeathTime && !_mobState.IsDead(ent, mob))
{
var damage = new DamageSpecifier(_prototypes.Index<DamageTypePrototype>("Bloodloss"), 150);
_damageable.TryChangeDamage(ent, damage, partMultiplier: 0f);
// go crit then dead so deathgasp can happen
_mobState.ChangeMobState(ent, MobState.Critical, mob);
_mobState.ChangeMobState(ent, MobState.Dead, mob);
}
}
}

private void OnDefibZap(Entity<DelayedDeathComponent> ent, ref TargetBeforeDefibrillatorZapsEvent args)
{
// can't defib someone without a heart or brain pal
args.Cancel();
}
}

0 comments on commit 5eb606d

Please sign in to comment.