2015-01-11 20:39:49 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Check if a unit can attach a specific item.
|
2015-02-01 20:56:19 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-03-27 05:02:54 +00:00
|
|
|
* 0: vehicle that it will be attached to (player or vehicle) <OBJECT>
|
|
|
|
* 1: unit doing the attach (player) <OBJECT>
|
|
|
|
* 2: Array empty or containing a string of the attachable item <ARRAY>
|
2015-02-01 20:56:19 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-03-27 17:08:05 +00:00
|
|
|
* Can Attach <BOOL>
|
2015-02-01 20:56:19 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2015-03-27 17:08:05 +00:00
|
|
|
* [bob, bob, ["light"]] call ace_attach_fnc_canAttach;
|
2015-02-01 20:56:19 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
2015-01-11 20:39:49 +00:00
|
|
|
*/
|
2015-02-01 20:56:19 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 20:39:49 +00:00
|
|
|
|
2015-08-04 22:47:31 +00:00
|
|
|
params ["_attachToVehicle","_player","_args"];
|
2015-08-06 18:17:59 +00:00
|
|
|
_args params [["_itemClassname","", [""]]];
|
2015-08-28 21:57:16 +00:00
|
|
|
TRACE_3("params",_attachToVehicle,_player,_itemClassname);
|
2015-01-11 20:39:49 +00:00
|
|
|
|
2015-08-28 21:57:16 +00:00
|
|
|
private ["_attachLimit", "_attachedObjects"];
|
2015-02-15 14:31:09 +00:00
|
|
|
|
2015-08-28 21:57:16 +00:00
|
|
|
_attachLimit = [6, 1] select (_player == _attachToVehicle);
|
|
|
|
_attachedObjects = _attachToVehicle getVariable [QGVAR(attached), []];
|
2015-03-27 16:14:04 +00:00
|
|
|
|
2015-08-28 21:57:16 +00:00
|
|
|
((_player == _attachToVehicle) || {canStand _player}) &&
|
|
|
|
{(_attachToVehicle distance _player) < 7} &&
|
|
|
|
{alive _attachToVehicle} &&
|
|
|
|
{(count _attachedObjects) < _attachLimit} &&
|
|
|
|
{_itemClassname in ((itemsWithMagazines _player) + [""])};
|