Healing tweaks (#9697)
This commit is contained in:
@@ -39,6 +39,12 @@ namespace Content.Server.Medical.Components
|
|||||||
[DataField("delay")]
|
[DataField("delay")]
|
||||||
public float Delay = 3f;
|
public float Delay = 3f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delay multiplier when healing yourself.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("selfHealPenaltyMultiplier")]
|
||||||
|
public float SelfHealPenaltyMultiplier = 3f;
|
||||||
|
|
||||||
public CancellationTokenSource? CancelToken = null;
|
public CancellationTokenSource? CancelToken = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ using Content.Server.Body.Systems;
|
|||||||
using Content.Server.DoAfter;
|
using Content.Server.DoAfter;
|
||||||
using Content.Server.Medical.Components;
|
using Content.Server.Medical.Components;
|
||||||
using Content.Server.Stack;
|
using Content.Server.Stack;
|
||||||
|
using Content.Server.MobState;
|
||||||
using Content.Shared.Audio;
|
using Content.Shared.Audio;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.MobState.Components;
|
|
||||||
using Content.Shared.Stacks;
|
using Content.Shared.Stacks;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
@@ -24,6 +24,7 @@ public sealed class HealingSystem : EntitySystem
|
|||||||
[Dependency] private readonly DoAfterSystem _doAfter = default!;
|
[Dependency] private readonly DoAfterSystem _doAfter = default!;
|
||||||
[Dependency] private readonly StackSystem _stacks = default!;
|
[Dependency] private readonly StackSystem _stacks = default!;
|
||||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||||
|
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -36,7 +37,7 @@ public sealed class HealingSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnHealingComplete(EntityUid uid, DamageableComponent component, HealingCompleteEvent args)
|
private void OnHealingComplete(EntityUid uid, DamageableComponent component, HealingCompleteEvent args)
|
||||||
{
|
{
|
||||||
if (TryComp<MobStateComponent>(uid, out var state) && state.IsDead())
|
if (_mobStateSystem.IsDead(uid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (TryComp<StackComponent>(args.Component.Owner, out var stack) && stack.Count < 1) return;
|
if (TryComp<StackComponent>(args.Component.Owner, out var stack) && stack.Count < 1) return;
|
||||||
@@ -97,12 +98,15 @@ public sealed class HealingSystem : EntitySystem
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TryComp<MobStateComponent>(target, out var state) && state.IsDead())
|
if (_mobStateSystem.IsDead(target))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!TryComp<DamageableComponent>(target, out var targetDamage))
|
if (!TryComp<DamageableComponent>(target, out var targetDamage))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (targetDamage.TotalDamage == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (component.DamageContainerID is not null && !component.DamageContainerID.Equals(targetDamage.DamageContainerID))
|
if (component.DamageContainerID is not null && !component.DamageContainerID.Equals(targetDamage.DamageContainerID))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -122,7 +126,12 @@ public sealed class HealingSystem : EntitySystem
|
|||||||
SoundSystem.Play(component.HealingBeginSound.GetSound(), Filter.Pvs(uid, entityManager:EntityManager), uid, AudioHelpers.WithVariation(0.125f).WithVolume(-5f));
|
SoundSystem.Play(component.HealingBeginSound.GetSound(), Filter.Pvs(uid, entityManager:EntityManager), uid, AudioHelpers.WithVariation(0.125f).WithVolume(-5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
_doAfter.DoAfter(new DoAfterEventArgs(user, component.Delay, component.CancelToken.Token, target)
|
var delay = component.Delay;
|
||||||
|
|
||||||
|
if (user == target)
|
||||||
|
delay *= component.SelfHealPenaltyMultiplier;
|
||||||
|
|
||||||
|
_doAfter.DoAfter(new DoAfterEventArgs(user, delay, component.CancelToken.Token, target)
|
||||||
{
|
{
|
||||||
BreakOnUserMove = true,
|
BreakOnUserMove = true,
|
||||||
BreakOnTargetMove = true,
|
BreakOnTargetMove = true,
|
||||||
|
|||||||
Reference in New Issue
Block a user