Core/Scripts: New ItemScript trigger, OnItemRemove

This commit is contained in:
kontownik
2014-03-03 22:18:47 +01:00
parent 437b97fe73
commit 91850fa9e4
3 changed files with 15 additions and 1 deletions

View File

@@ -12654,7 +12654,8 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
RemoveAurasDueToSpell(proto->Spells[i].SpellId);
ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount());
sScriptMgr->OnItemRemove(this, pItem);
if (bag == INVENTORY_SLOT_BAG_0)
{
SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0);

View File

@@ -691,6 +691,15 @@ bool ScriptMgr::OnItemExpire(Player* player, ItemTemplate const* proto)
return tmpscript->OnExpire(player, proto);
}
bool ScriptMgr::OnItemRemove(Player* player, Item* item)
{
ASSERT(player);
ASSERT(item);
GET_SCRIPT_RET(ItemScript, item->GetScriptId(), tmpscript, false);
return tmpscript->OnRemove(player, item);
}
bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Creature* target)
{
ASSERT(caster);

View File

@@ -388,6 +388,9 @@ class ItemScript : public ScriptObject
// Called when the item expires (is destroyed).
virtual bool OnExpire(Player* /*player*/, ItemTemplate const* /*proto*/) { return false; }
// Called when the item is destroyed.
virtual bool OnRemove(Player* /*player*/, Item* /*item*/) { return false; }
};
class UnitScript : public ScriptObject
@@ -918,6 +921,7 @@ class ScriptMgr
bool OnQuestAccept(Player* player, Item* item, Quest const* quest);
bool OnItemUse(Player* player, Item* item, SpellCastTargets const& targets);
bool OnItemExpire(Player* player, ItemTemplate const* proto);
bool OnItemRemove(Player* player, Item* item);
public: /* CreatureScript */