ACE3/addons/rearm/functions/fnc_canRearm.sqf

29 lines
847 B
Plaintext
Raw Normal View History

2015-08-15 16:43:13 +00:00
/*
* Author: GitHawk, Jonpas
* Check if a unit can rearm.
2015-08-15 16:43:13 +00:00
*
* Arguments:
2016-02-27 20:05:19 +00:00
* 0: Vehicle <OBJECT>
* 1: Unit <OBJECT>
2015-08-15 16:43:13 +00:00
*
* Return Value:
* Can Rearm <BOOL>
2015-08-15 16:43:13 +00:00
*
* Example:
2016-02-27 20:05:19 +00:00
* [tank, player] call ace_rearm_fnc_canRearm
2015-08-15 16:43:13 +00:00
*
* Public: No
*/
#include "script_component.hpp"
2016-02-27 20:05:19 +00:00
params [["_vehicle", objNull, [objNull]], ["_unit", objNull, [objNull]]];
2015-08-15 16:43:13 +00:00
2016-02-27 20:05:19 +00:00
if (GVAR(level) == 0 || {isNull _unit} || {!(_unit isKindOf "CAManBase")} || {!local _unit} || {_vehicle distance _unit > REARM_ACTION_DISTANCE} || {_vehicle getVariable [QGVAR(disabled), false]}) exitWith {false};
2015-08-15 16:43:13 +00:00
2016-02-27 20:05:19 +00:00
private _dummy = _unit getVariable [QGVAR(dummy), objNull];
if (isNull _dummy) exitwith {false};
2016-02-27 20:05:19 +00:00
private _magazineClass = _dummy getVariable QGVAR(magazineClass);
if (isNil "_magazineClass") exitWith {false};
2015-08-15 16:43:13 +00:00
2016-02-27 20:05:19 +00:00
([_vehicle, _magazineClass] call FUNC(getNeedRearmMagazines)) select 0