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