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>
This commit is contained in:
BAXENdev 2024-02-13 05:45:04 -05:00 committed by GitHub
parent 05a5ccd140
commit a0f3933bf0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 11 deletions

View File

@ -565,8 +565,11 @@ class ADDON {
timeInSystem = 120; timeInSystem = 120;
// How long until the maximum effect is reached // How long until the maximum effect is reached
timeTillMaxEffect = 30; 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; 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 <OBJECT>, 1: medicationClassName <STRING> // Function to execute upon overdose. Arguments passed to call back are 0: unit <OBJECT>, 1: medicationClassName <STRING>
onOverDose = ""; 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 // 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}; hrIncreaseHigh[] = {10, 40};
timeInSystem = 120; timeInSystem = 120;
timeTillMaxEffect = 10; timeTillMaxEffect = 10;
maxDose = 10; maxDose = 9;
incompatibleMedication[] = {}; incompatibleMedication[] = {};
}; };
class Adenosine { class Adenosine {
@ -601,7 +604,7 @@ class ADDON {
hrIncreaseHigh[] = {-15, -35}; hrIncreaseHigh[] = {-15, -35};
timeInSystem = 120; timeInSystem = 120;
timeTillMaxEffect = 15; timeTillMaxEffect = 15;
maxDose = 6; maxDose = 5;
incompatibleMedication[] = {}; incompatibleMedication[] = {};
}; };
class PainKillers { class PainKillers {
@ -611,7 +614,7 @@ class ADDON {
hrIncreaseHigh[] = {-5, -17}; hrIncreaseHigh[] = {-5, -17};
timeInSystem = 420; timeInSystem = 420;
timeTillMaxEffect = 60; timeTillMaxEffect = 60;
maxDose = 6; maxDose = 5;
incompatibleMedication[] = {}; incompatibleMedication[] = {};
viscosityChange = 5; viscosityChange = 5;
}; };

View File

@ -59,6 +59,7 @@ private _painReduce = GET_NUMBER(_medicationConfig >> "painReduce",g
private _timeInSystem = GET_NUMBER(_medicationConfig >> "timeInSystem",getNumber (_defaultConfig >> "timeInSystem")); private _timeInSystem = GET_NUMBER(_medicationConfig >> "timeInSystem",getNumber (_defaultConfig >> "timeInSystem"));
private _timeTillMaxEffect = GET_NUMBER(_medicationConfig >> "timeTillMaxEffect",getNumber (_defaultConfig >> "timeTillMaxEffect")); private _timeTillMaxEffect = GET_NUMBER(_medicationConfig >> "timeTillMaxEffect",getNumber (_defaultConfig >> "timeTillMaxEffect"));
private _maxDose = GET_NUMBER(_medicationConfig >> "maxDose",getNumber (_defaultConfig >> "maxDose")); 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 _viscosityChange = GET_NUMBER(_medicationConfig >> "viscosityChange",getNumber (_defaultConfig >> "viscosityChange"));
private _hrIncreaseLow = GET_ARRAY(_medicationConfig >> "hrIncreaseLow",getArray (_defaultConfig >> "hrIncreaseLow")); private _hrIncreaseLow = GET_ARRAY(_medicationConfig >> "hrIncreaseLow",getArray (_defaultConfig >> "hrIncreaseLow"));
private _hrIncreaseNormal = GET_ARRAY(_medicationConfig >> "hrIncreaseNormal",getArray (_defaultConfig >> "hrIncreaseNormal")); 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); [_patient, _className, _timeTillMaxEffect, _timeInSystem, _heartRateChange, _painReduce, _viscosityChange] call EFUNC(medical_status,addMedicationAdjustment);
// Check for medication compatiblity // Check for medication compatiblity
[_patient, _className, _maxDose, _incompatibleMedication] call FUNC(onMedicationUsage); [_patient, _className, _maxDose, _maxDoseDeviation, _incompatibleMedication] call FUNC(onMedicationUsage);

View File

@ -6,27 +6,33 @@
* Arguments: * Arguments:
* 0: The patient <OBJECT> * 0: The patient <OBJECT>
* 1: Medication Treatment classname <STRING> * 1: Medication Treatment classname <STRING>
* 2: Max dosage (0 to ignore) <NUMBER> * 2: Max dose (0 to ignore) <NUMBER>
* 3: Max dose deviation <NUMBER>
* 3: Incompatable medication <ARRAY<STRING>> * 3: Incompatable medication <ARRAY<STRING>>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * 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 * Public: No
*/ */
params ["_target", "_className", "_maxDosage", "_incompatibleMedication"]; params ["_target", "_className", "_maxDose", "_maxDoseDeviation", "_incompatibleMedication"];
TRACE_4("onMedicationUsage",_target,_className,_maxDosage,_incompatibleMedication); TRACE_5("onMedicationUsage",_target,_className,_maxDose,_maxDoseDeviation,_incompatibleMedication);
private _overdosedMedications = []; private _overdosedMedications = [];
// Check for overdose from current medication // Check for overdose from current medication
if (_maxDosage > 0) then { if (_maxDose > 0) then {
private _currentDose = [_target, _className] call EFUNC(medical_status,getMedicationCount); 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); TRACE_1("exceeded max dose",_currentDose);
_overdosedMedications pushBackUnique _className; _overdosedMedications pushBackUnique _className;
}; };