mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Use macros for peripheral resistance
This commit is contained in:
parent
52dbef84ab
commit
54c398a007
@ -16,6 +16,7 @@
|
||||
#define GET_ARRAY(config,default) (if (isArray (config)) then {getArray (config)} else {default})
|
||||
|
||||
#define DEFAULT_HEART_RATE 80
|
||||
#define DEFAULT_PERIPH_RES 100
|
||||
|
||||
// --- blood
|
||||
// 0.077 l/kg * 80kg = 6.16l
|
||||
@ -68,10 +69,12 @@
|
||||
#define VAR_HEART_RATE QEGVAR(medical,heartRate)
|
||||
#define VAR_PAIN QEGVAR(medical,pain)
|
||||
#define VAR_PAIN_SUPP QEGVAR(medical,painSuppress)
|
||||
#define VAR_PERIPH_RES QEGVAR(medical,peripheralResistance)
|
||||
#define VAR_UNCON "ACE_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)
|
||||
#define VAR_PERIPH_RES_ADJ QEGVAR(medical,peripheralResistanceAdjustments)
|
||||
// These variables track the current state of status values above
|
||||
#define VAR_HEMORRHAGE QEGVAR(medical,hemorrhage)
|
||||
#define VAR_IN_PAIN QEGVAR(medical,inPain)
|
||||
|
@ -21,12 +21,12 @@
|
||||
#define MODIFIER_BP_HIGH 13.7142792
|
||||
|
||||
// Value is taken because with cardic output and resistance at default values, it will put blood pressure Low at 80.
|
||||
#define MODIFIER_BP_LOW 9.1428528
|
||||
#define MODIFIER_BP_LOW 9.1428528
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
private _cardiacOutput = [_unit] call FUNC(getCardiacOutput);
|
||||
private _resistance = _unit getVariable [QGVAR(peripheralResistance), 100];
|
||||
private _resistance = _unit getVariable [VAR_PERIPH_RES, DEFAULT_PERIPH_RES];
|
||||
private _bloodPressure = _cardiacOutput * _resistance;
|
||||
|
||||
[round(_bloodPressure * MODIFIER_BP_LOW), round(_bloodPressure * MODIFIER_BP_HIGH)]
|
||||
|
@ -26,8 +26,8 @@ _unit setVariable [VAR_BLOOD_VOL, DEFAULT_BLOOD_VOLUME, true];
|
||||
_unit setVariable [VAR_HEART_RATE, DEFAULT_HEART_RATE, 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];
|
||||
_unit setVariable [VAR_PERIPH_RES, DEFAULT_PERIPH_RES, true];
|
||||
_unit setVariable [VAR_PERIPH_RES_ADJ, [], true];
|
||||
_unit setVariable [VAR_CRDC_ARRST, false, true];
|
||||
_unit setVariable [VAR_HEMORRHAGE, 0, true];
|
||||
_unit setVariable [VAR_IS_BLEEDING, false, true];
|
||||
|
@ -34,8 +34,8 @@ _target setVariable [QEGVAR(medical_engine,isLimping), false, 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];
|
||||
_target setVariable [VAR_PERIPH_RES, DEFAULT_PERIPH_RES, true];
|
||||
_target setVariable [VAR_PERIPH_RES_ADJ, [], true];
|
||||
|
||||
// IVs
|
||||
_target setVariable [QEGVAR(medical,ivBags), nil, true];
|
||||
|
@ -80,23 +80,23 @@ if (alive _target) then {
|
||||
|
||||
// Adjust the heart rate based upon config entry
|
||||
if (_heartRateChange != 0) then {
|
||||
private _heartRateAdjustments = GETVAR(_target,VAR_HEART_RATE_ADJ,[]);
|
||||
_heartRateAdjustments pushBack [_heartRateChange, _timeTillMaxEffect, _timeInSystem, 0];
|
||||
_target setVariable [VAR_HEART_RATE_ADJ, _heartRateAdjustments];
|
||||
private _adjustments = GETVAR(_target,VAR_HEART_RATE_ADJ,[]);
|
||||
_adjustments pushBack [_heartRateChange, _timeTillMaxEffect, _timeInSystem, 0];
|
||||
_target setVariable [VAR_HEART_RATE_ADJ, _adjustments];
|
||||
};
|
||||
|
||||
// Adjust the pain suppression based upon config entry
|
||||
if (_painReduce > 0) then {
|
||||
private _adjustments = _target getVariable [VAR_PAIN_SUPP_ADJ, []];
|
||||
private _adjustments = GETVAR(_target,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
|
||||
if (_viscosityChange != 0) then {
|
||||
private _peripheralResistanceAdjustments = _target getVariable [QEGVAR(medical,peripheralResistanceAdjustments), []];
|
||||
_peripheralResistanceAdjustments pushBack [_viscosityChange, _timeTillMaxEffect, _timeInSystem, 0];
|
||||
_target setVariable [QEGVAR(medical,peripheralResistanceAdjustments), _peripheralResistanceAdjustments];
|
||||
private _adjustments = GETVAR(_target,VAR_PERIPH_RES_ADJ,[]);
|
||||
_adjustments pushBack [_viscosityChange, _timeTillMaxEffect, _timeInSystem, 0];
|
||||
_target setVariable [VAR_PERIPH_RES_ADJ, _adjustments];
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -18,14 +18,14 @@
|
||||
params ["_unit", "_deltaT", "_syncValue"];
|
||||
|
||||
private _painSupressAdjustment = 0;
|
||||
private _adjustment = _unit getVariable [VAR_PAIN_SUPP_ADJ, []];
|
||||
private _adjustments = _unit getVariable [VAR_PAIN_SUPP_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;
|
||||
@ -33,12 +33,11 @@ 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 [VAR_PAIN_SUPP_ADJ, _adjustment, (_syncValue || {_adjustment isEqualTo []})]; // always sync on last run
|
||||
_unit setVariable [VAR_PAIN_SUPP_ADJ, _adjustments - [nil], (_syncValue || {_adjustments isEqualTo []})]; // always sync on last run
|
||||
|
||||
_unit setVariable [VAR_PAIN_SUPP, 0 max _painSupressAdjustment, _syncValue];
|
||||
};
|
||||
|
@ -18,14 +18,14 @@
|
||||
params ["_unit", "_deltaT", "_syncValue"];
|
||||
|
||||
private _peripheralResistanceAdjustment = 0;
|
||||
private _adjustment = _unit getVariable [QGVAR(peripheralResistanceAdjustments), []];
|
||||
private _adjustments = _unit getVariable [VAR_PERIPH_RES_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;
|
||||
@ -33,13 +33,12 @@ 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(peripheralResistanceAdjustments), _adjustment, _syncValue];
|
||||
_unit setVariable [VAR_PERIPH_RES_ADJ, _adjustments - [nil], _syncValue];
|
||||
|
||||
// always sync on last run
|
||||
_unit SetVariable [QGVAR(peripheralResistance), 0 max (100 + _peripheralResistanceAdjustment), _syncValue || {_adjustment isEqualTo []}];
|
||||
_unit setVariable [VAR_PERIPH_RES, 0 max (DEFAULT_PERIPH_RES + _peripheralResistanceAdjustment), _syncValue || {_adjustments isEqualTo []}];
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user