Settler/City Limit

dark_lord565

Chieftain
Joined
Sep 14, 2010
Messages
18
I want to begin by saying how awesome this mod is and thanks for all the hard work. :goodjob:

I was wondering if it was possible to limit the number of settlers that are available or the number of cities that can be built? I was just thinking if there is a quick string of code that I could implement into one of the files. If it is more complicated than that, than no worries.

For example in Civ 3 what I did was disable settlers, start with 5 settlers and had the palace spawn a settler every 200 turns. I was wondering if something like this would be possible.

I looked around and found this thread: http://forums.civfanatics.com/showthread.php?t=294200

but it did not work.

I found this thread: http://forums.civfanatics.com/showthread.php?p=7064255

which is way to complicated for me to be able to merge with this mod. So if it is at all possible with a quick fix; cool. If not, no problem.

Thanks
 
I asked the question on another thread and this guy gave me the code needed answering my question. I am posting it here in case anybody wanted an update. NOTE: put the code in RoMGameUtils instead of CvGameUtils so that it works and add the other settler units so that the AI doesn't build them

It would be quite simple to make settlers national units, which means that you could not train any more unless you have fewer than some limit (set in CIV4UnitClassInfos.xml.)

However, that would not take into account the number of cities you have already settled.


Limiting the number of cities shouldn't be that hard though.

I am assuming that you don't want to have to compile a whole new DLL (I know I don't like doing that), so your best bet is probably to use some python callbacks found in Assets/Python/CvGameUtils.py.

I believe that these python call backs should all be active in base Civ IV, and that in BtS they are mostly turned off by default but may be turned on in Assets/XML/PythonCallBackDefines.xml.

(It should be noted that some mods seem to lock certain callbacks as being always on or always off. I think that turning off such callbacks in the DLL rather than checking that xml file makes the game run faster, but it does make things harder for modmoders who don't want to deal with editing and compiling a lot of C++ files.)


The first entry in Assets/XML/PythonCallBackDefines.xml is USE_CANNOT_FOUND_CITY_CALLBACK. If you change this from 0 to 1, then you should be able to use this under Assets/Python/CvGameUtils.py:

Code:
	def cannotFoundCity(self,argsList):
		iPlayer, iPlotX, iPlotY = argsList

		[COLOR="Red"]pPlayer = gc.getPlayer(iPlayer)
		if pPlayer.getNumCities() > 5:
			return True[/COLOR]

		return False
Adding the red portion should block settlers from building cities once their owner already controls 5 of them.


If you change USE_CANNOT_TRAIN_CALLBACK from 0 to 1, then you can use this to stop players from training Settlers when they have too many cities:

Code:
	def cannotTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]

	[COLOR="Red"]	if eUnit == gc.getInfoTypeForString('UNIT_SETTLER'):
			pPlayer = gc.getPlayer(pCity.getOwner())
			if pPlayer.getNumCities() > 5:
				return True[/COLOR]

		return False
If you don't want to be able to train settlers if already have enough settlers to reach the maximum number of cities, you could make it more like this:
Code:
	def cannotTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]
[COLOR="Red"]
		if eUnit == gc.getInfoTypeForString('UNIT_SETTLER'):
			pPlayer = gc.getPlayer(pCity.getOwner())
			if pPlayer.getNumCities() [COLOR="DarkOrange"]+ pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_SETTLER'))[/COLOR] > 5:
				return True
[/COLOR]
		return False
 
Back
Top Bottom