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:
|
2015-08-22 17:47:23 +00:00
|
|
|
* None
|
2015-02-08 09:01:32 +00:00
|
|
|
*
|
|
|
|
* Public: yes
|
2015-02-07 23:08:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-22 17:47:23 +00:00
|
|
|
private "_timeInCardiacArrest";
|
|
|
|
params ["_unit"];
|
2015-02-07 23:08:36 +00:00
|
|
|
|
2015-11-30 16:27:09 +00:00
|
|
|
if (_unit getVariable [QGVAR(inCardiacArrest),false]) exitWith {};
|
|
|
|
_unit setVariable [QGVAR(inCardiacArrest), true,true];
|
|
|
|
_unit setVariable [QGVAR(heartRate), 0];
|
2015-02-07 23:08:36 +00:00
|
|
|
|
2016-06-03 18:57:21 +00:00
|
|
|
["ace_enteredCardiacArrest", [_unit]] call CBA_fnc_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-08-22 17:47:23 +00:00
|
|
|
params ["_args", "_idPFH"];
|
|
|
|
_args params ["_unit", "_startTime", "_timeInCardiacArrest"];
|
2015-02-07 23:08:36 +00:00
|
|
|
|
2016-04-18 13:20:35 +00:00
|
|
|
private _heartRate = _unit getVariable [QGVAR(heartRate), 80];
|
2015-11-30 16:14:05 +00:00
|
|
|
if (_heartRate > 0 || !alive _unit) exitWith {
|
2015-08-22 17:47:23 +00:00
|
|
|
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
2015-11-30 16:27:09 +00:00
|
|
|
_unit setVariable [QGVAR(inCardiacArrest), nil,true];
|
2015-02-07 23:08:36 +00:00
|
|
|
};
|
2016-03-02 10:01:39 +00:00
|
|
|
if (CBA_missionTime - _startTime >= _timeInCardiacArrest) exitWith {
|
2015-08-22 17:47:23 +00:00
|
|
|
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
2015-11-30 16:27:09 +00:00
|
|
|
_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
|
|
|
};
|
2016-03-02 10:01:39 +00:00
|
|
|
}, 1, [_unit, CBA_missionTime, _timeInCardiacArrest] ] call CBA_fnc_addPerFrameHandler;
|