ACE3/addons/csw/functions/fnc_getSourceCompatibleMagazines.sqf

39 lines
968 B
Plaintext
Raw Normal View History

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 compatible magazines to load a CSW from a magazine source.
2023-07-13 07:42:30 +00:00
*
* Arguments:
2023-12-18 16:47:01 +00:00
* 0: Magazine Source <OBJECT> (default: objNull)
2023-07-13 07:42:30 +00:00
* 1: CSW <OBJECT> (default: objNull)
*
* Return Value:
* Magazines <ARRAY>
* Magazine classname <STRING>
* Magazine ammo <NUMBER>
*
* Example:
* [backpackContainer player, cursorObject] call ace_csw_fnc_getSourceCompatibleMagazines
2023-07-13 07:42:30 +00:00
*
* Public: Yes
*/
2023-12-18 16:47:01 +00:00
2023-07-13 07:42:30 +00:00
params [["_source", objNull, [objNull]], ["_csw", objNull, [objNull]]];
2024-08-29 07:01:54 +00:00
if (isNull _source || {!alive _csw}) exitWith {[]};
2023-07-13 07:42:30 +00:00
if !(typeOf _csw in GVAR(initializedStaticTypes)) exitWith {[]};
2023-07-13 07:42:30 +00:00
private _magazines = magazinesAmmoCargo _source;
if (_magazines isEqualTo []) exitWith {[]};
private _compatibleMagazines = [_csw] call FUNC(compatibleMagazines);
private _return = _magazines select {(_x select 0) in _compatibleMagazines};
// sort by ammo count, highest to lowest
_return sort false;
_return