Fish Key: quiet all but sound effects while fishing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-11-12 15:42:26 +00:00
parent 25e3aa4fec
commit 38e942ac1d
3 changed files with 59 additions and 6 deletions

View file

@ -34,6 +34,22 @@ local FISHING_CVARS = {
{ name = "ActionButtonUseKeyHeldSpell", value = 0, mode = "max" },
}
-- Quiet everything but sound effects so the splash stands out (/fish sound).
-- There is no per-sound volume, so other effects (spells, footsteps) still play.
local SOUND_CVARS = {
{ name = "Sound_EnableMusic", value = 0, mode = "max" },
{ name = "Sound_EnableAmbience", value = 0, mode = "max" },
{ name = "Sound_EnableDialog", value = 0, mode = "max" },
{ name = "Sound_EnablePetSounds", value = 0, mode = "max" },
{ name = "Sound_EnableErrorSpeech", value = 0, mode = "max" },
{ name = "Sound_EnableSFX", value = 1, mode = "min" },
{ name = "Sound_SFXVolume", value = 1, mode = "min" },
-- Keep hearing it while another window has focus.
{ name = "Sound_EnableSoundWhenGameIsInBG", value = 1, mode = "min" },
-- Distant sounds are muffled; the bobber is 15-20 yards out.
{ name = "Sound_EnablePositionalLowPassFilter", value = 0, mode = "max" },
}
local owner = CreateFrame("Frame")
local overridden = false
local clearAfterCombat = false
@ -156,8 +172,8 @@ local function AnyKeyHeld()
return false
end
local function ChangeCVars()
for _, cvar in ipairs(FISHING_CVARS) do
local function ChangeList(list)
for _, cvar in ipairs(list) do
local current = tonumber(C_CVar.GetCVar(cvar.name))
local wrong = current and (cvar.mode == "min" and current < cvar.value or cvar.mode == "max" and current > cvar.value)
if wrong and not changedCVars[cvar.name] then
@ -171,6 +187,13 @@ local function ChangeCVars()
end
end
local function ChangeCVars()
ChangeList(FISHING_CVARS)
if FishKeyDB.sound then
ChangeList(SOUND_CVARS)
end
end
local function RestoreCVars()
for name in pairs(changedCVars) do
pcall(C_CVar.RemoveTempCVar, name)
@ -272,6 +295,9 @@ owner:SetScript("OnEvent", function(_, event, arg1, _, spellID)
if FishKeyDB.enabled == nil then
FishKeyDB.enabled = true
end
if FishKeyDB.sound == nil then
FishKeyDB.sound = true
end
end
elseif event == "UNIT_SPELLCAST_CHANNEL_START" then
if IsFishing(spellID) then
@ -318,11 +344,15 @@ SlashCmdList.FISHKEY = function(msg)
if not FishKeyDB.enabled then
Restore()
end
elseif msg == "sound on" or msg == "sound off" then
-- Takes effect from the next cast.
FishKeyDB.sound = msg == "sound on"
elseif msg ~= "" then
Print("/fish shows status, /fish on, /fish off")
Print("/fish shows status, /fish on|off, /fish sound on|off")
return
end
local keys = FishingKeys()
local where = #keys > 0 and table.concat(keys, ", ") or "no key bound to Fishing"
Print((FishKeyDB.enabled and "on" or "off") .. " (" .. where .. ")")
Print((FishKeyDB.enabled and "on" or "off") .. " (" .. where .. "), quiet sound "
.. (FishKeyDB.sound and "on" or "off"))
end