From 1dc934e1b138eeeef71749ba4b7bcd660f146666 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Fri, 11 May 2018 15:28:25 +0100 Subject: [PATCH] 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. --- .../medical/functions/fnc_addDamageToUnit.sqf | 4 +- .../medical/functions/fnc_adjustPainLevel.sqf | 5 +- .../functions/fnc_dev_watchMedicalStats.sqf | 4 +- addons/medical/functions/fnc_handleKilled.sqf | 6 +-- addons/medical/script_macros_medical.hpp | 47 ++++++++++++------- addons/medical_ai/functions/fnc_healSelf.sqf | 2 +- addons/medical_ai/functions/fnc_healUnit.sqf | 2 +- .../functions/fnc_woundsHandler.sqf | 2 +- .../functions/fnc_woundsHandlerSQF.sqf | 2 +- .../functions/fnc_handleStateDefault.sqf | 6 +-- .../functions/fnc_handleStateInjured.sqf | 6 +-- .../functions/fnc_handleStateUnconscious.sqf | 6 +-- .../functions/fnc_leftStateCardiacArrest.sqf | 2 +- addons/medical_status/XEH_PREP.hpp | 1 - .../functions/fnc_getPainPerceived.sqf | 20 -------- .../medical_status/functions/fnc_initUnit.sqf | 10 ++-- .../functions/fnc_setCardiacArrest.sqf | 2 +- .../functions/fnc_calculateBlood.sqf | 4 +- .../functions/fnc_treatmentFullHealLocal.sqf | 6 +-- .../fnc_treatmentMedicationLocal.sqf | 8 ++-- .../functions/fnc_handleUnitVitals.sqf | 8 ++-- .../functions/fnc_updateHeartRate.sqf | 2 +- .../functions/fnc_updatePainSuppress.sqf | 8 ++-- 23 files changed, 77 insertions(+), 86 deletions(-) delete mode 100644 addons/medical_status/functions/fnc_getPainPerceived.sqf diff --git a/addons/medical/functions/fnc_addDamageToUnit.sqf b/addons/medical/functions/fnc_addDamageToUnit.sqf index f721cbfb95..4fc8afac9a 100644 --- a/addons/medical/functions/fnc_addDamageToUnit.sqf +++ b/addons/medical/functions/fnc_addDamageToUnit.sqf @@ -41,14 +41,14 @@ if (!isNull _instigator) then { #ifdef DEBUG_TESTRESULTS private _startDmg = +(_unit getVariable [QGVAR(bodyPartDamage), [-1]]); -private _startPain = GET_PAIN_TOTAL(_unit); +private _startPain = GET_PAIN(_unit); #endif [QEGVAR(medical_engine,woundReceived), [_unit, _bodyPart, _damageToAdd, _instigator, _typeOfDamage]] call CBA_fnc_localEvent; #ifdef DEBUG_TESTRESULTS private _endDmg = _unit getVariable [QGVAR(bodyPartDamage), [-1]]; -private _endPain = GET_PAIN_TOTAL(_unit); +private _endPain = GET_PAIN(_unit); private _typeOfDamageAdj = _typeOfDamage call EFUNC(medical_damage,getTypeOfDamage); private _config = configFile >> "ACE_Medical_Injuries" >> "damageTypes" >> _typeOfDamageAdj; private _selectionSpecific = true; diff --git a/addons/medical/functions/fnc_adjustPainLevel.sqf b/addons/medical/functions/fnc_adjustPainLevel.sqf index 5183bee6f1..71d6d6c9f7 100644 --- a/addons/medical/functions/fnc_adjustPainLevel.sqf +++ b/addons/medical/functions/fnc_adjustPainLevel.sqf @@ -24,6 +24,7 @@ TRACE_2("adjustPainLevel",_unit,_desiredPainLevel); _desiredPainLevel = _desiredPainLevel * GVAR(painCoefficient); -private _pain = GET_PAIN_TOTAL(_unit); +private _pain = GET_PAIN(_unit); +_pain = 0 max (_pain max _desiredPainLevel) min 1; -SET_PAIN_TOTAL(_unit,_pain max _desiredPainLevel,false); +_unit setVariable [VAR_PAIN, _pain]; diff --git a/addons/medical/functions/fnc_dev_watchMedicalStats.sqf b/addons/medical/functions/fnc_dev_watchMedicalStats.sqf index 08861c2b88..71355a3533 100644 --- a/addons/medical/functions/fnc_dev_watchMedicalStats.sqf +++ b/addons/medical/functions/fnc_dev_watchMedicalStats.sqf @@ -55,8 +55,8 @@ _return pushBack format [" - [HR: %1] [BP: %2 / %3]", _heartRate toFixed 1, _bpLow toFixed 1, _bpHigh toFixed 1]; // Pain: - private _pain = GET_PAIN_TOTAL(_unit); - private _painSuppress = _unit getVariable [QEGVAR(medical_status,painSuppress), 0]; + private _pain = GET_PAIN(_unit); + private _painSuppress = GET_PAIN_SUPPRESS(_unit); private _painLevel = GET_PAIN_PERCEIVED(_unit); _return pushBack format ["Effective Pain: %1", _painLevel toFixed 3]; _return pushBack format [" - [Pain: %1] [Suppress: %2]", _pain toFixed 3, _painSuppress toFixed 3]; diff --git a/addons/medical/functions/fnc_handleKilled.sqf b/addons/medical/functions/fnc_handleKilled.sqf index dad7f8dbeb..6f4c4dccfa 100644 --- a/addons/medical/functions/fnc_handleKilled.sqf +++ b/addons/medical/functions/fnc_handleKilled.sqf @@ -20,6 +20,6 @@ params ["_unit"]; if (!local _unit) exitWith {}; -SET_PAIN_TOTAL(_unit,0); -SET_HEART_RATE(_unit,0); -_unit setVariable [QGVAR(bloodPressure), [0, 0], true]; +_unit setVariable [VAR_PAIN, 0, true]; +_unit setVariable [VAR_HEART_RATE, 0, true]; +_unit setVariable [VAR_BLOOD_PRESS, [0, 0], true]; diff --git a/addons/medical/script_macros_medical.hpp b/addons/medical/script_macros_medical.hpp index 3f086a4a73..654699c507 100644 --- a/addons/medical/script_macros_medical.hpp +++ b/addons/medical/script_macros_medical.hpp @@ -57,21 +57,32 @@ // Minimum body part damage required for blood effect on uniform #define VISUAL_BODY_DAMAGE_THRESHOLD 0.35 -// - Status macro functions --------------------------------------------------- -// These macros provide the same functionality as the functions in the status -// component, but are slightly faster (because most are just object variables) -#define GET_BLOOD_LOSS(unit) ([unit] call EFUNC(medical_status,getBloodLoss)) // Just for consistency -#define GET_BLOOD_PRESSURE(unit) ([unit] call EFUNC(medical_status,getBloodPressure)) // Just for consistency -#define GET_BLOOD_VOLUME(unit) (unit getVariable [QEGVAR(medical_status,bloodVolume), DEFAULT_BLOOD_VOLUME]) -#define GET_HEART_RATE(unit) (unit getVariable [QEGVAR(medical_status,heartRate), DEFAULT_HEART_RATE]) -#define GET_PAIN_PERCEIVED(unit) ([unit] call EFUNC(medical_status,getPainPerceived)) // Just for consistency -#define GET_PAIN_TOTAL(unit) (unit getVariable [QEGVAR(medical_status,pain), 0]) -#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] -#define SET_PAIN_TOTAL(unit,value,sync) unit setVariable [QEGVAR(medical_status,pain), 0 max (value) min 1, sync] + + +// - Unit Variables ---------------------------------------------------- +// These variables get stored in object space and used across components +// Defined here for easy consistency with GETVAR/SETVAR (also a list for reference) +#define VAR_BLOOD_PRESS QEGVAR(medical,bloodPressure) +#define VAR_BLOOD_VOL QEGVAR(medical,bloodVolume) +#define VAR_HEART_RATE QEGVAR(medical,heartRate) +#define VAR_PAIN QEGVAR(medical,pain) +#define VAR_PAIN_SUPP QEGVAR(medical,painSuppress) +#define VAR_UNCON QEGVAR(medical,isUnconscious) + + +// - Unit Functions --------------------------------------------------- +// Retrieval macros for common unit values +// Defined for easy consistency and speed +#define GET_BLOOD_VOLUME(unit) (GETVAR(unit,VAR_BLOOD_VOL,DEFAULT_BLOOD_VOLUME)) +#define GET_HEART_RATE(unit) (GETVAR(unit,VAR_HEART_RATE,DEFAULT_HEART_RATE)) +#define GET_PAIN(unit) (GETVAR(unit,VAR_PAIN,0)) +#define GET_PAIN_SUPPRESS(unit) (GETVAR(unit,VAR_PAIN_SUPP,0)) +#define IS_UNCONSCIOUS(unit) (GETVAR(unit,VAR_UNCON,false)) + +// The following function calls are defined here just for consistency +#define GET_BLOOD_LOSS(unit) ([unit] call EFUNC(medical_status,getBloodLoss)) +#define GET_BLOOD_PRESSURE(unit) ([unit] call EFUNC(medical_status,getBloodPressure)) + +// Derivative unit values commonly used +#define GET_PAIN_PERCEIVED(unit) (0 max (GET_PAIN(unit) - GET_PAIN_SUPPRESS(unit)) min 1) +#define IS_IN_PAIN(unit) (GET_PAIN_PERCEIVED(unit) > 0) diff --git a/addons/medical_ai/functions/fnc_healSelf.sqf b/addons/medical_ai/functions/fnc_healSelf.sqf index 2a48e10250..9cb04b425f 100644 --- a/addons/medical_ai/functions/fnc_healSelf.sqf +++ b/addons/medical_ai/functions/fnc_healSelf.sqf @@ -23,7 +23,7 @@ if IS_UNCONSCIOUS(_this) exitWith {}; if ((_this getVariable [QGVAR(treatmentOverAt), CBA_missionTime]) > CBA_missionTime) exitWith {}; private _needsBandaging = GET_BLOOD_LOSS(_this) > 0; -private _needsMorphine = GET_PAIN_TOTAL(_this) > 0.2; +private _needsMorphine = GET_PAIN(_this) > 0.2; switch (true) do { case _needsBandaging: { diff --git a/addons/medical_ai/functions/fnc_healUnit.sqf b/addons/medical_ai/functions/fnc_healUnit.sqf index 927d15341c..1f2caf651c 100644 --- a/addons/medical_ai/functions/fnc_healUnit.sqf +++ b/addons/medical_ai/functions/fnc_healUnit.sqf @@ -53,7 +53,7 @@ _this forceSpeed 0; _target forceSpeed 0; private _needsBandaging = GET_BLOOD_LOSS(_target) > 0; -private _needsMorphine = GET_PAIN_TOTAL(_target) > 0.2; +private _needsMorphine = GET_PAIN(_target) > 0.2; private _needsEpinephrine = IS_UNCONSCIOUS(_target); switch (true) do { diff --git a/addons/medical_damage/functions/fnc_woundsHandler.sqf b/addons/medical_damage/functions/fnc_woundsHandler.sqf index 066e430c27..f6e455cf91 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,GET_PAIN_TOTAL(_unit),_unit getVariable QEGVAR(medical,openWounds),_woundsCreated); +TRACE_5("exit",_unit,_painLevel,GET_PAIN(_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 4f75bd5dfd..10377411ed 100644 --- a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf @@ -176,4 +176,4 @@ if (_critialDamage || {_painLevel > PAIN_UNCONSCIOUS}) then { [_unit] call EFUNC(medical,handleIncapacitation); }; -TRACE_5("exit",_unit,_painLevel,GET_PAIN_TOTAL(_unit),_unit getVariable QEGVAR(medical,openWounds),_woundsCreated); +TRACE_5("exit",_unit,_painLevel,GET_PAIN(_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 95a750ee02..5156670201 100644 --- a/addons/medical_statemachine/functions/fnc_handleStateDefault.sqf +++ b/addons/medical_statemachine/functions/fnc_handleStateDefault.sqf @@ -8,9 +8,9 @@ if (!alive _unit) exitWith {}; // If locality changed, broadcast the last medical state and finish the local loop if (!local _unit) exitWith { - SET_HEART_RATE(_unit,GET_HEART_RATE(_unit)); - _unit setVariable [QGVAR(bloodPressure), _unit getVariable [QGVAR(bloodPressure), [80, 120]], true]; - SET_BLOOD_VOLUME(_unit,GET_BLOOD_VOLUME(_unit)); + _unit setVariable [VAR_HEART_RATE, GET_HEART_RATE(_unit), true]; + _unit setVariable [VAR_BLOOD_PRESS, _unit getVariable [VAR_BLOOD_PRESS, [80, 120]], true]; + _unit setVariable [VAR_BLOOD_VOL, GET_BLOOD_VOLUME(_unit), true]; }; [_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 95a750ee02..5156670201 100644 --- a/addons/medical_statemachine/functions/fnc_handleStateInjured.sqf +++ b/addons/medical_statemachine/functions/fnc_handleStateInjured.sqf @@ -8,9 +8,9 @@ if (!alive _unit) exitWith {}; // If locality changed, broadcast the last medical state and finish the local loop if (!local _unit) exitWith { - SET_HEART_RATE(_unit,GET_HEART_RATE(_unit)); - _unit setVariable [QGVAR(bloodPressure), _unit getVariable [QGVAR(bloodPressure), [80, 120]], true]; - SET_BLOOD_VOLUME(_unit,GET_BLOOD_VOLUME(_unit)); + _unit setVariable [VAR_HEART_RATE, GET_HEART_RATE(_unit), true]; + _unit setVariable [VAR_BLOOD_PRESS, _unit getVariable [VAR_BLOOD_PRESS, [80, 120]], true]; + _unit setVariable [VAR_BLOOD_VOL, GET_BLOOD_VOLUME(_unit), true]; }; [_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 73bae8762c..d939f00fa2 100644 --- a/addons/medical_statemachine/functions/fnc_handleStateUnconscious.sqf +++ b/addons/medical_statemachine/functions/fnc_handleStateUnconscious.sqf @@ -9,9 +9,9 @@ if (!alive _unit) exitWith {}; // If locality changed, broadcast the last medical state and finish the local loop if (!local _unit) exitWith { - SET_HEART_RATE(_unit,GET_HEART_RATE(_unit)); - _unit setVariable [QGVAR(bloodPressure), _unit getVariable [QGVAR(bloodPressure), [80, 120]], true]; - SET_BLOOD_VOLUME(_unit,GET_BLOOD_VOLUME(_unit)); + _unit setVariable [VAR_HEART_RATE, GET_HEART_RATE(_unit), true]; + _unit setVariable [VAR_BLOOD_PRESS, _unit getVariable [VAR_BLOOD_PRESS, [80, 120]], true]; + _unit setVariable [VAR_BLOOD_VOL, GET_BLOOD_VOLUME(_unit), true]; }; [_unit] call EFUNC(medical_vitals,handleUnitVitals); diff --git a/addons/medical_statemachine/functions/fnc_leftStateCardiacArrest.sqf b/addons/medical_statemachine/functions/fnc_leftStateCardiacArrest.sqf index c9182874ca..86cb0aebf6 100644 --- a/addons/medical_statemachine/functions/fnc_leftStateCardiacArrest.sqf +++ b/addons/medical_statemachine/functions/fnc_leftStateCardiacArrest.sqf @@ -16,5 +16,5 @@ params ["_unit"]; _unit setVariable [QGVAR(inCardiacArrest), false, true]; _unit setVariable [QGVAR(cardiacArrestStart), nil]; -SET_HEART_RATE(_unit,40); +_unit setVariable [VAR_HEART_RATE, 40, true]; _unit setVariable [QGVAR(lastTimeUpdated), CBA_missionTime]; diff --git a/addons/medical_status/XEH_PREP.hpp b/addons/medical_status/XEH_PREP.hpp index a7459567a1..f96de3b293 100644 --- a/addons/medical_status/XEH_PREP.hpp +++ b/addons/medical_status/XEH_PREP.hpp @@ -3,7 +3,6 @@ PREP(getBloodLoss); PREP(getBloodPressure); PREP(getBloodVolumeChange); PREP(getCardiacOutput); -PREP(getPainPerceived); PREP(hasStableVitals); PREP(hasTourniquetAppliedTo); PREP(initUnit); diff --git a/addons/medical_status/functions/fnc_getPainPerceived.sqf b/addons/medical_status/functions/fnc_getPainPerceived.sqf deleted file mode 100644 index 0b6bc129c6..0000000000 --- a/addons/medical_status/functions/fnc_getPainPerceived.sqf +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Author: Ruthberg - * Get the perceived pain level of a unit. - * - * Arguments: - * 0: The Unit - * - * Return Value: - * Pain level (0 .. 1) - * - * Public: No - */ -#include "script_component.hpp" - -params ["_unit"]; - -private _pain = GET_PAIN_TOTAL(_unit); -private _painSuppress = _unit getVariable [QGVAR(painSuppress), 0]; - -(0 max (_pain - _painSuppress) min 1) diff --git a/addons/medical_status/functions/fnc_initUnit.sqf b/addons/medical_status/functions/fnc_initUnit.sqf index c3cbd8ed20..0102458c66 100644 --- a/addons/medical_status/functions/fnc_initUnit.sqf +++ b/addons/medical_status/functions/fnc_initUnit.sqf @@ -22,10 +22,10 @@ if (damage _unit > 0) then { }; // - Blood and heart ---------------------------------------------------------- -SET_BLOOD_VOLUME(_unit,DEFAULT_BLOOD_VOLUME); -SET_HEART_RATE(_unit,DEFAULT_HEART_RATE); +_unit setVariable [VAR_BLOOD_VOL, DEFAULT_BLOOD_VOLUME, true]; +_unit setVariable [VAR_HEART_RATE, DEFAULT_HEART_RATE, true]; _unit setVariable [QGVAR(heartRateAdjustments), [], true]; -_unit setVariable [QGVAR(bloodPressure), [80, 120], true]; +_unit setVariable [VAR_BLOOD_PRESS, [80, 120], true]; _unit setVariable [QGVAR(peripheralResistance), 100, true]; _unit setVariable [QGVAR(peripheralResistanceAdjustments), [], true]; _unit setVariable [QGVAR(inCardiacArrest), false, true]; @@ -33,9 +33,9 @@ _unit setVariable [QGVAR(hasLostBlood), 0, true]; _unit setVariable [QGVAR(isBleeding), false, true]; // - Pain --------------------------------------------------------------------- -SET_PAIN_TOTAL(_unit,0); +_unit setVariable [VAR_PAIN, 0, true]; _unit setVariable [QGVAR(hasPain), false, true]; -_unit setVariable [QGVAR(painSuppress), 0, true]; +_unit setVariable [VAR_PAIN_SUPP, 0, true]; _unit setVariable [QGVAR(painSuppressAdjustments), [], true]; // - Wounds ------------------------------------------------------------------- diff --git a/addons/medical_status/functions/fnc_setCardiacArrest.sqf b/addons/medical_status/functions/fnc_setCardiacArrest.sqf index e6b9689df2..e3fa60afb5 100644 --- a/addons/medical_status/functions/fnc_setCardiacArrest.sqf +++ b/addons/medical_status/functions/fnc_setCardiacArrest.sqf @@ -22,7 +22,7 @@ params ["_unit"]; if (_unit getVariable [QGVAR(inCardiacArrest), false]) exitWith {}; _unit setVariable [QGVAR(inCardiacArrest), true, true]; -SET_HEART_RATE(_unit,0); +_unit setVariable [VAR_HEART_RATE, 0, true]; ["ace_cardiacArrestEntered", [_unit]] call CBA_fnc_localEvent; diff --git a/addons/medical_treatment/functions/fnc_calculateBlood.sqf b/addons/medical_treatment/functions/fnc_calculateBlood.sqf index fa759f4ea8..6939adb808 100644 --- a/addons/medical_treatment/functions/fnc_calculateBlood.sqf +++ b/addons/medical_treatment/functions/fnc_calculateBlood.sqf @@ -24,6 +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 = GET_BLOOD_VOLUME(_unit) + _change; - SET_BLOOD_VOLUME(_unit,_bloodVolume,_syncValues); + private _bloodVolume = 0 max (GET_BLOOD_VOLUME(_unit) + _change) min DEFAULT_BLOOD_VOLUME; + _unit setVariable [VAR_BLOOD_VOL, _bloodVolume, _syncValues]; }; diff --git a/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf index 9952db7a61..925a97ff49 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 {}; -SET_PAIN_TOTAL(_target,0); -SET_BLOOD_VOLUME(_target,DEFAULT_BLOOD_VOLUME); +_unit setVariable [VAR_PAIN, 0, true]; +_unit setVariable [VAR_BLOOD_VOL, DEFAULT_BLOOD_VOLUME, true]; // tourniquets _target setVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0], true]; @@ -52,7 +52,7 @@ _target setVariable ["ACE_isUnconscious", false, true]; _target setVariable [QEGVAR(medical,hasLostBlood), 0, true]; _target setVariable [QEGVAR(medical,isBleeding), false, true]; _target setVariable [QEGVAR(medical,hasPain), false, true]; -_target setVariable [QEGVAR(medical,painSuppress), 0, true]; +_target setVariable [VAR_PAIN_SUPP, 0, true]; _target setVariable [QGVAR(painSuppressAdjustments), [], true]; _target setVariable [QGVAR(partialHealCounter), 0, true]; diff --git a/addons/medical_treatment/functions/fnc_treatmentMedicationLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentMedicationLocal.sqf index 9d240be2d0..21acd54f91 100644 --- a/addons/medical_treatment/functions/fnc_treatmentMedicationLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentMedicationLocal.sqf @@ -20,8 +20,8 @@ TRACE_3("params",_target,_className,_partIndex); if (!EGVAR(medical,advancedMedication)) exitWith { if (_className == "Morphine") exitWith { #define MORPHINE_PAIN_SUPPRESSION 0.6 - private _painSupress = _target getVariable [QEGVAR(medical,painSuppress), 0]; - _target setVariable [QEGVAR(medical,painSuppress), (_painSupress + MORPHINE_PAIN_SUPPRESSION) min 1, true]; + private _painSupress = GET_PAIN_SUPPRESS(_target); + _target setVariable [VAR_PAIN_SUPP, (_painSupress + MORPHINE_PAIN_SUPPRESSION) min 1, true]; }; if (_className == "Epinephrine") exitWith { @@ -77,14 +77,14 @@ if (alive _target) then { private _hrIncrease = [_hrIncreaseLow, _hrIncreaseNorm, _hrIncreaseHigh] select (floor ((0 max _heartRate min 110) / 55)); _hrIncrease params ["_minIncrease", "_maxIncrease"]; private _heartRateChange = _minIncrease + random (_maxIncrease - _minIncrease); - + // Adjust the heart rate based upon config entry if (_heartRateChange != 0) then { private _heartRateAdjustments = _target getVariable [QEGVAR(medical,heartRateAdjustments), []]; _heartRateAdjustments pushBack [_heartRateChange, _timeTillMaxEffect, _timeInSystem, 0]; _target setVariable [QEGVAR(medical,heartRateAdjustments), _heartRateAdjustments]; }; - + // Adjust the pain suppression based upon config entry if (_painReduce > 0) then { private _painSupressAdjustments = _target getVariable [QEGVAR(medical,painSupressAdjustments), []]; diff --git a/addons/medical_vitals/functions/fnc_handleUnitVitals.sqf b/addons/medical_vitals/functions/fnc_handleUnitVitals.sqf index eee04cf29a..ffe1a41d05 100644 --- a/addons/medical_vitals/functions/fnc_handleUnitVitals.sqf +++ b/addons/medical_vitals/functions/fnc_handleUnitVitals.sqf @@ -26,17 +26,17 @@ BEGIN_COUNTER(Vitals); _unit setVariable [QGVAR(lastTimeUpdated), CBA_missionTime]; private _lastTimeValuesSynced = _unit getVariable [QGVAR(lastMomentValuesSynced), 0]; -private _syncValues = (CBA_missionTime - _lastTimeValuesSynced) >= (10 + floor(random(10))); +private _syncValues = (CBA_missionTime - _lastTimeValuesSynced) >= (10 + floor(random 10)); if (_syncValues) then { _unit setVariable [QGVAR(lastMomentValuesSynced), CBA_missionTime]; }; private _bloodVolume = GET_BLOOD_VOLUME(_unit) + ([_unit, _deltaT, _syncValues] call EFUNC(medical_status,getBloodVolumeChange)); -//_bloodVolume = 0 max _bloodVolume min DEFAULT_BLOOD_VOLUME; +_bloodVolume = 0 max _bloodVolume min DEFAULT_BLOOD_VOLUME; // @todo: replace this and the rest of the setVariable with EFUNC(common,setApproximateVariablePublic) -SET_BLOOD_VOLUME(_unit,_bloodVolume,_syncValues); +_unit setVariable [VAR_BLOOD_VOL, _bloodVolume, _syncValues]; // Set variables for synchronizing information across the net if (_bloodVolume < BLOOD_VOLUME_CLASS_1_HEMORRHAGE) then { @@ -96,7 +96,7 @@ private _heartRate = [_unit, _deltaT, _syncValues] call FUNC(updateHeartRate); [_unit, _deltaT, _syncValues] call FUNC(updatePeripheralResistance); private _bloodPressure = GET_BLOOD_PRESSURE(_unit); -_unit setVariable [QGVAR(bloodPressure), _bloodPressure, _syncValues]; +_unit setVariable [VAR_BLOOD_PRESS, _bloodPressure, _syncValues]; private _cardiacOutput = [_unit] call EFUNC(medical_status,getCardiacOutput); if (_bloodLoss > BLOOD_LOSS_KNOCK_OUT_THRESHOLD * _cardiacOutput) then { diff --git a/addons/medical_vitals/functions/fnc_updateHeartRate.sqf b/addons/medical_vitals/functions/fnc_updateHeartRate.sqf index 7caef478e2..dd0c8a7fd2 100644 --- a/addons/medical_vitals/functions/fnc_updateHeartRate.sqf +++ b/addons/medical_vitals/functions/fnc_updateHeartRate.sqf @@ -75,7 +75,7 @@ if (!(_unit getVariable [QGVAR(inCardiacArrest), false])) then { _heartRate = (_heartRate + _deltaT * _hrChange) max 0; }; -SET_HEART_RATE(_unit,_heartRate,_syncValue); +_unit setVariable [VAR_HEART_RATE, _heartRate, _syncValue]; _heartRate diff --git a/addons/medical_vitals/functions/fnc_updatePainSuppress.sqf b/addons/medical_vitals/functions/fnc_updatePainSuppress.sqf index 550cd626a7..45d200cd44 100644 --- a/addons/medical_vitals/functions/fnc_updatePainSuppress.sqf +++ b/addons/medical_vitals/functions/fnc_updatePainSuppress.sqf @@ -40,16 +40,16 @@ if (!(_adjustment isEqualTo [])) then { _adjustment = _adjustment - [ObjNull]; _unit setVariable [QGVAR(painSupressAdjustments), _adjustment, (_syncValue || {_adjustment isEqualTo []})]; // always sync on last run - _unit setVariable [QGVAR(painSuppress), 0 max _painSupressAdjustment, _syncValue]; + _unit setVariable [VAR_PAIN_SUPP, 0 max _painSupressAdjustment, _syncValue]; }; // Handle continuous pain reduction -private _pain = GET_PAIN_TOTAL(_unit); +private _pain = GET_PAIN(_unit); _unit setVariable [QEGVAR(medical_status,pain), 0 max (_pain - _deltaT / PAIN_FADE_TIME), _syncValue]; // Handles simple medication if (!EGVAR(medical,advancedMedication)) then { - private _painSupress = _unit getVariable [QGVAR(painSuppress), 0]; + private _painSupress = _unit getVariable [VAR_PAIN_SUPP, 0]; _painSupress = _painSupress - _deltaT / PAIN_SUPPRESSION_FADE_TIME; - _unit setVariable [QGVAR(painSuppress), 0 max _painSupress, _syncValue]; + _unit setVariable [VAR_PAIN_SUPP, 0 max _painSupress, _syncValue]; };