diff --git a/addons/medical/ACE_Settings.hpp b/addons/medical/ACE_Settings.hpp index a23e269000..a57bc43dff 100644 --- a/addons/medical/ACE_Settings.hpp +++ b/addons/medical/ACE_Settings.hpp @@ -64,4 +64,8 @@ class ACE_Settings { typeName = "BOOL"; value = false; }; + class GVAR(maxReviveTime) { + typeName = "NUMBER"; + value = 120; + }; }; diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index 267577c0a2..6a83cfae80 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -219,7 +219,7 @@ if (isNil QGVAR(level)) then { }, 0, []] call CBA_fnc_addPerFrameHandler; // broadcast injuries to JIP clients in a MP session -if (isMultiplayer && !isDedicated) then { +if (isMultiplayer) then { [QGVAR(onPlayerConnected), "onPlayerConnected", { if (isNil QGVAR(InjuredCollection)) then { GVAR(InjuredCollection) = []; @@ -234,3 +234,11 @@ if (isMultiplayer && !isDedicated) then { }foreach GVAR(InjuredCollection); }, []] call BIS_fnc_addStackedEventHandler; }; + + +[ + {(((_this select 0) getvariable [QGVAR(bloodVolume), 0]) < 65)}, + {(((_this select 0) getvariable [QGVAR(pain), 0]) > 48)}, + {(((_this select 0) call FUNC(getBloodLoss)) > 0.25)}, + {((_this select 0) getvariable [QGVAR(inReviveState), false])} +] call FUNC(registerUnconsciousCondition); diff --git a/addons/medical/functions/fnc_setDead.sqf b/addons/medical/functions/fnc_setDead.sqf index 69ce88c86f..2d72c31c93 100644 --- a/addons/medical/functions/fnc_setDead.sqf +++ b/addons/medical/functions/fnc_setDead.sqf @@ -25,8 +25,27 @@ if (!local _unit) exitwith { [[_unit, _force], QUOTE(DFUNC(setDead)), _unit, false] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ }; -if (missionNamespace getVariable [QGVAR(enableRevive), false]) exitwith { - // TODO Implement the revive state +if (GVAR(preventInstaDeath) && !_force) exitwith { + if (_unit getvariable [QGVAR(inReviveState), false]) exitwith {}; // already in revive state + _unit setvariable [QGVAR(inReviveState), true, true]; + [_unit] call FUNC(setUnconscious); + + [{ + private ["_args","_unit","_startTime"]; + _args = _this select 0; + _unit = _args select 0; + _startTime = _args select 1; + + if (time - _startTime > GVAR(maxReviveTime)) exitwith { + [(_this select 1)] call cba_fnc_removePerFrameHandler; + [_unit, true] call FUNC(setDead); + _unit setvariable [QGVAR(inReviveState), nil, true]; + }; + + if !(_unit getvariable [QGVAR(inReviveState), false]) exitwith { + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; + }, 1, [_unit, time] ] call CBA_fnc_addPerFrameHandler; }; _unit setvariable ["ACE_isDead", true, true];