From 8d4478b87c558ab4284aacc2a2e9f0b47f322132 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sun, 22 Mar 2026 18:19:51 -0700 Subject: [PATCH] feat: enhance spell tooltips with cost, range, cast time, and cooldown SetSpellByID now shows comprehensive spell information: - Mana/Rage/Energy/Runic Power cost - Range in yards (or omitted for self-cast) - Cast time ("1.5 sec cast" or "Instant") - Active cooldown remaining in red Uses existing GetSpellInfo (castTime, range from DBC), GetSpellPowerCost (mana cost from DBC), and GetSpellCooldown (remaining CD) to populate the tooltip with real spell data. --- src/addons/lua_engine.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/addons/lua_engine.cpp b/src/addons/lua_engine.cpp index 3bb293ef..3ebae787 100644 --- a/src/addons/lua_engine.cpp +++ b/src/addons/lua_engine.cpp @@ -5408,10 +5408,32 @@ void LuaEngine::registerCoreAPI() { "function GameTooltip:SetSpellByID(spellId)\n" " self:ClearLines()\n" " if not spellId or spellId == 0 then return end\n" - " local name, rank, icon = GetSpellInfo(spellId)\n" + " local name, rank, icon, castTime, minRange, maxRange = GetSpellInfo(spellId)\n" " if name then\n" " self:SetText(name, 1, 1, 1)\n" " if rank and rank ~= '' then self:AddLine(rank, 0.5, 0.5, 0.5) end\n" + " -- Mana cost\n" + " local cost, costType = GetSpellPowerCost(spellId)\n" + " if cost and cost > 0 then\n" + " local powerNames = {[0]='Mana',[1]='Rage',[2]='Focus',[3]='Energy',[6]='Runic Power'}\n" + " self:AddLine(cost..' '..(powerNames[costType] or 'Mana'), 1, 1, 1)\n" + " end\n" + " -- Range\n" + " if maxRange and maxRange > 0 then\n" + " self:AddDoubleLine(string.format('%.0f yd range', maxRange), '', 1,1,1, 1,1,1)\n" + " end\n" + " -- Cast time\n" + " if castTime and castTime > 0 then\n" + " self:AddDoubleLine(string.format('%.1f sec cast', castTime / 1000), '', 1,1,1, 1,1,1)\n" + " else\n" + " self:AddDoubleLine('Instant', '', 1,1,1, 1,1,1)\n" + " end\n" + " -- Cooldown\n" + " local start, dur = GetSpellCooldown(spellId)\n" + " if dur and dur > 0 then\n" + " local rem = start + dur - GetTime()\n" + " if rem > 0.1 then self:AddLine(string.format('%.0f sec cooldown', rem), 1, 0, 0) end\n" + " end\n" " self.__spellId = spellId\n" " end\n" "end\n"