Adding a new unit

Hunter

Civ Addict
Joined
Aug 12, 2002
Messages
833
Location
Feeding my addiction.
Ok here it is and not all of it yet which I hope some of you can help with.

Adding a unit :hammer:

First off I created a folder in the Mods folder to store my added units and placed in it this structure:
Mods\My CIV\Assets\XML\Art\CIV4ArtDefines_Unit.xml
Mods\My CIV\Assets\XML\Units\CIV4UnitInfos.xml
Mods\My CIV\Assets\XML\Text\CIV4GameText_Civilopedia_Units.xml

The three listed files are all I could find that needed to be used unless you want to create a new unit class then you need Firaxis Games\Sid Meier's Civilization 4\Assets\XML\Units\CIV4UnitClassInfos.xml.


CIV4ArtDefines_Unit.xml
To begin I edited my new CIV4ArtDefines_Unit.xml file by copying a similar chunk of code (in this case the Tank). Then changed the file names accordingly and found the location of the “shadows” file in Firaxis Games\Sid Meier's Civilization 4\Assets\Art\Units\01_unitshadows.

Example code: (only what was changed in listed)
Origonal
<UnitArtInfo>
<Type>ART_DEF_UNIT_TANK</Type>
<fScale>0.48</fScale>
<fInterfaceScale>0.9</fInterfaceScale>
<NIF>Art/Units/Tank/Tank.nif</NIF>
<KFM>Art/Units/Tank/Tank.kfm</KFM>
<SHADERNIF>Art/Units/Tank/Tank_FX.nif</SHADERNIF>
<ShadowDef>
<ShadowNIF>Art/Units/01_UnitShadows/TankShadow.nif</ShadowNIF>

Became

<UnitArtInfo>
<Type>ART_DEF_UNIT_mark_v_tank</Type>
<fScale>0.48</fScale>
<fInterfaceScale>0.9</fInterfaceScale>
<NIF>Art/Units/scenario/mark_v_tank/markvtank.nif</NIF>
<KFM>Art/Units/scenario/mark_v_tank/markvtank.kfm</KFM>
<SHADERNIF>Art/Units/scenario/mark_v_tank/markvtank_fx.nif</SHADERNIF>
<ShadowDef>
<ShadowNIF>Art/Units/01_UnitShadows/markvtankshadow.nif</ShadowNIF>

CIV4UnitInfos.xml
Following that I edited CIV4UnitInfos.xml, which was no picnic but it is impressive to see the available options located there. Again I changed all appropriate names except in the sounds area as I used stock sounds, which will most likely be the case for all units until new sounds and 3d models are made.

Important code to look for: (in relative order)

<Class>UNITCLASS_Tank</Class>
<Type>UNIT_mark_v_tank</Type>
<Combat>UNITCOMBAT_GUN</Combat><Domain>DOMAIN_LAND</Domain>
<DefaultUnitAI>UNITAI_ATTACK</DefaultUnitAI>
<Description>TXT_KEY_UNIT_mark_v_tank </Description>
<UnitClassUpgrades>
<UnitClassUpgrade>
<UnitClassUpgradeType>UNITCLASS_MODERN_ARMOR</UnitClassUpgradeType>
<bUnitClassUpgrade>1</bUnitClassUpgrade>
</UnitClassUpgrade>
<PrereqTech>TECH_INDUSTRIALISM</PrereqTech>
<TechTypes>
<PrereqTech>TECH_RIFLING</PrereqTech>
</TechTypes>
<BonusType>BONUS_OIL</BonusType>
<iCost>12</iCost>
<iCombat>13</iCombat>
<iMoves>2</iMoves>

There are several code snipits that have great potential such as <PrereqReligion>NONE</PrereqReligion> or <PrereqBuilding>NONE</PrereqBuilding> but this first example is just for simple unit addition little more. Very soon I hope to add the Crusader and use both aforementioned snipits. As for the upgrading the Mark V to the tank I would need to create a new unit class and to be honest it didn't work but when I figure it out I will post it here.

CIV4GameText_Civilopedia_Units.xml
Finally I created a Civlopedia entry in my CIV4GameText_Civilopedia_Units.xml file. Here again I copied code from a similar unit and changed it accordingly:

<TEXT>
<Tag>TXT_KEY_UNIT_TANK_PEDIA</Tag>
<English>[TAB] Tanks are powerful weapon against any ground unit.</English>
</TEXT>

I am still unsure of the settings needed to say what Civ can and cannot build these new units however I will know soon enough.

And so there you have it a new unit.
If this helps you in your Mods then Im pleased
 
I was just gonna make a post describing what you did.

As far as making the unit a UU:

I made an F16 for the americans:

In assets\XML\civilizations\civ4civilizationinfos.xml add:

Code:
<Units>
	<Unit>
	<UnitClassType>UNITCLASS_MARINE</UnitClassType>
	<UnitType>UNIT_AMERICAN_NAVY_SEAL</UnitType>
	</Unit>
	<Unit>
             <UnitClassType>UNITCLASS_JET_FIGHTER</UnitClassType>
	<UnitType>UNIT_AMERICAN_F16</UnitType>
	</Unit>
</Units>

Where my F16 would be your UNIT_mark_v_tank

There is one step you left out though. In assets\XML\Text there is a civ4gametextinfos_objects.xml You need to add your unit info there also. The key definations to be used are generated from the original key descriptions tags from the civ4units file. IF you dont do this, your unit will show up as UNIT_mark_v_tank instead of Mark V in game.

This will make it a unique unit. I've been testing and my American civ has been the only civ to build and use my F16.
 
Back
Top Bottom