diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index 3dfd4d2c8e..0aa7058bdc 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -188,7 +188,7 @@ namespace OpenRA.Mods.Common.AI readonly IPathFinder pathfinder; readonly Func isEnemyUnit; - readonly Predicate unitIsDeadOrHasNewOwner; + readonly Predicate unitCannotBeOrdered; Dictionary waitingPowers = new Dictionary(); Dictionary powerDecisions = new Dictionary(); @@ -242,7 +242,8 @@ namespace OpenRA.Mods.Common.AI Player.Stances[unit.Owner] == Stance.Enemy && !unit.Info.HasTraitInfo() && unit.Info.HasTraitInfo(); - unitIsDeadOrHasNewOwner = a => a.Owner != Player || a.IsDead; + + unitCannotBeOrdered = a => a.Owner != Player || a.IsDead || !a.IsInWorld; foreach (var decision in info.PowerDecisions) powerDecisions.Add(decision.OrderName, decision); @@ -612,7 +613,7 @@ namespace OpenRA.Mods.Common.AI { squads.RemoveAll(s => !s.IsValid); foreach (var s in squads) - s.Units.RemoveAll(unitIsDeadOrHasNewOwner); + s.Units.RemoveAll(unitCannotBeOrdered); } // Use of this function requires that one squad of this type. Hence it is a piece of shit @@ -631,8 +632,9 @@ namespace OpenRA.Mods.Common.AI void AssignRolesToIdleUnits(Actor self) { CleanSquads(); - activeUnits.RemoveAll(unitIsDeadOrHasNewOwner); - unitsHangingAroundTheBase.RemoveAll(unitIsDeadOrHasNewOwner); + + activeUnits.RemoveAll(unitCannotBeOrdered); + unitsHangingAroundTheBase.RemoveAll(unitCannotBeOrdered); if (--rushTicks <= 0) {