1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Civ 4 XML Tutorial Part 1

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

  1. BrentRitchie

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

    BrentRitchie Chieftain

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

    Yanez Chieftain

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

    PeteT Chieftain

    Joined:
    Jan 2, 2002
    Messages:
    273
    Location:
    Winterpeg
    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

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

    immortals84 The Mark

    Joined:
    Dec 30, 2003
    Messages:
    389
    Location:
    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

    Joined:
    Dec 5, 2005
    Messages:
    2,056
    Gender:
    Male
    Location:
    USA
    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

    Joined:
    Feb 19, 2006
    Messages:
    72
    Location:
    Madrid, Spain
    Thanks thanks thanks. It's clear and useful.
     
  9. Marshall Rommel

    Marshall Rommel Chieftain

    Joined:
    Sep 3, 2006
    Messages:
    5
    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

    Joined:
    Aug 17, 2006
    Messages:
    100
    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

    Joined:
    Apr 14, 2004
    Messages:
    19
    Location:
    Sweden
    Where is part 2? I found part 3...
     
  12. kristopherb

    kristopherb Protective/Charismatic

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

    Iluwen Chieftain

    Joined:
    Mar 13, 2003
    Messages:
    29
    Location:
    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

    Joined:
    Oct 24, 2006
    Messages:
    1
    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

    Joined:
    Aug 29, 2008
    Messages:
    8
    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 Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    30,961
    Location:
    Germany / Netherlands
    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

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

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    30,961
    Location:
    Germany / Netherlands
    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 :).
     
  19. Phrossack

    Phrossack Armored Fish and Armored Men

    Joined:
    Oct 26, 2008
    Messages:
    5,679
    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

    Joined:
    Jul 21, 2009
    Messages:
    18
    Location:
    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