PHP код:
--- Item.cpp
+++ Item.cpp
@@ -275,15 +275,20 @@
{
if (!GetUInt32Value(ITEM_FIELD_DURATION))
return;
//DEBUG_LOG("Item::UpdateDuration Item (Entry: %u Duration %u Diff %u)",GetEntry(),GetUInt32Value(ITEM_FIELD_DURATION),diff);
- if (GetUInt32Value(ITEM_FIELD_DURATION)<=diff)
+ if (GetUInt32Value(ITEM_FIELD_DURATION) <= diff)
{
- owner->DestroyItem(GetBagSlot(), GetSlot(), true);
+ uint32 itemId = GetEntry();
+ uint8 bagSlot = GetBagSlot();
+ uint8 slot = GetSlot();
+ uint16 pos = GetPos();
+ owner->DestroyItem(bagSlot, slot, true);
+ owner->HandleDestroyItemReplace(itemId, bagSlot, slot, pos);
return;
}
SetUInt32Value(ITEM_FIELD_DURATION, GetUInt32Value(ITEM_FIELD_DURATION) - diff);
SetState(ITEM_CHANGED, owner); // save new time in database
}
--- Player.cpp
+++ Player.cpp
@@ -11539,12 +11539,69 @@
pItem->SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid());
pItem->SetSlot( NULL_SLOT );
pItem->SetState(ITEM_REMOVED, this);
}
}
+void Player::HandleDestroyItemReplace(uint32 itemId, uint8 bag, uint8 slot, uint16 pos)
+{
+ if (!itemId || !bag || !slot)
+ return;
+
+ uint32 newItemId;
+ switch(itemId)
+ {
+ case 39878: // Mysterious Unhatched Egg
+ newItemId = 39883; // Cracked Egg
+ break;
+ case 44623: // Bottle of Dalaran Red
+ newItemId = 44625;
+ break;
+ case 44625: // Bottle of Aged Dalaran Red
+ newItemId = 44627; // Bottle of Peaked Dalaran Red
+ break;
+ case 44626: // Cask of Aged Dalaran Red
+ newItemId = 44629; // Cask of Peaked Dalaran Red
+ break;
+ case 44632: // Cask of Dalaran Red
+ newItemId = 44626;
+ break;
+ case 44717: // Disgusting Jar
+ newItemId = 44718; // Ripe Disgusting Jar
+ break;
+ default:
+ return;
+ }
+
+ ItemPosCountVec dest;
+ if (IsInventoryPos(pos))
+ {
+ uint8 msg = CanStoreNewItem(bag, slot, dest, newItemId, 1);
+ if (msg == EQUIP_ERR_OK)
+ {
+ StoreNewItem(dest, newItemId, 1, true);
+ return;
+ }
+ }
+ else if (IsBankPos(pos))
+ {
+ Item* pNewItem = Item::CreateItem(newItemId, 1, this);
+ if (!pNewItem)
+ return;
+
+ uint8 msg = CanBankItem(bag, slot, dest, pNewItem, true);
+ if (msg == EQUIP_ERR_OK)
+ {
+ BankItem(dest, pNewItem, true);
+ return;
+ }
+ else
+ delete pNewItem;
+ }
+}
+
void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check)
{
DEBUG_LOG( "STORAGE: DestroyItemCount item = %u, count = %u", item, count);
uint32 remcount = 0;
// in inventory
--- Player.h
+++ Player.h
@@ -1258,12 +1258,13 @@
void MoveItemFromInventory(uint8 bag, uint8 slot, bool update);
// in trade, auction, guild bank, mail....
void MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB = false);
// in trade, guild bank, mail....
void RemoveItemDependentAurasAndCasts( Item * pItem );
void DestroyItem( uint8 bag, uint8 slot, bool update );
+ void HandleDestroyItemReplace(uint32 itemId, uint8 bag, uint8 slot, uint16 pos);
void DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check = false);
void DestroyItemCount( Item* item, uint32& count, bool update );
void DestroyConjuredItems( bool update );
void DestroyZoneLimitedItem( bool update, uint32 new_zone );
void SplitItem( uint16 src, uint16 dst, uint32 count );
void SwapItem( uint16 src, uint16 dst );