From d99a47245622eb627235c510dce42a3d6bfd07d3 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Mon, 21 Aug 2017 15:03:04 +0200 Subject: [PATCH] Fix HackyAI trying to deploy undeployable actors --- OpenRA.Mods.Common/AI/HackyAI.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index 8559bcca92..104726f83d 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -979,12 +979,16 @@ namespace OpenRA.Mods.Common.AI if (!mcv.IsIdle) continue; + // Don't try to move and deploy an undeployable actor + var transformsInfo = mcv.Info.TraitInfoOrDefault(); + if (transformsInfo == null) + continue; + // If we lack a base, we need to make sure we don't restrict deployment of the MCV to the base! - var restrictToBase = - Info.RestrictMCVDeploymentFallbackToBase && + var restrictToBase = Info.RestrictMCVDeploymentFallbackToBase && CountBuildingByCommonName(Info.BuildingCommonNames.ConstructionYard, Player) > 0; - var factType = mcv.Info.TraitInfo().IntoActor; - var desiredLocation = ChooseBuildLocation(factType, restrictToBase, BuildingType.Building); + + var desiredLocation = ChooseBuildLocation(transformsInfo.IntoActor, restrictToBase, BuildingType.Building); if (desiredLocation == null) continue;