2015-05-25 16:41:24 +00:00
|
|
|
/*
|
|
|
|
* Author: ViperMaul
|
|
|
|
* Unload a person from a vehicle, local
|
|
|
|
*
|
|
|
|
* Arguments:
|
2016-01-27 00:01:01 +00:00
|
|
|
* 0: unit to unload <OBJECT>
|
|
|
|
* 1: Vehicle <OBJECT>
|
|
|
|
* 2: Unloader (player) <OBJECT><OPTIONAL>
|
2015-05-25 16:41:24 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Returns true if succesfully unloaded person <BOOL>
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
#define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson))
|
|
|
|
|
2016-01-27 00:01:01 +00:00
|
|
|
params ["_unit", "_vehicle", ["_unloader", objNull]];
|
|
|
|
TRACE_3("params",_unit,_vehicle,_unloader);
|
2015-09-18 17:12:38 +00:00
|
|
|
|
2016-01-27 00:01:01 +00:00
|
|
|
//This covers testing vehicle stability and finding a safe position
|
|
|
|
private _emptyPos = [_vehicle, (typeOf _unit), _unloader] call EFUNC(common,findUnloadPosition);
|
|
|
|
TRACE_1("findUnloadPosition",_emptyPos);
|
2015-05-25 16:41:24 +00:00
|
|
|
|
2016-01-27 00:01:01 +00:00
|
|
|
if (count _emptyPos != 3) exitwith {
|
|
|
|
ACE_LOGWARNING_4("Could not find unload pos %1-ASL: %2 isTouchingGround: %3 Speed: %4",_vehicle, getPosASL _vehicle, isTouchingGround _vehicle, speed _vehicle);
|
|
|
|
if ((!isNull _unloader) && {[_unloader] call FUNC(isPlayer)}) then {
|
|
|
|
//display text saying there are no safe places to exit the vehicle
|
|
|
|
["displayTextStructured", [_unloader], [localize LSTRING(NoRoomToUnload)]] call FUNC(targetEvent);
|
2015-09-18 17:12:38 +00:00
|
|
|
};
|
2015-08-26 13:20:11 +00:00
|
|
|
false
|
|
|
|
};
|
2015-06-23 23:11:00 +00:00
|
|
|
|
2015-05-25 16:41:24 +00:00
|
|
|
unassignVehicle _unit;
|
2015-06-11 22:56:11 +00:00
|
|
|
[_unit] orderGetIn false;
|
2015-09-18 17:12:38 +00:00
|
|
|
|
2015-06-11 22:56:11 +00:00
|
|
|
TRACE_1("Ejecting", alive _unit);
|
2015-09-18 17:12:38 +00:00
|
|
|
|
2015-06-11 22:56:11 +00:00
|
|
|
_unit action ["Eject", vehicle _unit];
|
2015-09-18 17:12:38 +00:00
|
|
|
|
|
|
|
[{
|
|
|
|
params ["_unit", "_emptyPos"];
|
|
|
|
|
|
|
|
_unit setPosASL AGLToASL _emptyPos;
|
|
|
|
|
2015-09-25 09:15:25 +00:00
|
|
|
if !([_unit] call FUNC(isAwake)) then {
|
2015-06-12 23:56:13 +00:00
|
|
|
TRACE_1("Check if isAwake", [_unit] call FUNC(isAwake));
|
2015-09-18 17:12:38 +00:00
|
|
|
|
2015-06-12 23:56:13 +00:00
|
|
|
if (driver _unit == _unit) then {
|
2015-12-14 12:08:19 +00:00
|
|
|
private _anim = [_unit] call FUNC(getDeathAnim);
|
2015-09-18 17:12:38 +00:00
|
|
|
|
|
|
|
[_unit, _anim, 1, true] call FUNC(doAnimation);
|
|
|
|
|
2015-06-12 23:56:13 +00:00
|
|
|
[{
|
|
|
|
_unit = _this select 0;
|
|
|
|
_anim = _this select 1;
|
|
|
|
if ((_unit getVariable "ACE_isUnconscious") and (animationState _unit != _anim)) then {
|
2015-09-18 17:12:38 +00:00
|
|
|
[_unit, _anim, 2, true] call FUNC(doAnimation);
|
2015-06-12 23:56:13 +00:00
|
|
|
};
|
2016-01-27 00:01:01 +00:00
|
|
|
}, [_unit, _anim], 0.5] call FUNC(waitAndExecute);
|
2015-06-12 23:56:13 +00:00
|
|
|
};
|
2015-09-25 09:15:25 +00:00
|
|
|
};
|
2016-01-27 00:01:01 +00:00
|
|
|
}, [_unit, _emptyPos], 0.5] call FUNC(waitAndExecute);
|
2015-05-25 16:41:24 +00:00
|
|
|
|
|
|
|
[_unit, false, GROUP_SWITCH_ID, side group _unit] call FUNC(switchToGroupSide);
|
|
|
|
|
2016-01-27 00:01:01 +00:00
|
|
|
private _loaded = _vehicle getvariable [QGVAR(loaded_persons),[]];
|
2015-09-18 17:12:38 +00:00
|
|
|
_loaded deleteAt (_loaded find _unit);
|
|
|
|
|
2016-01-27 00:01:01 +00:00
|
|
|
_vehicle setvariable [QGVAR(loaded_persons), _loaded, true];
|
2015-05-25 16:41:24 +00:00
|
|
|
|
2015-08-26 13:20:11 +00:00
|
|
|
true
|