Civilization IV/Adding a Civilization

Tools
Before you start anything, you need to make sure you have the right tools. We’re going to be editing XML files.

This can be done in window’s notepad, but I find that notepad++ is better, as it provides find and replace tools, as well as a few tools for working with XML files.

There is also going to be some Image editing and converting. For image editing you can use Paint Shop Pro, Adobe Photoshop, or a free alternative known as The GIMP. All images/textures in the game are .dds files. This stands for Direct Draw Surface, and is a texture format for DirectX.. There are plugins for Photoshop, Paint Shop Pro and The GIMP that will output .dds files, but they are very iffy. Luckily there is DXTbmp, a stand alone program that will take in most image files and save them as any flavour of .dds.

Planning
First off you’re going to need to know what Civilization you’re going to make. For this tutorial I’m going to make Australia. After that is decided, you have to think about a few other things:

City Names: Fairly obvious here. You could only have one city name, but after that it’ll start pulling random names for your new towns. A good idea would be to have 15+

 Starting Techs: In the game all the original Civs have 2 starting techs from the first 6 available (Mining, Mysticism, Fishing, The Wheel, Agriculture and Hunting). The Starting Techs can be any techs that are available, and you can have more then two. But unless you want to unbalance the game, stick with just having two from the starting six

Unique Units: All the original Civs have one unique unit. These units are slightly better versions of other units in the game, and actually replace them for that Civ. Each Civ can have more then one unique unit, but this can unbalance the game if you’re not careful.

Leaders: Each leader has their own Traits and favoured civic. As with the Starting Techs and The Unique units, you can have more then what the Civs in the original game had, but again, beware of unbalancing the game (unless that’s what you’re planning on doing)

Setup
Civ4 has a very strict directory and file structure for mods. You are going to need to set up a structure like this, in the \\Firaxis Games\Sid Meier's Civilization 4\Mods folder YourCiv\Assets\Art\Interface\Buttons\Civilizations\ YourCiv\Assets\Art\Interface\Buttons\Units\ YourCiv\Assets\Art\Interface\TeamColor\ YourCiv\Assets\Art\Interface\Leaderheads\ YourCiv\Assets\XML\Art YourCiv\Assets\XML\Civilizations YourCiv\Assets\XML\GameInfo YourCiv\Assets\XML\Text YourCiv\Assets\XML\Units Or just download this .zip and unzip it to the Mods folder.

Now you’re going to need to copy some of the XML files from the original game into your mod directory, as we’ll need to edit them later. The files come from  \\Firaxis Games Civilization 4 and go into \\Firaxis Games Civilization 4\Mods and the same structure. The files you need are: Assets\XML\Art\CIV4ArtDefines_Civilization.xml Assets\XML\Art\CIV4ArtDefines_Leaderhead.xml Assets\XML\Civilizations\CIV4LeaderHeadInfos.xml Assets\XML\Civilizations\CIV4CivilizationInfos.xml Assets\XML\GameInfo\CIV4DiplomacyInfos.xml Assets\XML\Interface\CIV4ColorVals.xml Assets\XML\Interface\CIV4PlayerColorInfos.xml Assets\XML\Units\CIV4UnitInfos.xml

Flag
The flag is displayed at the bottom right, near the minimap and near each of your units. The texture we have to create is 128x128 in size, but in game the flag is scaled down about 25% horizontally to fit on the flag model. The easiest way I can think of making the flag is creating a 96x128 image and then stretching the horizontal 25% to 128.

I got my source image from here, rotated it right 90 degrees, and resized it so the height was 128. Then I added some boarders to the side to make it 96 pixels in width. Finally I resized it to 128x128. Here is the result. Now, save your image as a .bmp somewhere, I usually put it where the end .dds file will be put. This would be  YourCiv\Assets\Art\Interface\TeamColor\

Open up DXTbmp and load the .bmp. You now should be looking at something like this. Over to the right hand side of the window it that ’Alpha Channel’ box.

The Alpha Channel is a map that tells the game what pixels of the texture are transparent, and which aren’t. In our case, all white pixels are transparent, and will show the default colour of the civilization. We want to change the Alpha channel to all black. Double click on the white part and it will load the Alpha channel in your default image editor. Bucket fill it all black, save it and click on the 3rd icon (white arrow up) to reload the edited Alpha channel.

Now go to File->Save As->DDS Texture. You be shown a save box. Navigate to YourCiv\Assets\Art\Interface\TeamColor\ and save the file, making sure you change save type to DDS DXT 3. That is very important.

With that flag, the in game the flag turned out like this. I added a border to the top, giving these (better) final results that can be seen here and here.

Leaderhead
The original Leaderheads are actual 3D Meshes which can be an involved process. in the midterm we will use static images much in the same way we did with the flag.

The Leaderheads also have the same problem of being a square texture, but showing in a rectangle that is 25% smaller horizontally. The only difference is that the texture is a 512x512. So, doing the same thing we did with the flag, make/get a base image that is 384x512 and then resize it to 512x512.

I’ve decided to have John Howard as the leader for the Australians, mainly because he was the easiest to get a picture for. Source image, here. I just cropped out Howard at about 0.75 ratio, then resized it to 512x512.

This time when you run it through DXTbmp, just leave the Alpha Channel white. Then save it to YourCiv\Assets\Art\Interface\Leaderheads\

Making the Buttons - Graphics
Now we have to make three buttons, one for your Civ, one for your leader and one for your Unique Unit.

For all three buttons, here is a border and Alpha channel: Save both of these somewhere.
 * Border
 * Alpha Channel

First is the Civ button. This is going to be the image for the flag, put into the above border. I imagine that you know how to do that. It isn’t needed, but it’ll make it look nicer. Load the finished image into DXTbmp, then click on the first button under Alpha Channel. This is how you load the Alpha Channel bitmap you saved before. Navigate to the Alpha Channel bitmap and load it. Then save the .dds as to '' YourCiv\Assets\Art\Interface\Buttons\Civilizations\ '', using the same options as before.

Next up is the Leader button, again, I’m going to get this from the image I made before, and merge it with the border image. Run it through DXTbmp, with the same Alpha Channel bitmap, and save the file in YourCiv\Assets\Art\Interface\Leaderheads\, obviously with a different name then the actual Leaderhead picture.

Lastly we need to do our Unique Unit button. This is exactly the same as the last two, except we need to find/make a new source image. Here is mine. Run it through DXTbmp, exactly the same as the last two times and save it in  YourCiv\Assets\Art\Interface\Buttons\Units\

My 3 buttons, here.

Making the Words - XML
First off I’ll try to provide a crash course in XML. XML is a way of storing and organising information.. Most, if not all information is enclosed by tags, these tags look like this: information The tag part can be anything, usually it’s something that describe what the information is. There are also these tags:

The first one is used when (in this instance), there is no information for this tag and the second is used for comments. I think that’s about all you need to know. Just be wary of typos in tags, if your not copying them from somewhere.

Now, to the XML text file. This file is a little different from all the other XML files, mainly because it’s name can be anything and it’s loaded in addition to the same (types) of XML files that come with the game. Anyway, this file contains the text that will be shown in the game. All the other XML files reference these text XML files when anything is needed to be written to the screen. This is so multi-language is made easier, and when one section of text it’s needed to be used multiple times. With this it’s only needed to be written out once, rather than every time it’s needed to be used.

Everything in this file is in this structure:  TXT_KEY_CIV_YOURCIV_DESC Your Empire in French in German in Italian in Spanish  I imagine it’s fairly straight forward. First it opens a TEXT tag, this is just a way of telling the game “Hey, everything up to the close of this tag, is all together”. Next it opens a TAG tag. The text that is contained within this tax is what will be used in the other XML files to print this line (depending on what language you are using). After this is the tags for the individual languages that are needed. And that’s it about the file.

Here is a text XML file that contains the basics of what you’ll need to make a civilization. Download it and unzip it to in your  YourCiv\Assets \XML\Text directory, then open it up for editing. It’s a slightly edited version from this tutorial. While the file is good, the tutorial isn’t complete.

All the data in this file is very easy to understand, just change all the YOURCIV, YOURLEADER and YOURUNIQUEUNIT parts of each tag and then the information contained in each of the tags below it.

Adding the Civ - XML
Navigate your way to Assets\XML\Civilizations and open CIV4CivilizationInfos.xml. This file contains all the information about the civilizations. What we’re going to need to do is add another entry for Australia.

The easiest way to do this is copy and then edit one of the civilizations that are already there. I copied the American Entry and have edited that.

If you look at the entries for the tags Description, ShortDescription and Adjective, you should see that they match up with entries in the GameTextInfos_yourciv.xml file.

For now, don’t worry about the  DefaultPlayerColor tag. I’ll cover that one later.

Have a look at the city tags now. They should look something like TXT_KEY_CITY_NAME_WASHINGTON. Look familiar? They are the same type of tags that Description and the rest use. If you put 2 and 2 together, you’ll figure out that the city names are put into the GameTextInfos_yourciv.XML file… These are a little different then the other texts, mainly because they are names, and how different languages handle names. Here is an extract from CIV4’s City name file:  TXT_KEY_CITY_NAME_WASHINGTON</Tag> Washington</English>  <Text>Washington</Text> <Gender>Male</Gender> <Plural>0</Plural> </French>  <Text>Washington</Text> <Gender>Male</Gender> <Plural>0</Plural> </German>  <Text>Washington</Text> <Gender>Female</Gender> <Plural>0</Plural> </Italian>  <Text>Washington</Text> <Gender>Female</Gender> <Plural>0</Plural> </Spanish> </TEXT> Fairly self explanatory, and if you want you can just include the English entry, but I don’t know what will happen when people from other languages play the mod.

Anyway, copy that code, and put it at the end of the GameTextInfos_yourciv.XML  file. Then edit the Tag name and the entries beneath it. After you’ve done that, go back to the  CIV4CivilizationInfos.xml and add in the new city name tags.

I’m going to put in 20 cities and be lazy, by just putting in the English ones. I got the list of cities from here.

After this we have the Units/Unit tags. This is where the Unique Unit is assigned to the Civ. There needs to be a bit of explaining here.

There are tags for UnitClassType and UnitType. Each basic unit is in it’s own UnitClass, wether their Workers, Macemen or Stealth bombers. The Unique Units share the UnitClassType with the unit they replace. So, for example: Unit Name:		Worker			Fast Worker UnitClassType:		UNITCLASS_WORKER	UNITCLASS_WORKER UnitType:		UNIT_WORKER		UNIT_FAST_WORKER With that explained, you might want to go hunting around \New Civ\Assets\XML\Units\CIV4UnitInfos.xml to find the unit class of the unit that you want your Civ’s Unique Unit to replace.

In adding Australia’s SAS, it isn’t going to be much different from America’s Navy Seal. It’s actually going to be of the same UnitClassType. So all I have to do here is change the UnitType.

Next up is the FreeUnitClasses/ FreeUnitClass tags. This is a way for you to give extra units at the start of the game to your civilization. There are two tags here: UnitClassType and iFreeUnits. The first one, is as with the last one, the unit class, not the actual unit it’s self.

The second tag needs a little explanation. At the start of the tag is an “i” this means that the information contained between the tags is an integer, or any whole number. Whatever number you put here is the amount of that type of units you’ll get extra at the start.

So, with this, you could give a Civ 2 extra Warriors or 1000 ICBMS at the start. Also, you can give the Civ more then just one type of unit, just copy everything between the <FreeUnitClass> and </FreeUnitClass> tags, then modify them

All the original civs give 1 of the UNITCLASS_SETTLER, so I suggest you do the same. And leave it for balancing issues.

Now we move onto the FreeBuildingClasses/ FreeBuildingClass tags. This is a way to give your Civ a building at the start of the game. Again, there are two tags here: BuildingClassType and bFreeBuildingClass. BuildingClassType is the same as the UnitClassType we worked with just before. Except, it’s obviously for buildings.

The other tag, bFreeBuildingClass, is yet another that needs a little explanation. The “b” at the start means that it’s a Boolean tag. For those that don’t know, that means that it can be either “True” or “False”, these are represented by 1 or 0 respectively. You’ll notice that all the ones in the file are given a 1. This indicates that it is a Free Building. You could add a BuildingClassType and make the bFreeBuildingClass eual 0, but then it would behave as a normal building.

With this you could give your Civ a Hospital from the start, but I think that it only gives one building of that type.

All the original civs again have one here. They give a BUILDINGCLASS_PALACE, which obviously is the Palace. I suggest you do the same and leave it for balancing issues, again.

Next we have the FreeTechs/FreeTech tags. This is where the techs that each Civ starts with are listed. As with the others, there’s 2 tags: TechType and bFreeTech. TechType is the tag of the tech, and bFreeTech works like the one for the free buildings.

As explained before, all original Civs have 2 techs from the first 6 that are available.

Next up there is a closed tag for DisableTechs. So, if you wanted you could disable some techs for your Civ, but I’m not going to go on about it here.

Moving on we have the InitialCivics and AnarchyCivics. Self explanatory, it’s the civics that your Civ is on at the start of the game and during the anarchy after changing Religion or Civics.

All the original Civs have the “basic” Civics for both of these, but you could easily change them.

Now we have the Leaders/Leader tags. Much the same as most of the others, two tags: LeaderName and bLeaderAvailability. LeaderName is something that we will be adding later, but you can add in what it will be, should be along the lines of LEADER_LEADERNAME. Then bLeaderAvailability, is weather the leader is available.

I think you could add leaders from other civs into this, so with a little editing, you could have Ghandi leading the French, or Washington leading the Germans.

Finally we have the CivilizationSelectionSound and CivilizationActionSound tags. I personally am not too sure about sounds (yet), so just leave them. You could possibly make them closed tags, if you wanted

Adding the Leader - XML
There is way too much stuff in here, and I don’t know half of it, and possibly couldn’t figure out more then a quarter of it. I’ll guide you through what you need to do, and if you want you can play around with the many other options in it. There is some excellent info in the CIV4LeaderHeadInfos on what's in this file. Definitely have a look at it, even if you don't want to modify this file too much.

Firstly, pick an existing leader that is the most like your leader, then copy everything between their <LeaderHeadInfo> and </LeaderHeadInfo> tags. Then copy it after the last </LeaderHeadInfo> down the bottom.

Now you’ll want to change the tags of the leader you copied to represent the one you’re making. First off that means changing their name to your leader’s name in the top four tags. Then there’s a bunch of different “attitudes” for your leader, play around with them if you want, but I’m not going to. At the bottom of this group, there’s a FavirouteCivic tag. Change this to suit your leader.

After that is the Traits/Trait tags. Like the FreeTechs/Freetech tags for the civilization, but this refers to the eight different traits each leader can have. Two tags inside it: TraitType and bTrait TraitType is the tag for the trait you want your leader to have, bTrait is a Boolean for if they have the trait or not.

With this, like the others, you can add as many as you want, but it will be unbalanced.

Everything onwards is just stuff to define your leader, and how they act when used by the CPU. I’m leaving it, because as I said before, there is just way too much stuff in there.

Adding The Unique Unit - XML
Another one that has heaps of options, which we really don’t need to use, as we’re copying a unit that should very closely resemble what we want to use anyway.

So, go find the unit that your Unique Unit is replacing and copy everything between it’s <UnitInfo> and </UnitInfo> tags, then paste it after the last </UnitInfo> tag down the bottom.

Keep the class the same (remember?) And change the Type tag to what you put in the CivilizationInfos.xml file. You should be able to skip all the tags down to the Description tag.

The Description, Civilopedia and Strategy tags are all references to texts (that you’re going to have to write, in the case of the Civilopedia and Strategy). Original UnitCivilopedia texts can be found in \\Firaxis Game\Civilization 4\Assets\XML\Text\CIV4GameText_Civilopedia_Units.xml, while the Strategy texts are in \\Firaxis Game\Civilization 4\Assets\XML\Text\ CIV4GameText_Strategy.xml . Have a look at them to see what the originals had, and then type up your own in your text XML file.

After doing that, look through the next ~60 lines, check out the options and change some, if you want. They all should be fairly obvious to you now. Seeing as we’re doing a Unique Unit, you really shouldn’t be changing too much…

The next tag I want to look at is the iCost tag. This is obviously the production “cost” to make the unit, you have to balance this with the other additions your unit has over the basic unit. But I really think this is something you’ll have to learn through trial and error.

Down a few more, we have iMoves tag. This is the number of spaces the unit can move each turn. Simple stuff.

Down some more we have the iCombat tag. I’m guessing that your Unique unit is a combat unit. Well this is where it’s combat strength is defined. Again, simple stuff.

Down a bit more and we have the UnitClassAttackMods and UnitClassAttackMod tags. This defines UnitClasses that this unit is either better or (possibly) worse against. 2 tags in this one: UnitClassType and iUnitClassMod. UnitClassType is the tag that defines which Unit Class you’re talking about. iUnitClassMod is an integer modifier. I think it adds the number as a % of the normal damage. Example: If you have a unit with 20 in it’s iCombat, and 50 in the iUnitClassMod, and it’s facing a unit from the unit class, it will act as though it actually has 30 for it’s iCombat. I’ll remind you, this is how I think it works.

Next up, I want to tell you about the iPower tag. This is actually for the AI, and is the “points” contribute Power Rating. This is an internally used rating that helps the AI make decision on whether or not it would be a good idea to attack other Civs, among other things. (Thanks Isak)

Next up (after the UnitMeshGroup), we have the Button tag. It does exactly as it says, points to the .dds file that has the button for that unit. Might as well change it now, considering we’re here.

Delete everything between the tags and put: ,Art\Interface\Buttons\Units\yourbutton.dds And that’s all you need to do for that.

Finally we have the FreePromotions and FreePromotion tags. Like a lot of the others, it’s self explanatory and hs 2 tags in it: PromotionType and bFreePromotion. PromotionType is the actual tag that points to the promotion the unit gets and bFreePromotion is a Boolean that says weither it is free or not.

After you’ve done all that, you’ve got your Unique Unit in the game, only a few more things to do before the mod is playable.

Adding the Pictures - XML
Now we add in the (rest) of the pictures, completing the necessary parts to play the mod.

Open up CIV4ArtDefines_Civilization.xml and scroll to the bottom. Paste this under neath the last </CivilizationArtInfos>: <CivilizationArtInfo> <Type>ART_DEF_CIVILIZATION_YOURCIV</Type> <Button>,Art/Interface/Buttons/Civilizations/civbutton.dds</Button> <Path>Art/Interface/TeamColor/civflag.dds</Path> <bWhiteFlag>1</bWhiteFlag> </CivilizationArtInfo> Change the type tag so that your civ’s name is there. Then Change the button and path tags to their respective path and files. Now, bWhiteFlag tells the game to actually use the texture for the flag it’s pointed to. So in my case I’ll actually see the Australian flag.

Now open up CIV4ArtDefines_Leaderhead.xml, again scroll to the bottom. And where is something else to copy and paste into it: <LeaderheadArtInfo> <Type>ART_DEF_LEADER_YOURLEADER</Type> <Button>,Art/interface/LeaderHeads/leaderbutton.dds</Button> <NIF>art/interface/LeaderHeads/Leaderhead.dds</NIF> <KFM/> <NoShaderNIF/> <BackgroundKFM/> </LeaderheadArtInfo> Remember to paste it after the last </LeaderheadArtInfo>

Again change the Type tag so it has your civ’s name. And change the button and NIF tags to point to your leader button and Leaderhead, respectively.

In the original ones, the NIF points to some kind of 3D file, or some such. Because we can’t import our own (yet), we can make the NIF point to a .dds, but then we have to close up the other 3 tags that are there, because they’re not needed.

Now, if either I or you haven’t done anything wrong, your civilization should be playable. There’s a few more things to do, but for now you can play.

Adding some Colour - XML
Now, remember back in Part 6, I told you to skip the DefaultPlayerColor tag? Well we’re going to fix that up now.

Open up the 3 XML files: CIV4ColorVals.xml, CIV4PlayerColorInfos.xml and CIV4CivilizationInfos.xml Now, in CIV4CivilizationInfos.xml go to your civ and find the DefaultPlayerColor tag. Change the tag to something. For mine, I’m going to use PLAYERCOLOR_GREEGOLD, obviously it’s going to contain a green and gold colour scheme for Australia.

Now open up CIV4PlayerColorInfos.xml. By now what you see here should be very straight forward. Copy all of the info between a pair of <PlayerColorInfo> and </PlayerColorInfo> tags and paste it beneath the last </PlayerColorInfo> tag. Change the type tag to what you did just before in the CIV4CivilizationInfos.xml file.

Just for now, take a quick look in the Civ4ColorVals.xml file. Here you will find a heap of pre-defined colours. Down the bottom are the COLOR_PLAYER_* colours. It would be best to see if the colours you would like to use are there. For me I’m going to use COLOR_PLAYER_GREEN for my primary colour and COLOR_PLAYER_GRAY_TEXT for my text colour. I’m going to also me up a gold colour for the secondary colour.

Now, back into CIV4PlayerColorInfos.xml and put in the tags of the colours that you want to use, if you have any. Also change the other tags for colours that you want to make. After you’ve done that it’s time to head back into Civ4ColorVals.xml.

Looking between the <ColorVal> and </ColorVal> tags you see Type, fRed, fGreen, fBlue and fAlpha. Like the ‘i’ and ‘b’ prefixes before, the ‘f’ indicates the type of information to be contained in this tag. The ‘f’ stands for “Float”, or a number that can include decimal places.

If you’ve done a bit of graphics design, or some modding like this before, then you possibly already can guess what’s happening here, but I’ll explain. The four ‘f’ tags are designed to hold a number from 0 to 1. For fRed, fGreen and fBlue it denotes the “intencity” of the colour that’s going to be shown. So, if you give fRed 1, and the other two 0, you will get a pure Red. If you give fRed 0.33, fGreen 0 and fBlue 0.66, you’ll get a (I think) nice purple colour.

The fAlpha, is for the transparency that will be used when this colour is called. 0 indicates that it will be totally transparent, 1 means that it will be totally opaque (solid). For these colours we’re making now, you’ll want the fAlpha to always be 1.

For my gold I’m going to use these settings: <fRed>1.00</fRed> <fGreen>0.77</fGreen> <fBlue>0.11</fBlue> <fAlpha>1.00</fAlpha>

Save the 3 files, and your colours should be done.