2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-09-18 16:28:19 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Load a person, local
|
2015-01-16 23:21:47 +00:00
|
|
|
*
|
2015-09-18 16:28:19 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: unit to be loaded <OBJECT>
|
|
|
|
* 1: vehicle that will beloaded <OBJECT>
|
|
|
|
* 2: caller that will load <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [bob, car, kevin] call ace_common_fnc_loadPersonLocal
|
|
|
|
*
|
2015-09-18 16:28:19 +00:00
|
|
|
* Public: Yes
|
2015-01-16 23:21:47 +00:00
|
|
|
*/
|
|
|
|
|
2015-09-18 16:28:19 +00:00
|
|
|
params ["_unit", "_vehicle", "_caller"];
|
2015-01-16 23:21:47 +00:00
|
|
|
|
2017-12-11 19:10:30 +00:00
|
|
|
// if (!alive _unit) then {
|
|
|
|
// _unit = [_unit, _caller] call makeCopyOfBody; //func does not exist
|
|
|
|
// };
|
2015-01-16 23:21:47 +00:00
|
|
|
|
2015-12-12 15:48:54 +00:00
|
|
|
private _slotsOpen = false;
|
2015-07-27 01:20:36 +00:00
|
|
|
|
|
|
|
if (_vehicle emptyPositions "cargo" > 0) then {
|
|
|
|
_unit moveInCargo _vehicle;
|
|
|
|
_slotsOpen = true;
|
2015-01-16 23:21:47 +00:00
|
|
|
} else {
|
2015-07-27 01:20:36 +00:00
|
|
|
if (_vehicle emptyPositions "gunner" > 0) then {
|
|
|
|
_unit moveInGunner _vehicle;
|
|
|
|
_slotsOpen = true;
|
|
|
|
};
|
|
|
|
};
|
2015-01-16 23:21:47 +00:00
|
|
|
|
2015-07-27 01:20:36 +00:00
|
|
|
if (_slotsOpen) then {
|
2015-12-12 15:48:54 +00:00
|
|
|
private _loaded = _vehicle getVariable [QGVAR(loaded_persons),[]];
|
2015-09-18 16:28:19 +00:00
|
|
|
_loaded pushBack _unit;
|
|
|
|
|
|
|
|
_vehicle setVariable [QGVAR(loaded_persons), _loaded, true];
|
|
|
|
|
2015-09-25 09:15:25 +00:00
|
|
|
if !([_unit] call FUNC(isAwake)) then {
|
2015-09-18 16:28:19 +00:00
|
|
|
[{
|
|
|
|
(_this select 0) params ["_unit", "_vehicle"];
|
|
|
|
|
|
|
|
// wait until the unit is in the vehicle
|
|
|
|
if (vehicle _unit != _vehicle) exitWith {
|
|
|
|
// kill this pfh if either one is deleted
|
|
|
|
if (isNull _unit || isNull _vehicle) then {
|
|
|
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
|
|
|
};
|
2015-07-27 01:20:36 +00:00
|
|
|
};
|
|
|
|
|
2015-09-18 16:28:19 +00:00
|
|
|
_unit setVariable [QEGVAR(medical,vehicleAwakeAnim), [_vehicle, animationState _unit]];
|
|
|
|
|
|
|
|
[_unit, [_unit] call FUNC(getDeathAnim), 1, true] call FUNC(doAnimation);
|
|
|
|
|
|
|
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
|
|
|
}, 0.5, [_unit, _vehicle]] call CBA_fnc_addPerFrameHandler;
|
2015-09-25 09:15:25 +00:00
|
|
|
};
|
2015-09-18 16:28:19 +00:00
|
|
|
};
|