/* * Author: commy2 * Check if a unit can attach a specific item. * * Arguments: * 0: vehicle that it will be attached to (player or vehicle) * 1: unit doing the attach (player) * 2: Array empty or containing a string of the attachable item * * Return Value: * Can Attach * * Example: * [bob, bob, ["light"]] call ace_attach_fnc_canAttach; * * Public: No */ #include "script_component.hpp" private ["_attachLimit", "_attachedObjects","_playerPos"]; params ["_attachToVehicle","_player","_args"]; _args params [["_itemClassname","", [""]]]; TRACE_3("params",_attachToVehicle,_unit,_itemClassname); _attachLimit = [6, 1] select (_player == _attachToVehicle); _attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []]; _playerPos = (ACE_player modelToWorldVisual (ACE_player selectionPosition "pilot")); (canStand _player) && {(_attachToVehicle distance _player) < 7} && {alive _attachToVehicle} && {(count _attachedObjects) < _attachLimit} && {_itemClassname in ((itemsWithMagazines _player) + [""])};