2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-09-21 11:08:10 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Count magazines of unit.
|
2015-01-16 23:21:47 +00:00
|
|
|
*
|
2015-09-21 11:08:10 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Magazine <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Magazine amount <NUMBER>
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [bob, "magazine"] call ace_common_fnc_getNumberMagazinesIn
|
|
|
|
*
|
2015-09-21 11:08:10 +00:00
|
|
|
* Public: No
|
2015-01-16 23:21:47 +00:00
|
|
|
*/
|
|
|
|
|
2015-09-21 11:08:10 +00:00
|
|
|
params ["_unit", "_magazine"];
|
2015-05-14 22:12:40 +00:00
|
|
|
|
2015-12-12 15:48:54 +00:00
|
|
|
private _return = 0;
|
2015-09-21 11:08:10 +00:00
|
|
|
|
2015-01-16 23:21:47 +00:00
|
|
|
if (_unit isKindOf "CAManBase") then {
|
2015-01-18 19:09:19 +00:00
|
|
|
_return = {_x == _magazine} count magazines _unit;
|
2015-01-16 23:21:47 +00:00
|
|
|
} else {
|
2015-01-18 19:09:19 +00:00
|
|
|
{
|
2017-05-31 21:09:36 +00:00
|
|
|
_return = _return + ({_x == _magazine} count magazines _x);
|
2015-09-21 11:08:10 +00:00
|
|
|
false
|
|
|
|
} count crew _unit;
|
2015-01-16 23:21:47 +00:00
|
|
|
|
2017-05-31 21:09:36 +00:00
|
|
|
(getMagazineCargo _unit) params [["_magNames", []], ["_magCount", []]];
|
|
|
|
{
|
|
|
|
if (_magazine == _x) exitWith {_return = _return + (_magCount select _forEachIndex)};
|
|
|
|
} forEach _magNames;
|
2015-01-16 23:21:47 +00:00
|
|
|
};
|
|
|
|
|
2015-05-14 22:12:40 +00:00
|
|
|
_return
|