mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[11438] Clarify code for quest start/source/req items adding/remove at quest start.
* Fix problem with complete quest when quest start item == quest source item. And source item not have max items amount setting. * Avoid remove start item for case when it will re-added at next code line as source item
This commit is contained in:
parent
1cd48649c2
commit
a5fe00d6f6
4 changed files with 37 additions and 33 deletions
|
|
@ -13512,7 +13512,7 @@ bool Player::CanAddQuest(Quest const *pQuest, bool msg) const
|
|||
if (!SatisfyQuestLog(msg))
|
||||
return false;
|
||||
|
||||
if (!CanGiveQuestSourceItem(pQuest))
|
||||
if (!CanGiveQuestSourceItemIfNeed(pQuest))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
@ -13726,7 +13726,28 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver )
|
|||
questStatusData.m_creatureOrGOcount[i] = 0;
|
||||
}
|
||||
|
||||
GiveQuestSourceItem(pQuest);
|
||||
// remove start item if not need
|
||||
if (questGiver && questGiver->isType(TYPEID_ITEM))
|
||||
{
|
||||
// destroy not required for quest finish quest starting item
|
||||
bool notRequiredItem = true;
|
||||
for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
|
||||
{
|
||||
if (pQuest->ReqItemId[i] == questGiver->GetEntry())
|
||||
{
|
||||
notRequiredItem = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pQuest->GetSrcItemId() == questGiver->GetEntry())
|
||||
notRequiredItem = false;
|
||||
|
||||
if (notRequiredItem)
|
||||
DestroyItem(((Item*)questGiver)->GetBagSlot(), ((Item*)questGiver)->GetSlot(), true);
|
||||
}
|
||||
|
||||
GiveQuestSourceItemIfNeed(pQuest);
|
||||
|
||||
AdjustQuestReqItemCount( pQuest, questStatusData );
|
||||
|
||||
|
|
@ -14374,14 +14395,18 @@ bool Player::SatisfyQuestMonth(Quest const* qInfo, bool msg) const
|
|||
return m_monthlyquests.find(qInfo->GetQuestId()) == m_monthlyquests.end();
|
||||
}
|
||||
|
||||
bool Player::CanGiveQuestSourceItem( Quest const *pQuest, ItemPosCountVec* dest ) const
|
||||
bool Player::CanGiveQuestSourceItemIfNeed( Quest const *pQuest, ItemPosCountVec* dest) const
|
||||
{
|
||||
uint32 srcitem = pQuest->GetSrcItemId();
|
||||
if (srcitem > 0)
|
||||
if (uint32 srcitem = pQuest->GetSrcItemId())
|
||||
{
|
||||
uint32 count = pQuest->GetSrcItemCount();
|
||||
if( count <= 0 )
|
||||
count = 1;
|
||||
|
||||
// player already have max amount required item (including bank), just report success
|
||||
uint32 has_count = GetItemCount(srcitem, true);
|
||||
if (has_count >= count)
|
||||
return true;
|
||||
|
||||
count -= has_count; // real need amount
|
||||
|
||||
InventoryResult msg;
|
||||
if (!dest)
|
||||
|
|
@ -14394,9 +14419,6 @@ bool Player::CanGiveQuestSourceItem( Quest const *pQuest, ItemPosCountVec* dest
|
|||
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
return true;
|
||||
// player already have max amount required item, just report success
|
||||
else if (msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS)
|
||||
return true;
|
||||
else
|
||||
SendEquipError( msg, NULL, NULL, srcitem );
|
||||
return false;
|
||||
|
|
@ -14405,11 +14427,10 @@ bool Player::CanGiveQuestSourceItem( Quest const *pQuest, ItemPosCountVec* dest
|
|||
return true;
|
||||
}
|
||||
|
||||
void Player::GiveQuestSourceItem( Quest const *pQuest )
|
||||
void Player::GiveQuestSourceItemIfNeed(Quest const *pQuest)
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
|
||||
if (CanGiveQuestSourceItem(pQuest, &dest) && !dest.empty())
|
||||
if (CanGiveQuestSourceItemIfNeed(pQuest, &dest) && !dest.empty())
|
||||
{
|
||||
uint32 count = 0;
|
||||
for(ItemPosCountVec::const_iterator c_itr = dest.begin(); c_itr != dest.end(); ++c_itr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue