From 84a9253b10f2ffa888aad4f4bc2c3fa9bfe8b494 Mon Sep 17 00:00:00 2001 From: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com> Date: Sun, 4 Aug 2024 20:14:01 -0700 Subject: [PATCH] Fix falsely showing damage color effect to entities that aren't allowed to be attacked (#30661) --- Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs index 72cf4ec550..ae0ebfe74c 100644 --- a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs +++ b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs @@ -625,14 +625,18 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem var appliedDamage = new DamageSpecifier(); - foreach (var entity in targets) + for (var i = targets.Count - 1; i >= 0; i--) { + var entity = targets[i]; // We raise an attack attempt here as well, // primarily because this was an untargeted wideswing: if a subscriber to that event cared about // the potential target (such as for pacifism), they need to be made aware of the target here. // In that case, just continue. if (!Blocker.CanAttack(user, entity, (weapon, component))) + { + targets.RemoveAt(i); continue; + } var attackedEvent = new AttackedEvent(meleeUid, user, GetCoordinates(ev.Coordinates)); RaiseLocalEvent(entity, attackedEvent); -- 2.52.0