Any way to limit the number of cities each civ have?

howe27

Chieftain
Joined
Nov 5, 2005
Messages
4
I just want to make all civ have 5 cities max and after that no settlers can be built. Help? Please?
 
howe27 said:
I just want to make all civ have 5 cities max and after that no settlers can be built. Help? Please?

In the CvGameUtil.py file, find the function that says "cannotBuild". In it, find the canTrain function:

Code:
def cannotTrain(self,argsList):
	pCity = argsList[0]
	eUnit = argsList[1]
	bContinue = argsList[2]
	bTestVisible = argsList[3]
	return False

Now, add something like this before the "return False" (I'm not sure if it's syntactically correct, but hopefully you get what I'm trying to do)...

Code:
	if gc.getUnitInfo(eUnit).getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_SETTLER"):
		if (gc.getPlayer(pCity.getOwner()).getNumCities >= 5):
			return True

This will make it so that if a player has five cities, then the ability to build settlers will not appear. It will also even cancel production of currently in-production settlers.

However, if the player still has settlers alive when the 5th city is built, this will not stop them from building the 6th city with one of those still-alive settlers. There doesn't appear to be a simple way of preventing this without modifying the SDK, so it's probably best to just eliminate those settlers by killing them or converting them to workers or something. However, the way that is probably best would be modifying the SDK's CvPlayer::canFound() function to disallow making cities if already at maximum capacity.
 
Very cool Gerikes, you should post that in the Sample Python thread in the Turorial forum, very helpful and informative. :)

howe27 said:
I just want to make all civ have 5 cities max and after that no settlers can be built. Help? Please?

The most basic way is to go into the unitinfos.xml file and set the Settler's cost to -1, this will make them unbuildable by all players. Next you go into civilizationinfos.xml file and change each civ from starting with 1 settler to how many you want them to start with. And bingo, no one will ever have more cities then those they build with the starting settlers. I play lots of gamew with limited cities and there are other ways to do it, but if all else fails this is a garonteed way to do it. :)
 
Thank you so much to both Gerikes and Jeckel. Both ideas helped so much. Trying it now.
 
Back
Top Bottom