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

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.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-06-08 17:25:02 -05:00
parent 6578cce471
commit 4e130dcdfd
15 changed files with 257 additions and 35 deletions

View File

@@ -3125,18 +3125,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
@@ -3155,26 +3163,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()