Playerbot: grant quest-source items so item-started quests push to bots
Item-started quests (e.g. item 1307 'Gold Pickup Schedule' -> quest 123 'The Collector') require the source item in the bag for CanAddQuest to pass, but the module only copied quest-OBJECTIVE items — so the push was skipped with '(CanAddQuest)' and the bots never got the quest. - GiveQuestItem (loot path): when the owner loots an item whose template starts a quest (GetStartQuest()>0), grant one to each bot. - TryPushQuestToBot (accept path): backstop — grant the quest's SrcItemId if the bot lacks it before the CanAddQuest check.
This commit is contained in:
@@ -2982,11 +2982,26 @@ static bool GiveQuestItem(Player* bot, uint32 itemId, uint32 count)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Quest-SOURCE item: starts a quest when used (e.g. item 1307 "Gold
|
||||||
|
// Pickup Schedule" → quest 123 "The Collector"). It's not an objective,
|
||||||
|
// but the bot needs it in the bag for CanAddQuest to pass once the quest
|
||||||
|
// is pushed — grant one when the owner loots it.
|
||||||
if (need == 0)
|
if (need == 0)
|
||||||
{
|
{
|
||||||
TC_LOG_ERROR("playerbot.v2",
|
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId);
|
||||||
"[QuestItemCopy] NONEED {} item={}", bot->GetName(), itemId);
|
if (proto && proto->GetStartQuest() > 0 &&
|
||||||
return false;
|
bot->GetItemCount(itemId, false) == 0)
|
||||||
|
{
|
||||||
|
if (bot->AddItem(itemId, 1))
|
||||||
|
TC_LOG_ERROR("playerbot.v2",
|
||||||
|
"[QuestItemCopy] OK {} +1x source item={} (starts quest {})",
|
||||||
|
bot->GetName(), itemId, proto->GetStartQuest());
|
||||||
|
else
|
||||||
|
TC_LOG_ERROR("playerbot.v2",
|
||||||
|
"[QuestItemCopy] FAIL {} source item={} (bag full)",
|
||||||
|
bot->GetName(), itemId);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have >= need)
|
if (have >= need)
|
||||||
@@ -3260,6 +3275,22 @@ static bool TryPushQuestToBot(Player* bot, Player* owner, uint32 quest_id)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Quest started from an item: CanAddQuest requires the source item in the
|
||||||
|
// bag (e.g. item 1307 → quest 123). Backstop for the loot-copy path — if
|
||||||
|
// the bot never picked up the source item, grant it now.
|
||||||
|
if (uint32 const srcId = botQuest->GetSrcItemId(); srcId > 0 &&
|
||||||
|
bot->GetItemCount(srcId, false) == 0)
|
||||||
|
{
|
||||||
|
if (bot->AddItem(srcId, 1))
|
||||||
|
TC_LOG_ERROR("playerbot.v2",
|
||||||
|
"[OnAcceptQuest] {} +1x source item={} for quest {}",
|
||||||
|
bot->GetName(), srcId, botQuestId);
|
||||||
|
else
|
||||||
|
TC_LOG_ERROR("playerbot.v2",
|
||||||
|
"[OnAcceptQuest] {} source item={} grant failed (bag full)",
|
||||||
|
bot->GetName(), srcId);
|
||||||
|
}
|
||||||
|
|
||||||
if (!bot->CanAddQuest(botQuest, false))
|
if (!bot->CanAddQuest(botQuest, false))
|
||||||
{
|
{
|
||||||
TC_LOG_ERROR("playerbot.v2",
|
TC_LOG_ERROR("playerbot.v2",
|
||||||
|
|||||||
Reference in New Issue
Block a user