ACE3/addons/common/functions/fnc_unloadPerson.sqf

45 lines
1.1 KiB
Plaintext
Raw Normal View History

/*
* Author: Glowbal
* Unload a person from a vehicle
2015-01-16 23:21:47 +00:00
*
* Arguments:
* 0: unit <OBJECT>
*
* Return Value:
* Returns true if succesfully unloaded person <BOOL>
*
* Public: No
2015-01-16 23:21:47 +00:00
*/
#include "script_component.hpp"
#define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson))
2015-01-16 23:21:47 +00:00
2015-05-14 18:06:06 +00:00
private ["_vehicle", "_loaded", "_emptyPos"];
PARAMS_1(_unit);
2015-01-16 23:21:47 +00:00
_vehicle = vehicle _unit;
if (_vehicle == _unit) exitwith {false;};
if !(speed _vehicle <1 && (((getpos _vehicle) select 2) < 2)) exitwith {false;};
_emptyPos = ((getPos _vehicle) findEmptyPosition [0, 10, typeof _unit]);
if (count _emptyPos == 0) exitwith {false};
_unit setPos _emptyPos;
2015-01-16 23:21:47 +00:00
unassignVehicle _unit;
if (!alive _unit) then {
2015-01-18 19:09:19 +00:00
_unit action ["Eject", vehicle _unit];
2015-01-16 23:21:47 +00:00
};
[_unit, false, GROUP_SWITCH_ID, side group _unit] call FUNC(switchToGroupSide);
2015-01-16 23:21:47 +00:00
_loaded = _vehicle getvariable [QGVAR(loaded_persons),[]];
2015-01-16 23:21:47 +00:00
_loaded = _loaded - [_unit];
_vehicle setvariable [QGVAR(loaded_persons),_loaded,true];
2015-01-16 23:21:47 +00:00
if (!([_unit] call FUNC(isAwake))) then {
[_unit,([_unit] call FUNC(getDeathAnim)), 1, true] call FUNC(doAnimation);
2015-01-16 23:21:47 +00:00
};
true;