Fish Key: turn Interact Key on while fishing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-11-11 17:02:47 +00:00
parent 6ae2b47bb1
commit 2d2b31aaf8
3 changed files with 46 additions and 18 deletions

View file

@ -1,17 +1,25 @@
-- Fish Key: while Fishing channels, every key bound to Fishing is overridden to
-- "Interact with Target", so the same key clicks the bobber. The override is
-- "Interact with Target", so the same key clicks the bobber, and the Interact
-- Key setting is switched on for the cast. The override is
-- dropped the moment the channel ends (catch, miss, timeout, move) or combat
-- starts. Saved keybinds are never touched.
local FISHING_SPELL = 7620
-- Soft interact range while fishing. The default (about 10 yards) is shorter
-- than a cast, so the bobber would never become the interact target.
local FISHING_RANGE = 30
-- Settings raised while fishing, as temp CVars that are never saved, and
-- dropped again when the cast ends. Each is only raised if it is below the value.
local FISHING_CVARS = {
-- Interact Key: 0 off, 1 gamepad, 2 mouse and keyboard, 3 always.
{ name = "SoftTargetInteract", value = 3 },
-- The default (about 10 yards) is shorter than a cast, so the bobber
-- would never become the interact target.
{ name = "SoftTargetInteractRange", value = 30 },
}
local owner = CreateFrame("Frame")
local overridden = false
local clearAfterCombat = false
local raisedRange = false
local raisedCVars = {}
local warned = false
local function Print(msg)
DEFAULT_CHAT_FRAME:AddMessage("|cff4fc3f7Fish Key|r: " .. msg)
@ -96,18 +104,24 @@ local function FishingKeys()
return keys
end
local function RaiseRange()
local current = tonumber(C_CVar.GetCVar("SoftTargetInteractRange"))
if current and current < FISHING_RANGE then
C_CVar.SetTempCVar("SoftTargetInteractRange", tostring(FISHING_RANGE))
raisedRange = true
local function RaiseCVars()
for _, cvar in ipairs(FISHING_CVARS) do
local current = tonumber(C_CVar.GetCVar(cvar.name))
if current and current < cvar.value and not raisedCVars[cvar.name] then
if pcall(C_CVar.SetTempCVar, cvar.name, tostring(cvar.value)) then
raisedCVars[cvar.name] = true
elseif not warned then
warned = true
Print("couldn't change " .. cvar.name .. ", turn Interact Key on in Settings")
end
end
end
end
local function RestoreRange()
if raisedRange then
C_CVar.RemoveTempCVar("SoftTargetInteractRange")
raisedRange = false
local function RestoreCVars()
for name in pairs(raisedCVars) do
pcall(C_CVar.RemoveTempCVar, name)
raisedCVars[name] = nil
end
end
@ -123,7 +137,7 @@ local function Apply()
SetOverrideBinding(owner, true, key, "INTERACTTARGET")
end
overridden = true
RaiseRange()
RaiseCVars()
end
local function Restore()
@ -135,7 +149,7 @@ local function Restore()
overridden = false
end
end
RestoreRange()
RestoreCVars()
end
owner:RegisterEvent("ADDON_LOADED")

View file

@ -10,7 +10,7 @@ Seven small quality-of-life addons for WoW Forever (client 1.60.1, Interface 160
| Quest Shopping List | A panel beside the auction house listing items your quests still need, with cost against the quest's reward. Click to search. Requires [Auctionator](https://www.curseforge.com/wow/addons/auctionator). | `/qsl` |
| Dungeon Pre-Quest | Marks dungeon quests and quests whose chain leads to one, in the quest log, NPC quest lists and the quest offer window, with a purple "!" on the minimap for ones you can pick up now. | `/dpq <questID>` |
| Ship Routes | Draws every boat, zeppelin and airship route on the world map, coloured by faction. Hover a dock marker to see where it sails and light up its route, click it to open the destination's map. On a continent or zone map, a route that sails off it ends in a marker at the edge naming where it goes. | `/routes`, `/routes mine`, `/routes all` |
| Fish Key | While you fish, the key you cast Fishing with clicks the bobber instead. It casts Fishing again once the cast ends. Needs the Interact Key soft targeting setting on. | `/fish`, `/fish on`, `/fish off` |
| Fish Key | While you fish, the key you cast Fishing with clicks the bobber instead. It casts Fishing again once the cast ends. It also turns the Interact Key setting on for the cast, then off again. | `/fish`, `/fish on`, `/fish off` |
## Install

View file

@ -38,7 +38,7 @@ function ClearOverrideBindings() overrides = {} end
local inCombat = false
function InCombatLockdown() return inCombat end
local cvars = { SoftTargetInteractRange = "10" }
local cvars = { SoftTargetInteract = "0", SoftTargetInteractRange = "10" }
local temp = {}
C_CVar = {
GetCVar = function(n) return temp[n] or cvars[n] end,
@ -78,10 +78,12 @@ check(overrides["BUTTON4"] == "INTERACTTARGET", "CLICK binding to an addon butto
check(overrides["G"] == nil and overrides["N"] == nil, "other spells untouched")
check(count(overrides) == 5, "only Fishing keys overridden")
check(C_CVar.GetCVar("SoftTargetInteractRange") == "30", "interact range raised while fishing")
check(C_CVar.GetCVar("SoftTargetInteract") == "3", "Interact Key turned on while fishing")
handler(nil, "UNIT_SPELLCAST_CHANNEL_STOP", "player", "guid", 7731)
check(count(overrides) == 0, "keys back to Fishing when the channel ends")
check(C_CVar.GetCVar("SoftTargetInteractRange") == "10", "range restored")
check(C_CVar.GetCVar("SoftTargetInteract") == "0", "Interact Key off again")
handler(nil, "UNIT_SPELLCAST_CHANNEL_START", "player", "guid", 133)
check(count(overrides) == 0, "other channels ignored")
@ -99,6 +101,18 @@ handler(nil, "UNIT_SPELLCAST_CHANNEL_START", "player", "guid", 7620)
check(temp.SoftTargetInteractRange == nil, "longer range left alone")
handler(nil, "UNIT_SPELLCAST_CHANNEL_STOP", "player", "guid", 7620)
cvars.SoftTargetInteract = "3"
handler(nil, "UNIT_SPELLCAST_CHANNEL_START", "player", "guid", 7620)
check(temp.SoftTargetInteract == nil, "Interact Key already on is left alone")
handler(nil, "UNIT_SPELLCAST_CHANNEL_STOP", "player", "guid", 7620)
cvars.SoftTargetInteract = "0"
C_CVar.SetTempCVar = function() error("secure cvar") end
handler(nil, "UNIT_SPELLCAST_CHANNEL_START", "player", "guid", 7620)
check(overrides["F"] == "INTERACTTARGET" and printed[#printed]:find("Settings", 1, true), "blocked setting warns, key still overridden")
handler(nil, "UNIT_SPELLCAST_CHANNEL_STOP", "player", "guid", 7620)
C_CVar.SetTempCVar = function(n, v) temp[n] = v end
SlashCmdList.FISHKEY("off")
check(FishKeyDB.enabled == false, "/fish off")
check(printed[#printed]:find("off", 1, true) and printed[#printed]:find("F, SHIFT-1", 1, true), "status lists keys")