From defc4aa06bb3a4359b6477d4336f97a7a6289409 Mon Sep 17 00:00:00 2001 From: LinkIsGrim <69561145+LinkIsGrim@users.noreply.github.com> Date: Sat, 5 Oct 2024 10:43:18 -0300 Subject: [PATCH 1/7] Medical - Add setting to use limb damage --- .../functions/fnc_determineIfFatal.sqf | 14 ++++++++++--- .../functions/fnc_handleIncapacitation.sqf | 2 +- addons/medical_damage/initSettings.inc.sqf | 20 ++++++++++++++++++- addons/medical_damage/stringtable.xml | 12 +++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/addons/medical_damage/functions/fnc_determineIfFatal.sqf b/addons/medical_damage/functions/fnc_determineIfFatal.sqf index 1e5c533e98b..eedbe395255 100644 --- a/addons/medical_damage/functions/fnc_determineIfFatal.sqf +++ b/addons/medical_damage/functions/fnc_determineIfFatal.sqf @@ -6,7 +6,7 @@ * Arguments: * 0: The Unit * 1: Part No - * 2: Damage Array - QGVAR(medical,bodyPartDamage) + * 2: Damage Array - QEGVAR(medical,bodyPartDamage) * 3: New Damage * * ReturnValue: @@ -20,7 +20,7 @@ params ["_unit", "_part", "_bodyPartDamage", "_woundDamage"]; -if (_part > 1) exitWith { false }; +if (_part > 1 && EGVAR(medical,useLimbDamage) == 0) exitWith { false }; scopeName "main"; @@ -46,6 +46,15 @@ if (EGVAR(medical,fatalDamageSource) in [1, 2]) then { _bodyPartDamage params ["_headDamage", "_bodyDamage"]; private _vitalDamage = ((_headDamage - _headThreshhold) max 0) + ((_bodyDamage - _bodyThreshhold) max 0); + + // Sum of trauma to the limbs can also be fatal (shock) but this should take much more damage at default (5x as much) + if ([false, !isPlayer _unit, true] select EGVAR(medical,useLimbDamage)) then { + private _limbThreshold = QEGVAR(medical,limbDamageThreshold) * _damageThreshold; + { + _vitalDamage = _vitalDamage + ((_x - _limbThreshold) max 0); + } forEach _bodyPartDamage select [2]; + }; + private _chanceFatal = 1 - exp -((_vitalDamage/FATAL_SUM_DAMAGE_WEIBULL_L)^FATAL_SUM_DAMAGE_WEIBULL_K); TRACE_3("",_bodyPartDamage,_vitalDamage,_chanceFatal); @@ -56,4 +65,3 @@ if (EGVAR(medical,fatalDamageSource) in [1, 2]) then { }; false - diff --git a/addons/medical_damage/functions/fnc_handleIncapacitation.sqf b/addons/medical_damage/functions/fnc_handleIncapacitation.sqf index b352564b45d..391d69c08bf 100644 --- a/addons/medical_damage/functions/fnc_handleIncapacitation.sqf +++ b/addons/medical_damage/functions/fnc_handleIncapacitation.sqf @@ -20,7 +20,7 @@ params ["_unit"]; private _painLevel = GET_PAIN_PERCEIVED(_unit); private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; -_bodyPartDamage params ["_headDamage", "_bodyDamage", "_leftArmDamage", "_rightArmDamage", "_leftLegDamage", "_rightLegDamage"]; +_bodyPartDamage params ["_headDamage", "_bodyDamage"]; // Exclude non penetrating body damage { diff --git a/addons/medical_damage/initSettings.inc.sqf b/addons/medical_damage/initSettings.inc.sqf index 229b086505c..54f5525cfb9 100644 --- a/addons/medical_damage/initSettings.inc.sqf +++ b/addons/medical_damage/initSettings.inc.sqf @@ -2,7 +2,7 @@ QEGVAR(medical,fatalDamageSource), "LIST", [LSTRING(fatalDamageSource_DisplayName), LSTRING(fatalDamageSource_Description)], - [ELSTRING(medical,Category)], + ELSTRING(medical,Category), [[0, 1, 2], [LSTRING(fatalDamageSource_vitalShotsOnly), LSTRING(fatalDamageSource_trauma), LSTRING(fatalDamageSource_both)], 2], true ] call CBA_fnc_addSetting; @@ -25,6 +25,24 @@ true ] call CBA_fnc_addSetting; +[ + QEGVAR(medical,useLimbDamage), + "LIST", + [LSTRING(useLimbDamage_DisplayName), LSTRING(useLimbDamage_Description)], + ELSTRING(medical,Category), + [[0, 1, 2], [ELSTRING(common,Never), ELSTRING(common,aiOnly), ELSTRING(common,playersAndAI)], 0], + true +] call CBA_fnc_addSetting; + +[ + QEGVAR(medical,limbDamageThreshold), + "SLIDER", + [LSTRING(limbDamageThreshold_DisplayName), LSTRING(limbDamageThreshold_Description)], + ELSTRING(medical,Category), + [0, 25, 5, 2], + true +] call CBA_fnc_addSetting; + [ QEGVAR(medical,painUnconsciousChance), "SLIDER", diff --git a/addons/medical_damage/stringtable.xml b/addons/medical_damage/stringtable.xml index fa4e1c4ae48..fc6691f0a33 100644 --- a/addons/medical_damage/stringtable.xml +++ b/addons/medical_damage/stringtable.xml @@ -843,5 +843,17 @@ 치명상으로 인해 사망할 확률을 정합니다. A chance de morrer para um ferimento fatal. + + Use Limb Damage + + + Controls whether limb damage is taken into account for fatality and unconsciousness calculations. + + + Limb Damage Threshold + + + Sets the amount of damage a limb can receive before going critical (leading to unconsciousness, or death if "Sum of Trauma" is enabled).\nDoes nothing if the "Use Limb Damage" setting is disabled. + From a880a57677e100adbb755b487d5c98dd97638a3b Mon Sep 17 00:00:00 2001 From: LinkIsGrim <69561145+LinkIsGrim@users.noreply.github.com> Date: Sat, 5 Oct 2024 10:53:47 -0300 Subject: [PATCH 2/7] fix translation keys --- addons/medical_damage/stringtable.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/medical_damage/stringtable.xml b/addons/medical_damage/stringtable.xml index fc6691f0a33..eba48529c3e 100644 --- a/addons/medical_damage/stringtable.xml +++ b/addons/medical_damage/stringtable.xml @@ -843,10 +843,10 @@ 치명상으로 인해 사망할 확률을 정합니다. A chance de morrer para um ferimento fatal. - + Use Limb Damage - + Controls whether limb damage is taken into account for fatality and unconsciousness calculations. From 0a2071d2524b2cfb3035bd703e708c6e69e02353 Mon Sep 17 00:00:00 2001 From: Grim <69561145+LinkIsGrim@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:16:11 -0300 Subject: [PATCH 3/7] Russian translation Co-authored-by: Smith --- addons/medical_damage/stringtable.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/medical_damage/stringtable.xml b/addons/medical_damage/stringtable.xml index eba48529c3e..dc141255b64 100644 --- a/addons/medical_damage/stringtable.xml +++ b/addons/medical_damage/stringtable.xml @@ -845,15 +845,19 @@ Use Limb Damage + Использовать урон конечностям Controls whether limb damage is taken into account for fatality and unconsciousness calculations. + Определяет, учитывается ли повреждение конечностей при расчете смертности и потери сознания. Limb Damage Threshold + Порог повреждения конечностей Sets the amount of damage a limb can receive before going critical (leading to unconsciousness, or death if "Sum of Trauma" is enabled).\nDoes nothing if the "Use Limb Damage" setting is disabled. + Устанавливает величину урона, который может получить конечность, прежде чем он станет критическим (приводит к потере сознания или смерти, если включена "Сумма травм").\nНичего не делает, если настройка "Использовать урон конечностям" отключена. From 134aa54967a0529e0315d2f87ea6044d9fea1a4d Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sat, 19 Oct 2024 12:10:24 +0200 Subject: [PATCH 4/7] Update fnc_determineIfFatal.sqf --- addons/medical_damage/functions/fnc_determineIfFatal.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical_damage/functions/fnc_determineIfFatal.sqf b/addons/medical_damage/functions/fnc_determineIfFatal.sqf index eedbe395255..c56763ef479 100644 --- a/addons/medical_damage/functions/fnc_determineIfFatal.sqf +++ b/addons/medical_damage/functions/fnc_determineIfFatal.sqf @@ -49,7 +49,7 @@ if (EGVAR(medical,fatalDamageSource) in [1, 2]) then { // Sum of trauma to the limbs can also be fatal (shock) but this should take much more damage at default (5x as much) if ([false, !isPlayer _unit, true] select EGVAR(medical,useLimbDamage)) then { - private _limbThreshold = QEGVAR(medical,limbDamageThreshold) * _damageThreshold; + private _limbThreshold = EGVAR(medical,limbDamageThreshold) * _damageThreshold; { _vitalDamage = _vitalDamage + ((_x - _limbThreshold) max 0); } forEach _bodyPartDamage select [2]; From 9dba37fa543b2b58a42dd0c7e80cc0ec6ac14c7c Mon Sep 17 00:00:00 2001 From: Grim <69561145+LinkIsGrim@users.noreply.github.com> Date: Sat, 2 Nov 2024 17:56:36 -0300 Subject: [PATCH 5/7] true -> 1 Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/medical_damage/initSettings.inc.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/medical_damage/initSettings.inc.sqf b/addons/medical_damage/initSettings.inc.sqf index 54f5525cfb9..c6d7f49e343 100644 --- a/addons/medical_damage/initSettings.inc.sqf +++ b/addons/medical_damage/initSettings.inc.sqf @@ -31,7 +31,7 @@ [LSTRING(useLimbDamage_DisplayName), LSTRING(useLimbDamage_Description)], ELSTRING(medical,Category), [[0, 1, 2], [ELSTRING(common,Never), ELSTRING(common,aiOnly), ELSTRING(common,playersAndAI)], 0], - true + 1 ] call CBA_fnc_addSetting; [ @@ -40,7 +40,7 @@ [LSTRING(limbDamageThreshold_DisplayName), LSTRING(limbDamageThreshold_Description)], ELSTRING(medical,Category), [0, 25, 5, 2], - true + 1 ] call CBA_fnc_addSetting; [ From 219d91ddb53eb65f8adefddb7652ddc074b82ddc Mon Sep 17 00:00:00 2001 From: LinkIsGrim <69561145+LinkIsGrim@users.noreply.github.com> Date: Sat, 2 Nov 2024 18:16:55 -0300 Subject: [PATCH 6/7] address some of the lazy bits --- addons/medical_damage/stringtable.xml | 4 ++-- .../medical_gui/functions/fnc_updateBodyImage.sqf | 14 ++++++++++++-- .../medical_gui/functions/fnc_updateInjuryList.sqf | 13 +++++++++++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/addons/medical_damage/stringtable.xml b/addons/medical_damage/stringtable.xml index dc141255b64..a1093ce6385 100644 --- a/addons/medical_damage/stringtable.xml +++ b/addons/medical_damage/stringtable.xml @@ -848,7 +848,7 @@ Использовать урон конечностям - Controls whether limb damage is taken into account for fatality and unconsciousness calculations. + Controls whether limb damage is taken into account for sum of trauma calculations. Определяет, учитывается ли повреждение конечностей при расчете смертности и потери сознания. @@ -856,7 +856,7 @@ Порог повреждения конечностей - Sets the amount of damage a limb can receive before going critical (leading to unconsciousness, or death if "Sum of Trauma" is enabled).\nDoes nothing if the "Use Limb Damage" setting is disabled. + Sets the amount of damage limbs can receive before going critical, leading to death. Must be over 0 for any effect.\nRequires the "Use Limb Damage" setting to be enabled and "Fatal Damage Source" to be set to "Sum of Trauma" or "Either".\nStacks multiplicatively with the overall unit Damage Threshold. Doesn't interact with fractures/limping at all. Устанавливает величину урона, который может получить конечность, прежде чем он станет критическим (приводит к потере сознания или смерти, если включена "Сумма травм").\nНичего не делает, если настройка "Использовать урон конечностям" отключена. diff --git a/addons/medical_gui/functions/fnc_updateBodyImage.sqf b/addons/medical_gui/functions/fnc_updateBodyImage.sqf index b8ee8ee240e..71b86449280 100644 --- a/addons/medical_gui/functions/fnc_updateBodyImage.sqf +++ b/addons/medical_gui/functions/fnc_updateBodyImage.sqf @@ -77,12 +77,22 @@ private _bodyPartBloodLoss = [0, 0, 0, 0, 0, 0]; [_bloodLoss] call FUNC(bloodLossToRGBA); } else { private _damage = _bodyPartDamage select _forEachIndex; + // _damageThreshold here indicates how close unit is to guaranteed death via sum of trauma, so use the same multipliers used in medical_damage/functions/fnc_determineIfFatal.sqf + // TODO: make multipliers for head and torso a macro in medical_engine/script_macros_medical.hpp switch (true) do { // torso damage threshold doesn't need scaling case (_forEachIndex > 3): { // legs: index 4 & 5 - _damageThreshold = LIMPING_DAMAGE_THRESHOLD * 4; + if (!EGVAR(medical,useLimbDamage) || EGVAR(medical,limbDamageThreshold) == 0) then { // Just indicate how close to the limping threshold we are + _damageThreshold = LIMPING_DAMAGE_THRESHOLD * 4; + } else { + _damageThreshold = _damageThreshold * EGVAR(medical,limbDamageThreshold); + }; }; case (_forEachIndex > 1): { // arms: index 2 & 3 - _damageThreshold = FRACTURE_DAMAGE_THRESHOLD * 4; + if (!EGVAR(medical,useLimbDamage) || EGVAR(medical,limbDamageThreshold) == 0) then { // Just indicate how close to the fracture threshold we are + _damageThreshold = FRACTURE_DAMAGE_THRESHOLD * 4; + } else { + _damageThreshold = _damageThreshold * EGVAR(medical,limbDamageThreshold); + }; }; case (_forEachIndex == 0): { // head: index 0 _damageThreshold = _damageThreshold * 1.25; diff --git a/addons/medical_gui/functions/fnc_updateInjuryList.sqf b/addons/medical_gui/functions/fnc_updateInjuryList.sqf index 3219eb025f5..f7a9eec1122 100644 --- a/addons/medical_gui/functions/fnc_updateInjuryList.sqf +++ b/addons/medical_gui/functions/fnc_updateInjuryList.sqf @@ -168,10 +168,18 @@ if (GVAR(showDamageEntry)) then { private _damageThreshold = GET_DAMAGE_THRESHOLD(_target); switch (true) do { case (_selectionN > 3): { // legs: index 4 & 5 - _damageThreshold = LIMPING_DAMAGE_THRESHOLD * 4; + if (!EGVAR(medical,useLimbDamage) || EGVAR(medical,limbDamageThreshold) == 0) then { // Just indicate how close to the limping threshold we are + _damageThreshold = LIMPING_DAMAGE_THRESHOLD * 4; + } else { + _damageThreshold = _damageThreshold * EGVAR(medical,limbDamageThreshold); + }; }; case (_selectionN > 1): { // arms: index 2 & 3 - _damageThreshold = FRACTURE_DAMAGE_THRESHOLD * 4; + if (!EGVAR(medical,useLimbDamage) || EGVAR(medical,limbDamageThreshold) == 0) then { // Just indicate how close to the fracture threshold we are + _damageThreshold = FRACTURE_DAMAGE_THRESHOLD * 4; + } else { + _damageThreshold = _damageThreshold * EGVAR(medical,limbDamageThreshold); + }; }; case (_selectionN == 0): { // head: index 0 _damageThreshold = _damageThreshold * 1.25; @@ -180,6 +188,7 @@ if (GVAR(showDamageEntry)) then { _damageThreshold = _damageThreshold * 1.5; }; }; + // _bodyPartDamage here should indicate how close unit is to guaranteed death via sum of trauma, so use the same multipliers used in medical_damage/functions/fnc_determineIfFatal.sqf _bodyPartDamage = (_bodyPartDamage / _damageThreshold) min 1; switch (true) do { case (_bodyPartDamage isEqualTo 1): { From af861a864059b998e485b1416f8f3c0060797d38 Mon Sep 17 00:00:00 2001 From: Grim <69561145+LinkIsGrim@users.noreply.github.com> Date: Sat, 2 Nov 2024 22:53:55 -0300 Subject: [PATCH 7/7] updated translations Co-authored-by: Smith --- addons/medical_damage/stringtable.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/medical_damage/stringtable.xml b/addons/medical_damage/stringtable.xml index a1093ce6385..f8f7e22e895 100644 --- a/addons/medical_damage/stringtable.xml +++ b/addons/medical_damage/stringtable.xml @@ -849,7 +849,7 @@ Controls whether limb damage is taken into account for sum of trauma calculations. - Определяет, учитывается ли повреждение конечностей при расчете смертности и потери сознания. + Определяет, учитывается ли повреждение конечностей при расчете совокупности травм. Limb Damage Threshold @@ -857,7 +857,7 @@ Sets the amount of damage limbs can receive before going critical, leading to death. Must be over 0 for any effect.\nRequires the "Use Limb Damage" setting to be enabled and "Fatal Damage Source" to be set to "Sum of Trauma" or "Either".\nStacks multiplicatively with the overall unit Damage Threshold. Doesn't interact with fractures/limping at all. - Устанавливает величину урона, который может получить конечность, прежде чем он станет критическим (приводит к потере сознания или смерти, если включена "Сумма травм").\nНичего не делает, если настройка "Использовать урон конечностям" отключена. + Устанавливает величину урона, который могут получить конечности, прежде чем урон станет критическим, что приведет к смерти. Для любого эффекта должно быть больше 0.\nТребуется, чтобы настройка "Использовать урон конечностям" была включена, а "Причина смертельного урона" была установлена на "Совокупность травмы" или "Оба".\nУмножается с общим порогом повреждения. Никак не взаимодействует с переломами или хроманием.