Add maximum and minimum range vs. target checks

This adresses the issue that actors would ignore the validity of weapons when deciding the attack distance versus a target. This could result in actors staying out of range of a weapon valid versus target if they carried a weapon with higher range but invalid versus target.
This commit is contained in:
reaperrr
2016-06-16 15:22:38 +02:00
parent 8e3415e70e
commit 2f1a6e8807
2 changed files with 49 additions and 3 deletions

View File

@@ -82,12 +82,12 @@ namespace OpenRA.Mods.Common.Activities
// Fly towards the target
// TODO: Fix that the helicopter won't do anything if it has multiple weapons with different ranges
// and the weapon with the longest range is out of ammo
if (!target.IsInRange(self.CenterPosition, attackHeli.GetMaximumRange()))
if (!target.IsInRange(self.CenterPosition, attackHeli.GetMaximumRangeVersusTarget(target)))
helicopter.SetPosition(self, helicopter.CenterPosition + helicopter.FlyStep(desiredFacing));
// Fly backwards from the target
// TODO: Same problem as with MaximumRange
if (target.IsInRange(self.CenterPosition, attackHeli.GetMinimumRange()))
if (target.IsInRange(self.CenterPosition, attackHeli.GetMinimumRangeVersusTarget(target)))
{
// Facing 0 doesn't work with the following position change
var facing = 1;