2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2019-06-28 00:01:20 +00:00
|
|
|
/*
|
|
|
|
* Author: BaerMitUmlaut
|
|
|
|
* Handles the unconscious state
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The Unit <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player] call ace_medical_statemachine_fnc_handleStateCardiacArrest
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_unit"];
|
|
|
|
|
|
|
|
// If the unit died the loop is finished
|
2022-03-07 18:28:51 +00:00
|
|
|
if (!alive _unit || {!local _unit}) exitWith {};
|
2019-06-28 00:01:20 +00:00
|
|
|
|
|
|
|
[_unit] call EFUNC(medical_vitals,handleUnitVitals);
|
|
|
|
|
|
|
|
private _timeDiff = CBA_missionTime - (_unit getVariable [QGVAR(cardiacArrestTimeLastUpdate), 0]);
|
|
|
|
if (_timeDiff >= 1) then {
|
|
|
|
_timeDiff = _timeDiff min 10;
|
|
|
|
_unit setVariable [QGVAR(cardiacArrestTimeLastUpdate), CBA_missionTime];
|
|
|
|
private _recieveingCPR = alive (_unit getVariable [QEGVAR(medical,CPR_provider), objNull]);
|
|
|
|
private _timeLeft = _unit getVariable [QGVAR(cardiacArrestTimeLeft), -1];
|
|
|
|
TRACE_3("cardiac arrest life tick",_unit,_recieveingCPR,_timeDiff);
|
|
|
|
if (_recieveingCPR) then { _timeDiff = _timeDiff * 0.5; }; // if being cpr'ed, then time decrease is reduced
|
|
|
|
_timeLeft = _timeLeft - _timeDiff; // negative values are fine
|
|
|
|
_unit setVariable [QGVAR(cardiacArrestTimeLeft), _timeLeft];
|
|
|
|
};
|