Modding: How to Create a New Unit

# Creating a new unit: Example with Conscripts
In this step by step process we will detail how to create a glorious Conscripts unit for the Imperial Guard. Tis is the one used in one of current mods. (link to be added later)

For that to work, you'll just need a text editor, such as Notepad++ or Sublime Text, and basic understanding of XML structure.

# Step One: Take a stable base
First you should locate a stable example. In this process we will use the Guardsman (Data\World\Units\AstraMilitarum\Guardsman.xml) as our example. Head to that folder.

# Step Two: Create the Unit and make it recruitable
Copy that file into a new one that you will name "Conscripts.xml".

To make that unit recruitable, locate Data\World\Buildings\AstraMilitarum\Infantry.xml and add one line under Guardsman, to look like this:

 

# Step Three: Address Core dependencies
At this point the game will crash on startup. You need to address text dependencies. Head to Data\Core\Languages\English folder and edit the Units.xml file there.

Add this content before the end of file:

  

# Step Four: Address Graphic dependencies
Now the hardest part. You need to address all video dependencies: this part includes the mesh, the animations, weapon animations and sprites.

Since the XML file currently uses the guardsman mesh and animations, normally you should only have to create the sprites so we'll cover that first. To do that search for "Guardsman" in Video\Textures and duplicate these files and rename these copies as Conscripts.

The two files you are looking for are both called "Guadsman.dds" and they are located in


 * 1) Data\Video\Textures\Icons\Overlay\Units\AstraMilitarum
 * 2) Data\Video\Textures\Icons\Units\AstraMilitarum

For instance in Data\Video\Textures\Icons\Units\AstraMilitarum you should copy Guardsman.dds into Conscripts.dds

Do the same for all occurrences.

# Step Five: Address More Graphic dependencies
Alternatively, you could also duplicate the mesh and animations, by searching for "Guardsman" in the whole "Data\Video" directory and following the same process.

That step should not be mandatory as only Data\Textures should be mandatory.

# Step Six: Address Sound dependencies
There is no current audio dependency because we are using Guardsman sounds. If you would like to add your own sounds, you should check Data\Audio.

First you could add your own sounds in Data\Audio\cached by searching for "Guardsman" and duplicating them. Secondly you have to look at Data\Audio\Mixer.xml and duplicate a few lines to make sure your new sounds are being used and do not crash the game.

# Step Seven: Testing and debugging!
At this point dependencies are all addressed. Yet there may still be crashes!

Make sure you did not forget anything.

If you tried to use your own mesh by editing the unit file created on step 2, redirect instead to the guardsman mesh.

In our tests using a custom mesh failed because of data inside the mesh you duplicated, which mentioned the Guardsman itself in its binary code.

It's safe however to use your own materials, but you have to use Guardsman mesh and animations.

# Step Eight: Let's make it better!
Now that we have a working Conscript we can make it better. As of now it's just a Guardsman.

You should use the guide for editing units, and adjust some values.


 * You should increase its size to 20 men in ranks of 5, 6 or 7.
 * You could increase the cost in Food; after all they are 20 men; and the consumption of food too, this should not be an endgame power unit but a way to soak up an attack.
 * You should also reduce the attributes of each soldier because they would be too strong. In our example we put Morale to 3, ranged accuracy and melee accuracy to 4, and armor to 3.
 * Also, for balance reasons, we also removed the Krak Grenade ability.

# The Final Conscripts
The final Conscripts.xml file content is here for you to enjoy.

           <meleeAccuracy set="4"/> <meleeAttacks set="1"/> <oreCost set="10.0"/> <meleeDamage set="1"/> <moraleMax set="3"/> <movementMax set="2"/> <productionCost set="24.0"/> <rangedAccuracy set="4"/> <strategyModifiers> <increaseInfantryScore set="1.0"/> </strategyModifiers> <action animation="Units/AstraMilitarum/ConscriptsAttack" beginFire="0.35" endFire="2.5"/> <action animation="Units/AstraMilitarum/ConscriptsDie" animationCount="3" sound="Units/MediumUnarmoredDie" soundCount="4"/> <action animation="Units/AstraMilitarum/ConscriptsMove" sound="Units/AstraMilitarum/InfantryMove" soundCount="4"/> <throwGrenade weaponSlotName="FragGrenade" cooldown="10" requiredUpgrade="AstraMilitarumExpanded/FragGrenade"> <action animation="Units/AstraMilitarum/ConscriptsGrenade" beginFire="0.833333333333"/> </throwGrenade> <mediPack cooldown="10" requiredUpgrade="AstraMilitarum/MediPack"> <action bone="ChestBone" sound="Actions/Heal"/> <selfTarget> <area affects="Unit"> <hitpointsFraction add="0.5"/> </selfTarget> </mediPack> <trait name="ExtraInfantryArmour" requiredUpgrade="AstraMilitarum/ExtraInfantryArmour"/> <trait name="VoxCaster" requiredUpgrade="AstraMilitarum/VoxCaster"/>

Back to Unit modding menu Back to Modding page