ACE3/addons/medical_engine/script_macros_medical.hpp

176 lines
7.9 KiB
C++
Raw Normal View History

// #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS
#define ALL_BODY_PARTS ["head", "body", "leftarm", "rightarm", "leftleg", "rightleg"]
#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
// below 0.25: 0, from 0.25 to 0.5: 1, more than 0.5: 2
#define PAIN_TO_SCREAM(pain) (floor (4 * pain) min 2)
// scale received pain to 0-2 level to select type of scream
// below 0.33: 0, from 0.34 to 0.66: 1, more than 0.67: 2
#define PAIN_TO_MOAN(pain) (floor (3 * pain) min 2)
#define GET_NUMBER(config,default) (if (isNumber (config)) then {getNumber (config)} else {default})
#define GET_STRING(config,default) (if (isText (config)) then {getText (config)} else {default})
#define GET_ARRAY(config,default) (if (isArray (config)) then {getArray (config)} else {default})
2016-10-10 15:30:42 +00:00
2016-12-09 11:57:27 +00:00
#define DEFAULT_HEART_RATE 80
2018-05-23 09:52:47 +00:00
#define DEFAULT_PERIPH_RES 100
2016-12-09 11:57:27 +00:00
2016-10-10 15:30:42 +00:00
// --- blood
// 0.077 l/kg * 80kg = 6.16l
2016-10-10 15:30:42 +00:00
#define DEFAULT_BLOOD_VOLUME 6.0 // in liters
2016-12-05 20:34:20 +00:00
#define BLOOD_VOLUME_CLASS_1_HEMORRHAGE 6.000 // lost less than 15% blood, Class I Hemorrhage
#define BLOOD_VOLUME_CLASS_2_HEMORRHAGE 5.100 // lost more than 15% blood, Class II Hemorrhage
#define BLOOD_VOLUME_CLASS_3_HEMORRHAGE 4.200 // lost more than 30% blood, Class III Hemorrhage
#define BLOOD_VOLUME_CLASS_4_HEMORRHAGE 3.600 // lost more than 40% blood, Class IV Hemorrhage
#define BLOOD_VOLUME_FATAL 3.0 // Lost more than 50% blood, Unrecoverable
2016-10-11 17:44:20 +00:00
// IV Change per second calculation:
2016-12-05 20:34:20 +00:00
// 250 ml should take 60 seconds to fill. 250 ml / 60 s ~ 4.1667 ml/s.
#define IV_CHANGE_PER_SECOND 4.1667 // in milliliters per second
2016-10-12 19:59:32 +00:00
2016-12-05 20:34:20 +00:00
// Minimum amount of damage required for penetrating wounds (also minDamage for velocity wounds)
#define PENETRATION_THRESHOLD 0.35
2016-10-12 19:59:32 +00:00
2016-12-05 20:34:20 +00:00
// To be replaced by a proper blood pressure calculation
#define BLOOD_LOSS_KNOCK_OUT_THRESHOLD 0.5 // 50% of cardiac output
2016-10-20 11:46:28 +00:00
Rewrite Medical GUI (#6831) * Add a macro for the bloodloss scaling factor * Adjust bloodloss threshold for red icon * Remove bloodloss color scaling factor The issue is actually the other way round, the factor of 20 would instantly make bodyparts red on taking a wound. * Implemet 10 color steps provided by ShackTac This replaces the old method of colouring the interaction menu icons and body image selections with a new method that has 10 distinct color steps (matching across the icons and the body image). * Use macros for constants * Implement blue damage colouring This re-adds visualisation for colouring based on damage. The case where a limb has a tourniquet will hopefully be handled by an overlayed icon. * Tidy up file structure * Move patient information display to medical_ui * Make common colour conversion code into functions * Add tourniquet icon overlay to body image * Fix mispelling I forgot to commit * Update icon paths to new white cross icon * Clean mess after rebase * Add new medical menu gui * Add updating injury list and body image * Add updating treatment category buttons * Update onMenuClose function * Delete unused functions * Add action buttons and triage card to menu * Move medical menu PFH to separate function * Move setTriageStatus to treatment * Add triage select dropdown * Add toggle button action * Fix mouse moving randomly when opening * Add logs list update and remove unused functions * Hide tourniquet icons by default * Remove CfgInGameUI (already in feedback) * Update patient info display * Update triage card display * Add settings to control interact menu actions * Cleanup files/paths * Move triage status update to common function * Add icons for interact menu actions * Modify icon color for interact menu actions * Update canOpenMenu for new setting * Hide pain information for unconscious * Stringtable cleanup * Use switch for pain text * Change minor triage status to minimal * Fix injury list to use new stringtable entry names * Fix medical actions check when disabled * Skip distance check in same vehicle * More cleanup * Fix CI error * Requested changes * Fix INJURIES string * Fix include after comment block * Fix missing ; Co-Authored-By: mharis001 <34453221+mharis001@users.noreply.github.com>
2019-03-24 22:17:48 +00:00
// Used to color interaction icons and body image selections
#define BLOOD_LOSS_RED_THRESHOLD 0.5
#define BLOOD_LOSS_TOTAL_COLORS 10
#define DAMAGE_BLUE_THRESHOLD 0.8
#define DAMAGE_TOTAL_COLORS 10
2016-10-20 11:46:28 +00:00
// --- pain
2016-12-05 20:34:20 +00:00
#define PAIN_UNCONSCIOUS 0.5
2016-10-20 11:46:28 +00:00
// Pain fade out time (time it takes until pain is guaranteed to be completly gone)
#define PAIN_FADE_TIME 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)
#define PAIN_SUPPRESSION_FADE_TIME 1800
2016-12-05 20:34:20 +00:00
// Chance to wake up when vitals are stable (checked once every SPONTANEOUS_WAKE_UP_INTERVAL seconds)
#define SPONTANEOUS_WAKE_UP_INTERVAL 15
2016-12-08 10:38:43 +00:00
// Minimum leg damage required for limping
#define LIMPING_DAMAGE_THRESHOLD 0.30
// Minimum limb damage required for fracture
#define FRACTURE_DAMAGE_THRESHOLD 0.50
2016-12-08 10:38:43 +00:00
// Minimum body part damage required for blood effect on uniform
#define VISUAL_BODY_DAMAGE_THRESHOLD 0.35
2017-04-27 17:05:21 +00:00
// Empty wound data, used for some default return values
// [classID, bodypartIndex, amountOf, bloodloss, damage]
#define EMPTY_WOUND [-1, -1, 0, 0, 0]
// Base time to bandage each wound category
#define BANDAGE_TIME_S 4
#define BANDAGE_TIME_M 6
#define BANDAGE_TIME_L 8
#define BANDAGE_TIME_MOD_MEDIC -2
#define BANDAGE_TIME_MOD_SELF 4
#define DEFAULT_BANDAGE_REOPENING_CHANCE 0.1
#define DEFAULT_BANDAGE_REOPENING_MIN_DELAY 120
#define DEFAULT_BANDAGE_REOPENING_MAX_DELAY 200
#define DEFAULT_TOURNIQUET_VALUES [0,0,0,0,0,0]
Medical Treatment - Modernize and Cleanup (#6933) * Modernize and cleanup medical_treatment * One line for each old public function * Fix litterCleanupDelay name * Improve adjustment calcs / wound blood loss / medications fix func descriptions Calc wound blood loss on events reorder includes so scritpmacroMed has global effect trivial optimization for getCardiacOutput Fix var Fix wounds not reopening (nil _category) Fix surgical kit inherting canBandage conditional debug hitpoints Update ACE_Medical_Treatment_Actions.hpp Use woundBleeding for IS_BLEEDING macro rework medication vars comments Reset var in init / fullHeal Update addons/medical_treatment/functions/fnc_onMedicationUsage.sqf Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * Change wound data array Drop unique id and merge classId and category * Splinting and treatment and gui * Add arm fractures and aim effects * localizations and event * fix * fix merge for renamed files * Fixes and code review changes * Move medical logs clearing to treatment * More cleanup work * cleanup * Apply suggestions from code review Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * formating, rename bone images * Fix args for setDead call in actionPlaceInBodyBag * Apply suggestions from code review Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * disable calls to extension * Update fnc_onMedicationUsage.sqf * Medical - Skip unneeded setVars on initUnit (#6949) * Medical - Transfer state machine state on locality (#6950) * Medical - Transfer state machine state on locality * Fix feedback isUnconscious var * Exclude AI * Make UAV excludes consistant, formating * Update fnc_treatmentFullHealLocal.sqf * reset fractures on respawn * Fix merge * Add PAK time coefficient setting * Fix medication * Add ace_medical_replacementItems config array * checkItems performance improvement * Treatment - cap max animation speed (#6995) * Treatment - cap max animation speed and add lock to prevent AF from reseting anim * Update fnc_getBandageTime.sqf * Use local version of setAnimSpeedCoef * Revert "Use local version of setAnimSpeedCoef" This reverts commit 36c22a90473fd0670ab97f3a373e4ae08493ff52. * Move replacementItems compiling to preInit * Improve replacementItems compiling * Cleanup splint functions, use macros for fractures * Rename splintCondition to canSplint * Add cprCreatesPulse setting * Cleanup remaining functions * Capitalize stringtable entry names * getStitchTime function and fix treatment locations * Update addons/medical_treatment/functions/fnc_getHealTime.sqf Co-Authored-By: SilentSpike <silentspike100+Github@gmail.com>
2019-06-03 15:31:46 +00:00
#define DEFAULT_FRACTURE_VALUES [0,0,0,0,0,0]
Rewrite Medical GUI (#6831) * Add a macro for the bloodloss scaling factor * Adjust bloodloss threshold for red icon * Remove bloodloss color scaling factor The issue is actually the other way round, the factor of 20 would instantly make bodyparts red on taking a wound. * Implemet 10 color steps provided by ShackTac This replaces the old method of colouring the interaction menu icons and body image selections with a new method that has 10 distinct color steps (matching across the icons and the body image). * Use macros for constants * Implement blue damage colouring This re-adds visualisation for colouring based on damage. The case where a limb has a tourniquet will hopefully be handled by an overlayed icon. * Tidy up file structure * Move patient information display to medical_ui * Make common colour conversion code into functions * Add tourniquet icon overlay to body image * Fix mispelling I forgot to commit * Update icon paths to new white cross icon * Clean mess after rebase * Add new medical menu gui * Add updating injury list and body image * Add updating treatment category buttons * Update onMenuClose function * Delete unused functions * Add action buttons and triage card to menu * Move medical menu PFH to separate function * Move setTriageStatus to treatment * Add triage select dropdown * Add toggle button action * Fix mouse moving randomly when opening * Add logs list update and remove unused functions * Hide tourniquet icons by default * Remove CfgInGameUI (already in feedback) * Update patient info display * Update triage card display * Add settings to control interact menu actions * Cleanup files/paths * Move triage status update to common function * Add icons for interact menu actions * Modify icon color for interact menu actions * Update canOpenMenu for new setting * Hide pain information for unconscious * Stringtable cleanup * Use switch for pain text * Change minor triage status to minimal * Fix injury list to use new stringtable entry names * Fix medical actions check when disabled * Skip distance check in same vehicle * More cleanup * Fix CI error * Requested changes * Fix INJURIES string * Fix include after comment block * Fix missing ; Co-Authored-By: mharis001 <34453221+mharis001@users.noreply.github.com>
2019-03-24 22:17:48 +00:00
// Triage colors, for consistency across UIs and functions
#define TRIAGE_COLOR_NONE 0, 0, 0, 0.9
#define TRIAGE_COLOR_MINIMAL 0, 0.5, 0, 0.9
#define TRIAGE_COLOR_DELAYED 1, 0.84, 0, 0.9
#define TRIAGE_COLOR_IMMEDIATE 1, 0, 0, 0.9
#define TRIAGE_COLOR_DECEASED 0, 0, 0, 0.9
#define TRIAGE_TEXT_COLOR_NONE 1, 1, 1, 1
#define TRIAGE_TEXT_COLOR_MINIMAL 1, 1, 1, 1
#define TRIAGE_TEXT_COLOR_DELAYED 0, 0, 0, 1
#define TRIAGE_TEXT_COLOR_IMMEDIATE 1, 1, 1, 1
#define TRIAGE_TEXT_COLOR_DECEASED 1, 1, 1, 1
Medical Treatment - Modernize and Cleanup (#6933) * Modernize and cleanup medical_treatment * One line for each old public function * Fix litterCleanupDelay name * Improve adjustment calcs / wound blood loss / medications fix func descriptions Calc wound blood loss on events reorder includes so scritpmacroMed has global effect trivial optimization for getCardiacOutput Fix var Fix wounds not reopening (nil _category) Fix surgical kit inherting canBandage conditional debug hitpoints Update ACE_Medical_Treatment_Actions.hpp Use woundBleeding for IS_BLEEDING macro rework medication vars comments Reset var in init / fullHeal Update addons/medical_treatment/functions/fnc_onMedicationUsage.sqf Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * Change wound data array Drop unique id and merge classId and category * Splinting and treatment and gui * Add arm fractures and aim effects * localizations and event * fix * fix merge for renamed files * Fixes and code review changes * Move medical logs clearing to treatment * More cleanup work * cleanup * Apply suggestions from code review Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * formating, rename bone images * Fix args for setDead call in actionPlaceInBodyBag * Apply suggestions from code review Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * disable calls to extension * Update fnc_onMedicationUsage.sqf * Medical - Skip unneeded setVars on initUnit (#6949) * Medical - Transfer state machine state on locality (#6950) * Medical - Transfer state machine state on locality * Fix feedback isUnconscious var * Exclude AI * Make UAV excludes consistant, formating * Update fnc_treatmentFullHealLocal.sqf * reset fractures on respawn * Fix merge * Add PAK time coefficient setting * Fix medication * Add ace_medical_replacementItems config array * checkItems performance improvement * Treatment - cap max animation speed (#6995) * Treatment - cap max animation speed and add lock to prevent AF from reseting anim * Update fnc_getBandageTime.sqf * Use local version of setAnimSpeedCoef * Revert "Use local version of setAnimSpeedCoef" This reverts commit 36c22a90473fd0670ab97f3a373e4ae08493ff52. * Move replacementItems compiling to preInit * Improve replacementItems compiling * Cleanup splint functions, use macros for fractures * Rename splintCondition to canSplint * Add cprCreatesPulse setting * Cleanup remaining functions * Capitalize stringtable entry names * getStitchTime function and fix treatment locations * Update addons/medical_treatment/functions/fnc_getHealTime.sqf Co-Authored-By: SilentSpike <silentspike100+Github@gmail.com>
2019-06-03 15:31:46 +00:00
// Medical activity logs
#define MED_LOG_MAX_ENTRIES 8
#define MED_LOG_VARNAME(type) (format [QEGVAR(medical,log_%1), type])
// - Unit Variables ----------------------------------------------------
// These variables get stored in object space and used across components
// Defined here for easy consistency with GETVAR/SETVAR (also a list for reference)
2019-06-22 18:36:27 +00:00
#define VAR_BLOOD_PRESS QEGVAR(medical,bloodPressure)
#define VAR_BLOOD_VOL QEGVAR(medical,bloodVolume)
#define VAR_WOUND_BLEEDING QEGVAR(medical,woundBleeding)
#define VAR_CRDC_ARRST QEGVAR(medical,inCardiacArrest)
#define VAR_HEART_RATE QEGVAR(medical,heartRate)
#define VAR_PAIN QEGVAR(medical,pain)
#define VAR_PAIN_SUPP QEGVAR(medical,painSuppress)
#define VAR_PERIPH_RES QEGVAR(medical,peripheralResistance)
#define VAR_UNCON "ACE_isUnconscious"
#define VAR_OPEN_WOUNDS QEGVAR(medical,openWounds)
#define VAR_BANDAGED_WOUNDS QEGVAR(medical,bandagedWounds)
#define VAR_STITCHED_WOUNDS QEGVAR(medical,stitchedWounds)
// These variables track gradual adjustments (from medication, etc.)
2019-06-22 18:36:27 +00:00
#define VAR_MEDICATIONS QEGVAR(medical,medications)
// These variables track the current state of status values above
2019-06-22 18:36:27 +00:00
#define VAR_HEMORRHAGE QEGVAR(medical,hemorrhage)
#define VAR_IN_PAIN QEGVAR(medical,inPain)
#define VAR_TOURNIQUET QEGVAR(medical,tourniquets)
#define VAR_FRACTURES QEGVAR(medical,fractures)
// - Unit Functions ---------------------------------------------------
// Retrieval macros for common unit values
// Defined for easy consistency and speed
#define GET_SM_STATE(_unit) ([_unit, EGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState)
2019-06-22 18:36:27 +00:00
#define GET_BLOOD_VOLUME(unit) (unit getVariable [VAR_BLOOD_VOL, DEFAULT_BLOOD_VOLUME])
#define GET_WOUND_BLEEDING(unit) (unit getVariable [VAR_WOUND_BLEEDING, 0])
#define GET_HEART_RATE(unit) (unit getVariable [VAR_HEART_RATE, DEFAULT_HEART_RATE])
#define GET_HEMORRHAGE(unit) (unit getVariable [VAR_HEMORRHAGE, 0])
#define GET_PAIN(unit) (unit getVariable [VAR_PAIN, 0])
#define GET_PAIN_SUPPRESS(unit) (unit getVariable [VAR_PAIN_SUPP, 0])
#define GET_TOURNIQUETS(unit) (unit getVariable [VAR_TOURNIQUET, DEFAULT_TOURNIQUET_VALUES])
Medical Treatment - Modernize and Cleanup (#6933) * Modernize and cleanup medical_treatment * One line for each old public function * Fix litterCleanupDelay name * Improve adjustment calcs / wound blood loss / medications fix func descriptions Calc wound blood loss on events reorder includes so scritpmacroMed has global effect trivial optimization for getCardiacOutput Fix var Fix wounds not reopening (nil _category) Fix surgical kit inherting canBandage conditional debug hitpoints Update ACE_Medical_Treatment_Actions.hpp Use woundBleeding for IS_BLEEDING macro rework medication vars comments Reset var in init / fullHeal Update addons/medical_treatment/functions/fnc_onMedicationUsage.sqf Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * Change wound data array Drop unique id and merge classId and category * Splinting and treatment and gui * Add arm fractures and aim effects * localizations and event * fix * fix merge for renamed files * Fixes and code review changes * Move medical logs clearing to treatment * More cleanup work * cleanup * Apply suggestions from code review Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * formating, rename bone images * Fix args for setDead call in actionPlaceInBodyBag * Apply suggestions from code review Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * disable calls to extension * Update fnc_onMedicationUsage.sqf * Medical - Skip unneeded setVars on initUnit (#6949) * Medical - Transfer state machine state on locality (#6950) * Medical - Transfer state machine state on locality * Fix feedback isUnconscious var * Exclude AI * Make UAV excludes consistant, formating * Update fnc_treatmentFullHealLocal.sqf * reset fractures on respawn * Fix merge * Add PAK time coefficient setting * Fix medication * Add ace_medical_replacementItems config array * checkItems performance improvement * Treatment - cap max animation speed (#6995) * Treatment - cap max animation speed and add lock to prevent AF from reseting anim * Update fnc_getBandageTime.sqf * Use local version of setAnimSpeedCoef * Revert "Use local version of setAnimSpeedCoef" This reverts commit 36c22a90473fd0670ab97f3a373e4ae08493ff52. * Move replacementItems compiling to preInit * Improve replacementItems compiling * Cleanup splint functions, use macros for fractures * Rename splintCondition to canSplint * Add cprCreatesPulse setting * Cleanup remaining functions * Capitalize stringtable entry names * getStitchTime function and fix treatment locations * Update addons/medical_treatment/functions/fnc_getHealTime.sqf Co-Authored-By: SilentSpike <silentspike100+Github@gmail.com>
2019-06-03 15:31:46 +00:00
#define GET_FRACTURES(unit) (unit getVariable [VAR_FRACTURES, DEFAULT_FRACTURE_VALUES])
2019-06-22 18:36:27 +00:00
#define IN_CRDC_ARRST(unit) (unit getVariable [VAR_CRDC_ARRST, false])
#define IS_BLEEDING(unit) (GET_WOUND_BLEEDING(unit) > 0)
2019-06-22 18:36:27 +00:00
#define IS_IN_PAIN(unit) (unit getVariable [VAR_IN_PAIN, false])
#define IS_UNCONSCIOUS(unit) (unit getVariable [VAR_UNCON, false])
#define GET_OPEN_WOUNDS(unit) (unit getVariable [VAR_OPEN_WOUNDS, []])
#define GET_BANDAGED_WOUNDS(unit) (unit getVariable [VAR_BANDAGED_WOUNDS, []])
#define GET_STITCHED_WOUNDS(unit) (unit getVariable [VAR_STITCHED_WOUNDS, []])
// The following function calls are defined here just for consistency
#define GET_BLOOD_LOSS(unit) ([unit] call EFUNC(medical_status,getBloodLoss))
#define GET_BLOOD_PRESSURE(unit) ([unit] call EFUNC(medical_status,getBloodPressure))
// Derivative unit values commonly used
#define GET_PAIN_PERCEIVED(unit) (0 max (GET_PAIN(unit) - GET_PAIN_SUPPRESS(unit)) min 1)
#define HAS_TOURNIQUET_APPLIED_ON(unit,index) ((GET_TOURNIQUETS(unit) select index) > 0)
// Cache expiry values, in seconds
#define IN_MEDICAL_FACILITY_CACHE_EXPIRY 1
#define CAN_TREAT_CONDITION_CACHE_EXPIRY 2
// Ignore UAV/Drone AI Base Classes
#define IGNORE_BASE_UAVPILOTS "B_UAV_AI", "O_UAV_AI", "UAV_AI_base_F"