ACE3/addons/medical_treatment/functions/fnc_calculateBlood.sqf

31 lines
1.1 KiB
Plaintext
Raw Normal View History

2017-03-23 13:12:08 +00:00
/*
* Author: Zakant
2017-03-23 17:17:38 +00:00
* Calculate the blood lost and blood volume for a unit. Used from CPR to simulate a heart rate while in cardiac arrest
2017-03-23 13:12:08 +00:00
*
* Arguments:
2017-03-23 16:23:18 +00:00
* 0: Unit <OBJECT>
2017-03-23 13:12:08 +00:00
*
* Return Value:
2017-03-23 16:26:16 +00:00
* None
2017-03-23 13:12:08 +00:00
*
* Public: No
*/
#include "script_component.hpp"
params["_unit"];
// We will just simulate blood flow for now!
private _lastTimeUpdated = _unit getVariable [QEGVAR(medical,lastTimeUpdated), CBA_missionTime];
private _deltaT = CBA_missionTime - _lastTimeUpdated;
private _lastTimeValuesSynced = _unit getVariable [QEGVAR(medical,lastMomentValuesSynced), 0];
private _syncValues = (CBA_missionTime - _lastTimeValuesSynced) >= (10 + floor(random(10)));
_unit setVariable [QEGVAR(medical,lastTimeUpdated), CBA_missionTime];
if (_deltaT != 0) then {
2017-03-23 16:27:11 +00:00
private _change = ([_unit, _deltaT, _syncValues] call EFUNC(medical,getBloodVolumeChange));
2017-03-23 16:27:53 +00:00
private _bloodVolume = (_unit getVariable [QEGVAR(medical,bloodVolume), DEFAULT_BLOOD_VOLUME]) + _change;
2017-03-23 16:27:11 +00:00
_bloodVolume = 0 max _bloodVolume min DEFAULT_BLOOD_VOLUME;
_unit setVariable [QEGVAR(medical,bloodVolume), _bloodVolume, _syncValues];
2017-03-23 13:12:08 +00:00
};