From: nikthechampiongr <32041239+nikthechampiongr@users.noreply.github.com> Date: Mon, 11 Mar 2024 01:55:19 +0000 (+0200) Subject: Fix shield absorbing asphyxiation damage (#25972) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=b0ffed1607452a2d4186228fc2343d10035611e5;p=space-station-14.git Fix shield absorbing asphyxiation damage (#25972) * Fix shield absorbing asphyxiation damage Shields will no longer reduce damage on their user that they themselves can't absorb. * Update Content.Shared/Blocking/BlockingSystem.User.cs --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> --- diff --git a/Content.Shared/Blocking/BlockingSystem.User.cs b/Content.Shared/Blocking/BlockingSystem.User.cs index 87f285597f..2cd1db7f1f 100644 --- a/Content.Shared/Blocking/BlockingSystem.User.cs +++ b/Content.Shared/Blocking/BlockingSystem.User.cs @@ -47,13 +47,23 @@ public sealed partial class BlockingSystem if (args.Damage.GetTotal() <= 0) return; + // A shield should only block damage it can itself absorb. To determine that we need the Damageable component on it. + if (!TryComp(component.BlockingItem, out var dmgComp)) + return; + var blockFraction = blocking.IsBlocking ? blocking.ActiveBlockFraction : blocking.PassiveBlockFraction; blockFraction = Math.Clamp(blockFraction, 0, 1); _damageable.TryChangeDamage(component.BlockingItem, blockFraction * args.OriginalDamage); - args.Damage *= (1 - blockFraction); + var modify = new DamageModifierSet(); + foreach (var key in dmgComp.Damage.DamageDict.Keys) + { + modify.Coefficients.TryAdd(key, 1 - blockFraction); + } + + args.Damage = DamageSpecifier.ApplyModifierSet(args.Damage, modify); - if (blocking.IsBlocking) + if (blocking.IsBlocking && !args.Damage.Equals(args.OriginalDamage)) { _audio.PlayPvs(blocking.BlockSound, uid); }