Changes between Version 1 and Version 2 of CreatingNewUnits


Ignore:
Timestamp:
May 1, 2014, 11:25:41 AM (10 years ago)
Author:
Niek
Comment:

Final

Legend:

Unmodified
Added
Removed
Modified
  • CreatingNewUnits

    v1 v2  
    11'''Introduction'''[[BR]]
    2 
    32This tutorial covers the workflow of adding and editing units. You will learn how to create
    4 templates and link them at the correct way. In the end you will have a fully featured axeman.[[BR]]
    5 
    6 
     3templates and link them at the correct way. In the end you will have a fully featured axeman. 
     4[[BR]]
     5[[Image(http://i.imgur.com/fKKBq0d.png)]][[BR]]
    76
    87'''Table of contents'''[[BR]]
     
    1413[[BR]]
    1514
    16 
    1715'''First start'''[[BR]]
    18 
    1916If you haven't done already, download the game and install it in any directory you like or obtain the
    2017source code using TortoiseSVN: <http://trac.wildfiregames.com/wiki/TortoiseSVN_Guide>. I'm
     
    2623will find all the data and gameplay scripts related to the main game of 0 A.D.
    2724The 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.
    28 Do so by creating a shortcut targeting pyrogenesis.exe located in <\binaries\system>.
    29 
     25Do so by creating a shortcut targeting pyrogenesis.exe located in <\binaries\system>.[[BR]]
     26
     27[[Image(http://i.imgur.com/jUKk6Tl.png)]]
    3028
    3129Add “-mod=testmod” to the target and press OK.
    3230Go back to the mods directory and create a folder called <testmod>.
    33 You will notice a few additional maps in my folder, ignore them.
    34 
     31You will notice a few additional maps in my folder, ignore them.[[BR]]
     32
     33[[Image(http://i.imgur.com/j8P9lA9.png)]]
    3534
    3635Create the following map structure like you see in the public mod:[[BR]]
     
    4544Well done! You now have the ability to launch your mod and know the map structure needed for
    4645editing stats – including auras – and visuals.
     46
     47
     48You might want to use this image to keep overview:[[BR]]
     49
     50[[Image(http://i.imgur.com/hnASqn2.png)]]
     51[[BR]]
     52[[BR]]
     53
     54'''Setting up a template'''[[BR]]
     55Good. Now let's head over to the template. In <simulation\templates\units>, create a file called
     56“gaul_champion_axeman.xml” and open it in a text editor of your choice. Finally paste the
     57following code in it:
     58{{{
     59#!div style="font-size: 80%"
     60Code highlighting:
     61  {{{#!xml
     62  <?xml version="1.0" encoding="utf-8"?>
     63  <Entity parent="template_unit_champion_infantry_swordsman">
     64    <Cost>
     65      <Resources>
     66        <metal>75</metal>
     67      </Resources>
     68    </Cost>
     69    <Attack>
     70      <Melee>
     71        <Hack>20.0</Hack>
     72        <Pierce>0.0</Pierce>
     73        <Crush>0.0</Crush>
     74      </Melee>
     75      <Charge>
     76        <Hack>30.0</Hack>
     77        <Pierce>0.0</Pierce>
     78        <Crush>0.0</Crush>
     79      </Charge>
     80    </Attack>
     81    <Identity>
     82      <Civ>gaul</Civ>
     83      <GenericName>Heavy Infantry</GenericName>
     84      <SpecificName>Gaul Axeman</SpecificName>
     85      <History>?</History>
     86      <Icon>units/celt_champion_infantry_gaul.png</Icon>
     87      <RequiredTechnology>unlock_champion_units</RequiredTechnology>
     88      <SelectionGroupName>units/gaul_champion_axeman</SelectionGroupName>
     89    </Identity>
     90    <UnitMotion>
     91      <WalkSpeed>7.0</WalkSpeed>
     92      <Run>
     93        <Speed>21.0</Speed>
     94      </Run>
     95    </UnitMotion>
     96    <VisualActor>
     97      <Actor>units/gaul/champion_axeman.xml</Actor>
     98    </VisualActor>
     99  </Entity>
     100  }}}
     101}}}
     102
     103Let me explain the most important tags to you.[[BR]]
     104
     105At the second line you see something saying about a parent xml file. Everything about templates in
     1060 A.D. Is working with parents and children. That is why we do not need to have every single tag in
     107our file: it only overrides what is in the parent file.
     108
     109
     110In the <Cost> tag the training costs are defined, we did set the metal costs to 75. The other costs
     111are defined in the parent file.
     112
     113
     114In <Identity> all info about the unit is explained. You might notice that we called the unit “Gaul
     115Axeman” and that we are requiring a technology to be researched before the Axeman gets
     116trainable.
     117
     118
     119Lastly we see the <VisualActor>. This is a link to an actor file in which the visuals are defined. In the
     120template we just created, all the rest is defined.[[BR]]
     121[[BR]]
     122
     123'''Setting up an actor'''[[BR]]
     124Now, let's go to <\art\actors\units\gaul> and create the actor file we defined above.
     125Paste this code into the file:
     126
     127{{{
     128#!div style="font-size: 80%"
     129Code highlighting:
     130  {{{#!xml
     131  <?xml version="1.0" encoding="utf-8"?>
     132  <actor version="1">
     133  <castshadow/>
     134  <group>
     135    <variant frequency="1" name="Base">
     136    <animations>
     137      <animation file="biped/inf_sword_ready_e.dae" name="Idle" speed="100"/>
     138      <animation file="biped/inf_sword_ready_e.dae" name="Idle" speed="90"/>
     139      <animation file="biped/inf_sword_ready_e.dae" name="Idle" speed="85"/>
     140      <animation file="biped/inf_sword_ready_e.dae" name="Idle" speed="75"/>
     141      <animation file="biped/inf_sword_ready_e.dae" name="Idle" speed="110"/>
     142      <animation file="biped/dudewalk_swordshield.psa" name="Walk" speed="110"/>
     143      <animation file="infantry/sword/move/run/isw_s_off_01.psa" name="Run" speed="8"/>
     144      <animation file="infantry/sword/move/run/isw_s_em_03.psa" name="Run" speed="8"/>
     145      <animation event="0.5" file="biped/inf_2_hand_sword_attack_b.dae" name="attack_melee" speed="150"/>
     146      <animation file="infantry/general/death/inf_01.psa" name="Death" speed="200"/>
     147      <animation file="infantry/general/death/inf_02.psa" name="Death" speed="400"/>
     148      <animation file="infantry/general/death/inf_03.psa" name="Death" speed="200"/>
     149    </animations>
     150    <mesh>skeletal/m_pants_tunic.dae</mesh>
     151    <props>
     152      <prop actor="props/units/heads/celt_helmet_b.xml" attachpoint="helmet"/>
     153      <prop actor="props/units/heads/head_celt.xml" attachpoint="head"/>
     154      <prop actor="props/units/shields/celt_round_b.xml" attachpoint="shield"/>
     155      <prop actor="props/units/weapons/axe_single.xml" attachpoint="r_hand"/>
     156    </props>
     157    </variant>
     158  </group>
     159  <group>
     160    <variant frequency="1" name="chainmail-1">
     161      <textures><texture file="skeletal/celt_su3_soldurii_1.dds" name="baseTex"/></textures>
     162    </variant>
     163    <variant frequency="1" name="chainmail-2">
     164      <textures><texture file="skeletal/celt_su3_soldurii_2.dds" name="baseTex"/></textures>
     165    </variant>
     166    <variant frequency="1" name="chainmail-3">
     167      <textures><texture file="skeletal/celt_su3_soldurii_3.dds" name="baseTex"/></textures>
     168    </variant>
     169  </group>
     170  <material>player_trans.xml</material>
     171  </actor>
     172  }}}
     173}}}
     174
     175Above you see the animations, the props and the textures defined. With props you should think of
     176small stuff like shields, helmets and weapons (in case of unit props).[[BR]]
     177[[BR]]
     178
     179'''Make the unit trainable''' [[BR]]
     180So far, so good. We now have the stats ánd the visuals. Now let's think of a location to train the
     181unit. I'm choosing the barracks. Therefore I need to copy the “gaul_barracks.xml” from
     182<simulation\templates\structures> and copy it in the right folder in our own testmod.
     183
     184Edit the file by adding “units/gaul_champion_axeman” (this is your template file) to
     185<ProductionQueue>.[[BR]]
     186
     187[[Image(http://i.imgur.com/qE7NIOP.png)]]
     188[[BR]]
     189[[BR]]
     190
     191'''Result'''[[BR]]
     192Well done, you made it to complete the tutorial! Run the game using your shortcut. The result
     193should be like below. If it gives some errors than likely you made some spelling errors. Go back and
     194fix them accordingly to the errors. You might not like everything, but don't hesitate to change
     195things to your own flavor.[[BR]]
     196
     197[[Image(http://i.imgur.com/W5TtIAL.png)]]
     198
     199Well done, you made it to create your own soldier! Since you have come this far, you have learned
     200the basics from template modding and reusing existing art. You should even be capable of creating
     201your own civilization now (from the template's point of view)!