diff --git a/OpenRA.Mods.Cnc/Traits/Buildings/ProductionAirdrop.cs b/OpenRA.Mods.Cnc/Traits/Buildings/ProductionAirdrop.cs index 49ae951bbe..c99c41ae21 100644 --- a/OpenRA.Mods.Cnc/Traits/Buildings/ProductionAirdrop.cs +++ b/OpenRA.Mods.Cnc/Traits/Buildings/ProductionAirdrop.cs @@ -83,7 +83,7 @@ namespace OpenRA.Mods.Cnc.Traits Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.ReadyAudio, self.Owner.Faction.InternalName); })); - actor.QueueActivity(new Fly(actor, Target.FromCell(w, endPos))); + actor.QueueActivity(new FlyOffMap(actor, Target.FromCell(w, endPos))); actor.QueueActivity(new RemoveSelf()); }); diff --git a/OpenRA.Mods.Common/Activities/Air/FlyOffMap.cs b/OpenRA.Mods.Common/Activities/Air/FlyOffMap.cs index 64c6ecb36c..f6ddb80633 100644 --- a/OpenRA.Mods.Common/Activities/Air/FlyOffMap.cs +++ b/OpenRA.Mods.Common/Activities/Air/FlyOffMap.cs @@ -11,16 +11,43 @@ using OpenRA.Activities; using OpenRA.Mods.Common.Traits; +using OpenRA.Traits; namespace OpenRA.Mods.Common.Activities { public class FlyOffMap : Activity { readonly Aircraft aircraft; + readonly Target target; + readonly bool hasTarget; public FlyOffMap(Actor self) { aircraft = self.Trait(); + ChildHasPriority = false; + } + + public FlyOffMap(Actor self, Target target) + { + aircraft = self.Trait(); + ChildHasPriority = false; + this.target = target; + hasTarget = true; + } + + protected override void OnFirstRun(Actor self) + { + if (hasTarget) + { + QueueChild(new Fly(self, target)); + return; + } + + // VTOLs must take off first if they're not at cruise altitude + if (aircraft.Info.VTOL && self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition) != aircraft.Info.CruiseAltitude) + QueueChild(new TakeOff(self)); + + QueueChild(new FlyTimed(-1, self)); } public override bool Tick(Actor self) @@ -35,8 +62,7 @@ namespace OpenRA.Mods.Common.Activities if (IsCanceling || !self.World.Map.Contains(self.Location)) return true; - Fly.FlyTick(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude); - return false; + return TickChild(self); } } }