ACE3/addons/common/functions/fnc_loadPersonLocal.sqf

64 lines
1.6 KiB
Plaintext
Raw Normal View History

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
*
* Public: Yes
2015-01-16 23:21:47 +00:00
*/
#include "script_component.hpp"
2015-09-18 16:28:19 +00:00
params ["_unit", "_vehicle", "_caller"];
2015-01-16 23:21:47 +00:00
if (!alive _unit) then {
2015-09-18 19:24:20 +00:00
// _unit = [_unit, _caller] call FUNC(makeCopyOfBody); //func does not exist
2015-01-16 23:21:47 +00:00
};
2015-09-18 16:28:19 +00:00
private "_slotsOpen";
_slotsOpen = false;
if (_vehicle emptyPositions "cargo" > 0) then {
_unit moveInCargo _vehicle;
_slotsOpen = true;
2015-01-16 23:21:47 +00:00
} else {
if (_vehicle emptyPositions "gunner" > 0) then {
_unit moveInGunner _vehicle;
_slotsOpen = true;
};
};
2015-01-16 23:21:47 +00:00
if (_slotsOpen) then {
2015-09-18 16:28:19 +00:00
private "_loaded";
_loaded = _vehicle getVariable [QGVAR(loaded_persons),[]];
_loaded pushBack _unit;
_vehicle setVariable [QGVAR(loaded_persons), _loaded, true];
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-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-18 16:28:19 +00:00
};