aboutsummaryrefslogtreecommitdiff
path: root/src/game/SpellHandler.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-06-08 17:25:02 -0500
committermegamage <none@none>2009-06-08 17:25:02 -0500
commit4e130dcdfdd30b84fb5e0b0531c817c7b6c64ff9 (patch)
tree09f871f8eab58afe981e99fa74cef6bcf0777e7c /src/game/SpellHandler.cpp
parent6578cce47133eb017a7ab6b14c91d6c5b80b226a (diff)
[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
Diffstat (limited to 'src/game/SpellHandler.cpp')
-rw-r--r--src/game/SpellHandler.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp
index 7e72fd4e749..62056a6806f 100644
--- a/src/game/SpellHandler.cpp
+++ b/src/game/SpellHandler.cpp
@@ -123,9 +123,29 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
}
SpellCastTargets targets;
- if(!targets.read(&recvPacket, pUser))
+ if (!targets.read(&recvPacket, pUser))
return;
+ targets.Update(pUser);
+
+ if (!pItem->IsTargetValidForItemUse(targets.getUnitTarget()))
+ {
+ // free greay item aftre use faul
+ pUser->SendEquipError(EQUIP_ERR_NONE, pItem, NULL);
+
+ // send spell error
+ if (SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid))
+ {
+ // for implicit area/coord target spells
+ if(!targets.getUnitTarget())
+ Spell::SendCastResult(_player,spellInfo,cast_count,SPELL_FAILED_NO_VALID_TARGETS);
+ // for explicit target spells
+ else
+ Spell::SendCastResult(_player,spellInfo,cast_count,SPELL_FAILED_BAD_TARGETS);
+ }
+ return;
+ }
+
//Note: If script stop casting it must send appropriate data to client to prevent stuck item in gray state.
if(!Script->ItemUse(pUser,pItem,targets))
{