ACE3/addons/medical_treatment/functions/fnc_calculateBlood.sqf
SilentSpike 1dc934e1b1 Use macros for unit variables
Improves the way medical is storing variables in object space by having
a common list of variables names as macros. Makes the code a bit cleaner
and ensured consistency across components. Also a handy reference for
when working on medical to see what values are all stored.
2018-05-11 15:28:25 +01:00

30 lines
1.0 KiB
Plaintext

/*
* Author: Zakant
* Calculate the blood lost and blood volume for a unit. Used from CPR to simulate a heart rate while in cardiac arrest.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* 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 {
private _change = ([_unit, _deltaT, _syncValues] call EFUNC(medical_status,getBloodVolumeChange));
private _bloodVolume = 0 max (GET_BLOOD_VOLUME(_unit) + _change) min DEFAULT_BLOOD_VOLUME;
_unit setVariable [VAR_BLOOD_VOL, _bloodVolume, _syncValues];
};