2015-02-21 20:10:57 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Handles the medication given to a patient.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The patient <OBJECT>
|
|
|
|
* 1: Treatment classname <STRING>
|
2016-02-03 20:40:26 +00:00
|
|
|
* 2: Injection Site Part Number <NUMBER>
|
2015-02-21 20:10:57 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Succesful treatment started <BOOL>
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [medic, "bandage", 2] call ace_medical_fnc_treatmentAdvanced_medicationLocal
|
|
|
|
*
|
2015-02-21 20:10:57 +00:00
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2016-02-03 20:40:26 +00:00
|
|
|
params ["_target", "_className", "_partNumber"];
|
|
|
|
TRACE_3("params",_target,_className,_partNumber);
|
|
|
|
|
|
|
|
private _tourniquets = _target getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]];
|
|
|
|
if ((_tourniquets select _partNumber) > 0) exitWith {
|
|
|
|
TRACE_1("unit has tourniquets blocking blood flow on injection site",_tourniquets);
|
|
|
|
private _delayedMedications = _target getVariable [QGVAR(occludedMedications), []];
|
|
|
|
_delayedMedications pushBack _this;
|
|
|
|
_target setVariable [QGVAR(occludedMedications), _delayedMedications, true];
|
|
|
|
true
|
|
|
|
};
|
2015-02-21 20:10:57 +00:00
|
|
|
|
|
|
|
// We have added a new dose of this medication to our system, so let's increase it
|
2016-06-13 00:34:56 +00:00
|
|
|
private _varName = format[QGVAR(%1_inSystem), _className];
|
|
|
|
private _currentInSystem = _target getVariable [_varName, 0];
|
|
|
|
_target setVariable [_varName, _currentInSystem + 1];
|
2015-02-21 20:10:57 +00:00
|
|
|
|
|
|
|
// Find the proper attributes for the used medication
|
2016-06-13 00:34:56 +00:00
|
|
|
private _medicationConfig = (configFile >> "ACE_Medical_Advanced" >> "Treatment" >> "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 _maxDose = getNumber (_medicationConfig >> "maxDose");
|
|
|
|
private _viscosityChange = getNumber (_medicationConfig >> "viscosityChange");
|
|
|
|
private _hrCallback = getText (_medicationConfig >> "hrCallback");
|
2015-03-03 18:56:32 +00:00
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
private _inCompatableMedication = [];
|
2015-02-21 20:10:57 +00:00
|
|
|
if (isClass (_medicationConfig >> _className)) then {
|
|
|
|
_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 >> "maxDose")) then { _maxDose = getNumber (_medicationConfig >> "maxDose"); };
|
|
|
|
if (isArray (_medicationConfig >> "inCompatableMedication")) then { _inCompatableMedication = getArray (_medicationConfig >> "inCompatableMedication"); };
|
2015-03-03 18:56:32 +00:00
|
|
|
if (isNumber (_medicationConfig >> "viscosityChange")) then { _viscosityChange = getNumber (_medicationConfig >> "viscosityChange"); };
|
2015-03-03 19:07:09 +00:00
|
|
|
if (isText (_medicationConfig >> "hrCallback")) then { _hrCallback = getText (_medicationConfig >> "hrCallback"); };
|
|
|
|
};
|
|
|
|
if (isNil _hrCallback) then {
|
|
|
|
_hrCallback = compile _hrCallback;
|
|
|
|
} else {
|
2015-11-30 16:27:09 +00:00
|
|
|
_hrCallback = missionNamespace getVariable _hrCallback;
|
2015-02-21 20:10:57 +00:00
|
|
|
};
|
2016-03-03 19:23:53 +00:00
|
|
|
if (!(_hrCallback isEqualType {})) then {_hrCallback = {TRACE_1("callback was NOT code",_hrCallback)};};
|
2015-02-21 20:10:57 +00:00
|
|
|
|
|
|
|
// Adjust the heart rate based upon config entry
|
2016-06-13 00:34:56 +00:00
|
|
|
private _heartRate = _target getVariable [QGVAR(heartRate), 70];
|
2015-02-21 20:10:57 +00:00
|
|
|
if (alive _target) then {
|
|
|
|
if (_heartRate > 0) then {
|
|
|
|
if (_heartRate <= 45) then {
|
2015-06-14 08:54:50 +00:00
|
|
|
[_target, ((_hrIncreaseLow select 0) + random ((_hrIncreaseLow select 1) - (_hrIncreaseLow select 0))), (_hrIncreaseLow select 2), _hrCallback] call FUNC(addHeartRateAdjustment);
|
2015-02-21 20:10:57 +00:00
|
|
|
} else {
|
|
|
|
if (_heartRate > 120) then {
|
2015-06-14 08:54:50 +00:00
|
|
|
[_target, ((_hrIncreaseHigh select 0) + random ((_hrIncreaseHigh select 1) - (_hrIncreaseHigh select 0))), (_hrIncreaseHigh select 2), _hrCallback] call FUNC(addHeartRateAdjustment);
|
2015-02-21 20:10:57 +00:00
|
|
|
} else {
|
2015-06-14 08:54:50 +00:00
|
|
|
[_target, ((_hrIncreaseNorm select 0) + random ((_hrIncreaseNorm select 1) - (_hrIncreaseNorm select 0))), (_hrIncreaseNorm select 2), _hrCallback] call FUNC(addHeartRateAdjustment);
|
2015-02-21 20:10:57 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-04-06 22:41:53 +00:00
|
|
|
if (_painReduce > 0) then {
|
2015-06-11 20:35:50 +00:00
|
|
|
// Reduce pain
|
2016-06-13 00:34:56 +00:00
|
|
|
private _painSuppress = _target getVariable [QGVAR(painSuppress), 0];
|
2015-11-30 16:27:09 +00:00
|
|
|
_target setVariable [QGVAR(painSuppress), (_painSuppress + _painReduce) max 0];
|
2015-06-11 20:35:50 +00:00
|
|
|
if (!GVAR(painIsOnlySuppressed)) then {
|
2015-11-30 16:27:09 +00:00
|
|
|
_pain = _target getVariable [QGVAR(pain), 0];
|
|
|
|
_target setVariable [QGVAR(pain), (_pain - _painReduce) max 0, true];
|
2015-06-11 15:36:18 +00:00
|
|
|
};
|
2015-04-06 22:41:53 +00:00
|
|
|
};
|
2015-02-21 20:10:57 +00:00
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
private _resistance = _target getVariable [QGVAR(peripheralResistance), 100];
|
|
|
|
_target setVariable [QGVAR(peripheralResistance), (_resistance + _viscosityChange) max 0];
|
2015-03-03 18:56:32 +00:00
|
|
|
|
2015-10-21 20:52:21 +00:00
|
|
|
// Call back to ensure that the medication is decreased over time
|
2015-05-16 14:09:30 +00:00
|
|
|
[_target, _classname, _varName, _maxDose, _timeInSystem, _inCompatableMedication, _viscosityChange, _painReduce] call FUNC(onMedicationUsage);
|
2015-02-21 20:10:57 +00:00
|
|
|
|
|
|
|
true
|