Playerbot: abandon the bot's class-equivalent quest when owner abandons
OnAbandonQuest was checking/removing the owner's raw quest_id on the bots, but bots hold the class/race VARIANT (ResolveBotQuestId, same as OnAcceptQuest). For variants like 28767 -> 28763 the status check hit NONE and the bot kept the quest. Resolve the bot's equivalent before taking source items / removing the active quest, and use the variant's template for timed/PvP cleanup.
This commit is contained in:
@@ -3407,7 +3407,6 @@ void Module::OnAbandonQuest(Player* player, uint32 quest_id)
|
||||
{
|
||||
if (!initialized_ || !player) return;
|
||||
if (player->GetSession()->IsBot()) return;
|
||||
Quest const* quest = sObjectMgr->GetQuestTemplate(quest_id);
|
||||
WorldSession* sess = player->GetSession();
|
||||
if (!sess) return;
|
||||
uint32 const account_id = sess->GetAccountId();
|
||||
@@ -3422,28 +3421,35 @@ void Module::OnAbandonQuest(Player* player, uint32 quest_id)
|
||||
ObjectGuid::Create<HighGuid::Player>(id));
|
||||
if (!bot || !bot->IsInWorld()) continue;
|
||||
|
||||
QuestStatus const st = bot->GetQuestStatus(quest_id);
|
||||
// Bots hold the class/race VARIANT of the owner's quest (same
|
||||
// resolution used by OnAcceptQuest) — abandoning by the raw owner id
|
||||
// misses those, leaving the bot stuck with a quest the owner dropped.
|
||||
uint32 const botQuestId = ResolveBotQuestId(bot, quest_id);
|
||||
if (!botQuestId)
|
||||
continue;
|
||||
|
||||
QuestStatus const st = bot->GetQuestStatus(botQuestId);
|
||||
if (st != QUEST_STATUS_INCOMPLETE &&
|
||||
st != QUEST_STATUS_COMPLETE &&
|
||||
st != QUEST_STATUS_FAILED)
|
||||
continue;
|
||||
|
||||
// Mirror TC HandleQuestLogRemoveQuest
|
||||
bot->TakeQuestSourceItem(quest_id, true);
|
||||
bot->RemoveActiveQuest(quest_id);
|
||||
if (quest)
|
||||
bot->TakeQuestSourceItem(botQuestId, true);
|
||||
bot->RemoveActiveQuest(botQuestId);
|
||||
if (Quest const* botQuest = sObjectMgr->GetQuestTemplate(botQuestId))
|
||||
{
|
||||
if (quest->GetLimitTime())
|
||||
bot->RemoveTimedQuest(quest_id);
|
||||
if (quest->HasFlag(QUEST_FLAGS_FLAGS_PVP))
|
||||
if (botQuest->GetLimitTime())
|
||||
bot->RemoveTimedQuest(botQuestId);
|
||||
if (botQuest->HasFlag(QUEST_FLAGS_FLAGS_PVP))
|
||||
{
|
||||
bot->pvpInfo.IsHostile =
|
||||
bot->pvpInfo.IsInHostileArea || bot->HasPvPForcingQuest();
|
||||
bot->UpdatePvPState();
|
||||
}
|
||||
}
|
||||
bot->SendForceSpawnTrackingUpdate(quest_id);
|
||||
bot->AbandonQuest(quest_id); // destroy BIND_QUEST items
|
||||
bot->SendForceSpawnTrackingUpdate(botQuestId);
|
||||
bot->AbandonQuest(botQuestId); // destroy BIND_QUEST items
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user