diff --git a/OpenRA.Mods.RA/Attack/AttackTurreted.cs b/OpenRA.Mods.RA/Attack/AttackTurreted.cs index b33b740e67..f17470ba95 100644 --- a/OpenRA.Mods.RA/Attack/AttackTurreted.cs +++ b/OpenRA.Mods.RA/Attack/AttackTurreted.cs @@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove) { - return new AttackActivity( newTarget ); + return new AttackActivity( newTarget, allowMove ); } public override void ResolveOrder(Actor self, Order order) @@ -69,7 +69,13 @@ namespace OpenRA.Mods.RA class AttackActivity : Activity { readonly Target target; - public AttackActivity( Target newTarget ) { this.target = newTarget; } + readonly bool allowMove; + + public AttackActivity( Target newTarget, bool allowMove ) + { + this.target = newTarget; + this.allowMove = allowMove; + } public override Activity Tick( Actor self ) { @@ -81,15 +87,17 @@ namespace OpenRA.Mods.RA var attack = self.Trait(); const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */ var weapon = attack.ChooseWeaponForTarget(target); + if (weapon != null) { attack.target = target; - if (self.HasTrait() && !self.Info.Traits.Get().OnRails) + if (allowMove && self.HasTrait() && !self.Info.Traits.Get().OnRails) return Util.SequenceActivities( new Follow( target, Math.Max( 0, (int)weapon.Info.Range - RangeTolerance ) ), this ); } + return NextActivity; } }