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 - Make some constants variables #7236

Merged
merged 2 commits into from
Oct 20, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 1 addition & 4 deletions addons/medical_damage/functions/fnc_determineIfFatal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
* Public: No
*/

#define WEIBULL_K 6.5625
#define WEIBULL_L 0.704523

params ["_unit", "_part", "_bodyPartDamage", "_woundDamage"];

if (_part > 1) exitWith { false };
Expand Down Expand Up @@ -49,7 +46,7 @@ if (EGVAR(medical,fatalDamageSource) in [1, 2]) then {
_bodyPartDamage params ["_headDamage", "_bodyDamage"];

private _vitalDamage = ((_headDamage - _headThreshhold) max 0) + ((_bodyDamage - _bodyThreshhold) max 0);
private _chanceFatal = 1 - exp -((_vitalDamage/WEIBULL_L)^WEIBULL_K);
private _chanceFatal = 1 - exp -((_vitalDamage/FATAL_SUM_DAMAGE_WEIBULL_L)^FATAL_SUM_DAMAGE_WEIBULL_K);
TRACE_3("",_bodyPartDamage,_vitalDamage,_chanceFatal);

if (_chanceFatal > random 1) exitWith {
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
22 changes: 22 additions & 0 deletions addons/medical_engine/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

// Define "Constants" variables (both are macros defined in script_macros_medical.hpp, look there for actual variable names)
if (isNil QUOTE(HEAD_DAMAGE_THRESHOLD)) then {HEAD_DAMAGE_THRESHOLD = HEAD_DAMAGE_THRESHOLD_DEFAULT};
if (isNil QUOTE(ORGAN_DAMAGE_THRESHOLD)) then {ORGAN_DAMAGE_THRESHOLD = ORGAN_DAMAGE_THRESHOLD_DEFAULT};
if (isNil QUOTE(HEART_HIT_CHANCE)) then {HEART_HIT_CHANCE = HEART_HIT_CHANCE_DEFAULT};
if (isNil QUOTE(PENETRATION_THRESHOLD)) then {PENETRATION_THRESHOLD = PENETRATION_THRESHOLD_DEFAULT};
if (isNil QUOTE(BLOOD_LOSS_KNOCK_OUT_THRESHOLD)) then {BLOOD_LOSS_KNOCK_OUT_THRESHOLD = BLOOD_LOSS_KNOCK_OUT_THRESHOLD_DEFAULT};
if (isNil QUOTE(PAIN_UNCONSCIOUS)) then {PAIN_UNCONSCIOUS = PAIN_UNCONSCIOUS_DEFAULT};
if (isNil QUOTE(PAIN_FADE_TIME)) then {PAIN_FADE_TIME = PAIN_FADE_TIME_DEFAULT};
if (isNil QUOTE(LIMPING_DAMAGE_THRESHOLD)) then {LIMPING_DAMAGE_THRESHOLD = LIMPING_DAMAGE_THRESHOLD_DEFAULT};
if (isNil QUOTE(FRACTURE_DAMAGE_THRESHOLD)) then {FRACTURE_DAMAGE_THRESHOLD = FRACTURE_DAMAGE_THRESHOLD_DEFAULT};
// Derive the alternate fatal damage coefficents
if (isNil QUOTE(FATAL_SUM_DAMAGE_WEIBULL_K) || isNil QUOTE(FATAL_SUM_DAMAGE_WEIBULL_L)) then {
private _x1 = 0.5;
private _y1 = 0.1;
private _x2 = 0.8;
private _y2 = 0.9;
private _b1 = -ln (1-_y1);
private _b2 = -ln (1-_y2);
FATAL_SUM_DAMAGE_WEIBULL_K = ln(_b1/_b2) / ln(_x1/_x2);
FATAL_SUM_DAMAGE_WEIBULL_L = _x1 / _b1^(1/FATAL_SUM_DAMAGE_WEIBULL_K);
};

// Hack for #3168 (units in static weapons do not take any damage):
// Doing a manual pre-load with a small distance seems to fix the LOD problems
// with handle damage not returning full results.
Expand Down
30 changes: 21 additions & 9 deletions addons/medical_engine/script_macros_medical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@
#define HITPOINT_INDEX_RLEG 5

// Damage threshold above which fatal organ damage can occur
#define HEAD_DAMAGE_THRESHOLD 1
#define ORGAN_DAMAGE_THRESHOLD 0.6
#define HEAD_DAMAGE_THRESHOLD EGVAR(medical,const_headDamageThreshold)
#define HEAD_DAMAGE_THRESHOLD_DEFAULT 1
#define ORGAN_DAMAGE_THRESHOLD EGVAR(medical,const_organDamageThreshold)
#define ORGAN_DAMAGE_THRESHOLD_DEFAULT 0.6
// Consts for determineIfFatal: sum of damage (values are calcualted at runtime in preInit)
#define FATAL_SUM_DAMAGE_WEIBULL_K EGVAR(medical,const_fatalSumDamageWeibull_K)
#define FATAL_SUM_DAMAGE_WEIBULL_L EGVAR(medical,const_fatalSumDamageWeibull_L)

// 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 HEART_HIT_CHANCE EGVAR(medical,const_heartHitChance)
#define HEART_HIT_CHANCE_DEFAULT 0.05

#define MEDICAL_ACTION_DISTANCE 1.75

Expand Down Expand Up @@ -53,10 +59,12 @@
#define IV_CHANGE_PER_SECOND 4.1667 // in milliliters per second

// Minimum amount of damage required for penetrating wounds (also minDamage for velocity wounds)
#define PENETRATION_THRESHOLD 0.35
#define PENETRATION_THRESHOLD EGVAR(medical,const_penetrationThreshold)
#define PENETRATION_THRESHOLD_DEFAULT 0.35

// To be replaced by a proper blood pressure calculation
#define BLOOD_LOSS_KNOCK_OUT_THRESHOLD 0.5 // 50% of cardiac output
#define BLOOD_LOSS_KNOCK_OUT_THRESHOLD EGVAR(medical,const_bloodLossKnockOutThreshold)
#define BLOOD_LOSS_KNOCK_OUT_THRESHOLD_DEFAULT 0.5 // 50% of cardiac output

// Used to color interaction icons and body image selections
#define BLOOD_LOSS_RED_THRESHOLD 0.5
Expand All @@ -65,10 +73,12 @@
#define DAMAGE_TOTAL_COLORS 10

// --- pain
#define PAIN_UNCONSCIOUS 0.5
#define PAIN_UNCONSCIOUS EGVAR(medical,const_painUnconscious)
#define PAIN_UNCONSCIOUS_DEFAULT 0.5

// Pain fade out time (time it takes until pain is guaranteed to be completly gone)
#define PAIN_FADE_TIME 900
#define PAIN_FADE_TIME EGVAR(medical,const_painFadeTime)
#define PAIN_FADE_TIME_DEFAULT 900

// Only relevant when advanced medication is disabled
// Morphine pain suppression fade out time (time it takes until pain suppression is guaranteed to be completly gone)
Expand All @@ -78,10 +88,12 @@
#define SPONTANEOUS_WAKE_UP_INTERVAL 15

// Minimum leg damage required for limping
#define LIMPING_DAMAGE_THRESHOLD 0.30
#define LIMPING_DAMAGE_THRESHOLD EGVAR(medical,const_limpingDamageThreshold)
#define LIMPING_DAMAGE_THRESHOLD_DEFAULT 0.30

// Minimum limb damage required for fracture
#define FRACTURE_DAMAGE_THRESHOLD 0.50
#define FRACTURE_DAMAGE_THRESHOLD EGVAR(medical,const_fractureDamageThreshold)
#define FRACTURE_DAMAGE_THRESHOLD_DEFAULT 0.50

// Minimum body part damage required for blood effect on uniform
#define VISUAL_BODY_DAMAGE_THRESHOLD 0.35
Expand Down