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..3bb97921 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -48,3 +48,24 @@ }; }, _unit, 1] call CBA_fnc_waitAndExecute; }] call CBA_fnc_addEventHandler; + +// Unconscious Moaning +if (isServer) then { + ["ace_unconscious", { + params ["_unit", "_state"]; + + if (GVAR(unconsciousFXChance) == 0) exitWith {}; + + if (isPlayer _unit && _state) then { + // Knock out sound + private _knockOutNoise = selectRandom KO_NOISES; + [QGVAR(say3D), [_unit, _knockOutNoise]] call CBA_fnc_globalEvent; + + // Local PFH for periodic groaning + [QGVAR(unconsciousFX), [], _unit] call CBA_fnc_targetEvent; + }; + }] call CBA_fnc_addEventHandler; +}; + +[QGVAR(say3D), {(_this select 0) say3D (_this select 1)}] 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..d4af9761 100644 --- a/addons/medical/config.cpp +++ b/addons/medical/config.cpp @@ -6,9 +6,14 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"tac_main", "ace_medical_engine"}; + requiredAddons[] = { + "tac_main", + "ace_fire", + "ace_medical_engine", + "ace_medical_feedback" + }; 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..864dbf27 --- /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; + [QGVAR(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..f018d0d6 100644 --- a/addons/medical/initSettings.inc.sqf +++ b/addons/medical/initSettings.inc.sqf @@ -1,8 +1,28 @@ +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(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..57d9d332 100644 --- a/addons/medical/stringtable.xml +++ b/addons/medical/stringtable.xml @@ -1,11 +1,23 @@ + + Coefficient for controlling the Cardiac Arrest Time on fatal injuries when 'Fatal Injuries' is NOT 'Always'. + Fatal Injuries Cardiac Arrest Time Coefficient - - Coefficient for controlling the Cardiac Arrest Time on fatal injuries when 'Fatal Injuries' is NOT 'Always'. + + The chance of unconscious sounds playing each check. + + + Unconscious Effect Sound Chance + + + Time interval for checking if the sound effect should play + + + Unconscious Effect Timer