]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix ghost command damage when in crit (#22134)
authorqwerltaz <69696513+qwerltaz@users.noreply.github.com>
Mon, 4 Dec 2023 23:06:10 +0000 (00:06 +0100)
committerGitHub <noreply@github.com>
Mon, 4 Dec 2023 23:06:10 +0000 (16:06 -0700)
* adjust kill damage on ghost command

* tweaks

* tweaks 2 argh

* refactor, tweak

Content.Server/GameTicking/GameTicker.GamePreset.cs

index 4ede91babc3602f161be8dd9da0236e9cbc481bf..5668625d37d2c64f60183fe4157bb8b94b4c7626 100644 (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);
                 }
             }