mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
43 lines
1.1 KiB
Plaintext
43 lines
1.1 KiB
Plaintext
/*
|
|
* Author: commy2
|
|
* Check if a unit has an item attached and if it can remove that item.
|
|
*
|
|
* Arguments:
|
|
* 0: vehicle that it will be detached from (player or vehicle) <OBJECT>
|
|
* 1: unit doing the detaching (player) <OBJECT>
|
|
*
|
|
* Return Value:
|
|
* Can Detach <BOOL>
|
|
*
|
|
* Example:
|
|
* [bob, bob] call ace_attach_fnc_canDetach;
|
|
*
|
|
* Public: No
|
|
*/
|
|
#include "script_component.hpp"
|
|
|
|
params ["_attachToVehicle", "_unit"];
|
|
TRACE_2("params",_attachToVehicle,_unit);
|
|
|
|
if ((vehicle _unit) != _unit) exitWith {false};
|
|
|
|
_attachedList = _attachToVehicle getVariable [QGVAR(attached), []];
|
|
if ((count _attachedList) == 0) exitWith {false};
|
|
|
|
private ["_inRange"];
|
|
|
|
_inRange = false;
|
|
{
|
|
_x params ["_xObject"];
|
|
if (isNull _xObject) exitWith {
|
|
TRACE_1("Null attached",_x);
|
|
_attachedList deleteAt _forEachIndex;
|
|
_attachToVehicle setVariable [QGVAR(attached), _attachedList, true];
|
|
};
|
|
if (((getPos _unit) distance2d (getPos _xObject)) < 4) exitWith {_inRange = true};
|
|
} forEach _attachedList;
|
|
|
|
_inRange &&
|
|
{(_unit == _attachToVehicle) || {canStand _unit}} &&
|
|
{alive _attachToVehicle}
|