diff --git a/AUTHORS.txt b/AUTHORS.txt index 8d36de66ab..96f11a8f44 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -135,4 +135,5 @@ voiper VyMajoris(W-Cephei) Winter xrufix +Zakant zGuba diff --git a/addons/common/functions/fnc_player.sqf b/addons/common/functions/fnc_player.sqf index 54510be05e..537b54568f 100644 --- a/addons/common/functions/fnc_player.sqf +++ b/addons/common/functions/fnc_player.sqf @@ -4,7 +4,7 @@ * Use this in INIT and RESPAWN eh scripts, because ACE_player isn't reset yet. * * Arguments: - * NONE. + * None * * Return Value: * Player controlled unit diff --git a/addons/medical/functions/fnc_getCardiacOutput.sqf b/addons/medical/functions/fnc_getCardiacOutput.sqf index 1c015f54d0..8176a1fbe4 100644 --- a/addons/medical/functions/fnc_getCardiacOutput.sqf +++ b/addons/medical/functions/fnc_getCardiacOutput.sqf @@ -26,8 +26,6 @@ params ["_unit"]; -if (_unit getVariable [QGVAR(inCardiacArrest), false]) exitWith { 0 }; - private _bloodVolume = ((_unit getVariable [QGVAR(bloodVolume), DEFAULT_BLOOD_VOLUME]) / DEFAULT_BLOOD_VOLUME) * 100; private _heartRate = _unit getVariable [QGVAR(heartRate), DEFAULT_HEART_RATE]; private _cardiacOutput = ((_bloodVolume / MODIFIER_CARDIAC_OUTPUT) + ((_heartRate / DEFAULT_HEART_RATE) - 1)) / 60; diff --git a/addons/medical/functions/fnc_setCardiacArrest.sqf b/addons/medical/functions/fnc_setCardiacArrest.sqf index 5bf71323f9..2baba726d7 100644 --- a/addons/medical/functions/fnc_setCardiacArrest.sqf +++ b/addons/medical/functions/fnc_setCardiacArrest.sqf @@ -27,4 +27,3 @@ _unit setVariable [QGVAR(heartRate), 0, true]; ["ace_cardiacArrestEntered", [_unit]] call CBA_fnc_localEvent; [_unit, true] call FUNC(setUnconsciousStatemachine); - diff --git a/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp b/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp index 45e01cbe4f..eda67eda38 100644 --- a/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp +++ b/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp @@ -248,10 +248,11 @@ class GVAR(Actions) { requiredMedic = 0; treatmentTime = 15; items[] = {}; - condition = QUOTE(!(_target call EFUNC(common,isAwake))); + condition = QUOTE(!(_target call EFUNC(common,isAwake)) && {!(_target getVariable [ARR_2('GVAR(receiveCPR)', false)])}); callbackSuccess = QFUNC(treatmentCPR); - callbackFailure = ""; - callbackProgress = QUOTE(!([(_this select 0) select 1] call EFUNC(common,isAwake))); + callbackFailure = QFUNC(treatmentCPR_failure); + callbackProgress = QFUNC(treatmentCPR_progress); + callbackStart = QFUNC(treatmentCPR_start); animationPatient = ""; animationPatientUnconscious = "AinjPpneMstpSnonWrflDnon_rolltoback"; animationCaller = "AinvPknlMstpSlayW[wpn]Dnon_medic"; diff --git a/addons/medical_treatment/ACE_Settings.hpp b/addons/medical_treatment/ACE_Settings.hpp index 0767cfb9d1..2fce6faa6b 100644 --- a/addons/medical_treatment/ACE_Settings.hpp +++ b/addons/medical_treatment/ACE_Settings.hpp @@ -23,4 +23,11 @@ class ACE_Settings { typeName = "SCALAR"; value = 0; }; + class EGVAR(medical,CPRcreatesPulse) { + category = ECSTRING(medical,Category_Medical); + displayName = CSTRING(CPRcreatesPulse); + description = CSTRING(CPRcreatesPulse_Description); + typeName = "BOOL"; + value = 1; + }; }; diff --git a/addons/medical_treatment/XEH_PREP.hpp b/addons/medical_treatment/XEH_PREP.hpp index 783d3dc1e0..be8f316967 100644 --- a/addons/medical_treatment/XEH_PREP.hpp +++ b/addons/medical_treatment/XEH_PREP.hpp @@ -20,6 +20,9 @@ PREP(treatment_success); PREP(treatmentBandage); PREP(treatmentBandageLocal); +PREP(treatmentCPR_failure); +PREP(treatmentCPR_progress); +PREP(treatmentCPR_start); PREP(treatmentCPR); PREP(treatmentCPRLocal); PREP(treatmentFullHeal); @@ -46,6 +49,7 @@ PREP(healTime); PREP(isBeingCarried); PREP(isBeingDragged); PREP(onMedicationUsage); +PREP(calculateBlood); // items PREP(checkItems); diff --git a/addons/medical_treatment/functions/fnc_calculateBlood.sqf b/addons/medical_treatment/functions/fnc_calculateBlood.sqf new file mode 100644 index 0000000000..d805ee1ffa --- /dev/null +++ b/addons/medical_treatment/functions/fnc_calculateBlood.sqf @@ -0,0 +1,30 @@ +/* + * 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 + */ +#include "script_component.hpp" + +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,getBloodVolumeChange)); + private _bloodVolume = (_unit getVariable [QEGVAR(medical,bloodVolume), DEFAULT_BLOOD_VOLUME]) + _change; + _bloodVolume = 0 max _bloodVolume min DEFAULT_BLOOD_VOLUME; + _unit setVariable [QEGVAR(medical,bloodVolume), _bloodVolume, _syncValues]; +}; diff --git a/addons/medical_treatment/functions/fnc_treatment.sqf b/addons/medical_treatment/functions/fnc_treatment.sqf index cdb170c7ad..fdefeed292 100644 --- a/addons/medical_treatment/functions/fnc_treatment.sqf +++ b/addons/medical_treatment/functions/fnc_treatment.sqf @@ -179,6 +179,19 @@ if (isArray (_config >> "sounds")) then { ]; }; +private _startCallback = getText (_config >> "callbackStart"); +if (isNil _startCallback) then { + _startCallback = compile _startCallback; +} else { + _startCallback = missionNamespace getVariable _startCallback; +}; + +if !(_startCallback isEqualType {}) then { + _startCallback = {TRACE_1("startCallback was NOT code",_startCallback)}; +}; + +[_caller, _target, _bodyPart, _className, _items, _usersOfItems] call _startCallback; + // start treatment [ _treatmentTime, diff --git a/addons/medical_treatment/functions/fnc_treatmentCPR.sqf b/addons/medical_treatment/functions/fnc_treatmentCPR.sqf index 0cfb3bddc8..570878c4f2 100644 --- a/addons/medical_treatment/functions/fnc_treatmentCPR.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentCPR.sqf @@ -18,6 +18,10 @@ params ["_caller", "_target", "_selectionName", "_className", "_items"]; +_target setVariable [QEGVAR(medical,heartRate), 0, true]; +_target setVariable [QGVAR(receiveCPR), false, true]; // CPR finished +[_target] call FUNC(calculateBlood); + if (alive _target && {_target getVariable [QEGVAR(medical,inCardiacArrest), false]}) then { [_target, "activity_view", ELSTRING(medical,Activity_cpr), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); diff --git a/addons/medical_treatment/functions/fnc_treatmentCPR_failure.sqf b/addons/medical_treatment/functions/fnc_treatmentCPR_failure.sqf new file mode 100644 index 0000000000..bca59a1246 --- /dev/null +++ b/addons/medical_treatment/functions/fnc_treatmentCPR_failure.sqf @@ -0,0 +1,22 @@ +/* + * Author: Zakant + * Handles the failure of the CPR treatment. + * + * Arguments: + * 0: The medic + * 1: The patient + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +params ["_caller", "_target"]; + +if (!(_target call EFUNC(common,isAwake)) || {_target getVariable [QEGVAR(medical,inCardiacArrest), false]}) then { + _target setVariable [QEGVAR(medical,heartRate), 0, true]; +}; +_target setVariable [QGVAR(receiveCPR), false, true]; +[_target] call FUNC(calculateBlood); diff --git a/addons/medical_treatment/functions/fnc_treatmentCPR_progress.sqf b/addons/medical_treatment/functions/fnc_treatmentCPR_progress.sqf new file mode 100644 index 0000000000..02504607d4 --- /dev/null +++ b/addons/medical_treatment/functions/fnc_treatmentCPR_progress.sqf @@ -0,0 +1,28 @@ +/* + * Author: Zakant + * Handles the progress of the CPR treatment. + * + * Arguments: + * 0: Arguments + * 0: Caller + * 1: Target + * 1: Elapsed Time + * 2: Total Time + * + * Return Value: + * May Treatment continue + * + * Public: No + */ +#include "script_component.hpp" + +params ["_args", "_elapsedTime", "_totalTime"]; +_args params ["_caller", "_target"]; + +// If the patient awakes by mysterious force, no cpr is needed! +if (_target call EFUNC(common,isAwake)) exitWith {false}; +if (!(_target getVariable [QEGVAR(medical,inCardiacArrest), false])) exitWith {false}; + +[_target] call FUNC(calculateBlood); // Calculate blood volume. If their is no pulse, nothing happens! + +(alive _target) // CPR may only proceed if the patient is not dead diff --git a/addons/medical_treatment/functions/fnc_treatmentCPR_start.sqf b/addons/medical_treatment/functions/fnc_treatmentCPR_start.sqf new file mode 100644 index 0000000000..0012a01d2b --- /dev/null +++ b/addons/medical_treatment/functions/fnc_treatmentCPR_start.sqf @@ -0,0 +1,23 @@ +/* + * Author: Zakant + * Handles the start of the CPR treatment. + * + * Arguments: + * 0: The medic + * 1: The patient + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +params ["_caller", "_target"]; + +_target setVariable [QGVAR(receiveCPR), true, true]; // Target receives CPR +if (EGVAR(medical,CPRcreatesPulse) && {_target getVariable [QEGVAR(medical,heartRate), 80] == 0}) then { + _target setVariable [QEGVAR(medical,heartRate), round (30 + random [-5, 0, 5]) , true]; // And we have a (random) pulse +}; + +_target setVariable [QEGVAR(medical,lastTimeUpdated), CBA_missionTime, true]; diff --git a/addons/medical_treatment/stringtable.xml b/addons/medical_treatment/stringtable.xml index 6c665e0ba6..085bdd2e0b 100644 --- a/addons/medical_treatment/stringtable.xml +++ b/addons/medical_treatment/stringtable.xml @@ -27,6 +27,14 @@ Abilita la creazione della barella dopo trattamento 治療を始めると、医療廃棄物の作成を有効化する + + CPR creates pulse + HLW erzeugt einen Puls + + + CPR will create a pulse for the patient while performing + HLW erzeugt während der Behandlung beim Patienten einen Puls + Litter Simulation Detail Detale zużytych medykamentów