Navigation Menu

Skip to content

Commit

Permalink
Aircraft can now scatter
Browse files Browse the repository at this point in the history
  • Loading branch information
BGluth authored and reaperrr committed Apr 22, 2019
1 parent e801537 commit 55aa346
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 24 additions & 0 deletions OpenRA.Mods.Common/Traits/Air/Aircraft.cs
Expand Up @@ -911,6 +911,7 @@ public string VoicePhraseForOrder(Actor self, Order order)
return Info.Voice;
case "Enter":
case "Stop":
case "Scatter":
return Info.Voice;
case "ReturnToBase":
return rearmable != null && rearmable.Info.RearmActors.Any() ? Info.Voice : null;
Expand Down Expand Up @@ -980,10 +981,33 @@ public void ResolveOrder(Actor self, Order order)
// 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()
Expand Down
3 changes: 2 additions & 1 deletion OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs
Expand Up @@ -16,6 +16,7 @@
using OpenRA.Mods.Common.Orders;
using OpenRA.Mods.Common.Traits;
using OpenRA.Orders;
using OpenRA.Traits;
using OpenRA.Widgets;

namespace OpenRA.Mods.Common.Widgets
Expand Down Expand Up @@ -291,7 +292,7 @@ void UpdateStateIfNecessary()
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>()
Expand Down

0 comments on commit 55aa346

Please sign in to comment.