diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index 7d06ecf5b2..c6b4e0474d 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -182,7 +182,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(); @@ -236,7 +236,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); @@ -606,7 +607,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 @@ -625,8 +626,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) {