mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
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.
This commit is contained in:
parent
91794f421e
commit
6a0e86efe8
1 changed files with 16 additions and 1 deletions
|
|
@ -2394,11 +2394,26 @@ static int lua_IsUsableAction(lua_State* L) {
|
||||||
}
|
}
|
||||||
const auto& action = bar[slot];
|
const auto& action = bar[slot];
|
||||||
bool usable = action.isReady();
|
bool usable = action.isReady();
|
||||||
|
bool noMana = false;
|
||||||
if (action.type == game::ActionBarSlot::SPELL) {
|
if (action.type == game::ActionBarSlot::SPELL) {
|
||||||
usable = usable && gh->getKnownSpells().count(action.id);
|
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<game::Unit*>(pe.get());
|
||||||
|
if (unit && unit->getPower() < spellData.manaCost) {
|
||||||
|
noMana = true;
|
||||||
|
usable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lua_pushboolean(L, usable ? 1 : 0);
|
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;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue