[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

@ -123,7 +123,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]=
&Spell::EffectThreat, // 63 SPELL_EFFECT_THREAT
&Spell::EffectTriggerSpell, // 64 SPELL_EFFECT_TRIGGER_SPELL
&Spell::EffectApplyAreaAura, // 65 SPELL_EFFECT_APPLY_AREA_AURA_RAID
&Spell::EffectUnused, // 66 SPELL_EFFECT_CREATE_MANA_GEM (possibly recharge it, misc - is item ID)
&Spell::EffectRestoreItemCharges, // 66 SPELL_EFFECT_RESTORE_ITEM_CHARGES itemtype - is affected item ID
&Spell::EffectHealMaxHealth, // 67 SPELL_EFFECT_HEAL_MAX_HEALTH
&Spell::EffectInterruptCast, // 68 SPELL_EFFECT_INTERRUPT_CAST
&Spell::EffectDistract, // 69 SPELL_EFFECT_DISTRACT
@ -1652,6 +1652,13 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
return;
}
}
// Conjure Mana Gem
if (eff_idx == EFFECT_INDEX_1 && m_spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_CREATE_ITEM)
{
unitTarget->CastSpell( unitTarget, m_spellInfo->CalculateSimpleValue(eff_idx), true, m_CastItem);
return;
}
break;
}
case SPELLFAMILY_WARRIOR:
@ -3191,6 +3198,10 @@ void Spell::DoCreateItem(SpellEffectIndex eff_idx, uint32 itemtype)
num_to_add -= no_space;
else
{
// ignore mana gem case (next effect will recharge existed example)
if (eff_idx == EFFECT_INDEX_0 && m_spellInfo->Effect[EFFECT_INDEX_1] == SPELL_EFFECT_DUMMY )
return;
// if not created by another reason from full inventory or unique items amount limitation
player->SendEquipError( msg, NULL, NULL, newitemid );
return;
@ -7436,3 +7447,14 @@ void Spell::EffectBind(SpellEffectIndex eff_idx)
data << uint32(area_id);
player->SendMessageToSet( &data, true );
}
void Spell::EffectRestoreItemCharges( SpellEffectIndex eff_idx )
{
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
Player* player = (Player*)unitTarget;
if (Item* item = player->GetItemByEntry(m_spellInfo->EffectItemType[eff_idx]))
item->RestoreCharges();
}