Eluna fix crash on InterruptSpell. Make item use and item gossip hooks to be able to return false to stop spell casting.
This commit is contained in:
54
HookMgr.cpp
54
HookMgr.cpp
@@ -398,13 +398,36 @@ bool Eluna::OnQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest)
|
||||
|
||||
bool Eluna::OnUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets)
|
||||
{
|
||||
return OnItemGossip(pPlayer, pItem, targets) || OnItemUse(pPlayer, pItem, targets);
|
||||
// pPlayer->SendEquipError((InventoryResult)83, pItem, NULL);
|
||||
// return true;
|
||||
ObjectGuid guid = pItem->GET_GUID();
|
||||
bool castSpell = true;
|
||||
|
||||
if (!OnItemGossip(pPlayer, pItem, targets))
|
||||
castSpell = false;
|
||||
|
||||
pItem = pPlayer->GetItemByGuid(guid);
|
||||
if (pItem && OnItemUse(pPlayer, pItem, targets))
|
||||
pItem = pPlayer->GetItemByGuid(guid);
|
||||
else
|
||||
castSpell = false;
|
||||
|
||||
if (pItem && castSpell)
|
||||
return true;
|
||||
|
||||
// Send equip error that shows no message
|
||||
// This is a hack fix to stop spell casting visual bug when a spell is not cast on use
|
||||
WorldPacket data(SMSG_INVENTORY_CHANGE_FAILURE, 18);
|
||||
data << uint8(83);
|
||||
data << ObjectGuid(guid);
|
||||
data << ObjectGuid(0);
|
||||
data << uint8(0);
|
||||
pPlayer->GetSession()->SendPacket(&data);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Eluna::OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets)
|
||||
{
|
||||
ENTRY_BEGIN(ItemEventBindings, pItem->GetEntry(), ITEM_EVENT_ON_USE, return false);
|
||||
bool result = true;
|
||||
ENTRY_BEGIN(ItemEventBindings, pItem->GetEntry(), ITEM_EVENT_ON_USE, return result);
|
||||
Push(L, pPlayer);
|
||||
Push(L, pItem);
|
||||
#ifdef MANGOS
|
||||
@@ -432,20 +455,33 @@ bool Eluna::OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targ
|
||||
else
|
||||
Push(L);
|
||||
#endif
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i)
|
||||
{
|
||||
if (lua_isnoneornil(L, i))
|
||||
continue;
|
||||
result = CHECKVAL<bool>(L, i, result);
|
||||
}
|
||||
ENDCALL();
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Eluna::OnItemGossip(Player* pPlayer, Item* pItem, SpellCastTargets const& /*targets*/)
|
||||
{
|
||||
ENTRY_BEGIN(ItemGossipBindings, pItem->GetEntry(), GOSSIP_EVENT_ON_HELLO, return false);
|
||||
bool result = true;
|
||||
ENTRY_BEGIN(ItemGossipBindings, pItem->GetEntry(), GOSSIP_EVENT_ON_HELLO, return result);
|
||||
pPlayer->PlayerTalkClass->ClearMenus();
|
||||
Push(L, pPlayer);
|
||||
Push(L, pItem);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i)
|
||||
{
|
||||
if (lua_isnoneornil(L, i))
|
||||
continue;
|
||||
result = CHECKVAL<bool>(L, i, result);
|
||||
}
|
||||
ENDCALL();
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Eluna::OnExpire(Player* pPlayer, ItemTemplate const* pProto)
|
||||
|
||||
Reference in New Issue
Block a user