mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
de13ab0f47
* Medical - Rework CPR and Bleeding in cardiac arrest * remove cprCreatesPulse, add cprSuccessChance * hide cpr for basic diagnose * Update addons/medical_statemachine/functions/fnc_enteredStateCardiacArrest.sqf Co-Authored-By: SilentSpike <silentspike100+Github@gmail.com>
70 lines
2.1 KiB
Plaintext
70 lines
2.1 KiB
Plaintext
#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"];
|
|
|
|
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;
|
|
private _bloodVolume = GET_BLOOD_VOLUME(_unit);
|
|
if (_bloodVolume > BLOOD_VOLUME_CLASS_4_HEMORRHAGE) then {
|
|
GET_BLOOD_PRESSURE(_unit) params ["_bloodPressureL", "_bloodPressureH"];
|
|
private _meanBP = (2/3) * _bloodPressureH + (1/3) * _bloodPressureL;
|
|
private _painLevel = GET_PAIN_PERCEIVED(_unit);
|
|
|
|
private _targetBP = 107;
|
|
if (_bloodVolume < BLOOD_VOLUME_CLASS_2_HEMORRHAGE) then {
|
|
_targetBP = _targetBP * (_bloodVolume / DEFAULT_BLOOD_VOLUME);
|
|
};
|
|
|
|
_targetHR = DEFAULT_HEART_RATE;
|
|
if (_bloodVolume < BLOOD_VOLUME_CLASS_3_HEMORRHAGE) then {
|
|
_targetHR = _heartRate * (_targetBP / (45 max _meanBP));
|
|
};
|
|
if (_painLevel > 0.2) then {
|
|
_targetHR = _targetHR max (80 + 50 * _painLevel);
|
|
};
|
|
_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;
|
|
};
|
|
};
|
|
|
|
_unit setVariable [VAR_HEART_RATE, _heartRate, _syncValue];
|
|
|
|
_heartRate
|