HOW TO: Add a Civ/Unit/Building in BTS (Modular XML Modding)

Teg, thanks again. I have been working through this, and I feel like I am making some real progress here. Couldn't have done it without your guide!
I have been picking up a LOT of info here, and some other articles from some other smart folks have also helped me out.

I seem to be stuck though... and was hoping you could help me...
Before I get started... In case you need it, here is the link to the mod itself (WIP!)

Here are the screen shots of the errors I keep getting. (Note: the 2nd two are not related to the first picture, but come separately with no other warning like in the first picture)

Also, every time I try to load the MOD, I cannot get a leader to show up under "South African Empire", there is not picture there and no name, etc... just a blank box... So, obviously, I have not advanced into gameplay yet to see if the unit works, etc.

I am trying to update the Afrikaan/Boer mod someone (they will be in the credits when finished). The pack I took it from was not updated for BTS, but I used your Swiss BTS for the bulk of my work.
 
I see several problems.

Firstly, there are some additional XML tags in BtS that are missing from your (vanilla) mod. I have written a python script that helps a bit, but if you don't know how to run it, doing it manually is probably faster. Still, the script might be useful, since it tells you where the changes are:

Code:
	if line.find("<bNoCapture>") != -1:
		line = ConvertUnits().InsertData(line,"<bQuickCombat>0</bQuickCombat>")

This tells you that you need to add the line "<bQuickCombat>0</bQuickCombat>" after the line containing "<bNoCapture>" in your UnitInfos file.

Secondly, I noticed some XML errors: try loading Afrikaan_CIV4UnitInfos.xml with a browser and you'll notice that it doesn't compile. There's two closing tags "</FreePromotion>", but only one "<FreePromotion>"

Thirdly, make absolutely sure that you name your units/leaders etc. consistently. Your leader ist called "LEADER_PIETER_WILLEM_BOTHA" in one place, and "LEADER_AFRIKAAN_PIETER_WILLEM_BOTHA" in another. This will screw up your mod.
 
Thanks! I will work on this when I get home for the weekend. It is my first go at it, so I appreciate your help and patience (because I am SURE that I will be posting about another error once I fix these...).

I did manage to correct several errors on my own before these stumped me... and 1 week ago I had never even opened an XML file.
 
OK, so here is what I did.
I found a BtS civ (Canada) done by someone who knows what they are doing and then some. I went down line by line and compared the "mountie" to the "kommando ruiter"...

I also made the names uniform like you said.

I don't know how to use a python, clicked on your link, thought I'd give it a shot... then I saw that you use LINUX... bridge too far for me. I am using Windows...

So, here is my latest errors (the Botha errors went away!!! Yeah!!!)
Still getting the one from before (#2) about the KOMMANDO_RUITER_ and this is the newest one


Here is another upload of my current mod if it helps...

Thanks again for your assistance on this.
 
Ok, I'll show you how to read the error message yourself. First, you'll see the name of the file causing the error message: Afrikaan_CIV4UnitInfos.xml

Do you use a text editor with line numbering? If yes, go to line 49 of that file. You see that it's the line with "bFlatMovementCost" in it, which is also shown on the error message. So far, so good.

The error message "Element content is invalid according to the DTD/Schema" means that there is a conflict between Afrikaan_CIV4UnitSchema.xml and Afrikaan_CIV4UnitInfos.xml. Go find "bFlatMovementCost" in Afrikaan_CIV4UnitSchema.xml and check what comes before and what comes after. See something that's missing from Afrikaan_CIV4UnitInfos.xml? Add it.

The "kommando ruiter" problem should go away as soon as Afrikaan_CIV4UnitInfos.xml successfully loads.
 
Yes! These things are working. Let me thank you again for your patience, and also for your quick responses!

I have gotten it down to two errors on the load, and one error when going to build the unique unit. I suspect they may be related.

First error...
Here is the screen shot of what I am getting (I get it twice in a row, back to back... no other errors during mod loading now):


The second error...
I went into World Builder, and tried out the unit. I was able to place the unit directly on the map in this mode. Then gave myself the techs required to build the unit. I also gave myself the required pasturized horses resource.
I exited World Builder, and went to build the unit in the city queue. The button was there, no problem, I had the prereqs. When I actually clicked on the button to build it... wham... game crashed.

Again, here is the mod in progress for DLing...
 
Crashes are usually due to missing art files. They might not actually be missing, but just misreferenced. Check your Afrikaan_CIV4ArtDefines_Unit.xml (and the other ArtDefines files) and make sure that the paths to the art files are correct. I see the path ".../South Africa/..." several times, which doesn't exist.

As for your XML error: check all tags in afrikaan_civ4unitinfos.xml that have the value 1. Then, find a group of two similar ones. There is either something wrong with your "UnitAIs" or "FreePromotions"; I'll leave it up to you to find out the rest.
 
Thanks a ton, I got it to the point where it is at least working after hours of fooling around. I still don't have a working .kfm file... Do I need that?


Now I will fine tune it, and am better equipped to deal with issues.

I look forward to posting a finish product soon!
 
OK, I have been working diligently (humidity here sometimes makes it too unbearable to go out).

I am seriously stuck this time, creating the unique building.
No matter what I do, I keep getting the same error. I have attached the screen shot. I have looked at the "add a building" tutorial, and followed it.

I modified the XML for the "Mint" (Mali, replaces forge) to create the "Mineral Mine" (replaces forge as well). The XML for the Mineral Mine seems to run fine (no errors are reported during upload).

For some reason, even though I added the UB like all the other civs from BtS have added theirs in the "Afrikaan_CIV4CivilizationInfos.xml" file , it doesn't seem to work. Every I get the same error, and on my buttons within the game, neither the forge nor the Mineral Mine are there (I am using the art from the Japanese Shale Plant for this) on my build list. These two issues are probably related.

I have gone over the code 1000 times now... and it should be easy...

Here is what I have
Code:
<Buildings>
				<Building>
                                                                                        <BuildingClassType>BUILDINGCLASS_FORGE</BuildingClassType>
					<BuildingType>BUILDING_MINERAL_MINE</BuildingType>
 				</Building>
			</Buildings>

Here is what a BtS Civ has:
Code:
<Buildings>
				<Building>
					<BuildingClassType>BUILDINGCLASS_FORGE</BuildingClassType>
					<BuildingType>BUILDING_MALI_MINT</BuildingType>
				</Building>
			</Buildings>
What could I possibly be doing wrong??? I am pulling my hair out!

As always, the DL link for what I have thus far
 

Attachments

  • mineralmineerror6-27.gif
    mineralmineerror6-27.gif
    33.4 KB · Views: 541
There's no Civ4BuildingsInfos.xml in the .rar-archive, did you forget it?

I don't need that, do I?
From the tutorial here, running on BtS, you only have to include changes when you load a mod. This tutorial is excellent watched for help... I appreciate/need that.

My building in question is in the file "Afrikaan_CIV4BuildingInfos.xml"
 
The_J is talking about "Afrikaan_CIV4BuildingInfos.xml", which isn't in the mod you uploaded. I can just reiterate that you have to make sure that all the cross-references are corerct: your Afrikaan_CIV4BuildingInfos.xml has to refer to a valid schema file (and valid art files), and the "type" you add has to be the same as in "Afrikaan_CIV4CivilizationInfos.xml".
 
@ The_J
I have re-upped the mod (odd that file was missing, since I hadn't moved it, I guess it was a megaupload issue).
http://www.megaupload.com/?d=XM2393J6

@ Teg
I have cross-checked everything a hundred times... I can't see anything different. I have checked it versus Mali and the Mali Mint from BtS (since this was a pure forge for UB swap out too), and the Canada Mod available here for BtS.
 
:confused: there's still no BuildingsInfos in it :confused:.

Weird! I DLed it from megaupload and sure enough, it wasn't there. I wonder why it was omitting it (and other files!)

Here it is directly then...
I attached it as a .txt
 

Attachments

  • Afrikaan_CIV4ArtDefines_Building.txt
    607 bytes · Views: 376
  • Afrikaan_CIV4BuildingInfos.txt
    8.8 KB · Views: 251
Do you also have "Afrikaan_CIV4BuildingsSchema.xml" in your mod folder? And I can't find any mention of the unique building in the "Afrikaan_CIV4CivilizationInfos.xml".

Without seeing an up-to-date version of the mod, I can't tell what's wrong. The problem is probably an inconsistency somewhere (could be just a typo), and code snippets or single files are of little use.

Your art file path names are still inconsistent BTW. Some say "afrikaan", some "south africa"
 
ok, fixed the "south africa" vs "afrikaan" issue, all should now be "afrikaan".

Here is a UL of the zipped version, rather than .rar. I don't know why it was excluding some files.
http://www.megaupload.com/?d=PJTTML04

The unique building in Afrikaan_CIV4CivilizationInfos.xml should be between "cities" and the UU, per the schema (search function "find" "MINERAL_MINE" on notepad and it will bring you right to it). And, yes, the schemas are all in there, and you teaching me how to use them has helped out tremendously in fixing other errors myself.
Thanks again.

I am still getting the same error from the most recent screen shot...
 
just a post to make sure people saw that I am still stuck here... the previous post has my most recent Mod work in it...

The UB is still stumping me...
 
Had to compare your files to some others to find the problem; the error message wasn't very helpful in this case.

The correct structure for the file is
<Civ4BuildingInfos>
<BuildingInfos>
<BuildingInfo>
(building1)
</BuildingInfo>
<BuildingInfo>
(building2)
</BuildingInfo>
</BuildingInfos>
</Civ4BuildingInfos>

You are missing the BuildingInfos tags.

I'm a bit surprised this didn't throw an error message. The schema file should have stricter rules here.

BTW, I still see some path inconsistencies in the ArtDefines files (Afrikaan/South Africa).
 
Thank you!
I will run this when I get home.

Re: Art... worst case, I can just use the Forge still... just to get the thing posted.

I will continue to make minor changes here and there (like for some reason the Kommando Ruiter's hats are pink!)... but once I get the UU and the UB working, it is postable I would say.

Eventually I hope to make my own art for the UB, and basically keep working it until I have a total mod. Thanks for your help. Since I have completed the parameters of your initial post here, you're off the hook from more annoying questions from me! :goodjob:


EDIT: IT WORKS!
 
Top Bottom