Skip to content

Commit

Permalink
Fix potentially crash in Orb of Draconic Energy script also -- we hav…
Browse files Browse the repository at this point in the history
…e good readable function: unit->GetHealthPercent()

(based on cmangos/mangos-wotlk@d9c0eb3cd)

Signed-off-by: Xfurry <xfurry.cmangos@outlook.com>
  • Loading branch information
boxa authored and xfurry committed Dec 10, 2017
1 parent c6daa11 commit 436c678
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/scriptdev2/scripts/world/item_scripts.cpp
Expand Up @@ -44,17 +44,19 @@ enum
bool ItemUse_item_orb_of_draconic_energy(Player* pPlayer, Item* pItem, const SpellCastTargets& pTargets)
{
Creature* pEmberstrife = GetClosestCreatureWithEntry(pPlayer, NPC_EMBERSTRIFE, 20.0f);
// If Emberstrife is already mind controled or above 10% HP: force spell cast failure
if (pEmberstrife && pEmberstrife->HasAura(SPELL_DOMINION_SOUL)
|| 10 * pEmberstrife->GetHealth() > pEmberstrife->GetMaxHealth())
if (!pEmberstrife)
return false;

// If Emberstrife already mind controled or above 10% HP: force spell cast failure
if (pEmberstrife->HasAura(SPELL_DOMINION_SOUL) || pEmberstrife->GetHealthPercent() > 10.0f)
{
pPlayer->SendEquipError(EQUIP_ERR_NONE, pItem, NULL);

if (const SpellEntry* pSpellInfo = GetSpellStore()->LookupEntry(SPELL_DOMINION_SOUL))
if (SpellEntry const* pSpellInfo = GetSpellStore()->LookupEntry(SPELL_DOMINION_SOUL))
Spell::SendCastResult(pPlayer, pSpellInfo, 1, SPELL_FAILED_TARGET_AURASTATE);

return true;
}
}

return false;
}
Expand Down

0 comments on commit 436c678

Please sign in to comment.