Xml

the100thballoon

Emperor
Joined
Aug 13, 2003
Messages
1,239
Anyone tried to make sense of the XML files yet? I glanced at one of them and its not too confusing, but a tutorial is definately in order. Anyone up to the challenge?
 
Ok, here's a quickie:

Think of XML like UBB code, only more structured.

You have: [.b]bold [.u]nested underline[/u] end underline [/b] end bold.
It looks like:

[.b]
[.u]
[/u]
[/b]

XML works the same way. (Look at the source in your browser -- view->source. It looks like HTML too).

You'll see something like:

<units>
<strength>5</strength>
</units>

the <strength>...</strength> field tells the game that it's the strength of the unit. If you change 5 to say, 50, you have one powerful unit!
 
Ok, I'll try to help out a little before I go to sleep. First of all, everything we'll be modding will be in the folder marked .../Firaxis Games/Sid Meier's Civilization 4/Assets. From there just open the XML folder and look around. I decided to open up the Units folder and check out the Civ4UnitInfos.xml file. Each unit in the game has a listing just like this:

<UnitClassInfo>
<Type>UNITCLASS_HINDU_MISSIONARY</Type>
<Description>TXT_KEY_UNIT_HINDU_MISSIONARY</Description>
<iMaxGlobalInstances>-1</iMaxGlobalInstances>
<iMaxTeamInstances>-1</iMaxTeamInstances>
<iMaxPlayerInstances>3</iMaxPlayerInstances>
<DefaultUnit>UNIT_HINDU_MISSIONARY</DefaultUnit>
</UnitClassInfo>

The numbers in between reflect the total number of units of that type allowed in the entire map, for each team, and for each player. -1 means that there is no limit, and any number including 0 places a limit on that type. Try changing the number 3, starting the hindu religion in the game, and you'll see that you'll be able to build that many hindu missionaies. Anyway, I'm off to sleep now very exciting times ahead.
 
:) I don't have the game yet, but try this program out... the best XML edotor I've come across... and it's free! XML Marker


intro.gif
 
Notepad2 is also a great program for editing any type of code. Ive done basic work with XML and I know HTML so I'll probably just sit down and mess with it one day (prolly today or tomorow :lol: )
 
I'm going to be using Visual SlickEdit. It's nice because it has autoformatting if you setup an xml project. The same with Python. I've been messing around with and it saves a LOT of typing. Can't wait to get my hands (well, editor) on Civ IV, set up a project and just search through all of the code to see what's available.
 
popewiz said:
Ok, I'll try to help out a little before I go to sleep. First of all, everything we'll be modding will be in the folder marked .../Firaxis Games/Sid Meier's Civilization 4/Assets. From there just open the XML folder and look around. I decided to open up the Units folder and check out the Civ4UnitInfos.xml file. Each unit in the game has a listing just like this:

<UnitClassInfo>
<Type>UNITCLASS_HINDU_MISSIONARY</Type>
<Description>TXT_KEY_UNIT_HINDU_MISSIONARY</Description>
<iMaxGlobalInstances>-1</iMaxGlobalInstances>
<iMaxTeamInstances>-1</iMaxTeamInstances>
<iMaxPlayerInstances>3</iMaxPlayerInstances>
<DefaultUnit>UNIT_HINDU_MISSIONARY</DefaultUnit>
</UnitClassInfo>

The numbers in between reflect the total number of units of that type allowed in the entire map, for each team, and for each player. -1 means that there is no limit, and any number including 0 places a limit on that type. Try changing the number 3, starting the hindu religion in the game, and you'll see that you'll be able to build that many hindu missionaies. Anyway, I'm off to sleep now very exciting times ahead.


Does this determine the number of units that can be constructed at all? or the number of units that are allowed at any one time? So if you build the 3 Hindu Missionaries and then expend two of them, can you build two more?

If this is the case: I smell modified immortals :) and any other UU that is actually an elite unit that should be limited in the numbers that can be produced.
 
Yeah, I kinda wish they did one XML file per unit rather than one XML file with all 100+ units. It's a lot to slog through. Same with the buildings and a lot of the other "big systems".

They did an excellent job with their naming convention, though, with the only confusion I've had so far being with the Creative and Financial leader traits. The <CommerceChanges> and <ExtraYieldThreshold> tags really need to have descriptive sub-tags instead of repeating themselves (3 repetitions of <iCommerce> and <iExtraYieldThreshold>, respectively). Obviously they're affecting 3 different values (or, actually, since they're both set to 0 0 2, skipping two values and affecting the third...) but the XML doesn't tell you what values they are, and that leads to confusion. The 2's are culture and coins, but what are the 0's? No way to know without messing around with it.
 
Weasel Op said:
Hopefullly somebody who is a better programmer than me will make an editor. Until then, I guess Ctrl-F works.

You could do it with Python (cross-compatibility, but I think you'd need the python engine). I have .NET, but you need the .NET framework...

I still have Borland C++, but that's quirky. ;)

.NET can do XML though, I've tried it.

I actually find CTRL-F in notepad to work wonders. It's much easier to copy/paste in notepad than using a 3rd party XML tool. (they are out there...)
 
Actually I may be able to whip up an XML viewer/editor, but it would be pretty ugly and would only be for specific files most likely. I'm familiar with parsing in XML data, the difficulty is purely in meshing it with an MFC framework (Microsoft Foundation Class - ie C++ equivalent of visual basic). Depending on how difficult it winds up being it may be a while before I get it done - I do have non-Civ tasks to do that take up a lot of my time ;)
 
You could make a parser even in C...

But, remember, there's so much to look at with the XML, and not one sample unit/building/etc. will do you justice. There could be nested XML code that one object doesn't have. It'll be a fun project if you like structs. (I just wished .NET didn't do away outright with arrays, structs and whatnot.... it's still there in, but in different forms.)
 
The way I was thinking about doing it was pretty brute-force (at least for now). Manually compile a list of all the unit subtags, for example, then make a UnitXML struct and parse in all the units into a linked list or vector of the structs, then allow the user to edit all the fields.

Like I said, very brute force and hard coded and not exactly robust, but it'd be a start and would let you view and edit a single unit at a time.

The earliest I'd be able to even get started working on it is saturday afternoon, though.
 
I've dabbled in XML coding a little bit (so many nodes! :eek: ). I'm not too familar with it, but my strategy would be parsing it into a myriad of structures. The problem is making them dynamic... So, it would only be a limited use tool in that most of the stuff you add is rather static. (same as all other types of data)
 
About my earlier post, the numbers tell you how many you can have at any 1 time. So your UU idea would definitely work out.
 
Back
Top Bottom