Tutorial: Configuration (Part 3)

Once you have your weapons configured the way you want them, you then need to actually create the soldiers you want. They are configured in the cfgVehicles section in your config.cpp. It is again considered good practice to include the definitions in their own folder.

Soldiers are configured with the following characteristics:

-Scope

-Side

-Faction

-Dlc

-author

-editorSubcategory

-displayName

-weapons

-respawnWeapons

-magazines

-respawnMagazines

-editorPreview

-model

-texture

- other less important things.

To create a unit, just like creating a weapon, you must inherit another class first. The most basic class, which has no model or texture or identity defined is "SoldierWB" however most custom gear is meant to be used with a specific model, so it is pretty common to simply inherit the base class from a soldier already using that addon. For example, here is a base class for my U.S. Army Desert group inheriting the class of the RHS U.S. Army Desert soldier, redefining certain characteristics:

class WWAF\_usarmy\_inf\_base: rhsusf\_infantry\_army\_base

{

scope = 0; // Can not be created by anyone

side = 1; // Blufor

faction = "WWAF\_usarmy\_d"; // U.S. Army desert faction

  dlc = "WWAF"; // Sets which mod it belongs to, name of class defined in cfgMods

  author = "Nightwolf"; // Author name

  editorSubcategory = "WWAF\_ed\_men"; // Editor Subcategory to be placed under

  displayName = "Rifleman"; // Name to be shown in the editor

  weapons[] = {"RH\_m4\_RIS\_M68\_PEQ15","Throw","Put"}; // Weapons to initially start with (See below)

  respawnWeapons[] = {"RH\_m4\_RIS\_M68\_PEQ15","Throw","Put"}; // Weapons to respawn with (see below)

  magazines[]=

{

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"rhs\_mag\_m67"

}; // Defines all weapon mags to be carried. Note that grenades are considered magazines

respawnMagazines[]=

{

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"RH\_30Rnd\_556x45\_M855A1",

"rhs\_mag\_m67"

}; // Magazines to respawn with

};

It makes life a lot easier to create a base class that defines most of the characteristics, and base every other class off of that, so you only need to redefine a few characteristics each time.

In the weapons[] section, the the weapons should be ordered as follows: {"PRIMARY","HANDGUN","LAUNCHER","THROW","PUT"}

Throw and put allow the soldier to throw grenades and put allows him to place explosives and mines etc.

There are some things not defined here that are also often used. As a second example, here is the Middle Eastern Insurgent base class:

class WWAF\_meins\_inf\_base: CUP\_Creatures\_Military\_TKI\_Insurgent\_Base

{

  side = 0; // Opfor

  dlc = "WWAF";

  faction = "WWAF\_meins";

  editorSubcategory = "WWAF\_ed\_men";

  items[] = {"FirstAidKit"}; // Any non-magazine items to spawn with, including helmets, NVGs, etc.

  respawnItems[] = {"FirstAidKit"}; // Any non-magazine items to respawn with

  accuracy = 2.3; // Sets soldier base accuracy

  sensitivity = 3;   // Sets base skill at seeing other enemies

  threat[] = {1,0.1,0.1}; // Sets how dangerous other units should see it

  camouflage = 1.4; // Sets how hard it will be for other units to see it

  minFireTime = 7; // Sets something to do with maximum fire rate

  canCarryBackPack = 1; // If the soldier should have a backpack slot

  cost = 100000; // How much killing this unit is worth (High cost, more likely to be targeted)

  model="\CUP\Creatures\People\Military\CUP\_Creatures\_People\_Military\_TakiInsurgents\CUP\_meunit\_1.p3d"; // Model file for the soldier (IDK much about this)

  uniformClass="CUP\_O\_TKI\_Khet\_Partug\_01"; // Name of uniform soldier will spawn with

  hiddenSelections[]=

  {

    "camo",

    "clan",

    "insignia"

  }; // ???

  hiddenSelectionsTextures[]=

  {

    "\CUP\Creatures\People\Military\CUP\_Creatures\_People\_Military\_TakiInsurgents\data\meunit\_1\_1\_co.paa"

  }; // ???

  linkedItems[] = {"CUP\_H\_TKI\_Lungee\_Open\_04","CUP\_V\_OI\_TKI\_Jacket4\_06","ItemMap","ItemCompass","ItemWatch"};

  // Other items to spawn with (see below)

  respawnLinkedItems[] = {"CUP\_H\_TKI\_Lungee\_Open\_04","CUP\_V\_OI\_TKI\_Jacket4\_06","ItemMap","ItemCompass","ItemWatch"};

  // Other items to respawn with (see below)

};

The linkedItems and respawnLinkedItems should be in the following order:

{"HAT","VEST","MAP SLOT","GPS SLOT","COMPASS SLOT","WATCH SLOT","RADIO SLOT"}

If there are any things that confuse you, the Bohemia Interactive wiki (community.bistudio.com) can be very useful in defining things, such as what each part of the threat[] array is defining, or what to do with hiddenSelectionsTextures[].

After you create your base soldier, you can simply inherit that base class, and change the aspects that you wish to. The U.S. Army base class defined above is already set up to be a rifleman, so all that is required to create a soldier would be this:

class WWAF\_usarmy\_inf\_d\_rifleman: WWAF\_usarmy\_inf\_base

{

  scope = 2;

};

Editor Previews will be discussed in a later tutorial, as they are not required.

Another set of traits you may wish to change are the way other soldiers call out the contact (such as "AT Soldier" instead of "Soldier") and the icon displayed next to their name in the editor. These traits would look as follows for an AT soldier:

textSingular = "$STR\_A3\_nameSound\_veh\_infantry\_AT\_s";

textPlural = "$STR\_A3\_nameSound\_veh\_infantry\_AT\_p";

nameSound = "veh\_infantry\_AT\_s";

icon = "iconManAT";

for an autorifleman/machinegunner:

textSingular = "$STR\_A3\_nameSound\_veh\_infantry\_MG\_s";

  textPlural = "$STR\_A3\_nameSound\_veh\_infantry\_MG\_p";

  nameSound = "veh\_infantry\_MG\_s";

  icon = "iconManMG";

    for a marksman:

  class SpeechVariants

  {

    class Default

    {

      speechSingular[] = {"veh\_infantry\_sniper\_s"};

      speechPlural[] = {"veh\_infantry\_sniper\_p"};

    };

  }; // I believe speechvariants changes the way the soldier speaks in order to reflect their role

  textSingular = "$STR\_A3\_nameSound\_veh\_infantry\_sniper\_s";

  textPlural = "$STR\_A3\_nameSound\_veh\_infantry\_sniper\_p";

  nameSound = "veh\_infantry\_sniper\_s";

    an officer/leader::

  class SpeechVariants

  {

    class Default

    {

      speechSingular[] = {"veh\_infantry\_officer\_s"};

      speechPlural[] = {"veh\_infantry\_officer\_p"};

    };

  };

  textSingular = "$STR\_A3\_nameSound\_veh\_infantry\_officer\_s";

  textPlural = "$STR\_A3\_nameSound\_veh\_infantry\_officer\_p";

  nameSound = "veh\_infantry\_officer\_s";

  icon = "iconManLeader";

    for a medic:

  icon = "iconManMedic";

  engineer:

  icon = "iconManEngineer";

  eod specialist:

  icon = "iconManExplosive";

  pilot:

  class SpeechVariants

  {

    class Default

    {

      speechSingular[] = {"veh\_infantry\_pilot\_s"};

      speechPlural[] = {"veh\_infantry\_pilot\_p"};

    };

  };

  textSingular = "$STR\_A3\_nameSound\_veh\_infantry\_pilot\_s";

  textPlural = "$STR\_A3\_nameSound\_veh\_infantry\_pilot\_p";

  nameSound = "veh\_infantry\_pilot\_s";

      Last but not least, you may wish to have your soldier carry an existing backpack, but with items in it. Backpacks are configured exactly the way a new rifle would be, just changing something else, and also under the cfgVehicles category. This means that whatever name you create for your bag should be put into your units[] section of your config.cpp. First, inherit an existing backpack class, then change the scope and the transportItems. For example, below is a configuration of a falcon II backpack for a grenadier:

  class WWAF\_pack\_falconii\_gr: rhsusf\_falconii

{

scope = 1;

class TransportItems

{

class \_xx\_1Rnd\_HE\_Grenade\_shell

{

name = "1Rnd\_HE\_Grenade\_shell";

count = 10;

};

class \_xx\_UGL\_FlareWhite\_F

{

name = "UGL\_FlareWhite\_F";

count = 5;

};

};

};

Scope = 1 makes it so that the bag can be acquired via scripting, but not in the arsenal. The names of the individual classes of items to be carried should always start with an "\_xx\_" and it is good practice to just put the name of the item afterward to avoid conflicting classnames. The name variable is pretty self-explanatory, just the name of the item you wish it to be, and count is just how many items you want to carry. Note that it is possible this way to load more items into a bag that the bag can fit, so be aware of how much you want to put in.

Once you have the bag, simply add the line:

backpack = "BACKPACKNAME";

into the soldiers config (obviously replacing BACKPACKNAME with the name of whatever backpack you created). Be careful not to accidentally overload your soldiers!

Other notes:

- Remember to always declare the class you are inheriting before you inherit it, otherwise the code will not binarize! (You do not have to declare items the soldier will be carrying, such as their gun, or their uniform, as long as the required addon is added to the list)

- There are other attributes that can be added to specialists:

canDeactivateMines - When set to 1, if the soldier has a toolkit, they can disarm mines

engineer - When set to 1, with a toolkit, soldier can repair trucks

attendant - When set to 1, with a medikit, soldier can heal others, and will be treated as a medic by AI