Aircraft can now scatter

This commit is contained in:
BGluth
2019-04-22 18:37:14 +00:00
committed by reaperrr
parent e801537d96
commit 55aa346ad7
2 changed files with 26 additions and 1 deletions

View File

@@ -911,6 +911,7 @@ namespace OpenRA.Mods.Common.Traits
return Info.Voice;
case "Enter":
case "Stop":
case "Scatter":
return Info.Voice;
case "ReturnToBase":
return rearmable != null && rearmable.Info.RearmActors.Any() ? Info.Voice : null;
@@ -980,10 +981,33 @@ namespace OpenRA.Mods.Common.Traits
// on a resupplier. For aircraft without it, it makes more sense to land than to idle above a free resupplier, though.
self.QueueActivity(order.Queued, new ReturnToBase(self, Info.AbortOnResupply, null, !Info.TakeOffOnResupply));
}
else if (order.OrderString == "Scatter")
Nudge(self);
}
#endregion
void Nudge(Actor self)
{
// Disable nudging if the aircraft is outside the map
if (!self.World.Map.Contains(self.Location))
return;
var offset = new WVec(0, -self.World.SharedRandom.Next(512, 2048), 0)
.Rotate(WRot.FromFacing(self.World.SharedRandom.Next(256)));
var target = Target.FromPos(self.CenterPosition + offset);
self.CancelActivity();
self.SetTargetLine(target, Color.Green, false);
if (!Info.CanHover)
self.QueueActivity(new Fly(self, target));
else
self.QueueActivity(new HeliFlyAndLandWhenIdle(self, target, Info));
UnReserve();
}
#region Airborne conditions
void OnAirborneAltitudeReached()

View File

@@ -16,6 +16,7 @@ using OpenRA.Graphics;
using OpenRA.Mods.Common.Orders;
using OpenRA.Mods.Common.Traits;
using OpenRA.Orders;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets
@@ -291,7 +292,7 @@ namespace OpenRA.Mods.Common.Widgets
guardDisabled = !selectedActors.Any(a => a.Info.HasTraitInfo<GuardInfo>() && a.Info.HasTraitInfo<AutoTargetInfo>());
forceMoveDisabled = !selectedActors.Any(a => a.Info.HasTraitInfo<MobileInfo>() || a.Info.HasTraitInfo<AircraftInfo>());
forceAttackDisabled = !selectedActors.Any(a => a.Info.HasTraitInfo<AttackBaseInfo>());
scatterDisabled = !selectedActors.Any(a => a.Info.HasTraitInfo<MobileInfo>());
scatterDisabled = !selectedActors.Any(a => a.Info.HasTraitInfo<IMoveInfo>());
selectedDeploys = selectedActors
.SelectMany(a => a.TraitsImplementing<IIssueDeployOrder>()