ACE3/addons/medical_treatment/functions/fnc_cprLocal.sqf
johnb432 2a3ff8e185
Medical Treatment - Fix low SpO2 making units go into cardiac arrest again (#10003)
* Set SpO2 after successful CPR

* Update fnc_cprLocal.sqf

* Add API

* Update fnc_cprLocal.sqf
2024-05-10 20:39:41 -05:00

38 lines
1.3 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: Glowbal
* Local callback for finishing performing CPR on the patient.
*
* Arguments:
* 0: Medic <OBJECT>
* 1: Patient <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject] call ace_medical_treatment_fnc_cprLocal
*
* Public: No
*/
params ["_medic", "_patient"];
TRACE_2("cprLocal",_medic,_patient);
[_patient, "activity", LSTRING(Activity_CPR), [[_medic, false, true] call EFUNC(common,getName)]] call FUNC(addToLog);
private _bloodVolume = GET_BLOOD_VOLUME(_patient);
private _successChance = linearConversion [BLOOD_VOLUME_CLASS_4_HEMORRHAGE, BLOOD_VOLUME_CLASS_2_HEMORRHAGE, _bloodVolume, GVAR(cprSuccessChanceMin), GVAR(cprSuccessChanceMax), true];
if ((random 1) < _successChance) then {
// If SpO2 is too low, it will make HR skyrocket to the point where patient goes back into CA
// Allow 3rd party mods to disable this mechanic
if (missionNamespace getVariable [QGVAR(setSpO2UponCPRSuccess), true] && {GET_SPO2(_patient) < DEFAULT_SPO2 / 2}) then {
_patient setVariable [VAR_SPO2, DEFAULT_SPO2 / 2, true];
};
TRACE_2("CPR random success",_bloodVolume,_successChance);
[QEGVAR(medical,CPRSucceeded), _patient] call CBA_fnc_localEvent;
} else {
TRACE_2("CPR random fail",_bloodVolume,_successChance);
};