fix(instance): Disable QuestStrategy for instance bots

Instance bots (JIT bots for BG/dungeon) should NEVER run quest behavior.
This was causing crashes when:
1. Bot worker thread calls QuestAcceptanceManager::AcceptQuest
2. SmartAI::OnQuestAccept is triggered
3. SmartScript (not thread-safe) crashes with memory corruption

Fix: Check IsInstanceBot() in both IsActive() and GetRelevance() to
completely disable quest strategy for instance bots.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
This commit is contained in:
agatho
2026-02-04 20:23:22 -03:00
committed by luis
co-authored by Claude Opus 4.5
parent 5d09867066
commit b8baf73d19
@@ -12,6 +12,7 @@
#include "Core/DI/Interfaces/IObjectiveTracker.h" // ObjectivePriority
#include "../BotAI.h"
#include "Player.h"
#include "../../Session/BotSession.h" // For IsInstanceBot check
#include "Group.h"
#include "QuestDef.h"
#include "ObjectAccessor.h"
@@ -91,6 +92,15 @@ bool QuestStrategy::IsActive(BotAI* ai) const
return false;
Player* bot = ai->GetBot();
// CRITICAL: Instance bots should NEVER quest - they exist only for BG/dungeon
// This prevents SmartAI thread-safety crashes when accepting quests from worker threads
if (BotSession* session = dynamic_cast<BotSession*>(bot->GetSession()))
{
if (session->IsInstanceBot())
return false;
}
// NOT active during combat (combat takes priority)
if (bot->IsInCombat())
return false;
@@ -107,6 +117,14 @@ float QuestStrategy::GetRelevance(BotAI* ai) const
return 0.0f;
Player* bot = ai->GetBot();
// Instance bots should NEVER quest - return 0 relevance
if (BotSession* session = dynamic_cast<BotSession*>(bot->GetSession()))
{
if (session->IsInstanceBot())
return 0.0f;
}
// Combat has higher priority - return 0 if in combat
if (bot->IsInCombat())
return 0.0f;