2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-02-08 09:01:32 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
2016-12-06 19:42:10 +00:00
|
|
|
* Update the heart rate
|
2015-02-07 22:55:48 +00:00
|
|
|
*
|
2015-02-08 09:01:32 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: The Unit <OBJECT>
|
2019-04-27 19:12:11 +00:00
|
|
|
* 1: Heart Rate Adjustments <NUMBER>
|
|
|
|
* 2: Time since last update <NUMBER>
|
|
|
|
* 3: Sync value? <BOOL>
|
2015-02-08 09:01:32 +00:00
|
|
|
*
|
|
|
|
* ReturnValue:
|
2017-04-22 15:57:32 +00:00
|
|
|
* Current Heart Rate <NUMBER>
|
|
|
|
*
|
|
|
|
* Example:
|
2019-04-27 19:12:11 +00:00
|
|
|
* [player, 0, 1, false] call ace_medical_vitals_fnc_updateHeartRate
|
2015-02-08 09:01:32 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
2015-02-07 22:55:48 +00:00
|
|
|
*/
|
|
|
|
|
2019-04-27 19:12:11 +00:00
|
|
|
params ["_unit", "_hrTargetAdjustment", "_deltaT", "_syncValue"];
|
2016-12-06 19:42:10 +00:00
|
|
|
|
2018-05-08 09:16:12 +00:00
|
|
|
private _heartRate = GET_HEART_RATE(_unit);
|
2016-12-06 16:26:11 +00:00
|
|
|
|
2019-06-28 00:01:20 +00:00
|
|
|
if IN_CRDC_ARRST(_unit) then {
|
|
|
|
if (alive (_unit getVariable [QEGVAR(medical,CPR_provider), objNull])) then {
|
|
|
|
if (_heartRate == 0) then { _syncValue = true }; // always sync on large change
|
|
|
|
_heartRate = random [25, 30, 35];
|
|
|
|
} else {
|
|
|
|
if (_heartRate != 0) then { _syncValue = true }; // always sync on large change
|
|
|
|
_heartRate = 0
|
|
|
|
};
|
|
|
|
} else {
|
2016-12-06 19:42:10 +00:00
|
|
|
private _hrChange = 0;
|
2018-08-14 20:34:35 +00:00
|
|
|
private _targetHR = 0;
|
2018-05-10 16:44:02 +00:00
|
|
|
private _bloodVolume = GET_BLOOD_VOLUME(_unit);
|
2016-12-06 16:26:11 +00:00
|
|
|
if (_bloodVolume > BLOOD_VOLUME_CLASS_4_HEMORRHAGE) then {
|
2018-05-08 08:28:16 +00:00
|
|
|
GET_BLOOD_PRESSURE(_unit) params ["_bloodPressureL", "_bloodPressureH"];
|
2016-12-06 16:26:11 +00:00
|
|
|
private _meanBP = (2/3) * _bloodPressureH + (1/3) * _bloodPressureL;
|
2024-02-07 20:50:18 +00:00
|
|
|
private _spo2 = GET_SPO2(_unit);
|
2018-05-08 07:47:03 +00:00
|
|
|
private _painLevel = GET_PAIN_PERCEIVED(_unit);
|
2017-04-22 15:57:32 +00:00
|
|
|
|
2018-08-14 20:34:35 +00:00
|
|
|
_targetHR = DEFAULT_HEART_RATE;
|
2019-06-10 16:23:21 +00:00
|
|
|
if (_bloodVolume < BLOOD_VOLUME_CLASS_3_HEMORRHAGE) then {
|
2024-06-20 18:19:14 +00:00
|
|
|
private _targetBP = 107 * (_bloodVolume / DEFAULT_BLOOD_VOLUME);
|
2016-12-06 16:26:11 +00:00
|
|
|
_targetHR = _heartRate * (_targetBP / (45 max _meanBP));
|
|
|
|
};
|
|
|
|
if (_painLevel > 0.2) then {
|
|
|
|
_targetHR = _targetHR max (80 + 50 * _painLevel);
|
|
|
|
};
|
2024-02-07 20:50:18 +00:00
|
|
|
// Increase HR to compensate for low blood oxygen
|
|
|
|
// Increase HR to compensate for higher oxygen demand (e.g. running, recovering from sprint)
|
|
|
|
private _oxygenDemand = _unit getVariable [VAR_OXYGEN_DEMAND, 0];
|
|
|
|
_targetHR = _targetHR + ((97 - _spo2) * 2) + (_oxygenDemand * -1000);
|
2018-08-14 20:34:35 +00:00
|
|
|
_targetHR = (_targetHR + _hrTargetAdjustment) max 0;
|
2016-12-06 16:26:11 +00:00
|
|
|
_hrChange = round(_targetHR - _heartRate) / 2;
|
|
|
|
} else {
|
2016-12-06 19:42:10 +00:00
|
|
|
_hrChange = -round(_heartRate / 10);
|
2015-02-07 22:55:48 +00:00
|
|
|
};
|
2018-08-14 20:34:35 +00:00
|
|
|
if (_hrChange < 0) then {
|
|
|
|
_heartRate = (_heartRate + _deltaT * _hrChange) max _targetHR;
|
|
|
|
} else {
|
|
|
|
_heartRate = (_heartRate + _deltaT * _hrChange) min _targetHR;
|
|
|
|
};
|
2015-02-07 22:55:48 +00:00
|
|
|
};
|
2016-12-05 20:34:20 +00:00
|
|
|
|
2018-05-11 14:28:25 +00:00
|
|
|
_unit setVariable [VAR_HEART_RATE, _heartRate, _syncValue];
|
2017-04-22 15:57:32 +00:00
|
|
|
|
|
|
|
_heartRate
|