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 2

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

  1. BrentRitchie

    BrentRitchie Chieftain

    Joined:
    Oct 30, 2005
    Messages:
    25
    Ok, in the first tutorial we went through and changed alot of options in the CIV4CivilizationInfos.xml file. This will make the civilization available but we didn't really add much information. Remember the Description, short description, adjective, and civilopedia tags? Well all we did was tell the game where to find the correct information. Now we will actually create this information.

    So the folder that holds all of the text in the game is in the Assets/XML/Text folder. The file that holds all of the short identifying text (Like unit names and such) is CIV4GameTextInfos_Objects.xml. We need to create 3 new entries one for each of the descriptions and one for the adjective.

    Now before we actually start modding you must realize that Civ 4 was released world wide. So these files in the text folder actually define *ALL* of the languages that are supported. Something really interesting though is the fact that this folder lacks a schema. This means we could add Language support for any language we want including the cool ones like Klingon ;).

    Ok, so we have the file open. Lets look at the first entry. BTW I have inlined the comments for this code again.

    <!-- Create the new text element -->
    <!-- you need to define a new text element for *every* tag made -->
    <TEXT>

    <!-- This is where we define those refrences we made before -->
    <!-- One of our refrences were TXT_KEY_CIV_CANADA_TEXT -->
    <Tag>TXT_KEY_IMPROVEMENT_LAND_WORKED</Tag>

    <!-- This tag looks a little different then the ones below thats because the english language is asexual in nature -->
    <!-- Being asexual we don't have to have different sentence structures to say the same thing like french -->
    <!-- If you have your game settings to english this is the text that will show up -->
    <!-- Nothing fancy just plain english -->
    <English>Land Worked</English>

    <!-- This tag tells the game that this is the french language description -->
    <!-- you could just as easily write <Klingon> and the game would not care because of the lack of a schema -->
    <French>

    <!-- This is the text that will appear if the french language option is selected -->
    <Text>En travaux</Text>

    <!-- This tag is a little wierd, because in french and other languages words have genders -->
    <!-- In this case "En Traveux" is male, this effects the words that appear around this text -->
    <Gender>Male</Gender>

    <!-- This simply states if the word is in plural form -->
    <Plural>0</Plural>

    <!-- End french language definition -->
    </French>

    <!-- Start German language definition -->
    <!-- this is as far as I go I don't want to repeat myself three more times -->
    <!-- you should get the basic idea for now -->
    <German>
    <Text>Bearbeitetes Land</Text>
    <Gender>Male</Gender>
    <Plural>0</Plural>
    </German>
    <Italian>
    <Text>Terreno bonificato:Terreni bonificati</Text>
    <Gender>Male</Gender>
    <Plural>0</Plural>
    </Italian>
    <Spanish>
    <Text>Tierra trabajada:Tierras trabajadas</Text>
    <Gender>Female</Gender>
    <Plural>0:1</Plural>
    </Spanish>
    </TEXT>


    OK, so now we know the basic structure, lets start adding our definitions.

    I like to add my definitions inside the files in alphabetical order, but you can add this stuff anywhere you want I suggest for this tutorial you just add it at the end of the file after the last </TEXT> tag but before the </Civ4GameText>.

    So We'll add the descriptions in order, first is the TXT_KEY_CIV_AMERICA_DESC.

    Add this:

    Remember this is the Long or standard description, you see this at the leader select screen.

    <TEXT>
    <Tag>TXT_KEY_CIV_CANADA_DESC</Tag>
    <English>Canadian Empire</English>
    </TEXT>

    This is fairly trivial and what it means is that when the game is set to english anywhere you refrence TXT_KEY_CIV_CANADA_DESC the phrase "Canadian Empire" will replace it. If you use a different language then there will be no description. I don't know french or anyother language that well so if somebody could help me translate these things that would be appreciated.

    The next two entries are as follows:

    <TEXT>
    <Tag>TXT_KEY_CIV_CANADA_SHORT_DESC</Tag>
    <English>Canada</English>
    </TEXT>
    <TEXT>
    <Tag>TXT_KEY_CIV_CANADA_ADJECTIVE</Tag>
    <English>Canadian</English>
    </TEXT>

    Remeber there is no schema so I can put in or leave out as many languages as I want.

    Next is kind of cool. Remember the tag <Civilopedia>? This tag allows our civ to have a civilopedia entry of it's own. I think thats a nice touch. Now we are done with the CIV4GameTextInfos_Objects.xml file, We now have to open the CIV4GameText_Civilopedia_CivLeaders.xml. This holds all of the text for the civilopedia that relates to Civs and their leaders. If you glance through it you will see that this is just the text that shows up in the civilopedia and it has the same structure as the text object file. So I don't think that this part really needs an explanation. at the end of the file after the last </TEXT> tag and before the </Civ4GameText> tag add the following:

    <TEXT>
    <Tag>TXT_KEY_CIV_CANADA_PEDIA</Tag>
    <English>*****Testing Canadian Mod</English>
    </TEXT>
    <TEXT>
    <Tag>TXT_KEY_LEADER_JOHN_MACDONALD_PEDIA</Tag>
    <English>

    John A. Macdonald [\H1][NEWLINE][BOLD]Prime Minister of Canada [\BOLD][NEWLINE][BOLD]Lived: [\BOLD] c. ???? - c. ???? BC[NEWLINE][PARAGRAPH:2][BOLD]Background:[\BOLD][NEWLINE]*****John A. Macdonald Played a major role in Canada's confederation. Through many meetings he finally joined upper and lower Canada to create the two provinces Quebec and Ontario.</English>
    </TEXT>

    Ok I said I wasn't going to explain the XML, so I won't. But I will explain the embedded tags. These tags are nothing more then HTML enclosed in square brackets instead of pointy brackets. HTML isn't necessary for modding civ 4 but it makes everything more interesting. So I would say take a crash course in basic HTML to add some flavor to your Civilopedia texts.

    We now are looking at the <DefaultPlayerColor> tag. All we did was set it to red. But what if we wanted to add our own custom color? well color definitions can be found in the Assets/XML/Interface/ folder in the file CIV4ColorVals.xml. Color definitions are very straight forward. Take COLOR_CLEAR for example:

    <!-- This starts the color definition -->
    <ColorVal>

    <!-- This is how we refrence the color -->
    <!-- We should follow the naming scheme because it makes life easier -->
    <Type>COLOR_CLEAR</Type>

    <!-- This tells us the intensity of the red in this color. 0.00 is no red, 1.00 is ful intensity -->
    <!-- It is *Very* important to use numbers in the format 0.00 or else the game will act funny or not even load -->
    <!-- You must keep the values between 0.00 and 1.00 or the game will either act funny of crash -->
    <fRed>1.00</fRed>

    <!-- Tells us the intensity of green used for the color -->
    <fGreen>1.00</fGreen>

    <!-- Tells us the intensity of blue used for the color -->
    <fBlue>1.00</fBlue>

    <!-- This tag tells us how transparent the color is. -->
    <!-- 1.0 means that the color is totally opaque, 0.0 means invisible -->
    <fAlpha>0.00<fAlpha>

    <!-- end color definition -->
    </ColorVal>

    Thats it for colors, Now I want to see someone implement every color they know ;)

    I will skip the ArtDefineTag and ArtStyleTag because they deserve their own tutorial.

    Now on to defining cities, these definitions go in the text directory in the CIV4GameTextInfos_Cities.xml file. There isn't anything new here so I will just add the St. Johns city definition we did in the last tutorial.

    <TEXT>
    <Tag>TXT_KEY_CITY_NAME_ST_JOHNS</Tag>
    <English>St.John's</English>
    </TEXT>

    For every city you add in the cities list of your civ there has to be an accomponying definition in the CIV4GameTextInfos_Cities.xml file.

    Thats it for adding the text entries for your civ. In the next tutorial I will explain how to add the John A Macdonald Leader for your new civ. If you want to play test you can use the Leader definition from Another civ.

     
  2. WildWeazel

    WildWeazel -- Turns to Completion

    Joined:
    Jul 14, 2003
    Messages:
    6,837
    Location:
    %CIV3%\Conquests\Scenarios\
    Great job. I'm linking to these in my modding thread.
     
  3. BrentRitchie

    BrentRitchie Chieftain

    Joined:
    Oct 30, 2005
    Messages:
    25
    No problem, glad to help. Part 3 should be up Saturday evening. Got lots of school stuff this week.
     
  4. thedaian

    thedaian Chieftain

    Joined:
    Oct 29, 2005
    Messages:
    95
    Location:
    Ohio, USA
    I can see great things from using the language tags... amoung using <klingon> and such. I do have a question, does anyone know where the list of languages are (as in, which files has the language selection options, so a <klingon> tag would actually do something), and, do you need to have every language, or can you just skip some? (it looks like you can, so I'll assume yes)
     
  5. WildWeazel

    WildWeazel -- Turns to Completion

    Joined:
    Jul 14, 2003
    Messages:
    6,837
    Location:
    %CIV3%\Conquests\Scenarios\
    I can see great possibilities here with a LotR mod.
    <sindarin>
    <quenya>
    :D:D:D
     
  6. BrentRitchie

    BrentRitchie Chieftain

    Joined:
    Oct 30, 2005
    Messages:
    25
    thedaian:

    You do not need all the language tags but probably a good idea if distributing a real mod not just a tutorial mod. As to the actual language option definition, I haven't waded through the GameInfo or Misc folders, That's more then likely where it is though.
     
  7. Tabris

    Tabris Chieftain

    Joined:
    Oct 31, 2005
    Messages:
    100
    I'm having some problem trying to implement Byzantines in a mod, i'm trying to make a flag like the one of england but red with a yellow cross, i've notice that if i set the color to dark purple i'll get a purple flag with a yellow cross, but using red i get a red flag with a white cross, how can i put red flag with a yellow cross?
     
  8. DJ Bonebraker

    DJ Bonebraker a.k.a Laura

    Joined:
    Mar 10, 2004
    Messages:
    5,640
    Location:
    Eorzea, Hydaelyn
    Even though it will be some time before I buy Civ IV (let alone start modding it), I would like to know what all can be used to edit XML (besides notepad and wordpad, of course :rolleyes: )? I have Microsoft Frontpage 2K, which are HTML editors, but I'm not sure if it can handle XML as well (I'ts been a while since I last used the program and checked its save file options, and I have to re-install it since my notebook crashed.....).

    I was just curious as to how much of a headache I'll have editing this stuff.
     
  9. BrentRitchie

    BrentRitchie Chieftain

    Joined:
    Oct 30, 2005
    Messages:
    25
    Tabris, I've been playing with the flags also and haven't come up with anything yet. In my early testing It seems that maybe the secondary color of the Player_Color tags might do the trick but my testing isn't done yet. Maybe give it a try?

    Hikaro Takayama, I only use Internet Explorer for reading the original Civ 4 XML files. I have Notepad open at the same time so I can take notes and write my mods into it. I have tried other XML editors and never liked any of them.
     
  10. DJ Bonebraker

    DJ Bonebraker a.k.a Laura

    Joined:
    Mar 10, 2004
    Messages:
    5,640
    Location:
    Eorzea, Hydaelyn
    Well, if IE can open them, then FrontPage can edit them. It's not that I find the XML that difficult, it's just like HTML for me: I hate nothing more than typing 3 pages of HTML for a webpage only to find, after loading it in IE for the first time, that I missed a </font> tag somewhere in the middle of the whole mess. FrontPage takes a lot of the hassle out of the process and allowed me to create a page in about 2 minutes that took me 2 hours to do the long way (using Notepad).

    THanks answering my question.
     
  11. BrentRitchie

    BrentRitchie Chieftain

    Joined:
    Oct 30, 2005
    Messages:
    25
    If your comfortable with frontpage go for it, it should handle xml files great, especially if it is fairly recent. I hope to see some of your mods when you get the game.
     
  12. DJ Bonebraker

    DJ Bonebraker a.k.a Laura

    Joined:
    Mar 10, 2004
    Messages:
    5,640
    Location:
    Eorzea, Hydaelyn

    You'll be waiting a couple of years..... I'm not getting Civ IV untill all the expansion packs and patches are out, so that I can 1) avoid some of the hassle and expense that I experienced with buying Civ III piecemeal, 2) so I can also finish up my Civ III projects, and 3) so I can get a better idea of what Civ IV minus all the "JUST RELEASED!!!!!!" hype is really like.
     
  13. cursif

    cursif Chieftain

    Joined:
    Oct 22, 2002
    Messages:
    49
    Is there any way to get the first part of this tutorial moved into this "section"? With the searching disabled it's harder to find things. I know you can use the Google search but it searches every single forum and section and doesn't tell you which section the result is from.
     
  14. Granias

    Granias Chieftain

    Joined:
    Nov 3, 2005
    Messages:
    34
    Location:
    The Netherlands
    Great tutorial :goodjob:

    And I also can't seem to find the first part. Perhaps it can be linked in this thread?
     
  15. BrentRitchie

    BrentRitchie Chieftain

    Joined:
    Oct 30, 2005
    Messages:
    25
    Civ 4 XML Tutorial Part 1

    Just FYI, I was supposed to have part 3 of my series done for saturday but I'm going home for the weekend. My mom is cooking homemede lasagna, MMMmmmmmm. So I will hove it done early next week instead. Sorry for any inconvience.
     
  16. Belaflek

    Belaflek Chieftain

    Joined:
    Oct 31, 2005
    Messages:
    10
    ...nm...
    Just saw the link
     
  17. ainwood

    ainwood Consultant. Administrator

    Joined:
    Oct 5, 2001
    Messages:
    30,074
    Moderator Action: Moved to the tutorials section.
     
  18. Wolfshanze

    Wolfshanze CFC Historian

    Joined:
    Nov 12, 2001
    Messages:
    5,689
    Location:
    Florida
    Okay, I read the post... maybe my eyes are fogging or something... how do I change a unit name and which XML files need changing? I tried to change the name of the Spearman and kept getting errors.

    Which file(s) do I need to edit to change a unit name?
     
  19. Feet

    Feet Chieftain

    Joined:
    Oct 25, 2005
    Messages:
    143
    Location:
    Southend, UK
    Any chance of seeing the third part any time soon?
     
  20. BrentRitchie

    BrentRitchie Chieftain

    Joined:
    Oct 30, 2005
    Messages:
    25
    Part three will be up tomorrow.
     

Share This Page