diff --git a/COE_TotemData.lua b/COE_TotemData.lua index 4103f37..baa211c 100644 --- a/COE_TotemData.lua +++ b/COE_TotemData.lua @@ -54,6 +54,41 @@ COE["PendingTotems"] = { Air = {Totem = nil, Rank = 0, TimeoutStartMS = 0} }; +--[[ ---------------------------------------------------------------- + COE.TotemElementsByName is the fallback ScanTotems uses when the + element cannot be read from the spell tooltip. The + "Tools: Totem" line names the totem item, so it stays + incomplete until that item is in the client's item cache (WDB). + A client whose WDB was cleared (the OctoWoW launcher does this on + every launch by default) scans at login with an empty cache. + English spell names only; other locales still rely on the tooltip. +-------------------------------------------------------------------]] +COE["TotemElementsByName"] = { + ["Earthbind Totem"] = "Earth", + ["Stoneclaw Totem"] = "Earth", + ["Stoneskin Totem"] = "Earth", + ["Strength of Earth Totem"] = "Earth", + ["Tremor Totem"] = "Earth", + ["Fire Nova Totem"] = "Fire", + ["Flametongue Totem"] = "Fire", + ["Frost Resistance Totem"] = "Fire", + ["Magma Totem"] = "Fire", + ["Searing Totem"] = "Fire", + ["Disease Cleansing Totem"] = "Water", + ["Fire Resistance Totem"] = "Water", + ["Healing Stream Totem"] = "Water", + ["Mana Spring Totem"] = "Water", + ["Mana Tide Totem"] = "Water", + ["Poison Cleansing Totem"] = "Water", + ["Grace of Air Totem"] = "Air", + ["Grounding Totem"] = "Air", + ["Nature Resistance Totem"] = "Air", + ["Sentry Totem"] = "Air", + ["Tranquil Air Totem"] = "Air", + ["Windfury Totem"] = "Air", + ["Windwall Totem"] = "Air" +}; + --[[ ---------------------------------------------------------------- COE.CleansingTotems stores pointers to the buttons and totems that are able to cleanse poisons, diseases and sleep, charm @@ -270,6 +305,18 @@ function COE:ScanTotems() end end + -- no element from the tooltip: fall back to the + -- known totem names (see COE.TotemElementsByName) + -- ------------------------------------------------ + if (totem.Element == "") then + local element = COE.TotemElementsByName[SpellName]; + if (element) then + totem.Element = element; + COE.TotemsAvailable[element] = + COE.TotemsAvailable[element] + 1; + end + end + -- get totem texture -- ------------------ totem.Texture = GetSpellTexture(i, BOOKTYPE_SPELL); @@ -307,9 +354,10 @@ function COE:ScanTotems() totem.Ranks[rank] = totemrank; if (rank > totem.MaxRank) then totem.MaxRank = rank; end - -- is this a new totem? - -- --------------------- - if (newtotem) then + -- is this a new totem? a spell that only has "Totem" in its + -- name but no element is not a placeable totem: leave it out + -- ------------------------------------------------------------ + if (newtotem and totem.Element ~= "") then -- store totem -- ------------ COE.TotemCount = COE.TotemCount + 1; @@ -332,7 +380,10 @@ function COE:ScanTotems() -- check visibility options -- ======================================================================= - if (COE_DisplayedTotems[SpellName] == nil) then + if (totem.Element == "") then + COE:DebugMessage("Skipped spell without a totem element: " .. + SpellName); + elseif (COE_DisplayedTotems[SpellName] == nil) then -- perhaps a new totem. set it to default visible -- and reorder it when the element count is known -- ----------------------------------------------- diff --git a/COE_TotemLogic.lua b/COE_TotemLogic.lua index 7d784d5..dcf025f 100644 --- a/COE_TotemLogic.lua +++ b/COE_TotemLogic.lua @@ -641,9 +641,15 @@ function COE_Totem:SetPendingTotem(totem, rank) -- Set PendingTotems for the given totem element type COE:DebugMessage("SetPendingTotem PendingTotems being set: " .. - totem.SpellName .. " with rank: " .. rank); - COE.PendingTotems[totem.Element].Totem = totem; - COE.PendingTotems[totem.Element].Rank = rank; + totem.SpellName .. " with rank: " .. tostring(rank)); + local pending = COE.PendingTotems[totem.Element]; + if (not pending) then + -- no known element: cast without a timer instead of erroring + -- ------------------------------------------------------------ + return; + end + pending.Totem = totem; + pending.Rank = rank; -- COE.PendingTotems[totem.Element].TimeoutStartMS = GetTime(); -- get the current lag - Not used but saving if needed