2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-05-25 16:41:24 +00:00
|
|
|
/*
|
|
|
|
* Author: ViperMaul
|
|
|
|
* Unload a person from a vehicle, local
|
|
|
|
*
|
|
|
|
* Arguments:
|
2017-09-22 15:33:08 +00:00
|
|
|
* 0: Unit to unload <OBJECT>
|
2016-01-27 00:01:01 +00:00
|
|
|
* 1: Vehicle <OBJECT>
|
2017-09-22 15:33:08 +00:00
|
|
|
* 2: Unloader (player) <OBJECT> (default: objNull)
|
2015-05-25 16:41:24 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2017-09-22 15:33:08 +00:00
|
|
|
* Succesfully unloaded person <BOOL>
|
2015-05-25 16:41:24 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [bob, car, bob] call ace_common_fnc_unloadpersonLocal
|
|
|
|
*
|
2015-05-25 16:41:24 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2016-04-08 18:43:26 +00:00
|
|
|
#define GROUP_SWITCH_ID QFUNC(loadPerson)
|
2015-05-25 16:41:24 +00:00
|
|
|
|
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 {
|
2016-10-02 10:55:31 +00:00
|
|
|
WARNING_4("Could not find unload pos %1-ASL: %2 isTouchingGround: %3 Speed: %4",_vehicle, getPosASL _vehicle, isTouchingGround _vehicle, speed _vehicle);
|
2016-01-27 00:01:01 +00:00
|
|
|
if ((!isNull _unloader) && {[_unloader] call FUNC(isPlayer)}) then {
|
|
|
|
//display text saying there are no safe places to exit the vehicle
|
2016-06-04 10:12:56 +00:00
|
|
|
[QGVAR(displayTextStructured), [localize LSTRING(NoRoomToUnload)], [_unloader]] call CBA_fnc_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
|
|
|
|
2017-09-26 22:45:10 +00:00
|
|
|
private _resetUncon = false;
|
|
|
|
if (lifeState _unit == "INCAPACITATED") then {
|
|
|
|
_resetUncon = true;
|
|
|
|
_unit setUnconscious false;
|
|
|
|
TRACE_1("pausing setUnconscious",_unit);
|
|
|
|
};
|
2015-09-18 17:12:38 +00:00
|
|
|
|
2017-09-26 22:45:10 +00:00
|
|
|
TRACE_1("Ejecting", alive _unit);
|
2015-06-11 22:56:11 +00:00
|
|
|
_unit action ["Eject", vehicle _unit];
|
2015-09-18 17:12:38 +00:00
|
|
|
|
|
|
|
[{
|
2017-09-26 22:45:10 +00:00
|
|
|
params ["_unit", "_emptyPos", "_resetUncon"];
|
|
|
|
|
|
|
|
if ((vehicle _unit) != _unit) then {
|
|
|
|
WARNING_2("Failed to unload in time [%1 - %2]",_unit, vehicle _unit);
|
|
|
|
};
|
2015-09-18 17:12:38 +00:00
|
|
|
|
|
|
|
_unit setPosASL AGLToASL _emptyPos;
|
|
|
|
|
2017-09-26 22:45:10 +00:00
|
|
|
if (_resetUncon) then {
|
|
|
|
TRACE_1("resuming setUnconscious",_unit);
|
|
|
|
// This should reset the unit to an Unconscious animation
|
|
|
|
// Also has the hilarious effect of violently ragdolling the guy
|
|
|
|
_unit setUnconscious true;
|
2015-09-25 09:15:25 +00:00
|
|
|
};
|
2017-09-26 22:45:10 +00:00
|
|
|
|
|
|
|
// ToDo [medical-rewrite]: verify we can remove the following commented code
|
|
|
|
|
|
|
|
// if !([_unit] call FUNC(isAwake)) then {
|
|
|
|
// TRACE_1("Check if isAwake", [_unit] call FUNC(isAwake));
|
|
|
|
|
|
|
|
// if (driver _unit == _unit) then {
|
|
|
|
// private _anim = [_unit] call FUNC(getDeathAnim);
|
|
|
|
|
|
|
|
// [_unit, _anim, 1, true] call FUNC(doAnimation);
|
|
|
|
|
|
|
|
// [{
|
|
|
|
// params ["_unit", "_anim"];
|
|
|
|
// if ((_unit getVariable "ACE_isUnconscious") and (animationState _unit != _anim)) then {
|
|
|
|
// [_unit, _anim, 2, true] call FUNC(doAnimation);
|
|
|
|
// };
|
|
|
|
// }, [_unit, _anim], 0.5] call CBA_fnc_waitAndExecute;
|
|
|
|
// };
|
|
|
|
// };
|
|
|
|
}, [_unit, _emptyPos, _resetUncon], 0.5] call CBA_fnc_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
|