From ce62e456d74b99b364727e7cf6a8f38b0262130a Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Wed, 3 Feb 2016 19:28:45 +0100 Subject: [PATCH] Fix TD gunboat attack behaviour --- OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs index 1b97dc918e..c9686ff459 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs @@ -58,16 +58,20 @@ namespace OpenRA.Mods.Common.Traits readonly IMove move; readonly Target target; readonly bool forceAttack; + readonly bool onRailsHack; public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack) { attack = self.Trait(); move = allowMove ? self.TraitOrDefault() : null; - // HACK: Mobile.OnRails is horrible + // HACK: Mobile.OnRails is horrible. Blergh. var mobile = move as Mobile; if (mobile != null && mobile.Info.OnRails) + { move = null; + onRailsHack = true; + } this.target = target; this.forceAttack = forceAttack; @@ -96,11 +100,15 @@ namespace OpenRA.Mods.Common.Traits if (move != null) return ActivityUtils.SequenceActivities(move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange), this); - if (target.IsInRange(self.CenterPosition, weapon.MaxRange()) && !target.IsInRange(self.CenterPosition, weapon.Weapon.MinRange)) + if (!onRailsHack && + target.IsInRange(self.CenterPosition, weapon.MaxRange()) && + !target.IsInRange(self.CenterPosition, weapon.Weapon.MinRange)) return this; } - attack.Target = Target.Invalid; + if (!onRailsHack) + attack.Target = Target.Invalid; + return NextActivity; } }