From 75caa105e647e78962d49828a920cd93ab1e04ed Mon Sep 17 00:00:00 2001 From: Sir Warock <67167466+SirWarock@users.noreply.github.com> Date: Tue, 9 Sep 2025 00:11:48 +0200 Subject: [PATCH] Fix limb healing on evenhealing (#4315) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix EvenHealing on bodyParts (#1469) Fixed EvenHealing not working on limb damage when there was no general damage. When you had a massively burned victim, healing them via aloxadone would heal their general damage, and each limb profited half of that general healing. However, as soon as the general damage was healed, Aloxadone wasn't outputting any healing anymore, since even healing is dependent on damage types on the general damage - And thus, with no healing, the limbs couldn't benefit anymore. This is wrong. I fixed it. Separated the healing of the general damage and limb damage, they are independent of each other. Healing General Damage won't heal limb damage and vice versa. Added a way to heal each limb specifically. I tested it thoroughly, and generally, it worked. Either with multiple different damage types, or just one. Multiple damage parts, or just one. Very much encourage to find a more elegant technical solution. I can't do videos, but videos would be required. Please try it out yourself. - [X] I have read and am following the [Pull Request and Changelog Guidelines](https://docs.spacestation14.com/en/general-development/codebase-info/pull-request-guidelines.html). - [X] I have added media to this PR or it does not require an ingame showcase. - [X] I can confirm this PR contains no AI-generated content, and did not use any AI-generated content. **Changelog** :cl: - fix: Fixed Chemicals with the EvenHealing attribute to not work on patient's limbs without General Damage. Aloxadone will now finally heal the burned Salvager's limbs. * Fix Port to Delta * Fixes * Made comments even more commenty? Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> * Update Content.Shared/Damage/Systems/DamageableSystem.cs Co-authored-by: Quanteey <61941975+Quanteey@users.noreply.github.com> Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> * Add Comments * Update Content.Shared/EntityEffects/Effects/EvenHealthChange.cs Co-authored-by: Quanteey <61941975+Quanteey@users.noreply.github.com> Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> * Update Content.Shared/Damage/Systems/DamageableSystem.cs Co-authored-by: Quanteey <61941975+Quanteey@users.noreply.github.com> Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> * Fix Comments * Update Content.Shared/EntityEffects/Effects/EvenHealthChange.cs Co-authored-by: Quanteey <61941975+Quanteey@users.noreply.github.com> Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> * commenty commenta WHEN DO THE COMMENTS END --------- Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> Co-authored-by: Quanteey <61941975+Quanteey@users.noreply.github.com> --- .../Damage/Systems/DamageableSystem.cs | 23 +++--- .../EntityEffects/Effects/EvenHealthChange.cs | 74 ++++++++++++------- 2 files changed, 62 insertions(+), 35 deletions(-) diff --git a/Content.Shared/Damage/Systems/DamageableSystem.cs b/Content.Shared/Damage/Systems/DamageableSystem.cs index 5786f3ca9c..0e5caa1bee 100644 --- a/Content.Shared/Damage/Systems/DamageableSystem.cs +++ b/Content.Shared/Damage/Systems/DamageableSystem.cs @@ -181,7 +181,7 @@ namespace Content.Shared.Damage public DamageSpecifier? TryChangeDamage(EntityUid? uid, DamageSpecifier damage, bool ignoreResistances = false, bool interruptsDoAfters = true, DamageableComponent? damageable = null, EntityUid? origin = null, // Shitmed Change - bool? canSever = true, bool? canEvade = false, float? partMultiplier = 1.00f, TargetBodyPart? targetPart = null) + bool? canSever = true, bool? canEvade = false, float? partMultiplier = 1.00f, TargetBodyPart? targetPart = null, bool doPartDamage = true, bool onlyDamageParts = false) // DeltaV - Fix EvenHealing on Limbs. { if (!uid.HasValue || !_damageableQuery.Resolve(uid.Value, ref damageable, false)) { @@ -194,20 +194,24 @@ namespace Content.Shared.Damage return damage; } + damage = ApplyUniversalAllModifiers(damage); // DeltaV - Fix EvenHealing with Limbs. + var before = new BeforeDamageChangedEvent(damage, origin, targetPart); // Shitmed Change RaiseLocalEvent(uid.Value, ref before); if (before.Cancelled) return null; - // Shitmed Change Start - var partDamage = new TryChangePartDamageEvent(damage, origin, targetPart, ignoreResistances, canSever ?? true, canEvade ?? false, partMultiplier ?? 1.00f); - RaiseLocalEvent(uid.Value, ref partDamage); + if (doPartDamage) // DeltaV - Fix EvenHealing with Limbs. + { + // ShitMed Start + var partDamage = new TryChangePartDamageEvent(damage, origin, targetPart, ignoreResistances, canSever ?? true, canEvade ?? false, partMultiplier ?? 1.00f); + RaiseLocalEvent(uid.Value, ref partDamage); - if (partDamage.Evaded || partDamage.Cancelled) - return null; - - // Shitmed Change End + if (partDamage.Evaded || partDamage.Cancelled) + return null; + //ShitMed End + } // Apply resistances if (!ignoreResistances) @@ -231,7 +235,8 @@ namespace Content.Shared.Damage } } - damage = ApplyUniversalAllModifiers(damage); + if (onlyDamageParts) // DeltaV - Fix EvenHealing with Limbs. + return null; // TODO DAMAGE PERFORMANCE // Consider using a local private field instead of creating a new dictionary here. diff --git a/Content.Shared/EntityEffects/Effects/EvenHealthChange.cs b/Content.Shared/EntityEffects/Effects/EvenHealthChange.cs index 968d559939..7cbc48ba98 100644 --- a/Content.Shared/EntityEffects/Effects/EvenHealthChange.cs +++ b/Content.Shared/EntityEffects/Effects/EvenHealthChange.cs @@ -1,3 +1,8 @@ +// DeltaV Start - Fix EvenHealing with Limbs. +using System.Linq; +using Content.Shared._Shitmed.Targeting; +using Content.Shared.Body.Systems; +// DeltaV End - Fix EvenHealing with Limbs. using Content.Shared.Damage; using Content.Shared.Damage.Prototypes; using Content.Shared.EntityEffects; @@ -91,10 +96,47 @@ public sealed partial class EvenHealthChange : EntityEffect } var damagableSystem = args.EntityManager.System(); - var universalReagentDamageModifier = damagableSystem.UniversalReagentDamageModifier; - var universalReagentHealModifier = damagableSystem.UniversalReagentHealModifier; + var dspec = GetDamageSpec(protoMan, damageable); // DeltaV - Fix EvenHealing with Limbs. - var dspec = new DamageSpecifier(); + damagableSystem.TryChangeDamage( + args.TargetEntity, + dspec * scale, + IgnoreResistances, + interruptsDoAfters: false, + doPartDamage: false); // DeltaV - Fix EvenHealing with Limbs. + + // DeltaV Start - Fix EvenHealing with Limbs. + var bodySystem = args.EntityManager.System(); + var bodyParts = SharedTargetingSystem.GetValidParts(); + foreach (var bodyPart in bodyParts) + { + var (targetType, targetSymmetry) = bodySystem.ConvertTargetBodyPart(bodyPart); + if (bodySystem.GetBodyChildrenOfType(args.TargetEntity, targetType, symmetry: targetSymmetry) is { } part) + { + if (!args.EntityManager.TryGetComponent(part.FirstOrDefault().Id, out var damageablePart)) + continue; + dspec = GetDamageSpec(protoMan, damageablePart); + + if (dspec.GetTotal() == 0) + continue; + + damagableSystem.TryChangeDamage( + args.TargetEntity, + dspec * scale, + IgnoreResistances, + interruptsDoAfters: false, + targetPart: bodyPart, + onlyDamageParts: true, + partMultiplier: 0.5f, + canSever: false); + } + } + // DeltaV End - Fix EvenHealing with Limbs. + } + + private DamageSpecifier GetDamageSpec(IPrototypeManager protoMan, DamageableComponent damageable) // DeltaV - Fix EvenHealing with Limbs. + { + var damageSpecifier = new DamageSpecifier(); // DeltaV - Fix EvenHealing with Limbs. foreach (var (group, amount) in Damage) { @@ -110,30 +152,10 @@ public sealed partial class EvenHealthChange : EntityEffect var sum = groupDamage.Values.Sum(); foreach (var (damageId, damageAmount) in groupDamage) { - var existing = dspec.DamageDict.GetOrNew(damageId); - dspec.DamageDict[damageId] = existing + damageAmount / sum * amount; + var existing = damageSpecifier.DamageDict.GetOrNew(damageId); // DeltaV - Fix EvenHealing with Limbs. + damageSpecifier.DamageDict[damageId] = existing + damageAmount / sum * amount; // DeltaV - Fix EvenHealing with Limbs. } } - - if (universalReagentDamageModifier != 1 || universalReagentHealModifier != 1) - { - foreach (var (type, val) in dspec.DamageDict) - { - if (val < 0f) - { - dspec.DamageDict[type] = val * universalReagentHealModifier; - } - if (val > 0f) - { - dspec.DamageDict[type] = val * universalReagentDamageModifier; - } - } - } - - damagableSystem.TryChangeDamage( - args.TargetEntity, - dspec * scale, - IgnoreResistances, - interruptsDoAfters: false); + return damageSpecifier; // DeltaV - Fix EvenHealing with Limbs. } }