Make iMaxPlayerInstances based on other units?

ice2k4

Emperor
Joined
Feb 28, 2004
Messages
1,937
Location
Brooklyn, New York
A quick question to more advanced modders than me:

In the CIV4UNITClassInfos.xml file each Unit Class has

iMaxPlayerInstances set to -1 (if unlimited) and a positive interger if limited (such as missionaries are 3.)

I want to know if I can do something like this where the max amount of units for a unit type (or class) is based on the number of units of another unit type (or class.)

For instance, I would like to make it where you need 3 axeman to build have one worker. But, I don't want to limit the amount of axeman you can have/build.

How would I go about doing this?
 
There already is such a counter. You just have to query that counter in the cannotTrain/canTrain function.

The number of Axemen a player possess is something like

pPlayer.getUnitClassCount(gc.getInfoTypeForString("UNITCLASS_AXEMAN"))

and this has to be compared to

pPlayer.getUnitClassCount(gc.getInfoTypeForString("UNITCLASS_WORKER"))

for your example. pPlayer is of course a CyPlayer object.
 
Top Bottom