ACE3/addons/common/functions/fnc_unloadPerson.sqf

59 lines
1.9 KiB
Plaintext
Raw Normal View History

2015-01-16 23:21:47 +00:00
/**
* fn_unloadPerson_f.sqf
* @Descr: Unload a person from a vehicle
* @Author: Glowbal
*
* @Arguments: [caller OBJECT, unit OBJECT]
* @Return: BOOL Returns true if succesfully unloaded person
* @PublicAPI: true
*/
#include "script_component.hpp"
#define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson))
2015-01-16 23:21:47 +00:00
private ["_caller", "_unit","_vehicle", "_loaded"];
_caller = [_this, 0, ObjNull,[ObjNull]] call BIS_fnc_Param;
_unit = [_this, 1, ObjNull,[ObjNull]] call BIS_fnc_Param;
_vehicle = vehicle _unit;
if (_vehicle == _unit) exitwith {false;};
if !(speed _vehicle <1 && (((getpos _vehicle) select 2) < 2)) exitwith {false;};
if (!([_caller] call FUNC(isAwake))) exitwith{false;};
moveOut _unit;
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 _caller] 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 {
2015-01-18 19:09:19 +00:00
_handle = [_unit,_vehicle] spawn {
private ["_unit","_vehicle"];
_unit = _this select 0;
_vehicle = _this select 1;
waituntil {vehicle _unit != _vehicle};
[_unit,([_unit] call FUNC(getDeathAnim)), 1, true] call FUNC(doAnimation);
[format["Unit should move into death anim: %1", _unit]] call FUNC(debug);
};
2015-01-16 23:21:47 +00:00
} else {
2015-01-18 19:09:19 +00:00
if ([_unit] call FUNC(isArrested)) then {
_handle = [_unit,_vehicle] spawn {
_unit = _this select 0;
_vehicle = _this select 1;
waituntil {vehicle _unit != _vehicle};
[_unit,"UnaErcPoslechVelitele2", 1] call FUNC(doAnimation);
[format["Unit should move into arrested anim: %1", _unit]] call FUNC(debug);
};
} else {
[format["Unit should move into normal anim: %1", _unit]] call FUNC(debug);
};
2015-01-16 23:21:47 +00:00
};
true;