From e8320cc9d8c96eda04420e74b26b1b4802b8633c Mon Sep 17 00:00:00 2001 From: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Date: Mon, 25 Aug 2025 11:05:55 -0700 Subject: [PATCH] [Bugfix] Fix topical self healing time multiplier not working (#39883) * Commit * Fix 2 * Prettier --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> --- .../Medical/Healing/HealingComponent.cs | 2 +- .../Medical/Healing/HealingSystem.cs | 38 +++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Content.Shared/Medical/Healing/HealingComponent.cs b/Content.Shared/Medical/Healing/HealingComponent.cs index 53358fd28d..40fb180700 100644 --- a/Content.Shared/Medical/Healing/HealingComponent.cs +++ b/Content.Shared/Medical/Healing/HealingComponent.cs @@ -43,7 +43,7 @@ public sealed partial class HealingComponent : Component /// How long it takes to apply the damage. /// [DataField, AutoNetworkedField] - public float Delay = 3f; + public TimeSpan Delay = TimeSpan.FromSeconds(3f); /// /// Delay multiplier when healing yourself. diff --git a/Content.Shared/Medical/Healing/HealingSystem.cs b/Content.Shared/Medical/Healing/HealingSystem.cs index 74cb8881f4..b737914dcb 100644 --- a/Content.Shared/Medical/Healing/HealingSystem.cs +++ b/Content.Shared/Medical/Healing/HealingSystem.cs @@ -112,9 +112,17 @@ public sealed class HealingSystem : EntitySystem // Logic to determine the whether or not to repeat the healing action args.Repeat = HasDamage((args.Used.Value, healing), target) && !dontRepeat; - if (!args.Repeat && !dontRepeat) - _popupSystem.PopupClient(Loc.GetString("medical-item-finished-using", ("item", args.Used)), target.Owner, args.User); args.Handled = true; + + if (!args.Repeat) + { + _popupSystem.PopupClient(Loc.GetString("medical-item-finished-using", ("item", args.Used)), target.Owner, args.User); + return; + } + + // Update our self heal delay so it shortens as we heal more damage. + if (args.User == target.Owner) + args.Args.Delay = healing.Delay * GetScaledHealingPenalty(target.Owner, healing.SelfHealPenaltyMultiplier); } private bool HasDamage(Entity healing, Entity target) @@ -203,7 +211,7 @@ public sealed class HealingSystem : EntitySystem var delay = isNotSelf ? healing.Comp.Delay - : healing.Comp.Delay * GetScaledHealingPenalty(healing); + : healing.Comp.Delay * GetScaledHealingPenalty(target, healing.Comp.SelfHealPenaltyMultiplier); var doAfterEventArgs = new DoAfterArgs(EntityManager, user, delay, new HealingDoAfterEvent(), target, target: target, used: healing) @@ -222,21 +230,21 @@ public sealed class HealingSystem : EntitySystem /// /// Scales the self-heal penalty based on the amount of damage taken /// - /// - /// - /// - public float GetScaledHealingPenalty(Entity healing) + /// Entity we're healing + /// Maximum modifier we can have. + /// Modifier we multiply our healing time by + public float GetScaledHealingPenalty(Entity ent, float mod) { - var output = healing.Comp.Delay; - if (!TryComp(healing, out var mobThreshold) || - !TryComp(healing, out var damageable)) - return output; - if (!_mobThresholdSystem.TryGetThresholdForState(healing, MobState.Critical, out var amount, mobThreshold)) + if (!Resolve(ent, ref ent.Comp1, ref ent.Comp2, false)) + return mod; + + if (!_mobThresholdSystem.TryGetThresholdForState(ent, MobState.Critical, out var amount, ent.Comp2)) return 1; - var percentDamage = (float)(damageable.TotalDamage / amount); + var percentDamage = (float)(ent.Comp1.TotalDamage / amount); //basically make it scale from 1 to the multiplier. - var modifier = percentDamage * (healing.Comp.SelfHealPenaltyMultiplier - 1) + 1; - return Math.Max(modifier, 1); + + var output = percentDamage * (mod - 1) + 1; + return Math.Max(output, 1); } }