2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2019-06-03 15:31:46 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal, mharis001
|
|
|
|
* Local callback for administering medication to a patient.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Patient <OBJECT>
|
|
|
|
* 1: Body Part <STRING>
|
|
|
|
* 2: Treatment <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, "RightArm", "Morphine"] call ace_medical_treatment_fnc_medicationLocal
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
// todo: move this macro to script_macros_medical.hpp?
|
|
|
|
#define MORPHINE_PAIN_SUPPRESSION 0.6
|
2024-04-11 15:58:50 +00:00
|
|
|
// 0.2625 = 0.6/0.8 * 0.35
|
|
|
|
// 0.6 = basic medication morph. pain suppr., 0.8 = adv. medication morph. pain suppr., 0.35 = adv. medication painkillers. pain suppr.
|
|
|
|
#define PAINKILLERS_PAIN_SUPPRESSION 0.2625
|
2019-06-03 15:31:46 +00:00
|
|
|
|
|
|
|
params ["_patient", "_bodyPart", "_classname"];
|
|
|
|
TRACE_3("medicationLocal",_patient,_bodyPart,_classname);
|
|
|
|
|
|
|
|
// Medication has no effects on dead units
|
|
|
|
if (!alive _patient) exitWith {};
|
|
|
|
|
|
|
|
// Exit with basic medication handling if advanced medication not enabled
|
|
|
|
if (!GVAR(advancedMedication)) exitWith {
|
|
|
|
switch (_classname) do {
|
|
|
|
case "Morphine": {
|
|
|
|
private _painSuppress = GET_PAIN_SUPPRESS(_patient);
|
|
|
|
_patient setVariable [VAR_PAIN_SUPP, (_painSuppress + MORPHINE_PAIN_SUPPRESSION) min 1, true];
|
|
|
|
};
|
|
|
|
case "Epinephrine": {
|
|
|
|
[QEGVAR(medical,WakeUp), _patient] call CBA_fnc_localEvent;
|
|
|
|
};
|
2024-04-11 15:58:50 +00:00
|
|
|
case "Painkillers": {
|
|
|
|
private _painSuppress = GET_PAIN_SUPPRESS(_patient);
|
|
|
|
_patient setVariable [VAR_PAIN_SUPP, (_painSuppress + PAINKILLERS_PAIN_SUPPRESSION) min 1, true];
|
|
|
|
};
|
2019-06-03 15:31:46 +00:00
|
|
|
};
|
|
|
|
};
|
2019-09-28 21:11:32 +00:00
|
|
|
TRACE_1("Running treatmentMedicationLocal with Advanced configuration for",_patient);
|
2019-06-03 15:31:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Handle tourniquet on body part blocking blood flow at injection site
|
2024-03-07 21:08:13 +00:00
|
|
|
private _partIndex = ALL_BODY_PARTS find tolowerANSI _bodyPart;
|
2019-06-03 15:31:46 +00:00
|
|
|
|
|
|
|
if (HAS_TOURNIQUET_APPLIED_ON(_patient,_partIndex)) exitWith {
|
|
|
|
TRACE_1("unit has tourniquets blocking blood flow on injection site",_tourniquets);
|
|
|
|
private _occludedMedications = _patient getVariable [QEGVAR(medical,occludedMedications), []];
|
|
|
|
_occludedMedications pushBack [_partIndex, _classname];
|
|
|
|
_patient setVariable [QEGVAR(medical,occludedMedications), _occludedMedications, true];
|
|
|
|
};
|
|
|
|
|
|
|
|
// Get adjustment attributes for used medication
|
|
|
|
private _defaultConfig = configFile >> QUOTE(ADDON) >> "Medication";
|
|
|
|
private _medicationConfig = _defaultConfig >> _classname;
|
|
|
|
|
|
|
|
private _painReduce = GET_NUMBER(_medicationConfig >> "painReduce",getNumber (_defaultConfig >> "painReduce"));
|
|
|
|
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"));
|
2024-02-13 10:45:04 +00:00
|
|
|
private _maxDoseDeviation = GET_NUMBER(_medicationConfig >> "maxDoseDeviation",getNumber (_defaultConfig >> "maxDoseDeviation"));
|
2019-06-03 15:31:46 +00:00
|
|
|
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"));
|
|
|
|
private _hrIncreaseHigh = GET_ARRAY(_medicationConfig >> "hrIncreaseHigh",getArray (_defaultConfig >> "hrIncreaseHigh"));
|
|
|
|
private _incompatibleMedication = GET_ARRAY(_medicationConfig >> "incompatibleMedication",getArray (_defaultConfig >> "incompatibleMedication"));
|
|
|
|
|
|
|
|
private _heartRate = GET_HEART_RATE(_patient);
|
|
|
|
private _hrIncrease = [_hrIncreaseLow, _hrIncreaseNormal, _hrIncreaseHigh] select (floor ((0 max _heartRate min 110) / 55));
|
|
|
|
_hrIncrease params ["_minIncrease", "_maxIncrease"];
|
|
|
|
private _heartRateChange = _minIncrease + random (_maxIncrease - _minIncrease);
|
|
|
|
|
|
|
|
// Adjust the medication effects and add the medication to the list
|
|
|
|
TRACE_3("adjustments",_heartRateChange,_painReduce,_viscosityChange);
|
|
|
|
[_patient, _className, _timeTillMaxEffect, _timeInSystem, _heartRateChange, _painReduce, _viscosityChange] call EFUNC(medical_status,addMedicationAdjustment);
|
|
|
|
|
|
|
|
// Check for medication compatiblity
|
2024-02-13 10:45:04 +00:00
|
|
|
[_patient, _className, _maxDose, _maxDoseDeviation, _incompatibleMedication] call FUNC(onMedicationUsage);
|