Fix Helis facing target center instead of attacked position
This commit is contained in:
@@ -62,10 +62,12 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (IsCanceled || !target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
var pos = self.CenterPosition;
|
||||
var targetPos = attackHeli.GetTargetPosition(pos, target);
|
||||
if (attackOnlyVisibleTargets && target.Type == TargetType.Actor && canHideUnderFog
|
||||
&& !self.Owner.CanTargetActor(target.Actor))
|
||||
{
|
||||
var newTarget = Target.FromCell(self.World, self.World.Map.CellContaining(target.CenterPosition));
|
||||
var newTarget = Target.FromCell(self.World, self.World.Map.CellContaining(targetPos));
|
||||
|
||||
Cancel(self);
|
||||
self.SetTargetLine(newTarget, Color.Green);
|
||||
@@ -76,7 +78,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (ammoPools.Any(x => !x.Info.SelfReloads && !x.HasAmmo()) && !attackHeli.HasAnyValidWeapons(target))
|
||||
return ActivityUtils.SequenceActivities(new HeliReturnToBase(self, helicopter.Info.AbortOnResupply), this);
|
||||
|
||||
var dist = target.CenterPosition - self.CenterPosition;
|
||||
var dist = targetPos - pos;
|
||||
|
||||
// Can rotate facing while ascending
|
||||
var desiredFacing = dist.HorizontalLengthSquared != 0 ? dist.Yaw.Facing : helicopter.Facing;
|
||||
@@ -86,11 +88,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return this;
|
||||
|
||||
// Fly towards the target
|
||||
if (!target.IsInRange(self.CenterPosition, attackHeli.GetMaximumRangeVersusTarget(target)))
|
||||
if (!target.IsInRange(pos, attackHeli.GetMaximumRangeVersusTarget(target)))
|
||||
helicopter.SetPosition(self, helicopter.CenterPosition + helicopter.FlyStep(desiredFacing));
|
||||
|
||||
// Fly backwards from the target
|
||||
if (target.IsInRange(self.CenterPosition, attackHeli.GetMinimumRangeVersusTarget(target)))
|
||||
if (target.IsInRange(pos, attackHeli.GetMinimumRangeVersusTarget(target)))
|
||||
{
|
||||
// Facing 0 doesn't work with the following position change
|
||||
var facing = 1;
|
||||
|
||||
Reference in New Issue
Block a user