[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>
This commit is contained in:
committed by
GitHub
parent
ffc7cc5e5d
commit
e8320cc9d8
@@ -43,7 +43,7 @@ public sealed partial class HealingComponent : Component
|
|||||||
/// How long it takes to apply the damage.
|
/// How long it takes to apply the damage.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField, AutoNetworkedField]
|
[DataField, AutoNetworkedField]
|
||||||
public float Delay = 3f;
|
public TimeSpan Delay = TimeSpan.FromSeconds(3f);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delay multiplier when healing yourself.
|
/// Delay multiplier when healing yourself.
|
||||||
|
|||||||
@@ -112,9 +112,17 @@ public sealed class HealingSystem : EntitySystem
|
|||||||
|
|
||||||
// Logic to determine the whether or not to repeat the healing action
|
// Logic to determine the whether or not to repeat the healing action
|
||||||
args.Repeat = HasDamage((args.Used.Value, healing), target) && !dontRepeat;
|
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;
|
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)
|
private bool HasDamage(Entity<HealingComponent> healing, Entity<DamageableComponent> target)
|
||||||
@@ -203,7 +211,7 @@ public sealed class HealingSystem : EntitySystem
|
|||||||
|
|
||||||
var delay = isNotSelf
|
var delay = isNotSelf
|
||||||
? healing.Comp.Delay
|
? healing.Comp.Delay
|
||||||
: healing.Comp.Delay * GetScaledHealingPenalty(healing);
|
: healing.Comp.Delay * GetScaledHealingPenalty(target, healing.Comp.SelfHealPenaltyMultiplier);
|
||||||
|
|
||||||
var doAfterEventArgs =
|
var doAfterEventArgs =
|
||||||
new DoAfterArgs(EntityManager, user, delay, new HealingDoAfterEvent(), target, target: target, used: healing)
|
new DoAfterArgs(EntityManager, user, delay, new HealingDoAfterEvent(), target, target: target, used: healing)
|
||||||
@@ -222,21 +230,21 @@ public sealed class HealingSystem : EntitySystem
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Scales the self-heal penalty based on the amount of damage taken
|
/// Scales the self-heal penalty based on the amount of damage taken
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uid"></param>
|
/// <param name="ent">Entity we're healing</param>
|
||||||
/// <param name="component"></param>
|
/// <param name="mod">Maximum modifier we can have.</param>
|
||||||
/// <returns></returns>
|
/// <returns>Modifier we multiply our healing time by</returns>
|
||||||
public float GetScaledHealingPenalty(Entity<HealingComponent> healing)
|
public float GetScaledHealingPenalty(Entity<DamageableComponent?, MobThresholdsComponent?> ent, float mod)
|
||||||
{
|
{
|
||||||
var output = healing.Comp.Delay;
|
if (!Resolve(ent, ref ent.Comp1, ref ent.Comp2, false))
|
||||||
if (!TryComp<MobThresholdsComponent>(healing, out var mobThreshold) ||
|
return mod;
|
||||||
!TryComp<DamageableComponent>(healing, out var damageable))
|
|
||||||
return output;
|
if (!_mobThresholdSystem.TryGetThresholdForState(ent, MobState.Critical, out var amount, ent.Comp2))
|
||||||
if (!_mobThresholdSystem.TryGetThresholdForState(healing, MobState.Critical, out var amount, mobThreshold))
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
var percentDamage = (float)(damageable.TotalDamage / amount);
|
var percentDamage = (float)(ent.Comp1.TotalDamage / amount);
|
||||||
//basically make it scale from 1 to the multiplier.
|
//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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user