mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Medical Engine - Fix unloading dead units in vehicles and handle deleted units vehicles (#9283)
* Medical Engine - Unlock when dead
* Update fnc_unloadPersonLocal.sqf
* Update addons/common/functions/fnc_unloadPersonLocal.sqf
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
* fix actually unloading people to found emptyPos
* handle deleted units
* handle dead units
ref 179957c39d
* vehicle -> objectParent
---------
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
This commit is contained in:
parent
6bc1ae453b
commit
6fb9161ecc
@ -19,7 +19,7 @@
|
||||
|
||||
#define GROUP_SWITCH_ID QFUNC(loadPerson)
|
||||
|
||||
params ["_unit", "_vehicle", ["_unloader", objNull]];
|
||||
params ["_unit", ["_vehicle", objNull], ["_unloader", objNull]];
|
||||
TRACE_3("unloadpersonLocal",_unit,_vehicle,_unloader);
|
||||
|
||||
//This covers testing vehicle stability and finding a safe position
|
||||
@ -46,16 +46,20 @@ if (count _emptyPos != 3) exitwith {
|
||||
unassignVehicle _unit;
|
||||
[_unit] orderGetIn false;
|
||||
|
||||
TRACE_1("Ejecting", alive _unit);
|
||||
private _vehicle = vehicle _unit;
|
||||
TRACE_2("Ejecting",alive _unit,local _vehicle);
|
||||
|
||||
if (local _vehicle) then {
|
||||
_unit action ["Eject", _vehicle];
|
||||
// Failsafe - sometimes eject alone doesn't work, but moveOut does
|
||||
[{
|
||||
params ["_unit"];
|
||||
|
||||
if (vehicle _unit != _unit) then {
|
||||
WARNING_1("UnloadPersonLocal [%1] did not eject normally",_unit);
|
||||
if (!isNull objectParent _unit) then {
|
||||
if ([_unit] call FUNC(isAwake)) then {
|
||||
WARNING_1("UnloadPersonLocal [%1] did not eject normally",_unit);
|
||||
} else {
|
||||
TRACE_1("UnloadPersonLocal dead/uncon did not eject normally",_unit);
|
||||
};
|
||||
moveOut _unit;
|
||||
};
|
||||
}, [_unit], 1] call CBA_fnc_waitAndExecute;
|
||||
@ -64,18 +68,21 @@ if (local _vehicle) then {
|
||||
moveOut _unit;
|
||||
};
|
||||
|
||||
[{
|
||||
params ["_unit", "_emptyPos"];
|
||||
(alive _unit) && {(vehicle _unit) != _unit}
|
||||
}, {
|
||||
params ["_unit", "_emptyPos"];
|
||||
TRACE_2("success",_unit,_emptyPos);
|
||||
_unit setPosASL AGLToASL _emptyPos;
|
||||
}, [_unit, _emptyPos], 2, {
|
||||
params ["_unit", "_emptyPos"];
|
||||
if (!alive _unit) exitWith {};
|
||||
WARNING_2("timeout %1->%2",_unit,vehicle _unit);
|
||||
}] call CBA_fnc_waitUntilAndExecute;
|
||||
// Wait until unit has actually exited vehicle and then move them to the unload position
|
||||
if (alive _unit) then {
|
||||
[{
|
||||
params ["_unit", "_emptyPos"];
|
||||
(alive _unit) && {isNull objectParent _unit}
|
||||
}, {
|
||||
params ["_unit", "_emptyPos"];
|
||||
TRACE_2("unload success",_unit,_emptyPos);
|
||||
_unit setPosASL AGLToASL _emptyPos;
|
||||
}, [_unit, _emptyPos], 2, {
|
||||
params ["_unit", "_emptyPos"];
|
||||
if (!alive _unit) exitWith {};
|
||||
WARNING_2("timeout %1->%2",_unit,objectParent _unit);
|
||||
}] call CBA_fnc_waitUntilAndExecute;
|
||||
};
|
||||
|
||||
[_unit, false, GROUP_SWITCH_ID, side group _unit] call FUNC(switchToGroupSide);
|
||||
|
||||
|
@ -85,8 +85,8 @@
|
||||
|
||||
["ace_unconscious", {
|
||||
params ["_unit", "_unconscious"];
|
||||
|
||||
if (vehicle _unit != _unit && {local vehicle _unit}) then {
|
||||
TRACE_3("unit uncon",_unit,objectParent _unit,local _unit);
|
||||
if (!isNull objectParent _unit && {local objectParent _unit}) then {
|
||||
if (_unconscious) then {
|
||||
[_unit] call FUNC(lockUnconsciousSeat);
|
||||
} else {
|
||||
@ -94,3 +94,19 @@
|
||||
};
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
["ace_killed", { // global event
|
||||
params ["_unit"];
|
||||
TRACE_3("unit Killed",_unit,objectParent _unit,local _unit);
|
||||
if (!isNull objectParent _unit && {local objectParent _unit}) exitWith {
|
||||
[_unit] call FUNC(lockUnconsciousSeat);
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
["CAManBase", "deleted", {
|
||||
params ["_unit"];
|
||||
TRACE_3("unit deleted",_unit,objectParent _unit,local _unit);
|
||||
if ((!isNull objectParent _unit) && {local objectParent _unit}) then {
|
||||
[_unit] call FUNC(unlockUnconsciousSeat);
|
||||
};
|
||||
}, true, []] call CBA_fnc_addClassEventHandler;
|
||||
|
@ -11,10 +11,13 @@
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
if (missionNamespace getVariable [QGVAR(disableSeatLocking), false]) exitWith {};
|
||||
params ["_unit"];
|
||||
|
||||
private _vehicle = objectParent _unit;
|
||||
TRACE_3("lockUnconsciousSeat",_unit,_vehicle,lifeState _unit);
|
||||
|
||||
if (isNull _vehicle) exitWith {};
|
||||
if (alive _unit && {lifeState _unit != "INCAPACITATED"}) exitWith {};
|
||||
|
||||
switch (true) do {
|
||||
@ -35,3 +38,4 @@ switch (true) do {
|
||||
_unit setVariable [QGVAR(lockedSeat), [_vehicle, "turret", _turretPath], true];
|
||||
};
|
||||
};
|
||||
TRACE_1("locked",_unit getVariable QGVAR(lockedSeat));
|
||||
|
@ -16,6 +16,7 @@ params ["_unit"];
|
||||
private _seat = _unit getVariable [QGVAR(lockedSeat), []];
|
||||
_seat params ["_vehicle", "_type", "_position"];
|
||||
|
||||
TRACE_2("unlockUnconsciousSeat",_unit,_seat);
|
||||
if (_seat isEqualTo []) exitWith {};
|
||||
|
||||
switch (_type) do {
|
||||
|
Loading…
Reference in New Issue
Block a user