Limit Number of Cities?

Yanez

Chieftain
Joined
Jul 13, 2005
Messages
64
Hi, I want to mod the game so that the "One City Challenge" affects all, not just human player. If not possible, I would like to limit the number of cities , anyway to do it?

Can anyone help me on how to do it?Plz?
 
You could do it with Python. In the file CvGameUtils.py there is a method called cannotConstruct. It is checked when ever a city starts to construct a building. If it returns True the building will not be constructed. If it returns False the building will be constructed. Just place some code to count the player's cities in this method. If they have reached the max value return True.
 
thanks, can u give me more detailed instructions?
having a hard time.

def cannotConstruct(self,argsList):
pCity = argsList[0]----------------Changed to pCity = argsList[1]
eBuilding = argsList[1]
bContinue = argsList[2]
bTestVisible = argsList[3]
bIgnoreCost = argsList[4]
return False
 
I'm sorry, I pointed you in the wrong direction. You want to use cannotFoundCity - it's in the same file.
cannotFoundCity should look something like this.
Code:
 def cannotFoundCity(self,argsList):
  iPlayer, iPlotX, iPlotY = argsList
  pPlot = CyMap().plot(iPlotX,iPlotY)
 
  pPlayer = gc.getPlayer(iPlayer)
  maxCities = 2  # Or whatever value you want.
  if (pPlayer.getNumCities() < maxCities):
   return False
  else:
   return True

If you're new to modding here's the basic routine you should use:
You should never edit the original files.
1. First create your own folder in the Mods directory. The name of the folder is the name of your mod.
2. Create the following folders in your mod direcory - "assets\python"
2. Copy the file assets\python\CvGameUtils.py from whatever version of Civ4 you are using to your folder while keeping the same file path.
3. Edit the new file.
 
Well to be honest, was trying to limit the number of cities in Colonization. I thought it had the same files which it does, but it doesnt have the

"Cannot found city part"


Still having issues.
 
I want to do the same as Yanez. What you could do is disable settler building and give every civ 3 or 4 settlers.

It would have been nice if there was another way without using Python.
 
Another Idea:
If you limit SETTLERS to build a number of cities then a cool exception would be if you can get a BIG SETLLER (just like you got big artists and big engineers) which allows you to build a city.
 
Somebody made that. Check through the mod downloads on this site. I highly dout the AI;s capability todeal with one city though, especially if it only had 2 national wonders.
 
Top Bottom