From 6a0e86efe8cf86d0cfa505fb999596f9c36cb091 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 21 Mar 2026 04:23:07 -0700 Subject: [PATCH] fix: IsUsableAction now checks spell power cost from DBC IsUsableAction previously always returned notEnoughMana=false. Now it checks the spell's mana cost from SpellDataResolver against the player's current power, matching the same fix applied to IsUsableSpell. This fixes action bar addons (Bartender, Dominos) incorrectly showing abilities as usable when the player lacks mana/rage/energy. --- src/addons/lua_engine.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/addons/lua_engine.cpp b/src/addons/lua_engine.cpp index 42dd640a..07ed2232 100644 --- a/src/addons/lua_engine.cpp +++ b/src/addons/lua_engine.cpp @@ -2394,11 +2394,26 @@ static int lua_IsUsableAction(lua_State* L) { } const auto& action = bar[slot]; bool usable = action.isReady(); + bool noMana = false; if (action.type == game::ActionBarSlot::SPELL) { usable = usable && gh->getKnownSpells().count(action.id); + // Check power cost + if (usable && action.id != 0) { + auto spellData = gh->getSpellData(action.id); + if (spellData.manaCost > 0) { + auto pe = gh->getEntityManager().getEntity(gh->getPlayerGuid()); + if (pe) { + auto* unit = dynamic_cast(pe.get()); + if (unit && unit->getPower() < spellData.manaCost) { + noMana = true; + usable = false; + } + } + } + } } lua_pushboolean(L, usable ? 1 : 0); - lua_pushboolean(L, 0); // notEnoughMana (can't determine without cost data) + lua_pushboolean(L, noMana ? 1 : 0); return 2; }