diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index a9476a3765..d22e88ba15 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -180,6 +180,7 @@ PREP(toHex); PREP(toNumber); PREP(uniqueElementsOnly); PREP(unloadPerson); +PREP(unloadPersonLocal); PREP(unmuteUnit); PREP(useItem); PREP(useMagazine); diff --git a/addons/common/functions/fnc_unloadPersonLocal.sqf b/addons/common/functions/fnc_unloadPersonLocal.sqf new file mode 100644 index 0000000000..2dc1331b9d --- /dev/null +++ b/addons/common/functions/fnc_unloadPersonLocal.sqf @@ -0,0 +1,44 @@ +/* + * Author: ViperMaul + * Unload a person from a vehicle, local + * + * Arguments: + * 0: unit + * + * Return Value: + * Returns true if succesfully unloaded person + * + * Public: No + */ +#define DEBUG_MODE_FULL +#include "script_component.hpp" + +#define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson)) + +private ["_vehicle", "_loaded", "_emptyPos"]; +PARAMS_1(_unit); +_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; +unassignVehicle _unit; +if (!alive _unit) then { + _unit action ["Eject", vehicle _unit]; +}; + +[_unit, false, GROUP_SWITCH_ID, side group _unit] call FUNC(switchToGroupSide); + +_loaded = _vehicle getvariable [QGVAR(loaded_persons),[]]; +_loaded = _loaded - [_unit]; +_vehicle setvariable [QGVAR(loaded_persons),_loaded,true]; + +if (!([_unit] call FUNC(isAwake))) then { + [_unit,([_unit] call FUNC(getDeathAnim)), 1, true] call FUNC(doAnimation); +}; + +true; diff --git a/addons/medical/functions/fnc_actionUnloadUnit.sqf b/addons/medical/functions/fnc_actionUnloadUnit.sqf index bb66147f2a..4bcdacf6e7 100644 --- a/addons/medical/functions/fnc_actionUnloadUnit.sqf +++ b/addons/medical/functions/fnc_actionUnloadUnit.sqf @@ -27,7 +27,7 @@ if (([_target] call cse_fnc_isAwake)) exitwith {}; if ([_target] call EFUNC(common,unloadPerson)) then { if (_drag) then { if ((vehicle _caller) == _caller) then { - [[_caller, _target, true], QUOTE(DFUNC(actionDragUnit)), _caller, false] call EFUNC(common,execRemoteFnc); // TODO replace by event + [[_caller, _target], QUOTE(EFUNC(common,unloadPerson)), _caller, false] call EFUNC(common,execRemoteFnc); // TODO replace by event }; }; };