From 8cf73bde88802d0ffc16327c51240e25c12e83d8 Mon Sep 17 00:00:00 2001 From: Mike-MF Date: Fri, 25 Oct 2024 04:48:40 +0100 Subject: [PATCH 1/3] Medical - Unconscious Effects --- addons/medical/XEH_PREP.hpp | 1 + addons/medical/XEH_postInit.sqf | 20 ++++++++++ addons/medical/XEH_preInit.sqf | 4 ++ addons/medical/config.cpp | 8 +++- .../medical/functions/fnc_unconsciousFX.sqf | 38 +++++++++++++++++++ addons/medical/initSettings.inc.sqf | 31 ++++++++++++++- addons/medical/script_component.hpp | 3 ++ addons/medical/stringtable.xml | 18 +++++++++ 8 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 addons/medical/XEH_PREP.hpp create mode 100644 addons/medical/functions/fnc_unconsciousFX.sqf diff --git a/addons/medical/XEH_PREP.hpp b/addons/medical/XEH_PREP.hpp new file mode 100644 index 00000000..af24c01e --- /dev/null +++ b/addons/medical/XEH_PREP.hpp @@ -0,0 +1 @@ +PREP(unconsciousFX); diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index bf995d92..b3ab699d 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -48,3 +48,23 @@ }; }, _unit, 1] call CBA_fnc_waitAndExecute; }] call CBA_fnc_addEventHandler; + +// Unconscious Moaning +if (isServer) then { + ["ace_unconscious", { + params ["_unit", "_state"]; + + if !(GVAR(unconsciousFXEnabled)) exitWith {}; + + if (isPlayer _unit && _state) then { + // Knock out sound + private _knockOutNoise = selectRandom KO_NOISES; + [QEGVAR(mission,say3D), [_unit, _knockOutNoise]] call CBA_fnc_globalEvent; + + // Local PFH for periodic groaning + [QGVAR(unconsciousFX), [], _unit] call CBA_fnc_targetEvent; + }; + }] call CBA_fnc_addEventHandler; +}; + +[QGVAR(unconsciousFx), LINKFUNC(unconsciousFX)] call CBA_fnc_addEventHandler; diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index 7c7b7646..89477353 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -2,6 +2,10 @@ ADDON = false; +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + #include "initSettings.inc.sqf" ADDON = true; diff --git a/addons/medical/config.cpp b/addons/medical/config.cpp index c39a7367..bd3f0a94 100644 --- a/addons/medical/config.cpp +++ b/addons/medical/config.cpp @@ -6,9 +6,13 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"tac_main", "ace_medical_engine"}; + requiredAddons[] = { + "tac_main", + "tac_mission", + "ace_medical_engine" + }; author = ECSTRING(main,Author); - authors[] = {"Jonpas"}; + authors[] = {"Jonpas", "Mike"}; url = ECSTRING(main,URL); VERSION_CONFIG; }; diff --git a/addons/medical/functions/fnc_unconsciousFX.sqf b/addons/medical/functions/fnc_unconsciousFX.sqf new file mode 100644 index 00000000..8d0fbd27 --- /dev/null +++ b/addons/medical/functions/fnc_unconsciousFX.sqf @@ -0,0 +1,38 @@ +#include "..\script_component.hpp" +/* + * Author: Mike + * Handles noises while unconscious + * + * Called locally per player via target event + * + * Arguments + * None + * + * Return Value: + * None + * + * Example: + * [] call tac_medical_fnc_unconsciousFX +*/ + +[{ + params ["_args", "_handle"]; + _args params [["_firstIteration", true]]; + + // If woken up or died end PFH. + if !(ace_player getVariable ["ACE_isUnconscious", false]) exitWith { + _handle call CBA_fnc_removePerFrameHandler; + }; + + // Don't want the groaning to happen instantly. + if (_firstIteration) exitWith { + _args set [0, false]; + }; + + // 50% chance of making noises, requires a heart rate above CPR/Cardiac Arrest + private _heartRate = ace_player getVariable ["ace_medical_heartRate", 80]; + if (random 1 > GVAR(unconsciousFXChance) && _heartRate > 40) then { + private _moan = selectRandom UNCONSCIOUS_NOISES; + [QEGVAR(mission,say3D), [ace_player, _moan]] call CBA_fnc_globalEvent; + }; +}, GVAR(unconsciousFXTimer)] call CBA_fnc_addPerFrameHandler; diff --git a/addons/medical/initSettings.inc.sqf b/addons/medical/initSettings.inc.sqf index 721ad054..046f7368 100644 --- a/addons/medical/initSettings.inc.sqf +++ b/addons/medical/initSettings.inc.sqf @@ -1,8 +1,37 @@ +private _category = format ["TAC %1", QUOTE(COMPONENT_BEAUTIFIED)]; + [ QGVAR(fatalInjuriesCardiacArrestTimeCoefficient), "SLIDER", [LSTRING(FatalInjuriesCardiacArrestTimeCoefficient_DisplayName), LSTRING(FatalInjuriesCardiacArrestTimeCoefficient_Description)], - format ["TAC %1", QUOTE(COMPONENT_BEAUTIFIED)], + _category, [0.01, 1, 0.2, 2], true // isGlobal ] call CBA_fnc_addSetting; + +[ + QGVAR(unconsciousFXEnabled), + "CHECKBOX", + [LSTRING(UnconsciousFX_DisplayName), LSTRING(UnconsciousFX_Description)], + _category, + true, + 1 +] call CBA_fnc_addSetting; + +[ + QGVAR(unconsciousFXChance), + "SLIDER", + [LSTRING(UnconsciousFXChance_DisplayName), LSTRING(UnconsciousFXChance_Description)], + _category, + [0, 1, 0.5, 1, true], + 1 +] call CBA_fnc_addSetting; + +[ + QGVAR(unconsciousFXTimer), + "SLIDER", + [LSTRING(UnconsciousFXTimer_DisplayName), LSTRING(UnconsciousFXTimer_Description)], + _category, + [5, 60, 30, 1, false], + 1 +] call CBA_fnc_addSetting; diff --git a/addons/medical/script_component.hpp b/addons/medical/script_component.hpp index a08a9106..1f39b9a7 100644 --- a/addons/medical/script_component.hpp +++ b/addons/medical/script_component.hpp @@ -15,3 +15,6 @@ #endif #include "\x\tac\addons\main\script_macros.hpp" + +#define KO_NOISES ["ace_fire_scream_12", "ACE_hit_Male05ENG_high_3", "ACE_hit_Male05ENG_high_4", "ACE_hit_Male05ENG_mid_4", "ACE_moan_Male06ENG_high_8"] +#define UNCONSCIOUS_NOISES ["ace_fire_scream_8", "ACE_moan_Male07ENG_high_2", "ACE_moan_Male07ENG_high_4", "ACE_moan_Male09ENG_high_1", "ACE_moan_Male09ENG_high_2", "ACE_moan_Male09ENG_high_3", "ACE_moan_Male09ENG_high_4"] diff --git a/addons/medical/stringtable.xml b/addons/medical/stringtable.xml index d07195a5..a09fdcea 100644 --- a/addons/medical/stringtable.xml +++ b/addons/medical/stringtable.xml @@ -7,5 +7,23 @@ Coefficient for controlling the Cardiac Arrest Time on fatal injuries when 'Fatal Injuries' is NOT 'Always'. + + Unconscious Effect Sounds + + + Enabled groaning sounds for unconscious players with a heart rate. + + + Unconscious Effect Sound Chance + + + The chance of unconscious sounds playing each check. + + + Unconscious Effect Timer + + + Time interval for checking if the sound effect should play + From b905b816c55a147c367baf8142b68eac864a511a Mon Sep 17 00:00:00 2001 From: Mike-MF Date: Fri, 25 Oct 2024 04:53:31 +0100 Subject: [PATCH 2/3] ACE requiredAddons --- addons/medical/config.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/medical/config.cpp b/addons/medical/config.cpp index bd3f0a94..042bbd5b 100644 --- a/addons/medical/config.cpp +++ b/addons/medical/config.cpp @@ -9,7 +9,9 @@ class CfgPatches { requiredAddons[] = { "tac_main", "tac_mission", - "ace_medical_engine" + "ace_fire", + "ace_medical_engine", + "ace_medical_feedback" }; author = ECSTRING(main,Author); authors[] = {"Jonpas", "Mike"}; From 61dd4327c03c27b9254359ab6374d02cb8f19056 Mon Sep 17 00:00:00 2001 From: Mike-MF Date: Fri, 25 Oct 2024 07:29:38 +0100 Subject: [PATCH 3/3] Sort stringtable --- addons/medical/stringtable.xml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/addons/medical/stringtable.xml b/addons/medical/stringtable.xml index a09fdcea..c487ca33 100644 --- a/addons/medical/stringtable.xml +++ b/addons/medical/stringtable.xml @@ -1,29 +1,29 @@ - - Fatal Injuries Cardiac Arrest Time Coefficient - Coefficient for controlling the Cardiac Arrest Time on fatal injuries when 'Fatal Injuries' is NOT 'Always'. - - Unconscious Effect Sounds + + Fatal Injuries Cardiac Arrest Time Coefficient - - Enabled groaning sounds for unconscious players with a heart rate. + + The chance of unconscious sounds playing each check. Unconscious Effect Sound Chance - - The chance of unconscious sounds playing each check. + + Time interval for checking if the sound effect should play Unconscious Effect Timer - - Time interval for checking if the sound effect should play + + Enabled groaning sounds for unconscious players with a heart rate. + + + Unconscious Effect Sounds