fixed cardiac arrest

This commit is contained in:
Glowbal 2015-04-04 21:20:03 +02:00
parent e3aaac7005
commit 93d9088410
2 changed files with 14 additions and 13 deletions

View File

@ -237,6 +237,7 @@ if (USE_WOUND_EVENT_SYNC) then {
{(((_this select 0) getvariable [QGVAR(pain), 0]) > 0.9)},
{(((_this select 0) call FUNC(getBloodLoss)) > 0.25)},
{((_this select 0) getvariable [QGVAR(inReviveState), false])},
{((_this select 0) getvariable [QGVAR(inCardiacArrest), false])},
{((_this select 0) getvariable ["ACE_isDead", false])},
{(((_this select 0) getvariable [QGVAR(airwayStatus), 100]) < 80)}
] call FUNC(addUnconsciousCondition);

View File

@ -14,7 +14,7 @@
#include "script_component.hpp"
private ["_unit", "_modifier","_timer","_counter", "_heartRate"];
private ["_unit", "_timeInCardiacArrest"];
_unit = _this select 0;
if (_unit getvariable [QGVAR(inCardiacArrest),false]) exitwith {};
@ -23,27 +23,27 @@ _unit setvariable [QGVAR(heartRate), 0];
["Medical_onEnteredCardiacArrest", [_unit]] call ace_common_fnc_localEvent;
[_unit] call FUNC(setUnconscious);
_counter = 120 + round(random(600));
_timer = 0;
[_unit, true] call FUNC(setUnconscious);
_timeInCardiacArrest = 120 + round(random(600));
systemChat format["Unit went cardiac arrest; hr: %1", _unit getvariable [QGVAR(heartRate), -1]];
[{
private ["_args","_unit","_timer","_counter","_heartRate"];
private ["_args","_unit","_startTime","_timeInCardiacArrest","_heartRate"];
_args = _this select 0;
_unit = _args select 0;
_timer = _args select 1;
_counter = _args select 2;
_startTime = _args select 1;
_timeInCardiacArrest = _args select 2;
_heartRate = _unit getvariable [QGVAR(heartRate), 0];
if (_heartRate > 0 || !alive _unit) exitwith {
_unit setvariable [QGVAR(inCardiacArrest), nil,true];
systemChat format["Unit no longer cardiac arrest; hr: %1", _unit getvariable [QGVAR(heartRate), -1]];
[(_this select 1)] call cba_fnc_removePerFrameHandler;
_unit setvariable [QGVAR(inCardiacArrest), nil,true];
};
if (_counter - _timer < 1) exitwith {
if (time - _startTime >= _timeInCardiacArrest) exitwith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
_unit setvariable [QGVAR(inCardiacArrest), nil,true];
[_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;
}, 1, [_unit, time, _timeInCardiacArrest] ] call CBA_fnc_addPerFrameHandler;