2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-09-18 16:28:19 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
2017-09-29 20:00:47 +00:00
|
|
|
* Loads a specified unit into any nearby vehicle, or _vehicle parameter.
|
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>
|
2017-09-29 20:00:47 +00:00
|
|
|
* 2: Vehicle that the unit will be loaded in <OBJECT> (default: objNull)
|
2022-02-17 17:14:39 +00:00
|
|
|
* 3: Preferred seats <ARRAY>
|
|
|
|
* 4: Reverse fill <BOOL>
|
2015-09-18 16:28:19 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2017-09-29 20:00:47 +00:00
|
|
|
* Vehicle that the unitToBeloaded has been loaded in. Returns objNull if function failed <OBJECT>
|
2015-09-18 16:28:19 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [bob, kevin] call ace_common_fnc_loadPerson
|
|
|
|
*
|
2015-09-18 16:28:19 +00:00
|
|
|
* Public: Yes
|
2015-01-16 23:21:47 +00:00
|
|
|
*/
|
|
|
|
|
2015-09-18 19:12:40 +00:00
|
|
|
#define GROUP_SWITCH_ID QFUNC(loadPerson)
|
2015-01-16 23:21:47 +00:00
|
|
|
|
2022-02-17 17:14:39 +00:00
|
|
|
params ["_caller", "_unit", ["_vehicle", objNull], ["_preferredSeats", []], ["_reverseFill", false]];
|
|
|
|
TRACE_5("loadPerson",_caller,_unit,_vehicle,_preferredSeats,_reverseFill);
|
2015-01-16 23:21:47 +00:00
|
|
|
|
2019-09-05 20:56:53 +00:00
|
|
|
if (!([_caller, _unit, ["isNotDragging", "isNotCarrying", "isNotSwimming"]] call FUNC(canInteractWith)) || {_caller == _unit}) exitWith { objNull };
|
2015-01-16 23:21:47 +00:00
|
|
|
|
2017-09-29 20:00:47 +00:00
|
|
|
// Try to use nearest vehicle if a vehicle hasn't been supplied
|
|
|
|
if (isNull _vehicle) then {
|
|
|
|
_vehicle = ([_unit] call FUNC(nearestVehiclesFreeSeat)) param [0, objNull];
|
|
|
|
};
|
2015-09-18 16:28:19 +00:00
|
|
|
|
2015-01-16 23:21:47 +00:00
|
|
|
if (!isNull _vehicle) then {
|
2021-10-10 14:26:36 +00:00
|
|
|
switch (true) do {
|
|
|
|
case ((crew _vehicle isEqualTo []) && {side group _caller != side group _unit}): {
|
|
|
|
[_unit, true, GROUP_SWITCH_ID, side group _caller] call FUNC(switchToGroupSide);
|
|
|
|
};
|
|
|
|
case (side group _vehicle != side group _unit): {
|
|
|
|
[_unit, true, GROUP_SWITCH_ID, side group _vehicle] call FUNC(switchToGroupSide);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-02-17 17:14:39 +00:00
|
|
|
TRACE_5("sending ace_loadPersonEvent",_unit,_vehicle,_caller,_preferredSeats,_reverseFill);
|
|
|
|
["ace_loadPersonEvent", [_unit, _vehicle, _caller, _preferredSeats, _reverseFill], _unit] call CBA_fnc_targetEvent;
|
2015-01-16 23:21:47 +00:00
|
|
|
};
|
2015-09-18 16:28:19 +00:00
|
|
|
|
|
|
|
_vehicle
|