From 37a2ecf01a311d9a6073fbf2e179831938e8f6dc Mon Sep 17 00:00:00 2001 From: DartRuffian Date: Sat, 16 Nov 2024 10:27:37 -0600 Subject: [PATCH 01/18] Add wrapper for medical_ai isInjured --- addons/medical/XEH_PREP.hpp | 1 + addons/medical/functions/fnc_isInjured.sqf | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 addons/medical/functions/fnc_isInjured.sqf diff --git a/addons/medical/XEH_PREP.hpp b/addons/medical/XEH_PREP.hpp index d1edb26493b..b1146c40411 100644 --- a/addons/medical/XEH_PREP.hpp +++ b/addons/medical/XEH_PREP.hpp @@ -2,5 +2,6 @@ PREP(addDamageToUnit); PREP(adjustPainLevel); PREP(deserializeState); PREP(fullHeal); +PREP(isInjured); PREP(serializeState); PREP(setUnconscious); diff --git a/addons/medical/functions/fnc_isInjured.sqf b/addons/medical/functions/fnc_isInjured.sqf new file mode 100644 index 00000000000..74c78cc8d6b --- /dev/null +++ b/addons/medical/functions/fnc_isInjured.sqf @@ -0,0 +1,22 @@ +#include "..\script_component.hpp" +/* + * Author: DartRuffian + * Checks if a unit needs treatment. + * + * Arguments: + * Unit + * + * Return Value: + * Does unit need treatment + * + * Example: + * ACE_player call ace_medical_fnc_isInjured + * + * Public: Yes + */ + +params [["_unit", objNull, [objNull]]]; + +if !(alive _unit) exitWith {false}; + +_unit call EFUNC(medical_ai,isInjured) From 8f2a557985ab8350f983734528b49bc63e5558a1 Mon Sep 17 00:00:00 2001 From: DartRuffian Date: Sat, 16 Nov 2024 10:37:54 -0600 Subject: [PATCH 02/18] getBloodLoss --- addons/medical/XEH_PREP.hpp | 1 + addons/medical/functions/fnc_getBloodLoss.sqf | 22 +++++++++++++++++++ .../functions/fnc_getBloodLoss.sqf | 6 ++--- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 addons/medical/functions/fnc_getBloodLoss.sqf diff --git a/addons/medical/XEH_PREP.hpp b/addons/medical/XEH_PREP.hpp index b1146c40411..ec28688c1e1 100644 --- a/addons/medical/XEH_PREP.hpp +++ b/addons/medical/XEH_PREP.hpp @@ -2,6 +2,7 @@ PREP(addDamageToUnit); PREP(adjustPainLevel); PREP(deserializeState); PREP(fullHeal); +PREP(getBloodLoss); PREP(isInjured); PREP(serializeState); PREP(setUnconscious); diff --git a/addons/medical/functions/fnc_getBloodLoss.sqf b/addons/medical/functions/fnc_getBloodLoss.sqf new file mode 100644 index 00000000000..c830677d2be --- /dev/null +++ b/addons/medical/functions/fnc_getBloodLoss.sqf @@ -0,0 +1,22 @@ +#include "..\script_component.hpp" +/* + * Author: DartRuffian + * Calculate the total blood loss of a unit. + * + * Arguments: + * 0: The Unit + * + * Return Value: + * Total blood loss of unit (litres/second) + * + * Example: + * [player] call ace_medical_fnc_getBloodLoss + * + * Public: Yes + */ + +params [["_unit", objNull, [objNull]]]; + +if (isNull _unit) exitWith {-1}; + +_unit call EFUNC(medical_status,getBloodLoss) diff --git a/addons/medical_status/functions/fnc_getBloodLoss.sqf b/addons/medical_status/functions/fnc_getBloodLoss.sqf index 5193ccbb0b0..b98164e06ff 100644 --- a/addons/medical_status/functions/fnc_getBloodLoss.sqf +++ b/addons/medical_status/functions/fnc_getBloodLoss.sqf @@ -21,13 +21,13 @@ private _woundBleeding = GET_WOUND_BLEEDING(_unit); if (_woundBleeding == 0) exitWith {0}; private _cardiacOutput = [_unit] call FUNC(getCardiacOutput); -private _resistance = _unit getVariable [VAR_PERIPH_RES, DEFAULT_PERIPH_RES]; // can use value directly since this is sum of default and adjustments +private _resistance = _unit getVariable [VAR_PERIPH_RES, DEFAULT_PERIPH_RES]; // Can use value directly since this is sum of default and adjustments -// even if heart stops blood will still flow slowly (gravity) +// Even if heart stops blood will still flow slowly (gravity) private _bloodLoss = (_woundBleeding * (_cardiacOutput max CARDIAC_OUTPUT_MIN) * (DEFAULT_PERIPH_RES / _resistance) * EGVAR(medical,bleedingCoefficient)); private _eventArgs = [_unit, _bloodLoss]; // Pass by reference [QGVAR(getBloodLoss), _eventArgs] call CBA_fnc_localEvent; -_eventArgs select 1 // return +_eventArgs select 1 // Return From b91c687f1f0dc402112b4ced7d58dffc23d7390c Mon Sep 17 00:00:00 2001 From: DartRuffian Date: Sat, 16 Nov 2024 10:44:02 -0600 Subject: [PATCH 03/18] Fix missing "0: " --- addons/medical/functions/fnc_isInjured.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_isInjured.sqf b/addons/medical/functions/fnc_isInjured.sqf index 74c78cc8d6b..b58ce74a147 100644 --- a/addons/medical/functions/fnc_isInjured.sqf +++ b/addons/medical/functions/fnc_isInjured.sqf @@ -4,7 +4,7 @@ * Checks if a unit needs treatment. * * Arguments: - * Unit + * 0: Unit * * Return Value: * Does unit need treatment From 512f5ca02623b12ecfda4b93b6684a58bd7c2b90 Mon Sep 17 00:00:00 2001 From: Dart <59131299+DartRuffian@users.noreply.github.com> Date: Sat, 16 Nov 2024 20:00:42 -0600 Subject: [PATCH 04/18] Revert comment changes --- addons/medical_status/functions/fnc_getBloodLoss.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/medical_status/functions/fnc_getBloodLoss.sqf b/addons/medical_status/functions/fnc_getBloodLoss.sqf index b98164e06ff..5193ccbb0b0 100644 --- a/addons/medical_status/functions/fnc_getBloodLoss.sqf +++ b/addons/medical_status/functions/fnc_getBloodLoss.sqf @@ -21,13 +21,13 @@ private _woundBleeding = GET_WOUND_BLEEDING(_unit); if (_woundBleeding == 0) exitWith {0}; private _cardiacOutput = [_unit] call FUNC(getCardiacOutput); -private _resistance = _unit getVariable [VAR_PERIPH_RES, DEFAULT_PERIPH_RES]; // Can use value directly since this is sum of default and adjustments +private _resistance = _unit getVariable [VAR_PERIPH_RES, DEFAULT_PERIPH_RES]; // can use value directly since this is sum of default and adjustments -// Even if heart stops blood will still flow slowly (gravity) +// even if heart stops blood will still flow slowly (gravity) private _bloodLoss = (_woundBleeding * (_cardiacOutput max CARDIAC_OUTPUT_MIN) * (DEFAULT_PERIPH_RES / _resistance) * EGVAR(medical,bleedingCoefficient)); private _eventArgs = [_unit, _bloodLoss]; // Pass by reference [QGVAR(getBloodLoss), _eventArgs] call CBA_fnc_localEvent; -_eventArgs select 1 // Return +_eventArgs select 1 // return From 253ec0700c7baaee2c670daeac146bbe717e716c Mon Sep 17 00:00:00 2001 From: Dart <59131299+DartRuffian@users.noreply.github.com> Date: Sun, 17 Nov 2024 12:55:57 -0600 Subject: [PATCH 05/18] Use GET_BLOOD_LOSS macro Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/medical/functions/fnc_getBloodLoss.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_getBloodLoss.sqf b/addons/medical/functions/fnc_getBloodLoss.sqf index c830677d2be..c0b6032e2d4 100644 --- a/addons/medical/functions/fnc_getBloodLoss.sqf +++ b/addons/medical/functions/fnc_getBloodLoss.sqf @@ -19,4 +19,4 @@ params [["_unit", objNull, [objNull]]]; if (isNull _unit) exitWith {-1}; -_unit call EFUNC(medical_status,getBloodLoss) +GET_BLOOD_LOSS(_unit) From 818f8cf79051c267efe35fb464a2336b2e57e26d Mon Sep 17 00:00:00 2001 From: Dart <59131299+DartRuffian@users.noreply.github.com> Date: Sun, 17 Nov 2024 12:56:18 -0600 Subject: [PATCH 06/18] Update parameter description Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/medical/functions/fnc_getBloodLoss.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_getBloodLoss.sqf b/addons/medical/functions/fnc_getBloodLoss.sqf index c0b6032e2d4..e663cd082bb 100644 --- a/addons/medical/functions/fnc_getBloodLoss.sqf +++ b/addons/medical/functions/fnc_getBloodLoss.sqf @@ -4,7 +4,7 @@ * Calculate the total blood loss of a unit. * * Arguments: - * 0: The Unit + * 0: Unit * * Return Value: * Total blood loss of unit (litres/second) From 4ceef9d255f34de6ab0cf36e292bbe13d96f94bc Mon Sep 17 00:00:00 2001 From: Dart <59131299+DartRuffian@users.noreply.github.com> Date: Sun, 17 Nov 2024 12:56:29 -0600 Subject: [PATCH 07/18] Use `player` Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/medical/functions/fnc_isInjured.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_isInjured.sqf b/addons/medical/functions/fnc_isInjured.sqf index b58ce74a147..3fe5e97dc02 100644 --- a/addons/medical/functions/fnc_isInjured.sqf +++ b/addons/medical/functions/fnc_isInjured.sqf @@ -10,7 +10,7 @@ * Does unit need treatment * * Example: - * ACE_player call ace_medical_fnc_isInjured + * player call ace_medical_fnc_isInjured * * Public: Yes */ From 92efffc4759b4eb15dc05004c969975c06c56a5e Mon Sep 17 00:00:00 2001 From: Dart <59131299+DartRuffian@users.noreply.github.com> Date: Sun, 17 Nov 2024 12:56:40 -0600 Subject: [PATCH 08/18] Remove brackets Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/medical/functions/fnc_getBloodLoss.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_getBloodLoss.sqf b/addons/medical/functions/fnc_getBloodLoss.sqf index e663cd082bb..a17b4a0e459 100644 --- a/addons/medical/functions/fnc_getBloodLoss.sqf +++ b/addons/medical/functions/fnc_getBloodLoss.sqf @@ -10,7 +10,7 @@ * Total blood loss of unit (litres/second) * * Example: - * [player] call ace_medical_fnc_getBloodLoss + * player call ace_medical_fnc_getBloodLoss * * Public: Yes */ From 93a717ebaf995109fc6c43aa3b294f76e66aa612 Mon Sep 17 00:00:00 2001 From: DartRuffian Date: Sun, 17 Nov 2024 15:28:01 -0600 Subject: [PATCH 09/18] Check if arms are fractured --- addons/medical/functions/fnc_isInjured.sqf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_isInjured.sqf b/addons/medical/functions/fnc_isInjured.sqf index 3fe5e97dc02..518e4e90c60 100644 --- a/addons/medical/functions/fnc_isInjured.sqf +++ b/addons/medical/functions/fnc_isInjured.sqf @@ -19,4 +19,7 @@ params [["_unit", objNull, [objNull]]]; if !(alive _unit) exitWith {false}; -_unit call EFUNC(medical_ai,isInjured) +private _fractures = GET_FRACTURES(_unit); + +((_fractures select HITPOINT_INDEX_LARM) == 1) || {(_fractures select HITPOINT_INDEX_RARM) == 1} || +{_unit call EFUNC(medical_ai,isInjured)} From 4ae3df39f8901ab7232e29f48a0255db7d01042d Mon Sep 17 00:00:00 2001 From: DartRuffian Date: Mon, 18 Nov 2024 12:23:50 -0600 Subject: [PATCH 10/18] Error on remote unit --- addons/medical/functions/fnc_isInjured.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_isInjured.sqf b/addons/medical/functions/fnc_isInjured.sqf index 518e4e90c60..fb78ff22d3e 100644 --- a/addons/medical/functions/fnc_isInjured.sqf +++ b/addons/medical/functions/fnc_isInjured.sqf @@ -17,7 +17,8 @@ params [["_unit", objNull, [objNull]]]; -if !(alive _unit) exitWith {false}; +if (!alive _unit) exitWith { false }; +if (!local _unit) exitWith { ERROR_1("unit [%1] is not local",_unit); }; private _fractures = GET_FRACTURES(_unit); From 53f2706036d2670d92cebf50a0823ad574947273 Mon Sep 17 00:00:00 2001 From: DartRuffian Date: Mon, 18 Nov 2024 12:25:44 -0600 Subject: [PATCH 11/18] Check blood volume --- addons/medical/functions/fnc_isInjured.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/medical/functions/fnc_isInjured.sqf b/addons/medical/functions/fnc_isInjured.sqf index fb78ff22d3e..d4e518331c3 100644 --- a/addons/medical/functions/fnc_isInjured.sqf +++ b/addons/medical/functions/fnc_isInjured.sqf @@ -23,4 +23,5 @@ if (!local _unit) exitWith { ERROR_1("unit [%1] is not local",_unit); }; private _fractures = GET_FRACTURES(_unit); ((_fractures select HITPOINT_INDEX_LARM) == 1) || {(_fractures select HITPOINT_INDEX_RARM) == 1} || +{GET_BLOOD_VOLUME(_unit) != DEFAULT_BLOOD_VOLUME} || {_unit call EFUNC(medical_ai,isInjured)} From b77cd6de6e90002770f6602f0fd4f2635b5a6c09 Mon Sep 17 00:00:00 2001 From: DartRuffian Date: Mon, 18 Nov 2024 23:36:48 -0600 Subject: [PATCH 12/18] Check common_fnc_isAwake --- addons/medical/functions/fnc_isInjured.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/medical/functions/fnc_isInjured.sqf b/addons/medical/functions/fnc_isInjured.sqf index d4e518331c3..ce8638e9012 100644 --- a/addons/medical/functions/fnc_isInjured.sqf +++ b/addons/medical/functions/fnc_isInjured.sqf @@ -24,4 +24,5 @@ private _fractures = GET_FRACTURES(_unit); ((_fractures select HITPOINT_INDEX_LARM) == 1) || {(_fractures select HITPOINT_INDEX_RARM) == 1} || {GET_BLOOD_VOLUME(_unit) != DEFAULT_BLOOD_VOLUME} || +{!(_unit call EFUNC(common,isAwake))} || {_unit call EFUNC(medical_ai,isInjured)} From bb7970d7c610ceab26ced5b4acfc04c93604e544 Mon Sep 17 00:00:00 2001 From: DartRuffian Date: Sat, 23 Nov 2024 08:09:10 -0600 Subject: [PATCH 13/18] Remove isAwake check --- addons/medical/functions/fnc_isInjured.sqf | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/medical/functions/fnc_isInjured.sqf b/addons/medical/functions/fnc_isInjured.sqf index ce8638e9012..d4e518331c3 100644 --- a/addons/medical/functions/fnc_isInjured.sqf +++ b/addons/medical/functions/fnc_isInjured.sqf @@ -24,5 +24,4 @@ private _fractures = GET_FRACTURES(_unit); ((_fractures select HITPOINT_INDEX_LARM) == 1) || {(_fractures select HITPOINT_INDEX_RARM) == 1} || {GET_BLOOD_VOLUME(_unit) != DEFAULT_BLOOD_VOLUME} || -{!(_unit call EFUNC(common,isAwake))} || {_unit call EFUNC(medical_ai,isInjured)} From 79265d81fa75d12a17e775003db18f53460ddad8 Mon Sep 17 00:00:00 2001 From: DartRuffian Date: Fri, 13 Dec 2024 11:46:14 -0600 Subject: [PATCH 14/18] Update isInjured Is injured just wraps medical ai's isInjured and checks for arm fractures. No longer is required to be local. Add local check to getBloodLoss --- addons/medical/functions/fnc_getBloodLoss.sqf | 2 +- addons/medical/functions/fnc_isInjured.sqf | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/addons/medical/functions/fnc_getBloodLoss.sqf b/addons/medical/functions/fnc_getBloodLoss.sqf index a17b4a0e459..5fc5665d8e3 100644 --- a/addons/medical/functions/fnc_getBloodLoss.sqf +++ b/addons/medical/functions/fnc_getBloodLoss.sqf @@ -17,6 +17,6 @@ params [["_unit", objNull, [objNull]]]; -if (isNull _unit) exitWith {-1}; +if (!local _unit) exitWith { ERROR_1("unit [%1] is not local",_unit) }; GET_BLOOD_LOSS(_unit) diff --git a/addons/medical/functions/fnc_isInjured.sqf b/addons/medical/functions/fnc_isInjured.sqf index d4e518331c3..1573be01980 100644 --- a/addons/medical/functions/fnc_isInjured.sqf +++ b/addons/medical/functions/fnc_isInjured.sqf @@ -1,13 +1,13 @@ #include "..\script_component.hpp" /* * Author: DartRuffian - * Checks if a unit needs treatment. + * Checks if a unit is injured. * * Arguments: * 0: Unit * * Return Value: - * Does unit need treatment + * Is unit injured * * Example: * player call ace_medical_fnc_isInjured @@ -18,10 +18,8 @@ params [["_unit", objNull, [objNull]]]; if (!alive _unit) exitWith { false }; -if (!local _unit) exitWith { ERROR_1("unit [%1] is not local",_unit); }; private _fractures = GET_FRACTURES(_unit); ((_fractures select HITPOINT_INDEX_LARM) == 1) || {(_fractures select HITPOINT_INDEX_RARM) == 1} || -{GET_BLOOD_VOLUME(_unit) != DEFAULT_BLOOD_VOLUME} || {_unit call EFUNC(medical_ai,isInjured)} From 25012543f68aec8523c3793f8243d0a9afeaca37 Mon Sep 17 00:00:00 2001 From: DartRuffian Date: Fri, 13 Dec 2024 11:51:01 -0600 Subject: [PATCH 15/18] Add wrapper for isInStablecondition --- addons/medical/XEH_PREP.hpp | 1 + .../functions/fnc_isInStableCondition.sqf | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 addons/medical/functions/fnc_isInStableCondition.sqf diff --git a/addons/medical/XEH_PREP.hpp b/addons/medical/XEH_PREP.hpp index ec28688c1e1..d189305076c 100644 --- a/addons/medical/XEH_PREP.hpp +++ b/addons/medical/XEH_PREP.hpp @@ -4,5 +4,6 @@ PREP(deserializeState); PREP(fullHeal); PREP(getBloodLoss); PREP(isInjured); +PREP(isInStableCondition); PREP(serializeState); PREP(setUnconscious); diff --git a/addons/medical/functions/fnc_isInStableCondition.sqf b/addons/medical/functions/fnc_isInStableCondition.sqf new file mode 100644 index 00000000000..91f907cc923 --- /dev/null +++ b/addons/medical/functions/fnc_isInStableCondition.sqf @@ -0,0 +1,22 @@ +#include "..\script_component.hpp" +/* + * Author: DartRuffian + * Checks if a unit is in stable condition. + * + * Arguments: + * 0: Unit + * + * Return Value: + * Is unit stable + * + * Example: + * player call ace_medical_fnc_isInStableCondition + * + * Public: Yes + */ + +params [["_unit", objNull, [objNull]]]; + +if (!alive _unit) exitWith { false }; + +_unit call EFUNC(medical_status,isInStableCondition) From 3c58ee074127b754304d16403b5395e1bcbc0a56 Mon Sep 17 00:00:00 2001 From: Dart <59131299+DartRuffian@users.noreply.github.com> Date: Sun, 15 Dec 2024 15:22:20 -0600 Subject: [PATCH 16/18] Update header Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> --- addons/medical/functions/fnc_isInjured.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_isInjured.sqf b/addons/medical/functions/fnc_isInjured.sqf index 1573be01980..25a3aad9518 100644 --- a/addons/medical/functions/fnc_isInjured.sqf +++ b/addons/medical/functions/fnc_isInjured.sqf @@ -1,7 +1,8 @@ #include "..\script_component.hpp" /* * Author: DartRuffian - * Checks if a unit is injured. + * Checks if a unit is injured (bleeding, fractured limbs, low blood, etc). + * Unit may still require further treatment even if false. * * Arguments: * 0: Unit From 90502bf660e2df2bab8e3f896b60365f8543241a Mon Sep 17 00:00:00 2001 From: Dart <59131299+DartRuffian@users.noreply.github.com> Date: Sun, 15 Dec 2024 15:22:42 -0600 Subject: [PATCH 17/18] Update header Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> --- addons/medical/functions/fnc_isInStableCondition.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_isInStableCondition.sqf b/addons/medical/functions/fnc_isInStableCondition.sqf index 91f907cc923..d30e7d09854 100644 --- a/addons/medical/functions/fnc_isInStableCondition.sqf +++ b/addons/medical/functions/fnc_isInStableCondition.sqf @@ -1,7 +1,8 @@ #include "..\script_component.hpp" /* * Author: DartRuffian - * Checks if a unit is in stable condition. + * Checks if a unit is in stable condition (stable vitals, awake, and not bleeding). + * Unit shouldn't require further treatment if true and not injured. * * Arguments: * 0: Unit From cbb5d292e3f741af0f6b90928af6b2a00b9678be Mon Sep 17 00:00:00 2001 From: Dart <59131299+DartRuffian@users.noreply.github.com> Date: Sun, 15 Dec 2024 15:24:15 -0600 Subject: [PATCH 18/18] Return -1 for remote units --- addons/medical/functions/fnc_getBloodLoss.sqf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_getBloodLoss.sqf b/addons/medical/functions/fnc_getBloodLoss.sqf index 5fc5665d8e3..427f9b2fda8 100644 --- a/addons/medical/functions/fnc_getBloodLoss.sqf +++ b/addons/medical/functions/fnc_getBloodLoss.sqf @@ -17,6 +17,9 @@ params [["_unit", objNull, [objNull]]]; -if (!local _unit) exitWith { ERROR_1("unit [%1] is not local",_unit) }; +if (!local _unit) exitWith { + ERROR_1("unit [%1] is not local",_unit); + -1 +}; GET_BLOOD_LOSS(_unit)