ACE3/addons/medical_treatment/functions/fnc_onMedicationUsage.sqf
BAXENdev a0f3933bf0
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>
2024-02-13 02:45:04 -08:00

69 lines
2.4 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: Glowbal
* Handles the medication given to a patient.
*
* Arguments:
* 0: The patient <OBJECT>
* 1: Medication Treatment classname <STRING>
* 2: Max dose (0 to ignore) <NUMBER>
* 3: Max dose deviation <NUMBER>
* 3: Incompatable medication <ARRAY<STRING>>
*
* Return Value:
* None
*
* Example:
* [player, "morphine", 4, 2, [["x", 1]]] call ace_medical_treatment_fnc_onMedicationUsage
*
* Public: No
*/
params ["_target", "_className", "_maxDose", "_maxDoseDeviation", "_incompatibleMedication"];
TRACE_5("onMedicationUsage",_target,_className,_maxDose,_maxDoseDeviation,_incompatibleMedication);
private _overdosedMedications = [];
// Check for overdose from current medication
if (_maxDose > 0) then {
private _currentDose = [_target, _className] call EFUNC(medical_status,getMedicationCount);
// 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;
};
};
// Check incompatible medication (format [med,limit])
{
_x params ["_xMed", "_xLimit"];
private _inSystem = [_target, _xMed] call EFUNC(medical_status,getMedicationCount);
if (_inSystem> _xLimit) then {
_overdosedMedications pushBackUnique _xMed;
};
} forEach _incompatibleMedication;
if (_overdosedMedications isNotEqualTo []) then {
private _medicationConfig = (configFile >> "ace_medical_treatment" >> "Medication");
private _onOverDose = getText (_medicationConfig >> "onOverDose");
if (isClass (_medicationConfig >> _className)) then {
_medicationConfig = (_medicationConfig >> _className);
if (isText (_medicationConfig >> "onOverDose")) then { _onOverDose = getText (_medicationConfig >> "onOverDose"); };
};
TRACE_2("overdose",_overdosedMedications,_onOverDose);
if (_onOverDose == "") exitWith {
TRACE_1("CriticalVitals Event",_target); // make unconscious
[QEGVAR(medical,CriticalVitals), _target] call CBA_fnc_localEvent;
};
if (isNil _onOverDose) then {
_onOverDose = compile _onOverDose;
} else {
_onOverDose = missionNamespace getVariable _onOverDose;
};
[_target, _className, _overdosedMedications] call _onOverDose;
};