Use FlyForward for strafing

This commit is contained in:
abcdefg30
2020-04-13 18:47:48 +02:00
committed by Paul Chote
parent a66305e282
commit 559b143265

View File

@@ -164,7 +164,7 @@ namespace OpenRA.Mods.Common.Activities
// The aircraft must keep moving forward even if it is already in an ideal position.
else if (attackAircraft.Info.AttackType == AirAttackType.Strafe)
QueueChild(new StrafeAttackRun(self, attackAircraft, target, strafeDistance != WDist.Zero ? strafeDistance : lastVisibleMaximumRange));
QueueChild(new StrafeAttackRun(self, attackAircraft, aircraft, target, strafeDistance != WDist.Zero ? strafeDistance : lastVisibleMaximumRange));
else if (attackAircraft.Info.AttackType == AirAttackType.Default && !aircraft.Info.CanHover)
QueueChild(new FlyAttackRun(self, target, lastVisibleMaximumRange));
@@ -226,6 +226,9 @@ namespace OpenRA.Mods.Common.Activities
if (target.IsValidFor(self))
{
QueueChild(new Fly(self, target, target.CenterPosition));
// Fly a single tick forward so we have passed the target and start flying out of range facing away from it
QueueChild(new FlyForward(self, 1));
QueueChild(new Fly(self, target, exitRange, WDist.MaxValue, target.CenterPosition));
}
else
@@ -252,16 +255,18 @@ namespace OpenRA.Mods.Common.Activities
class StrafeAttackRun : Activity
{
readonly AttackAircraft attackAircraft;
readonly Aircraft aircraft;
readonly WDist exitRange;
Target target;
public StrafeAttackRun(Actor self, AttackAircraft attackAircraft, in Target t, WDist exitRange)
public StrafeAttackRun(Actor self, AttackAircraft attackAircraft, Aircraft aircraft, in Target t, WDist exitRange)
{
ChildHasPriority = false;
target = t;
this.attackAircraft = attackAircraft;
this.aircraft = aircraft;
this.exitRange = exitRange;
}
@@ -271,7 +276,11 @@ namespace OpenRA.Mods.Common.Activities
if (target.IsValidFor(self))
{
QueueChild(new Fly(self, target, target.CenterPosition));
QueueChild(new Fly(self, target, exitRange, WDist.MaxValue, target.CenterPosition));
QueueChild(new FlyForward(self, exitRange));
// Exit the range and then fly enough to turn towards the target for another run
var distanceToTurn = new WDist(aircraft.Info.Speed * 256 / aircraft.Info.TurnSpeed.Angle);
QueueChild(new Fly(self, target, exitRange + distanceToTurn, WDist.MaxValue, target.CenterPosition));
}
else
Cancel(self);