mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Fix heart rate and pain suppression adjustments
This commit is contained in:
parent
1dc934e1b1
commit
563742bdd8
@ -63,11 +63,14 @@
|
||||
// These variables get stored in object space and used across components
|
||||
// Defined here for easy consistency with GETVAR/SETVAR (also a list for reference)
|
||||
#define VAR_BLOOD_PRESS QEGVAR(medical,bloodPressure)
|
||||
#define VAR_BLOOD_VOL QEGVAR(medical,bloodVolume)
|
||||
#define VAR_HEART_RATE QEGVAR(medical,heartRate)
|
||||
#define VAR_PAIN QEGVAR(medical,pain)
|
||||
#define VAR_PAIN_SUPP QEGVAR(medical,painSuppress)
|
||||
#define VAR_UNCON QEGVAR(medical,isUnconscious)
|
||||
#define VAR_BLOOD_VOL QEGVAR(medical,bloodVolume)
|
||||
#define VAR_HEART_RATE QEGVAR(medical,heartRate)
|
||||
#define VAR_PAIN QEGVAR(medical,pain)
|
||||
#define VAR_PAIN_SUPP QEGVAR(medical,painSuppress)
|
||||
#define VAR_UNCON QEGVAR(medical,isUnconscious)
|
||||
// These variables track gradual adjustments (from medication, etc.)
|
||||
#define VAR_HEART_RATE_ADJ QEGVAR(medical,heartRateAdjustments)
|
||||
#define VAR_PAIN_SUPP_ADJ QEGVAR(medical,painSuppressAdjustments)
|
||||
|
||||
|
||||
// - Unit Functions ---------------------------------------------------
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "script_component.hpp"
|
||||
params ["_unit", "_change", "_timeToMaxEffect", "_maxTimeInSystem"];
|
||||
|
||||
private _adjustments = _unit getVariable [QGVAR(heartRateAdjustments), []];
|
||||
private _adjustments = GETVAR(_unit,VAR_HEART_RATE_ADJ,[]);
|
||||
// The last number indicates the time the adjustment is already in the system
|
||||
_adjustments pushBack [_change, _timeToMaxEffect, _maxTimeInSystem, 0];
|
||||
_unit setVariable [QGVAR(heartRateAdjustments), _heartRateAdjustments];
|
||||
_unit setVariable [VAR_HEART_RATE_ADJ, _adjustments];
|
||||
|
@ -24,7 +24,7 @@ if (damage _unit > 0) then {
|
||||
// - Blood and heart ----------------------------------------------------------
|
||||
_unit setVariable [VAR_BLOOD_VOL, DEFAULT_BLOOD_VOLUME, true];
|
||||
_unit setVariable [VAR_HEART_RATE, DEFAULT_HEART_RATE, true];
|
||||
_unit setVariable [QGVAR(heartRateAdjustments), [], true];
|
||||
_unit setVariable [VAR_HEART_RATE_ADJ, [], true];
|
||||
_unit setVariable [VAR_BLOOD_PRESS, [80, 120], true];
|
||||
_unit setVariable [QGVAR(peripheralResistance), 100, true];
|
||||
_unit setVariable [QGVAR(peripheralResistanceAdjustments), [], true];
|
||||
@ -36,7 +36,7 @@ _unit setVariable [QGVAR(isBleeding), false, true];
|
||||
_unit setVariable [VAR_PAIN, 0, true];
|
||||
_unit setVariable [QGVAR(hasPain), false, true];
|
||||
_unit setVariable [VAR_PAIN_SUPP, 0, true];
|
||||
_unit setVariable [QGVAR(painSuppressAdjustments), [], true];
|
||||
_unit setVariable [VAR_PAIN_SUPP_ADJ, [], true];
|
||||
|
||||
// - Wounds -------------------------------------------------------------------
|
||||
_unit setVariable [QGVAR(openWounds), [], true];
|
||||
|
@ -19,7 +19,7 @@ params ["_caller", "_target", "_bodyPart"];
|
||||
private _heartRate = 0;
|
||||
|
||||
if (alive _target && !([_target, _bodyPart] call EFUNC(medical_status,hasTourniquetAppliedTo))) then {
|
||||
_heartRate = _target getVariable [QEGVAR(medical,heartRate), 80];
|
||||
_heartRate = GET_HEART_RATE(_target);
|
||||
};
|
||||
|
||||
private _heartRateOutput = ELSTRING(medical,Check_Pulse_Output_5);
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
params ["_caller", "_target", "_selectionName", "_className", "_items"];
|
||||
|
||||
_target setVariable [QEGVAR(medical,heartRate), 0, true];
|
||||
_target setVariable [VAR_HEART_RATE, 0, true];
|
||||
_target setVariable [QGVAR(receiveCPR), false, true]; // CPR finished
|
||||
[_target] call FUNC(calculateBlood);
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
params ["_caller", "_target"];
|
||||
|
||||
if (!(_target call EFUNC(common,isAwake)) || {_target getVariable [QEGVAR(medical,inCardiacArrest), false]}) then {
|
||||
_target setVariable [QEGVAR(medical,heartRate), 0, true];
|
||||
_target setVariable [VAR_HEART_RATE, 0, true];
|
||||
};
|
||||
_target setVariable [QGVAR(receiveCPR), false, true];
|
||||
[_target] call FUNC(calculateBlood);
|
||||
|
@ -16,8 +16,8 @@
|
||||
params ["_caller", "_target"];
|
||||
|
||||
_target setVariable [QGVAR(receiveCPR), true, true]; // Target receives CPR
|
||||
if (EGVAR(medical,CPRcreatesPulse) && {_target getVariable [QEGVAR(medical,heartRate), 80] == 0}) then {
|
||||
_target setVariable [QEGVAR(medical,heartRate), round (30 + random [-5, 0, 5]) , true]; // And we have a (random) pulse
|
||||
if (EGVAR(medical,CPRcreatesPulse) && {GET_HEART_RATE(_target) == 0}) then {
|
||||
_target setVariable [VAR_HEART_RATE, round (30 + random [-5, 0, 5]) , true]; // And we have a (random) pulse
|
||||
};
|
||||
|
||||
_target setVariable [QEGVAR(medical,lastTimeUpdated), CBA_missionTime, true];
|
||||
|
@ -31,9 +31,9 @@ _target setVariable [QEGVAR(medical,stitchedWounds), [], true];
|
||||
_target setVariable [QEGVAR(medical_engine,isLimping), false, true];
|
||||
|
||||
// vitals
|
||||
_target setVariable [QEGVAR(medical,heartRate), 80, true];
|
||||
_target setVariable [QEGVAR(medical,heartRateAdjustments), [], true];
|
||||
_target setVariable [QEGVAR(medical,bloodPressure), [80, 120], true];
|
||||
_target setVariable [VAR_HEART_RATE, DEFAULT_HEART_RATE, true];
|
||||
_target setVariable [VAR_HEART_RATE_ADJ, [], true];
|
||||
_target setVariable [VAR_BLOOD_PRESS, [80, 120], true];
|
||||
_target setVariable [QEGVAR(medical,peripheralResistance), 100, true];
|
||||
_target setVariable [QGVAR(peripheralResistanceAdjustments), [], true];
|
||||
|
||||
@ -53,7 +53,7 @@ _target setVariable [QEGVAR(medical,hasLostBlood), 0, true];
|
||||
_target setVariable [QEGVAR(medical,isBleeding), false, true];
|
||||
_target setVariable [QEGVAR(medical,hasPain), false, true];
|
||||
_target setVariable [VAR_PAIN_SUPP, 0, true];
|
||||
_target setVariable [QGVAR(painSuppressAdjustments), [], true];
|
||||
_target setVariable [VAR_PAIN_SUPP_ADJ, [], true];
|
||||
_target setVariable [QGVAR(partialHealCounter), 0, true];
|
||||
|
||||
// medication
|
||||
|
@ -73,23 +73,23 @@ if (isClass (_medicationConfig >> _className)) then {
|
||||
};
|
||||
|
||||
if (alive _target) then {
|
||||
private _heartRate = _target getVariable [QEGVAR(medical,heartRate), 80];
|
||||
private _heartRate = GET_HEART_RATE(_target);
|
||||
private _hrIncrease = [_hrIncreaseLow, _hrIncreaseNorm, _hrIncreaseHigh] select (floor ((0 max _heartRate min 110) / 55));
|
||||
_hrIncrease params ["_minIncrease", "_maxIncrease"];
|
||||
private _heartRateChange = _minIncrease + random (_maxIncrease - _minIncrease);
|
||||
|
||||
// Adjust the heart rate based upon config entry
|
||||
if (_heartRateChange != 0) then {
|
||||
private _heartRateAdjustments = _target getVariable [QEGVAR(medical,heartRateAdjustments), []];
|
||||
private _heartRateAdjustments = GETVAR(_target,VAR_HEART_RATE_ADJ,[]);
|
||||
_heartRateAdjustments pushBack [_heartRateChange, _timeTillMaxEffect, _timeInSystem, 0];
|
||||
_target setVariable [QEGVAR(medical,heartRateAdjustments), _heartRateAdjustments];
|
||||
_target setVariable [VAR_HEART_RATE_ADJ, _heartRateAdjustments];
|
||||
};
|
||||
|
||||
// Adjust the pain suppression based upon config entry
|
||||
if (_painReduce > 0) then {
|
||||
private _painSupressAdjustments = _target getVariable [QEGVAR(medical,painSupressAdjustments), []];
|
||||
_painSupressAdjustments pushBack [_painReduce, _timeTillMaxEffect, _timeInSystem, 0];
|
||||
_target setVariable [QEGVAR(medical,painSupressAdjustments), _painSupressAdjustments];
|
||||
private _adjustments = _target getVariable [VAR_PAIN_SUPP_ADJ, []];
|
||||
_adjustments pushBack [_painReduce, _timeTillMaxEffect, _timeInSystem, 0];
|
||||
_target setVariable [VAR_PAIN_SUPP_ADJ, _adjustments];
|
||||
};
|
||||
|
||||
// Adjust the peripheral resistance based upon config entry
|
||||
|
@ -21,14 +21,14 @@
|
||||
params ["_unit", "_deltaT", "_syncValue"];
|
||||
|
||||
private _hrTargetAdjustment = 0;
|
||||
private _adjustment = _unit getVariable [QGVAR(heartRateAdjustments), []];
|
||||
private _adjustments = GETVAR(_unit,VAR_HEART_RATE_ADJ,[]);
|
||||
|
||||
if (!(_adjustment isEqualTo [])) then {
|
||||
if !(_adjustments isEqualTo []) then {
|
||||
{
|
||||
_x params ["_value", "_timeTillMaxEffect", "_maxTimeInSystem", "_timeInSystem"];
|
||||
if (abs _value > 0 && {_maxTimeInSystem > 0}) then {
|
||||
if (_value != 0 && {_maxTimeInSystem > 0}) then {
|
||||
if (_timeInSystem >= _maxTimeInSystem) then {
|
||||
_adjustment set [_forEachIndex, ObjNull];
|
||||
_adjustments set [_forEachIndex, nil];
|
||||
} else {
|
||||
_timeInSystem = _timeInSystem + _deltaT;
|
||||
private _effectRatio = ((_timeInSystem / (1 max _timeTillMaxEffect)) ^ 2) min 1;
|
||||
@ -36,17 +36,16 @@ if (!(_adjustment isEqualTo [])) then {
|
||||
_x set [3, _timeInSystem];
|
||||
};
|
||||
} else {
|
||||
_adjustment set [_forEachIndex, ObjNull];
|
||||
_adjustments set [_forEachIndex, nil];
|
||||
};
|
||||
} forEach _adjustment;
|
||||
} forEach _adjustments;
|
||||
|
||||
_adjustment = _adjustment - [ObjNull];
|
||||
_unit setVariable [QGVAR(heartRateAdjustments), _adjustment, _syncValue];
|
||||
_unit setVariable [VAR_HEART_RATE_ADJ, _adjustments - [nil], _syncValue];
|
||||
};
|
||||
|
||||
private _heartRate = GET_HEART_RATE(_unit);
|
||||
|
||||
if (!(_unit getVariable [QGVAR(inCardiacArrest), false])) then {
|
||||
if !(_unit getVariable [QGVAR(inCardiacArrest), false]) then {
|
||||
private _hrChange = 0;
|
||||
private _bloodVolume = GET_BLOOD_VOLUME(_unit);
|
||||
if (_bloodVolume > BLOOD_VOLUME_CLASS_4_HEMORRHAGE) then {
|
||||
@ -59,7 +58,7 @@ if (!(_unit getVariable [QGVAR(inCardiacArrest), false])) then {
|
||||
_targetBP = _targetBP * (_bloodVolume / DEFAULT_BLOOD_VOLUME);
|
||||
};
|
||||
|
||||
private _targetHR = 80;
|
||||
private _targetHR = DEFAULT_HEART_RATE;
|
||||
if (_bloodVolume < BLOOD_VOLUME_CLASS_2_HEMORRHAGE) then {
|
||||
_targetHR = _heartRate * (_targetBP / (45 max _meanBP));
|
||||
};
|
||||
|
@ -18,7 +18,7 @@
|
||||
params ["_unit", "_deltaT", "_syncValue"];
|
||||
|
||||
private _painSupressAdjustment = 0;
|
||||
private _adjustment = _unit getVariable [QGVAR(painSupressAdjustments), []];
|
||||
private _adjustment = _unit getVariable [VAR_PAIN_SUPP_ADJ, []];
|
||||
|
||||
if (!(_adjustment isEqualTo [])) then {
|
||||
{
|
||||
@ -38,7 +38,7 @@ if (!(_adjustment isEqualTo [])) then {
|
||||
} forEach _adjustment;
|
||||
|
||||
_adjustment = _adjustment - [ObjNull];
|
||||
_unit setVariable [QGVAR(painSupressAdjustments), _adjustment, (_syncValue || {_adjustment isEqualTo []})]; // always sync on last run
|
||||
_unit setVariable [VAR_PAIN_SUPP_ADJ, _adjustment, (_syncValue || {_adjustment isEqualTo []})]; // always sync on last run
|
||||
|
||||
_unit setVariable [VAR_PAIN_SUPP, 0 max _painSupressAdjustment, _syncValue];
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user