Thunderbrd
C2C War Dog
There's a few of us here looking to expand their ability to mod C2C in the XML files.
Numerous questions have come up about 'what tags can do what', 'what's the proper way to code for that' etc...
I figured I'd start a thread to go over some things that will make these questions much more possible to answer for yourselves as the information often is available if you only know how to read it.
Most of those answers lie within the Schema files. Schemas probably look like Greek when you first take a look at one. I know it did for me. I only managed to garner a greater understanding of how it can be used to derive important XML modding information when learning what I would have to do to manipulate it to add new tags. So it's understandable how this information is not so obvious to those who've not taken the step of trying to learn to code new tags.
But ignoring the schema will leave you in the dark, only able to program with tags you can see examples of on other buildings, open to making grievous errors in the order of the tags you utilize on a given object and possibly missing out on understanding some of the options you have available to you.
There's two parts to understanding the Schema. The first is how to read it and apply that knowledge. The second is how to garner a basic understanding of a tag by understanding some basic naming conventions. I'll cover both here.
So let's say we want to add a unit to the game. The schema is too big to post here so you'll have to open it yourself - I'd suggest doing so in Notepad++.
You'll find there are a number of lines like the following:
These are declarations of tags. To have a tag included in an info.xml file attached to this schema the tag must be declared somewhere in the schema. This is not, however, an automatic indicator that these tags are included in your particular info file. Any tag that is declared like this MAY be, without error, used in your info file, but without further programming in the dll, it probably won't work.
Thus we include a list of the tags that ARE programmed for a given Info file in an 'application' line.
Declaration lines are easily spotted by the way they begin: <ElementType name=
Application lines are also easily spotted by the way THEY begin: <element type=
You'll see Declaration lines that don't close, such as the following:
<ElementType name="UnitInfo" content="eltOnly">
These almost always end with content="eltOnly"> and they then go on to have Application lines listing off underneath them, wrapping up the full statement with a final close line:
</ElementType>
In this example, what we're seeing here is the list of all tags used in UnitInfos.xml. You'll see IN the unit info file the way the file begins:
The first line indicates what this file is and what schema this file is going to use as a control file. The second line you'd actually find inside the schema. It reads:
Which is saying, Within <UnitInfos> you'll find any number of uses of the <UnitInfo> tag.
Note: I'm not entirely sure what maxOccurs="*' means still but the application of <element type="UnitInfo" within the nested UnitInfos declaration is where I'm able to derive the above noted meaning.
Then I can search for the term UnitInfo and find the Declaration for UnitInfo and I find my example above:
<ElementType name="UnitInfo" content="eltOnly">
Then there are nested applications of tags within UnitInfo. These tags, applied with <element type=, are declared elsewhere in the schema. Where is not important so long as it is not within any other declaration and that it is only declared once - even though once declared, a tag may be applied in multiple places, nested within other multi-tag (eltOnly) declarations.
If that above paragraph is too confusing, take away from it the following:
1) A tag must only be declared once in the schema.
2) A tag may, however, be applied in many places.
So under <ElementType name="UnitInfo" content="eltOnly"> we start listing off the tags that can be used for a given Unit definition. Here's a sample of the first ones listed there:
And it goes on for quite a few more tags than that.
Now, when you are programming the xml, you must keep these tags in order on a given UnitInfo. Thus you would find that this beginning sample example of a UnitInfo entry adheres to the above listed order of tags:
EDIT: Update - the order of tags no longer matter in C2C due to a new way to load tags that was added by our master programmers. You can now put them in whatever order you wish in the XML entry.
Some may be missing - that's not only ok, that's advisable. If a tag is not used, it really shouldn't be included in the definition of that UnitInfo at all. (EDIT: Sometimes there are design reasons you may want to include a tag with a default value so that you or others to come may see the specific intention to use default.)
In otherwords, it would usually be better to have the <Advisor> tag line in the above example simply not be there at all. However, some tags are not optimally programmed and thus not including them causes a default that is not exactly what you'd think so be on the lookout for those.
Nevertheless, even if a tag is missing from a UnitInfo (we'll begin calling that an 'object definition' from here on out) as long as the tags that ARE included are in the order established by the schema, we're OK.
So what we've learned so far is how to find a FULL list of tags that can be used in any object definition and the proper syntax use for those tags.
Now if you see a tag in use in an info file and it isn't given an application line in the schema, this is fine... as I said above, it COULD possibly work and it won't error out. Tags that are just declared but not applied can be used ANYWHERE in the xml. An example of such a tag is <ConstructCondition> in the Buildings Schema. You can go on to use ConstructCondition anywhere in any building file and the way AIAndy has programmed it it'll work just fine to apply to the object definition its used in. It is not, however, given an application line on any Info type in the Building Schema. Don't let this throw you if you're looking for where you should be putting that tag in any given order.
Generally the rule of thumb here is if a tag has NO application lines anywhere, its a generic tag that can be used in all of the object definitions that apply to that schema.
Otherwise, if you search for and FIND an application line on a tag but you don't find it within the particular Info type you're wanting to apply that tag to, you're probably looking at a situation where the tag isn't setup to work with that particular Info type.
Thus, if I have a TechPrereq tag and I want to use it on my FeaturesInfo but in the Terrain schema you find TechPrereq has been declared, and applied to some of the Info types within that schema, like BuildsInfo for example, but NOT applied under FeaturesInfo, you have a tag that probably isn't setup to work with FeaturesInfo even though you could use the tag there without error but without it having any effect.
Ok, I'll move on to the next post to explain more.
Numerous questions have come up about 'what tags can do what', 'what's the proper way to code for that' etc...
I figured I'd start a thread to go over some things that will make these questions much more possible to answer for yourselves as the information often is available if you only know how to read it.
Most of those answers lie within the Schema files. Schemas probably look like Greek when you first take a look at one. I know it did for me. I only managed to garner a greater understanding of how it can be used to derive important XML modding information when learning what I would have to do to manipulate it to add new tags. So it's understandable how this information is not so obvious to those who've not taken the step of trying to learn to code new tags.
But ignoring the schema will leave you in the dark, only able to program with tags you can see examples of on other buildings, open to making grievous errors in the order of the tags you utilize on a given object and possibly missing out on understanding some of the options you have available to you.
There's two parts to understanding the Schema. The first is how to read it and apply that knowledge. The second is how to garner a basic understanding of a tag by understanding some basic naming conventions. I'll cover both here.
So let's say we want to add a unit to the game. The schema is too big to post here so you'll have to open it yourself - I'd suggest doing so in Notepad++.
You'll find there are a number of lines like the following:
Code:
<ElementType name="BonusType" content="textOnly"/>
<ElementType name="PrereqTech" content="textOnly"/>
<ElementType name="Description" content="textOnly"/>
Thus we include a list of the tags that ARE programmed for a given Info file in an 'application' line.
Declaration lines are easily spotted by the way they begin: <ElementType name=
Application lines are also easily spotted by the way THEY begin: <element type=
You'll see Declaration lines that don't close, such as the following:
<ElementType name="UnitInfo" content="eltOnly">
These almost always end with content="eltOnly"> and they then go on to have Application lines listing off underneath them, wrapping up the full statement with a final close line:
</ElementType>
In this example, what we're seeing here is the list of all tags used in UnitInfos.xml. You'll see IN the unit info file the way the file begins:
Code:
<Civ4UnitInfos xmlns="x-schema:C2C_CIV4UnitSchema.xml">
<UnitInfos>
<UnitInfo>
Code:
<ElementType name="UnitInfos" content="eltOnly">
<element type="UnitInfo" maxOccurs="*"/>
</ElementType>
Note: I'm not entirely sure what maxOccurs="*' means still but the application of <element type="UnitInfo" within the nested UnitInfos declaration is where I'm able to derive the above noted meaning.
Then I can search for the term UnitInfo and find the Declaration for UnitInfo and I find my example above:
<ElementType name="UnitInfo" content="eltOnly">
Then there are nested applications of tags within UnitInfo. These tags, applied with <element type=, are declared elsewhere in the schema. Where is not important so long as it is not within any other declaration and that it is only declared once - even though once declared, a tag may be applied in multiple places, nested within other multi-tag (eltOnly) declarations.
If that above paragraph is too confusing, take away from it the following:
1) A tag must only be declared once in the schema.
2) A tag may, however, be applied in many places.
So under <ElementType name="UnitInfo" content="eltOnly"> we start listing off the tags that can be used for a given Unit definition. Here's a sample of the first ones listed there:
Code:
<element type="Class" minOccurs="0"/>
<element type="Type" minOccurs="0"/>
<!-- XMLCOPY 02/20/2008 MRGENIE -->
<element type="bTypeDependency" minOccurs="0"/>
<element type="bForceOverwrite" minOccurs="0"/>
<element type="AndDependencyTypes" minOccurs="0"/>
<element type="OrDependencyTypes" minOccurs="0"/>
<!-- XMLCOPY END MRGENIE -->
<element type="UniqueNames" minOccurs="0"/>
<element type="Special" minOccurs="0"/>
<element type="Capture" minOccurs="0"/>
<element type="Combat" minOccurs="0"/>
<!--TB SubCombat Mod begin-->
<element type="SubCombatTypes" minOccurs="0"/>
<!--TB SubCombat Mod end-->
<element type="Domain" minOccurs="0"/>
<element type="DefaultUnitAI" minOccurs="0"/>
<element type="Invisible" minOccurs="0"/>
<element type="SeeInvisible" minOccurs="0"/>
<element type="Description" minOccurs="0"/>
<element type="Civilopedia" minOccurs="0"/>
<element type="Strategy" minOccurs="0"/>
<element type="Help" minOccurs="0"/>
<element type="Advisor" minOccurs="0"/>
<element type="bAnimal" minOccurs="0"/>
<element type="bFood" minOccurs="0"/>
<element type="bNoBadGoodies" minOccurs="0"/>
<element type="bOnlyDefensive" minOccurs="0"/>
<element type="bNoCapture" minOccurs="0"/>
<element type="bQuickCombat" minOccurs="0"/>
<element type="bRivalTerritory" minOccurs="0"/>
<element type="bMilitaryHappiness" minOccurs="0"/>
<element type="bMilitarySupport" minOccurs="0"/>
<element type="bMilitaryProduction" minOccurs="0"/>
<element type="bPillage" minOccurs="0"/>
<element type="bSpy" minOccurs="0"/>
<element type="bSabotage" minOccurs="0"/>
<element type="bDestroy" minOccurs="0"/>
<element type="bStealPlans" minOccurs="0"/>
<element type="bInvestigate" minOccurs="0"/>
<element type="bCounterSpy" minOccurs="0"/>
<element type="bFound" minOccurs="0"/>
<element type="bGoldenAge" minOccurs="0"/>
<element type="bInvisible" minOccurs="0"/>
<element type="bFirstStrikeImmune" minOccurs="0"/>
<element type="bNoDefensiveBonus" minOccurs="0"/>
EDIT: Update - the order of tags no longer matter in C2C due to a new way to load tags that was added by our master programmers. You can now put them in whatever order you wish in the XML entry.
Code:
<UnitInfo>
<Class>UNITCLASS_AARDVARK</Class>
<Type>UNIT_AARDVARK</Type>
<UniqueNames/>
<Special>NONE</Special>
<Capture>NONE</Capture>
<Combat>UNITCOMBAT_ANIMAL</Combat>
<Domain>DOMAIN_LAND</Domain>
<DefaultUnitAI>UNITAI_ANIMAL</DefaultUnitAI>
<Invisible>NONE</Invisible>
<SeeInvisible>NONE</SeeInvisible>
<Description>TXT_KEY_UNIT_AARDVARK</Description>
<Civilopedia>TXT_KEY_CONCEPT_ANIMALS_PEDIA</Civilopedia>
<Strategy>TXT_KEY_UNIT_ANIMAL_STRATEGY</Strategy>
<Advisor>NONE</Advisor>
In otherwords, it would usually be better to have the <Advisor> tag line in the above example simply not be there at all. However, some tags are not optimally programmed and thus not including them causes a default that is not exactly what you'd think so be on the lookout for those.
Nevertheless, even if a tag is missing from a UnitInfo (we'll begin calling that an 'object definition' from here on out) as long as the tags that ARE included are in the order established by the schema, we're OK.
So what we've learned so far is how to find a FULL list of tags that can be used in any object definition and the proper syntax use for those tags.
Now if you see a tag in use in an info file and it isn't given an application line in the schema, this is fine... as I said above, it COULD possibly work and it won't error out. Tags that are just declared but not applied can be used ANYWHERE in the xml. An example of such a tag is <ConstructCondition> in the Buildings Schema. You can go on to use ConstructCondition anywhere in any building file and the way AIAndy has programmed it it'll work just fine to apply to the object definition its used in. It is not, however, given an application line on any Info type in the Building Schema. Don't let this throw you if you're looking for where you should be putting that tag in any given order.
Generally the rule of thumb here is if a tag has NO application lines anywhere, its a generic tag that can be used in all of the object definitions that apply to that schema.
Otherwise, if you search for and FIND an application line on a tag but you don't find it within the particular Info type you're wanting to apply that tag to, you're probably looking at a situation where the tag isn't setup to work with that particular Info type.
Thus, if I have a TechPrereq tag and I want to use it on my FeaturesInfo but in the Terrain schema you find TechPrereq has been declared, and applied to some of the Info types within that schema, like BuildsInfo for example, but NOT applied under FeaturesInfo, you have a tag that probably isn't setup to work with FeaturesInfo even though you could use the tag there without error but without it having any effect.
Ok, I'll move on to the next post to explain more.
Last edited: