ACE3/addons/rearm/functions/fnc_canRearm.sqf
GitHawk d0509830e3 Some things
Made params nicer, replaced some forEach and used params in XEH_respawn
2016-05-12 14:55:40 +02:00

32 lines
857 B
Plaintext

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