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>
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Succesful treatment started <BOOL>
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-03-03 19:07:09 +00:00
|
|
|
private ["_target", "_className", "_currentInSystem", "_medicationConfig", "_painReduce", "_hrIncreaseLow", "_hrIncreaseNorm", "_hrIncreaseHigh", "_maxDose", "_inCompatableMedication", "_timeInSystem", "_heartRate", "_pain", "_resistance", "_hrCallback"];
|
2015-02-21 20:10:57 +00:00
|
|
|
_target = _this select 0;
|
|
|
|
_className = _this select 1;
|
|
|
|
|
|
|
|
// We have added a new dose of this medication to our system, so let's increase it
|
2015-02-28 10:41:27 +00:00
|
|
|
_varName = format[QGVAR(%1_inSystem), _className];
|
2015-02-21 20:10:57 +00:00
|
|
|
_currentInSystem = _target getvariable [_varName, 0];
|
|
|
|
_currentInSystem = _currentInSystem + 1;
|
|
|
|
_target setvariable [_varName, _currentInSystem];
|
|
|
|
|
|
|
|
// Find the proper attributes for the used medication
|
|
|
|
_medicationConfig = (configFile >> "ACE_Medical_Advanced" >> "Treatment" >> "Medication");
|
|
|
|
_painReduce = getNumber (_medicationConfig >> "painReduce");
|
|
|
|
_hrIncreaseLow = getArray (_medicationConfig >> "hrIncreaseLow");
|
|
|
|
_hrIncreaseNorm = getArray (_medicationConfig >> "hrIncreaseNormal");
|
|
|
|
_hrIncreaseHigh = getArray (_medicationConfig >> "hrIncreaseHigh");
|
|
|
|
_timeInSystem = getNumber (_medicationConfig >> "timeInSystem");
|
|
|
|
_maxDose = getNumber (_medicationConfig >> "maxDose");
|
2015-03-03 18:56:32 +00:00
|
|
|
_viscosityChange = getNumber (_medicationConfig >> "viscosityChange");
|
2015-03-03 19:07:09 +00:00
|
|
|
_hrCallback = getText (_medicationConfig >> "hrCallback");
|
2015-03-03 18:56:32 +00:00
|
|
|
|
2015-02-21 20:10:57 +00:00
|
|
|
_inCompatableMedication = [];
|
|
|
|
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-03-03 19:12:57 +00:00
|
|
|
_hrCallback = missionNamespace getvariable _hrCallback;
|
2015-02-21 20:10:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Adjust the heart rate based upon config entry
|
|
|
|
_heartRate = _target getvariable [QGVAR(heartRate), 70];
|
|
|
|
if (alive _target) then {
|
|
|
|
if (_heartRate > 0) then {
|
|
|
|
if (_heartRate <= 45) then {
|
2015-03-03 19:07:09 +00:00
|
|
|
[_target, ((_hrIncreaseLow select 0) + random((_hrIncreaseLow select 1))), (_hrIncreaseLow select 2), _hrCallback] call FUNC(addHeartRateAdjustment);
|
2015-02-21 20:10:57 +00:00
|
|
|
} else {
|
|
|
|
if (_heartRate > 120) then {
|
2015-03-03 19:07:09 +00:00
|
|
|
[_target, ((_hrIncreaseHigh select 0) + random((_hrIncreaseHigh select 1))), (_hrIncreaseHigh select 2), _hrCallback] call FUNC(addHeartRateAdjustment);
|
2015-02-21 20:10:57 +00:00
|
|
|
} else {
|
2015-03-03 19:07:09 +00:00
|
|
|
[_target, ((_hrIncreaseNorm select 0) + random((_hrIncreaseNorm select 1))), (_hrIncreaseNorm select 2), _hrCallback] call FUNC(addHeartRateAdjustment);
|
2015-02-21 20:10:57 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// Reduce the pain level
|
|
|
|
_pain = _target getvariable [QGVAR(pain), 0];
|
2015-03-22 22:24:24 +00:00
|
|
|
_target setvariable [QGVAR(pain), (_pain - _painReduce) max 0];
|
2015-02-21 20:10:57 +00:00
|
|
|
|
2015-03-03 18:56:32 +00:00
|
|
|
_resistance = _unit getvariable [QGVAR(peripheralResistance), 100];
|
|
|
|
_resistance = _resistance + _viscosityChange;
|
2015-03-03 18:58:58 +00:00
|
|
|
_unit setvariable [QGVAR(peripheralResistance), _resistance max 0];
|
2015-03-03 18:56:32 +00:00
|
|
|
|
2015-02-21 20:10:57 +00:00
|
|
|
// Call back to ensure that the medication is decreased over time
|
2015-03-03 18:56:32 +00:00
|
|
|
[_target, _classname, _varName, _maxDose, _timeInSystem, _inCompatableMedication, _viscosityChange] call FUNC(onMedicationUsage);
|
2015-02-21 20:10:57 +00:00
|
|
|
|
|
|
|
true
|