From de13ab0f47ef7a0d7bdc9b2f942869185217ac93 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 27 Jun 2019 19:01:20 -0500 Subject: [PATCH] Medical - Rework CPR and Bleeding in cardiac arrest (#7060) * Medical - Rework CPR and Bleeding in cardiac arrest * remove cprCreatesPulse, add cprSuccessChance * hide cpr for basic diagnose * Update addons/medical_statemachine/functions/fnc_enteredStateCardiacArrest.sqf Co-Authored-By: SilentSpike --- addons/medical/dev/watchVariable.sqf | 10 +++-- .../medical_gui/functions/fnc_onMenuClose.sqf | 1 + addons/medical_statemachine/Statemachine.hpp | 1 + addons/medical_statemachine/XEH_PREP.hpp | 1 + .../fnc_conditionCardiacArrestTimer.sqf | 5 +-- .../fnc_enteredStateCardiacArrest.sqf | 8 ++-- .../fnc_handleStateCardiacArrest.sqf | 37 +++++++++++++++++++ .../functions/fnc_leftStateCardiacArrest.sqf | 8 ++-- .../functions/fnc_getBloodLoss.sqf | 3 +- .../functions/fnc_getCardiacOutput.sqf | 4 +- .../functions/fnc_setCardiacArrest.sqf | 1 + .../ACE_Medical_Treatment_Actions.hpp | 2 +- addons/medical_treatment/ACE_Settings.hpp | 3 -- addons/medical_treatment/XEH_PREP.hpp | 3 +- .../functions/fnc_calculateBlood.sqf | 29 --------------- .../functions/fnc_canCPR.sqf | 4 +- .../functions/fnc_cprFailure.sqf | 12 ++---- .../functions/fnc_cprLocal.sqf | 7 +++- .../functions/fnc_cprProgress.sqf | 14 +++---- .../functions/fnc_cprStart.sqf | 15 ++------ .../{fnc_cpr.sqf => fnc_cprSuccess.sqf} | 10 +++-- addons/medical_treatment/initSettings.sqf | 18 ++++----- addons/medical_treatment/stringtable.xml | 15 +++----- .../functions/fnc_handleUnitVitals.sqf | 1 + .../functions/fnc_updateHeartRate.sqf | 10 ++++- 25 files changed, 116 insertions(+), 106 deletions(-) create mode 100644 addons/medical_statemachine/functions/fnc_handleStateCardiacArrest.sqf delete mode 100644 addons/medical_treatment/functions/fnc_calculateBlood.sqf rename addons/medical_treatment/functions/{fnc_cpr.sqf => fnc_cprSuccess.sqf} (58%) diff --git a/addons/medical/dev/watchVariable.sqf b/addons/medical/dev/watchVariable.sqf index 05966d907a..1fa8157fd4 100644 --- a/addons/medical/dev/watchVariable.sqf +++ b/addons/medical/dev/watchVariable.sqf @@ -19,12 +19,16 @@ _return pushBack ""; // State: - private _hasStableVitals = [_unit] call EFUNC(medical_status,hasStableVitals); private _targetState = [_unit, EGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState; if (!local _unit) then {_targetState = "NotLocal";}; private _color = switch (_targetState) do {case "Default": {"33FF33"}; case "Injured": {"FF3333"}; case "Unconscious": {"FF8833"}; case "CardiacArrest": {"FF33AA"}; default {"555555"}}; - private _unconcFlag = if IS_UNCONSCIOUS(_unit) then {"[U]"} else {""}; - _return pushBack format ["State: %2 [StableVitals: %3] %4", _color, _targetState, _hasStableVitals, _unconcFlag]; + _return pushBack format ["State: %2", _color, _targetState]; + private _hasStableVitals = ["N", "Y"] select ([_unit] call EFUNC(medical_status,hasStableVitals)); + private _hasStableCondition = ["N", "Y"] select ([_unit] call EFUNC(medical_status,isInStableCondition)); + private _unconcFlag = if IS_UNCONSCIOUS(_unit) then {"[U]"} else {""}; + private _timeLeft = _unit getVariable [QEGVAR(medical_statemachine,cardiacArrestTimeLeft), -1]; + private _cardiactArrestFlag = if IN_CRDC_ARRST(_unit) then {format ["[CA %1]", _timeLeft toFixed 1]} else {""}; + _return pushBack format ["[StableVitals: %1] [StableCon: %2] %3 %4", _hasStableVitals, _hasStableCondition, _unconcFlag, _cardiactArrestFlag]; // Blood: private _bloodVolume = GET_BLOOD_VOLUME(_unit); diff --git a/addons/medical_gui/functions/fnc_onMenuClose.sqf b/addons/medical_gui/functions/fnc_onMenuClose.sqf index bc65e975fd..a531eca4e8 100644 --- a/addons/medical_gui/functions/fnc_onMenuClose.sqf +++ b/addons/medical_gui/functions/fnc_onMenuClose.sqf @@ -18,5 +18,6 @@ if (EGVAR(interact_menu,menuBackground) == 1) then {[QGVAR(id), false] call EFUNC(common,blurScreen)}; if (EGVAR(interact_menu,menuBackground) == 2) then {(uiNamespace getVariable [QEGVAR(interact_menu,menuBackground), displayNull]) closeDisplay 0}; +GVAR(pendingReopen) = false; GVAR(menuPFH) call CBA_fnc_removePerFrameHandler; GVAR(menuPFH) = -1; diff --git a/addons/medical_statemachine/Statemachine.hpp b/addons/medical_statemachine/Statemachine.hpp index 12a5a01779..8c3e83d5d9 100644 --- a/addons/medical_statemachine/Statemachine.hpp +++ b/addons/medical_statemachine/Statemachine.hpp @@ -86,6 +86,7 @@ class ACE_Medical_StateMachine { }; }; class CardiacArrest { + onState = QFUNC(handleStateCardiacArrest); onStateEntered = QFUNC(enteredStateCardiacArrest); onStateLeaving = QFUNC(leftStateCardiacArrest); class DeathAI { diff --git a/addons/medical_statemachine/XEH_PREP.hpp b/addons/medical_statemachine/XEH_PREP.hpp index 26595cfb62..8e2725d3da 100644 --- a/addons/medical_statemachine/XEH_PREP.hpp +++ b/addons/medical_statemachine/XEH_PREP.hpp @@ -3,6 +3,7 @@ PREP(conditionExecutionDeath); PREP(enteredStateCardiacArrest); PREP(enteredStateDeath); PREP(enteredStateFatalInjury); +PREP(handleStateCardiacArrest); PREP(handleStateDefault); PREP(handleStateInjured); PREP(handleStateUnconscious); diff --git a/addons/medical_statemachine/functions/fnc_conditionCardiacArrestTimer.sqf b/addons/medical_statemachine/functions/fnc_conditionCardiacArrestTimer.sqf index df29c592a1..b28459db53 100644 --- a/addons/medical_statemachine/functions/fnc_conditionCardiacArrestTimer.sqf +++ b/addons/medical_statemachine/functions/fnc_conditionCardiacArrestTimer.sqf @@ -17,7 +17,4 @@ params ["_unit"]; -private _startTime = _unit getVariable [QGVAR(cardiacArrestStart), CBA_missionTime]; -private _lifeTime = _unit getVariable [QGVAR(cardiacArrestTime), GVAR(cardiacArrestTime)]; - -(CBA_missionTime - _startTime) > _lifeTime +(_unit getVariable [QGVAR(cardiacArrestTimeLeft), -1]) <= 0 diff --git a/addons/medical_statemachine/functions/fnc_enteredStateCardiacArrest.sqf b/addons/medical_statemachine/functions/fnc_enteredStateCardiacArrest.sqf index f418e38b84..0c5e184029 100644 --- a/addons/medical_statemachine/functions/fnc_enteredStateCardiacArrest.sqf +++ b/addons/medical_statemachine/functions/fnc_enteredStateCardiacArrest.sqf @@ -20,10 +20,12 @@ params ["_unit"]; // 10% possible variance in cardiac arrest time private _time = GVAR(cardiacArrestTime); -_time = _time + random [_time*-0.1, 0, _time*0.1]; +_time = _time + _time * random [-0.1, 0, 0.1]; -_unit setVariable [QGVAR(cardiacArrestTime), _time]; -_unit setVariable [QGVAR(cardiacArrestStart), CBA_missionTime]; +_unit setVariable [QGVAR(cardiacArrestTimeLeft), _time]; +_unit setVariable [QGVAR(cardiacArrestTimeLastUpdate), CBA_missionTime]; + +TRACE_3("enteredStateCardiacArrest",_unit,_time,CBA_missionTime); // Update the unit status to reflect cardiac arrest [_unit, true] call EFUNC(medical_status,setCardiacArrest); diff --git a/addons/medical_statemachine/functions/fnc_handleStateCardiacArrest.sqf b/addons/medical_statemachine/functions/fnc_handleStateCardiacArrest.sqf new file mode 100644 index 0000000000..b9e49adfe3 --- /dev/null +++ b/addons/medical_statemachine/functions/fnc_handleStateCardiacArrest.sqf @@ -0,0 +1,37 @@ +#include "script_component.hpp" +/* + * Author: BaerMitUmlaut + * Handles the unconscious state + * + * Arguments: + * 0: The Unit + * + * Return Value: + * None + * + * Example: + * [player] call ace_medical_statemachine_fnc_handleStateCardiacArrest + * + * Public: No + */ + +params ["_unit"]; + +// If the unit died the loop is finished +if (!alive _unit) exitWith {}; +if (!local _unit) exitWith {}; + +[_unit] call EFUNC(medical_vitals,handleUnitVitals); + +private _timeDiff = CBA_missionTime - (_unit getVariable [QGVAR(cardiacArrestTimeLastUpdate), 0]); +if (_timeDiff >= 1) then { + _timeDiff = _timeDiff min 10; + _unit setVariable [QGVAR(cardiacArrestTimeLastUpdate), CBA_missionTime]; + private _recieveingCPR = alive (_unit getVariable [QEGVAR(medical,CPR_provider), objNull]); + private _timeLeft = _unit getVariable [QGVAR(cardiacArrestTimeLeft), -1]; + TRACE_3("cardiac arrest life tick",_unit,_recieveingCPR,_timeDiff); + if (_recieveingCPR) then { _timeDiff = _timeDiff * 0.5; }; // if being cpr'ed, then time decrease is reduced + _timeLeft = _timeLeft - _timeDiff; // negative values are fine + _unit setVariable [QGVAR(cardiacArrestTimeLeft), _timeLeft]; +}; + diff --git a/addons/medical_statemachine/functions/fnc_leftStateCardiacArrest.sqf b/addons/medical_statemachine/functions/fnc_leftStateCardiacArrest.sqf index 85c469c4a5..5b077be771 100644 --- a/addons/medical_statemachine/functions/fnc_leftStateCardiacArrest.sqf +++ b/addons/medical_statemachine/functions/fnc_leftStateCardiacArrest.sqf @@ -17,11 +17,9 @@ */ params ["_unit"]; +TRACE_1("leftStateCardiacArrest",_unit); -_unit setVariable [QGVAR(cardiacArrestTime), nil]; -_unit setVariable [QEGVAR(medical,cardiacArrestStart), nil]; - -// Temporary fix for vitals loop on cardiac arrest exit -_unit setVariable [QGVAR(lastTimeUpdated), CBA_missionTime]; +_unit setVariable [QGVAR(cardiacArrestTimeLeft), nil]; +_unit setVariable [QGVAR(cardiacArrestTimeLastUpdate), nil]; [_unit, false] call EFUNC(medical_status,setCardiacArrest); diff --git a/addons/medical_status/functions/fnc_getBloodLoss.sqf b/addons/medical_status/functions/fnc_getBloodLoss.sqf index a181eba479..ca3cba77cd 100644 --- a/addons/medical_status/functions/fnc_getBloodLoss.sqf +++ b/addons/medical_status/functions/fnc_getBloodLoss.sqf @@ -22,4 +22,5 @@ if (_woundBleeding == 0) exitWith {0}; private _cardiacOutput = [_unit] call FUNC(getCardiacOutput); -(_woundBleeding * _cardiacOutput * EGVAR(medical,bleedingCoefficient)) +// even if heart stops blood will still flow slowly (gravity) +(_woundBleeding * (_cardiacOutput max 0.05) * EGVAR(medical,bleedingCoefficient)) diff --git a/addons/medical_status/functions/fnc_getCardiacOutput.sqf b/addons/medical_status/functions/fnc_getCardiacOutput.sqf index cf9cdca7fe..cf405b52bc 100644 --- a/addons/medical_status/functions/fnc_getCardiacOutput.sqf +++ b/addons/medical_status/functions/fnc_getCardiacOutput.sqf @@ -7,7 +7,7 @@ * 0: The Unit * * Return Value: - * Current cardiac output (litre per second) + * Current cardiac output (liter per second) * * Example: * [player] call ace_medical_status_fnc_getCardiacOutput @@ -16,7 +16,7 @@ */ /* - Cardiac output (Q or or CO ) is the volume of blood being pumped by the heart, in particular by a left or right ventricle in the CBA_missionTime interval of one second. CO may be measured in many ways, for example dm3/min (1 dm3 equals 1 litre). + Cardiac output (Q or or CO ) is the volume of blood being pumped by the heart, in particular by a left or right ventricle in the CBA_missionTime interval of one second. CO may be measured in many ways, for example dm3/min (1 dm3 equals 1 liter). Source: http://en.wikipedia.org/wiki/Cardiac_output */ diff --git a/addons/medical_status/functions/fnc_setCardiacArrest.sqf b/addons/medical_status/functions/fnc_setCardiacArrest.sqf index 32c858b36d..5ce67938e9 100644 --- a/addons/medical_status/functions/fnc_setCardiacArrest.sqf +++ b/addons/medical_status/functions/fnc_setCardiacArrest.sqf @@ -14,6 +14,7 @@ */ params ["_unit", "_active"]; +TRACE_2("setCardiacArrest",_unit,_active); // No change to make if (_active isEqualTo IN_CRDC_ARRST(_unit)) exitWith {}; diff --git a/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp b/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp index 31d009ec63..1791568b34 100644 --- a/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp +++ b/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp @@ -269,7 +269,7 @@ class GVAR(actions) { treatmentTime = 15; items[] = {}; condition = QFUNC(canCPR); - callbackSuccess = QFUNC(cpr); + callbackSuccess = QFUNC(cprSuccess); callbackFailure = QFUNC(cprFailure); callbackProgress = QFUNC(cprProgress); callbackStart = QFUNC(cprStart); diff --git a/addons/medical_treatment/ACE_Settings.hpp b/addons/medical_treatment/ACE_Settings.hpp index 309c923299..444e5236ed 100644 --- a/addons/medical_treatment/ACE_Settings.hpp +++ b/addons/medical_treatment/ACE_Settings.hpp @@ -2,9 +2,6 @@ class ACE_Settings { class EGVAR(medical,allowLitterCreation) { movedToSqf = 1; }; - class EGVAR(medical,CPRcreatesPulse) { - movedToSqf = 1; - }; class EGVAR(medical,litterCleanUpDelay) { movedToSqf = 1; }; diff --git a/addons/medical_treatment/XEH_PREP.hpp b/addons/medical_treatment/XEH_PREP.hpp index 628003ff62..5b18bba14e 100644 --- a/addons/medical_treatment/XEH_PREP.hpp +++ b/addons/medical_treatment/XEH_PREP.hpp @@ -4,7 +4,6 @@ PREP(addToTriageCard); PREP(bandage); PREP(bandageLocal); PREP(bodyCleanupLoop); -PREP(calculateBlood); PREP(canBandage); PREP(canCPR); PREP(canSplint); @@ -17,7 +16,7 @@ PREP(checkItems); PREP(checkPulse); PREP(checkPulseLocal); PREP(checkResponse); -PREP(cpr); +PREP(cprSuccess); PREP(cprFailure); PREP(cprLocal); PREP(cprProgress); diff --git a/addons/medical_treatment/functions/fnc_calculateBlood.sqf b/addons/medical_treatment/functions/fnc_calculateBlood.sqf deleted file mode 100644 index 074022ed29..0000000000 --- a/addons/medical_treatment/functions/fnc_calculateBlood.sqf +++ /dev/null @@ -1,29 +0,0 @@ -#include "script_component.hpp" -/* - * Author: Zakant - * Calculate the blood lost and blood volume for a unit. Used from CPR to simulate a heart rate while in cardiac arrest. - * - * Arguments: - * 0: Unit - * - * Return Value: - * None - * - * Public: No - */ - -params["_unit"]; - -// We will just simulate blood flow for now! -private _lastTimeUpdated = _unit getVariable [QEGVAR(medical,lastTimeUpdated), CBA_missionTime]; -private _deltaT = CBA_missionTime - _lastTimeUpdated; - -private _lastTimeValuesSynced = _unit getVariable [QEGVAR(medical,lastMomentValuesSynced), 0]; -private _syncValues = (CBA_missionTime - _lastTimeValuesSynced) >= (10 + floor(random(10))); - -_unit setVariable [QEGVAR(medical,lastTimeUpdated), CBA_missionTime]; -if (_deltaT != 0) then { - private _change = ([_unit, _deltaT, _syncValues] call EFUNC(medical_status,getBloodVolumeChange)); - private _bloodVolume = 0 max (GET_BLOOD_VOLUME(_unit) + _change) min DEFAULT_BLOOD_VOLUME; - _unit setVariable [VAR_BLOOD_VOL, _bloodVolume, _syncValues]; -}; diff --git a/addons/medical_treatment/functions/fnc_canCPR.sqf b/addons/medical_treatment/functions/fnc_canCPR.sqf index 9da6ec6891..172cbe5aa9 100644 --- a/addons/medical_treatment/functions/fnc_canCPR.sqf +++ b/addons/medical_treatment/functions/fnc_canCPR.sqf @@ -18,4 +18,6 @@ params ["", "_patient"]; -!(_patient call EFUNC(common,isAwake)) && {!(_patient getVariable [QGVAR(isReceivingCPR), false])} +!(_patient call EFUNC(common,isAwake)) +&& {(GVAR(advancedDiagnose)) || {IN_CRDC_ARRST(_patient)}} // if basic diagnose, then only show action if appropriate (they can't tell difference between uncon/ca) +&& {isNull (_patient getVariable [QEGVAR(medical,CPR_provider), objNull])} diff --git a/addons/medical_treatment/functions/fnc_cprFailure.sqf b/addons/medical_treatment/functions/fnc_cprFailure.sqf index a19179c5f8..513c2e43ee 100644 --- a/addons/medical_treatment/functions/fnc_cprFailure.sqf +++ b/addons/medical_treatment/functions/fnc_cprFailure.sqf @@ -16,13 +16,7 @@ * Public: No */ -params ["", "_patient"]; +params ["_medic", "_patient"]; +TRACE_2("cprFailure",_medic,_patient); -if (!(_patient call EFUNC(common,isAwake)) || {IN_CRDC_ARRST(_patient)}) then { - _patient setVariable [VAR_HEART_RATE, 0, true]; -}; - -// Patient is no longer receiving CPR -_patient setVariable [QGVAR(isReceivingCPR), false, true]; - -_patient call FUNC(calculateBlood); +_patient setVariable [QEGVAR(medical,CPR_provider), objNull, true]; diff --git a/addons/medical_treatment/functions/fnc_cprLocal.sqf b/addons/medical_treatment/functions/fnc_cprLocal.sqf index da72faba45..3d9dfd1e32 100644 --- a/addons/medical_treatment/functions/fnc_cprLocal.sqf +++ b/addons/medical_treatment/functions/fnc_cprLocal.sqf @@ -17,9 +17,14 @@ */ params ["_medic", "_patient"]; +TRACE_2("cprLocal",_medic,_patient); [_patient, "activity", LSTRING(Activity_CPR), [[_medic, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); -if (random 1 >= 0.6) then { +if ((random 1) < GVAR(cprSuccessChance)) then { + TRACE_1("CPR random success",GVAR(cprSuccessChance)); [QEGVAR(medical,CPRSucceeded), _patient] call CBA_fnc_localEvent; +} else { + TRACE_1("CPR random fail",GVAR(cprSuccessChance)); }; + diff --git a/addons/medical_treatment/functions/fnc_cprProgress.sqf b/addons/medical_treatment/functions/fnc_cprProgress.sqf index e595b7ffdd..f41fefe5bf 100644 --- a/addons/medical_treatment/functions/fnc_cprProgress.sqf +++ b/addons/medical_treatment/functions/fnc_cprProgress.sqf @@ -5,7 +5,7 @@ * * Arguments: * 0: Arguments - * 0: Medic (not used) + * 0: Medic * 1: Patient * * Return Value: @@ -18,12 +18,10 @@ */ params ["_args"]; -_args params ["", "_patient"]; +_args params ["_medic", "_patient"]; -// Cancel CPR is patient wakes up -if (_patient getVariable EFUNC(common,isAwake) || {!IN_CRDC_ARRST(_patient)}) exitWith {false}; +// Cancel CPR if patient wakes up -// Calculate blood volume, if there is no pulse nothing happens -_patient call FUNC(calculateBlood); - -true +!(_patient call EFUNC(common,isAwake)) +&& {(GVAR(advancedDiagnose)) || {IN_CRDC_ARRST(_patient)}} // if basic diagnose, then only show action if appropriate (they can't tell difference between uncon/ca) +&& {_medic == (_patient getVariable [QEGVAR(medical,CPR_provider), objNull])} diff --git a/addons/medical_treatment/functions/fnc_cprStart.sqf b/addons/medical_treatment/functions/fnc_cprStart.sqf index 677e8a516a..f49ccbb4a3 100644 --- a/addons/medical_treatment/functions/fnc_cprStart.sqf +++ b/addons/medical_treatment/functions/fnc_cprStart.sqf @@ -4,7 +4,7 @@ * Handles starting the CPR treatment. * * Arguments: - * 0: Medic (not used) + * 0: Medic * 1: Patient * * Return Value: @@ -16,14 +16,7 @@ * Public: No */ -params ["", "_patient"]; +params ["_medic", "_patient"]; +TRACE_2("cprStart",_medic,_patient); -// Prevent others from performing CPR -_patient setVariable [QGVAR(isReceivingCPR), true, true]; - -// Create a random pulse based on setting -if (GVAR(cprCreatesPulse) && {GET_HEART_RATE(_patient) == 0}) then { - _patient setVariable [VAR_HEART_RATE, round random [25, 30, 35], true]; -}; - -_patient setVariable [QEGVAR(medical,lastTimeUpdated), CBA_missionTime, true]; +_patient setVariable [QEGVAR(medical,CPR_provider), _medic, true]; diff --git a/addons/medical_treatment/functions/fnc_cpr.sqf b/addons/medical_treatment/functions/fnc_cprSuccess.sqf similarity index 58% rename from addons/medical_treatment/functions/fnc_cpr.sqf rename to addons/medical_treatment/functions/fnc_cprSuccess.sqf index a0732bcbf8..bd9d0c3e2b 100644 --- a/addons/medical_treatment/functions/fnc_cpr.sqf +++ b/addons/medical_treatment/functions/fnc_cprSuccess.sqf @@ -11,17 +11,19 @@ * None * * Example: - * [player, cursorObject] call ace_medical_treatment_fnc_cpr + * [player, cursorObject] call ace_medical_treatment_fnc_cprSuccess * * Public: No */ params ["_medic", "_patient"]; +TRACE_2("cprSuccess",_medic,_patient); -_patient setVariable [QGVAR(isReceivingCPR), false, true]; -_patient setVariable [VAR_HEART_RATE, 0, true]; -_patient call FUNC(calculateBlood); +_patient setVariable [QEGVAR(medical,CPR_provider), objNull, true]; if (alive _patient && {IN_CRDC_ARRST(_patient)}) then { + TRACE_1("sending cprLocal event",_patient); [QGVAR(cprLocal), [_medic, _patient], _patient] call CBA_fnc_targetEvent; +} else { + TRACE_1("not alive or in cardiac arrest",_patient); }; diff --git a/addons/medical_treatment/initSettings.sqf b/addons/medical_treatment/initSettings.sqf index 0717c8e88f..148af1686a 100644 --- a/addons/medical_treatment/initSettings.sqf +++ b/addons/medical_treatment/initSettings.sqf @@ -38,15 +38,6 @@ true ] call CBA_settings_fnc_init; -[ - QGVAR(cprCreatesPulse), - "CHECKBOX", - [LSTRING(CPRCreatesPulse_DisplayName), LSTRING(CPRCreatesPulse_Description)], - [ELSTRING(medical,Category), LSTRING(SubCategory_Treatment)], - true, - true -] call CBA_settings_fnc_init; - // todo: should this setting differentiate between medical vehicles and facilities? [ QGVAR(locationsBoostTraining), @@ -165,6 +156,15 @@ true ] call CBA_settings_fnc_init; +[ + QGVAR(cprSuccessChance), + "SLIDER", + [LSTRING(cprSuccessChance_DisplayName), LSTRING(cprSuccessChance_Description)], + [ELSTRING(medical,Category), LSTRING(SubCategory_Treatment)], + [0, 1, 0.4, 2], + true +] call CBA_settings_fnc_init; + [ QGVAR(allowLitterCreation), "CHECKBOX", diff --git a/addons/medical_treatment/stringtable.xml b/addons/medical_treatment/stringtable.xml index 04e6fd4476..3c7e2fc9db 100644 --- a/addons/medical_treatment/stringtable.xml +++ b/addons/medical_treatment/stringtable.xml @@ -44,15 +44,6 @@ Enables extended, more in-depth medication handling. Also, enables the use of Adenosine and Atropine. Устанавливает расширенное использование лекарств - - CPR Creates Pulse - HLW erzeugt einen Puls - 心肺蘇生による脈 - СЛР создаст пульс - - - Controls whether performing CPR creates a pulse for the patient. - Locations Boost Training Místa pro vylepšení zkušeností @@ -1939,6 +1930,12 @@ 进行心肺复苏术中... 進行心肺復甦術中... + + CPR Success Chance + + + Probability that cpr will be successful in restoring heart rhythm. + Give Blood IV (1000ml) Bluttransfusion IV (1000ml) diff --git a/addons/medical_vitals/functions/fnc_handleUnitVitals.sqf b/addons/medical_vitals/functions/fnc_handleUnitVitals.sqf index 64c8b0cd4c..5fe474ad38 100644 --- a/addons/medical_vitals/functions/fnc_handleUnitVitals.sqf +++ b/addons/medical_vitals/functions/fnc_handleUnitVitals.sqf @@ -113,6 +113,7 @@ switch (true) do { TRACE_3("BloodVolume Fatal",_unit,BLOOD_VOLUME_FATAL,_bloodVolume); [QEGVAR(medical,Bleedout), _unit] call CBA_fnc_localEvent; }; + case (IN_CRDC_ARRST(_unit)): {}; // if in cardiac arrest just break now to avoid throwing unneeded events case (_hemorrhage == 4): { TRACE_3("Class IV Hemorrhage",_unit,_hemorrhage,_bloodVolume); [QEGVAR(medical,FatalVitals), _unit] call CBA_fnc_localEvent; diff --git a/addons/medical_vitals/functions/fnc_updateHeartRate.sqf b/addons/medical_vitals/functions/fnc_updateHeartRate.sqf index f8543eeade..4da8519077 100644 --- a/addons/medical_vitals/functions/fnc_updateHeartRate.sqf +++ b/addons/medical_vitals/functions/fnc_updateHeartRate.sqf @@ -22,7 +22,15 @@ params ["_unit", "_hrTargetAdjustment", "_deltaT", "_syncValue"]; private _heartRate = GET_HEART_RATE(_unit); -if !IN_CRDC_ARRST(_unit) then { +if IN_CRDC_ARRST(_unit) then { + if (alive (_unit getVariable [QEGVAR(medical,CPR_provider), objNull])) then { + if (_heartRate == 0) then { _syncValue = true }; // always sync on large change + _heartRate = random [25, 30, 35]; + } else { + if (_heartRate != 0) then { _syncValue = true }; // always sync on large change + _heartRate = 0 + }; +} else { private _hrChange = 0; private _targetHR = 0; private _bloodVolume = GET_BLOOD_VOLUME(_unit);