diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 27fb8b166b..dea900a9fa 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -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() diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs index 5e4f5ae634..1a2741d537 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs @@ -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() && a.Info.HasTraitInfo()); forceMoveDisabled = !selectedActors.Any(a => a.Info.HasTraitInfo() || a.Info.HasTraitInfo()); forceAttackDisabled = !selectedActors.Any(a => a.Info.HasTraitInfo()); - scatterDisabled = !selectedActors.Any(a => a.Info.HasTraitInfo()); + scatterDisabled = !selectedActors.Any(a => a.Info.HasTraitInfo()); selectedDeploys = selectedActors .SelectMany(a => a.TraitsImplementing()