Make helicopters move backwards when target is too close
'Too close' as in closer than weapons' MinRange.
This commit is contained in:
@@ -57,6 +57,19 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (!target.IsInRange(self.CenterPosition, attackHeli.GetMaximumRange()))
|
if (!target.IsInRange(self.CenterPosition, attackHeli.GetMaximumRange()))
|
||||||
helicopter.SetPosition(self, helicopter.CenterPosition + helicopter.FlyStep(desiredFacing));
|
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()))
|
||||||
|
{
|
||||||
|
// Facing 0 doesn't work with the following position change
|
||||||
|
var facing = 1;
|
||||||
|
if (desiredFacing != 0)
|
||||||
|
facing = desiredFacing;
|
||||||
|
else if (helicopter.Facing != 0)
|
||||||
|
facing = helicopter.Facing;
|
||||||
|
helicopter.SetPosition(self, helicopter.CenterPosition + helicopter.FlyStep(-facing));
|
||||||
|
}
|
||||||
|
|
||||||
attackHeli.DoAttack(self, target);
|
attackHeli.DoAttack(self, target);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -157,6 +157,15 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return Armaments.Any(a => a.Weapon.IsValidAgainst(t, self.World, self));
|
return Armaments.Any(a => a.Weapon.IsValidAgainst(t, self.World, self));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WRange GetMinimumRange()
|
||||||
|
{
|
||||||
|
if (IsTraitDisabled)
|
||||||
|
return WRange.Zero;
|
||||||
|
|
||||||
|
return Armaments.Where(a => !a.IsTraitDisabled)
|
||||||
|
.Select(a => a.Weapon.MinRange).Min();
|
||||||
|
}
|
||||||
|
|
||||||
public WRange GetMaximumRange()
|
public WRange GetMaximumRange()
|
||||||
{
|
{
|
||||||
if (IsTraitDisabled)
|
if (IsTraitDisabled)
|
||||||
|
|||||||
Reference in New Issue
Block a user