Added support for callbacks with heart rate changes through medication

This commit is contained in:
Glowbal 2015-03-03 20:07:09 +01:00
parent 83cdef770a
commit 7750f2d1b2
3 changed files with 17 additions and 6 deletions

View File

@ -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?

View File

@ -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;

View File

@ -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);
};
};
};