From 71ec93b8ee7eb624d25c22701775ee7f7b7d28d6 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Mon, 18 Feb 2019 19:30:57 +0100 Subject: [PATCH 1/6] Merge HeliReturnToBase into ReturnToBase --- .../Activities/Air/HeliAttack.cs | 2 +- .../Activities/Air/HeliReturnToBase.cs | 127 ------------------ .../Activities/Air/ReturnToBase.cs | 78 +++++++++-- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 - .../Properties/AircraftProperties.cs | 5 +- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 10 +- 6 files changed, 68 insertions(+), 155 deletions(-) delete mode 100644 OpenRA.Mods.Common/Activities/Air/HeliReturnToBase.cs diff --git a/OpenRA.Mods.Common/Activities/Air/HeliAttack.cs b/OpenRA.Mods.Common/Activities/Air/HeliAttack.cs index 9902a470621b..8736f34bc9d0 100644 --- a/OpenRA.Mods.Common/Activities/Air/HeliAttack.cs +++ b/OpenRA.Mods.Common/Activities/Air/HeliAttack.cs @@ -83,7 +83,7 @@ public override Activity Tick(Actor self) // If all valid weapons have depleted their ammo and Rearmable trait exists, return to RearmActor to reload and then resume the activity if (rearmable != null && !useLastVisibleTarget && attackAircraft.Armaments.All(x => x.IsTraitPaused || !x.Weapon.IsValidAgainst(target, self.World, self))) { - QueueChild(self, new HeliReturnToBase(self, aircraft.Info.AbortOnResupply), true); + QueueChild(self, new ReturnToBase(self, aircraft.Info.AbortOnResupply), true); return this; } diff --git a/OpenRA.Mods.Common/Activities/Air/HeliReturnToBase.cs b/OpenRA.Mods.Common/Activities/Air/HeliReturnToBase.cs deleted file mode 100644 index 2a21b505f921..000000000000 --- a/OpenRA.Mods.Common/Activities/Air/HeliReturnToBase.cs +++ /dev/null @@ -1,127 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2019 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. For more - * information, see COPYING. - */ -#endregion - -using System.Collections.Generic; -using System.Linq; -using OpenRA.Activities; -using OpenRA.Mods.Common.Traits; -using OpenRA.Primitives; -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Activities -{ - public class HeliReturnToBase : Activity - { - readonly Aircraft aircraft; - readonly RepairableInfo repairableInfo; - readonly Rearmable rearmable; - readonly bool alwaysLand; - readonly bool abortOnResupply; - Actor dest; - - public HeliReturnToBase(Actor self, bool abortOnResupply, Actor dest = null, bool alwaysLand = true) - { - aircraft = self.Trait(); - repairableInfo = self.Info.TraitInfoOrDefault(); - rearmable = self.TraitOrDefault(); - this.alwaysLand = alwaysLand; - this.abortOnResupply = abortOnResupply; - this.dest = dest; - } - - public override Activity Tick(Actor self) - { - // Refuse to take off if it would land immediately again. - // Special case: Don't kill other deploy hotkey activities. - if (aircraft.ForceLanding) - return NextActivity; - - if (IsCanceling) - return NextActivity; - - if (dest == null || dest.IsDead || !Reservable.IsAvailableFor(dest, self)) - dest = ReturnToBase.ChooseResupplier(self, true); - - var initialFacing = aircraft.Info.InitialFacing; - - if (dest == null || dest.IsDead) - { - var nearestResupplier = ReturnToBase.ChooseResupplier(self, false); - - // If a heli was told to return and there's no (available) RearmBuilding, going to the probable next queued activity (HeliAttack) - // would be pointless (due to lack of ammo), and possibly even lead to an infinite loop due to HeliAttack.cs:L79. - if (nearestResupplier == null && aircraft.Info.LandWhenIdle) - { - if (aircraft.Info.TurnToLand) - return ActivityUtils.SequenceActivities(self, new Turn(self, initialFacing), new HeliLand(self, true)); - - return new HeliLand(self, true); - } - else if (nearestResupplier == null && !aircraft.Info.LandWhenIdle) - return null; - else - { - var distanceFromResupplier = (nearestResupplier.CenterPosition - self.CenterPosition).HorizontalLength; - var distanceLength = aircraft.Info.WaitDistanceFromResupplyBase.Length; - - // If no pad is available, move near one and wait - if (distanceFromResupplier > distanceLength) - { - var randomPosition = WVec.FromPDF(self.World.SharedRandom, 2) * distanceLength / 1024; - - var target = Target.FromPos(nearestResupplier.CenterPosition + randomPosition); - - return ActivityUtils.SequenceActivities(self, - new HeliFly(self, target, WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green), - this); - } - - return this; - } - } - - var landingProcedures = new List(); - var exit = dest.FirstExitOrDefault(null); - var offset = exit != null ? exit.Info.SpawnOffset : WVec.Zero; - - landingProcedures.Add(new HeliFly(self, Target.FromPos(dest.CenterPosition + offset))); - - if (ShouldLandAtBuilding(self, dest)) - { - aircraft.MakeReservation(dest); - - if (aircraft.Info.TurnToDock) - landingProcedures.Add(new Turn(self, initialFacing)); - - landingProcedures.Add(new HeliLand(self, false)); - landingProcedures.Add(new ResupplyAircraft(self)); - if (!abortOnResupply) - landingProcedures.Add(NextActivity); - } - else - landingProcedures.Add(NextActivity); - - return ActivityUtils.SequenceActivities(self, landingProcedures.ToArray()); - } - - bool ShouldLandAtBuilding(Actor self, Actor dest) - { - if (alwaysLand) - return true; - - if (repairableInfo != null && repairableInfo.RepairActors.Contains(dest.Info.Name) && self.GetDamageState() != DamageState.Undamaged) - return true; - - return rearmable != null && rearmable.Info.RearmActors.Contains(dest.Info.Name) - && rearmable.RearmableAmmoPools.Any(p => !p.FullAmmo()); - } - } -} diff --git a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs index 11dee247424a..1fb212cd4cc6 100644 --- a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs +++ b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs @@ -53,15 +53,16 @@ public static Actor ChooseResupplier(Actor self, bool unreservedOnly) .ClosestTo(self); } + // Calculates non-CanHover/non-VTOL approach vector and waypoints void Calculate(Actor self) { - if (dest == null || dest.IsDead || !Reservable.IsAvailableFor(dest, self)) - dest = ChooseResupplier(self, true); - if (dest == null) return; - var landPos = dest.CenterPosition; + var exit = dest.FirstExitOrDefault(null); + var offset = exit != null ? exit.Info.SpawnOffset : WVec.Zero; + + var landPos = dest.CenterPosition + offset; var altitude = aircraft.Info.CruiseAltitude.Length; // Distance required for descent. @@ -127,6 +128,9 @@ public override Activity Tick(Actor self) if (IsCanceling || self.IsDead) return NextActivity; + if (dest == null || dest.IsDead || !Reservable.IsAvailableFor(dest, self)) + dest = ReturnToBase.ChooseResupplier(self, true); + if (!isCalculated) Calculate(self); @@ -135,10 +139,39 @@ public override Activity Tick(Actor self) var nearestResupplier = ChooseResupplier(self, false); if (nearestResupplier != null) - return ActivityUtils.SequenceActivities(self, - new Fly(self, Target.FromActor(nearestResupplier), WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green), - new FlyCircle(self, aircraft.Info.NumberOfTicksToVerifyAvailableAirport), - this); + { + if (aircraft.Info.VTOL) + { + var distanceFromResupplier = (nearestResupplier.CenterPosition - self.CenterPosition).HorizontalLength; + var distanceLength = aircraft.Info.WaitDistanceFromResupplyBase.Length; + + // If no pad is available, move near one and wait + if (distanceFromResupplier > distanceLength) + { + var randomPosition = WVec.FromPDF(self.World.SharedRandom, 2) * distanceLength / 1024; + + var target = Target.FromPos(nearestResupplier.CenterPosition + randomPosition); + + return ActivityUtils.SequenceActivities(self, + new HeliFly(self, target, WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green), + this); + } + + return this; + } + else + return ActivityUtils.SequenceActivities(self, + new Fly(self, Target.FromActor(nearestResupplier), WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green), + new FlyCircle(self, aircraft.Info.NumberOfTicksToVerifyAvailableAirport), + this); + } + else if (nearestResupplier == null && aircraft.Info.VTOL && aircraft.Info.LandWhenIdle) + { + if (aircraft.Info.TurnToLand) + return ActivityUtils.SequenceActivities(self, new Turn(self, aircraft.Info.InitialFacing), new HeliLand(self, true)); + + return new HeliLand(self, true); + } else { // Prevent an infinite loop in case we'd return to the activity that called ReturnToBase in the first place. Go idle instead. @@ -147,21 +180,38 @@ public override Activity Tick(Actor self) } } + var exit = dest.FirstExitOrDefault(null); + var offset = exit != null ? exit.Info.SpawnOffset : WVec.Zero; + List landingProcedures = new List(); - var turnRadius = Fly.CalculateTurnRadius(aircraft.Info.Speed, aircraft.Info.TurnSpeed); + if (aircraft.Info.CanHover) + landingProcedures.Add(new HeliFly(self, Target.FromPos(dest.CenterPosition + offset))); + else + { + var turnRadius = Fly.CalculateTurnRadius(aircraft.Info.Speed, aircraft.Info.TurnSpeed); - landingProcedures.Add(new Fly(self, Target.FromPos(w1), WDist.Zero, new WDist(turnRadius * 3))); - landingProcedures.Add(new Fly(self, Target.FromPos(w2))); + landingProcedures.Add(new Fly(self, Target.FromPos(w1), WDist.Zero, new WDist(turnRadius * 3))); + landingProcedures.Add(new Fly(self, Target.FromPos(w2))); - // Fix a problem when the airplane is send to resupply near the airport - landingProcedures.Add(new Fly(self, Target.FromPos(w3), WDist.Zero, new WDist(turnRadius / 2))); + // Fix a problem when the airplane is sent to resupply near the airport + landingProcedures.Add(new Fly(self, Target.FromPos(w3), WDist.Zero, new WDist(turnRadius / 2))); + } if (ShouldLandAtBuilding(self, dest)) { aircraft.MakeReservation(dest); - landingProcedures.Add(new Land(self, Target.FromActor(dest))); + if (aircraft.Info.VTOL) + { + if (aircraft.Info.TurnToDock) + landingProcedures.Add(new Turn(self, aircraft.Info.InitialFacing)); + + landingProcedures.Add(new HeliLand(self, false)); + } + else + landingProcedures.Add(new Land(self, Target.FromPos(dest.CenterPosition + offset))); + landingProcedures.Add(new ResupplyAircraft(self)); } diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index c18c4b8dad8d..5ba8c1233c04 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -75,7 +75,6 @@ - diff --git a/OpenRA.Mods.Common/Scripting/Properties/AircraftProperties.cs b/OpenRA.Mods.Common/Scripting/Properties/AircraftProperties.cs index b79b79d1cceb..f91961f03c0b 100644 --- a/OpenRA.Mods.Common/Scripting/Properties/AircraftProperties.cs +++ b/OpenRA.Mods.Common/Scripting/Properties/AircraftProperties.cs @@ -41,10 +41,7 @@ public void Move(CPos cell) [Desc("Return to the base, which is either the destination given, or an auto-selected one otherwise.")] public void ReturnToBase(Actor destination = null) { - if (!aircraftInfo.CanHover) - Self.QueueActivity(new ReturnToBase(Self, false, destination)); - else - Self.QueueActivity(new HeliReturnToBase(Self, false, destination)); + Self.QueueActivity(new ReturnToBase(Self, false, destination)); } [ScriptActorPropertyActivity] diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index ead3d2b77483..fda0590fe429 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -844,10 +844,7 @@ public void ResolveOrder(Actor self, Order order) if (Reservable.IsAvailableFor(targetActor, self)) self.SetTargetLine(Target.FromActor(targetActor), Color.Green); - if (!Info.CanHover && !Info.VTOL) - self.QueueActivity(order.Queued, new ReturnToBase(self, Info.AbortOnResupply, targetActor)); - else - self.QueueActivity(order.Queued, new HeliReturnToBase(self, Info.AbortOnResupply, targetActor)); + self.QueueActivity(order.Queued, new ReturnToBase(self, Info.AbortOnResupply, targetActor)); } else if (order.OrderString == "Stop") { @@ -865,10 +862,7 @@ public void ResolveOrder(Actor self, Order order) if (!order.Queued) UnReserve(); - if (!Info.CanHover) - self.QueueActivity(order.Queued, new ReturnToBase(self, Info.AbortOnResupply, null, false)); - else - self.QueueActivity(order.Queued, new HeliReturnToBase(self, Info.AbortOnResupply, null, false)); + self.QueueActivity(order.Queued, new ReturnToBase(self, Info.AbortOnResupply, null, false)); } } From bcb8e608118c3b687ce8cc321257b77574e22f55 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 24 Feb 2019 23:09:25 +0100 Subject: [PATCH 2/6] Exclude dead actors from ChooseResupplier --- OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs index 1fb212cd4cc6..6924ceb6714a 100644 --- a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs +++ b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs @@ -47,7 +47,8 @@ public static Actor ChooseResupplier(Actor self, bool unreservedOnly) return null; return self.World.ActorsHavingTrait() - .Where(a => a.Owner == self.Owner + .Where(a => !a.IsDead + && a.Owner == self.Owner && rearmInfo.RearmActors.Contains(a.Info.Name) && (!unreservedOnly || Reservable.IsAvailableFor(a, self))) .ClosestTo(self); From 1b3893b4bdf92df55123f929151f933859310a0b Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 10 Mar 2019 02:14:03 +0100 Subject: [PATCH 3/6] Improve ReturnToBase Activity.cs adherance And make it use child activities for queueability. --- .../Activities/Air/FlyCircle.cs | 2 +- .../Activities/Air/ReturnToBase.cs | 72 ++++++++++++------- 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Air/FlyCircle.cs b/OpenRA.Mods.Common/Activities/Air/FlyCircle.cs index 1176449a874c..f55324d61479 100644 --- a/OpenRA.Mods.Common/Activities/Air/FlyCircle.cs +++ b/OpenRA.Mods.Common/Activities/Air/FlyCircle.cs @@ -29,7 +29,7 @@ public FlyCircle(Actor self, int ticks = -1, int turnSpeedOverride = -1) public override Activity Tick(Actor self) { - if (NextActivity != null && remainingTicks <= 0) + if (remainingTicks == 0 || (NextActivity != null && remainingTicks < 0)) return NextActivity; // Refuse to take off if it would land immediately again. diff --git a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs index 6924ceb6714a..9ad1e2de2717 100644 --- a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs +++ b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs @@ -27,6 +27,7 @@ public class ReturnToBase : Activity readonly bool alwaysLand; readonly bool abortOnResupply; bool isCalculated; + bool resupplied; Actor dest; WPos w1, w2, w3; @@ -121,12 +122,29 @@ bool ShouldLandAtBuilding(Actor self, Actor dest) public override Activity Tick(Actor self) { + if (ChildActivity != null) + { + ChildActivity = ActivityUtils.RunActivity(self, ChildActivity); + if (ChildActivity != null) + return this; + } + // Refuse to take off if it would land immediately again. // Special case: Don't kill other deploy hotkey activities. if (aircraft.ForceLanding) return NextActivity; - if (IsCanceling || self.IsDead) + // If a Cancel was triggered at this point, it's unlikely that previously queued child activities finished, + // so 'resupplied' needs to be set to false, else it + abortOnResupply might cause another Cancel + // that would cancel any other activities that were queued after the first Cancel was triggered. + // TODO: This is a mess, we need to somehow make the activity cancelling a bit less tricky. + if (resupplied && IsCanceling) + resupplied = false; + + if (resupplied && abortOnResupply) + Cancel(self); + + if (resupplied || IsCanceling || self.IsDead) return NextActivity; if (dest == null || dest.IsDead || !Reservable.IsAvailableFor(dest, self)) @@ -135,13 +153,13 @@ public override Activity Tick(Actor self) if (!isCalculated) Calculate(self); - if (dest == null || dest.IsDead) + if (dest == null) { var nearestResupplier = ChooseResupplier(self, false); if (nearestResupplier != null) { - if (aircraft.Info.VTOL) + if (aircraft.Info.CanHover) { var distanceFromResupplier = (nearestResupplier.CenterPosition - self.CenterPosition).HorizontalLength; var distanceLength = aircraft.Info.WaitDistanceFromResupplyBase.Length; @@ -150,28 +168,32 @@ public override Activity Tick(Actor self) if (distanceFromResupplier > distanceLength) { var randomPosition = WVec.FromPDF(self.World.SharedRandom, 2) * distanceLength / 1024; - var target = Target.FromPos(nearestResupplier.CenterPosition + randomPosition); - return ActivityUtils.SequenceActivities(self, - new HeliFly(self, target, WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green), - this); + QueueChild(self, new HeliFly(self, target, WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green), true); } return this; } else - return ActivityUtils.SequenceActivities(self, + { + QueueChild(self, new Fly(self, Target.FromActor(nearestResupplier), WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green), - new FlyCircle(self, aircraft.Info.NumberOfTicksToVerifyAvailableAirport), - this); + true); + + QueueChild(self, new FlyCircle(self, aircraft.Info.NumberOfTicksToVerifyAvailableAirport), true); + return this; + } } else if (nearestResupplier == null && aircraft.Info.VTOL && aircraft.Info.LandWhenIdle) { + // Using Queue instead of QueueChild here is intentional, as we want VTOLs with LandWhenIdle to land and stay there in this situation + Cancel(self); if (aircraft.Info.TurnToLand) - return ActivityUtils.SequenceActivities(self, new Turn(self, aircraft.Info.InitialFacing), new HeliLand(self, true)); + Queue(self, new Turn(self, aircraft.Info.InitialFacing)); - return new HeliLand(self, true); + Queue(self, new HeliLand(self, true)); + return NextActivity; } else { @@ -184,19 +206,19 @@ public override Activity Tick(Actor self) var exit = dest.FirstExitOrDefault(null); var offset = exit != null ? exit.Info.SpawnOffset : WVec.Zero; - List landingProcedures = new List(); - if (aircraft.Info.CanHover) - landingProcedures.Add(new HeliFly(self, Target.FromPos(dest.CenterPosition + offset))); + QueueChild(self, new HeliFly(self, Target.FromPos(dest.CenterPosition + offset)), true); + else if (aircraft.Info.VTOL) + QueueChild(self, new Fly(self, Target.FromPos(dest.CenterPosition + offset)), true); else { var turnRadius = Fly.CalculateTurnRadius(aircraft.Info.Speed, aircraft.Info.TurnSpeed); - landingProcedures.Add(new Fly(self, Target.FromPos(w1), WDist.Zero, new WDist(turnRadius * 3))); - landingProcedures.Add(new Fly(self, Target.FromPos(w2))); + QueueChild(self, new Fly(self, Target.FromPos(w1), WDist.Zero, new WDist(turnRadius * 3)), true); + QueueChild(self, new Fly(self, Target.FromPos(w2)), true); // Fix a problem when the airplane is sent to resupply near the airport - landingProcedures.Add(new Fly(self, Target.FromPos(w3), WDist.Zero, new WDist(turnRadius / 2))); + QueueChild(self, new Fly(self, Target.FromPos(w3), WDist.Zero, new WDist(turnRadius / 2)), true); } if (ShouldLandAtBuilding(self, dest)) @@ -206,20 +228,18 @@ public override Activity Tick(Actor self) if (aircraft.Info.VTOL) { if (aircraft.Info.TurnToDock) - landingProcedures.Add(new Turn(self, aircraft.Info.InitialFacing)); + QueueChild(self, new Turn(self, aircraft.Info.InitialFacing), true); - landingProcedures.Add(new HeliLand(self, false)); + QueueChild(self, new HeliLand(self, false), true); } else - landingProcedures.Add(new Land(self, Target.FromPos(dest.CenterPosition + offset))); + QueueChild(self, new Land(self, Target.FromPos(dest.CenterPosition + offset)), true); - landingProcedures.Add(new ResupplyAircraft(self)); + QueueChild(self, new ResupplyAircraft(self), true); + resupplied = true; } - if (!abortOnResupply) - landingProcedures.Add(NextActivity); - - return ActivityUtils.SequenceActivities(self, landingProcedures.ToArray()); + return this; } } } From 776e860c561998cf9a94aff8b1e923aa8bbb4dd9 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 31 Mar 2019 23:30:49 +0200 Subject: [PATCH 4/6] Make aircraft without TakeOffOnResupply always land on resupplier, even if ammo is full, when given a "ReturnToBase" order via deploy key. In other words, in that case treat the RTB order like an explicit "Repair" or "Enter" order. --- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index fda0590fe429..75fb8d506509 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -862,7 +862,9 @@ public void ResolveOrder(Actor self, Order order) if (!order.Queued) UnReserve(); - self.QueueActivity(order.Queued, new ReturnToBase(self, Info.AbortOnResupply, null, false)); + // Aircraft with TakeOffOnResupply would immediately take off again, so there's no point in forcing them to land + // 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)); } } From 12a6a0da6c16b8accbd6d191bf42a84ed890d10d Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 31 Mar 2019 23:58:23 +0200 Subject: [PATCH 5/6] Fix ReturnToBase restarting on each hotkey press Now that the RTB process is a single activity with childs, it's relatively easy to prevent the activity from restarting every time the deploy/RTB hotkey is pressed. --- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 75fb8d506509..b3ecb28df59d 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -859,6 +859,10 @@ public void ResolveOrder(Actor self, Order order) } else if (order.OrderString == "ReturnToBase" && rearmable != null && rearmable.Info.RearmActors.Any()) { + // Don't restart activity every time deploy hotkey is triggered + if (self.CurrentActivity is ReturnToBase) + return; + if (!order.Queued) UnReserve(); From 318c86fb92ccd69dd019b7f3e404b236af699325 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 4 Apr 2019 20:49:05 +0200 Subject: [PATCH 6/6] Make actors ignore ReturnToBase order if already on resupplier --- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index b3ecb28df59d..1645a3848d1f 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -860,7 +860,7 @@ public void ResolveOrder(Actor self, Order order) else if (order.OrderString == "ReturnToBase" && rearmable != null && rearmable.Info.RearmActors.Any()) { // Don't restart activity every time deploy hotkey is triggered - if (self.CurrentActivity is ReturnToBase) + if (self.CurrentActivity is ReturnToBase || GetActorBelow() != null) return; if (!order.Queued)