Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions addons/common/functions/fnc_setVolume.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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];
};
28 changes: 6 additions & 22 deletions addons/medical_feedback/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;

Expand All @@ -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);
Expand Down