Merge pull request #1389 from acemod/possibleFixMedicalUnloadPatient

Possible fix medical unload patient
This commit is contained in:
Glowbal 2015-05-27 19:34:23 +02:00
commit 7dd01ebb69
4 changed files with 51 additions and 24 deletions

View File

@ -180,6 +180,7 @@ PREP(toHex);
PREP(toNumber);
PREP(uniqueElementsOnly);
PREP(unloadPerson);
PREP(unloadPersonLocal);
PREP(unmuteUnit);
PREP(useItem);
PREP(useMagazine);

View File

@ -10,12 +10,12 @@
*
* Public: No
*/
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
#define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson))
private ["_vehicle", "_loaded", "_emptyPos"];
private ["_vehicle","_emptyPos"];
PARAMS_1(_unit);
_vehicle = vehicle _unit;
@ -25,20 +25,8 @@ 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);
if (!isNull _vehicle) then {
[[_unit], QUOTE(FUNC(unloadPersonLocal)), _unit, false] call EFUNC(common,execRemoteFnc);
};
true;

View File

@ -0,0 +1,44 @@
/*
* Author: ViperMaul
* Unload a person from a vehicle, local
*
* Arguments:
* 0: unit <OBJECT>
*
* Return Value:
* Returns true if succesfully unloaded person <BOOL>
*
* 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;

View File

@ -22,12 +22,6 @@ _drag = if (count _this > 2) then {_this select 2} else {false};
// cannot unload a unit not in a vehicle.
if (vehicle _target == _target) exitwith {};
if (([_target] call cse_fnc_isAwake)) exitwith {};
if (([_target] call EFUNC(common,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
};
};
};
[_target] call EFUNC(common,unloadPerson)