fix ghost command damage when in crit (#22134)

* adjust kill damage on ghost command

* tweaks

* tweaks 2 argh

* refactor, tweak
This commit is contained in:
qwerltaz
2023-12-05 00:06:10 +01:00
committed by GitHub
parent 9d6475aae2
commit 14929571d0

View File

@@ -7,9 +7,12 @@ using Content.Shared.CCVar;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Database;
using Content.Shared.FixedPoint;
using Content.Shared.Ghost;
using Content.Shared.Mind;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using JetBrains.Annotations;
using Robust.Shared.Player;
@@ -17,6 +20,8 @@ namespace Content.Server.GameTicking
{
public sealed partial class GameTicker
{
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
public const float PresetFailedCooldownIncrease = 30f;
/// <summary>
@@ -254,7 +259,17 @@ namespace Content.Server.GameTicking
//todo: what if they dont breathe lol
//cry deeply
DamageSpecifier damage = new(_prototypeManager.Index<DamageTypePrototype>("Asphyxiation"), 200);
FixedPoint2 dealtDamage = 200;
if (TryComp<DamageableComponent>(playerEntity, out var damageable)
&& TryComp<MobThresholdsComponent>(playerEntity, out var thresholds))
{
var playerDeadThreshold = _mobThresholdSystem.GetThresholdForState(playerEntity.Value, MobState.Dead, thresholds);
dealtDamage = playerDeadThreshold - damageable.TotalDamage;
}
DamageSpecifier damage = new(_prototypeManager.Index<DamageTypePrototype>("Asphyxiation"), dealtDamage);
_damageable.TryChangeDamage(playerEntity, damage, true);
}
}