XML: Making a Module to add/change game Elements
Allmost all Game Information is stored in an XML database. How much movement a warrior has, what civilizations exist, the Name of a Leader, etc. The base Files are in the Assets\XML subfolders, however many files are updated by XML Modules in the Modules Folder.
In modmodding XML changes should always be done modular. The huge advantage is that modular changes persist even if the main mode is updated to a later patch. There are two elements however which cannot be made modular: Randomevents (eventinfos.xml and eventtriggerinfos.xml) and Rituals (projectinfos.xml) [Rituals can be done modular with Wildmana 9.0]
Adding a new Element
As an example, create a new Promotion that allows a unit to fly and requires combat V and is only available to the Mercurian Civilization.
First create a folder, let's call it Wings. Then you need to add two files into the folder, the xml for the promotions and the schema file for it. Copy the Civ4PromotionsInfos.xml file from Assets\XML\units and rename it to WINGS_Civ4PromotionsInfos.xml. Open it with an editor and remove all promotions (a promotion starts with <promotioninfo> and ends with </promotioninfo>. It will look like this:
next thing to do is to copy the schema file list after "x-schema:" from Assets\XML\units to the wings folder and rename it to WINGS_CIV4UnitSchema.xml, then change the name in the file to WINGS_CIV4UnitSchema.xml.
Now everything is set up and promotions could be added to the file. The most simple promotion looks like this
Code:
<PromotionInfo>
<Type>PROMOTION_NAME</Type>
</PromotionInfo>
the string list in Type is how the game identifies the Promotion. Since we add a new Promotion it is very important that this name is different from all others. Now all that needs to be done is to add the effects of the promotion. This is done by adding XML entries below type.
In our case it is
for a promotion name: <Description>TXT_KEY_PROMOTION_ACCURACY</Description>
for a button: <Button>Art/Interface/Buttons/TechTree/Fanaticism.dds</Button>
for a sound when acquired: <Sound>AS2D_IF_LEVELUP</Sound>
for Combat V as prereq: <PromotionPrereq>PROMOTION_COMBAT5</PromotionPrereq>
for Mercurian Civ as prereq:<PrereqCivilizations>
<PrereqCivilization>CIVILIZATION_MERCURIANS</PrereqCivilization>
</PrereqCivilizations>
and for the flying effect: <bFlying>1</bFlying>
Modifying an existing Element
Lets say the Wings Promotion already exists. To change the prereq from Combat V to Combat III all steps from above except the last one need to be done. Instead of defining all features of the Promotion only though that should be changed need to get listed.
The ModularLoadingControls XML files that you see in a few folders aren't necessary. They can be used to force the game to load one folder before the other.