Civ 4 XML Tutorial Part 1

BrentRitchie

Chieftain
Joined
Oct 30, 2005
Messages
25
Creating a new Civilization

First we need to find where the Civilization Entries are entered. Under the Civ 4 folder you will see an assests folder and inside there is where all of the game definitions and logic are held. We are interested in the XML folder. In the XML directory you see a few more folders. The Civilizations folder is where all the different civilizations are defined. Now to add a new civ we need to open the CIV4CivilizationInfos.xml file. This is where all Civilizations in civ 4 are defined.

Looking through the file, you will see alot of tags. Here is the basic layout of each civ definition with comments inlied. Also the actual data inbetween the tags is the data needed for my own Canadian Civ mod.

[EDIT] This tut is ment for those with little XML experience and find the civ 4 files too unwieldly [/EDIT]

Pay careful attention to the tags, you can't define <CivilizationInfos> like <CiviliZAtionINFos> The schema forbids it.

<!-- Declareing the root node and namespace -->
<Civ4CivilizationInfos xmlns="x-schema:CIV4CivilizationsSchema.xml">
<!-- Just for organization Saying that there is more then one Civilization definition coning up. -->
<CivilizationInfos>
<!-- This is the starting of a new Civ definition. -->
<CivilizationInfo>
<!-- This tag allows you to create a refrence name for your new Civ -->
<!-- This is a definition tag it allows refrence to your new civ
please keep to the naming standards -->
<Type>CIVILIZATION_CANADA</Type>

<!-- The next six tags are part of the Type tag but are all refrences -->
<!-- A refrence means that these things are defined in another XML file -->
<!-- This tag allows us to give our civ a name that is then displayed by the game -->
<!-- Example of a description is "Canadian Empire" -->
<Description>TXT_KEY_CIV_CANADA_DESC</Description>

<!-- This is a shorter description -->
<!-- Anexample is "Canada", not that much shorter eh? -->
<ShortDescription>TXT_KEY_CIV_CANADA_SHORT_DESC</ShortDescription>

<!-- This is the adjective of the new civ -->
<!-- Example "Canadian" -->
<Adjective>TXT_KEY_CIV_CANADA_ADJECTIVE</Adjective>

<!-- This is interesting, This tag allows us to create a new civilopedia entry for our new civ -->
<Civilopedia>TXT_KEY_CIV_CANADA_PEDIA</Civilopedia>

<!-- This is what the standard player color is -->
<DefaultPlayerColor>PLAYERCOLOR_BLUE</DefaultPlayerColor>

<!-- This tag makes refrence to your Civs Flag -->
<!-- Just set this to america because I don't have the tools to create a new flag ->
<!-- Later in the tutorial I will show you how to edit this however -->
<ArtDefineTag>ART_DEF_CIVILIZATION_AMERICA</ArtDefineTag>

<!-- Tis next tag allows you to set how your buildings look -->
<!-- Since canadians are actually european settlers we'll set it to european style -->
<ArtStyleType>ARTSTYLE_EUROPEAN</ArtStyleType>

<!-- This tag tells the game if humans can play as this civ -->
<!-- Just a note 1 = true, 0 = false -->
<bPlayable>1</bPlayable>

<!-- If the AI can play as the new Civ -->
<bAIPlayable>1</bAIPlayable>

<!-- Now this is where alot of the work is -->
<!-- This tag allows you to list a bunch of city names that your new civ will build -->
<Cities>

<!-- This is actually a refrence to a city that was defined in another file -->
<!-- The more of these there are the more Definitions you need to create -->
<!-- for now I will only use one city - St. Johns, because it is the oldest city in north america -->
<City>TXT_KEY_CITY_NAME_ST_JOHNS</City>

<!-- This means that there are no more city definitions -->
</Cities>

<!-- This tag defines all of this civ's unique units -->
<Units>

<-- This is the new unique unit definition -->
<Unit>

<!-- This is the unit to be replaced -->
<!-- Again these are refrences to graphics and what not so I will set them to the american equiv -->
<UnitClassType>UNITCLASS_MARINE</UnitClassType>

<!-- This is the unit that will do the replacing -->
<!-- This is still the american equivilant -->
<UnitType>UNIT_AMERICAN_NAVY_SEAL</UnitType>

<!-- Finished Defining this UU -->
</Unit>

<!-- Finished defining all UU's for this Civ -->
</Units>

<!-- This portion defines which units a civ starts the game with -->
<FreeUnitClasses>

<!-- Defines each free unit individually -->
<FreeUnitClass>

<!-- The actual free unit that you get -->
<UnitClassType>UNITCLASS_SETTLER</UnitClassType>

<!-- How many of this type of unit? -->
<iFreeUnits>1</iFreeUnits>

<!-- finished defining this free unit -->
</FreeUnitClass>

<!-- Finished defining all free units -->
</FreeUnitClasses>

<!-- This Defines a list of which free buildings your first city will have -->
<FreeBuildingClasses>

<!-- this is the actual building definition -->
<FreeBuildingClass>

<!-- This tag tells us exactly which building is free -->
<BuildingClassType>BUILDING_CLASS_PALACE</BuildingClassType>

<!-- This tag sets if the free building is prebuilt or not -->
<!-- If you set this tag to 0 then the building will have to be built normally -->
<bFreeBuildingClass>1</bFreeBuildingClass>

<!-- Finished defining this free building -->
</FreeBuildingClass>

<!-- Finished defining all free buildings -->
</FreeBuildingClasses>

<!-- This sectio defines all the free techs that you start with -->
<FreeTechs>

<!-- This tag starts the free tech definition -->
<FreeTech>

<!-- This tag allows you to define which tech is free -->
<TechType>TECH_FISHING</TechType>

<!-- This tag specifies if you start with this tech researched -->
<!-- remember 1 = True, 0 = False -->
<bFreeTech>1</bFreeTech>

<!-- Ends the free tech definition -->
</FreeTech>

<!-- No more free tech's to define -->
</FreeTechs>

<!-- This tag I haven't played with but I assume it's to list techs that this civ can't use -->
<!-- I'll look into the schema later -->
<DisableTechs />

<!-- This section deals with starting civics -->
<!-- You can define which civics a civilization can start with here -->
<InitialCivics>

<!-- This line can be used to define the first initial civic -->
<!-- It is important to keep the following pattern so you don't miss any -->
<!-- if you do miss one then none of the civics from that on one will be selected -->
<!-- Define the initial government civic -->
<CivicType>CIVIC_DESPOTISM</CivicType>

<!-- Define the initial legal civic -->
<CivicType>CIVIC_BARBARISM</CivicType>

<!-- Define the initial Labor civic -->
<CivicType>CIVIC_TRIBALISM</CivicType>

<!-- Define the initial economy civic -->
<CivicType>CIVIC_DECENTRALIZATION</CivicType>

<!-- Define the initial religion civic -->
<CivicType>CIVIC_PAGANISM</CivicType>

<!-- No more initial civics to define -->
</InitialCivics>

<!-- These tell the game which civics to use during anarchy -->
<!-- These should be the same as the initial civics but don't have to be-->
<!-- Just to note that if you mess this up then some of the anarchy civics will default to nothing -->
<AnarchyCivics>

<!-- Define the anarchy government civic -->
<CivicType>CIVIC_DESPOTISM</CivicType>

<!-- Define the anarchy legal civic -->
<CivicType>CIVIC_BARBARISM</CivicType>

<!-- Define the anarchy Labor civic -->
<CivicType>CIVIC_TRIBALISM</CivicType>

<!-- Define the anarchy economy civic -->
<CivicType>CIVIC_DECENTRALIZATION</CivicType>

<!-- Define the anarchy religion civic -->
<CivicType>CIVIC_PAGANISM</CivicType>

<!-- nomore anarchy civics to define -->
</AnarchyCivics>

<!-- This defines which leaders are available for this civilization -->
<Leaders>

<!-- This section defines one leader that is available -->
<Leader>

<!-- This defines the leaders name -->
<LeaderName>LEADER_JOHN_MACDONALD</LeaderName>

<!-- Is the leader available to olay as? -->
<!-- you can set this to 0 if you want to hide this leader -->
<bLeaderAvailability>1</bLeaderAvailability>

<!-- finished with this leader -->
</Leader>

<!-- finished defining all leaders -->
</Leaders>

<!-- This tag tells the game which sound schemes to use for when something is selected -->
<CivilizationSelectionSound>AS3D_AMERICA_SELECT</CivilizationSelectionSound>

<!-- This tag tells the game which sounds to play when units are taking actions -->
<CivilizationActionSound>AS3D_AMERICA_ORDER</CivilizationActionSound>

<!-- Finished defining our new civilization -->
</CivilizationInfo>

<!-- Finished defining all civilizations -->
</CivilizationInfos>

<!-- Tell the game our XML file is done -->
</Civ4CivilizationInfos>

Ok now that we made all those changes we have a brand new civ to play right? Wrong, There are still more files to go through just to make it work. I'll cover that in part 2 though.
 
i have to delete another civ right? i cant me a new one completely
 
Yanez said:
i have to delete another civ right? i cant me a new one completely

No, you can add a completely new one. But you'll also have to add new leader/s to CIV4LeaderHeadInfos.xml and all the necessary text references (e.g., <Description>TXT_KEY_CIV_CANADA_DESC</Description>) to make it work.
 
I want to add the "new mod pack" with all those new civilizations created by that civarmy s 1994 guy. Now i used to do alot of adding stuff for civ3. So i figure i just copy and paste the xml data from the assets/XML/Civilizations/CIV4CivilizationInfos out of the New mod pack folder into the CIV4CivilizationInfos already in the game. But when i open CIV4CivilizationInfos out of the New mod pack folder i get this error message:

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

Error opening input file: 'CIV4CivilizationsSchema.xml'. Access is denied. Error processing resource 'CIV4CivilizationsSch...


WHAT DO I DO?!?!?!?!?!
 
Right click on it and edit it, that will open it with notepad instead of trying to open it with your web browser.
 
Thanks thanks thanks. It's clear and useful.
 
Ok, this is easy enough to understand

As an experiment, i went to the civilizationxml, down to the descriptions for the german civ, and everywhere there was the word "german" or "germany", i replaced it with "austria" or "austrian", thinking that this would simply rename the civilization. I was wrong though, as when i tried to load up the civ, instead of appearing as "austrian empire" as i thought it would, it said something like "txt_xml..." well, you get the point. Luckily enough, i was able to fix it easily by retyping in "german" on everything i had changed, but how do i rename a civ, since this didnt work?:confused:
 
Marshall Rommel said:
Ok, this is easy enough to understand

As an experiment, i went to the civilizationxml, down to the descriptions for the german civ, and everywhere there was the word "german" or "germany", i replaced it with "austria" or "austrian", thinking that this would simply rename the civilization. I was wrong though, as when i tried to load up the civ, instead of appearing as "austrian empire" as i thought it would, it said something like "txt_xml..." well, you get the point. Luckily enough, i was able to fix it easily by retyping in "german" on everything i had changed, but how do i rename a civ, since this didnt work?:confused:
You probably changed the word GERMAN as it appeared in the XML tags. If you replace only the tag data (i.e. <tag>data</tag>), then the word German should be properly changed to Austrian.

The game writes TXT_KEY... when it can't find the string which the TXT_KEY refers to. In this case, since you changed the TXT_KEY itself, the game does this.
 
small question do you do this in word or a different program
 
I am having a similar problem to Marshall Rommel.

I am trying to add a new tech. So, I copied Horseback Riding, in TechInfos.
Then I changed <Type>TECH_HORSEBACk_RIDING</Type> to <Type>TECH_CAVALRY_TACTICS</Type>. At that point, the game loaded fine, and gave me two entries for Horseback Riding, one of which contained only the quote and decription.

I changed Civilopedia>TXT_KEY_TECH_HORSEBACK_RIDING_PEDIA</Civilopedia>, as above, to reda CAVALRY_TACTICS, and supplied a new entry with that name in GameText_Civopedia_Techs. And eveyrthing was still fine, the game now gave a new description for the second Horseback Riding entry in the Civopedia.

Then, I changed <Description>TXT_KEY_TECH_HORSEBACK_RIDING</Description> again as above, so that the tech would read Cavalry Tactics when I loaded the game. But no, it read TXT_KEY etc. What am I missing? What other file is being referenced where I actually name the tech?

And, a second problem: When I change <Quote>TXT_KEY_TECH_HORSEBACK_RIDING_QUOTE</Quote>, suppling a new entry and quote in GameTextInfos, the game won't even load properly, crashing with an error message about being "unable to read" followed by a list of numbers with a hyphen somewher in the middle.

What am I doing wrong here?
 
i have no idea about xml files and all that stuff, how do i add a new civ cos it won't just let me add stuff to the file
 
Im trying the best i can to keep the modding within the allready provided material and I was trying to make Byzantian UU into a Polish UU and to name it Hussar but how do i do that?
 
The examples are there...in the XMLs ;).

To create an UU, you have to add it in the XML\Civilizations\CivilizationsInfos.xml.
Just look at the file ;).

Copy this section:

PHP:
<Units>
				<Unit>
					<UnitClassType>UNITCLASS_KNIGHT</UnitClassType>
					<UnitType>UNIT_BYZANTINE_CATAPHRACT</UnitType>
				</Unit>
			</Units>

to the right part of your poland civ.
Then you have to go to the text xmls (XML\Text\), and in this folder, in some file (i guess CIV4GameText_Objects_BTS.xml) is the name of the unit. Change it there. Done :).
 
Samurai start with Drill 1, and can receive the other Drill promotions, even though melee units can't normally get these. I gave Keshiks Drill 1, but they can't get the other Drills. How can you let them receive the other Drills?

EDIT: Never mind, got it to work. FEAR THE HORDE!
 
Right click on it and edit it, that will open it with notepad instead of trying to open it with your web browser.

I tryed doing this. All it said was I can't save because it isn't the right file type. How do I save it if I edited it on Notepad?
 
Top Bottom