diff --git a/addons/medical_damage/functions/fnc_woundsHandler.sqf b/addons/medical_damage/functions/fnc_woundsHandler.sqf index cf6eb118ce..9b1d01d567 100644 --- a/addons/medical_damage/functions/fnc_woundsHandler.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandler.sqf @@ -71,12 +71,24 @@ private _bodyPartVisParams = [_unit, false, false, false, false]; // params arra _critialDamage = true; }; #ifdef DEBUG_MODE_FULL - systemChat format["%1, damage: %2, peneration: %3, bleeding: %4, pain: %5", _bodyPart, round(_woundDamage * 100) / 100, _woundDamage > PENETRATION_THRESHOLD, round(_bleeding * 1000) / 1000, round(_pain * 1000) / 1000]; + systemChat format["%1, damage: %2, peneration: %3, bleeding: %4, pain: %5", _bodyPart, _woundDamage toFixed 2, _woundDamage > PENETRATION_THRESHOLD, _bleeding toFixed 3, _pain toFixed 3]; #endif - if (_bodyPartNToAdd == 0 && {_woundDamage > LETHAL_HEAD_DAMAGE_THRESHOLD}) then { - TRACE_2("FatalInjury",_unit,_woundDamage); - [QEGVAR(medical,FatalInjury), _unit] call CBA_fnc_localEvent; + // Emulate damage to vital organs + switch (true) do { + // Fatal damage to the head is guaranteed death + case (_bodyPartNToAdd == 0 && {_woundDamage >= HEAD_DAMAGE_THRESHOLD}): { + TRACE_1("lethal headshot",_woundDamage toFixed 2); + [QEGVAR(medical,FatalInjury), _unit] call CBA_fnc_localEvent; + }; + // Fatal damage to torso has various results based on organ hit + case (_bodyPartNToAdd == 1 && {_woundDamage >= ORGAN_DAMAGE_THRESHOLD}): { + // Heart shot is lethal + if (random 1 < HEART_HIT_CHANCE) then { + TRACE_1("lethal heartshot",_woundDamage toFixed 2); + [QEGVAR(medical,FatalInjury), _unit] call CBA_fnc_localEvent; + }; + }; }; // todo `forceWalk` based on leg damage diff --git a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf index 84f4386e80..4fe030efc7 100644 --- a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf @@ -32,7 +32,7 @@ private _damageTypeInfo = [GVAR(allDamageTypesData) getVariable _typeOfDamage] p _damageTypeInfo params ["_thresholds", "_isSelectionSpecific", "_woundTypes"]; // It appears we are dealing with an unknown type of damage. -if (count _woundTypes == 0) then { +if (_woundTypes isEqualTo []) then { // grabbing the configuration for unknown damage type _damageTypeInfo = [GVAR(allDamageTypesData) getVariable "unknown"] param [0, [[], false, []]]; _woundTypes = _damageTypeInfo select 2; @@ -121,12 +121,24 @@ private _woundsCreated = []; _critialDamage = true; }; #ifdef DEBUG_MODE_FULL - systemChat format["%1, damage: %2, peneration: %3, bleeding: %4, pain: %5", _bodyPart, round(_woundDamage * 100) / 100, _woundDamage > PENETRATION_THRESHOLD, round(_bleeding * 1000) / 1000, round(_pain * 1000) / 1000]; + systemChat format["%1, damage: %2, peneration: %3, bleeding: %4, pain: %5", _bodyPart, _woundDamage toFixed 2, _woundDamage > PENETRATION_THRESHOLD, _bleeding toFixed 3, _pain toFixed 3]; #endif - if (_bodyPartNToAdd == 0 && {_woundDamage > LETHAL_HEAD_DAMAGE_THRESHOLD}) then { - TRACE_2("FatalInjury",_unit,_woundDamage); - [QEGVAR(medical,FatalInjury), _unit] call CBA_fnc_localEvent; + // Emulate damage to vital organs + switch (true) do { + // Fatal damage to the head is guaranteed death + case (_bodyPartNToAdd == 0 && {_woundDamage >= HEAD_DAMAGE_THRESHOLD}): { + TRACE_1("lethal headshot",_woundDamage toFixed 2); + [QEGVAR(medical,FatalInjury), _unit] call CBA_fnc_localEvent; + }; + // Fatal damage to torso has various results based on organ hit + case (_bodyPartNToAdd == 1 && {_woundDamage >= ORGAN_DAMAGE_THRESHOLD}): { + // Heart shot is lethal + if (random 1 < HEART_HIT_CHANCE) then { + TRACE_1("lethal heartshot",_woundDamage toFixed 2); + [QEGVAR(medical,FatalInjury), _unit] call CBA_fnc_localEvent; + }; + }; }; // todo `forceWalk` based on leg damage diff --git a/addons/medical_engine/script_macros_medical.hpp b/addons/medical_engine/script_macros_medical.hpp index c232531e7d..bc2c60830e 100644 --- a/addons/medical_engine/script_macros_medical.hpp +++ b/addons/medical_engine/script_macros_medical.hpp @@ -3,6 +3,14 @@ #define ALL_SELECTIONS ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"] #define ALL_HITPOINTS ["HitHead", "HitBody", "HitLeftArm", "HitRightArm", "HitLeftLeg", "HitRightLeg"] +// Damage threshold above which fatal organ damage can occur +#define HEAD_DAMAGE_THRESHOLD 1 +#define ORGAN_DAMAGE_THRESHOLD 0.6 + +// Chance to hit heart based on ratio of 70kg (approx. 70L) body to 70mL stroke volume of heart +// Assuming torso is 50% of the body volume (35L) +#define HEART_HIT_CHANCE 0.05 + #define MEDICAL_ACTION_DISTANCE 1.75 // scale received pain to 0-2 level to select type of scream @@ -53,8 +61,6 @@ // Chance to wake up when vitals are stable (checked once every SPONTANEOUS_WAKE_UP_INTERVAL seconds) #define SPONTANEOUS_WAKE_UP_INTERVAL 15 -#define LETHAL_HEAD_DAMAGE_THRESHOLD 1.0 - // Minimum leg damage required for limping #define LIMPING_DAMAGE_THRESHOLD 0.30