UseAction hooks: GetActionInfo + GetMacroSpell, drop tooltip scans

The three UseAction hooks in libtotem / libpredict / libcast all did
the same dance: filter out macros via GetActionText, then tooltip-scan
the action to recover the spell name + rank. ClassicAPI's
GetActionInfo + GetMacroSpell make both steps unnecessary:

- GetActionInfo returns ("spell", spellID) or ("macro", macroSlot)
- GetMacroSpell resolves a macroSlot to (name, rank, spellID) at the
  highest known rank, parsed engine-side at macro save time

So macros are no longer skipped — they resolve to their cast spell
just like a raw spell action. libtotem queue gains a real spellID
(the previous "no spellId available, icon-based fallback" comment is
obsolete). libcast also wins: it can feed the resolved spellID
through FindSpellBookSlotByID + libspell.GetSpellInfo(slot, "spell")
without the name-with-rank-suffix string concat round-trip.

Drops libtipscan:GetScanner("prediction") usage in libtotem and
libpredict, and libtipscan:GetScanner("libcast") in libcast.
This commit is contained in:
Brues
2026-05-21 16:45:57 -05:00
parent 8e635afeed
commit 2f17546c1a
3 changed files with 39 additions and 17 deletions
+13 -7
View File
@@ -259,13 +259,19 @@ hooksecurefunc("CastSpell", function(id, bookType)
libtotem:CheckAddQueue(name, rank, icon, spellId)
end)
-- Hook UseAction (no spellId available, icon-based fallback)
local scanner = libtipscan:GetScanner("prediction")
-- Hook UseAction. GetActionInfo + GetMacroSpell give us the spellID
-- directly for both spell-action and macro-action slots, so the
-- tooltip-scan fallback (and the "no spellId available" caveat) goes away.
hooksecurefunc("UseAction", function(slot, target, selfcast)
if GetActionText(slot) or not IsCurrentAction(slot) then return end
scanner:SetAction(slot)
local name, rank = scanner:Line(1)
local icon = GetActionTexture(slot)
if not IsCurrentAction(slot) then return end
local kind, id = GetActionInfo(slot)
local name, rank, spellID
if kind == "spell" then
spellID = id
name, rank = GetSpellInfo(id)
elseif kind == "macro" then
name, rank, spellID = GetMacroSpell(id)
end
if not name then return end
libtotem:CheckAddQueue(name, rank, icon, nil)
libtotem:CheckAddQueue(name, rank, GetActionTexture(slot), spellID)
end)