2015-02-08 09:01:32 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* 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.
|
2015-02-07 23:08:36 +00:00
|
|
|
*
|
2015-02-08 09:01:32 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: The unit that will be put in cardiac arrest state <OBJECT>
|
|
|
|
*
|
|
|
|
* ReturnValue:
|
|
|
|
* <NIL>
|
|
|
|
*
|
|
|
|
* Public: yes
|
2015-02-07 23:08:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-04-04 19:20:03 +00:00
|
|
|
private ["_unit", "_timeInCardiacArrest"];
|
2015-02-07 23:08:36 +00:00
|
|
|
_unit = _this select 0;
|
|
|
|
|
|
|
|
if (_unit getvariable [QGVAR(inCardiacArrest),false]) exitwith {};
|
|
|
|
_unit setvariable [QGVAR(inCardiacArrest), true,true];
|
|
|
|
_unit setvariable [QGVAR(heartRate), 0];
|
|
|
|
|
2015-06-09 22:30:02 +00:00
|
|
|
["Medical_onEnteredCardiacArrest", [_unit]] call EFUNC(common,localEvent);
|
2015-02-07 23:08:36 +00:00
|
|
|
|
2015-04-04 19:20:03 +00:00
|
|
|
[_unit, true] call FUNC(setUnconscious);
|
|
|
|
_timeInCardiacArrest = 120 + round(random(600));
|
2015-02-07 23:08:36 +00:00
|
|
|
|
|
|
|
[{
|
2015-04-04 19:20:03 +00:00
|
|
|
private ["_args","_unit","_startTime","_timeInCardiacArrest","_heartRate"];
|
2015-02-07 23:08:36 +00:00
|
|
|
_args = _this select 0;
|
|
|
|
_unit = _args select 0;
|
2015-04-04 19:20:03 +00:00
|
|
|
_startTime = _args select 1;
|
|
|
|
_timeInCardiacArrest = _args select 2;
|
2015-02-07 23:08:36 +00:00
|
|
|
|
2015-04-17 17:13:23 +00:00
|
|
|
_heartRate = _unit getvariable [QGVAR(heartRate), 80];
|
2015-02-07 23:08:36 +00:00
|
|
|
if (_heartRate > 0 || !alive _unit) exitwith {
|
|
|
|
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
2015-04-04 19:20:03 +00:00
|
|
|
_unit setvariable [QGVAR(inCardiacArrest), nil,true];
|
2015-02-07 23:08:36 +00:00
|
|
|
};
|
2015-05-21 16:42:44 +00:00
|
|
|
if (ACE_time - _startTime >= _timeInCardiacArrest) exitwith {
|
2015-02-07 23:08:36 +00:00
|
|
|
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
|
|
|
_unit setvariable [QGVAR(inCardiacArrest), nil,true];
|
2015-04-04 19:20:03 +00:00
|
|
|
[_unit] call FUNC(setDead);
|
2015-02-07 23:08:36 +00:00
|
|
|
};
|
2015-05-21 16:42:44 +00:00
|
|
|
}, 1, [_unit, ACE_time, _timeInCardiacArrest] ] call CBA_fnc_addPerFrameHandler;
|
2015-02-07 23:08:36 +00:00
|
|
|
|