diff --git a/addons/medical/ACE_Medical_Treatments.hpp b/addons/medical/ACE_Medical_Treatments.hpp index b9019e42c7..b7a903f2c0 100644 --- a/addons/medical/ACE_Medical_Treatments.hpp +++ b/addons/medical/ACE_Medical_Treatments.hpp @@ -633,6 +633,9 @@ class ACE_Medical_Advanced { hrIncreaseLow[] = {0, 0, 0}; hrIncreaseNormal[] = {0, 0, 0}; hrIncreaseHigh[] = {0, 0, 0}; + // Callback once the heart rate values have been added. + hrCallback = ""; + // How long until this medication has disappeared timeInSystem = 120; // How many of this type of medication can be in the system before the patient overdoses? diff --git a/addons/medical/functions/fnc_getHeartRateChange.sqf b/addons/medical/functions/fnc_getHeartRateChange.sqf index 2f1b7bfab8..e7bc9407d2 100644 --- a/addons/medical/functions/fnc_getHeartRateChange.sqf +++ b/addons/medical/functions/fnc_getHeartRateChange.sqf @@ -34,7 +34,7 @@ if (!(_unit getvariable [QGVAR(inCardiacArrest),false])) then { _change = (_values / _time); _hrIncrease = _hrIncrease + _change; - if ( (_time - 1) < 0) then { + if ( (_time - 1) <= 0) then { _time = 0; _adjustment set [_foreachIndex, ObjNull]; [_unit] call _callBack; @@ -43,7 +43,8 @@ if (!(_unit getvariable [QGVAR(inCardiacArrest),false])) then { _adjustment set [_foreachIndex, [_values - _change, _time]]; }; } else { - _adjustment set [_foreachIndex, ObjNull]; + _adjustment set [_foreachIndex, ObjNull]; + [_unit] call _callBack; }; }foreach _adjustment; diff --git a/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf b/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf index 5f33df82d9..68e8caa88e 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf @@ -15,7 +15,7 @@ #include "script_component.hpp" -private ["_target", "_className", "_currentInSystem", "_medicationConfig", "_painReduce", "_hrIncreaseLow", "_hrIncreaseNorm", "_hrIncreaseHigh", "_maxDose", "_inCompatableMedication", "_timeInSystem", "_heartRate", "_pain", "_resistance"]; +private ["_target", "_className", "_currentInSystem", "_medicationConfig", "_painReduce", "_hrIncreaseLow", "_hrIncreaseNorm", "_hrIncreaseHigh", "_maxDose", "_inCompatableMedication", "_timeInSystem", "_heartRate", "_pain", "_resistance", "_hrCallback"]; _target = _this select 0; _className = _this select 1; @@ -34,6 +34,7 @@ _hrIncreaseHigh = getArray (_medicationConfig >> "hrIncreaseHigh"); _timeInSystem = getNumber (_medicationConfig >> "timeInSystem"); _maxDose = getNumber (_medicationConfig >> "maxDose"); _viscosityChange = getNumber (_medicationConfig >> "viscosityChange"); +_hrCallback = getText (_medicationConfig >> "hrCallback"); _inCompatableMedication = []; if (isClass (_medicationConfig >> _className)) then { @@ -46,6 +47,12 @@ if (isClass (_medicationConfig >> _className)) then { 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"); }; + if (isText (_medicationConfig >> "hrCallback")) then { _hrCallback = getText (_medicationConfig >> "hrCallback"); }; +}; +if (isNil _hrCallback) then { + _hrCallback = compile _hrCallback; +} else { + _hrCallback = missionNamespace getvariable [_hrCallback, {}]; }; // Adjust the heart rate based upon config entry @@ -53,12 +60,12 @@ _heartRate = _target getvariable [QGVAR(heartRate), 70]; if (alive _target) then { if (_heartRate > 0) then { if (_heartRate <= 45) then { - [_target, ((_hrIncreaseLow select 0) + random((_hrIncreaseLow select 1))), (_hrIncreaseLow select 2)] call FUNC(addHeartRateAdjustment); + [_target, ((_hrIncreaseLow select 0) + random((_hrIncreaseLow select 1))), (_hrIncreaseLow select 2), _hrCallback] call FUNC(addHeartRateAdjustment); } else { if (_heartRate > 120) then { - [_target, ((_hrIncreaseHigh select 0) + random((_hrIncreaseHigh select 1))), (_hrIncreaseHigh select 2)] call FUNC(addHeartRateAdjustment); + [_target, ((_hrIncreaseHigh select 0) + random((_hrIncreaseHigh select 1))), (_hrIncreaseHigh select 2), _hrCallback] call FUNC(addHeartRateAdjustment); } else { - [_target, ((_hrIncreaseNorm select 0) + random((_hrIncreaseNorm select 1))), (_hrIncreaseNorm select 2)] call FUNC(addHeartRateAdjustment); + [_target, ((_hrIncreaseNorm select 0) + random((_hrIncreaseNorm select 1))), (_hrIncreaseNorm select 2), _hrCallback] call FUNC(addHeartRateAdjustment); }; }; };