Allow VTOLs to land with force-move

This commit is contained in:
tovl
2019-06-30 10:11:42 +00:00
committed by reaperrr
parent 8e5875453a
commit 79a48765d9
13 changed files with 58 additions and 32 deletions

View File

@@ -119,20 +119,22 @@ namespace OpenRA.Mods.Common.Activities
// Look for free landing cell
if (target.Type == TargetType.Terrain && !landingInitiated)
{
var targetLocation = aircraft.FindLandingLocation(landingCell, landRange);
if (!targetLocation.HasValue)
var newLocation = aircraft.FindLandingLocation(landingCell, landRange);
// Cannot land so fly towards the last target location instead.
if (!newLocation.HasValue)
{
// Maintain holding pattern.
if (aircraft.Info.CanHover)
QueueChild(self, new Wait(25), true);
else
QueueChild(self, new FlyCircle(self, 25), true);
Cancel(self, true);
QueueChild(self, aircraft.MoveTo(landingCell, 0), true);
return this;
}
target = Target.FromCell(self.World, targetLocation.Value);
targetPosition = target.CenterPosition + offset;
landingCell = self.World.Map.CellContaining(targetPosition);
if (newLocation.Value != landingCell)
{
target = Target.FromCell(self.World, newLocation.Value);
targetPosition = target.CenterPosition + offset;
landingCell = self.World.Map.CellContaining(targetPosition);
}
}
// Move towards landing location

View File

@@ -97,6 +97,9 @@ namespace OpenRA.Mods.Common.Activities
// Checking for NextActivity == null again in case another activity was queued while taking off
if (moveToRallyPoint && NextActivity == null)
{
if (!aircraft.Info.VTOL && assignTargetOnFirstRun)
return NextActivity;
QueueChild(self, new AttackMoveActivity(self, () => move.MoveToTarget(self, target)), true);
moveToRallyPoint = false;
return this;

View File

@@ -66,7 +66,15 @@ namespace OpenRA.Mods.Common.Activities
if (cargo != carryall.Carryable)
return NextActivity;
if (cargo.IsDead || IsCanceling || carryable.IsTraitDisabled || !cargo.AppearsFriendlyTo(self))
if (IsCanceling)
{
if (carryall.State == Carryall.CarryallState.Reserved)
carryall.UnreserveCarryable(self);
return NextActivity;
}
if (cargo.IsDead || carryable.IsTraitDisabled || !cargo.AppearsFriendlyTo(self))
{
carryall.UnreserveCarryable(self);
return NextActivity;
@@ -93,14 +101,15 @@ namespace OpenRA.Mods.Common.Activities
{
// Land at the target location
var localOffset = carryall.OffsetForCarryable(self, cargo).Rotate(carryableBody.QuantizeOrientation(self, cargo.Orientation));
QueueChild(self, new Land(self, Target.FromActor(cargo), -carryableBody.LocalToWorld(localOffset), carryableFacing.Facing));
QueueChild(self, new Land(self, Target.FromActor(cargo), -carryableBody.LocalToWorld(localOffset), carryableFacing.Facing), true);
// Pause briefly before attachment for visual effect
if (delay > 0)
QueueChild(self, new Wait(delay, false), true);
QueueChild(self, new Wait(delay, false));
// Remove our carryable from world
QueueChild(self, new CallFunc(() => Attach(self)));
QueueChild(self, new TakeOff(self));
return this;
}
}