From c62298a585f1d75001df391e8704042d94394b39 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 8 Dec 2009 21:21:28 +1300 Subject: [PATCH] oops, that was rather exploitable. --- OpenRa.Game/Traits/AutoTarget.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OpenRa.Game/Traits/AutoTarget.cs b/OpenRa.Game/Traits/AutoTarget.cs index 9ecc2f2f39..0b8a5bedf2 100644 --- a/OpenRa.Game/Traits/AutoTarget.cs +++ b/OpenRa.Game/Traits/AutoTarget.cs @@ -13,9 +13,10 @@ namespace OpenRa.Game.Traits { var attack = self.traits.WithInterface().First(); - if (attack.target == null) - attack.target = ChooseTarget(self, - Rules.WeaponInfo[self.Info.Primary].Range); + var range = Rules.WeaponInfo[self.Info.Primary].Range; + if (attack.target == null || + (attack.target.Location - self.Location).LengthSquared > range * range + 2) + attack.target = ChooseTarget(self, range); } Actor ChooseTarget(Actor self, float range)