[9507] Implement SPELL_EFFECT_RESTORE_ITEM_CHARGES

Also it application in special case of item 5513 and similar.
This commit is contained in:
VladimirMangos 2010-03-03 05:58:36 +03:00
parent d775eea9a4
commit 4c4629e861
11 changed files with 105 additions and 3 deletions

View file

@ -1055,3 +1055,28 @@ bool ItemRequiredTarget::IsFitToRequirements( Unit* pUnitTarget ) const
return false;
}
}
bool Item::HasMaxCharges() const
{
ItemPrototype const* itemProto = GetProto();
for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
if (GetSpellCharges(i) != itemProto->Spells[i].SpellCharges)
return false;
return true;
}
void Item::RestoreCharges()
{
ItemPrototype const* itemProto = GetProto();
for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
{
if (GetSpellCharges(i) != itemProto->Spells[i].SpellCharges)
{
SetSpellCharges(i, itemProto->Spells[i].SpellCharges);
SetState(ITEM_CHANGED);
}
}
}