[[TOC]]
This tutorial covers the workflow of adding and editing units. You will learn how to create
templates and link them at the correct way. In the end you will have a fully featured axeman.
[[BR]]
[[Image(http://i.imgur.com/fKKBq0d.png)]][[BR]]
== First start[[BR]]
If you haven't done already, download the game and install it in any directory you like or obtain the
source code using TortoiseSVN: [wiki:TortoiseSVN_Guide TortoiseSVN Guide]. I'm
using the SVN version in this tutorial.
Navigate to the directory of the game, in my case: ''D:\0_A.D._source''. Then go to
[source:/ps/trunk/binaries/data/mods binaries/data/mods]. Here you will find a few folders, one of them is [source:/ps/trunk/binaries/data/mods/public public]. In this folder you
will find all the data and gameplay scripts related to the main game of 0 A.D.
The game works with the so called mod folders. Everything you put in there will override the main game's data, the only requirement is that you load them.
Do so by creating a shortcut targeting pyrogenesis.exe located in [source:/ps/trunk/binaries/system binaries/system].[[BR]]
[[Image(http://i.imgur.com/jUKk6Tl.png)]]
Add “-mod=testmod” to the target and press OK.
Go back to the mods directory and create a folder called '''testmod'''.
You will notice a few additional maps in my folder, ignore them.[[BR]]
[[Image(http://i.imgur.com/j8P9lA9.png)]]
Create the following map structure like you see in the [source:/ps/trunk/binaries/data/mods/public/ public mod]:[[BR]]
* [source:/ps/trunk/binaries/data/mods/public/simulation/templates/units simulation/templates/units][[BR]]
* [source:/ps/trunk/binaries/data/mods/public/simulation/templates/structures simulation/templates/structures][[BR]]
* [source:/ps/trunk/binaries/data/mods/public/art/actors/units/gaul art/actors/units/gaul][[BR]]
To save time and effort we will use already existing meshes, textures and animations (we therefore
do not create those maps), and do not write our template from scratch.
Well done! You now have the ability to launch your mod and know the map structure needed for
editing stats – including auras – and visuals.
You might want to use this image to keep overview:[[BR]]
[[Image(http://i.imgur.com/hnASqn2.png)]]
[[BR]]
[[BR]]
== Setting up a template[[BR]]
Good. Now let's head over to the template. In [source:/ps/trunk/binaries/data/mods/public/simulation/templates/units simulation/templates/units], create a file called
“gaul_champion_axeman.xml” and open it in a text editor of your choice. Finally paste the
following code in it:
{{{
#!div style="font-size: 80%"
Code highlighting:
{{{#!xml
75
20.0
0.0
0.0
30.0
0.0
0.0
gaul
Heavy Infantry
Gaul Axeman
?
units/celt_champion_infantry_gaul.png
unlock_champion_units
units/gaul_champion_axeman
7.0
21.0
units/gaul/champion_axeman.xml
}}}
}}}
Let me explain the most important tags to you.[[BR]]
At the second line you see something saying about a parent xml file. Everything about templates in
0 A.D. Is working with parents and children. That is why we do not need to have every single tag in
our file: it only overrides what is in the parent file.
In the '''' tag the training costs are defined, we did set the metal costs to 75. The other costs
are defined in the parent file.
In '''' all info about the unit is explained. You might notice that we called the unit “Gaul
Axeman” and that we are requiring a technology to be researched before the Axeman gets
trainable.
Lastly we see the ''''. This is a link to an [wiki:Actors actor] file in which the visuals are defined. In the
template we just created, all the rest is defined.[[BR]]
[[BR]]
== Setting up an [wiki:Actors actor][[BR]]
Now, let's go to [source:/ps/trunk/binaries/data/mods/public/art/actors/units/gaul art/actors/units/gaul] and create the actor file we defined above.
Paste this code into the file:
{{{
#!div style="font-size: 80%"
Code highlighting:
{{{#!xml
skeletal/m_pants_tunic.dae
player_trans.xml
}}}
}}}
Above you see the animations, the props and the textures defined. With props you should think of
small stuff like shields, helmets and weapons (in case of unit props).[[BR]]
[[BR]]
== Make the unit trainable[[BR]]
So far, so good. We now have the stats ánd the visuals. Now let's think of a location to train the
unit. I'm choosing the barracks. Therefore I need to copy the “gaul_barracks.xml” from
[source:/ps/trunk/binaries/data/mods/public/simulation/templates/structures simulation/templates/structures] and copy it in the right folder in our own testmod.
Edit the file by adding “units/gaul_champion_axeman” (this is your template file) to
''''.[[BR]]
[[Image(http://i.imgur.com/qE7NIOP.png)]]
[[BR]]
[[BR]]
== Result[[BR]]
Well done, you made it to complete the tutorial! Run the game using your shortcut. The result
should be like below. If it gives some errors than likely you made some spelling errors. Go back and
fix them accordingly to the errors. You might not like everything, but don't hesitate to change
things to your own flavor.[[BR]]
[[Image(http://i.imgur.com/W5TtIAL.png)]]
Well done, you made it to create your own soldier! Since you have come this far, you have learned
the basics from template modding and reusing existing art. You should even be capable of creating
your own civilization now (from the template's point of view)!