2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-08-15 16:43:13 +00:00
|
|
|
/*
|
2015-08-18 00:32:10 +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>
|
2015-08-18 01:37:02 +00:00
|
|
|
* 1: Unit <OBJECT>
|
2015-08-15 16:43:13 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-08-18 00:32:10 +00:00
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
params ["_vehicle", "_unit"];
|
2015-08-15 16:43:13 +00:00
|
|
|
|
2017-05-17 23:21:11 +00:00
|
|
|
if (!alive _vehicle) exitWith {false};
|
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};
|
2017-05-13 22:36:53 +00:00
|
|
|
|
2016-02-27 20:05:19 +00:00
|
|
|
private _dummy = _unit getVariable [QGVAR(dummy), objNull];
|
2015-08-19 23:20:31 +00:00
|
|
|
if (isNull _dummy) exitwith {false};
|
2016-02-27 20:05:19 +00:00
|
|
|
private _magazineClass = _dummy getVariable QGVAR(magazineClass);
|
2015-08-18 00:32:10 +00:00
|
|
|
if (isNil "_magazineClass") exitWith {false};
|
2015-08-15 16:43:13 +00:00
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
private _needRearmMags = [_vehicle] call FUNC(getNeedRearmMagazines);
|
|
|
|
|
|
|
|
// Testing if vehicle needs rearm on any magazines of class _magazineClass
|
|
|
|
private _needsRearm = ({(_x select 0) isEqualTo _magazineClass} count _needRearmMags) > 0;
|
|
|
|
|
|
|
|
_needsRearm
|