]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
[Bugfix] Fix topical self healing time multiplier not working (#39883)
authorPrincess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com>
Mon, 25 Aug 2025 18:05:55 +0000 (11:05 -0700)
committerGitHub <noreply@github.com>
Mon, 25 Aug 2025 18:05:55 +0000 (11:05 -0700)
* Commit

* Fix 2

* Prettier

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Content.Shared/Medical/Healing/HealingComponent.cs
Content.Shared/Medical/Healing/HealingSystem.cs

index 53358fd28d9816b90007ecec58c4fef073beb6b8..40fb1807002af4d302c58e5fbdcb353c99e63bdb 100644 (file)
@@ -43,7 +43,7 @@ public sealed partial class HealingComponent : Component
     /// How long it takes to apply the damage.
     /// </summary>
     [DataField, AutoNetworkedField]
-    public float Delay = 3f;
+    public TimeSpan Delay = TimeSpan.FromSeconds(3f);
 
     /// <summary>
     /// Delay multiplier when healing yourself.
index 74cb8881f485c10dcf1d961b034ffad6721ea033..b737914dcba9be941b2465df728ceabd104f2a91 100644 (file)
@@ -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<HealingComponent> healing, Entity<DamageableComponent> 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
     /// <summary>
     /// Scales the self-heal penalty based on the amount of damage taken
     /// </summary>
-    /// <param name="uid"></param>
-    /// <param name="component"></param>
-    /// <returns></returns>
-    public float GetScaledHealingPenalty(Entity<HealingComponent> healing)
+    /// <param name="ent">Entity we're healing</param>
+    /// <param name="mod">Maximum modifier we can have.</param>
+    /// <returns>Modifier we multiply our healing time by</returns>
+    public float GetScaledHealingPenalty(Entity<DamageableComponent?, MobThresholdsComponent?> ent, float mod)
     {
-        var output = healing.Comp.Delay;
-        if (!TryComp<MobThresholdsComponent>(healing, out var mobThreshold) ||
-            !TryComp<DamageableComponent>(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);
     }
 }