-
Notifications
You must be signed in to change notification settings - Fork 763
Expand file tree
/
Copy pathfnc_loadPerson.sqf
More file actions
54 lines (46 loc) · 1.95 KB
/
Copy pathfnc_loadPerson.sqf
File metadata and controls
54 lines (46 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "..\script_component.hpp"
/*
* Author: Glowbal
* Loads a specified unit into any nearby vehicle, or _vehicle parameter.
*
* Arguments:
* 0: Unit that will load <OBJECT>
* 1: Unit to be loaded <OBJECT>
* 2: Vehicle that the unit will be loaded in <OBJECT> (default: objNull)
* 3: Preferred seats <ARRAY> (default: [])
* 4: Reverse fill <BOOL> (default: false)
*
* Return Value:
* Vehicle that the unitToBeloaded has been loaded in. Returns objNull if function failed <OBJECT>
*
* Example:
* [bob, kevin] call ace_common_fnc_loadPerson
*
* Public: Yes
*/
#define GROUP_SWITCH_ID QFUNC(loadPerson)
params ["_caller", "_unit", ["_vehicle", objNull], ["_preferredSeats", []], ["_reverseFill", false]];
TRACE_5("loadPerson",_caller,_unit,_vehicle,_preferredSeats,_reverseFill);
if (!([_caller, _unit, ["isNotDragging", "isNotCarrying", "isNotSwimming"]] call FUNC(canInteractWith)) || {_caller == _unit}) exitWith { objNull };
// Try to use nearest vehicle if a vehicle hasn't been supplied
if (isNull _vehicle) then {
_vehicle = ([_unit] call FUNC(nearestVehiclesFreeSeat)) param [0, objNull];
};
if (isNull _vehicle) exitWith {objNull};
if (alive _unit) then {
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);
};
};
TRACE_5("sending ace_loadPersonEvent",_unit,_vehicle,_caller,_preferredSeats,_reverseFill);
["ace_loadPersonEvent", [_unit, _vehicle, _caller, _preferredSeats, _reverseFill], _unit] call CBA_fnc_targetEvent;
} else {
// vehicle must be local
TRACE_2("sending loadDeadPerson event",_unit,_vehicle);
[QGVAR(loadDeadPerson), [_unit, _vehicle], _vehicle] call CBA_fnc_targetEvent;
};
_vehicle