defib tweaks (#17167)

This commit is contained in:
Nemanja
2023-06-06 17:08:34 -04:00
committed by GitHub
parent e584b9a6ca
commit 409462df7f
2 changed files with 35 additions and 25 deletions

View File

@@ -156,7 +156,7 @@ public sealed class DefibrillatorSystem : EntitySystem
if (_timing.CurTime < component.NextZapTime) if (_timing.CurTime < component.NextZapTime)
return false; return false;
if (!TryComp<MobStateComponent>(target, out var mobState) || _rotting.IsRotten(target)) if (!TryComp<MobStateComponent>(target, out var mobState))
return false; return false;
if (!_powerCell.HasActivatableCharge(uid, user: user)) if (!_powerCell.HasActivatableCharge(uid, user: user))
@@ -203,40 +203,49 @@ public sealed class DefibrillatorSystem : EntitySystem
if (!_powerCell.TryUseActivatableCharge(uid, user: user)) if (!_powerCell.TryUseActivatableCharge(uid, user: user))
return; return;
_mobThreshold.SetAllowRevives(target, true, thresholds);
_audio.PlayPvs(component.ZapSound, uid); _audio.PlayPvs(component.ZapSound, uid);
_electrocution.TryDoElectrocution(target, null, component.ZapDamage, component.WritheDuration, true, ignoreInsulation: true); _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; component.NextZapTime = _timing.CurTime + component.ZapDelay;
_appearance.SetData(uid, DefibrillatorVisuals.Ready, false); _appearance.SetData(uid, DefibrillatorVisuals.Ready, false);
_mobState.ChangeMobState(target, MobState.Critical, mob, uid);
_mobThreshold.SetAllowRevives(target, false, thresholds);
IPlayerSession? session = null; IPlayerSession? session = null;
if (TryComp<MindComponent>(target, out var mindComp) &&
mindComp.Mind?.UserId != null && if (_rotting.IsRotten(target))
_playerManager.TryGetSessionById(mindComp.Mind.UserId.Value, out session))
{ {
// notify them they're being revived. _chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-rotten"),
if (mindComp.Mind.CurrentEntity != target) InGameICChatType.Speak, true);
{
_chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-ghosted"),
InGameICChatType.Speak, true);
_euiManager.OpenEui(new ReturnToBodyEui(mindComp.Mind), session);
}
} }
else else
{ {
_chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-no-mind"), if (_mobState.IsDead(target, mob))
InGameICChatType.Speak, true); _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<MindComponent>(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 var sound = _mobState.IsDead(target, mob) || session == null
? component.SuccessSound ? component.FailureSound
: component.FailureSound; : component.SuccessSound;
_audio.PlayPvs(sound, uid); _audio.PlayPvs(sound, uid);
// if we don't have enough power left for another shot, turn it off // if we don't have enough power left for another shot, turn it off

View File

@@ -1,3 +1,4 @@
defibrillator-not-on = The defibrillator isn't turned on. 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-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-ghosted = Resuscitation failed - Mental interface error. Further attempts may be successful.
defibrillator-rotten = Body decomposition detected: resuscitation failed.