How to add a new unit xml tag

ahenobarb

Warlord
Joined
Mar 8, 2001
Messages
118
Does anyone know how to add a new unit tag in the xml files that will be recognized by the game? For instance, if you want to add a new unit ability and want to be able to specify whether each unit has it or not.

What are the steps to implement this?

Dale was able to do this in his combat mod:

Originally posted by Dale

All components can be easily turned off or on in a single XML file which can be edited in any text editor.

....

A number of new XML tags have been added to certain files, please merge carefully into your own Mods.
Code:
// Dale - DCM: DalesCombatMod specific code (not related to any component)
// Dale - AB: Airbombing missions
// Dale - BE: Battle Effects
// Dale - CC: Civ Customiser
// Dale - RB: Ranged Bombard
// Dale - CCH: Civ Changer
// Dale - SA: CASA, Opportunity Fire, Active Defense
// Dale - ARB: Archer Bombard
// Dale - NB: Nuke Bomber

... But I don't know where to start. I already have programmed my c++ code for the new ability, but need to figure out how to connect it to the xml files.

Thanks.
 
Kael did up a decent tutorial for that, check the modding tutorials board. It's not hard at all so you could also just search the cpp files for one of the existing xml tags to see how firaxis did it. i don't have the SDK in front of me right now but I think the file you want to check out is CvInfos.cpp or something with a very similar name.
 
Kael did up a decent tutorial for that, check the modding tutorials board. It's not hard at all so you could also just search the cpp files for one of the existing xml tags to see how firaxis did it. i don't have the SDK in front of me right now but I think the file you want to check out is CvInfos.cpp or something with a very similar name.

THANK YOU!!! That's is just what I needed!

I was doing forum searches for "add" and "xml" and "tag", all of which are under the 4 letter limit -- Argh!:cry:
 
Definitely read Kael's tutorial. That is how I learned it.

The essence of it:

1) Add the tag to schema.
2) Add the tag to the actual XML.
3) Test run for crashes.
4) Go to the class that will be loading the XML in the SDK.
5) In the header (.h) file, add an accessor function for the tag.
5a) If the variable will be saved, create a property to store it.
6) In the .cpp file add the accessor function and the XML ::read code.
6a) If the variable will be saved, add it to the stream ::read and ::write code.
7) If the variable must be output to Python, add it to the CyClass interface.
 
Back
Top Bottom