2023-12-18 16:47:01 +00:00
|
|
|
#include "..\script_component.hpp"
|
2023-07-13 07:42:30 +00:00
|
|
|
/*
|
|
|
|
* Author: LinkIsGrim
|
2023-12-18 16:47:01 +00:00
|
|
|
* Gets all carry magazines that can be loaded into a CSW, includes weapons added by script.
|
2023-07-13 07:42:30 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: CSW <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
2023-12-22 22:03:33 +00:00
|
|
|
* Compatible Magazines <HASHMAP>
|
2023-07-13 07:42:30 +00:00
|
|
|
* Magazine classname <STRING>
|
|
|
|
* Nothing
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [cursorObject] call ace_csw_fnc_compatibleMagazines
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
2023-12-18 16:47:01 +00:00
|
|
|
|
2023-07-13 07:42:30 +00:00
|
|
|
params [["_csw", objNull, [objNull]]];
|
|
|
|
|
2023-07-13 10:45:52 +00:00
|
|
|
if !((typeOf _csw) in GVAR(initializedStaticTypes)) exitWith {createHashMap};
|
2023-07-13 10:01:28 +00:00
|
|
|
|
|
|
|
// fast exit for csw with single weapon, most common scenario
|
|
|
|
if (count allTurrets _csw isEqualTo 1 && {count weapons _csw isEqualTo 1}) exitWith {
|
2024-02-07 17:18:35 +00:00
|
|
|
+(GVAR(compatibleMagsCache) getOrDefault [(weapons _csw) select 0, createHashMap]) // return
|
2023-07-13 10:01:28 +00:00
|
|
|
};
|
|
|
|
|
2023-07-13 07:42:30 +00:00
|
|
|
private _weapons = [];
|
|
|
|
|
|
|
|
{
|
|
|
|
private _turret = _x;
|
|
|
|
{
|
|
|
|
_weapons pushBackUnique _x;
|
|
|
|
} forEach (_csw weaponsTurret _turret);
|
|
|
|
} forEach (allTurrets _csw);
|
|
|
|
|
|
|
|
if (_weapons isEqualTo []) exitWith {[]};
|
|
|
|
|
|
|
|
private _carryMagazines = createHashMap; // hashmap for constant lookup
|
|
|
|
{
|
|
|
|
private _weapon = _x;
|
2023-07-13 10:01:28 +00:00
|
|
|
if !(_weapon in GVAR(compatibleMagsCache)) then {continue};
|
2023-07-13 07:42:30 +00:00
|
|
|
_carryMagazines merge [GVAR(compatibleMagsCache) get _weapon, true];
|
|
|
|
} forEach _weapons;
|
|
|
|
|
2023-12-22 22:03:33 +00:00
|
|
|
+_carryMagazines // return
|