-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathfnc_compatibleItems.sqf
More file actions
61 lines (53 loc) · 2.04 KB
/
fnc_compatibleItems.sqf
File metadata and controls
61 lines (53 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
Author: Karel Moricky
Enhanced by Robalo
Caching added by joko // Jonas
Description:
Return all compatible weapon attachments
Parameter(s):
0: STRING - weapon class
1: STRING - optional, accessory type: number (101 - muzzle, 201 - optic, 301 - pointer, 302 - bipod)
Returns:
ARRAY of STRINGs
Examples:
_acclist = ["LMG_Mk200_F"] call CBA_fnc_compatibleItems;
_muzzleacclist = ["LMG_Mk200_F", 101] call CBA_fnc_compatibleItems;
*/
#include "script_component.hpp"
params [["_weapon", "", [""]], ["_typefilter", 0]];
if (_weapon == "") exitWith {[]};
if (isNil QGVAR(namespace)) then {
GVAR(namespace) = call CBA_fnc_createNamespace;
};
private _compatibleItems = GVAR(namespace) getVariable _weapon;
if (isNil "_compatibleItems") then {
_compatibleItems = [];
private _cfgWeapon = configFile >> "CfgWeapons" >> _weapon;
if (isClass _cfgWeapon) then {
{
private _cfgCompatibleItems = _x >> "compatibleItems";
if (isArray _cfgCompatibleItems) then {
{
_compatibleItems pushBackUnique _x;
nil
} count (getArray _cfgCompatibleItems);
} else {
if (isClass _cfgCompatibleItems) then {
{
if ((getNumber _x > 0)) then {_compatibleItems pushBackUnique (configName _x)};
nil
} count configProperties [_cfgCompatibleItems, "isNumber _x"];
};
};
nil
} count configProperties [_cfgWeapon >> "WeaponSlotsInfo","isclass _x"];
GVAR(namespace) setVariable [_weapon, _compatibleItems]; //save entry in cache
} else {
["'%1' not found in CfgWeapons",_weapon] call bis_fnc_error;
};
};
if (_typefilter == 0) then { //return
_compatibleItems
} else {
_compatibleItems select {_typefilter == getNumber(configFile>>"CfgWeapons">>_x>>"itemInfo">>"type")};
};