diff --git a/OpenRA.Mods.RA/Activities/Follow.cs b/OpenRA.Mods.RA/Activities/Follow.cs index 70827aeb6b..0bb6836321 100644 --- a/OpenRA.Mods.RA/Activities/Follow.cs +++ b/OpenRA.Mods.RA/Activities/Follow.cs @@ -16,15 +16,17 @@ namespace OpenRA.Mods.RA.Activities public class Follow : Activity { Target target; + Mobile mobile; WRange range; int nextPathTime; const int delayBetweenPathingAttempts = 20; const int delaySpread = 5; - public Follow(Target target, WRange range) + public Follow(Actor self, Target target, WRange range) { this.target = target; + mobile = self.Trait(); this.range = range; } @@ -39,7 +41,6 @@ namespace OpenRA.Mods.RA.Activities nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread, delayBetweenPathingAttempts + delaySpread); - var mobile = self.Trait(); return Util.SequenceActivities(mobile.MoveWithinRange(target, range), this); } } diff --git a/OpenRA.Mods.RA/Attack/AttackTurreted.cs b/OpenRA.Mods.RA/Attack/AttackTurreted.cs index ed3f2ef799..d6e2226b49 100644 --- a/OpenRA.Mods.RA/Attack/AttackTurreted.cs +++ b/OpenRA.Mods.RA/Attack/AttackTurreted.cs @@ -98,7 +98,7 @@ namespace OpenRA.Mods.RA attack.Target = target; if (allowMove && self.HasTrait() && !self.Info.Traits.Get().OnRails) - return Util.SequenceActivities(new Follow(target, range), this); + return Util.SequenceActivities(new Follow(self, target, range), this); } return NextActivity; diff --git a/OpenRA.Mods.RA/Guard.cs b/OpenRA.Mods.RA/Guard.cs index 8550b0017c..94cf1cba70 100644 --- a/OpenRA.Mods.RA/Guard.cs +++ b/OpenRA.Mods.RA/Guard.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA var range = WRange.FromCells(target.Actor.Info.Traits.Get().Range); self.QueueActivity(false, new AttackMove.AttackMoveActivity(self, - new Follow(target, range))); + new Follow(self, target, range))); } }