ACE3/addons/common/functions/fnc_loadPerson.sqf

39 lines
1.0 KiB
Plaintext
Raw Normal View History

2015-09-18 16:28:19 +00:00
/*
* Author: Glowbal
* Loads a specified unit into any nearby vehicle
2015-01-16 23:21:47 +00:00
*
2015-09-18 16:28:19 +00:00
* Arguments:
* 0: Unit that will load <OBJECT>
* 1: Unit to be loaded <OBJECT>
*
* Return Value:
* the vehicle that the unitToBeloaded has been loaded in. Returns ObjNull if function failed <OBJECT>
*
* Public: Yes
2015-01-16 23:21:47 +00:00
*/
#include "script_component.hpp"
2015-09-18 19:12:40 +00:00
#define GROUP_SWITCH_ID QFUNC(loadPerson)
2015-01-16 23:21:47 +00:00
2015-09-18 16:28:19 +00:00
params ["_caller", "_unit"];
private _vehicle = objNull;
2015-01-16 23:21:47 +00:00
2015-11-30 16:14:05 +00:00
if (!([_caller, _unit, ["isNotDragging", "isNotCarrying"]] call FUNC(canInteractWith)) || {_caller == _unit}) exitWith {_vehicle};
2015-01-16 23:21:47 +00:00
private _nearVehicles = nearestObjects [_unit, ["Car", "Air", "Tank", "Ship_F"], 10];
{
TRACE_1("",_x);
if ((_x emptyPositions "cargo" > 0) || {_x emptyPositions "gunner" > 0}) exitWith {
_vehicle = _x;
2015-01-18 19:09:19 +00:00
};
} forEach _nearVehicles;
2015-09-18 16:28:19 +00:00
2015-01-16 23:21:47 +00:00
if (!isNull _vehicle) then {
[_unit, true, GROUP_SWITCH_ID, side group _caller] call FUNC(switchToGroupSide);
2016-05-24 13:13:11 +00:00
["ace_loadPersonEvent", [_unit, _vehicle, _caller], _unit] call CBA_fnc_targetEvent;
2015-01-16 23:21:47 +00:00
};
2015-09-18 16:28:19 +00:00
_vehicle