From a0f3933bf015f19759ced08a38deaae515b739f6 Mon Sep 17 00:00:00 2001 From: BAXENdev <83290629+BAXENdev@users.noreply.github.com> Date: Tue, 13 Feb 2024 05:45:04 -0500 Subject: [PATCH] Medical - Change max medication dosage behavior (#9746) * Consistentency Update with Overdosing * Added Description to Condition Cases * Updated to CASE 2 Overdose behavior: ODs on uses `_maxDose + {1 or 2 or 3}` from `_maxDose + {0 or 1 or 2}` * Update fnc_onMedicationUsage.sqf * Update fnc_onMedicationUsage.sqf * Added riskDose range and updated medications * maxDose -> maxSafeDose | riskDose -> chanceDoses * Fixed maxDose reference in trace * Added chanceDoses to trace * Fixed use of TRACE macro * Updated comments and variable maxSafeDose -> maxDose * Updated comment and overdose formula * chanceDoses -> maxDoseDeviation * Update addons/medical_treatment/functions/fnc_onMedicationUsage.sqf * Update addons/medical_treatment/functions/fnc_onMedicationUsage.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Update addons/medical_treatment/ACE_Medical_Treatment.hpp --------- Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> --- .../ACE_Medical_Treatment.hpp | 11 +++++++---- .../functions/fnc_medicationLocal.sqf | 3 ++- .../functions/fnc_onMedicationUsage.sqf | 18 ++++++++++++------ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/addons/medical_treatment/ACE_Medical_Treatment.hpp b/addons/medical_treatment/ACE_Medical_Treatment.hpp index d1ea741cb3..267a45dd44 100644 --- a/addons/medical_treatment/ACE_Medical_Treatment.hpp +++ b/addons/medical_treatment/ACE_Medical_Treatment.hpp @@ -565,8 +565,11 @@ class ADDON { timeInSystem = 120; // How long until the maximum effect is reached timeTillMaxEffect = 30; - // How many of this type of medication can be in the system before the patient overdoses? + // How many of this type of medication can be in the system before the patient can possibly overdose? maxDose = 4; + // The number of doses over maxDose where there is a chance to overdose. + // Example with maxDose = 4 and maxDoseDeviation = 2: Dose 4: Safe | Dose 5 and 6: Possible overdose | Dose 7: Guaranteed overdose + maxDoseDeviation = 2; // Function to execute upon overdose. Arguments passed to call back are 0: unit , 1: medicationClassName onOverDose = ""; // The viscosity of a fluid is a measure of its resistance to gradual deformation by shear stress or tensile stress. For liquids, it corresponds to the informal concept of "thickness". This value will increase/decrease the viscoty of the blood with the percentage given. Where 100 = max. Using the minus will decrease viscosity @@ -591,7 +594,7 @@ class ADDON { hrIncreaseHigh[] = {10, 40}; timeInSystem = 120; timeTillMaxEffect = 10; - maxDose = 10; + maxDose = 9; incompatibleMedication[] = {}; }; class Adenosine { @@ -601,7 +604,7 @@ class ADDON { hrIncreaseHigh[] = {-15, -35}; timeInSystem = 120; timeTillMaxEffect = 15; - maxDose = 6; + maxDose = 5; incompatibleMedication[] = {}; }; class PainKillers { @@ -611,7 +614,7 @@ class ADDON { hrIncreaseHigh[] = {-5, -17}; timeInSystem = 420; timeTillMaxEffect = 60; - maxDose = 6; + maxDose = 5; incompatibleMedication[] = {}; viscosityChange = 5; }; diff --git a/addons/medical_treatment/functions/fnc_medicationLocal.sqf b/addons/medical_treatment/functions/fnc_medicationLocal.sqf index b5499e9bb4..0d0aa735ce 100644 --- a/addons/medical_treatment/functions/fnc_medicationLocal.sqf +++ b/addons/medical_treatment/functions/fnc_medicationLocal.sqf @@ -59,6 +59,7 @@ private _painReduce = GET_NUMBER(_medicationConfig >> "painReduce",g private _timeInSystem = GET_NUMBER(_medicationConfig >> "timeInSystem",getNumber (_defaultConfig >> "timeInSystem")); private _timeTillMaxEffect = GET_NUMBER(_medicationConfig >> "timeTillMaxEffect",getNumber (_defaultConfig >> "timeTillMaxEffect")); private _maxDose = GET_NUMBER(_medicationConfig >> "maxDose",getNumber (_defaultConfig >> "maxDose")); +private _maxDoseDeviation = GET_NUMBER(_medicationConfig >> "maxDoseDeviation",getNumber (_defaultConfig >> "maxDoseDeviation")); private _viscosityChange = GET_NUMBER(_medicationConfig >> "viscosityChange",getNumber (_defaultConfig >> "viscosityChange")); private _hrIncreaseLow = GET_ARRAY(_medicationConfig >> "hrIncreaseLow",getArray (_defaultConfig >> "hrIncreaseLow")); private _hrIncreaseNormal = GET_ARRAY(_medicationConfig >> "hrIncreaseNormal",getArray (_defaultConfig >> "hrIncreaseNormal")); @@ -75,4 +76,4 @@ TRACE_3("adjustments",_heartRateChange,_painReduce,_viscosityChange); [_patient, _className, _timeTillMaxEffect, _timeInSystem, _heartRateChange, _painReduce, _viscosityChange] call EFUNC(medical_status,addMedicationAdjustment); // Check for medication compatiblity -[_patient, _className, _maxDose, _incompatibleMedication] call FUNC(onMedicationUsage); +[_patient, _className, _maxDose, _maxDoseDeviation, _incompatibleMedication] call FUNC(onMedicationUsage); diff --git a/addons/medical_treatment/functions/fnc_onMedicationUsage.sqf b/addons/medical_treatment/functions/fnc_onMedicationUsage.sqf index 6235358446..cd26d15424 100644 --- a/addons/medical_treatment/functions/fnc_onMedicationUsage.sqf +++ b/addons/medical_treatment/functions/fnc_onMedicationUsage.sqf @@ -6,27 +6,33 @@ * Arguments: * 0: The patient * 1: Medication Treatment classname - * 2: Max dosage (0 to ignore) + * 2: Max dose (0 to ignore) + * 3: Max dose deviation * 3: Incompatable medication > * * Return Value: * None * * Example: - * [player, "morphine", 4, [["x", 1]]] call ace_medical_treatment_fnc_onMedicationUsage + * [player, "morphine", 4, 2, [["x", 1]]] call ace_medical_treatment_fnc_onMedicationUsage * * Public: No */ -params ["_target", "_className", "_maxDosage", "_incompatibleMedication"]; -TRACE_4("onMedicationUsage",_target,_className,_maxDosage,_incompatibleMedication); +params ["_target", "_className", "_maxDose", "_maxDoseDeviation", "_incompatibleMedication"]; +TRACE_5("onMedicationUsage",_target,_className,_maxDose,_maxDoseDeviation,_incompatibleMedication); private _overdosedMedications = []; // Check for overdose from current medication -if (_maxDosage > 0) then { +if (_maxDose > 0) then { private _currentDose = [_target, _className] call EFUNC(medical_status,getMedicationCount); - if (_currentDose >= floor (_maxDosage + round(random(2)))) then { + // Because both {floor random 0} and {floor random 1} return 0 + if (_maxDoseDeviation > 0) then { + _maxDoseDeviation = _maxDoseDeviation + 1; + }; + + if (_currentDose > _maxDose + (floor random _maxDoseDeviation)) then { TRACE_1("exceeded max dose",_currentDose); _overdosedMedications pushBackUnique _className; };