From bdeb347ea9782af8f5c88861648db1d1c0408698 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 20 Feb 2022 17:23:56 -0600 Subject: [PATCH] medical_damage - cleanup woundHandler naming (#8824) * medical_damage - cleanup woundHandler naming * woundsHandlerBase --- .../functions/fnc_handleWoundReceived.sqf | 6 +- .../medical_damage/ACE_Medical_Injuries.hpp | 2 +- addons/medical_damage/XEH_PREP.hpp | 3 +- addons/medical_damage/XEH_preInit.sqf | 9 -- .../functions/fnc_debug_explosiveTest.sqf | 2 +- .../functions/fnc_parseConfigForInjuries.sqf | 2 +- .../functions/fnc_woundsHandler.sqf | 141 ------------------ ...ndlerSQF.sqf => fnc_woundsHandlerBase.sqf} | 4 +- .../functions/fnc_woundsHandlerBurning.sqf | 3 +- .../fnc_woundsHandlerVehiclecrash.sqf | 1 + docs/wiki/framework/medical-framework.md | 6 +- 11 files changed, 15 insertions(+), 164 deletions(-) delete mode 100644 addons/medical_damage/functions/fnc_woundsHandler.sqf rename addons/medical_damage/functions/{fnc_woundsHandlerSQF.sqf => fnc_woundsHandlerBase.sqf} (99%) diff --git a/addons/medical_blood/functions/fnc_handleWoundReceived.sqf b/addons/medical_blood/functions/fnc_handleWoundReceived.sqf index 766c334d88..3b2b0d3e86 100644 --- a/addons/medical_blood/functions/fnc_handleWoundReceived.sqf +++ b/addons/medical_blood/functions/fnc_handleWoundReceived.sqf @@ -5,9 +5,9 @@ * * Arguments: * 0: Unit - * 1: Body Part (not used) - * 2: Damage - * 3: Shooter + * 1: Damage done to each body part + * 2: Shooter + * 3: Ammo classname or damage type * * Return Value: * None diff --git a/addons/medical_damage/ACE_Medical_Injuries.hpp b/addons/medical_damage/ACE_Medical_Injuries.hpp index 53f257db3d..f0f7d107d4 100644 --- a/addons/medical_damage/ACE_Medical_Injuries.hpp +++ b/addons/medical_damage/ACE_Medical_Injuries.hpp @@ -73,7 +73,7 @@ class ACE_Medical_Injuries { // each entry should be a SQF expression that returns a function // this can also be overridden for each damage type class woundHandlers { - ADDON = QFUNC(woundsHandlerActive); + ADDON = QFUNC(woundsHandlerBase); }; class bullet { diff --git a/addons/medical_damage/XEH_PREP.hpp b/addons/medical_damage/XEH_PREP.hpp index 5dd6441190..6df53fb309 100644 --- a/addons/medical_damage/XEH_PREP.hpp +++ b/addons/medical_damage/XEH_PREP.hpp @@ -6,7 +6,6 @@ PREP(interpolatePoints); PREP(parseConfigForInjuries); PREP(parseWoundHandlersCfg); PREP(woundReceived); -PREP(woundsHandler); +PREP(woundsHandlerBase); PREP(woundsHandlerBurning); -PREP(woundsHandlerSQF); PREP(woundsHandlerVehiclecrash); diff --git a/addons/medical_damage/XEH_preInit.sqf b/addons/medical_damage/XEH_preInit.sqf index 380e0c4b65..26445ad61a 100644 --- a/addons/medical_damage/XEH_preInit.sqf +++ b/addons/medical_damage/XEH_preInit.sqf @@ -8,15 +8,6 @@ PREP_RECOMPILE_END; #include "initSettings.sqf" -// decide which woundsHandler to use by whether the extension is present or not -// if ("ace_medical" callExtension "version" != "") then { - - // DFUNC(woundsHandlerActive) = LINKFUNC(woundsHandler); -// } else { - // INFO("Using woundsHandlerSQF"); - DFUNC(woundsHandlerActive) = LINKFUNC(woundsHandlerSQF); -// }; - call FUNC(parseConfigForInjuries); addMissionEventHandler ["Loaded",{ diff --git a/addons/medical_damage/functions/fnc_debug_explosiveTest.sqf b/addons/medical_damage/functions/fnc_debug_explosiveTest.sqf index 60b2e1d694..67f0a48d2d 100644 --- a/addons/medical_damage/functions/fnc_debug_explosiveTest.sqf +++ b/addons/medical_damage/functions/fnc_debug_explosiveTest.sqf @@ -57,7 +57,7 @@ if (_ammoClass != "") then { params ["_ammoClass", "_center"]; private _position = _center vectorAdd [0, 0, 5]; private _obj = _ammoClass createVehicle _position; - _object setVectorDirAndUp [[0, 0, -1], [0, 1, 0]]; + _obj setVectorDirAndUp [[0, 0, -1], [0, 1, 0]]; _obj setVelocity [0, 0, -20]; }, [_ammoClass, _center], _delay] call CBA_fnc_waitAndExecute; }; diff --git a/addons/medical_damage/functions/fnc_parseConfigForInjuries.sqf b/addons/medical_damage/functions/fnc_parseConfigForInjuries.sqf index 670fdebe64..cc76111b0c 100644 --- a/addons/medical_damage/functions/fnc_parseConfigForInjuries.sqf +++ b/addons/medical_damage/functions/fnc_parseConfigForInjuries.sqf @@ -114,7 +114,7 @@ TRACE_1("Found default wound handlers", count _defaultWoundHandlers); private _woundType = configName _x; if (_woundType == "woundHandlers") then {continue}; if (_woundType in GVAR(woundDetails)) then { - private _weighting = GET_ARRAY(_x >> "weighting",ARR_2([[0,1]])); + private _weighting = GET_ARRAY(_x >> "weighting",[[ARR_2(0,1)]]); private _dmgMulti = GET_NUMBER(_x >> "damageMultiplier", 1); private _bleedMulti = GET_NUMBER(_x >> "bleedingMultiplier", 1); private _sizeMulti = GET_NUMBER(_x >> "sizeMultiplier", 1); diff --git a/addons/medical_damage/functions/fnc_woundsHandler.sqf b/addons/medical_damage/functions/fnc_woundsHandler.sqf deleted file mode 100644 index 0356d91766..0000000000 --- a/addons/medical_damage/functions/fnc_woundsHandler.sqf +++ /dev/null @@ -1,141 +0,0 @@ -#include "script_component.hpp" -/* - * Author: Glowbal, commy2 - * Handling of the open wounds & injuries upon the handleDamage eventhandler. - * - * Arguments: - * 0: Unit That Was Hit - * 1: Name Of Body Part - * 2: Amount Of Damage - * 3: Type of the damage done - * - * Return Value: - * None - * - * Example: - * [player, "Body", 0.5, "bullet"] call ace_medical_damage_fnc_woundsHandler - * - * Public: No - */ - -WARNING("this function needs to be updated for changes to woundsHandlerSQF"); - -params ["_unit", "_bodyPart", "_damage", "_typeOfDamage"]; -TRACE_4("start",_unit,_bodyPart,_damage,_typeOfDamage); - -if (_typeOfDamage isEqualTo "") then { - _typeOfDamage = "unknown"; -}; - -if !(_typeOfDamage in GVAR(damageTypeDetails)) then { - _typeOfDamage = "unknown"; -}; - -// Administration for open wounds and ids -private _openWounds = GET_OPEN_WOUNDS(_unit); -private _woundID = _unit getVariable [QEGVAR(medical,lastUniqueWoundID), 1]; // Unique wound ids are not used anywhere: ToDo Remove from openWounds array - -TRACE_4("extension call",_bodyPart,_damage,_typeOfDamage,_woundID); -private _extensionOutput = "ace_medical" callExtension format ["HandleDamageWounds,%1,%2,%3,%4", _bodyPart, _damage, _typeOfDamage, _woundID]; -TRACE_1("",_extensionOutput); - -// these are default values and modified by _extensionOutput -(parseSimpleArray _extensionOutput) params ["_woundsCreated", "_painToAdd"]; - -// todo: Make the pain and bleeding calculations part of the extension again -private _woundDamage = _damage / ((count _woundsCreated) max 1); // If the damage creates multiple wounds -private _painLevel = 0; -private _critialDamage = false; -private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; -private _bodyPartVisParams = [_unit, false, false, false, false]; // params array for EFUNC(medical_engine,updateBodyPartVisuals); -{ - _x params ["", "_woundClassIDToAdd", "_bodyPartNToAdd", "", "_bleeding"]; - - _bodyPartDamage set [_bodyPartNToAdd, (_bodyPartDamage select _bodyPartNToAdd) + _woundDamage]; - _bodyPartVisParams set [[1,2,3,3,4,4] select _bodyPartNToAdd, true]; // Mark the body part index needs updating - - // The higher the nastiness likelihood the higher the change to get a painful and bloody wound - private _nastinessLikelihood = linearConversion [0, 20, _woundDamage, 0.5, 30, true]; - private _bleedingModifier = 0.25 + 8 * exp ((random [-4.5, -5, -6]) / _nastinessLikelihood); - private _painModifier = 0.05 + 2 * exp (-2 / _nastinessLikelihood); - - TRACE_3("",_nastinessLikelihood,_bleedingModifier,_painModifier); - - _bleeding = _bleeding * _bleedingModifier; - private _pain = (((GVAR(woundsData) select _woundClassIDToAdd) select 3) * _painModifier); - _painLevel = _painLevel + _pain; - - // wound category (minor [0..0.5], medium[0.5..1.0], large[1.0+]) - private _category = floor linearConversion [0, 1, _bleedingModifier, 0, 2, true]; - - _x set [4, _bleeding]; - _x set [5, _woundDamage]; - _x set [6, _category]; - - - if (_bodyPartNToAdd == 0 || {_bodyPartNToAdd == 1 && {_woundDamage > PENETRATION_THRESHOLD}}) then { - _critialDamage = true; - }; -#ifdef DEBUG_MODE_FULL - 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 - - // 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 - private _causeLimping = (GVAR(woundsData) select _woundClassIDToAdd) select 7; - if (_causeLimping == 1 && {_woundDamage > LIMPING_DAMAGE_THRESHOLD} && {_bodyPartNToAdd > 3}) then { - [_unit, true] call EFUNC(medical_engine,setLimping); - }; - - // if possible merge into existing wounds - private _createNewWound = true; - { - _x params ["", "_classID", "_bodyPartN", "_oldAmountOf", "_oldBleeding", "_oldDamage", "_oldCategory"]; - if (_woundClassIDToAdd == _classID && {_bodyPartNToAdd == _bodyPartN && {(_woundDamage < PENETRATION_THRESHOLD) isEqualTo (_oldDamage < PENETRATION_THRESHOLD)}}) then { - if (_oldCategory == _category) exitWith { - private _newAmountOf = _oldAmountOf + 1; - _x set [3, _newAmountOf]; - private _newBleeding = (_oldAmountOf * _oldBleeding + _bleeding) / _newAmountOf; - _x set [4, _newBleeding]; - private _newDamage = (_oldAmountOf * _oldDamage + _woundDamage) / _newAmountOf; - _x set [5, _newDamage]; - _createNewWound = false; - }; - }; - } forEach _openWounds; - - if (_createNewWound) then { - _openWounds pushBack _x; - }; -} forEach _woundsCreated; - -_unit setVariable [VAR_OPEN_WOUNDS, _openWounds, true]; -_unit setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true]; - -[_unit] call EFUNC(medical_status,updateWoundBloodLoss); - -_bodyPartVisParams call EFUNC(medical_engine,updateBodyPartVisuals); - -[QEGVAR(medical,injured), [_unit, _painLevel]] call CBA_fnc_localEvent; - -if (_critialDamage || {_painLevel > PAIN_UNCONSCIOUS}) then { - [_unit] call FUNC(handleIncapacitation); -}; - -TRACE_5("exit",_unit,_painLevel,GET_PAIN(_unit),GET_OPEN_WOUNDS(_unit),_woundsCreated); diff --git a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf b/addons/medical_damage/functions/fnc_woundsHandlerBase.sqf similarity index 99% rename from addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf rename to addons/medical_damage/functions/fnc_woundsHandlerBase.sqf index 6646fc5093..e0b0a2a32b 100644 --- a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandlerBase.sqf @@ -12,13 +12,13 @@ * None * * Example: - * [player, [[0.5, "Body", 1]], "bullet"] call ace_medical_damage_fnc_woundsHandlerSQF + * [player, [[0.5, "Body", 1]], "bullet"] call ace_medical_damage_fnc_woundsHandlerBase * * Public: No */ params ["_unit", "_allDamages", "_typeOfDamage"]; -TRACE_4("woundsHandlerSQF",_unit,_allDamages,_typeOfDamage); +TRACE_3("woundsHandlerBase",_unit,_allDamages,_typeOfDamage); if !(_typeOfDamage in GVAR(damageTypeDetails)) then { diff --git a/addons/medical_damage/functions/fnc_woundsHandlerBurning.sqf b/addons/medical_damage/functions/fnc_woundsHandlerBurning.sqf index e5b0196f94..c6ca70f768 100644 --- a/addons/medical_damage/functions/fnc_woundsHandlerBurning.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandlerBurning.sqf @@ -17,6 +17,7 @@ * Public: No */ params ["_unit", "_allDamages", "_typeOfDamage"]; +TRACE_3("woundsHandlerBurning",_unit,_allDamages,_typeOfDamage); #define FIRE_DAMAGE_INTERVAL 1 @@ -47,4 +48,4 @@ params ["_unit", "_allDamages", "_typeOfDamage"]; _unit setVariable [QGVAR(storedBurnDamage), _newDamage]; } forEach _allDamages; -[] //return, no further damage handling for this event \ No newline at end of file +[] //return, no further damage handling for this event diff --git a/addons/medical_damage/functions/fnc_woundsHandlerVehiclecrash.sqf b/addons/medical_damage/functions/fnc_woundsHandlerVehiclecrash.sqf index cb24cf19e5..6417fd2034 100644 --- a/addons/medical_damage/functions/fnc_woundsHandlerVehiclecrash.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandlerVehiclecrash.sqf @@ -17,6 +17,7 @@ * Public: No */ params ["_unit", "_allDamages", "_typeOfDamage"]; +TRACE_3("woundsHandlerVehicleCrash",_unit,_allDamages,_typeOfDamage); // randomise all hit selections private _newDamages = _allDamages apply { diff --git a/docs/wiki/framework/medical-framework.md b/docs/wiki/framework/medical-framework.md index 6aa80a0a62..91bb5a6c79 100644 --- a/docs/wiki/framework/medical-framework.md +++ b/docs/wiki/framework/medical-framework.md @@ -160,7 +160,7 @@ class ACE_Medical_Injuries { // each entry should be a SQF expression that returns a function // this can also be overridden for each damage type class woundHandlers { - ace_medical_damage = "ace_medical_damage_fnc_woundsHandlerActive"; + ace_medical_damage = "ace_medical_damage_fnc_woundsHandlerBase"; }; // each sub-class defines a valid damage type @@ -214,7 +214,7 @@ class ACE_Medical_Injuries { ## 4.4 Wound Handler Function Custom wound handlers should follow the same spec as the built-in handler: -`ace_medical_damage_fnc_woundsHandlerSQF` +`ace_medical_damage_fnc_woundsHandlerBase` | Arguments | Type | Optional (default value) ---| --------- | ---- | ------------------------ @@ -226,7 +226,7 @@ Custom wound handlers should follow the same spec as the built-in handler: The damage elements are sorted in descending order according to how much damage was dealt to each body part _before armor was taken into account_, but the actual damage values are _after armor_. ### Example -`[player, [[0.5, "Body", 1], [0.3, "Head", 0.6]], "grenade"] ace_medical_damage_fnc_woundsHandlerSQF` +`[player, [[0.5, "Body", 1], [0.3, "Head", 0.6]], "grenade"] ace_medical_damage_fnc_woundsHandlerBase` | Arguments | Explanation ---| --------- | -----------