mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
438a90b63d
* extended loadouts - earplugs, gunbag, and arsenal identity * arsenal - maintain default loadout size check * restore comment Co-authored-by: jonpas <jonpas33@gmail.com> * fix forgotten example Co-authored-by: jonpas <jonpas33@gmail.com>
115 lines
3.7 KiB
Plaintext
115 lines
3.7 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: 654wak654
|
|
* Adds a loadout to the "Default Loadouts" list.
|
|
* If a loadout with the same name exists, it is overwritten.
|
|
*
|
|
* Arguments:
|
|
* 0: Name of loadout <STRING>
|
|
* 1: CBA extended loadout or getUnitLoadout array <ARRAY>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* ["Squad Leader", getUnitLoadout sql1] call ace_arsenal_fnc_addDefaultLoadout
|
|
*
|
|
* Public: Yes
|
|
*/
|
|
|
|
params [["_name", "", [""]], ["_loadout", [], [[]]]];
|
|
|
|
private _extendedInfo = createHashMap;
|
|
if (count _loadout == 2) then {
|
|
_extendedInfo = _loadout select 1;
|
|
_loadout = _loadout select 0;
|
|
};
|
|
|
|
if (count _loadout != 10) exitWith {};
|
|
|
|
if (isNil QGVAR(defaultLoadoutsList)) then {
|
|
GVAR(defaultLoadoutsList) = [];
|
|
};
|
|
|
|
for "_dataIndex" from 0 to 10 do {
|
|
switch (_dataIndex) do {
|
|
|
|
case 0;
|
|
case 1;
|
|
case 2;
|
|
case 8: {
|
|
if (count (_loadout select _dataIndex) > 0) then {
|
|
|
|
private _weapon = (_loadout select _dataIndex) select 0;
|
|
if (_weapon != "") then {
|
|
|
|
private _baseWeapon = _weapon call BIS_fnc_baseWeapon;
|
|
if (_weapon != _baseWeapon) then {
|
|
(_loadout select _dataIndex) set [0, _baseWeapon];
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
case 3;
|
|
case 4;
|
|
case 5: {
|
|
if (count (_loadout select _dataIndex) > 0) then {
|
|
private _containerContents = (_loadout select _dataIndex) select 1;
|
|
|
|
if (count _containerContents > 0) then {
|
|
|
|
{
|
|
if (count _x == 2) then {
|
|
|
|
if ((_x select 0) isEqualType "") then {
|
|
|
|
private _item = (_x select 0);
|
|
if (_item != "") then {
|
|
|
|
private _uniqueBaseCfgText = getText (configFile >> "CfgWeapons" >> _item >> "ace_arsenal_uniqueBase");
|
|
if (_uniqueBaseCfgText != "") then {
|
|
|
|
_x set [0, _uniqueBaseCfgText];
|
|
};
|
|
};
|
|
} else {
|
|
private _weapon = (_x select 0) select 0;
|
|
if (_weapon != "") then {
|
|
|
|
private _baseWeapon = _weapon call BIS_fnc_baseWeapon;
|
|
if (_weapon != _baseWeapon) then {
|
|
(_x select 0) set [0, _baseWeapon];
|
|
};
|
|
};
|
|
};
|
|
};
|
|
} foreach _containerContents;
|
|
};
|
|
};
|
|
};
|
|
|
|
case 9: {
|
|
for "_subIndex" from 0 to 4 do {
|
|
private _item = (_loadout select _dataIndex) select _subIndex;
|
|
|
|
if (_item != "") then {
|
|
|
|
private _uniqueBaseCfgText = getText (configFile >> "CfgWeapons" >> _item >> "ace_arsenal_uniqueBase");
|
|
if (_uniqueBaseCfgText != "") then {
|
|
|
|
(_loadout select _dataIndex) set [_subIndex, _uniqueBaseCfgText];
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
private _loadoutIndex = (+(GVAR(defaultLoadoutsList))) findIf {(_x select 0) == _name};
|
|
if (_loadoutIndex == -1) then {
|
|
GVAR(defaultLoadoutsList) pushBack [_name, [_loadout, _extendedInfo]];
|
|
} else {
|
|
GVAR(defaultLoadoutsList) set [_loadoutIndex, [_name, [_loadout, _extendedInfo]]];
|
|
};
|