Replace libtotem with ClassicAPI's native totem tracker

ClassicAPI now ships GetTotemInfo/GetTotemTimeLeft/GetTotemDuration/
TargetTotem plus a native PLAYER_TOTEM_UPDATE event, backed by a
data-driven tracker (slot from the Spell.dbc summon effect, duration from
SpellDuration.dbc, and object-manager death detection). That's exactly
what libtotem hand-rolled -- and better -- so delete the library outright:
its spellid/icon tables, the CastSpellByName/CastSpell/UseAction hooks,
the SPELL_GO commit path, and the active-totem bookkeeping.

modules/totems.lua becomes a thin consumer of the native API:
- Driven by PLAYER_TOTEM_UPDATE; drop the shaman tick-poller that only
  existed because vanilla had no totem event.
- Fix the GetTotemInfo call sites: the native 1st return is tool presence,
  not "summoned", so key active state on name/start instead.
- Right-click a totem icon to TargetTotem it; tooltip shows remaining time
  via GetTotemTimeLeft.

modules/turtle-wow.lua: drop the Totemic Recall handler that poked
libtotem:Clean() -- the native tracker detects the totems despawning and
clears the slots itself. Also clean up the now-orphaned translation string
and a stale libtotem mention in libdebuff's comment.
This commit is contained in:
Brues
2026-07-20 21:51:08 -05:00
parent 88d0f7bf74
commit 9c529512d1
13 changed files with 20 additions and 317 deletions
+19 -20
View File
@@ -1,6 +1,4 @@
pfUI:RegisterModule("totems", function ()
local _, class = UnitClass("player")
local slots = {
[FIRE_TOTEM_SLOT] = { r = .5, g = .2, b = .1 },
[EARTH_TOTEM_SLOT] = { r = .2, g = .4, b = .1 },
@@ -15,43 +13,44 @@ pfUI:RegisterModule("totems", function ()
totems:RefreshList()
end)
if class == "SHAMAN" then
-- there's no totem event in vanilla using ticks instead
local eventemu = CreateFrame("Frame")
eventemu:SetScript("OnUpdate", function()
if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .5 end
totems:RefreshList()
end)
end
totems.OnEnter = function(self)
if not this.id then return end
local active, name, start, duration, icon = GetTotemInfo(this.id)
if not name or not active then return end -- Prüfen ob name gültig ist
-- native GetTotemInfo's 1st return is tool presence, not "summoned";
-- a live totem shows a non-empty name / non-zero start.
local _, name = GetTotemInfo(this.id)
if not name or name == "" then return end
local color = slots[this.id]
GameTooltip:SetOwner(this, "ANCHOR_LEFT")
GameTooltip:SetText(name, color.r+.2, color.g+.2, color.b+.2)
local timeleft = GetTotemTimeLeft(this.id)
if timeleft and timeleft > 0 then
GameTooltip:AddLine(string.format("%d:%02d", floor(timeleft/60), floor(mod(timeleft, 60))), 1, 1, 1)
end
GameTooltip:Show()
end
end
totems.OnLeave = function(self)
GameTooltip:Hide()
end
totems.OnClick = function(self)
if this.id and arg1 and arg1 == "LeftButton" then
-- Try to recast totem on left click
local active, name, start, duration, icon = GetTotemInfo(this.id)
if name then CastSpellByName(name) end
if not this.id then return end
if arg1 == "LeftButton" then
-- recast the totem on left click
local _, name = GetTotemInfo(this.id)
if name and name ~= "" then CastSpellByName(name) end
elseif arg1 == "RightButton" then
-- target the totem on right click
TargetTotem(this.id)
end
end
totems.RefreshList = function(self)
local count = 0
for i = 1, MAX_TOTEMS do
local active, name, start, duration, icon = GetTotemInfo(i)
local _, _, start, duration, icon = GetTotemInfo(i)
if active and icon and icon ~= "" then
if start and start > 0 and icon and icon ~= "" then
count = count + 1
local color = slots[i]