From 2024f86290d7c7a5a64702c9542468a20eb233b9 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 3 Apr 2016 10:22:53 +0100 Subject: [PATCH] Fix Turreted units not dropping cancelled targets. --- OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs index e8004b0768..7af6de28cb 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs @@ -66,6 +66,7 @@ namespace OpenRA.Mods.Common.Traits readonly Target target; readonly bool forceAttack; readonly bool onRailsHack; + bool hasTicked; public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack) { @@ -103,7 +104,13 @@ namespace OpenRA.Mods.Common.Traits var maxRange = targetIsMobile ? new WDist(Math.Max(weapon.Weapon.MinRange.Length, modifiedRange.Length - 1024)) : modifiedRange; + // Check that AttackFollow hasn't cancelled the target by modifying attack.Target + // Having both this and AttackFollow modify that field is a horrible hack. + if (hasTicked && attack.Target.Type == TargetType.Invalid) + return NextActivity; + attack.Target = target; + hasTicked = true; if (move != null) return ActivityUtils.SequenceActivities(move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange), this);