ACE3/addons/medical_vitals/functions/fnc_updateHeartRate.sqf

70 lines
2.4 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
/*
* Author: Glowbal
* Update the heart rate
*
* Arguments:
* 0: The Unit <OBJECT>
* 1: Heart Rate Adjustments <NUMBER>
* 2: Time since last update <NUMBER>
* 3: Sync value? <BOOL>
*
* ReturnValue:
* Current Heart Rate <NUMBER>
*
* Example:
* [player, 0, 1, false] call ace_medical_vitals_fnc_updateHeartRate
*
* Public: No
*/
params ["_unit", "_hrTargetAdjustment", "_deltaT", "_syncValue"];
2018-05-08 09:16:12 +00:00
private _heartRate = GET_HEART_RATE(_unit);
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 {
private _hrChange = 0;
private _targetHR = 0;
2018-05-10 16:44:02 +00:00
private _bloodVolume = GET_BLOOD_VOLUME(_unit);
if (_bloodVolume > BLOOD_VOLUME_CLASS_4_HEMORRHAGE) then {
2018-05-08 08:28:16 +00:00
GET_BLOOD_PRESSURE(_unit) params ["_bloodPressureL", "_bloodPressureH"];
private _meanBP = (2/3) * _bloodPressureH + (1/3) * _bloodPressureL;
private _spo2 = GET_SPO2(_unit);
2018-05-08 07:47:03 +00:00
private _painLevel = GET_PAIN_PERCEIVED(_unit);
_targetHR = DEFAULT_HEART_RATE;
Medical - Fix severity of wound bleeding and adjust cardiac output calculations (#7010) * Fix severity of wound bleeding I'm simplifying the nastiness calculations so that the wound config specifies the worst wound and we scale it between 25% to 100% based on the wound damage and number of wounds recieved. Similarly I've updated the wound configs to more reasonable maximum bleeding values based on the fact that they're percentages of cardiac output being bled. * Limit variance of pain modifier This is to avoid unexpectedly high pain for small wounds or unexpectedly small pain for large wounds * Make more wounds increase chance for nastiness Rather than guarantee * Adjust worst damage scaling This handles torso wounds better as they're typically around 0.3-0.6 for 6.5mm shots which makes them roughly medium sized. * Fix cardiac output calculation Previously the calculation didn't make sense as it wasn't outputting a value in l/s. This method of calculation makes more logical sense and provides a point of reference for what the bleeding values actually represent (percentage of the blood being pumped that is lost - which now has an actual volumetric value). * Fix blood pressure after change to cardiac output * Fix heartrate skyrocketing between 5l and 4l blood Pretty sure someone accidnentally got these conditions the wrong way around. This way blood pressure will first drop and then heart rate will later go up to compensate. * Fix comment typo Co-Authored-By: PabstMirror <pabstmirror@gmail.com>
2019-06-10 16:23:21 +00:00
if (_bloodVolume < BLOOD_VOLUME_CLASS_3_HEMORRHAGE) then {
private _targetBP = 107 * (_bloodVolume / DEFAULT_BLOOD_VOLUME);
_targetHR = _heartRate * (_targetBP / (45 max _meanBP));
};
if (_painLevel > 0.2) then {
_targetHR = _targetHR max (80 + 50 * _painLevel);
};
// 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);
_targetHR = (_targetHR + _hrTargetAdjustment) max 0;
_hrChange = round(_targetHR - _heartRate) / 2;
} else {
_hrChange = -round(_heartRate / 10);
};
if (_hrChange < 0) then {
_heartRate = (_heartRate + _deltaT * _hrChange) max _targetHR;
} else {
_heartRate = (_heartRate + _deltaT * _hrChange) min _targetHR;
};
};
2016-12-05 20:34:20 +00:00
_unit setVariable [VAR_HEART_RATE, _heartRate, _syncValue];
_heartRate