Comrades in Arms Discussion Board

Full Version: ACE Loadouts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I thought this might be useful for mission makers. It's a small script function that can be used to add a diversity of ACE specific stuff to players. It makes sure that ACE is loaded, and that multiple invocations (for example through JIP) don't mess things up.

Invocation is simple, just add the following to the init field:

Code:
[this, [<list of classes>]] call FHQ_fnc_aceLoadout;

The list of classes can be one of "default", "maptools", "sapper", "sniper", "spotter", "vector" and "vectorday".

"default" adds Fulton and ear plugs
"maptools" adds map tools (doh)
"sapper" adds clacker
"sniper" adds a rangecard
"spotter" adds a rangecard and a spotting scope
"vector" and "vectorday" add a vector with or without night vision, respectively.

Example:
Code:
[this, ["default", "sniper", "vector"]] call FHQ_fnc_aceLoadout;

will add the Fulton, Earplugs, a range card and a vector 21 Nite to the inventory if ACE is loaded.

The function can be stacked, i.e. the above could be done as

Code:
[this, "default"] call FHQ_fnc_aceLoadout;
[this, ["sniper", "vector"]] call FHQ_fnc_aceLoadout;

Can also be called later in the game, and as you can see in the first line, you can omit the array if you only want a single class loadout to be added.

Anyway, here's the code
Code:
/*
** Add ACE Specific items to a unit, based on an abstract class
**
** Parameters:
**   _this select 0: (OBJECT) The unit to add the items to 
**   _this select 1: (STRING) A class name or
**                   (ARRAY) an array of class names
**
** Class name can be one of the following:
** "default" - A basic loadout with a fulton flashlight and ear plugs
** "maptools" - Adds map tools
** "sapper" - Adds a clacker
** "sniper" - Adds range card
** "spotter" - adds the spotting scope
** "vector", "vectorday" - give a Vector 21 and remove potential other binocs
**
** Example of use:
**   Sniper-type unit: [this, ["default", "sniper"]] call FHQ_fnc_aceLoadout;
**   Compassman: [this, ["default", "maptools"]] call FHQ_fnc_aceLoadout;
**   Normal soldier: [this, "default"] call FHQ_fnc_aceLoadout;
*/

params [
    ["_unit", objNull],
    "_class"
];

if (!isClass (configFile >> "CfgMods" >> "ace")) exitWith {}; // No ACE loaded

if (_class isEqualType "") then {
    _class = [_class];
};

// Class is an array here no matter what
{
    _varName = format ["FHQ_ACE_Handled_%1", _x];
    // Check if this class was added already
    if (!(_unit getVariable [_varName, false])) then {
        _unit setVariable [_varName, true, true];

        switch (_x) do {

        case "default": {
            // Fulton Flashlight and ear plugs
                _unit addItem "ACE_Flashlight_MX991";
                _unit addItem "ACE_EarPlugs";
            };
            case "maptools": {
                _unit addItem "ACE_MapTools";
            };
            case "sapper": {
                _unit addItem "ACE_Clacker";
            };
            case "sniper": {
                _unit addItem "ACE_RangeCard";
            };
            case "spotter": {
                _unit addItem "ACE_SpottingScope";
            };
            case "vector": {
                _binoc = binocular _unit;
                if (!(_binoc isEqualTo "")) then {
                    _unit removeWeapon _binoc;
                };
                _unit addWeapon "ACE_Vector";
            };
            case "vectorday": {
                _binoc = binocular _unit;
                if (!(_binoc isEqualTo "")) then {
                    _unit removeWeapon _binoc;
                };
                _unit addWeapon "ACE_VectorDay";
            };
        };
    };
} forEach _class;
Does this script still works for Arma 3?

Tried to implement it to a mission, but I don´t get it working ...

Placed this at the soldiers INIT Line (Eden Editor)

Code:
[this, ["default", "sniper", "vector"]] call FHQ_fnc_aceLoadout;

Created a script with the code mentioned by Alwarren and named the script

Code:
FHQ_fnc_aceLoadout.sqf

Mission tested, but I don´t find any of the equipment in the soldiers inventory. What did I messed up? Any ideas to solve?

Thx guys!
The code snippet Alwarren posted is assuming that you have the script in a function library. To use it directly, try this:

You already put it into a file FHQ_fnc_aceLoadout.sqf. So all you need to do is call it like this:
Code:
[this, ["default", "sniper", "vector"]] call compile preprocessFileLineNumbers "FHQ_fnc_aceLoadout.sqf";