2015-01-11 20:39:49 +00:00
|
|
|
/*
|
2015-02-01 20:56:19 +00:00
|
|
|
* Author: commy2
|
|
|
|
* Check if a unit has an item attached and if it can remove that item.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2015-03-27 05:02:54 +00:00
|
|
|
* 0: vehicle that it will be detached from (player or vehicle) <OBJECT>
|
|
|
|
* 1: unit doing the detaching (player) <OBJECT>
|
2015-02-01 20:56:19 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-03-27 17:08:05 +00:00
|
|
|
* Can Detach <BOOL>
|
2015-02-01 20:56:19 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2015-03-27 17:08:05 +00:00
|
|
|
* [bob, bob] call ace_attach_fnc_canDetach;
|
2015-02-01 20:56:19 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
2015-01-11 20:39:49 +00:00
|
|
|
|
2015-08-04 22:47:31 +00:00
|
|
|
params ["_attachToVehicle", "_unit"];
|
2015-08-06 18:17:59 +00:00
|
|
|
TRACE_2("params",_attachToVehicle,_unit);
|
2015-02-15 14:31:09 +00:00
|
|
|
|
2015-08-29 16:47:56 +00:00
|
|
|
_attachedList = _attachToVehicle getVariable [QGVAR(attached), []];
|
|
|
|
if ((count _attachedList) == 0) exitWith {false};
|
|
|
|
|
2015-08-28 21:57:16 +00:00
|
|
|
private ["_inRange"];
|
2015-01-30 20:32:21 +00:00
|
|
|
|
|
|
|
_inRange = false;
|
2015-08-28 21:57:16 +00:00
|
|
|
{
|
|
|
|
_x params ["_xObject"];
|
2015-08-29 16:47:56 +00:00
|
|
|
if (isNull _xObject) exitWith {
|
|
|
|
TRACE_1("Null attached",_x);
|
|
|
|
_attachedList deleteAt _forEachIndex;
|
|
|
|
_attachToVehicle setVariable [QGVAR(attached), _attachedList, true];
|
|
|
|
};
|
2015-08-28 21:57:16 +00:00
|
|
|
if (((getPos _unit) distance2d (getPos _xObject)) < 4) exitWith {_inRange = true};
|
2015-08-29 16:47:56 +00:00
|
|
|
} forEach _attachedList;
|
2015-01-30 20:32:21 +00:00
|
|
|
|
2015-08-28 21:57:16 +00:00
|
|
|
_inRange &&
|
|
|
|
{(_unit == _attachToVehicle) || {canStand _unit}} &&
|
|
|
|
{alive _attachToVehicle}
|