View Full Version : XML syntax explanation


HanWuDi
Aug 22, 2009, 05:34 PM
So, I'm trying to do some simple modding, only playing with some xml, but I'm running into the problems that I'm not sure what all the syntax means. I'm looking for a resource that lays it out something along the lines of:

<icommercechanges> does such-and-such. This is exactly how you can use it, how it expect the syntax to look, and what all the numbers you add will do to your game.

Anyone able to direct me?

civ editor11
Aug 22, 2009, 05:53 PM
the modding wiki's xml page should help you http://modiki.civfanatics.com/index.php/Civ4_XML_Reference . It tells you what most things do and how you should change them. I think its mainly for beyond the sword. I don't know of anything for vanilla.

The_J
Aug 22, 2009, 06:36 PM
The way i take everytime, when i don't know, what something does: Look, where it's used, and compare the values to the ingame effect.

Afforess
Aug 22, 2009, 07:07 PM
I figure out ~85% of the syntax by its naming. Firaxis picked very logical names for everything. For example, the "I" or "b" in front of the words means "Integer" or "boolean." Integers are whole numbers. Boolean means yes or no, true, or false, 1, or 0. The rest, means pretty much what it says. If I can't immediately tell what something does, Modiki (http://modiki.civfanatics.com/) comes in handy.

HanWuDi
Aug 27, 2009, 04:50 PM
Thanks, this makes sense. I was able to figure out a lot of it by common sense, but because my computer is a little overeager to crash, I don't like experimenting if I can avoid it. If I freak out the game engine, I ususally need to reboot.

Second question: Is there a brief overview of how scripting events works? I know Rhye's mod has certain cities and units spawn on certain dates. I'd like to know how easy it would be to make a scenerio where you never build your own cities with settlers, but player and barbarian cities spawn on the map at historically correct times.

The_J
Aug 27, 2009, 06:58 PM
That would be more difficult, because for this you need programming skills (python).

HanWuDi
Aug 27, 2009, 08:48 PM
terribly difficult programming skills?

The_J
Aug 28, 2009, 06:59 PM
No, not terribly difficult.
For spawning a city/unit, you only need one line, but you'll need several checks for everyone (is the plot for the city/unit not a hill/water, is there no enemy unit, what date do we have, etc).

Do you have basic programming skills?

HanWuDi
Aug 28, 2009, 10:19 PM
Yes, although they're fairly rusty. I'm getting the hang of python slowly, I'm just having a hard time finding the various functions civ uses and the syntax is throwing me. I'm beyond the basic python tutorials I've found so far, but can't find anything to get me into actually writing CivIV specific code.

General Tso
Aug 29, 2009, 08:38 PM
This may help.

http://civilization4.net/files/modding/PythonAPI/

It has most of the methods available to Python - some of the ones added with recent patches are missing.
I also like the "Types List" in the lower left of the screen.

civ editor11
Aug 29, 2009, 09:11 PM
That one is for warlords They also have one here:
http://civ4bug.sourceforge.net/PythonAPI/index.html
for BTS

General Tso
Aug 29, 2009, 10:46 PM
Cool, thanks for the link.

HanWuDi
Aug 30, 2009, 01:06 PM
I've seen those before, but i'm getting caught on exactly how to turn that into useful code.

If I wanted to spawn a city at a certain spot on a certain turn, I figure I'd need to get the turn first, and by the look of that database, would that be getGameTurnInfo (INT iIndex)? I know INT iIndex means I need to pass an integer argument, but I'm not sure what I'd be passing. Or could I just write
if gc.getGameTurnInfo() == 0:
Would that trigger the following code on turn 1?

Which brings up my other problem, I've read every void on that list, and I can't find one to spawn a city, or any other object for that matter, at a given plot.

The_J
Aug 30, 2009, 06:07 PM
CyGame().getTurnYear(iGameTurn)==XY

XY= Year.
iGameTurn is a value, you'll have to get from the function itself (like in onBeginGameTurn).


Or you could use

CyGame().getGameTurn ()

to get the current turn.



For a city:
pPlayer.initCity(iX,iY)

iX, iY: Numbers for the position (have to be specified somewhere before).
pPlayer = CyPlayer instance.
You get a CyPlayer instance through gc.getPlayer (theplayernumber).

HanWuDi
Aug 30, 2009, 06:25 PM
Is there some way to force the name of the city?

God-Emperor
Aug 30, 2009, 07:21 PM
Is there some way to force the name of the city?

Of course.

Once you create the city you can change many things.

pCity=pPlayer.initCity( iX, iY)
pCity.setName( "Bob", False)
pCity.setPopulation( 77 )
pCity.setFood( 33 )

This gets you a city named "Bob" (the "False" in the setName may prevent it from chanigng the city founding date to the current turn, but I'm not sure) with a population of 77 (way too much) with 33 food currently stored.