From 1a2487d61fe57f05719bcc4a068beb49b7c2f7ce Mon Sep 17 00:00:00 2001 From: Whigital Date: Sat, 22 Feb 2020 21:24:47 +0100 Subject: [PATCH] Medical Feedback - Set volume and radio usage based current unit (#7529) --- addons/common/functions/fnc_setVolume.sqf | 26 +++++++++++---------- addons/medical_feedback/XEH_postInit.sqf | 28 +++++------------------ 2 files changed, 20 insertions(+), 34 deletions(-) diff --git a/addons/common/functions/fnc_setVolume.sqf b/addons/common/functions/fnc_setVolume.sqf index 0ab00e26bec..01de0b2802c 100644 --- a/addons/common/functions/fnc_setVolume.sqf +++ b/addons/common/functions/fnc_setVolume.sqf @@ -17,36 +17,38 @@ * Note: Uses player */ -#define MUTED_LEVEL 0.2 +#define MUTED_LEVEL 0.2 #define NORMAL_LEVEL 1 -#define NO_SOUND 0 +#define NO_SOUND 0 -params [["_setVolume", false]]; +params [ + ["_setVolume", false], + ["_unit", player] +]; if (_setVolume) then { // Vanilla Game 2 fadeSound NORMAL_LEVEL; // TFAR - player setVariable ["tf_voiceVolume", NORMAL_LEVEL, true]; - player setVariable ["tf_globalVolume", NORMAL_LEVEL]; - player setVariable ["tf_unable_to_use_radio", false]; + _unit setVariable ["tf_voiceVolume", NORMAL_LEVEL, true]; + _unit setVariable ["tf_globalVolume", NORMAL_LEVEL]; + _unit setVariable ["tf_unable_to_use_radio", false]; // ACRE2 if (!isNil "acre_api_fnc_setGlobalVolume") then { [NORMAL_LEVEL^0.33] call acre_api_fnc_setGlobalVolume; }; - player setVariable ["acre_sys_core_isDisabled", false, true]; + _unit setVariable ["acre_sys_core_isDisabled", false, true]; } else { // Vanilla Game 2 fadeSound MUTED_LEVEL; // TFAR - player setVariable ["tf_voiceVolume", NO_SOUND, true]; - player setVariable ["tf_globalVolume", MUTED_LEVEL]; - player setVariable ["tf_unable_to_use_radio", true]; + _unit setVariable ["tf_voiceVolume", NO_SOUND, true]; + _unit setVariable ["tf_globalVolume", MUTED_LEVEL]; + _unit setVariable ["tf_unable_to_use_radio", true]; // ACRE2 if (!isNil "acre_api_fnc_setGlobalVolume") then { [MUTED_LEVEL^0.33] call acre_api_fnc_setGlobalVolume; }; - player setVariable ["acre_sys_core_isDisabled", true, true]; - + _unit setVariable ["acre_sys_core_isDisabled", true, true]; }; diff --git a/addons/medical_feedback/XEH_postInit.sqf b/addons/medical_feedback/XEH_postInit.sqf index 2f18bc15833..2efae271d19 100644 --- a/addons/medical_feedback/XEH_postInit.sqf +++ b/addons/medical_feedback/XEH_postInit.sqf @@ -43,14 +43,7 @@ GVAR(bloodTickCounter) = 0; ACE_player switchCamera "INTERNAL"; }; - // Toggle unconscious player's ability to talk in radio addons - if (["task_force_radio"] call EFUNC(common,isModLoaded)) then { - _unit setVariable ["tf_voiceVolume", [1, 0] select _unconscious, true]; - _unit setVariable ["tf_unable_to_use_radio", _unconscious]; // Only used locally - }; - if (["acre_main"] call EFUNC(common,isModLoaded)) then { - _unit setVariable ["acre_sys_core_isDisabled", _unconscious, true]; - }; + [!_unconscious, _unit] call EFUNC(common,setVolume); // Greatly reduce player's hearing ability while unconscious (affects radio addons) [QUOTE(ADDON), VOL_UNCONSCIOUS, _unconscious] call EFUNC(common,setHearingCapability); @@ -64,13 +57,9 @@ GVAR(bloodTickCounter) = 0; params ["_unit"]; if (_unit != ACE_player) exitWith {}; - if (["task_force_radio"] call EFUNC(common,isModLoaded)) then { - _unit setVariable ["tf_voiceVolume", 1, true]; - _unit setVariable ["tf_unable_to_use_radio", false]; - }; - if (["acre_main"] call EFUNC(common,isModLoaded)) then { - _unit setVariable ["acre_sys_core_isDisabled", false, true]; - }; + // Players always able to hear for any systems that might run while dead (e.g. spectator) + [true, _unit] call EFUNC(common,setVolume); + [QUOTE(ADDON), 1, false] call EFUNC(common,setHearingCapability); }] call CBA_fnc_addEventHandler; @@ -79,13 +68,8 @@ GVAR(bloodTickCounter) = 0; params ["_new"]; private _status = IS_UNCONSCIOUS(_new); - if (["task_force_radio"] call EFUNC(common,isModLoaded)) then { - _new setVariable ["tf_voiceVolume", [1, 0] select _status, true]; - _new setVariable ["tf_unable_to_use_radio", _status]; - }; - if (["acre_main"] call EFUNC(common,isModLoaded)) then { - _new setVariable ["acre_sys_core_isDisabled", _status, true]; - }; + [!_status, _new] call EFUNC(common,setVolume); + [QUOTE(ADDON), VOL_UNCONSCIOUS, _status] call EFUNC(common,setHearingCapability); [true] call FUNC(handleEffects); ["unconscious", _status] call EFUNC(common,setDisableUserInputStatus);