View Full Version : How to... start...


kooboo
Apr 16, 2009, 09:51 AM
Hey, I have a very simple mod in my mind. It will change few aspects in game that irritate me in a way or two. No sophisticated alterations whatsoever.
I've spent some time browsing and reading the tutorials, about XML, Python etc, but most of them are not what I need to be honest, because I only want to modify existing features.

The first issue I've encountered is - how to start?
I created a folder \Mods\Mod Lobka\Assets\XML\Units (and ...\Gameinfo)
and copied the files I wanted to change (namely CIV4UnitInfos.xml and CIV4CivicInfos.xml)

The first thing I've changed is strenght of Pikeman from 6 to 7 in
<iCombat>7</iCombat>
That was the one and only and first thing I've changed at all. I tried loading the mod from the game, but it says:
Failed Loading XML file xml\units/Civ4UnitsInfos. [.\FXml.cpp:133] Error parsing XML file:
File: xml\units/Civ4UnitsInfos
Reason: Element content is invalid according to the DTD/Schema

I probably start making changes wrong way, but I really couldn't find the "How to make the very first step" tutorial. Most of them assume you know the file structure already :confused:

This is the planned changes list. As you can see, it's really not much changes.
Civilizations
Financial
+ 1 commerce on plots with at least 3 commerce
+50% bank building speed

Imperialistic
Great General emergence increased 100 percent.
50% faster production of Settlers.
+2XP for horse units

Civics
Serfdom (all normal + …)
every city gains free Citizen specialist.

Environmentalism (all normal + ...)
reduces building cost of all by 5%

Units

Gallic Warrior
starts with guerilla
+10% city attack
+10% vs melee

Pikeman
strenght = 7
+71% vs cavalry
+20% defense on plains, grassland vs melee

Landsknecht (UU pikeman)
str = 7
+71% vs cavalry and melee
+20% def on plains, grassland vs melee

Spearman
+20% defense on plains, grassland vs melee

Impi (UU spearman)
+20% def on plains, grassland vs melee
Starts with mobility

Holkan (UU spearman)
+20% def on plains, grassland vs melee
immune to first strikes

(new) Steam Cruiser (delayed until everything else is done)
str = 18
move = 5
Can bombard city defenses, ignoring Walls and Castles (-12%/turn)

City Improvements
Dun (waits until I have an idea how to alter it)
Wonders
Other
Forests grant 25% defense bonus instead of 50%

phungus420
Apr 16, 2009, 01:14 PM
My advice is to start here:
Guide: Adding new units to CIV 4 (http://forums.civfanatics.com/showthread.php?t=139721)

This is the first tutorial I read, that got me to start modding.

Shiggs713
Apr 16, 2009, 01:14 PM
does the error give you a line number? If so just find it and look at it... you'll probably find an error fairly quickly.

Use notepad++ to edit XML files. Despite what anyone might say, it is the best (easiest to use) for that. Maybe some of the xml editors on this forum are comparable though.

its pretty apparent thats not all you did, because if it is like you said and you only changed a "6" to a "7", it would 100% definitely work.

I'd bet money you left the tag open... something like this <iCombat>7/iCombat> instead of <iCombat>7</iCombat>

maybe try copying the files to the proper directories again (start over basically... its not much) and try running the mod without making any changes. Make sure it says your mod name at the top right on the main menu screen. After that, change 1 value again and check it to make sure it works...

I started out like that, doing 1 or 2 simple things at a time. Now I usually do a few hundred changes before I check them... you'll get better at it.

edit: more info

the iCombat tag is an Integer. Hence the i. The value inside of it can pretty much be any whole number (within reason, I think civ caps it somewhere). The boolean tags are b. They are always 0 (false) or 1 (true). The tags that don't have any naming conventions are of type string. For example, the description tag for lion, <Description>TXT_KEY_UNIT_LION</Description>. Obviously when you see a lion in the game, it doesn't say TXT_KEY_UNIT_LION. It says Lion. The txt_key tags are usually located in the XML/text folder, in a file specific to your mod. In your example it would be something like LobkaText.xml

instead of having some txt_key tag leading to that xml file, you could alternatively just type in Lion, and it would show up exactly the same. The only problem with that is people using other languages with civ. Really thats the one and only reason all that stuff is like that instead of directly within the tag itself.


On a side note, why 71% for Landsknecht and Pike? Especially the Landsknecht vs Melee and the grasslands bonus... Overpowered much?
and environmentalism I would think would increase building cost, not reduce it. (strict building codes)

Edgecrusher
Apr 16, 2009, 01:42 PM
If you have a chance I would read the civ4 wiki (if its still up), it gives a good run down of what you can expect when editing the tags.

I learned alot just skimming through those, and alot of trial & error.

phungus420
Apr 16, 2009, 01:47 PM
If you have a chance I would read the civ4 wiki (if its still up), it gives a good run down of what you can expect when editing the tags.

I learned alot just skimming through those, and alot of trial & error.

I wouldn't... You'll figure out most of what the tags mean just by using common sense, and those you don't, you can always just ask questions about, plus I think the Civ4 wiki is incomplete. The Python API is a great reference though if you ever get into python editing, but I just totally disagree about the wiki, it's next to useless in my book.

kooboo
Apr 16, 2009, 02:01 PM
Use notepad
Aye, I'm using only notepad :)

its pretty apparent thats not all you did, because if it is like you said and you only changed a "6" to a "7", it would 100% definitely work.
Yes, that's true... I did something really stupid and expected it to work. I copied the Civ4UnitInfos.xml from vanilla civ... Apart from that I've changed only the value from 6 to 7 :)
I thought I need to copy some additional files or something to make it work, but, well...:mischief:

maybe try copying the files to the proper directories again (start over basically... its not much)
That's what helped :D

On a side note, why 71% for Landsknecht and Pike? Especially the Landsknecht vs Melee and the grasslands bonus... Overpowered much?

I feel sorry about the role of spearman/pikeman has in the game, while it was the most basic and common type of troops in human history. I feel they are misrepresented in the game.
And why 71%? Well, 71% may look odd, but I want to change as little as possible. Original +100% of 6 is 12 against cavalry. +71% of 7 is... 12 against cavalry :)
I don't want to mess up the game :)
The grassland bonus is yet another addition to all spear and pike wielding (and their UU counterparts). And it's only on defense.

environmentalism I would think would increase building cost, not reduce it. (strict building codes)
I guess I'll leave it as it was in original anyway :)

Thanks :)

edit:

Now... How the hell I edit plains defense? The only option available is hills defense. I've tried adding <iPlainsDefense> but it won't work :)
Also in Serfdom change... there is only option to add any free specialist... <iFreeSpecialist>0</iFreeSpecialist>.
And specific unit (here: cavalry) extra xp, not generic xp.
Is it simple thing to do or is it more advanced editing?

DEADLY9996
Apr 16, 2009, 03:31 PM
Heres a link for basics, quite good really:

http://forums.civfanatics.com/showthread.php?t=262402


Now READ This defiantly, makes life easier (Hopefully you have BTS)

http://forums.civfanatics.com/showthread.php?t=234970


Plains Defense, well if it isn't there at all, maybe you could make it a promotion? Amras MOD has promotions like that.

For EXP, you could increase the EXP Stables Building gives you.

Shiggs713
Apr 16, 2009, 10:35 PM
for plains defense you simply use the <TerrainDefenses> tag like this;

<TerrainDefenses>
<TerrainDefense>
<TerrainType>TERRAIN_PLAINS</TerrainType>
<iTerrainDefense>50</iTerrainDefense>
</TerrainDefense>
</TerrainDefenses>

for a 50% bonus

and yea, you cant just add new tags... they have to be located in the schema file, and more importantly in the SDK as well

for a certain specialist... maybe somehow do it with buildings indirectly. like serfdom allows a building (or wonder) that grants free specialist. Like the great library does...

<FreeSpecialistCounts>
<FreeSpecialistCount>
<SpecialistType>SPECIALIST_SCIENTIST</SpecialistType>
<iFreeSpecialistCount>2</iFreeSpecialistCount>
</FreeSpecialistCount>
</FreeSpecialistCounts>


for cav getting extra xp... not really certain.. maybe something like an upgraded stable that requires same tech as cavalry. Or you could add to the <FreePromotions/> tag if you just want to give it something like flanking for free.

phungus420
Apr 16, 2009, 10:39 PM
and yea, you cant just add new tags... they have to be located in the schema file, and more importantly in the SDK as well
Correct me if I'm wrong, but couldn't you just add new tags by setting them up in the Schema file, it's just that without any SDK work, the tag wol't do anything (but technically speacking you could create a new tag without SDK modding).

Shiggs713
Apr 16, 2009, 10:51 PM
well you might be right, but point being it still wont do anything.

phungus420
Apr 16, 2009, 10:52 PM
Yeah, I know was just being pedantic :p

kooboo
Apr 19, 2009, 04:10 PM
Correct me if I'm wrong, but couldn't you just add new tags by setting them up in the Schema file, it's just that without any SDK work, the tag wol't do anything (but technically speacking you could create a new tag without SDK modding).

I think I've tried that and it wouldn't work (the mod wouldn't load correctly) :)