Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Medical - Add setting to use limb damage for sum of trauma #10362

Merged
merged 8 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions addons/medical_damage/functions/fnc_determineIfFatal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Arguments:
* 0: The Unit <OBJECT>
* 1: Part No <NUMBER>
* 2: Damage Array - QGVAR(medical,bodyPartDamage) <ARRAY>
* 2: Damage Array - QEGVAR(medical,bodyPartDamage) <ARRAY>
* 3: New Damage <NUMBER>
*
* ReturnValue:
Expand All @@ -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";

Expand All @@ -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);

Expand All @@ -56,4 +65,3 @@ if (EGVAR(medical,fatalDamageSource) in [1, 2]) then {
};

false

Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
20 changes: 19 additions & 1 deletion addons/medical_damage/initSettings.inc.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
LinkIsGrim marked this conversation as resolved.
Show resolved Hide resolved
] call CBA_fnc_addSetting;

[
QEGVAR(medical,limbDamageThreshold),
"SLIDER",
[LSTRING(limbDamageThreshold_DisplayName), LSTRING(limbDamageThreshold_Description)],
ELSTRING(medical,Category),
[0, 25, 5, 2],
true
LinkIsGrim marked this conversation as resolved.
Show resolved Hide resolved
] call CBA_fnc_addSetting;

[
QEGVAR(medical,painUnconsciousChance),
"SLIDER",
Expand Down
12 changes: 12 additions & 0 deletions addons/medical_damage/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -843,5 +843,17 @@
<Korean>치명상으로 인해 사망할 확률을 정합니다.</Korean>
<Portuguese>A chance de morrer para um ferimento fatal.</Portuguese>
</Key>
<Key ID="STR_ACE_Medical_Damage_uselimbDamage_DisplayName">
<English>Use Limb Damage</English>
LinkIsGrim marked this conversation as resolved.
Show resolved Hide resolved
</Key>
<Key ID="STR_ACE_Medical_Damage_uselimbDamage_Description">
<English>Controls whether limb damage is taken into account for fatality and unconsciousness calculations.</English>
LinkIsGrim marked this conversation as resolved.
Show resolved Hide resolved
</Key>
<Key ID="STR_ACE_Medical_Damage_limbDamageThreshold_DisplayName">
<English>Limb Damage Threshold</English>
LinkIsGrim marked this conversation as resolved.
Show resolved Hide resolved
</Key>
<Key ID="STR_ACE_Medical_Damage_limbDamageThreshold_Description">
<English>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.</English>
LinkIsGrim marked this conversation as resolved.
Show resolved Hide resolved
</Key>
</Package>
</Project>