Hey Magister, have a question

Cuteunit

Danse Macabre
Joined
Sep 5, 2007
Messages
618
Is it possible to prevent building X from being allowed to be built in a town that already has building Y?

If so, how? I dont like the effects of stacking wonders.
 
It should be easy to do using python. Just edit "def cannotConstruct(self, argsList):" in assets\python\CvGameUtils.py, so that if eBuilding is one of these buildings it checks to see if the city has the other building, and if so returns true.

I haven't tested it yet, but plan to pretty soon (when I add advanced temples)
 
Code:
	def cannotConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		pPlayer = gc.getPlayer(pCity.getOwner())

[...]

		iAltar6 = gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_EXALTED')
		iAltar7 = gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_FINAL')

[...]
			if eBuilding == iAltar6:
				if pPlayer.countNumBuildings(iAltar7) > 0:
					return True

Example from the Altar code. If you have altar7 (Final), you can't build altar6 (Exalted) again.
 
is all that editable in notepad ? does it need to be recompiled after modification somehow?

<- knows nothing about python
 
Python can be edited in Notepad (although Notepad2 or Notepad++ are better), and is not a compiled language. Just edit and save.

Python is a very simple language. It is basically pseudo-code. The one thing you have to keep in mind is that tabs (and not spaces) are used instead of brackets or end statements to determine what is in a function/conditional/loop. I often use IDLE to check for bugs, but I hate actually editing with it. It will point out roughly were the error is, but its recommended solution to having one space accidentally placed before a tab is to turn all tabs to spaces and make you go through and change every line. Oh, and you can't make it actually show the spaces or tabs.

You can actually edit and test the files without even closing the game. When you save the files, Civ IV will reload the python modules. However, this always seems to cause problems in FfH, so it is better to close and restart.
 
Is the old bug with Civ4UnitInfos.xml still around?

With Notepad it saves the first characters of the file upside down, causing all editing to corrupt the file.

This can be prevented by using programs like XML Marker etc. for editing.
 
Back
Top Bottom