08-26-2017, 01:23 AM
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:
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:
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
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
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;
I don't need luck, I have ammo.