diff --git a/Content.Server/Medical/DefibrillatorSystem.cs b/Content.Server/Medical/DefibrillatorSystem.cs
index 64861fdc515..4373532f018 100644
--- a/Content.Server/Medical/DefibrillatorSystem.cs
+++ b/Content.Server/Medical/DefibrillatorSystem.cs
@@ -162,6 +162,9 @@ public bool CanZap(EntityUid uid, EntityUid target, EntityUid? user = null, Defi
if (_mobState.IsAlive(target, mobState))
return false;
+ if (!component.CanDefibCrit && _mobState.IsCritical(target, mobState))
+ return false;
+
return true;
}
@@ -179,7 +182,8 @@ public bool TryStartZap(EntityUid uid, EntityUid target, EntityUid user, Defibri
{
BlockDuplicate = true,
BreakOnHandChange = true,
- NeedHand = true
+ NeedHand = true,
+ BreakOnMove = !component.AllowDoAfterMovement
});
}
@@ -254,6 +258,10 @@ public void Zap(EntityUid uid, EntityUid target, EntityUid user, DefibrillatorCo
// if we don't have enough power left for another shot, turn it off
if (!_powerCell.HasActivatableCharge(uid))
TryDisable(uid, component);
+
+ // TODO clean up this clown show above
+ var ev = new TargetDefibrillatedEvent(user, (uid, component));
+ RaiseLocalEvent(target, ref ev);
}
public override void Update(float frameTime)
diff --git a/Content.Shared/Medical/DefibrillatorComponent.cs b/Content.Shared/Medical/DefibrillatorComponent.cs
index 2da52852854..61a02187d09 100644
--- a/Content.Shared/Medical/DefibrillatorComponent.cs
+++ b/Content.Shared/Medical/DefibrillatorComponent.cs
@@ -60,6 +60,12 @@ public sealed partial class DefibrillatorComponent : Component
[DataField("doAfterDuration"), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan DoAfterDuration = TimeSpan.FromSeconds(3);
+ [DataField]
+ public bool AllowDoAfterMovement = true;
+
+ [DataField]
+ public bool CanDefibCrit = true;
+
///
/// The sound when someone is zapped.
///
diff --git a/Content.Shared/Medical/TargetDefibrillatedEvent.cs b/Content.Shared/Medical/TargetDefibrillatedEvent.cs
new file mode 100644
index 00000000000..60d1a215845
--- /dev/null
+++ b/Content.Shared/Medical/TargetDefibrillatedEvent.cs
@@ -0,0 +1,4 @@
+namespace Content.Shared.Medical;
+
+[ByRefEvent]
+public readonly record struct TargetDefibrillatedEvent(EntityUid User, Entity Defibrillator);