Partly fixed Medication

* Brings the heart rate adjustment (due to medication) back to life
* Restores the medication effect loop (needs testing)
This commit is contained in:
ulteq 2016-12-06 12:58:12 +01:00
parent 7d6edd6c41
commit 92da5c80a0
8 changed files with 49 additions and 26 deletions

View File

@ -4,6 +4,7 @@
*
* Arguments:
* 0: The Unit <OBJECT>
* 1: Time since last update <NUMBER>
*
* ReturnValue:
* Change in heart Rate <NUMBER>
@ -13,28 +14,24 @@
#include "script_component.hpp"
params ["_unit"];
params ["_unit", "_deltaT"];
private _hrIncrease = 0;
if (!(_unit getVariable [QGVAR(inCardiacArrest),false])) then {
private _hrTargetAdjustment = 0;
private _adjustment = _unit getVariable [QGVAR(heartRateAdjustments), []];
{
_x params ["_values", "_time", "_callBack"];
if (abs _values > 0) then {
if (_time <= 0) then {
_time = 1;
};
private _change = (_values / _time);
_hrIncrease = _hrIncrease + _change;
if ( (_time - 1) <= 0) then {
_time = 0;
_x params ["_value", "_timeTillMaxEffect", "_maxTimeInSystem", "_timeInSystem", "_callBack"];
if (abs _value > 0 && {_maxTimeInSystem > 0}) then {
if (_timeInSystem >= _maxTimeInSystem) then {
_adjustment set [_forEachIndex, ObjNull];
[_unit] call _callBack;
} else {
_time = _time - 1;
_adjustment set [_forEachIndex, [_values - _change, _time]];
_timeInSystem = _timeInSystem + _deltaT;
private _effectRatio = (_timeInSystem / (1 max _timeTillMaxEffect)) min 1;
_hrTargetAdjustment = _value * _effectRatio * (_maxTimeInSystem - _timeInSystem) / _maxTimeInSystem;
_x set [3, _timeInSystem];
};
} else {
_adjustment set [_forEachIndex, ObjNull];
@ -44,7 +41,7 @@ if (!(_unit getVariable [QGVAR(inCardiacArrest),false])) then {
_adjustment = _adjustment - [ObjNull];
_unit setVariable [QGVAR(heartRateAdjustments), _adjustment];
if (!(_unit getVariable [QGVAR(inCardiacArrest), false])) then {
private _heartRate = (_unit getVariable [QGVAR(heartRate), 80]);
private _bloodVolume = _unit getVariable [QGVAR(bloodVolume), DEFAULT_BLOOD_VOLUME];
@ -60,11 +57,10 @@ if (!(_unit getVariable [QGVAR(inCardiacArrest),false])) then {
_targetBP = _targetBP * (_bloodVolume / DEFAULT_BLOOD_VOLUME);
};
if (_hasPain && {_pain > 0.2}) then {
_targetHR = 130;
};
if (_heartRate < _targetHR) then {
_hrChange = round(_targetHR - _heartRate) / 2;
_targetHR = _targetHR + 50 * _pain;
};
_targetHR = _targetHR + _hrTargetAdjustment;
_hrChange = round(_targetHR - _heartRate) / 2;
if ((_meanBP > _targetBP && {_heartRate > _targetHR}) || {_bloodVolume < BLOOD_VOLUME_CLASS_2_HEMORRHAGE && {_heartRate < 200}}) then {
_hrChange = 2 * round(_targetBP - _meanBP);
if (_hrChange < 0) then {
@ -78,4 +74,4 @@ if (!(_unit getVariable [QGVAR(inCardiacArrest),false])) then {
};
};
_hrIncrease
(_deltaT * _hrIncrease)

View File

@ -88,7 +88,7 @@ private _oldTourniquets = (_unit getVariable [QGVAR(tourniquets), []]) select {_
// Increase pain at a rate of 0.001 units/s per old tourniquet
_painStatus = _painStatus + (count _oldTourniquets) * 0.001 * _deltaT;
private _heartRate = (_unit getVariable [QGVAR(heartRate), 80]) + _deltaT * ([_unit] call FUNC(getHeartRateChange));
private _heartRate = (_unit getVariable [QGVAR(heartRate), 80]) + ([_unit, _deltaT] call FUNC(getHeartRateChange));
_unit setVariable [QGVAR(heartRate), 0 max _heartRate, _syncValues];
private _bloodPressure = [_unit] call FUNC(getBloodPressure);

View File

@ -557,7 +557,7 @@ class ADDON {
class Medication {
// How much does the pain get reduced?
painReduce = 0;
// How much will the heart rate be increased when the HR is low (below 55)? {minIncrease, maxIncrease, seconds}
// How much will the heart rate be increased when the HR is low (below 55)? {minIncrease, maxIncrease, seconds until max. effect}
hrIncreaseLow[] = {0, 0, 0};
hrIncreaseNormal[] = {0, 0, 0};
hrIncreaseHigh[] = {0, 0, 0};

View File

@ -34,6 +34,7 @@ PREP(treatmentFullHealTreatmentTime);
PREP(treatmentSurgicalKit_onProgress);
// misc
PREP(addHeartRateAdjustment);
PREP(addToLog);
PREP(addToTriageCard);
PREP(addUnloadPatientActions);

View File

@ -0,0 +1,26 @@
/*
* Author: Glowbal, KoffeinFlummi
* Increase the heart rate target of a local unit by given number during the given amount of seconds.
*
* Arguments:
* 0: The unit <OBJECT>
* 1: value <NUMBER>
* 2: time until max. effect (seconds) <NUMBER>
* 3: time in system (seconds) <NUMBER>
* 4: callback <CODE>
*
* Return Value:
* None
*
* Public: Yes
*/
#include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_value", 0, [0]], ["_timeTillMaxEffect", 1, [0]], ["_timeInSystem", 1, [0]], ["_callBack", {}, [{}]]];
private _adjustment = _unit getVariable [QEGVAR(medical,heartRateAdjustments), []];
_adjustment pushBack [_value, _timeTillMaxEffect, _timeInSystem, 0, _callBack];
_unit setVariable [QEGVAR(medical,heartRateAdjustments), _adjustment];
["ace_heartRateAdjustmentAdded", [_unit, _value, _time]] call CBA_fnc_localEvent;

View File

@ -18,7 +18,7 @@
#include "script_component.hpp"
params ["_unit", "_variableName", "_amountDecreased","_decreaseRate", "_viscosityAdjustmentRate", "_painReduceRate"];
params ["_unit", "_variableName", "_amountDecreased", "_decreaseRate", "_viscosityAdjustmentRate", "_painReduceRate"];
// If the unit died the loop is finished
if (!alive _unit) exitWith {};

View File

@ -44,7 +44,7 @@ if (!_foundEntry) then {
private _usedMeds = _target getVariable [_variable, 0];
if (_usedMeds >= floor (_maxDosage + round(random(2))) && _maxDosage >= 1) then {
[_target] call EFUNC(medical,setDead);
[QEGVAR(medical,CriticalVitals), _target] call CBA_fnc_localEvent;
};
private _hasOverDosed = 0;

View File

@ -95,12 +95,12 @@ private _heartRate = _target getVariable [QEGVAR(medical,heartRate), 70];
if (alive _target) then {
if (_heartRate > 0) then {
if (_heartRate <= 45) then {
[_target, ((_hrIncreaseLow select 0) + random ((_hrIncreaseLow select 1) - (_hrIncreaseLow select 0))), (_hrIncreaseLow select 2), _hrCallback] call FUNC(addHeartRateAdjustment);
[_target, ((_hrIncreaseLow select 0) + random ((_hrIncreaseLow select 1) - (_hrIncreaseLow select 0))), (_hrIncreaseLow select 2), _timeInSystem, _hrCallback] call FUNC(addHeartRateAdjustment);
} else {
if (_heartRate > 120) then {
[_target, ((_hrIncreaseHigh select 0) + random ((_hrIncreaseHigh select 1) - (_hrIncreaseHigh select 0))), (_hrIncreaseHigh select 2), _hrCallback] call FUNC(addHeartRateAdjustment);
[_target, ((_hrIncreaseHigh select 0) + random ((_hrIncreaseHigh select 1) - (_hrIncreaseHigh select 0))), (_hrIncreaseHigh select 2), _timeInSystem, _hrCallback] call FUNC(addHeartRateAdjustment);
} else {
[_target, ((_hrIncreaseNorm select 0) + random ((_hrIncreaseNorm select 1) - (_hrIncreaseNorm select 0))), (_hrIncreaseNorm select 2), _hrCallback] call FUNC(addHeartRateAdjustment);
[_target, ((_hrIncreaseNorm select 0) + random ((_hrIncreaseNorm select 1) - (_hrIncreaseNorm select 0))), (_hrIncreaseNorm select 2), _timeInSystem, _hrCallback] call FUNC(addHeartRateAdjustment);
};
};
};