non-turreted AutoTarget is sensible now
This commit is contained in:
@@ -16,16 +16,23 @@ namespace OpenRa.Game.Traits
|
||||
attack.ResolveOrder(self, new Order("Attack", self, target, int2.Zero, null));
|
||||
}
|
||||
|
||||
float GetMaximumRange(Actor self)
|
||||
{
|
||||
return new[] { self.Info.Primary, self.Info.Secondary }
|
||||
.Where(w => w != null)
|
||||
.Max(w => Rules.WeaponInfo[w].Range);
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (!self.IsIdle) return;
|
||||
|
||||
var attack = self.traits.WithInterface<AttackBase>().First();
|
||||
var range = Rules.WeaponInfo[self.Info.Primary].Range;
|
||||
var range = GetMaximumRange(self);
|
||||
|
||||
if (attack.target == null ||
|
||||
(attack.target.Location - self.Location).LengthSquared > range * range + 2)
|
||||
attack.target = ChooseTarget(self, range);
|
||||
AttackTarget(self, ChooseTarget(self, range));
|
||||
}
|
||||
|
||||
Actor ChooseTarget(Actor self, float range)
|
||||
|
||||
Reference in New Issue
Block a user