ACE3/addons/medical/functions/fnc_setCardiacArrest.sqf
esteldunedain 18f09b9310 Rename events:
- ace_addedHeartRateAdjustment -> ace_heartRateAdjustmentAdded
- ace_cargoAddedByClass -> ace_cargoByClassAdded
- ace_enteredCardiacArrest -> ace_cardiacArrestEntered
- ace_itemAddedToTriageCard -> ace_triageCardItemAdded
- ace_reload_linkedAmmo ->  ace_reload_ammoLinked
- ace_reload_returnedAmmo -> ace_reload_ammoReturned
- ace_treatmentSuccess ->  ace_treatmentSucceded
- ace_common_engineOn -> ace_common_setEngine
- ace_explosives_clientRequestOrientations -> ace_explosives_requestOrientations
- ace_explosives_serverSendOrientations -> ace_explosives_sendOrientations
- ace_interaction_lampTurnOff -> ace_interaction_setLampOff
- ace_interaction_lampTurnOn -> ace_interaction_setLampOn
- ace_overheating_spareBarrelsLoadCoolest -> ace_overheating_loadCoolestSpareBarrel
- ace_overheating_spareBarrelsSendTemperatureHint -> ace_overheating_sendSpareBarrelTemperatureHint
Close #3533
2016-06-24 10:45:13 -03:00

44 lines
1.4 KiB
Plaintext

/*
* 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.
*
* Arguments:
* 0: The unit that will be put in cardiac arrest state <OBJECT>
*
* ReturnValue:
* None
*
* Public: yes
*/
#include "script_component.hpp"
private "_timeInCardiacArrest";
params ["_unit"];
if (_unit getVariable [QGVAR(inCardiacArrest),false]) exitWith {};
_unit setVariable [QGVAR(inCardiacArrest), true,true];
_unit setVariable [QGVAR(heartRate), 0];
["ace_cardiacArrestEntered", [_unit]] call CBA_fnc_localEvent;
[_unit, true] call FUNC(setUnconscious);
_timeInCardiacArrest = 120 + round(random(600));
[{
params ["_args", "_idPFH"];
_args params ["_unit", "_startTime", "_timeInCardiacArrest"];
private _heartRate = _unit getVariable [QGVAR(heartRate), 80];
if (_heartRate > 0 || !alive _unit) exitWith {
[_idPFH] call CBA_fnc_removePerFrameHandler;
_unit setVariable [QGVAR(inCardiacArrest), nil,true];
};
if (CBA_missionTime - _startTime >= _timeInCardiacArrest) exitWith {
[_idPFH] call CBA_fnc_removePerFrameHandler;
_unit setVariable [QGVAR(inCardiacArrest), nil,true];
[_unit] call FUNC(setDead);
};
}, 1, [_unit, CBA_missionTime, _timeInCardiacArrest] ] call CBA_fnc_addPerFrameHandler;