diff --git a/Content.Server/Medical/DefibrillatorSystem.cs b/Content.Server/Medical/DefibrillatorSystem.cs index e821a25a44..983805e793 100644 --- a/Content.Server/Medical/DefibrillatorSystem.cs +++ b/Content.Server/Medical/DefibrillatorSystem.cs @@ -156,7 +156,7 @@ public sealed class DefibrillatorSystem : EntitySystem if (_timing.CurTime < component.NextZapTime) return false; - if (!TryComp(target, out var mobState) || _rotting.IsRotten(target)) + if (!TryComp(target, out var mobState)) return false; if (!_powerCell.HasActivatableCharge(uid, user: user)) @@ -203,40 +203,49 @@ public sealed class DefibrillatorSystem : EntitySystem if (!_powerCell.TryUseActivatableCharge(uid, user: user)) return; - _mobThreshold.SetAllowRevives(target, true, thresholds); _audio.PlayPvs(component.ZapSound, uid); _electrocution.TryDoElectrocution(target, null, component.ZapDamage, component.WritheDuration, true, ignoreInsulation: true); - - if (_mobState.IsIncapacitated(target, mob)) - _damageable.TryChangeDamage(target, component.ZapHeal, true, origin: uid); - component.NextZapTime = _timing.CurTime + component.ZapDelay; _appearance.SetData(uid, DefibrillatorVisuals.Ready, false); - _mobState.ChangeMobState(target, MobState.Critical, mob, uid); - _mobThreshold.SetAllowRevives(target, false, thresholds); IPlayerSession? session = null; - if (TryComp(target, out var mindComp) && - mindComp.Mind?.UserId != null && - _playerManager.TryGetSessionById(mindComp.Mind.UserId.Value, out session)) + + if (_rotting.IsRotten(target)) { - // notify them they're being revived. - if (mindComp.Mind.CurrentEntity != target) - { - _chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-ghosted"), - InGameICChatType.Speak, true); - _euiManager.OpenEui(new ReturnToBodyEui(mindComp.Mind), session); - } + _chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-rotten"), + InGameICChatType.Speak, true); } else { - _chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-no-mind"), - InGameICChatType.Speak, true); + if (_mobState.IsDead(target, mob)) + _damageable.TryChangeDamage(target, component.ZapHeal, true, origin: uid); + + _mobThreshold.SetAllowRevives(target, true, thresholds); + _mobState.ChangeMobState(target, MobState.Critical, mob, uid); + _mobThreshold.SetAllowRevives(target, false, thresholds); + + if (TryComp(target, out var mindComp) && + mindComp.Mind?.UserId != null && + _playerManager.TryGetSessionById(mindComp.Mind.UserId.Value, out session)) + { + // notify them they're being revived. + if (mindComp.Mind.CurrentEntity != target) + { + _chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-ghosted"), + InGameICChatType.Speak, true); + _euiManager.OpenEui(new ReturnToBodyEui(mindComp.Mind), session); + } + } + else + { + _chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-no-mind"), + InGameICChatType.Speak, true); + } } - var sound = _mobState.IsAlive(target, mob) && session != null - ? component.SuccessSound - : component.FailureSound; + var sound = _mobState.IsDead(target, mob) || session == null + ? component.FailureSound + : component.SuccessSound; _audio.PlayPvs(sound, uid); // if we don't have enough power left for another shot, turn it off diff --git a/Resources/Locale/en-US/medical/components/defibrillator.ftl b/Resources/Locale/en-US/medical/components/defibrillator.ftl index aa7c8cd708..9304a07a45 100644 --- a/Resources/Locale/en-US/medical/components/defibrillator.ftl +++ b/Resources/Locale/en-US/medical/components/defibrillator.ftl @@ -1,3 +1,4 @@ defibrillator-not-on = The defibrillator isn't turned on. -defibrillator-no-mind = No intelligence pattern can be detected in patient's brain. Further attempts futile -defibrillator-ghosted = Resuscitation failed - Mental interface error. Further attempts may be successful. \ No newline at end of file +defibrillator-no-mind = No intelligence pattern can be detected in patient's brain. Further attempts futile. +defibrillator-ghosted = Resuscitation failed - Mental interface error. Further attempts may be successful. +defibrillator-rotten = Body decomposition detected: resuscitation failed.