diff --git a/addons/medical/script_macros_medical.hpp b/addons/medical/script_macros_medical.hpp index e8485cbb3c..3f086a4a73 100644 --- a/addons/medical/script_macros_medical.hpp +++ b/addons/medical/script_macros_medical.hpp @@ -69,6 +69,8 @@ #define IS_IN_PAIN(unit) (GET_PAIN_PERCEIVED(unit) > 0) #define IS_UNCONSCIOUS(unit) (unit getVariable [QEGVAR(medical_status,isUnconscious), false]) // Setters have overloaded versions for locality handling +#define SET_BLOOD_VOLUME(unit,value) unit setVariable [QEGVAR(medical_status,bloodVolume), 0 max value min DEFAULT_BLOOD_VOLUME, true] +#define SET_BLOOD_VOLUME(unit,value,sync) unit setVariable [QEGVAR(medical_status,bloodVolume), 0 max value min DEFAULT_BLOOD_VOLUME, sync] #define SET_HEART_RATE(unit,value) unit setVariable [QEGVAR(medical_status,heartRate), value, true] #define SET_HEART_RATE(unit,value,sync) unit setVariable [QEGVAR(medical_status,heartRate), value, sync] #define SET_PAIN_TOTAL(unit,value) unit setVariable [QEGVAR(medical_status,pain), 0 max (value) min 1, true] diff --git a/addons/medical_damage/functions/fnc_woundsHandler.sqf b/addons/medical_damage/functions/fnc_woundsHandler.sqf index 688ff86fd7..066e430c27 100644 --- a/addons/medical_damage/functions/fnc_woundsHandler.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandler.sqf @@ -118,4 +118,4 @@ if (_critialDamage || {_painLevel > PAIN_UNCONSCIOUS}) then { [_unit] call EFUNC(medical,handleIncapacitation); }; -TRACE_5("exit",_unit,_painLevel,_unit getVariable QEGVAR(medical,pain),_unit getVariable QEGVAR(medical,openWounds),_woundsCreated); +TRACE_5("exit",_unit,_painLevel,GET_PAIN_TOTAL(_unit),_unit getVariable QEGVAR(medical,openWounds),_woundsCreated); diff --git a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf index 10af92bf17..4f75bd5dfd 100644 --- a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf @@ -91,10 +91,10 @@ private _woundsCreated = []; _oldInjury params ["_woundClassIDToAdd", "", "_injuryBleedingRate", "_injuryPain"]; private _bodyPartNToAdd = [floor random 6, _bodyPartN] select _isSelectionSpecific; // 6 == count ALL_BODY_PARTS - + _bodyPartDamage set [_bodyPartNToAdd, (_bodyPartDamage select _bodyPartNToAdd) + _woundDamage]; _bodyPartVisParams set [[1,2,3,3,4,4] select _bodyPartNToAdd, true]; // Mark the body part index needs updating - + // Create a new injury. Format [ID, classID, bodypart, percentage treated, bleeding rate] _injury = [_woundID, _woundClassIDToAdd, _bodyPartNToAdd, 1, _injuryBleedingRate]; @@ -176,4 +176,4 @@ if (_critialDamage || {_painLevel > PAIN_UNCONSCIOUS}) then { [_unit] call EFUNC(medical,handleIncapacitation); }; -TRACE_5("exit",_unit,_painLevel,_unit getVariable QEGVAR(medical,pain),_unit getVariable QEGVAR(medical,openWounds),_woundsCreated); +TRACE_5("exit",_unit,_painLevel,GET_PAIN_TOTAL(_unit),_unit getVariable QEGVAR(medical,openWounds),_woundsCreated); diff --git a/addons/medical_statemachine/functions/fnc_handleStateDefault.sqf b/addons/medical_statemachine/functions/fnc_handleStateDefault.sqf index f3027d1ee8..95a750ee02 100644 --- a/addons/medical_statemachine/functions/fnc_handleStateDefault.sqf +++ b/addons/medical_statemachine/functions/fnc_handleStateDefault.sqf @@ -10,7 +10,7 @@ if (!alive _unit) exitWith {}; if (!local _unit) exitWith { SET_HEART_RATE(_unit,GET_HEART_RATE(_unit)); _unit setVariable [QGVAR(bloodPressure), _unit getVariable [QGVAR(bloodPressure), [80, 120]], true]; - _unit setVariable [QGVAR(bloodVolume), _unit getVariable [QGVAR(bloodVolume), DEFAULT_BLOOD_VOLUME], true]; + SET_BLOOD_VOLUME(_unit,GET_BLOOD_VOLUME(_unit)); }; [_unit] call EFUNC(medical_vitals,handleUnitVitals); diff --git a/addons/medical_statemachine/functions/fnc_handleStateInjured.sqf b/addons/medical_statemachine/functions/fnc_handleStateInjured.sqf index f3027d1ee8..95a750ee02 100644 --- a/addons/medical_statemachine/functions/fnc_handleStateInjured.sqf +++ b/addons/medical_statemachine/functions/fnc_handleStateInjured.sqf @@ -10,7 +10,7 @@ if (!alive _unit) exitWith {}; if (!local _unit) exitWith { SET_HEART_RATE(_unit,GET_HEART_RATE(_unit)); _unit setVariable [QGVAR(bloodPressure), _unit getVariable [QGVAR(bloodPressure), [80, 120]], true]; - _unit setVariable [QGVAR(bloodVolume), _unit getVariable [QGVAR(bloodVolume), DEFAULT_BLOOD_VOLUME], true]; + SET_BLOOD_VOLUME(_unit,GET_BLOOD_VOLUME(_unit)); }; [_unit] call EFUNC(medical_vitals,handleUnitVitals); diff --git a/addons/medical_statemachine/functions/fnc_handleStateUnconscious.sqf b/addons/medical_statemachine/functions/fnc_handleStateUnconscious.sqf index 979d2ec1fe..73bae8762c 100644 --- a/addons/medical_statemachine/functions/fnc_handleStateUnconscious.sqf +++ b/addons/medical_statemachine/functions/fnc_handleStateUnconscious.sqf @@ -11,7 +11,7 @@ if (!alive _unit) exitWith {}; if (!local _unit) exitWith { SET_HEART_RATE(_unit,GET_HEART_RATE(_unit)); _unit setVariable [QGVAR(bloodPressure), _unit getVariable [QGVAR(bloodPressure), [80, 120]], true]; - _unit setVariable [QGVAR(bloodVolume), _unit getVariable [QGVAR(bloodVolume), DEFAULT_BLOOD_VOLUME], true]; + SET_BLOOD_VOLUME(_unit,GET_BLOOD_VOLUME(_unit)); }; [_unit] call EFUNC(medical_vitals,handleUnitVitals); diff --git a/addons/medical_status/functions/fnc_getBloodVolumeChange.sqf b/addons/medical_status/functions/fnc_getBloodVolumeChange.sqf index 59088856bb..431a043aa0 100644 --- a/addons/medical_status/functions/fnc_getBloodVolumeChange.sqf +++ b/addons/medical_status/functions/fnc_getBloodVolumeChange.sqf @@ -19,7 +19,7 @@ params ["_unit", "_deltaT", "_syncValues"]; -private _bloodVolume = _unit getVariable [QGVAR(bloodVolume), DEFAULT_BLOOD_VOLUME]; +private _bloodVolume = GET_BLOOD_VOLUME(_unit); private _bloodVolumeChange = -_deltaT * GET_BLOOD_LOSS(_unit); if (!isNil {_unit getVariable QGVAR(ivBags)}) then { diff --git a/addons/medical_status/functions/fnc_hasStableVitals.sqf b/addons/medical_status/functions/fnc_hasStableVitals.sqf index e360af8a90..04455426e5 100644 --- a/addons/medical_status/functions/fnc_hasStableVitals.sqf +++ b/addons/medical_status/functions/fnc_hasStableVitals.sqf @@ -17,7 +17,7 @@ params ["_unit"]; -if (_unit getVariable [QGVAR(bloodVolume), DEFAULT_BLOOD_VOLUME] < BLOOD_VOLUME_CLASS_2_HEMORRHAGE) exitWith { false }; +if (GET_BLOOD_VOLUME(_unit) < BLOOD_VOLUME_CLASS_2_HEMORRHAGE) exitWith { false }; if (_unit getVariable [QGVAR(inCardiacArrest), false]) exitWith { false }; private _cardiacOutput = [_unit] call FUNC(getCardiacOutput); diff --git a/addons/medical_status/functions/fnc_initUnit.sqf b/addons/medical_status/functions/fnc_initUnit.sqf index 77f39ac234..c3cbd8ed20 100644 --- a/addons/medical_status/functions/fnc_initUnit.sqf +++ b/addons/medical_status/functions/fnc_initUnit.sqf @@ -22,7 +22,7 @@ if (damage _unit > 0) then { }; // - Blood and heart ---------------------------------------------------------- -_unit setVariable [QGVAR(bloodVolume), DEFAULT_BLOOD_VOLUME, true]; +SET_BLOOD_VOLUME(_unit,DEFAULT_BLOOD_VOLUME); SET_HEART_RATE(_unit,DEFAULT_HEART_RATE); _unit setVariable [QGVAR(heartRateAdjustments), [], true]; _unit setVariable [QGVAR(bloodPressure), [80, 120], true]; diff --git a/addons/medical_treatment/functions/fnc_calculateBlood.sqf b/addons/medical_treatment/functions/fnc_calculateBlood.sqf index 2721afd8c9..fa759f4ea8 100644 --- a/addons/medical_treatment/functions/fnc_calculateBlood.sqf +++ b/addons/medical_treatment/functions/fnc_calculateBlood.sqf @@ -24,7 +24,6 @@ private _syncValues = (CBA_missionTime - _lastTimeValuesSynced) >= (10 + floor(r _unit setVariable [QEGVAR(medical,lastTimeUpdated), CBA_missionTime]; if (_deltaT != 0) then { private _change = ([_unit, _deltaT, _syncValues] call EFUNC(medical_status,getBloodVolumeChange)); - private _bloodVolume = (_unit getVariable [QEGVAR(medical,bloodVolume), DEFAULT_BLOOD_VOLUME]) + _change; - _bloodVolume = 0 max _bloodVolume min DEFAULT_BLOOD_VOLUME; - _unit setVariable [QEGVAR(medical,bloodVolume), _bloodVolume, _syncValues]; + private _bloodVolume = GET_BLOOD_VOLUME(_unit) + _change; + SET_BLOOD_VOLUME(_unit,_bloodVolume,_syncValues); }; diff --git a/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf index 403e8179d3..9952db7a61 100644 --- a/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf @@ -17,8 +17,8 @@ params ["_caller", "_target"]; if (!alive _target) exitWith {}; -_target setVariable [QEGVAR(medical,pain), 0, true]; -_target setVariable [QEGVAR(medical,bloodVolume), DEFAULT_BLOOD_VOLUME, true]; +SET_PAIN_TOTAL(_target,0); +SET_BLOOD_VOLUME(_target,DEFAULT_BLOOD_VOLUME); // tourniquets _target setVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0], true]; diff --git a/addons/medical_treatment/functions/fnc_treatmentIVLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentIVLocal.sqf index 0b64260e2b..690446a2be 100644 --- a/addons/medical_treatment/functions/fnc_treatmentIVLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentIVLocal.sqf @@ -20,7 +20,7 @@ params ["_target", "_treatmentClassname", "_bodyPart"]; private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; if (_partIndex < 0) exitWith { false }; -private _bloodVolume = _target getVariable [QEGVAR(medical,bloodVolume), DEFAULT_BLOOD_VOLUME]; +private _bloodVolume = GET_BLOOD_VOLUME(_target); if (_bloodVolume >= DEFAULT_BLOOD_VOLUME) exitWith {}; diff --git a/addons/medical_vitals/functions/fnc_handleUnitVitals.sqf b/addons/medical_vitals/functions/fnc_handleUnitVitals.sqf index 514d4bd528..eee04cf29a 100644 --- a/addons/medical_vitals/functions/fnc_handleUnitVitals.sqf +++ b/addons/medical_vitals/functions/fnc_handleUnitVitals.sqf @@ -32,11 +32,11 @@ if (_syncValues) then { _unit setVariable [QGVAR(lastMomentValuesSynced), CBA_missionTime]; }; -private _bloodVolume = (_unit getVariable [QGVAR(bloodVolume), DEFAULT_BLOOD_VOLUME]) + ([_unit, _deltaT, _syncValues] call EFUNC(medical_status,getBloodVolumeChange)); -_bloodVolume = 0 max _bloodVolume min DEFAULT_BLOOD_VOLUME; +private _bloodVolume = GET_BLOOD_VOLUME(_unit) + ([_unit, _deltaT, _syncValues] call EFUNC(medical_status,getBloodVolumeChange)); +//_bloodVolume = 0 max _bloodVolume min DEFAULT_BLOOD_VOLUME; // @todo: replace this and the rest of the setVariable with EFUNC(common,setApproximateVariablePublic) -_unit setVariable [QGVAR(bloodVolume), _bloodVolume, _syncValues]; +SET_BLOOD_VOLUME(_unit,_bloodVolume,_syncValues); // Set variables for synchronizing information across the net if (_bloodVolume < BLOOD_VOLUME_CLASS_1_HEMORRHAGE) then { diff --git a/addons/medical_vitals/functions/fnc_updateHeartRate.sqf b/addons/medical_vitals/functions/fnc_updateHeartRate.sqf index 6e38b2821b..7caef478e2 100644 --- a/addons/medical_vitals/functions/fnc_updateHeartRate.sqf +++ b/addons/medical_vitals/functions/fnc_updateHeartRate.sqf @@ -48,7 +48,7 @@ private _heartRate = GET_HEART_RATE(_unit); if (!(_unit getVariable [QGVAR(inCardiacArrest), false])) then { private _hrChange = 0; - private _bloodVolume = _unit getVariable [QGVAR(bloodVolume), DEFAULT_BLOOD_VOLUME]; + 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;