From 5092681729cadd56c6194ab42c1f7c3e96e96e6e Mon Sep 17 00:00:00 2001 From: Whatstone <166147148+whatston3@users.noreply.github.com> Date: Tue, 4 Feb 2025 22:23:30 -0500 Subject: [PATCH] HealingSystem: check blood restoration, staunching (#33526) * HealingSystem: check blood restoration, staunching * Milon's suggestions * beck-thompson's requests --- Content.Server/Medical/HealingSystem.cs | 32 ++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/Content.Server/Medical/HealingSystem.cs b/Content.Server/Medical/HealingSystem.cs index 74bce0eee6..6c1a7f2c85 100644 --- a/Content.Server/Medical/HealingSystem.cs +++ b/Content.Server/Medical/HealingSystem.cs @@ -118,15 +118,15 @@ public sealed class HealingSystem : EntitySystem _audio.PlayPvs(healing.HealingEndSound, entity.Owner, AudioHelpers.WithVariation(0.125f, _random).WithVolume(1f)); // Logic to determine the whether or not to repeat the healing action - args.Repeat = (HasDamage(entity.Comp, healing) && !dontRepeat); + args.Repeat = (HasDamage(entity, healing) && !dontRepeat); if (!args.Repeat && !dontRepeat) _popupSystem.PopupEntity(Loc.GetString("medical-item-finished-using", ("item", args.Used)), entity.Owner, args.User); args.Handled = true; } - private bool HasDamage(DamageableComponent component, HealingComponent healing) + private bool HasDamage(Entity ent, HealingComponent healing) { - var damageableDict = component.Damage.DamageDict; + var damageableDict = ent.Comp.Damage.DamageDict; var healingDict = healing.Damage.DamageDict; foreach (var type in healingDict) { @@ -136,6 +136,23 @@ public sealed class HealingSystem : EntitySystem } } + if (TryComp(ent, out var bloodstream)) + { + // Is ent missing blood that we can restore? + if (healing.ModifyBloodLevel > 0 + && _solutionContainerSystem.ResolveSolution(ent.Owner, bloodstream.BloodSolutionName, ref bloodstream.BloodSolution, out var bloodSolution) + && bloodSolution.Volume < bloodSolution.MaxVolume) + { + return true; + } + + // Is ent bleeding and can we stop it? + if (healing.BloodlossModifier < 0 && bloodstream.BleedAmount > 0) + { + return true; + } + } + return false; } @@ -175,14 +192,7 @@ public sealed class HealingSystem : EntitySystem if (TryComp(uid, out var stack) && stack.Count < 1) return false; - var anythingToDo = - HasDamage(targetDamage, component) || - component.ModifyBloodLevel > 0 // Special case if healing item can restore lost blood... - && TryComp(target, out var bloodstream) - && _solutionContainerSystem.ResolveSolution(target, bloodstream.BloodSolutionName, ref bloodstream.BloodSolution, out var bloodSolution) - && bloodSolution.Volume < bloodSolution.MaxVolume; // ...and there is lost blood to restore. - - if (!anythingToDo) + if (!HasDamage((target, targetDamage), component)) { _popupSystem.PopupEntity(Loc.GetString("medical-item-cant-use", ("item", uid)), uid, user); return false;