PART 2 - Writing in your new unit
Now you are ready to mod .xml. You can use notepad or some other program which highlights stuff for you. I use Dreamweaver.
a) Open
CIV4UnitInfos.xml
It's a very big file but copy one whole class section. i.e. between and including :
Code:
<UnitInfo>
....
</UnitInfo>
Then paste it after a </UnitInfo>. You have now esentially created a duplicate of a unit.
So now we need to edit it. I will only tell you the essential elements to change, the rest you can fiddle round with and you can figure out what the do by checking out the other units.
Below is a list of things to change.
<Class>UNITCLASS_WARRIOR</Class>
<Type>UNIT_WARRIOR</Type>
...
<Description>TXT_KEY_UNIT_WARRIOR</Description>
<Civilopedia>TXT_KEY_UNIT_WARRIOR_PEDIA</Civilopedia>
<Strategy>TXT_KEY_UNIT_WARRIOR_STRATEGY</Strategy>
to
<Class>UNITCLASS_TERRY</Class>
<Type>UNIT_TERRY</Type>
...
<Description>TXT_KEY_UNIT_TERRY</Description>
<Civilopedia>TXT_KEY_UNIT_TERRY_PEDIA</Civilopedia>
<Strategy>TXT_KEY_UNIT_TERRY_STRATEGY</Strategy>
Notice all i do is change all WARRIOR references to TERRY. If you want you can just type in the words you want bewtween the <Description><Civilopedia><Strategy> but then it won't translate. This will save you from editting the text files though.
Near the bottom of the UnitInfo class you will see this:
Code:
<UnitMeshGroups>
<iGroupSize>3</iGroupSize>
<fMaxSpeed>1.75</fMaxSpeed>
<iMeleeWaveSize>3</iMeleeWaveSize>
<iRangedWaveSize>0</iRangedWaveSize>
<UnitMeshGroup>
<iRequired>8</iRequired>
<EarlyArtDefineTag>ART_DEF_UNIT_WARRIOR</EarlyArtDefineTag>
</UnitMeshGroup>
</UnitMeshGroups>
<Button>,Art/Interface/Buttons/Units/Warrior.dds,Art/Interface/Buttons/Unit_Resource_Atlas.dds,2,1</Button>
Again change the WARRIOR ref to TERRY so it should look like this.
Code:
<UnitMeshGroups>
<iGroupSize>3</iGroupSize>
<fMaxSpeed>1.75</fMaxSpeed>
<iMeleeWaveSize>3</iMeleeWaveSize>
<iRangedWaveSize>0</iRangedWaveSize>
<UnitMeshGroup>
<iRequired>8</iRequired>
<EarlyArtDefineTag>ART_DEF_UNIT_TERRY</EarlyArtDefineTag>
</UnitMeshGroup>
</UnitMeshGroups>
<Button>Art/Interface/Buttons/Units/Terry.dds</Button>
Notice that I removed the atlas picture in the mod. It will still work fine without it and is just easier to edit one file.
There is so much more that you can do, but i am just covering the basics.
b) Open
Civ4UnitClassInfos.xml
Again copy a whole UnitClassInfo and paste it in at the end but before the
</UnitClassInfos></Civ4UnitClassInfos>. It should look like this
Code:
<UnitClassInfo>
<Type>UNITCLASS_TERRY</Type>
<Description>TXT_KEY_UNIT_TERRY</Description>
<iMaxGlobalInstances>-1</iMaxGlobalInstances>
<iMaxTeamInstances>-1</iMaxTeamInstances>
<iMaxPlayerInstances>-1</iMaxPlayerInstances>
<DefaultUnit>UNIT_TERRY</DefaultUnit>
</UnitClassInfo>
c) Edit all the TEXT files.
This is pretty straight forward. Again copy the class and paste a new one, remembering to rename the KEYs corrrectly.
d) Open the
CIV4ArtDefines_Units.xml
Like before create a new <UnitArtInfo> and edit it. It should look like this:
Code:
<UnitArtInfo>
<Type>ART_DEF_UNIT_TERRY</Type>
<fScale>0.61</fScale>
<fInterfaceScale>1.3</fInterfaceScale>
<NIF>Art/Units/Terry/Warrior.nif</NIF>
<KFM>Art/Units/Terry/Warrior.kfm</KFM>
<SHADERNIF>Art/Units/Terry/Warrior_FX.nif</SHADERNIF>
<ShadowDef>
<ShadowNIF>Art/Units/01_UnitShadows/LionShadow.nif</ShadowNIF>
<ShadowAttachNode>LionBip Spine1</ShadowAttachNode>
<fShadowScale>1.0</fShadowScale>
</ShadowDef>
<fBattleDistance>0.35</fBattleDistance>
<fRangedDeathTime>0.28</fRangedDeathTime>
<bActAsRanged>0</bActAsRanged>
<TrainSound>AS2D_UNIT_BUILD_UNIT</TrainSound>
<AudioRunSounds>
<AudioRunTypeLoop/>
<AudioRunTypeEnd/>
</AudioRunSounds>
</UnitArtInfo>
Notce that all we do is change the folder reference to TERRY but keep the warrior file names. This is why you must not rename files as the .dds skin is not referenced here but in the .nif file. Everything has to be the same and original name so all the .kf s will work properly.
TADA: now your unit will be avaliable to play with its new graphics/stats. But we still have something missing. The buttons!!