Medical Feedback - Set volume and radio usage based current unit (#7529)

This commit is contained in:
Whigital
2020-02-22 21:24:47 +01:00
committed by GitHub
parent e1f6db8a69
commit 1a2487d61f
2 changed files with 20 additions and 34 deletions

View File

@ -17,36 +17,38 @@
* Note: Uses player * Note: Uses player
*/ */
#define MUTED_LEVEL 0.2 #define MUTED_LEVEL 0.2
#define NORMAL_LEVEL 1 #define NORMAL_LEVEL 1
#define NO_SOUND 0 #define NO_SOUND 0
params [["_setVolume", false]]; params [
["_setVolume", false],
["_unit", player]
];
if (_setVolume) then { if (_setVolume) then {
// Vanilla Game // Vanilla Game
2 fadeSound NORMAL_LEVEL; 2 fadeSound NORMAL_LEVEL;
// TFAR // TFAR
player setVariable ["tf_voiceVolume", NORMAL_LEVEL, true]; _unit setVariable ["tf_voiceVolume", NORMAL_LEVEL, true];
player setVariable ["tf_globalVolume", NORMAL_LEVEL]; _unit setVariable ["tf_globalVolume", NORMAL_LEVEL];
player setVariable ["tf_unable_to_use_radio", false]; _unit setVariable ["tf_unable_to_use_radio", false];
// ACRE2 // ACRE2
if (!isNil "acre_api_fnc_setGlobalVolume") then { [NORMAL_LEVEL^0.33] call acre_api_fnc_setGlobalVolume; }; 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 { } else {
// Vanilla Game // Vanilla Game
2 fadeSound MUTED_LEVEL; 2 fadeSound MUTED_LEVEL;
// TFAR // TFAR
player setVariable ["tf_voiceVolume", NO_SOUND, true]; _unit setVariable ["tf_voiceVolume", NO_SOUND, true];
player setVariable ["tf_globalVolume", MUTED_LEVEL]; _unit setVariable ["tf_globalVolume", MUTED_LEVEL];
player setVariable ["tf_unable_to_use_radio", true]; _unit setVariable ["tf_unable_to_use_radio", true];
// ACRE2 // ACRE2
if (!isNil "acre_api_fnc_setGlobalVolume") then { [MUTED_LEVEL^0.33] call acre_api_fnc_setGlobalVolume; }; 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];
}; };

View File

@ -43,14 +43,7 @@ GVAR(bloodTickCounter) = 0;
ACE_player switchCamera "INTERNAL"; ACE_player switchCamera "INTERNAL";
}; };
// Toggle unconscious player's ability to talk in radio addons [!_unconscious, _unit] call EFUNC(common,setVolume);
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];
};
// Greatly reduce player's hearing ability while unconscious (affects radio addons) // Greatly reduce player's hearing ability while unconscious (affects radio addons)
[QUOTE(ADDON), VOL_UNCONSCIOUS, _unconscious] call EFUNC(common,setHearingCapability); [QUOTE(ADDON), VOL_UNCONSCIOUS, _unconscious] call EFUNC(common,setHearingCapability);
@ -64,13 +57,9 @@ GVAR(bloodTickCounter) = 0;
params ["_unit"]; params ["_unit"];
if (_unit != ACE_player) exitWith {}; if (_unit != ACE_player) exitWith {};
if (["task_force_radio"] call EFUNC(common,isModLoaded)) then { // Players always able to hear for any systems that might run while dead (e.g. spectator)
_unit setVariable ["tf_voiceVolume", 1, true]; [true, _unit] call EFUNC(common,setVolume);
_unit setVariable ["tf_unable_to_use_radio", false];
};
if (["acre_main"] call EFUNC(common,isModLoaded)) then {
_unit setVariable ["acre_sys_core_isDisabled", false, true];
};
[QUOTE(ADDON), 1, false] call EFUNC(common,setHearingCapability); [QUOTE(ADDON), 1, false] call EFUNC(common,setHearingCapability);
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
@ -79,13 +68,8 @@ GVAR(bloodTickCounter) = 0;
params ["_new"]; params ["_new"];
private _status = IS_UNCONSCIOUS(_new); private _status = IS_UNCONSCIOUS(_new);
if (["task_force_radio"] call EFUNC(common,isModLoaded)) then { [!_status, _new] call EFUNC(common,setVolume);
_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];
};
[QUOTE(ADDON), VOL_UNCONSCIOUS, _status] call EFUNC(common,setHearingCapability); [QUOTE(ADDON), VOL_UNCONSCIOUS, _status] call EFUNC(common,setHearingCapability);
[true] call FUNC(handleEffects); [true] call FUNC(handleEffects);
["unconscious", _status] call EFUNC(common,setDisableUserInputStatus); ["unconscious", _status] call EFUNC(common,setDisableUserInputStatus);