Fix bot strategy activation blocked by throttle and death recovery

Solo strategy activation (rest, solo_combat, quest, grind, loot, solo)
was positioned after both the AI update throttler and the death recovery
guard in UpdateAI(). Bots that were throttled or dead at login never
reached the activation code, leaving them with Strategies=0 and idle.

Move the one-time strategy activation to run before all guards so it
executes on the first UpdateAI tick regardless of throttle/death state.
This commit is contained in:
luis
2026-03-16 20:21:29 -03:00
parent 0a3a69b19e
commit 78782bc6f3
+29 -33
View File
@@ -648,6 +648,35 @@ void BotAI::UpdateAI(uint32 diff)
auto startTime = std::chrono::high_resolution_clock::now();
_performanceMetrics.totalUpdates++;
// ========================================================================
// SOLO STRATEGY ACTIVATION - Once per bot after first login
// ========================================================================
// MUST run BEFORE throttle/budget/deathRecovery checks to ensure strategies
// get activated. Dead bots still need strategies so they can act once revived.
if (!_bot->GetGroup() && !_soloStrategiesActivated)
{
TC_LOG_INFO("module.playerbot.ai", "ACTIVATING SOLO STRATEGIES: Bot {} (not in group, first UpdateAI)", _bot->GetName());
ActivateStrategy("rest");
ActivateStrategy("solo_combat");
if (!_instanceOnlyMode)
{
ActivateStrategy("quest");
ActivateStrategy("grind");
ActivateStrategy("loot");
ActivateStrategy("solo");
}
else
{
TC_LOG_INFO("module.playerbot.ai", "Bot {} is JIT/Instance-Only - Skipping quest/grind/solo strategies", _bot->GetName());
}
_soloStrategiesActivated = true;
TC_LOG_INFO("module.playerbot.ai", "SOLO BOT ACTIVATION COMPLETE: Bot {} - {} strategies active", _bot->GetName(), _activeStrategies.size());
}
// Only run normal AI if NOT in death recovery
if (!isInDeathRecovery)
{
@@ -733,39 +762,6 @@ void BotAI::UpdateAI(uint32 diff)
}
}
// ========================================================================
// SOLO STRATEGY ACTIVATION - Once per bot after first login
// ========================================================================
// For bots not in a group, activate solo-relevant strategies on first UpdateAI() call
// This ensures solo bots have active strategies and can perform autonomous actions
// Group-related strategies (follow, group_combat) are activated in OnGroupJoined()
if (!_bot->GetGroup() && !_soloStrategiesActivated)
{
TC_LOG_DEBUG("module.playerbot.ai", "?? ACTIVATING SOLO STRATEGIES: Bot {} (not in group, first UpdateAI)", _bot->GetName());
// Activate all solo-relevant strategies in priority order:
ActivateStrategy("rest");
ActivateStrategy("solo_combat");
// CRITICAL FIX: Disable questing, grinding, looting and solo behavior for JIT/Instance bots
// They should only defend themselves (solo_combat) and rest while waiting for queues
if (!_instanceOnlyMode)
{
ActivateStrategy("quest");
ActivateStrategy("grind"); // Fallback when quests unavailable (activates via ShouldGrind check)
ActivateStrategy("loot");
ActivateStrategy("solo");
}
else
{
TC_LOG_DEBUG("module.playerbot.ai", "Bot {} is JIT/Instance-Only - Skipping quest/grind/solo strategies", _bot->GetName());
}
_soloStrategiesActivated = true;
TC_LOG_DEBUG("module.playerbot.ai", "? SOLO BOT ACTIVATION COMPLETE: Bot {} - {} strategies active", _bot->GetName(), _activeStrategies.size());
}
// PHASE 0 - Quick Win #3: Periodic group check REMOVED
// Now using event-driven GROUP_JOINED/GROUP_LEFT events for instant reactions
// Events dispatched in BotSession.cpp (GROUP_JOINED) and BotAI.cpp (GROUP_LEFT)