Skip to content

Instantly share code, notes, and snippets.

@commy2
Last active August 17, 2016 17:52
Show Gist options
  • Save commy2/34099f92df9c282c36c13cc2a97ff3a2 to your computer and use it in GitHub Desktop.
Save commy2/34099f92df9c282c36c13cc2a97ff3a2 to your computer and use it in GitHub Desktop.
CBA_fnc_findLoadableWeapon = {//
params [["_unit", objNull, [objNull]], ["_magazine", "", [""]]];
_magazine = toLower _magazine;
private _weaponsMagazines = [
[primaryWeapon _unit, primaryWeaponMagazine _unit],
[handgunWeapon _unit, handgunMagazine _unit],
[secondaryWeapon _unit, secondaryWeaponMagazine _unit],
[binocular _unit, [_unit call CBA_fnc_binocularMagazine]]
] select {_x select 0 != ""};
scopeName "main";
{
_x params ["_weapon", "_loadedMagazines"];
_loadedMagazines = _loadedMagazines apply {toLower _x};
private _config = _weapon call CBA_fnc_getItemConfig;
private _compatibleMagazines = [getArray (_config >> "magazines") apply {toLower _x}];
{
_compatibleMagazines pushBack (getArray (_config >> _x >> "magazines") apply {toLower _x});
} forEach getArray (_config >> "muzzles");
{
if (_magazine in _x && {(_loadedMagazines arrayIntersect _x) isEqualTo []}) exitWith {
_weapon breakOut "main";
};
} forEach _compatibleMagazines;
} forEach _weaponsMagazines;
""
};//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment