2015-02-08 09:01:32 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Get the change in the heart rate. Used for the vitals calculations. Calculated in one seconds.
|
2015-02-07 22:55:48 +00:00
|
|
|
*
|
2015-02-08 09:01:32 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: The Unit <OBJECT>
|
|
|
|
*
|
|
|
|
* ReturnValue:
|
|
|
|
* Change in heart Rate <NUMBER>
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-02-07 22:55:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
#define HEART_RATE_MODIFIER 0.02
|
|
|
|
|
2015-08-22 14:25:10 +00:00
|
|
|
params ["_unit"];
|
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
private _hrIncrease = 0;
|
2015-11-30 16:27:09 +00:00
|
|
|
if (!(_unit getVariable [QGVAR(inCardiacArrest),false])) then {
|
2016-06-13 00:34:56 +00:00
|
|
|
private _heartRate = _unit getVariable [QGVAR(heartRate), 80];
|
|
|
|
private _bloodLoss = [_unit] call FUNC(getBloodLoss);
|
2015-02-07 22:55:48 +00:00
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
private _adjustment = _unit getVariable [QGVAR(heartRateAdjustments), []];
|
2015-02-07 22:55:48 +00:00
|
|
|
{
|
2015-08-22 14:25:10 +00:00
|
|
|
_x params ["_values", "_time", "_callBack"];
|
2015-02-07 22:55:48 +00:00
|
|
|
if (abs _values > 0) then {
|
|
|
|
if (_time <= 0) then {
|
|
|
|
_time = 1;
|
|
|
|
};
|
2016-06-13 00:34:56 +00:00
|
|
|
private _change = (_values / _time);
|
2015-02-07 22:55:48 +00:00
|
|
|
_hrIncrease = _hrIncrease + _change;
|
|
|
|
|
2015-03-03 19:07:09 +00:00
|
|
|
if ( (_time - 1) <= 0) then {
|
2015-02-07 22:55:48 +00:00
|
|
|
_time = 0;
|
2015-11-30 16:23:48 +00:00
|
|
|
_adjustment set [_forEachIndex, ObjNull];
|
2015-02-07 22:55:48 +00:00
|
|
|
[_unit] call _callBack;
|
|
|
|
} else {
|
|
|
|
_time = _time - 1;
|
2015-11-30 16:23:48 +00:00
|
|
|
_adjustment set [_forEachIndex, [_values - _change, _time]];
|
2015-02-07 22:55:48 +00:00
|
|
|
};
|
|
|
|
} else {
|
2015-11-30 16:23:48 +00:00
|
|
|
_adjustment set [_forEachIndex, ObjNull];
|
2015-03-03 19:07:09 +00:00
|
|
|
[_unit] call _callBack;
|
2015-02-07 22:55:48 +00:00
|
|
|
};
|
2015-11-30 16:23:48 +00:00
|
|
|
} forEach _adjustment;
|
2016-06-13 00:34:56 +00:00
|
|
|
|
2015-02-07 22:55:48 +00:00
|
|
|
_adjustment = _adjustment - [ObjNull];
|
2015-11-30 16:27:09 +00:00
|
|
|
_unit setVariable [QGVAR(heartRateAdjustments), _adjustment];
|
2015-02-07 22:55:48 +00:00
|
|
|
|
2016-10-10 15:30:42 +00:00
|
|
|
private _bloodVolume = _unit getVariable [QGVAR(bloodVolume), DEFAULT_BLOOD_VOLUME];
|
2015-02-07 22:55:48 +00:00
|
|
|
if (_bloodVolume > 75) then {
|
2016-06-13 00:34:56 +00:00
|
|
|
if (_bloodLoss > 0.0) then {
|
|
|
|
if (_bloodLoss < 0.5) then {
|
2015-02-07 22:55:48 +00:00
|
|
|
if (_heartRate < 126) then {
|
|
|
|
_hrIncrease = _hrIncrease + 0.05;
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
if (_bloodLoss < 1) then {
|
|
|
|
if (_heartRate < 161) then {
|
|
|
|
_hrIncrease = _hrIncrease + 0.1;
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
if (_heartRate < 220) then {
|
|
|
|
_hrIncrease = _hrIncrease + 0.15;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
// Stabalize it
|
|
|
|
if (_heartRate < (60 + round(random(10)))) then {
|
|
|
|
_hrIncrease = _hrIncrease + HEART_RATE_MODIFIER;
|
|
|
|
} else {
|
|
|
|
if (_heartRate > (77 + round(random(10)))) then {
|
|
|
|
_hrIncrease = _hrIncrease - HEART_RATE_MODIFIER;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
_hrIncrease = _hrIncrease - HEART_RATE_MODIFIER;
|
|
|
|
};
|
|
|
|
};
|
2015-04-22 20:36:41 +00:00
|
|
|
_hrIncrease
|