Core/Spells: You should not be able to cast Create Healthstone if you already have one in your inventory

Closes #1498
Signed-off-by: Subv <s.v.h21@hotmail.com>
This commit is contained in:
Subv
2012-04-12 20:18:07 -05:00
parent c04e92564b
commit 491999280e

View File

@@ -172,6 +172,19 @@ class spell_warl_create_healthstone : public SpellScriptLoader
return true;
}
SpellCastResult CheckCast()
{
if (Player* caster = GetCaster()->ToPlayer())
{
uint8 spellRank = sSpellMgr->GetSpellRank(GetSpellInfo()->Id);
ItemPosCountVec dest;
InventoryResult msg = caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, iTypes[spellRank - 1][0], 1, NULL);
if (msg != EQUIP_ERR_OK)
return SPELL_FAILED_TOO_MANY_OF_ITEM;
}
return SPELL_CAST_OK;
}
void HandleScriptEffect(SpellEffIndex effIndex)
{
if (Unit* unitTarget = GetHitUnit())
@@ -198,6 +211,7 @@ class spell_warl_create_healthstone : public SpellScriptLoader
void Register()
{
OnEffectHitTarget += SpellEffectFn(spell_warl_create_healthstone_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
OnCheckCast += SpellCheckCastFn(spell_warl_create_healthstone_SpellScript::CheckCast);
}
};