mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
feat: add spell power cost to SpellDataResolver; fix IsUsableSpell mana check
Extend SpellDataInfo with manaCost and powerType fields, extracted from Spell.dbc ManaCost and PowerType columns. This enables IsUsableSpell() to properly check if the player has enough mana/rage/energy to cast. Previously IsUsableSpell always returned notEnoughMana=false since cost data wasn't available. Now it compares the spell's DBC mana cost against the player's current power, returning accurate usability and mana state. This fixes action bar addons showing abilities as usable when the player lacks sufficient power, and enables OmniCC-style cooldown text to properly dim insufficient-power abilities.
This commit is contained in:
parent
c7e16646fc
commit
91794f421e
3 changed files with 35 additions and 4 deletions
|
|
@ -2189,8 +2189,22 @@ static int lua_IsUsableSpell(lua_State* L) {
|
|||
float cd = gh->getSpellCooldown(spellId);
|
||||
bool onCooldown = (cd > 0.1f);
|
||||
|
||||
lua_pushboolean(L, onCooldown ? 0 : 1); // usable (not on cooldown)
|
||||
lua_pushboolean(L, 0); // noMana (can't determine without spell cost data)
|
||||
// Check mana/power cost
|
||||
bool noMana = false;
|
||||
if (!onCooldown) {
|
||||
auto spellData = gh->getSpellData(spellId);
|
||||
if (spellData.manaCost > 0) {
|
||||
auto playerEntity = gh->getEntityManager().getEntity(gh->getPlayerGuid());
|
||||
if (playerEntity) {
|
||||
auto* unit = dynamic_cast<game::Unit*>(playerEntity.get());
|
||||
if (unit && unit->getPower() < spellData.manaCost) {
|
||||
noMana = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lua_pushboolean(L, (onCooldown || noMana) ? 0 : 1); // usable
|
||||
lua_pushboolean(L, noMana ? 1 : 0); // notEnoughMana
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue