diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index 065086c9cb..b896ddfcda 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -12,5 +12,12 @@ PREP(handleFractures); PREP(handleInternalInjuries); PREP(init); PREP(selectionNameToNumber); +PREP(handleDamage_wounds); +PREP(handleUnitVitals); +PREP(getBloodLoss); +PREP(getBloodPressure); +PREP(getBloodVolumeChange); +PREP(getCardiacOutput); +PREP(setCardiacArrest); ADDON = true; diff --git a/addons/medical/functions/fnc_handleUnitVitals.sqf b/addons/medical/functions/fnc_handleUnitVitals.sqf index 745d4bb28d..063dda629b 100644 --- a/addons/medical/functions/fnc_handleUnitVitals.sqf +++ b/addons/medical/functions/fnc_handleUnitVitals.sqf @@ -93,12 +93,12 @@ if ((missionNamespace getvariable[QGVAR(setting_AdvancedLevel), 0]) > 0) exitwit // Check vitals for medical status // TODO check for in revive state instead of variable // TODO Implement cardiac arrest. -/* _bloodPressureL = _bloodPressure select 0; + _bloodPressureL = _bloodPressure select 0; _bloodPressureH = _bloodPressure select 1; if (!(_unit getvariable [QGVAR(inCardiacArrest),false])) then { if (_heartRate < 10 || _bloodPressureH < 30 || _bloodVolume < 20) then { - [_unit] call FUNC(setUnconsciousState); // safety check to ensure unconsciousness for units if they are not dead already. + //[_unit] call FUNC(setUnconsciousState); // safety check to ensure unconsciousness for units if they are not dead already. }; if (_bloodPressureH > 260) then { @@ -123,5 +123,5 @@ if ((missionNamespace getvariable[QGVAR(setting_AdvancedLevel), 0]) > 0) exitwit if (_heartRate < 20) then { [_unit] call FUNC(setCardiacArrest); }; - };*/ + }; }; diff --git a/addons/medical/functions/fnc_setCardiacArrest.sqf b/addons/medical/functions/fnc_setCardiacArrest.sqf new file mode 100644 index 0000000000..f23d269d8f --- /dev/null +++ b/addons/medical/functions/fnc_setCardiacArrest.sqf @@ -0,0 +1,46 @@ +/** + * fn_setCardiacArrest.sqf + * @Descr: Triggers a unit into the Cardiac Arrest state from CMS. Will put the unit in an unconscious state and run a countdown timer until unit dies.
Timer is a random value between 120 and 720 seconds. + * @Author: Glowbal + * + * @Arguments: [unit OBJECT (The unit that will be put in cardiac arrest state)] + * @Return: void + * @PublicAPI: true + */ + +#include "script_component.hpp" + +private ["_unit", "_modifier","_timer","_counter", "_heartRate"]; +_unit = _this select 0; + +if (_unit getvariable [QGVAR(inCardiacArrest),false]) exitwith {}; +_unit setvariable [QGVAR(inCardiacArrest), true,true]; +_unit setvariable [QGVAR(heartRate), 0]; + +["Medical_onEnteredCardiacArrest", [_unit]] call ace_common_fnc_localEvent; + +//[_unit] call FUNC(setUnconsciousState); +_counter = 120 + round(random(600)); +_timer = 0; + +[{ + private ["_args","_unit","_timer","_counter","_heartRate"]; + _args = _this select 0; + _unit = _args select 0; + _timer = _args select 1; + _counter = _args select 2; + + _heartRate = _unit getvariable [QGVAR(heartRate), 0]; + if (_heartRate > 0 || !alive _unit) exitwith { + _unit setvariable [QGVAR(inCardiacArrest), nil,true]; + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; + if (_counter - _timer < 1) exitwith { + + //[_unit] call FUNC(setDead); + [(_this select 1)] call cba_fnc_removePerFrameHandler; + _unit setvariable [QGVAR(inCardiacArrest), nil,true]; + }; + _args set[1, _timer + 1]; +}, 1, [_unit, _timer, _counter] ] call CBA_fnc_addPerFrameHandler; +