ACE3/addons/rearm/functions/fnc_getNeedRearmMagazines.sqf

45 lines
1.0 KiB
Plaintext
Raw Normal View History

/*
* Author: GitHawk, Jonpas
* Get rearm return value.
*
* Arguments:
* 0: Target <OBJECT>
2015-08-18 14:20:11 +00:00
* 1: Magazine Classname <STRING>
*
* Return Value:
2015-08-18 14:20:11 +00:00
* Return Value <ARRAY>
* 0: Can Rearm <BOOL>
* 1: TurretPath <ARRAY>
* 2: Magazine Classname <STRING>
*
* Example:
2015-08-18 14:20:11 +00:00
* [tank, "mag"] call ace_rearm_fnc_getNeedRearmMagazines
*
* Public: No
*/
#include "script_component.hpp"
2015-08-18 14:20:11 +00:00
private ["_return", "_magazines", "_cnt"];
params ["_target", "_magazineClass"];
2015-08-18 14:20:11 +00:00
_return = [false, [], 0];
{
_magazines = _target magazinesTurret _x;
if (_magazineClass in _magazines) then {
_cnt = {_x == _magazineClass} count _magazines;
if ((_target magazineTurretAmmo [_magazineClass, _x]) < getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count")) exitWith {
_return = [true, _x, _cnt];
};
if (_cnt < ([_target, _x, _magazineClass] call FUNC(getMaxMagazines))) exitWith {
_return = [true, _x, _cnt];
};
};
if (_return select 0) exitWith {};
} forEach REARM_TURRET_PATHS;
_return