R
Rabbit, White
Guest
Adding newly created units
Disclaimer
By newly created I mean units that use new NIF files.
This tutorial is more like a step-by-step guide really, and it doesnt cover units that have only been reskinned. It also doesnt cover more XML than is necessary to accomplish this. If you want to know more about that you should read sovarns excellent guide to adding new units. In fact, it is recommended to read it before you read this tutorial, as you will understand much better the steps described here.
There are also no instructions on how to add/use new buttons for these units, theres a whole thread on that I believe.
There are two kinds of units of concern here one is units that use vanilla animations and the other is, units that use new (either completely new, or slightly modified vanilla) animations. The steps for adding them differ only slightly, in fact only one step is partially different for them. However, difference is important and I will explain it when we get to that step.
If you only have trouble with the art defines then skip to the last step.
Step 1
Once you downloaded the unit, unzip it into your mods unit directory, that would be Mods\[mod name]\Assets\Art\Units. Dont forget to create a folder for the unit if needed. (If youre putting it in Custome Assets then obviously the path is just CustomAssets\Art\Units.)
In most cases the creator of a unit will provide all the files needed to make it work unless otherwise stated. If the unit uses vanilla animations then there probably wont be any animation files (KF and KFM) with the unit, and that is because they are not needed.
This is important - do not add any other files to the units folder, in 99% of the cases you do not need them and they might mess things up.
The most common mistake people make is when they download a unit that doesnt have animation files and then add those files to its folder. That is not necessary and in fact, sometimes can mess things up (I dont know why but it just does).
Step 2
If you havent already, then create a folder called XML in your mods assets directory. In it create two additional folders Units and Art.
Go to these folders in the main civ4 directory and copy the following files from them CIV4FormationInfos.xml, CIV4UnitClassInfos.xml and CIV4UnitInfos.xml from the Units folder, and CIV4ArtDefines_Unit.xml from the Art folder. Place them in the corresponding new folders you just created.
Step 3
Open the UnitInfos file (Ill be dropping the CIV4 and .xml parts from file names for brevity). Make a copy of any unit entry. By unit entry I mean everything between the <UnitInfo> and </UnitInfo> tags, including them. You can make a copy of any unit but its best to copy a unit that closely resembles then new unit youd like to add. Resembles in terms of properties (stats) not look.
Change the units class and type to something else, usually its just UNITCLASS_ (or UNIT_ for type) followed by a capitalized name of the unit.
A bit lower find the <Description> tag and change its contents to the simple name of the unit, i.e. not capitalized, not with spaces replaced by underscore, just regular ol unit name (like Horse Archer). This will mean that in game this unit will use that name. This is however only a temporary solution (for testing purposes), because to do this properly you should change this to a reference to the multi-lingual name of the unit in a different file. Thats where sovarns tutorial comes in handy as it explains this in more detail.
Scroll down until you find the <EarlyArtDefineTag> tag. Change the contents of that tag to something else. Again, like with type and class its usually ART_DEF_UNIT_[capitalized unit name].
At this point you can of course also modify any of the units properties, and again more info on that in sovarns tutorial.
Step 4
Open the UnitClassInfos file. Make a copy of any unit class entry, i.e. everything in between and including the <UnitClassInfo> and </UnitClassInfo> tags. In the new class info entry change the type to the class (UNITCLASS_) that you gave the new unit (in the UnitInfos files). Change the default unit, i.e. <DefaultUnit> tag contents, to the type (UNIT_) that you gave the new unit.
Step 5
Open the FormationInfos file. In it you will find a bunch of formations between the <UnitFormation> tags, it would take a whole nother tutorial to cover this file (seZ? wink, wink, nudge, nudge ), but for now to make the new unit use formations, simply add its type to any list where the unit which closely resembles it is found.
Step 6 - Last and most important step
Open the ArtDefines_Unit file. Once again, make a copy of the art entry (between and including <UnitArtInfo> and </UnitArtInfo> tags) of a unit that closely resembles the new one.
Change the type of the art define to match the one you used in the EarlyArtDefineTag in UnitInfos file.
Change both <NIF> and <SHADERNIF> so that they point to the location of the new units NIF files. If the unit (as it comes in the zip) has an _fx version of the file then the SHADERNIF tag should point to that. If not then the SHADERNIF tag should point to the same file as the NIF tag.
And now this is where there is a difference between what to do based on the type of unit youre dealing with.
If the unit uses vanilla animations then you need to change the KFM tag to point to the location of the original vanilla animation KFM file. That is to say if the unit should be using warrior animations for example, the KFM tag should point to Art/Units/Warrior/Warrior.kfm.
To put it another way the new units KFM tag should be identical to the KFM tag of the vanilla unit whos animations its using.
As to which animations the unit should use either the creator gives that information in the thread (or readme file), or it is assumed to be obvious. For example, some new units may use vanilla units file names (some of my units use warrior.nif and warrior_fx.nif files), in which case the creator might not specifically state which animations the unit should use, as it is assumed that it should use the same animations as its vanilla namesake.
If the unit uses new animations (which could be completely new or modified existing ones) then the creator would have provided the necessary animation files with the unit, and so the KFM tag should point to the KFM file that came with the unit.
You can now run the game (with the mod loaded) and use the new unit.
Conclusion
That's it. If you follow these steps you should be able to add new units to civ4 without trouble.
I hope this was helpful. Please feel free to ask me anything (even if it has to do with the wider general topic of adding units, like in sovarns tutorial ).
And if you still find sections of this tutorial not detailed or clear enough, let me know and I will try to fix that.
Disclaimer
By newly created I mean units that use new NIF files.
This tutorial is more like a step-by-step guide really, and it doesnt cover units that have only been reskinned. It also doesnt cover more XML than is necessary to accomplish this. If you want to know more about that you should read sovarns excellent guide to adding new units. In fact, it is recommended to read it before you read this tutorial, as you will understand much better the steps described here.
There are also no instructions on how to add/use new buttons for these units, theres a whole thread on that I believe.
There are two kinds of units of concern here one is units that use vanilla animations and the other is, units that use new (either completely new, or slightly modified vanilla) animations. The steps for adding them differ only slightly, in fact only one step is partially different for them. However, difference is important and I will explain it when we get to that step.
If you only have trouble with the art defines then skip to the last step.
Step 1
Once you downloaded the unit, unzip it into your mods unit directory, that would be Mods\[mod name]\Assets\Art\Units. Dont forget to create a folder for the unit if needed. (If youre putting it in Custome Assets then obviously the path is just CustomAssets\Art\Units.)
In most cases the creator of a unit will provide all the files needed to make it work unless otherwise stated. If the unit uses vanilla animations then there probably wont be any animation files (KF and KFM) with the unit, and that is because they are not needed.
This is important - do not add any other files to the units folder, in 99% of the cases you do not need them and they might mess things up.
The most common mistake people make is when they download a unit that doesnt have animation files and then add those files to its folder. That is not necessary and in fact, sometimes can mess things up (I dont know why but it just does).
Step 2
If you havent already, then create a folder called XML in your mods assets directory. In it create two additional folders Units and Art.
Go to these folders in the main civ4 directory and copy the following files from them CIV4FormationInfos.xml, CIV4UnitClassInfos.xml and CIV4UnitInfos.xml from the Units folder, and CIV4ArtDefines_Unit.xml from the Art folder. Place them in the corresponding new folders you just created.
Step 3
Open the UnitInfos file (Ill be dropping the CIV4 and .xml parts from file names for brevity). Make a copy of any unit entry. By unit entry I mean everything between the <UnitInfo> and </UnitInfo> tags, including them. You can make a copy of any unit but its best to copy a unit that closely resembles then new unit youd like to add. Resembles in terms of properties (stats) not look.
Change the units class and type to something else, usually its just UNITCLASS_ (or UNIT_ for type) followed by a capitalized name of the unit.
A bit lower find the <Description> tag and change its contents to the simple name of the unit, i.e. not capitalized, not with spaces replaced by underscore, just regular ol unit name (like Horse Archer). This will mean that in game this unit will use that name. This is however only a temporary solution (for testing purposes), because to do this properly you should change this to a reference to the multi-lingual name of the unit in a different file. Thats where sovarns tutorial comes in handy as it explains this in more detail.
Scroll down until you find the <EarlyArtDefineTag> tag. Change the contents of that tag to something else. Again, like with type and class its usually ART_DEF_UNIT_[capitalized unit name].
At this point you can of course also modify any of the units properties, and again more info on that in sovarns tutorial.
Step 4
Open the UnitClassInfos file. Make a copy of any unit class entry, i.e. everything in between and including the <UnitClassInfo> and </UnitClassInfo> tags. In the new class info entry change the type to the class (UNITCLASS_) that you gave the new unit (in the UnitInfos files). Change the default unit, i.e. <DefaultUnit> tag contents, to the type (UNIT_) that you gave the new unit.
Step 5
Open the FormationInfos file. In it you will find a bunch of formations between the <UnitFormation> tags, it would take a whole nother tutorial to cover this file (seZ? wink, wink, nudge, nudge ), but for now to make the new unit use formations, simply add its type to any list where the unit which closely resembles it is found.
Step 6 - Last and most important step
Open the ArtDefines_Unit file. Once again, make a copy of the art entry (between and including <UnitArtInfo> and </UnitArtInfo> tags) of a unit that closely resembles the new one.
Change the type of the art define to match the one you used in the EarlyArtDefineTag in UnitInfos file.
Change both <NIF> and <SHADERNIF> so that they point to the location of the new units NIF files. If the unit (as it comes in the zip) has an _fx version of the file then the SHADERNIF tag should point to that. If not then the SHADERNIF tag should point to the same file as the NIF tag.
And now this is where there is a difference between what to do based on the type of unit youre dealing with.
If the unit uses vanilla animations then you need to change the KFM tag to point to the location of the original vanilla animation KFM file. That is to say if the unit should be using warrior animations for example, the KFM tag should point to Art/Units/Warrior/Warrior.kfm.
To put it another way the new units KFM tag should be identical to the KFM tag of the vanilla unit whos animations its using.
As to which animations the unit should use either the creator gives that information in the thread (or readme file), or it is assumed to be obvious. For example, some new units may use vanilla units file names (some of my units use warrior.nif and warrior_fx.nif files), in which case the creator might not specifically state which animations the unit should use, as it is assumed that it should use the same animations as its vanilla namesake.
If the unit uses new animations (which could be completely new or modified existing ones) then the creator would have provided the necessary animation files with the unit, and so the KFM tag should point to the KFM file that came with the unit.
You can now run the game (with the mod loaded) and use the new unit.
Conclusion
That's it. If you follow these steps you should be able to add new units to civ4 without trouble.
I hope this was helpful. Please feel free to ask me anything (even if it has to do with the wider general topic of adding units, like in sovarns tutorial ).
And if you still find sections of this tutorial not detailed or clear enough, let me know and I will try to fix that.