diff --git a/OpenRA.Mods.Common/Scripting/Properties/ProductionProperties.cs b/OpenRA.Mods.Common/Scripting/Properties/ProductionProperties.cs index eb02f93b78..f67e25ca3c 100644 --- a/OpenRA.Mods.Common/Scripting/Properties/ProductionProperties.cs +++ b/OpenRA.Mods.Common/Scripting/Properties/ProductionProperties.cs @@ -34,19 +34,22 @@ namespace OpenRA.Mods.Common.Scripting [ScriptActorPropertyActivity] [Desc("Build a unit, ignoring the production queue. The activity will wait if the exit is blocked.", - "If productionType is nil or unavailable, then an exit will be selected based on Buildable info.")] + "If productionType is nil or unavailable, then an exit will be selected based on 'Buildable.BuildAtProductionType'.", + "If 'Buildable.BuildAtProductionType' is not set either, a random exit will be selected.")] public void Produce(string actorType, string factionVariant = null, string productionType = null) { ActorInfo actorInfo; if (!Self.World.Map.Rules.Actors.TryGetValue(actorType, out actorInfo)) throw new LuaException("Unknown actor type '{0}'".F(actorType)); + var bi = actorInfo.TraitInfo(); Self.QueueActivity(new WaitFor(() => { // Go through all available traits and see which one successfully produces foreach (var p in productionTraits) { - if (!string.IsNullOrEmpty(productionType) && !p.Info.Produces.Contains(productionType)) + var type = productionType ?? bi.BuildAtProductionType; + if (!string.IsNullOrEmpty(type) && !p.Info.Produces.Contains(type)) continue; var inits = new TypeDictionary @@ -55,7 +58,7 @@ namespace OpenRA.Mods.Common.Scripting new FactionInit(factionVariant ?? BuildableInfo.GetInitialFaction(actorInfo, p.Faction)) }; - if (p.Produce(Self, actorInfo, productionType, inits)) + if (p.Produce(Self, actorInfo, type, inits)) return true; }