diff --git a/OpenRA.Mods.Common/Scripting/Global/ReinforcementsGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/ReinforcementsGlobal.cs index 1c29681d7c..eff19d29c6 100644 --- a/OpenRA.Mods.Common/Scripting/Global/ReinforcementsGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/ReinforcementsGlobal.cs @@ -26,7 +26,13 @@ namespace OpenRA.Mods.Common.Scripting [ScriptGlobal("Reinforcements")] public class ReinforcementsGlobal : ScriptGlobal { - public ReinforcementsGlobal(ScriptContext context) : base(context) { } + readonly DomainIndex domainIndex; + + public ReinforcementsGlobal(ScriptContext context) + : base(context) + { + domainIndex = context.World.WorldActor.Trait(); + } Actor CreateActor(Player owner, string actorType, bool addToWorld, CPos? entryLocation = null, CPos? nextLocation = null) { @@ -153,11 +159,23 @@ namespace OpenRA.Mods.Common.Scripting // Try to find an alternative landing spot if we can't land at the current destination if (!aircraft.CanLand(destination) && dropRange > 0) { + var mobiles = cargo != null ? cargo.Passengers.Select(a => + { + var mobileInfo = a.Info.TraitInfoOrDefault(); + if (mobileInfo == null) + return new Pair(null, 0); + + return new Pair(mobileInfo, (uint)mobileInfo.GetMovementClass(a.World.Map.Rules.TileSet)); + }) : new Pair[0]; + foreach (var c in transport.World.Map.FindTilesInCircle(destination, dropRange)) { if (!aircraft.CanLand(c)) continue; + if (!mobiles.All(m => m.First == null || domainIndex.IsPassable(destination, c, m.First, m.Second))) + continue; + destination = c; break; }