Craig_Sutter
Deity
Unless I am doing something wrong, it appears that neither this XML:
nor this LUA:
... can be used to limit the number of Missionary units produced.
For your information or correction as the case may be...
Code:
<UnitClasses>
<Replace>
<Type>UNITCLASS_MISSIONARY</Type>
<Description>TXT_KEY_UNIT_MISSIONARY</Description>
<DefaultUnit>UNIT_MISSIONARY</DefaultUnit>
<MaxPlayerInstances>2</MaxPlayerInstances>
</Replace>
</UnitClasses>
nor this LUA:
Code:
--allows building of Missionary Class units up to two units
local iMissionaryID = GameInfo.Units.UNIT_MISSIONARY.ID
local iIrishMissionaryID = GameInfo.Units.UNIT_IRISH_MISSIONARY.ID
local iMissionaryClassID = GameInfo.UnitClasses.UNITCLASS_MISSIONARY.ID
function MissionaryUnit (iPlayer, iUnit)
--differentiate Missionary Class units
if iUnit == iMissionaryID or iUnit == iIrishMissionaryID then
local pPlayer = Players[iPlayer]
local iMissionaryClassID = GameInfo.UnitClasses.UNITCLASS_MISSIONARY.ID
local iValue = pPlayer:GetUnitClassCount(iMissionaryClassID)
if iValue <= 2 then
print(iValue, "is <= 2 missionaries so can build")
return true
else
print(iValue, "is not <= 2 missionaries so cannot build")
return false
end
else
return true --default needed for other units
end
end
GameEvents.PlayerCanTrain.Add (MissionaryUnit)
... can be used to limit the number of Missionary units produced.
For your information or correction as the case may be...