Civ 4 XML Tutorial Part 1

Discussion in 'Civ4 - Modding Tutorials & Reference' started by BrentRitchie, Oct 30, 2005.

  1. BrentRitchie

    BrentRitchie Chieftain

    Oct 30, 2005
    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. -->
    <!-- This is the starting of a new Civ definition. -->
    <!-- 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 -->

    <!-- 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" -->

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

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

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

    <!-- This is what the standard player color is -->

    <!-- 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 -->

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

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

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

    <!-- 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 -->

    <!-- 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 -->

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

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

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

    <!-- 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 -->

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

    <!-- Finished Defining this UU -->

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

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

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

    <!-- The actual free unit that you get -->

    <!-- How many of this type of unit? -->

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

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

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

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

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

    <!-- 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 -->

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

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

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

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

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

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

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

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

    <!-- 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 -->

    <!-- 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 -->

    <!-- Define the initial legal civic -->

    <!-- Define the initial Labor civic -->

    <!-- Define the initial economy civic -->

    <!-- Define the initial religion civic -->

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

    <!-- 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 -->

    <!-- Define the anarchy government civic -->

    <!-- Define the anarchy legal civic -->

    <!-- Define the anarchy Labor civic -->

    <!-- Define the anarchy economy civic -->

    <!-- Define the anarchy religion civic -->

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

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

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

    <!-- This defines the leaders name -->

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

    <!-- finished with this leader -->

    <!-- finished defining all leaders -->

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

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

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

    <!-- Finished defining all civilizations -->

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

    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.
  2. BrentRitchie

    BrentRitchie Chieftain

    Oct 30, 2005
    Bumping so it can be moved to the appropriate section.
  3. Yanez

    Yanez Chieftain

    Jul 13, 2005
    i have to delete another civ right? i cant me a new one completely
  4. PeteT

    PeteT Warlord

    Jan 2, 2002
    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.
  5. 4_HoTA

    4_HoTA Chieftain

    Sep 26, 2005
    new zealand
    Cheers for the time and effort taken brent,much appreciated mate.
  6. immortals84

    immortals84 The Mark

    Dec 30, 2003
    Raider Nation
    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?!?!?!?!?!
  7. Seven05

    Seven05 Warmonger

    Dec 5, 2005
    Right click on it and edit it, that will open it with notepad instead of trying to open it with your web browser.
  8. Der_Meister

    Der_Meister Chieftain

    Feb 19, 2006
    Madrid, Spain
    Thanks thanks thanks. It's clear and useful.
  9. Marshall Rommel

    Marshall Rommel Chieftain

    Sep 3, 2006
    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:
  10. Saketh

    Saketh Brutal banana

    Aug 17, 2006
    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.
  11. cubsaver

    cubsaver Chieftain

    Apr 14, 2004
    Where is part 2? I found part 3...
  12. kristopherb

    kristopherb Protective/Charismatic

    May 23, 2006
    British Empire Soul:Tesco
    small question do you do this in word or a different program
  13. Iluwen

    Iluwen Chieftain

    Mar 13, 2003
    Wallach VII
    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?
  14. zattifier

    zattifier Chieftain

    Oct 24, 2006
    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
  15. Aliestor

    Aliestor Chieftain

    Aug 29, 2008
    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?
  16. The_J

    The_J Say No 2 Net Validations Administrator Supporter

    Oct 22, 2008
    Can you add a normal unit?

    If yes, then it should be no problem, when you look at the Civ4CivilizationsInfos.xml.
  17. Aliestor

    Aliestor Chieftain

    Aug 29, 2008
    Could you trow me an example, my brain is fried for the moment :p
  18. The_J

    The_J Say No 2 Net Validations Administrator Supporter

    Oct 22, 2008
    The examples are 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:

    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 :).
  19. Phrossack

    Phrossack Armored Fish and Armored Men

    Oct 26, 2008
    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!
  20. Drunk Link

    Drunk Link Chieftain

    Jul 21, 2009
    United States
    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?

Share This Page