gear - Global-Conflicts-ArmA/Olsen-Framework-Arma-3 GitHub Wiki

WARNING: The GearScript have changed, and some of the information on this page is out of date. - It will be updated shortly.

The gear.sqf file is used to set the inventory of unit.

To give a unit a custom loadout you use [this, "LOADOUT", "GROUPNAME"] call FNC_GearScript, in the initialization field of the unit, where LOADOUT is the custom text name of the loadout and GROUPNAME is the group name.

Example:

[this, "SL", "1'6"] call FNC_GearScript;

example

Switch structure

The gear script uses a case switch to separate the loadouts. A switch basically takes an input and compares it to all the cases until it spots a match and executes the matched loadout. The case switch uses custom text names to differentiate the loadouts.

Example: LOADOUT is not valid code.

switch (_type) do {
    
    case "SL": {
        LOADOUT
    };
    
    case "SNIPER": {
        LOADOUT
    };
    
};

Making a loadout

When making a loadout if you give the unit the magazines for the weapon, before giving him the weapon, he will spawn with the weapon loaded. Before packing a backpack you need to add the backpack first.

ACE3 classnames

UO classnames

To clear the gear of a unit use _unit call FNC_RemoveAllGear;.

To add a single item anywhere use ["CLASSNAME"] call FNC_AddItem;.

To add multiple items anywhere use ["CLASSNAME", AMOUNT] call FNC_AddItem;.

To add items to the uniform use ["CLASSNAME", AMOUNT, "uniform"] call FNC_AddItem;.

To add items to the vest use ["CLASSNAME", AMOUNT, "vest"] call FNC_AddItem;.

To add items to the backpack use ["CLASSNAME", AMOUNT, "backpack"] call FNC_AddItem;.

To add random items to the uniform use [["CLASSNAME1", "CLASSNAME2"], AMOUNT, "uniform"] call FNC_AddItem;.

Advanced random items syntax [["CASE1_AMMO", random(2, 6)], ["CASE1_WEAPON"](/Global-Conflicts-ArmA/Olsen-Framework-Arma-3/wiki/["CASE1_AMMO",-random(2,-6)],-["CASE1_WEAPON"), ["CASE2_AMMO", random(1, 4)], ["CASE2_WEAPON"](/Global-Conflicts-ArmA/Olsen-Framework-Arma-3/wiki/"CASE2_AMMO",-random(1,-4)],-["CASE2_WEAPON")] call FNC_AddItemRandom;.
You can have as many cases and items per cases as you like.

Example:

_unit call FNC_RemoveAllGear;

case "SL": {
    // SL Only //
    ["U_B_CombatUniform_mcam"] call FNC_AddItem;
    ["H_HelmetB_black"] call FNC_AddItem;
    ["NVGoggles"] call FNC_AddItem;
    ["V_PlateCarrier3_rgr"] call FNC_AddItem;
    ["B_Kitbag_mcamo"] call FNC_AddItem;

    ["11Rnd_45ACP_Mag", 3, "uniform"] call FNC_AddItem;

    ["ACRE_PRC148", 1, "vest"] call FNC_AddItem;
    ["30Rnd_65x39_caseless_mag", 8, "vest"] call FNC_AddItem;
    ["SmokeShell", 2, "vest"] call FNC_AddItem;
    ["HandGrenade", 2, "vest"] call FNC_AddItem;

    ["30Rnd_65x39_caseless_mag_Tracer", 3, "backpack"] call FNC_AddItem;
    ["30Rnd_65x39_caseless_mag", 3, "backpack"] call FNC_AddItem;
    ["FlareWhite_F", 2, "backpack"] call FNC_AddItem;
    ["SmokeShellRed", 2, "backpack"] call FNC_AddItem;
    ["SmokeShellGreen", 2, "backpack"] call FNC_AddItem;
    ["Chemlight_green", 5, "backpack"] call FNC_AddItem;
    ["Chemlight_red", 5, "backpack"] call FNC_AddItem;
    ["ACE_morphine", 1, "uniform"] call FNC_AddItem;

    ["Rangefinder"] call FNC_AddItem;

    ["arifle_MX_Hamr_pointer_F"] call FNC_AddItem;
    ["hgun_Pistol_heavy_01_MRD_F"] call FNC_AddItem;

};
// Everyone //
["ItemCompass"] call FNC_AddItem;
["ItemWatch"] call FNC_AddItem;
["ItemMap"] call FNC_AddItem;

["ACRE_PRC343", 1, "uniform"] call FNC_AddItem;
["ACE_EarPlugs", 1, "uniform"] call FNC_AddItem;

["ACE_fieldDressing", 3, "uniform"] call FNC_AddItem;
["ACE_packingBandage", 1, "uniform"] call FNC_AddItem;
["ACE_elasticBandage", 1, "vest"] call FNC_AddItem;
["ACE_tourniquet", 1, "vest"] call FNC_AddItem;

example

Defines

Using defines is a technique to reduce the size of your gear script and make it smaller. When ever 2 loadouts have a minimum of 2 items in common it is worth making a define.

The format for using defines is *#define NAME * where NAME is what the compiler will match on and replace with the code in the define. Every line inside a define has to end with ** except for the last line. What ** does is it tells the define to include the next line.

Example:

switch (_type) do {
    case "SL": {
        ["30Rnd_65x39_caseless_mag", 7] call FNC_AddItem;
        ["HandGrenade"] call FNC_AddItem;
        ["arifle_MX_Hamr_pointer_F"] call FNC_AddItem;
    };

    case "MEDIC": {
        ["30Rnd_65x39_caseless_mag", 7] call FNC_AddItem;
        ["HandGrenade"] call FNC_AddItem;
        ["arifle_MX_pointer_F"] call FNC_AddItem;
    };
};

Becomes:

#define AMMOFRAG \
["30Rnd_65x39_caseless_mag", 7] call FNC_AddItem; \
["HandGrenade"] call FNC_AddItem;

switch (_type) do {
    case "SL": {
        AMMOFRAG;
        ["arifle_MX_Hamr_pointer_F"] call FNC_AddItem;
    };

    case "MEDIC": {
        AMMOFRAG;
        ["arifle_MX_pointer_F"] call FNC_AddItem;
    };
};

Dynamic defines

The more powerful thing about defines is that you can give them parameters like a normal function. It is just like before but the parameters are written like this: #define NAME(PARAMETER1, PARAMETER2, PARAMETER3, ... ).

Example:

switch (_type) do {
    case "SL": {
        ["Binocular"] call FNC_AddItem;
        ["30Rnd_65x39_caseless_mag", 7] call FNC_AddItem;
        ["30Rnd_65x39_caseless_mag_Tracer"] call FNC_AddItem;
        ["arifle_MX_Hamr_pointer_F"] call FNC_AddItem;
        ["HandGrenade", 2] call FNC_AddItem;
        ["SmokeShell", 1] call FNC_AddItem;
        ["SmokeShellGreen", 1] call FNC_AddItem;
        ["ACRE_PRC117F"] call FNC_AddItem;
    };

    case "FL": {
        ["B_Kitbag_mcamo"] call FNC_AddItem;
        ["Binocular"] call FNC_AddItem;
        ["30Rnd_65x39_caseless_mag", 7] call FNC_AddItem;
        ["30Rnd_65x39_caseless_mag_Tracer"] call FNC_AddItem;
        ["1Rnd_HE_Grenade_shell", 4] call FNC_AddItem;
        ["1Rnd_Smoke_Grenade_shell", 2] call FNC_AddItem;
        ["arifle_MX_GL_F"] call FNC_AddItem;
        ["HandGrenade", 2] call FNC_AddItem;
        ["SmokeShell", 2] call FNC_AddItem;
    };
    
    case "LAT": {
        ["B_Kitbag_mcamo"] call FNC_AddItem;
        ["30Rnd_65x39_caseless_mag", 8] call FNC_AddItem;
        ["arifle_MX_Hamr_pointer_F"] call FNC_AddItem;
        ["HandGrenade", 2] call FNC_AddItem;
        ["SmokeShell", 2] call FNC_AddItem;
        ["launch_NLAW_F"] call FNC_AddItem;
    };    
};

Becomes:

#define DEFAULTGEAR(AMMO, TRACER, FRAG, WHITE, GREEN) \
["30Rnd_65x39_caseless_mag", AMMO] call FNC_AddItem; \
["30Rnd_65x39_caseless_mag_Tracer", TRACER] call FNC_AddItem; \
["HandGrenade", FRAG] call FNC_AddItem; \
["SmokeShell", WHITE] call FNC_AddItem; \
["SmokeShellGreen", GREEN] call FNC_AddItem;

switch (_type) do {
    case "SL": {
        DEFAULTGEAR(7, 1, 2, 1, 1);
        ["Binocular"] call FNC_AddItem;
        ["arifle_MX_Hamr_pointer_F"] call FNC_AddItem;
        ["ACRE_PRC117F"] call FNC_AddItem;
    };
    
    case "FL": {
        DEFAULTGEAR(7, 1, 2, 2, 0);
        ["B_Kitbag_mcamo"] call FNC_AddItem;
        ["Binocular"] call FNC_AddItem;
        ["1Rnd_HE_Grenade_shell", 4] call FNC_AddItem;
        ["1Rnd_Smoke_Grenade_shell", 2] call FNC_AddItem;
        ["arifle_MX_GL_F"] call FNC_AddItem;
    };

    case "LAT": {
        DEFAULTGEAR(8, 0, 2, 2, 0);
        ["B_Kitbag_mcamo"] call FNC_AddItem;
        ["arifle_MX_Hamr_pointer_F"] call FNC_AddItem;
        ["launch_NLAW_F"] call FNC_AddItem;
    };
};