fixed units forgetting their orders while near enemies.

This commit is contained in:
Bob
2010-04-02 21:57:16 +12:00
parent fa4c5c3fea
commit b4298a445e

View File

@@ -49,9 +49,9 @@ namespace OpenRA.Traits
var attack = self.traits.Get<AttackBase>();
var range = Util.GetMaximumRange(self);
if (attack.target == null ||
(attack.target.Location - self.Location).LengthSquared > range * range + 2)
AttackTarget(self, ChooseTarget(self, range));
if( attack.target == null ||
( attack.target.Location - self.Location ).LengthSquared > range * range )
attack.target = ChooseTarget( self, range );
var info = self.Info.Traits.Get<AutoTargetInfo>();
nextScanTime = (int)(25 * (info.ScanTimeAverage +
@@ -74,6 +74,12 @@ namespace OpenRA.Traits
{
if (!self.IsIdle) return;
var attack = self.traits.Get<AttackBase>();
var range = Util.GetMaximumRange(self);
if( attack.target != null && ( attack.target.Location - self.Location ).LengthSquared <= range * range )
return;
// not a lot we can do about things we can't hurt... although maybe we should automatically run away?
if (!Combat.HasAnyValidWeapons(self, e.Attacker)) return;
@@ -82,7 +88,7 @@ namespace OpenRA.Traits
if (e.Damage < 0) return; // don't retaliate against healers
AttackTarget(self, e.Attacker);
attack.target = e.Attacker;
}
}
}