From e95cb7540d31a9f35ce644a06219596793eebd88 Mon Sep 17 00:00:00 2001 From: teees Date: Tue, 3 Nov 2015 15:35:52 +0100 Subject: [PATCH] Fix immovable actors not dropping targets that are out of range --- OpenRA.Mods.Common/Activities/Attack.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Attack.cs b/OpenRA.Mods.Common/Activities/Attack.cs index 94df1d1af8..8d164ee376 100644 --- a/OpenRA.Mods.Common/Activities/Attack.cs +++ b/OpenRA.Mods.Common/Activities/Attack.cs @@ -76,9 +76,13 @@ namespace OpenRA.Mods.Common.Activities minRange = armaments.Max(a => a.Weapon.MinRange); maxRange = armaments.Min(a => a.MaxRange()); - // Try to move within range - if (move != null && (!Target.IsInRange(self.CenterPosition, maxRange) || Target.IsInRange(self.CenterPosition, minRange))) + if (!Target.IsInRange(self.CenterPosition, maxRange) || Target.IsInRange(self.CenterPosition, minRange)) + { + // Try to move within range, drop the target otherwise + if (move == null) + return NextActivity; return ActivityUtils.SequenceActivities(move.MoveWithinRange(Target, minRange, maxRange), this); + } var desiredFacing = (Target.CenterPosition - self.CenterPosition).Yaw.Facing; if (facing.Facing != desiredFacing)