2025-07-03 01:20:31 +02:00
|
|
|
using Content.Shared.Administration.Logs;
|
|
|
|
|
using Content.Shared.Body.Components;
|
|
|
|
|
using Content.Shared.Body.Systems;
|
2024-09-02 06:26:04 -05:00
|
|
|
using Content.Shared.Chemistry.EntitySystems;
|
2022-02-07 14:14:45 +11:00
|
|
|
using Content.Shared.Damage;
|
|
|
|
|
using Content.Shared.Database;
|
2023-02-24 19:01:25 -05:00
|
|
|
using Content.Shared.DoAfter;
|
2023-04-03 13:13:48 +12:00
|
|
|
using Content.Shared.FixedPoint;
|
2024-07-09 10:41:47 +02:00
|
|
|
using Content.Shared.IdentityManagement;
|
2022-02-07 14:14:45 +11:00
|
|
|
using Content.Shared.Interaction;
|
2022-03-13 01:33:23 +13:00
|
|
|
using Content.Shared.Interaction.Events;
|
2023-01-13 16:57:10 -08:00
|
|
|
using Content.Shared.Mobs;
|
|
|
|
|
using Content.Shared.Mobs.Components;
|
|
|
|
|
using Content.Shared.Mobs.Systems;
|
2024-07-09 10:41:47 +02:00
|
|
|
using Content.Shared.Popups;
|
2022-02-07 14:14:45 +11:00
|
|
|
using Content.Shared.Stacks;
|
2023-11-27 22:12:34 +11:00
|
|
|
using Robust.Shared.Audio.Systems;
|
2022-02-07 14:14:45 +11:00
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
namespace Content.Shared.Medical.Healing;
|
2022-02-07 14:14:45 +11:00
|
|
|
|
|
|
|
|
public sealed class HealingSystem : EntitySystem
|
|
|
|
|
{
|
2022-09-29 03:12:16 -04:00
|
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
2025-07-03 01:20:31 +02:00
|
|
|
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
2022-02-07 14:14:45 +11:00
|
|
|
[Dependency] private readonly DamageableSystem _damageable = default!;
|
2025-07-03 01:20:31 +02:00
|
|
|
[Dependency] private readonly SharedBloodstreamSystem _bloodstreamSystem = default!;
|
2023-04-03 13:13:48 +12:00
|
|
|
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
2025-07-03 01:20:31 +02:00
|
|
|
[Dependency] private readonly SharedStackSystem _stacks = default!;
|
2022-02-17 15:40:03 +13:00
|
|
|
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
2023-01-13 16:57:10 -08:00
|
|
|
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
|
2025-07-03 01:20:31 +02:00
|
|
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
2024-09-02 06:26:04 -05:00
|
|
|
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
|
2022-02-07 14:14:45 +11:00
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2025-07-03 01:20:31 +02:00
|
|
|
|
2022-02-07 14:14:45 +11:00
|
|
|
SubscribeLocalEvent<HealingComponent, UseInHandEvent>(OnHealingUse);
|
|
|
|
|
SubscribeLocalEvent<HealingComponent, AfterInteractEvent>(OnHealingAfterInteract);
|
2023-04-03 13:13:48 +12:00
|
|
|
SubscribeLocalEvent<DamageableComponent, HealingDoAfterEvent>(OnDoAfter);
|
2022-02-07 14:14:45 +11:00
|
|
|
}
|
|
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
private void OnDoAfter(Entity<DamageableComponent> target, ref HealingDoAfterEvent args)
|
2022-02-07 14:14:45 +11:00
|
|
|
{
|
2023-04-23 23:34:18 -05:00
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
if (args.Handled || args.Cancelled)
|
2023-02-26 00:33:06 -05:00
|
|
|
return;
|
|
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
if (!TryComp(args.Used, out HealingComponent? healing))
|
2022-04-16 23:29:31 -07:00
|
|
|
return;
|
|
|
|
|
|
2023-06-03 15:30:20 -04:00
|
|
|
if (healing.DamageContainers is not null &&
|
2025-07-03 01:20:31 +02:00
|
|
|
target.Comp.DamageContainerID is not null &&
|
|
|
|
|
!healing.DamageContainers.Contains(target.Comp.DamageContainerID.Value))
|
2023-06-03 15:30:20 -04:00
|
|
|
{
|
2022-09-29 03:12:16 -04:00
|
|
|
return;
|
2023-06-03 15:30:20 -04:00
|
|
|
}
|
2022-02-07 14:14:45 +11:00
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
TryComp<BloodstreamComponent>(target, out var bloodstream);
|
|
|
|
|
|
2023-02-24 19:01:25 -05:00
|
|
|
// Heal some bloodloss damage.
|
2025-07-03 01:20:31 +02:00
|
|
|
if (healing.BloodlossModifier != 0 && bloodstream != null)
|
2023-04-23 23:34:18 -05:00
|
|
|
{
|
|
|
|
|
var isBleeding = bloodstream.BleedAmount > 0;
|
2025-07-03 01:20:31 +02:00
|
|
|
_bloodstreamSystem.TryModifyBleedAmount((target.Owner, bloodstream), healing.BloodlossModifier);
|
2023-04-23 23:34:18 -05:00
|
|
|
if (isBleeding != bloodstream.BleedAmount > 0)
|
|
|
|
|
{
|
2025-07-03 01:20:31 +02:00
|
|
|
var popup = (args.User == target.Owner)
|
2025-01-29 14:13:50 +01:00
|
|
|
? Loc.GetString("medical-item-stop-bleeding-self")
|
2025-07-03 01:20:31 +02:00
|
|
|
: Loc.GetString("medical-item-stop-bleeding", ("target", Identity.Entity(target.Owner, EntityManager)));
|
|
|
|
|
_popupSystem.PopupClient(popup, target, args.User);
|
2023-04-23 23:34:18 -05:00
|
|
|
}
|
|
|
|
|
}
|
2022-02-17 15:00:41 -07:00
|
|
|
|
The bleed update (#14814)
* Removed arbitrary modifier scaling. The bleed amount is now 1-1 in units.
* Added some comments to explain the blood and bleed code
* added some comments
* added some comments
* profusely bleeding message scales with max bleed rate
* Added some comments
* Added some comments (tm)
* Halved the speed bleed rate heals.
* Changed the wording of a comment to make the function of the values more clear
* Changed bleed rate values, made heat heal more bleed rate
* doubled crit chance, since damage types were reduced
* Made iron restore more blood, 2->4u per 1u
* Starting to add the blood pack
* add bloodlevel to healingcomponent
* Created code support in the healing system for restoring blood
* first test of blood pack prototype
* More pack testing, and defining the yml stack
* yml syntax fix
* adds bloodpack tag
* Successfully added the item, but the effect and deletion after using the item is not working yet.
* the blood regen worksgit add -A!
* blood pack is entirely functioning
* Removed bleed rate healing from brute pack
* Comment correction
* I tried
* Removed bleed stats from corrupted corgi, they inherit same stats from basemob
* Removed bleed stats from xeno, they inherit same stats from a base mob
* Removed bleed stats from diona, they inherit same stats from a base mob
* Removed bleed stats from slimes, they inherit same stats from a base mob
* All mobs now heal bloodloss damage at a rate of 1 instead of 0.25 when healthy
* The cautery now closes bleed wounds
* Nerf blood pack bleed rate heal
* Added 2 blood packs to medicine locker
* Added 2 blood packs to wall medicine locker
* Minor YML fix to chemistry locker, no changes in game
* Added tag to medical belt for blood pack, added 2 blood packs to medical belt
* Added 1 gauze to medical belt
* 5 blood packs addded to nanomed plus
* nanomed inventory change
* 2 blood packs added to medical supplies crate from cargo
* Moved 1 gauze from med kit to advanced med kit
* Moved 1 tricord pill from advanced med kit to basic med kit
* added 2 ointment to burn kit
* Moved ina syringe from burn treatment to oxygen kit
* Removed one gauze from brute kit
* Added one bloodpack to brute med kit
* Moved tranex acid syringe from advanced first aid to brute kit
* Poison medipen moved from advanced first aid kit to toxin kit
* Removed health analyzer from advanced first aid kit
* removed one brute pack from advanced aid kit
* added one ointment to advanced aid kit
* Added one blood pack to advanced aid kit
* Added 2 blood packs to combat med kit
* Starting with adding the license for the tg sprite
* Adds the blood pack sprite and meta.json code
* I forgor to actually code the sprite in
* Advanced med kit missing one blood pack
* Replaced tricord pill with emergency medipen in cobat kit
* Removed emergency pen from combat kit, there's no space for it
* Revert "I tried"
This reverts commit 94c2e28df3200993d3f09b72ecabc838ea5ae5c0.
* Trying to fix yml test fail
* Try again
* attempt number 3
* Restock crate price was too low
* fixing merge conflict without making a HUGE mess this time
* ???
* again
* again
* Can I add the newline now maybe???
* Revert "Can I add the newline now maybe???"
This reverts commit 22d26706a65a24633f7da1dea6315012e2d3ac6f.
* Adds the doafter fix code from Keron to the blood level healing
* minor typo fix
* Feedback from Emisse and sloth; Removed chance based feedback on cauterizing
* comment fix
2023-04-03 01:59:51 -04:00
|
|
|
// Restores missing blood
|
2025-07-03 01:20:31 +02:00
|
|
|
if (healing.ModifyBloodLevel != 0 && bloodstream != null)
|
|
|
|
|
_bloodstreamSystem.TryModifyBloodLevel((target.Owner, bloodstream), healing.ModifyBloodLevel);
|
The bleed update (#14814)
* Removed arbitrary modifier scaling. The bleed amount is now 1-1 in units.
* Added some comments to explain the blood and bleed code
* added some comments
* added some comments
* profusely bleeding message scales with max bleed rate
* Added some comments
* Added some comments (tm)
* Halved the speed bleed rate heals.
* Changed the wording of a comment to make the function of the values more clear
* Changed bleed rate values, made heat heal more bleed rate
* doubled crit chance, since damage types were reduced
* Made iron restore more blood, 2->4u per 1u
* Starting to add the blood pack
* add bloodlevel to healingcomponent
* Created code support in the healing system for restoring blood
* first test of blood pack prototype
* More pack testing, and defining the yml stack
* yml syntax fix
* adds bloodpack tag
* Successfully added the item, but the effect and deletion after using the item is not working yet.
* the blood regen worksgit add -A!
* blood pack is entirely functioning
* Removed bleed rate healing from brute pack
* Comment correction
* I tried
* Removed bleed stats from corrupted corgi, they inherit same stats from basemob
* Removed bleed stats from xeno, they inherit same stats from a base mob
* Removed bleed stats from diona, they inherit same stats from a base mob
* Removed bleed stats from slimes, they inherit same stats from a base mob
* All mobs now heal bloodloss damage at a rate of 1 instead of 0.25 when healthy
* The cautery now closes bleed wounds
* Nerf blood pack bleed rate heal
* Added 2 blood packs to medicine locker
* Added 2 blood packs to wall medicine locker
* Minor YML fix to chemistry locker, no changes in game
* Added tag to medical belt for blood pack, added 2 blood packs to medical belt
* Added 1 gauze to medical belt
* 5 blood packs addded to nanomed plus
* nanomed inventory change
* 2 blood packs added to medical supplies crate from cargo
* Moved 1 gauze from med kit to advanced med kit
* Moved 1 tricord pill from advanced med kit to basic med kit
* added 2 ointment to burn kit
* Moved ina syringe from burn treatment to oxygen kit
* Removed one gauze from brute kit
* Added one bloodpack to brute med kit
* Moved tranex acid syringe from advanced first aid to brute kit
* Poison medipen moved from advanced first aid kit to toxin kit
* Removed health analyzer from advanced first aid kit
* removed one brute pack from advanced aid kit
* added one ointment to advanced aid kit
* Added one blood pack to advanced aid kit
* Added 2 blood packs to combat med kit
* Starting with adding the license for the tg sprite
* Adds the blood pack sprite and meta.json code
* I forgor to actually code the sprite in
* Advanced med kit missing one blood pack
* Replaced tricord pill with emergency medipen in cobat kit
* Removed emergency pen from combat kit, there's no space for it
* Revert "I tried"
This reverts commit 94c2e28df3200993d3f09b72ecabc838ea5ae5c0.
* Trying to fix yml test fail
* Try again
* attempt number 3
* Restock crate price was too low
* fixing merge conflict without making a HUGE mess this time
* ???
* again
* again
* Can I add the newline now maybe???
* Revert "Can I add the newline now maybe???"
This reverts commit 22d26706a65a24633f7da1dea6315012e2d3ac6f.
* Adds the doafter fix code from Keron to the blood level healing
* minor typo fix
* Feedback from Emisse and sloth; Removed chance based feedback on cauterizing
* comment fix
2023-04-03 01:59:51 -04:00
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
var healed = _damageable.TryChangeDamage(target.Owner, healing.Damage * _damageable.UniversalTopicalsHealModifier, true, origin: args.Args.User);
|
2022-02-07 14:14:45 +11:00
|
|
|
|
2023-04-03 13:13:48 +12:00
|
|
|
if (healed == null && healing.BloodlossModifier != 0)
|
2022-02-07 14:14:45 +11:00
|
|
|
return;
|
|
|
|
|
|
2024-01-22 02:59:14 +01:00
|
|
|
var total = healed?.GetTotal() ?? FixedPoint2.Zero;
|
2023-02-24 19:01:25 -05:00
|
|
|
|
2023-04-23 23:34:18 -05:00
|
|
|
// Re-verify that we can heal the damage.
|
2025-07-03 01:20:31 +02:00
|
|
|
var dontRepeat = false;
|
2023-08-30 21:06:15 -04:00
|
|
|
if (TryComp<StackComponent>(args.Used.Value, out var stackComp))
|
|
|
|
|
{
|
|
|
|
|
_stacks.Use(args.Used.Value, 1, stackComp);
|
|
|
|
|
|
|
|
|
|
if (_stacks.GetCount(args.Used.Value, stackComp) <= 0)
|
|
|
|
|
dontRepeat = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2025-07-03 01:20:31 +02:00
|
|
|
PredictedQueueDel(args.Used.Value);
|
2023-08-30 21:06:15 -04:00
|
|
|
}
|
2023-08-12 17:39:58 -04:00
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
if (target.Owner != args.User)
|
2023-04-23 23:34:18 -05:00
|
|
|
{
|
2023-04-03 13:13:48 +12:00
|
|
|
_adminLogger.Add(LogType.Healed,
|
2025-07-03 01:20:31 +02:00
|
|
|
$"{ToPrettyString(args.User):user} healed {ToPrettyString(target.Owner):target} for {total:damage} damage");
|
2023-04-23 23:34:18 -05:00
|
|
|
}
|
2022-02-07 14:14:45 +11:00
|
|
|
else
|
2023-04-23 23:34:18 -05:00
|
|
|
{
|
2023-04-03 13:13:48 +12:00
|
|
|
_adminLogger.Add(LogType.Healed,
|
2025-06-26 19:50:49 -04:00
|
|
|
$"{ToPrettyString(args.User):user} healed themselves for {total:damage} damage");
|
2023-04-23 23:34:18 -05:00
|
|
|
}
|
2022-02-27 10:02:00 +03:00
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
_audio.PlayPredicted(healing.HealingEndSound, target.Owner, args.User);
|
2022-02-07 14:14:45 +11:00
|
|
|
|
2023-04-23 23:34:18 -05:00
|
|
|
// Logic to determine the whether or not to repeat the healing action
|
2025-07-03 01:20:31 +02:00
|
|
|
args.Repeat = HasDamage((args.Used.Value, healing), target) && !dontRepeat;
|
2023-02-24 19:01:25 -05:00
|
|
|
args.Handled = true;
|
2025-08-25 11:05:55 -07:00
|
|
|
|
|
|
|
|
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);
|
2022-02-07 14:14:45 +11:00
|
|
|
}
|
|
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
private bool HasDamage(Entity<HealingComponent> healing, Entity<DamageableComponent> target)
|
2023-04-23 23:34:18 -05:00
|
|
|
{
|
2025-07-03 01:20:31 +02:00
|
|
|
var damageableDict = target.Comp.Damage.DamageDict;
|
|
|
|
|
var healingDict = healing.Comp.Damage.DamageDict;
|
2023-04-23 23:34:18 -05:00
|
|
|
foreach (var type in healingDict)
|
|
|
|
|
{
|
|
|
|
|
if (damageableDict[type.Key].Value > 0)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
if (TryComp<BloodstreamComponent>(target, out var bloodstream))
|
2025-02-04 22:23:30 -05:00
|
|
|
{
|
|
|
|
|
// Is ent missing blood that we can restore?
|
2025-07-03 01:20:31 +02:00
|
|
|
if (healing.Comp.ModifyBloodLevel > 0
|
|
|
|
|
&& _solutionContainerSystem.ResolveSolution(target.Owner, bloodstream.BloodSolutionName, ref bloodstream.BloodSolution, out var bloodSolution)
|
2025-02-04 22:23:30 -05:00
|
|
|
&& bloodSolution.Volume < bloodSolution.MaxVolume)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Is ent bleeding and can we stop it?
|
2025-07-03 01:20:31 +02:00
|
|
|
if (healing.Comp.BloodlossModifier < 0 && bloodstream.BleedAmount > 0)
|
2025-02-04 22:23:30 -05:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-23 23:34:18 -05:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
private void OnHealingUse(Entity<HealingComponent> healing, ref UseInHandEvent args)
|
2022-02-07 14:14:45 +11:00
|
|
|
{
|
2022-09-29 03:12:16 -04:00
|
|
|
if (args.Handled)
|
|
|
|
|
return;
|
2022-02-07 14:14:45 +11:00
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
if (TryHeal(healing, args.User, args.User))
|
2022-05-09 16:21:32 +10:00
|
|
|
args.Handled = true;
|
2022-02-07 14:14:45 +11:00
|
|
|
}
|
|
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
private void OnHealingAfterInteract(Entity<HealingComponent> healing, ref AfterInteractEvent args)
|
2022-02-07 14:14:45 +11:00
|
|
|
{
|
2022-09-29 03:12:16 -04:00
|
|
|
if (args.Handled || !args.CanReach || args.Target == null)
|
|
|
|
|
return;
|
2022-02-07 14:14:45 +11:00
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
if (TryHeal(healing, args.Target.Value, args.User))
|
2022-05-09 16:21:32 +10:00
|
|
|
args.Handled = true;
|
2022-02-07 14:14:45 +11:00
|
|
|
}
|
|
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
private bool TryHeal(Entity<HealingComponent> healing, Entity<DamageableComponent?> target, EntityUid user)
|
2022-02-07 14:14:45 +11:00
|
|
|
{
|
2025-07-03 01:20:31 +02:00
|
|
|
if (!Resolve(target, ref target.Comp, false))
|
2022-05-09 16:21:32 +10:00
|
|
|
return false;
|
2022-02-07 14:14:45 +11:00
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
if (healing.Comp.DamageContainers is not null &&
|
|
|
|
|
target.Comp.DamageContainerID is not null &&
|
|
|
|
|
!healing.Comp.DamageContainers.Contains(target.Comp.DamageContainerID.Value))
|
2023-06-03 15:30:20 -04:00
|
|
|
{
|
2022-05-09 16:21:32 +10:00
|
|
|
return false;
|
2023-06-03 15:30:20 -04:00
|
|
|
}
|
2022-02-07 14:14:45 +11:00
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
if (user != target.Owner && !_interactionSystem.InRangeUnobstructed(user, target.Owner, popup: true))
|
2022-05-09 16:21:32 +10:00
|
|
|
return false;
|
2022-02-07 14:14:45 +11:00
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
if (TryComp<StackComponent>(healing, out var stack) && stack.Count < 1)
|
2022-05-09 16:21:32 +10:00
|
|
|
return false;
|
2022-02-07 14:14:45 +11:00
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
if (!HasDamage(healing, target!))
|
2023-04-23 23:34:18 -05:00
|
|
|
{
|
2025-07-03 01:20:31 +02:00
|
|
|
_popupSystem.PopupClient(Loc.GetString("medical-item-cant-use", ("item", healing.Owner)), healing, user);
|
2023-04-23 23:34:18 -05:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
_audio.PlayPredicted(healing.Comp.HealingBeginSound, healing, user);
|
2022-02-27 10:02:00 +03:00
|
|
|
|
2025-07-03 01:20:31 +02:00
|
|
|
var isNotSelf = user != target.Owner;
|
2023-02-26 00:33:06 -05:00
|
|
|
|
2024-07-09 10:41:47 +02:00
|
|
|
if (isNotSelf)
|
|
|
|
|
{
|
2025-07-03 01:20:31 +02:00
|
|
|
var msg = Loc.GetString("medical-item-popup-target", ("user", Identity.Entity(user, EntityManager)), ("item", healing.Owner));
|
2024-07-09 10:41:47 +02:00
|
|
|
_popupSystem.PopupEntity(msg, target, target, PopupType.Medium);
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-26 00:33:06 -05:00
|
|
|
var delay = isNotSelf
|
2025-07-03 01:20:31 +02:00
|
|
|
? healing.Comp.Delay
|
2025-08-25 11:05:55 -07:00
|
|
|
: healing.Comp.Delay * GetScaledHealingPenalty(target, healing.Comp.SelfHealPenaltyMultiplier);
|
2022-07-14 01:24:35 -04:00
|
|
|
|
2023-04-03 13:13:48 +12:00
|
|
|
var doAfterEventArgs =
|
2025-07-03 01:20:31 +02:00
|
|
|
new DoAfterArgs(EntityManager, user, delay, new HealingDoAfterEvent(), target, target: target, used: healing)
|
2023-04-03 13:13:48 +12:00
|
|
|
{
|
|
|
|
|
// Didn't break on damage as they may be trying to prevent it and
|
|
|
|
|
// not being able to heal your own ticking damage would be frustrating.
|
|
|
|
|
NeedHand = true,
|
2024-03-19 12:09:00 +02:00
|
|
|
BreakOnMove = true,
|
|
|
|
|
BreakOnWeightlessMove = false,
|
2023-04-03 13:13:48 +12:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_doAfter.TryStartDoAfter(doAfterEventArgs);
|
2022-05-09 16:21:32 +10:00
|
|
|
return true;
|
2022-02-07 14:14:45 +11:00
|
|
|
}
|
|
|
|
|
|
2022-09-29 03:12:16 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Scales the self-heal penalty based on the amount of damage taken
|
|
|
|
|
/// </summary>
|
2025-08-25 11:05:55 -07:00
|
|
|
/// <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)
|
2022-09-29 03:12:16 -04:00
|
|
|
{
|
2025-08-25 11:05:55 -07:00
|
|
|
if (!Resolve(ent, ref ent.Comp1, ref ent.Comp2, false))
|
|
|
|
|
return mod;
|
|
|
|
|
|
|
|
|
|
if (!_mobThresholdSystem.TryGetThresholdForState(ent, MobState.Critical, out var amount, ent.Comp2))
|
2023-01-13 16:57:10 -08:00
|
|
|
return 1;
|
2023-02-24 19:01:25 -05:00
|
|
|
|
2025-08-25 11:05:55 -07:00
|
|
|
var percentDamage = (float)(ent.Comp1.TotalDamage / amount);
|
2022-09-29 03:12:16 -04:00
|
|
|
//basically make it scale from 1 to the multiplier.
|
2025-08-25 11:05:55 -07:00
|
|
|
|
|
|
|
|
var output = percentDamage * (mod - 1) + 1;
|
|
|
|
|
return Math.Max(output, 1);
|
2022-09-29 03:12:16 -04:00
|
|
|
}
|
2022-02-07 14:14:45 +11:00
|
|
|
}
|