Civilization IV/Python Misc

This page contains other stuff about Civ 4 python that isn't really covered in the other posts, and is not obvious at first glance. Some of it is fan-made - creating shortcuts to do some quite complicated things.

PyHelpers.py
Most python files import this file. Basically it adds a few shortcuts to some more complicated functions. If you can't find exactly what you want in the API there is a chance that this file might be able to help you - though it only really creates shortcuts, and still follows the API.

CvGameUtils.py
This file is used when deciding certain things, like what can/cannot be built. It can be used to interrupt some basic game functions. Normally each function returns "False", but if you were to make it return "True" under some certain conditions on those conditions the unit, for example, could be removed from the list of units available. You could use this to make having the slavery civic make a slave unit be buildable, for example. I'd check it out yourself to see exactly how much power you have in there.

Scriptdata
If you want to add additional information about certain parts of the game world you need scriptdata. For example, if you want a unit to use up "ammo" every time it fought, and then have to return to a city with an armoury to resupply, or maybe you want plots to become muddy if too many units travel on them without roads, you need scriptdata.

If you want to play around with scriptdata, I recommend getting Stone-D's excellent SD-Toolkit. This toolkit allows you to attach pieces of data to parts of the game. Each part must be identified with a unique mod-name (for compatibility).

NOTE: There is an improved version of the toolkit posted on this post on CFC by Teg_Navanis. This version is faster than the default version, and fixes several minor issues the default had.

Action Buttons
talchas has released an Action Button's Utility Mod which is a template for adding buttons to the GUI to do custom functions when pressed. The AI will have no clue about it.

Square Selection
Once again by talchas this mod is a template. With suitable modification this could be used to make artillery act exactly as Civ 3 artillery, with no bodges. Once again, AI shortcomings come in.

.ini file modifications
While I have not actually tried it myself, there is a mod by Dr Elmer Jiggle which allows you to add variables to a mod's .ini file. Get it here