From 1b075e17f183291b09a1e7bf9a70d984ca724bd1 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sun, 22 Mar 2026 20:17:50 -0700 Subject: [PATCH] feat: show item spell effects in tooltips (Use/Equip/Chance on Hit) Item tooltips now display spell effects in green text: - "Use: Restores 2200 health over 30 sec" (trigger 0) - "Equip: Increases attack power by 120" (trigger 1) - "Chance on hit: Strikes the enemy for 95 Nature damage" (trigger 2) Passes up to 5 item spell entries through _GetItemTooltipData with spellId, trigger type, spell name, and spell description from DBC. The tooltip builder maps trigger IDs to "Use: ", "Equip: ", or "Chance on hit: " prefixes. This completes the item tooltip with all major WoW tooltip sections: quality name, bind type, equip slot/type, armor, damage/DPS/speed, primary stats, combat ratings, resistances, spell effects, gem sockets, required level, flavor text, and sell price. --- src/addons/lua_engine.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/addons/lua_engine.cpp b/src/addons/lua_engine.cpp index d85c56ad..c7c754bf 100644 --- a/src/addons/lua_engine.cpp +++ b/src/addons/lua_engine.cpp @@ -2100,6 +2100,29 @@ static int lua_GetItemTooltipData(lua_State* L) { if (info->frostRes != 0) { lua_pushnumber(L, info->frostRes); lua_setfield(L, -2, "frostRes"); } if (info->shadowRes != 0) { lua_pushnumber(L, info->shadowRes); lua_setfield(L, -2, "shadowRes"); } if (info->arcaneRes != 0) { lua_pushnumber(L, info->arcaneRes); lua_setfield(L, -2, "arcaneRes"); } + // Item spell effects (Use: / Equip: / Chance on Hit:) + { + lua_newtable(L); + int spellCount = 0; + for (int i = 0; i < 5; ++i) { + if (info->spells[i].spellId == 0) continue; + ++spellCount; + lua_newtable(L); + lua_pushnumber(L, info->spells[i].spellId); + lua_setfield(L, -2, "spellId"); + lua_pushnumber(L, info->spells[i].spellTrigger); + lua_setfield(L, -2, "trigger"); + // Get spell name for display + const std::string& sName = gh->getSpellName(info->spells[i].spellId); + if (!sName.empty()) { lua_pushstring(L, sName.c_str()); lua_setfield(L, -2, "name"); } + // Get description + const std::string& sDesc = gh->getSpellDescription(info->spells[i].spellId); + if (!sDesc.empty()) { lua_pushstring(L, sDesc.c_str()); lua_setfield(L, -2, "description"); } + lua_rawseti(L, -2, spellCount); + } + if (spellCount > 0) lua_setfield(L, -2, "itemSpells"); + else lua_pop(L, 1); + } // Gem sockets (WotLK/TBC) int numSockets = 0; for (int i = 0; i < 3; ++i) { @@ -5533,6 +5556,17 @@ void LuaEngine::registerCoreAPI() { " if data.frostRes and data.frostRes ~= 0 then self:AddLine('+'..data.frostRes..' Frost Resistance', 0, 1, 0) end\n" " if data.shadowRes and data.shadowRes ~= 0 then self:AddLine('+'..data.shadowRes..' Shadow Resistance', 0, 1, 0) end\n" " if data.arcaneRes and data.arcaneRes ~= 0 then self:AddLine('+'..data.arcaneRes..' Arcane Resistance', 0, 1, 0) end\n" + " -- Item spell effects (Use: / Equip: / Chance on Hit:)\n" + " if data.itemSpells then\n" + " local triggerLabels = {[0]='Use: ',[1]='Equip: ',[2]='Chance on hit: ',[5]=''}\n" + " for _, sp in ipairs(data.itemSpells) do\n" + " local label = triggerLabels[sp.trigger] or ''\n" + " local text = sp.description or sp.name or ''\n" + " if text ~= '' then\n" + " self:AddLine(label .. text, 0, 1, 0)\n" + " end\n" + " end\n" + " end\n" " -- Gem sockets\n" " if data.sockets then\n" " local socketNames = {[1]='Meta',[2]='Red',[4]='Yellow',[8]='Blue'}\n"