ACE3/addons/medical_treatment/functions/fnc_treatmentMedicationLocal.sqf

88 lines
4.3 KiB
Plaintext
Raw Normal View History

#include "script_component.hpp"
/*
* Author: Glowbal
* Handles the medication given to a patient.
*
* Arguments:
* 0: The patient <OBJECT>
2016-10-15 11:48:13 +00:00
* 1: Treatment class name <STRING>
* 2: Injection Site Part Number <NUMBER>
*
* Return Value:
* Succesful treatment started <BOOL>
*
* Example:
* [player, "Morphine", 2] call ace_medical_treatment_fnc_treatmentMedicationLocal
*
2019-03-30 16:07:54 +00:00
* Public: No
*/
2018-07-15 12:21:41 +00:00
#define MORPHINE_PAIN_SUPPRESSION 0.6
2016-10-15 11:48:13 +00:00
params ["_target", "_className", "_partIndex"];
TRACE_3("treatmentMedicationLocal",_target,_className,_partIndex);
if (!alive _target) exitWith {false};
if (!GVAR(advancedMedication)) exitWith {
TRACE_1("MedicalSettingAdvancedMedication is:", GVAR(advancedMedication));
2016-10-20 00:14:11 +00:00
if (_className == "Morphine") exitWith {
private _painSupress = GET_PAIN_SUPPRESS(_target);
_target setVariable [VAR_PAIN_SUPP, (_painSupress + MORPHINE_PAIN_SUPPRESSION) min 1, true];
2016-10-20 00:14:11 +00:00
};
if (_className == "Epinephrine") exitWith {
2016-12-05 20:34:20 +00:00
[QEGVAR(medical,WakeUp), _target] call CBA_fnc_localEvent;
2016-10-20 00:14:11 +00:00
};
};
2018-07-15 12:21:41 +00:00
TRACE_1("Running treatmentMedicationLocal with Advanced configuration for", _target);
2016-10-20 00:14:11 +00:00
private _tourniquets = GET_TOURNIQUETS(_target);
2016-10-15 11:48:13 +00:00
if (_tourniquets select _partIndex > 0) exitWith {
TRACE_1("unit has tourniquets blocking blood flow on injection site",_tourniquets);
private _delayedMedications = _target getVariable [QEGVAR(medical,occludedMedications), []];
_delayedMedications pushBack _this;
_target setVariable [QEGVAR(medical,occludedMedications), _delayedMedications, true];
true
};
// Find the proper attributes for the used medication
2016-10-20 11:38:26 +00:00
private _medicationConfig = configFile >> QUOTE(ADDON) >> "Medication";
private _painReduce = getNumber (_medicationConfig >> "painReduce");
private _hrIncreaseLow = getArray (_medicationConfig >> "hrIncreaseLow");
private _hrIncreaseNorm = getArray (_medicationConfig >> "hrIncreaseNormal");
private _hrIncreaseHigh = getArray (_medicationConfig >> "hrIncreaseHigh");
private _timeInSystem = getNumber (_medicationConfig >> "timeInSystem");
private _timeTillMaxEffect = getNumber (_medicationConfig >> "timeTillMaxEffect");
private _maxDose = getNumber (_medicationConfig >> "maxDose");
private _viscosityChange = getNumber (_medicationConfig >> "viscosityChange");
private _inCompatableMedication = [];
if (isClass (_medicationConfig >> _className)) then {
2016-10-20 00:14:11 +00:00
_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"); };
if (isArray (_medicationConfig >> "hrIncreaseHigh")) then { _hrIncreaseHigh = getArray (_medicationConfig >> "hrIncreaseHigh"); };
if (isNumber (_medicationConfig >> "timeInSystem")) then { _timeInSystem = getNumber (_medicationConfig >> "timeInSystem"); };
if (isNumber (_medicationConfig >> "timeTillMaxEffect")) then { _timeTillMaxEffect = getNumber (_medicationConfig >> "timeTillMaxEffect"); };
if (isNumber (_medicationConfig >> "maxDose")) then { _maxDose = getNumber (_medicationConfig >> "maxDose"); };
if (isArray (_medicationConfig >> "inCompatableMedication")) then { _inCompatableMedication = getArray (_medicationConfig >> "inCompatableMedication"); };
if (isNumber (_medicationConfig >> "viscosityChange")) then { _viscosityChange = getNumber (_medicationConfig >> "viscosityChange"); };
};
private _heartRate = GET_HEART_RATE(_target);
private _hrIncrease = [_hrIncreaseLow, _hrIncreaseNorm, _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);
[_target, _className, _timeTillMaxEffect, _timeInSystem, _heartRateChange, _painReduce, _viscosityChange] call EFUNC(medical_status,addMedicationAdjustment);
// Check for medication compatiblity
[_target, _className, _maxDose, _inCompatableMedication] call FUNC(onMedicationUsage);
true