diff --git a/OpenRA.Mods.Cnc/Activities/LeapAttack.cs b/OpenRA.Mods.Cnc/Activities/LeapAttack.cs index cbe2c0c3d6..7027c255f2 100644 --- a/OpenRA.Mods.Cnc/Activities/LeapAttack.cs +++ b/OpenRA.Mods.Cnc/Activities/LeapAttack.cs @@ -156,7 +156,8 @@ namespace OpenRA.Mods.Cnc.Activities if (newStance > oldStance || forceAttack) return; - if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes)) + // If lastVisibleTarget is invalid we could never view the target in the first place, so we just drop it here too + if (!lastVisibleTarget.IsValidFor(self) || !autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes)) target = Target.Invalid; } diff --git a/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs b/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs index ca32e927d1..b39932c4c6 100644 --- a/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs +++ b/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs @@ -184,7 +184,8 @@ namespace OpenRA.Mods.Common.Activities if (newStance > oldStance || forceAttack) return; - if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes)) + // If lastVisibleTarget is invalid we could never view the target in the first place, so we just drop it here too + if (!lastVisibleTarget.IsValidFor(self) || !autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes)) attackAircraft.ClearRequestedTarget(); } diff --git a/OpenRA.Mods.Common/Activities/Attack.cs b/OpenRA.Mods.Common/Activities/Attack.cs index 873265c50f..c9c46d5566 100644 --- a/OpenRA.Mods.Common/Activities/Attack.cs +++ b/OpenRA.Mods.Common/Activities/Attack.cs @@ -225,7 +225,8 @@ namespace OpenRA.Mods.Common.Activities if (newStance > oldStance || forceAttack) return; - if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes)) + // If lastVisibleTarget is invalid we could never view the target in the first place, so we just drop it here too + if (!lastVisibleTarget.IsValidFor(self) || !autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes)) target = Target.Invalid; } diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs index 73185c1a19..5dd1519ef3 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs @@ -364,7 +364,8 @@ namespace OpenRA.Mods.Common.Traits if (newStance > oldStance || forceAttack) return; - if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes)) + // If lastVisibleTarget is invalid we could never view the target in the first place, so we just drop it here too + if (!lastVisibleTarget.IsValidFor(self) || !autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes)) attack.ClearRequestedTarget(); }