Skip to content
László Major edited this page May 5, 2014 · 8 revisions

Unit templates define the classnames of units spawned by zones. It uses ArmA's class system, acting as a key/value store, that supports inheritance. To be able to use it, you must include admiral\unit_templates.h file in your mission's description.ext file. To do this, Just copy #include admiral\unit_templates.h line into the description.ext file.

##Template Example

An example admiral\unit_templates.h file could look like this:

#include "admiral_defines.h"

class Admiral
  class UnitTemplates {
    class Base {
        side = SIDE_WEST;
        infantry[] = {"Cow02", "Cow03", "Cow04", "Fin", "Goat", "Cock", "Pastor", "Rabbit", "Sheep", "WildBoar"};
        crewmen[] = {"Cow02", "Cow03", "Cow04", "Fin", "Goat", "Cock", "Pastor", "Rabbit", "Sheep", "WildBoar"};
        technicals[] = {"Ikarus"};
        armour[] = {"Ikarus"};
    };

    class RU_Woodland : Base {
        side=SIDE_EAST;
        infantry[] = {"RU_Soldier", "RU_Soldier", "RU_Soldier", "RU_Soldier", "RU_Soldier", "RU_Soldier", "RU_Soldier_GL", "RU_Soldier_GL", "RU_Soldier_MG", "RU_Soldier_AR", "RU_Soldier_AR", "RU_Soldier_AR", "RU_Soldier_LAT"};
        crewmen[] = {"RU_Soldier_Crew"};
        technicals[] = {"ACE_UAZ_MG_RU"};
        armour[] = {"ACE_T72B_Base"};
    };

    class RU_Desert : RU_Woodland {
        infantry[] = {"ACE_RU_Soldier_D", "ACE_RU_Soldier_D", "ACE_RU_Soldier_D", "ACE_RU_Soldier_D", "ACE_RU_Soldier_D", "ACE_RU_Soldier_D", "ACE_RU_Soldier_GL_D", "ACE_RU_Soldier_GL_D", "ACE_RU_Soldier_MG_D", "ACE_RU_Soldier_AR_D", "ACE_RU_Soldier_AR_D", "ACE_RU_Soldier_AR_D", "ACE_RU_Soldier_LAT_D"};
        crewmen[] = {"ACE_RU_Soldier_Crew_D"};
    };

    class RU_Winter : RU_Woodland {
        infantry[] = {"RW_RU_Soldier", "RW_RU_Soldier", "RW_RU_Soldier", "RW_RU_Soldier", "RW_RU_Soldier", "RW_RU_Soldier", "RW_RU_Soldier_GL", "RW_RU_Soldier_GL", "RW_RU_Soldier_MG", "RW_RU_Soldier_AR", "RW_RU_Soldier_AR", "RW_RU_Soldier_AR", "RW_RU_Soldier_LAT"};
        crewmen[] = {"RW_RU_Soldier_Crew"};
        armour[] = {"RW_T72_RU"};
    };
  };
};

##Template Explanation

You must put all your templates in the UnitTemplates class. Template classnames are case-sensitive! To create a new template you must add the following fields to the class:

  • side: This determines, which side the groups will be in. Values can be SIDE_EAST, SIDE_WEST, SIDE_IND, SIDE_CIV.
  • infantry: This is an array of infantry classnames. These are the units that will be spawned in infantry groups with Patrol and Camp zones and inside buildings with CQC zones. To increase the spawning chance of a classname, simply add it more, than once.
  • crewmen: This is an array of crewman classnames. These are the units that will be spawned in armour groups with Patrol and Camp zones. To increase the spawning chance of a classname, simply add it more, than once.
  • technicals: This is an array of technical classnames. These are the units that will be spawned as the vehicle of a technical group with Patrol and Camp zones. To increase the spawning chance of a classname, simply add it more, than once.
  • armour: This is an array of armour classnames. These are the units that will be spawned as the vehicle of a armour group with Patrol and Camp zones. To increase the spawning chance of a classname, simply add it more, than once.

As for the syntax, you must always end the class and it's field with a ;. Array fields have [] at the end of their fieldname , and the elements are between {}. Elements must be separated by ,, but the last element must not be followed by one.

##Inheritance

One of the nice features of using class definitions is that a class can inherit their parent's fields.

class RU_Woodland : Base {
};

This is the syntax for inheriting. When you define a class after the name, you put a : and the name of the parent class. In this example RU_Woodland inherits the fields of the parent class Base.

In this example we have basic Woodland and Desert templates for the Russian faction.

class Base {
    side = SIDE_WEST;
    infantry[] = {"Cow02", "Cow03", "Cow04", "Fin", "Goat", "Cock", "Pastor", "Rabbit", "Sheep", "WildBoar"};
    crewmen[] = {"Cow02", "Cow03", "Cow04", "Fin", "Goat", "Cock", "Pastor", "Rabbit", "Sheep", "WildBoar"};
    technicals[] = {"Ikarus"};
    armour[] = {"Ikarus"};
};

class RU_Woodland : Base {
    side=SIDE_EAST;
    infantry[] = {"RU_Soldier", "RU_Soldier", "RU_Soldier", "RU_Soldier", "RU_Soldier", "RU_Soldier", "RU_Soldier_GL", "RU_Soldier_GL", "RU_Soldier_MG", "RU_Soldier_AR", "RU_Soldier_AR", "RU_Soldier_AR", "RU_Soldier_LAT"};
    crewmen[] = {"RU_Soldier_Crew"};
    technicals[] = {"ACE_UAZ_MG_RU"};
    armour[] = {"ACE_T72B_Base"};
};

As you can see the RU_Woodland class inherits from the Base class. Since we don't want to use any of the fields from Base, we overwrite them by simply redefining them.

class RU_Desert : RU_Woodland {
    infantry[] = {"ACE_RU_Soldier_D", "ACE_RU_Soldier_D", "ACE_RU_Soldier_D", "ACE_RU_Soldier_D", "ACE_RU_Soldier_D", "ACE_RU_Soldier_D", "ACE_RU_Soldier_GL_D", "ACE_RU_Soldier_GL_D", "ACE_RU_Soldier_MG_D", "ACE_RU_Soldier_AR_D", "ACE_RU_Soldier_AR_D", "ACE_RU_Soldier_AR_D", "ACE_RU_Soldier_LAT_D"};
    crewmen[] = {"ACE_RU_Soldier_Crew_D"};
};

Now for class RU_Desert, we inherit from RU_Woodland class. Since we are using the same side (SIDE_EAST), we can ommit the side field. We don't want to use the inherited woodland infantry[] and crewmen[] class names, so we overwrite those fields by redefining them. Now for technicals[] and armour[], we want to use the same class names, so we ommit the fields as we did with side[].

##Ingame usage By default the zones are using the template defined by adm_cqc_defaultUnitTemplate , adm_patrol_defaultUnitTemplate and adm_camp_defaultUnitTemplate setting variables in settings.sqf.

adm_cqc_defaultUnitTemplate  = "Base";
adm_patrol_defaultUnitTemplate  = "Base";
adm_camp_defaultUnitTemplate  = "Base";

To force a zone to use a given template, you must add a config entry ["unitTemplate", "<template class name>"], to the zone's init configuration.

Examples:

  • CQC zone: Using template RU_Woodland [thisTrigger, [["pool", 20], ["unitTemplate", "RU_Woodland"]]] call adm_api_fnc_initZone;
  • Camp zone: Using template RU_Desert [thisTrigger, [["type", "periodic"],["pool", [10,3,2]],["wave", [2,1,1]],["campDelay", 60], ["groupDelay", [60,60,60]], ["unitTemplate", "RU_Desert"]]] call adm_api_fnc_initZone;
  • Patrol zone: Using default template defined with adm_patrol_defaultUnitTemplate variable [thisTrigger, [["pool",[6,2,1]]]] call adm_api_fnc_initZone;
Clone this wiki locally