mirror of
https://github.com/mangosfour/server.git
synced 2025-12-29 07:37:05 +00:00
[11979] Remove ReqSourceItems when rewarding or abandoning a quest
Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
parent
24574b000e
commit
c17fdc3093
4 changed files with 127 additions and 48 deletions
|
|
@ -11177,7 +11177,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo
|
|||
else if (Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ))
|
||||
{
|
||||
pBag->StoreItem( slot, pItem, update );
|
||||
if( IsInWorld() && update )
|
||||
if (IsInWorld() && update)
|
||||
{
|
||||
pItem->AddToWorld();
|
||||
pItem->SendCreateUpdateToPlayer( this );
|
||||
|
|
@ -11293,7 +11293,7 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update )
|
|||
}
|
||||
}
|
||||
|
||||
if( IsInWorld() && update )
|
||||
if (IsInWorld() && update)
|
||||
{
|
||||
pItem->AddToWorld();
|
||||
pItem->SendCreateUpdateToPlayer( this );
|
||||
|
|
@ -11315,12 +11315,12 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update )
|
|||
else
|
||||
{
|
||||
pItem2->SetCount( pItem2->GetCount() + pItem->GetCount() );
|
||||
if( IsInWorld() && update )
|
||||
if (IsInWorld() && update)
|
||||
pItem2->SendCreateUpdateToPlayer( this );
|
||||
|
||||
// delete item (it not in any slot currently)
|
||||
//pItem->DeleteFromDB();
|
||||
if( IsInWorld() && update )
|
||||
if (IsInWorld() && update)
|
||||
{
|
||||
pItem->RemoveFromWorld();
|
||||
pItem->DestroyForPlayer( this );
|
||||
|
|
@ -11618,7 +11618,7 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update )
|
|||
else if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ))
|
||||
pBag->RemoveItem(slot, update);
|
||||
|
||||
if( IsInWorld() && update )
|
||||
if (IsInWorld() && update)
|
||||
{
|
||||
pItem->RemoveFromWorld();
|
||||
pItem->DestroyForPlayer(this);
|
||||
|
|
@ -11631,15 +11631,15 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update )
|
|||
}
|
||||
}
|
||||
|
||||
void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check)
|
||||
void Player::DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check, bool inBankAlso)
|
||||
{
|
||||
DEBUG_LOG( "STORAGE: DestroyItemCount item = %u, count = %u", item, count);
|
||||
DEBUG_LOG("STORAGE: DestroyItemCount item = %u, count = %u", item, count);
|
||||
uint32 remcount = 0;
|
||||
|
||||
// in inventory
|
||||
for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
|
||||
for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
|
||||
{
|
||||
if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||
{
|
||||
if (pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
|
|
@ -11647,17 +11647,17 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
|
|||
{
|
||||
// all items in inventory can unequipped
|
||||
remcount += pItem->GetCount();
|
||||
DestroyItem( INVENTORY_SLOT_BAG_0, i, update);
|
||||
DestroyItem(INVENTORY_SLOT_BAG_0, i, update);
|
||||
|
||||
if (remcount >= count)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount );
|
||||
pItem->SetCount( pItem->GetCount() - count + remcount );
|
||||
if (IsInWorld() & update)
|
||||
pItem->SendCreateUpdateToPlayer( this );
|
||||
ItemRemovedQuestCheck(pItem->GetEntry(), count - remcount);
|
||||
pItem->SetCount(pItem->GetCount() - count + remcount);
|
||||
if (IsInWorld() && update)
|
||||
pItem->SendCreateUpdateToPlayer(this);
|
||||
pItem->SetState(ITEM_CHANGED, this);
|
||||
return;
|
||||
}
|
||||
|
|
@ -11665,9 +11665,9 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
|
|||
}
|
||||
}
|
||||
|
||||
for(int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
|
||||
for (int i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i)
|
||||
{
|
||||
if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||
{
|
||||
if (pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
|
|
@ -11675,17 +11675,17 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
|
|||
{
|
||||
// all keys can be unequipped
|
||||
remcount += pItem->GetCount();
|
||||
DestroyItem( INVENTORY_SLOT_BAG_0, i, update);
|
||||
DestroyItem(INVENTORY_SLOT_BAG_0, i, update);
|
||||
|
||||
if (remcount >= count)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount );
|
||||
pItem->SetCount( pItem->GetCount() - count + remcount );
|
||||
if (IsInWorld() & update)
|
||||
pItem->SendCreateUpdateToPlayer( this );
|
||||
ItemRemovedQuestCheck(pItem->GetEntry(), count - remcount);
|
||||
pItem->SetCount(pItem->GetCount() - count + remcount);
|
||||
if (IsInWorld() && update)
|
||||
pItem->SendCreateUpdateToPlayer(this);
|
||||
pItem->SetState(ITEM_CHANGED, this);
|
||||
return;
|
||||
}
|
||||
|
|
@ -11694,13 +11694,13 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
|
|||
}
|
||||
|
||||
// in inventory bags
|
||||
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
{
|
||||
if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||
{
|
||||
for(uint32 j = 0; j < pBag->GetBagSize(); ++j)
|
||||
for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
|
||||
{
|
||||
if(Item* pItem = pBag->GetItemByPos(j))
|
||||
if (Item* pItem = pBag->GetItemByPos(j))
|
||||
{
|
||||
if (pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
|
|
@ -11708,17 +11708,17 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
|
|||
if (pItem->GetCount() + remcount <= count)
|
||||
{
|
||||
remcount += pItem->GetCount();
|
||||
DestroyItem( i, j, update );
|
||||
DestroyItem(i, j, update);
|
||||
|
||||
if (remcount >= count)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount );
|
||||
pItem->SetCount( pItem->GetCount() - count + remcount );
|
||||
ItemRemovedQuestCheck(pItem->GetEntry(), count - remcount);
|
||||
pItem->SetCount(pItem->GetCount() - count + remcount);
|
||||
if (IsInWorld() && update)
|
||||
pItem->SendCreateUpdateToPlayer( this );
|
||||
pItem->SendCreateUpdateToPlayer(this);
|
||||
pItem->SetState(ITEM_CHANGED, this);
|
||||
return;
|
||||
}
|
||||
|
|
@ -11729,18 +11729,18 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
|
|||
}
|
||||
|
||||
// in equipment and bag list
|
||||
for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
{
|
||||
if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||
{
|
||||
if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
if (pItem->GetCount() + remcount <= count)
|
||||
{
|
||||
if (!unequip_check || CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false) == EQUIP_ERR_OK )
|
||||
if (!unequip_check || CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false) == EQUIP_ERR_OK)
|
||||
{
|
||||
remcount += pItem->GetCount();
|
||||
DestroyItem( INVENTORY_SLOT_BAG_0, i, update);
|
||||
DestroyItem(INVENTORY_SLOT_BAG_0, i, update);
|
||||
|
||||
if (remcount >= count)
|
||||
return;
|
||||
|
|
@ -11748,16 +11748,75 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
|
|||
}
|
||||
else
|
||||
{
|
||||
ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount );
|
||||
pItem->SetCount( pItem->GetCount() - count + remcount );
|
||||
if (IsInWorld() & update)
|
||||
pItem->SendCreateUpdateToPlayer( this );
|
||||
ItemRemovedQuestCheck(pItem->GetEntry(), count - remcount);
|
||||
pItem->SetCount(pItem->GetCount() - count + remcount);
|
||||
if (IsInWorld() && update)
|
||||
pItem->SendCreateUpdateToPlayer(this);
|
||||
pItem->SetState(ITEM_CHANGED, this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inBankAlso) // Remove items from bank as well
|
||||
{
|
||||
for (int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i)
|
||||
{
|
||||
Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i);
|
||||
if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
if (pItem->GetCount() + remcount <= count)
|
||||
{
|
||||
remcount += pItem->GetCount();
|
||||
DestroyItem(INVENTORY_SLOT_BAG_0, i, update);
|
||||
|
||||
if (remcount >= count)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemRemovedQuestCheck(pItem->GetEntry(), count - remcount);
|
||||
pItem->SetCount(pItem->GetCount() - count + remcount);
|
||||
if (IsInWorld() && update)
|
||||
pItem->SendCreateUpdateToPlayer(this);
|
||||
pItem->SetState(ITEM_CHANGED, this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
|
||||
{
|
||||
if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||
{
|
||||
for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
|
||||
{
|
||||
Item* pItem = pBag->GetItemByPos(j);
|
||||
if (pItem && pItem->GetEntry() == item && !pItem->IsInTrade())
|
||||
{
|
||||
if (pItem->GetCount() + remcount <= count)
|
||||
{
|
||||
remcount += pItem->GetCount();
|
||||
DestroyItem(i, j, update);
|
||||
|
||||
if (remcount >= count)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemRemovedQuestCheck(pItem->GetEntry(), count - remcount);
|
||||
pItem->SetCount(pItem->GetCount() - count + remcount);
|
||||
if (IsInWorld() && update)
|
||||
pItem->SendCreateUpdateToPlayer(this);
|
||||
pItem->SetState(ITEM_CHANGED, this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::DestroyZoneLimitedItem( bool update, uint32 new_zone )
|
||||
|
|
@ -11835,7 +11894,7 @@ void Player::DestroyItemCount( Item* pItem, uint32 &count, bool update )
|
|||
ItemRemovedQuestCheck( pItem->GetEntry(), count);
|
||||
pItem->SetCount( pItem->GetCount() - count );
|
||||
count = 0;
|
||||
if( IsInWorld() & update )
|
||||
if (IsInWorld() && update)
|
||||
pItem->SendCreateUpdateToPlayer( this );
|
||||
pItem->SetState(ITEM_CHANGED, this);
|
||||
}
|
||||
|
|
@ -13958,12 +14017,22 @@ void Player::RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver,
|
|||
{
|
||||
uint32 quest_id = pQuest->GetQuestId();
|
||||
|
||||
for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i )
|
||||
for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
|
||||
{
|
||||
if (pQuest->ReqItemId[i])
|
||||
DestroyItemCount(pQuest->ReqItemId[i], pQuest->ReqItemCount[i], true);
|
||||
}
|
||||
|
||||
for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
|
||||
{
|
||||
if (pQuest->ReqSourceId[i])
|
||||
{
|
||||
ItemPrototype const* iProto = ObjectMgr::GetItemPrototype(pQuest->ReqSourceId[i]);
|
||||
if (iProto && iProto->Bonding == BIND_QUEST_ITEM)
|
||||
DestroyItemCount(pQuest->ReqSourceId[i], pQuest->ReqSourceCount[i], true, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
RemoveTimedQuest(quest_id);
|
||||
|
||||
if (BattleGround* bg = GetBattleGround())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue