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", "_loadcar", "_loadair", "_loadtank", "_loadboat"];
|
|
|
|
|
|
|
|
_vehicle = objNull;
|
2015-01-16 23:21:47 +00:00
|
|
|
|
|
|
|
if (!([_caller] call FUNC(canInteract)) || {_caller == _unit}) exitwith {_vehicle};
|
|
|
|
|
2015-09-18 16:28:19 +00:00
|
|
|
_loadcar = nearestObject [_unit, "Car"];
|
|
|
|
|
2015-01-16 23:21:47 +00:00
|
|
|
if (_unit distance _loadcar <= 10) then {
|
2015-01-18 19:09:19 +00:00
|
|
|
_vehicle = _loadcar;
|
2015-01-16 23:21:47 +00:00
|
|
|
} else {
|
2015-09-18 16:28:19 +00:00
|
|
|
_loadair = nearestObject [_unit, "Air"];
|
|
|
|
|
|
|
|
if (_unit distance _loadair <= 10) then {
|
|
|
|
_vehicle = _loadair;
|
2015-01-18 19:09:19 +00:00
|
|
|
} else {
|
2015-09-18 16:28:19 +00:00
|
|
|
_loadtank = nearestObject [_unit, "Tank"];
|
|
|
|
|
2015-01-18 19:09:19 +00:00
|
|
|
if (_unit distance _loadtank <= 10) then {
|
|
|
|
_vehicle = _loadtank;
|
2015-07-27 01:33:25 +00:00
|
|
|
} else {
|
2015-09-18 16:28:19 +00:00
|
|
|
_loadboat = nearestObject [_unit, "Ship_F"];
|
|
|
|
|
2015-07-27 01:33:25 +00:00
|
|
|
if (_unit distance _loadboat <= 10) then {
|
|
|
|
_vehicle = _loadboat;
|
|
|
|
};
|
2015-01-18 19:09:19 +00:00
|
|
|
};
|
|
|
|
};
|
2015-01-16 23:21:47 +00:00
|
|
|
};
|
2015-09-18 16:28:19 +00:00
|
|
|
|
2015-01-16 23:21:47 +00:00
|
|
|
if (!isNull _vehicle) then {
|
2015-02-14 19:29:07 +00:00
|
|
|
[_unit, true, GROUP_SWITCH_ID, side group _caller] call FUNC(switchToGroupSide);
|
2015-09-18 16:28:19 +00:00
|
|
|
[[_unit, _vehicle, _caller], QFUNC(loadPersonLocal), _unit, false] call FUNC(execRemoteFnc);
|
2015-01-16 23:21:47 +00:00
|
|
|
};
|
2015-09-18 16:28:19 +00:00
|
|
|
|
|
|
|
_vehicle
|