From 7e498ab762ff67058aca69bc2e39f2eadd8d3c37 Mon Sep 17 00:00:00 2001 From: commy2 Date: Thu, 20 Oct 2016 02:14:11 +0200 Subject: [PATCH] setting for basic/advanced syringes --- addons/medical/XEH_preInit.sqf | 9 ++++ .../functions/fnc_handleUnitVitals.sqf | 8 +-- .../ACE_Medical_Treatment_Actions.hpp | 54 ++++++------------- addons/medical_treatment/XEH_PREP.hpp | 53 +++++++++--------- addons/medical_treatment/XEH_postInit.sqf | 2 - .../functions/fnc_treatmentEpipen.sqf | 20 ------- .../fnc_treatmentMedicationLocal.sqf | 26 +++++++-- .../functions/fnc_treatmentMorphine.sqf | 22 -------- .../functions/fnc_treatmentMorphineLocal.sqf | 26 --------- 9 files changed, 78 insertions(+), 142 deletions(-) delete mode 100644 addons/medical_treatment/functions/fnc_treatmentEpipen.sqf delete mode 100644 addons/medical_treatment/functions/fnc_treatmentMorphine.sqf delete mode 100644 addons/medical_treatment/functions/fnc_treatmentMorphineLocal.sqf diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index 45c9eb7af0..b590114b13 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -28,4 +28,13 @@ GVAR(STATE_MACHINE) = (configFile >> "ACE_Medical_StateMachine") call FUNC(creat true ] call CBA_Settings_fnc_init; +[ + QGVAR(advancedMedication), + "CHECKBOX", + ["Advanced Medication", "Enables advanced simulation of Morphine, Epinephrine etc."], //@todo + "ACE Medical", // @todo + false, + true +] call CBA_Settings_fnc_init; + ADDON = true; diff --git a/addons/medical/functions/fnc_handleUnitVitals.sqf b/addons/medical/functions/fnc_handleUnitVitals.sqf index 9341fee12c..715134a373 100644 --- a/addons/medical/functions/fnc_handleUnitVitals.sqf +++ b/addons/medical/functions/fnc_handleUnitVitals.sqf @@ -93,10 +93,10 @@ if (GVAR(level) == 1) then { _unit setVariable [QGVAR(pain), (_painStatus - 0.001 * _interval) max 0, _syncValues]; }; - // reduce painkillers - if (_unit getVariable [QGVAR(morphine), 0] > 0) then { - _unit setVariable [QGVAR(morphine), ((_unit getVariable [QGVAR(morphine), 0]) - 0.0015 * _interval) max 0, _syncValues]; - }; + //// reduce painkillers + //if (_unit getVariable [QGVAR(morphine), 0] > 0) then { + // _unit setVariable [QGVAR(morphine), ((_unit getVariable [QGVAR(morphine), 0]) - 0.0015 * _interval) max 0, _syncValues]; + //}; }; */ diff --git a/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp b/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp index 50e6c0d1cc..319bb65fa1 100644 --- a/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp +++ b/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp @@ -90,28 +90,37 @@ class GVAR(Actions) { }; // --- syringes - class Morphine: BasicBandage { + class Morphine: fieldDressing { displayName = ECSTRING(medical,Inject_Morphine); displayNameProgress = ECSTRING(medical,Injecting_Morphine); allowedSelections[] = {"LeftArm", "RightArm", "LeftLeg", "RightLeg"}; - allowSelfTreatment = 1; category = "medication"; - treatmentTime = 10; items[] = {"ACE_morphine"}; condition = ""; - callbackSuccess = QFUNC(treatmentMorphine); + treatmentTime = 10; + callbackSuccess = QFUNC(treatmentMedication); animationCaller = "AinvPknlMstpSnonWnonDnon_medic1"; litter[] = { {"All", "", {"ACE_MedicalLitter_morphine"}} }; sounds[] = {{QPATHTO_R(sounds\Inject.ogg),1,1,50}}; }; + class Adenosine: Morphine { + displayName = ECSTRING(medical,Inject_Adenosine); + displayNameProgress = ECSTRING(medical,Injecting_Adenosine); + items[] = {"ACE_adenosine"}; + litter[] = { {"All", "", {"ACE_MedicalLitter_adenosine"}} }; + }; + class Atropine: Morphine { + displayName = ECSTRING(medical,Inject_Atropine); + displayNameProgress = ECSTRING(medical,Injecting_Atropine); + items[] = {"ACE_atropine"}; + litter[] = { {"All", "", {"ACE_MedicalLitter_atropine"}} }; + }; class Epinephrine: Morphine { displayName = ECSTRING(medical,Inject_Epinephrine); displayNameProgress = ECSTRING(medical,Injecting_Epinephrine); - requiredMedic = QEGVAR(medical,medicSetting_basicEpi); items[] = {"ACE_epinephrine"}; - callbackSuccess = QFUNC(treatmentEpipen); litter[] = { {"All", "", {"ACE_MedicalLitter_epinephrine"}} }; - treatmentLocations[] = {QGVAR(useLocation_basicEpi)}; + //treatmentLocations[] = {QGVAR(useLocation_basicEpi)}; }; // --- iv bags @@ -251,37 +260,6 @@ class GVAR(Actions) { /* class Advanced { - class Morphine: fieldDressing { - displayName = ECSTRING(medical,Inject_Morphine); - displayNameProgress = ECSTRING(medical,Injecting_Morphine); - allowedSelections[] = {"LeftArm", "RightArm", "LeftLeg", "RightLeg"}; - category = "medication"; - items[] = {"ACE_morphine"}; - treatmentTime = 3; - callbackSuccess = QFUNC(treatmentMedication); - animationCaller = "AinvPknlMstpSnonWnonDnon_medic1"; - litter[] = { {"All", "", {"ACE_MedicalLitter_morphine"}} }; - sounds[] = {{QPATHTO_R(sounds\Inject.ogg),1,1,50}}; - }; - class Adenosine: Morphine { - displayName = ECSTRING(medical,Inject_Adenosine); - displayNameProgress = ECSTRING(medical,Injecting_Adenosine); - items[] = {"ACE_adenosine"}; - litter[] = { {"All", "", {"ACE_MedicalLitter_adenosine"}} }; - }; - class Atropine: Morphine { - displayName = ECSTRING(medical,Inject_Atropine); - displayNameProgress = ECSTRING(medical,Injecting_Atropine); - items[] = {"ACE_atropine"}; - litter[] = { {"All", "", {"ACE_MedicalLitter_atropine"}} }; - }; - class Epinephrine: Morphine { - displayName = ECSTRING(medical,Inject_Epinephrine); - displayNameProgress = ECSTRING(medical,Injecting_Epinephrine); - items[] = {"ACE_epinephrine"}; - litter[] = { {"All", "", {"ACE_MedicalLitter_epinephrine"}} }; - }; - class SurgicalKit: fieldDressing { displayName = ECSTRING(medical,Use_SurgicalKit); displayNameProgress = ECSTRING(medical,Stitching); diff --git a/addons/medical_treatment/XEH_PREP.hpp b/addons/medical_treatment/XEH_PREP.hpp index 4a3d39a553..0b0fb88e95 100644 --- a/addons/medical_treatment/XEH_PREP.hpp +++ b/addons/medical_treatment/XEH_PREP.hpp @@ -1,4 +1,5 @@ +// actions PREP(actionCheckBloodPressure); PREP(actionCheckBloodPressureLocal); PREP(actionCheckPulse); @@ -8,6 +9,31 @@ PREP(actionDiagnose); PREP(actionLoadUnit); PREP(actionPlaceInBodyBag); PREP(actionUnloadUnit); + +// treaments +PREP(canTreat); +PREP(canTreatCached); +PREP(treatment); +PREP(treatment_success); +PREP(treatment_failure); + +PREP(treatmentBandage); +PREP(treatmentBandageLocal); +PREP(treatmentTourniquet); +PREP(treatmentTourniquetLocal); +PREP(treatmentTourniquetRemove); +PREP(treatmentMedication); +PREP(treatmentMedicationLocal); +PREP(treatmentIV); +PREP(treatmentIVLocal); +PREP(treatmentCPR); +PREP(treatmentCPRLocal); +PREP(treatmentFullHeal); +PREP(treatmentFullHealLocal); +PREP(treatmentFullHealTreatmentTime); +PREP(treatmentSurgicalKit_onProgress); + +// misc PREP(addToLog); PREP(addToTriageCard); PREP(addUnloadPatientActions); @@ -22,33 +48,6 @@ PREP(isBeingDragged); PREP(medicationEffectLoop); PREP(onMedicationUsage); -// treaments -PREP(canTreat); -PREP(canTreatCached); -PREP(treatment); -PREP(treatment_success); -PREP(treatment_failure); - -PREP(treatmentBandage); -PREP(treatmentBandageLocal); -PREP(treatmentTourniquet); -PREP(treatmentTourniquetLocal); -PREP(treatmentTourniquetRemove); -PREP(treatmentMorphine); -PREP(treatmentMorphineLocal); -PREP(treatmentEpipen); -//PREP(treatmentEpipenLocal); -PREP(treatmentMedication); -PREP(treatmentMedicationLocal); -PREP(treatmentIV); -PREP(treatmentIVLocal); -PREP(treatmentCPR); -PREP(treatmentCPRLocal); -PREP(treatmentFullHeal); -PREP(treatmentFullHealLocal); -PREP(treatmentFullHealTreatmentTime); -PREP(treatmentSurgicalKit_onProgress); - // items PREP(checkItems); PREP(hasItem); diff --git a/addons/medical_treatment/XEH_postInit.sqf b/addons/medical_treatment/XEH_postInit.sqf index c9eb328322..86f2cf1ffa 100644 --- a/addons/medical_treatment/XEH_postInit.sqf +++ b/addons/medical_treatment/XEH_postInit.sqf @@ -10,8 +10,6 @@ if (isServer) then { // treatment events [QGVAR(treatmentBandageLocal), FUNC(treatmentBandageLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentTourniquetLocal), FUNC(treatmentTourniquetLocal)] call CBA_fnc_addEventHandler; -//[QGVAR(treatmentMorphineLocal), FUNC(treatmentMorphineLocal)] call CBA_fnc_addEventHandler; -//[QGVAR(treatmentEpipenLocal), FUNC(treatmentEpipenLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentMedicationLocal), FUNC(treatmentMedicationLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentIVLocal), FUNC(treatmentIVLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentCPRLocal), FUNC(treatmentCPRLocal)] call CBA_fnc_addEventHandler; diff --git a/addons/medical_treatment/functions/fnc_treatmentEpipen.sqf b/addons/medical_treatment/functions/fnc_treatmentEpipen.sqf deleted file mode 100644 index 3dae4dc811..0000000000 --- a/addons/medical_treatment/functions/fnc_treatmentEpipen.sqf +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Author: KoffeinFlummi - * Callback when the epipen treatment is complete - * - * Arguments: - * 0: The medic - * 1: The patient - * 2: Body part - * 3: Treatment class name - * - * Return Value: - * None - * - * Public: No - */ -#include "script_component.hpp" - -params ["_caller", "_target"]; - -[_target, false] call EFUNC(medical,setUnconscious); diff --git a/addons/medical_treatment/functions/fnc_treatmentMedicationLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentMedicationLocal.sqf index a91174f2c0..faa87fbafb 100644 --- a/addons/medical_treatment/functions/fnc_treatmentMedicationLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentMedicationLocal.sqf @@ -17,6 +17,25 @@ params ["_target", "_className", "_partIndex"]; TRACE_3("params",_target,_className,_partIndex); +if !(EGVAR(medical,advancedMedication)) exitWith { + if (_className == "Morphine") exitWith { + #define MORPHINEHEAL 0.4 + + params ["_target"]; + + // reduce pain, pain sensitivity + private _morphine = ((_target getVariable [QEGVAR(medical,morphine), 0]) + MORPHINEHEAL) min 1; + _target setVariable [QEGVAR(medical,morphine), _morphine, true]; + + private _pain = ((_target getVariable [QEGVAR(medical,pain), 0]) - MORPHINEHEAL) max 0; + _target setVariable [QEGVAR(medical,pain), _pain, true]; + }; + + if (_className == "Epinephrine") exitWith { + [_target, false] call EFUNC(medical,setUnconscious); + }; +}; + private _tourniquets = _target getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; if (_tourniquets select _partIndex > 0) exitWith { @@ -35,7 +54,7 @@ private _currentInSystem = _target getVariable [_varName, 0]; _target setVariable [_varName, _currentInSystem + 1]; // Find the proper attributes for the used medication -private _medicationConfig = (configFile >> "ace_medical_treatment" >> "Medication"); +private _medicationConfig = configFile >> "ace_medical_treatment" >> "Medication"; private _painReduce = getNumber (_medicationConfig >> "painReduce"); private _hrIncreaseLow = getArray (_medicationConfig >> "hrIncreaseLow"); private _hrIncreaseNorm = getArray (_medicationConfig >> "hrIncreaseNormal"); @@ -48,7 +67,7 @@ private _hrCallback = getText (_medicationConfig >> "hrCallback"); private _inCompatableMedication = []; if (isClass (_medicationConfig >> _className)) then { - _medicationConfig = (_medicationConfig >> _className); + _medicationConfig = _medicationConfig >> _className; if (isNumber (_medicationConfig >> "painReduce")) then { _painReduce = getNumber (_medicationConfig >> "painReduce");}; if (isArray (_medicationConfig >> "hrIncreaseLow")) then { _hrIncreaseLow = getArray (_medicationConfig >> "hrIncreaseLow"); }; if (isArray (_medicationConfig >> "hrIncreaseNormal")) then { _hrIncreaseNorm = getArray (_medicationConfig >> "hrIncreaseNormal"); }; @@ -91,6 +110,7 @@ if (_painReduce > 0) then { // Reduce pain private _painSuppress = _target getVariable [QEGVAR(medical,painSuppress), 0]; _target setVariable [QEGVAR(medical,painSuppress), (_painSuppress + _painReduce) max 0]; + if (!GVAR(painIsOnlySuppressed)) then { _pain = _target getVariable [QEGVAR(medical,pain), 0]; _target setVariable [QEGVAR(medical,pain), (_pain - _painReduce) max 0, true]; @@ -101,6 +121,6 @@ private _resistance = _target getVariable [QEGVAR(medical,peripheralResistance), _target setVariable [QEGVAR(medical,peripheralResistance), (_resistance + _viscosityChange) max 0]; // Call back to ensure that the medication is decreased over time -[_target, _classname, _varName, _maxDose, _timeInSystem, _inCompatableMedication, _viscosityChange, _painReduce] call FUNC(onMedicationUsage); +[_target, _className, _varName, _maxDose, _timeInSystem, _inCompatableMedication, _viscosityChange, _painReduce] call FUNC(onMedicationUsage); true diff --git a/addons/medical_treatment/functions/fnc_treatmentMorphine.sqf b/addons/medical_treatment/functions/fnc_treatmentMorphine.sqf deleted file mode 100644 index 3a396a2bc9..0000000000 --- a/addons/medical_treatment/functions/fnc_treatmentMorphine.sqf +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Author: KoffeinFlummi - * Callback when the morphine treatment is complete - * - * Arguments: - * 0: The medic - * 1: The patient - * 2: Body part - * 3: Treatment class name - * - * Return Value: - * None - * - * Public: No - */ -#include "script_component.hpp" - -#define MORPHINEHEAL 0.4 - -params ["_caller", "_target"]; - -[QGVAR(treatmentMorphineLocal), [_target], _target] call CBA_fnc_targetEvent; diff --git a/addons/medical_treatment/functions/fnc_treatmentMorphineLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentMorphineLocal.sqf deleted file mode 100644 index 15b0e543f3..0000000000 --- a/addons/medical_treatment/functions/fnc_treatmentMorphineLocal.sqf +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Author: KoffeinFlummi - * Local callback when the morphine treatment is complete - * - * Arguments: - * 0: The patient - * - * Return Value: - * None - * - * Public: No - */ -#include "script_component.hpp" - -#define MORPHINEHEAL 0.4 - -params ["_target"]; - -// reduce pain, pain sensitivity -private _morphine = ((_target getVariable [QEGVAR(medical,morphine), 0]) + MORPHINEHEAL) min 1; -_target setVariable [QEGVAR(medical,morphine), _morphine, true]; - -private _pain = ((_target getVariable [QEGVAR(medical,pain), 0]) - MORPHINEHEAL) max 0; -_target setVariable [QEGVAR(medical,pain), _pain, true]; - -// @todo overdose