diff --git a/src/modules/PlayerbotV2/PlayerbotV2.cpp b/src/modules/PlayerbotV2/PlayerbotV2.cpp index 037b4b8d63..91dd3933a9 100644 --- a/src/modules/PlayerbotV2/PlayerbotV2.cpp +++ b/src/modules/PlayerbotV2/PlayerbotV2.cpp @@ -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) { - TC_LOG_ERROR("playerbot.v2", - "[QuestItemCopy] NONEED {} item={}", bot->GetName(), itemId); - return false; + ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId); + if (proto && proto->GetStartQuest() > 0 && + 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) @@ -3260,6 +3275,22 @@ static bool TryPushQuestToBot(Player* bot, Player* owner, uint32 quest_id) 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)) { TC_LOG_ERROR("playerbot.v2",