[7980] Implement item use target requirements store and check (new table item_required_target).

Signed-off-by: VladimirMangos <vladimir@getmangos.com>

* Also implement this table reload
* Static Spell::SendCastResult function for call not from spell code.
  Can be also used in scripts where need send explicitly spell cast error to client.
This commit is contained in:
NoFantasy 2009-06-09 00:22:51 +04:00 committed by VladimirMangos
parent 6d8867d0fc
commit 6a1b4e5729
18 changed files with 279 additions and 36 deletions

View file

@ -2862,18 +2862,26 @@ void Spell::SendCastResult(SpellCastResult result)
if(((Player*)m_caster)->GetSession()->PlayerLoading()) // don't send cast results at loading time
return;
SendCastResult((Player*)m_caster,m_spellInfo,m_cast_count,result);
}
void Spell::SendCastResult(Player* caster, SpellEntry const* spellInfo, uint8 cast_count, SpellCastResult result)
{
if(result == SPELL_CAST_OK)
return;
WorldPacket data(SMSG_CAST_FAILED, (4+1+1));
data << uint8(m_cast_count); // single cast or multi 2.3 (0/1)
data << uint32(m_spellInfo->Id);
data << uint8(cast_count); // single cast or multi 2.3 (0/1)
data << uint32(spellInfo->Id);
data << uint8(result); // problem
switch (result)
{
case SPELL_FAILED_REQUIRES_SPELL_FOCUS:
data << uint32(m_spellInfo->RequiresSpellFocus);
data << uint32(spellInfo->RequiresSpellFocus);
break;
case SPELL_FAILED_REQUIRES_AREA:
// hardcode areas limitation case
switch(m_spellInfo->Id)
switch(spellInfo->Id)
{
case 41617: // Cenarion Mana Salve
case 41619: // Cenarion Healing Salve
@ -2892,26 +2900,26 @@ void Spell::SendCastResult(SpellCastResult result)
}
break;
case SPELL_FAILED_TOTEMS:
if(m_spellInfo->Totem[0])
data << uint32(m_spellInfo->Totem[0]);
if(m_spellInfo->Totem[1])
data << uint32(m_spellInfo->Totem[1]);
if(spellInfo->Totem[0])
data << uint32(spellInfo->Totem[0]);
if(spellInfo->Totem[1])
data << uint32(spellInfo->Totem[1]);
break;
case SPELL_FAILED_TOTEM_CATEGORY:
if(m_spellInfo->TotemCategory[0])
data << uint32(m_spellInfo->TotemCategory[0]);
if(m_spellInfo->TotemCategory[1])
data << uint32(m_spellInfo->TotemCategory[1]);
if(spellInfo->TotemCategory[0])
data << uint32(spellInfo->TotemCategory[0]);
if(spellInfo->TotemCategory[1])
data << uint32(spellInfo->TotemCategory[1]);
break;
case SPELL_FAILED_EQUIPPED_ITEM_CLASS:
data << uint32(m_spellInfo->EquippedItemClass);
data << uint32(m_spellInfo->EquippedItemSubClassMask);
//data << uint32(m_spellInfo->EquippedItemInventoryTypeMask);
data << uint32(spellInfo->EquippedItemClass);
data << uint32(spellInfo->EquippedItemSubClassMask);
//data << uint32(spellInfo->EquippedItemInventoryTypeMask);
break;
default:
break;
}
((Player*)m_caster)->GetSession()->SendPacket(&data);
caster->GetSession()->SendPacket(&data);
}
void Spell::SendSpellStart()