Two BG fixes:
1. BGBotManager::PopulateBattlegroundLocked now counts in-transit bots
(dispatched via SendToBattleground but not yet in bg->GetPlayers())
when calculating empty slots. Without this, both WAIT_JOIN and
IN_PROGRESS population calls thought teams were empty and spawned
full teams, resulting in 20v20 in a 10v10 BG.
2. BattlegroundAI::Update now calls coordinator->AddBot() when a bot
has a coordinator but UNASSIGNED role. This handles late-joining bots
that arrive after the coordinator was created, ensuring they get
proper roles and participate in strategy execution.
Also converts TODO comments to NOTE/DESIGN NOTE across 10 files where
the TODOs described intentional design decisions rather than future work.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: luis <[email protected]>
Establish the lighthouse pattern by moving all TOK-specific runtime behavior
(orb pickup, escort, carrier movement, hunting, defense) from the generic
BattlegroundAI class into TempleOfKotmoguScript. BattlegroundAI now acts as
a thin delegation wrapper via the new IBGScript::ExecuteStrategy() virtual method.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Signed-off-by: luis <[email protected]>
Implement all 6 TOK functions with full orb interaction, role-based
strategy dispatch, combat engagement, escort formations, carrier
movement with center push logic, and survival retreat behavior.
Includes comprehensive null safety, edge case handling, and logging.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Signed-off-by: luis <[email protected]>
The plan is complete and correctly structured. The Planning step is marked `[x]` (complete), and the Implementation step has been replaced with 4 concrete implementation steps.
Here's a summary of the plan:
**4 Implementation Steps (mapping to spec's delivery phases):**
| Step | Scope | ~Lines |
|------|-------|--------|
| **Implement PickupOrb + basic dispatch** | `PickupOrb()` full impl, `ExecuteKotmoguStrategy()` role-based dispatch, header declarations, temporary stubs for 3 new functions | ~150 |
| **Implement HuntEnemyOrbCarrier + DefendOrbCarrier** | Combat engagement: enemy carrier hunting with priority targeting, friendly carrier defense with spatial cache | ~150 |
| **Implement EscortOrbCarrier + ExecuteOrbCarrierMovement** | Escort formations, center push logic with route navigation, defensive hold, ROAMER role completion | ~180 |
| **Polish, edge cases, build verification** | Null safety audit, edge case handling, logging completeness, HEALER_SUPPORT role, code style, final build | ~50 |
**Key design decisions:**
- Each step is independently buildable (stubs for not-yet-implemented functions)
- All implementations follow existing WSG/AB patterns (PickupFlag, ExecuteEscortBehavior, ExecuteDefenderBehavior, etc.)
- Only 2 files modified: `BattlegroundAI.cpp` and `BattlegroundAI.h`
- All coordination layer APIs already exist — the work is purely execution layer
- Verification at each step is "build compiles clean" since there are no automated unit tests for BattlegroundAI
Signed-off-by: luis <[email protected]>
## PRD Summary
The PRD at `.zenflow/tasks/tok-lighthouse-battleground-5045/requirements.md` documents:
**Core Problem:** The TOK coordination layer is ~80% complete (strategy, positions, role management, event tracking) but the execution layer is entirely stubbed out — bots never actually pick up orbs, attack enemies, or move to objectives.
**6 Requirements identified:**
1. **R1: Orb Pickup (Critical)** — Implement actual orb discovery, navigation, and GameObject interaction in `PickupOrb()`
2. **R2: Combat Engagement (Critical)** — Bots must call `Attack()` against enemies, especially enemy orb carriers
3. **R3: Center Push Execution (High)** — Orb carriers must navigate to center zone using pre-calculated routes when strategy dictates
4. **R4: Dynamic Strategy Execution (High)** — `ExecuteKotmoguStrategy()` must branch on the bot's assigned role (ORB_CARRIER, FLAG_ESCORT, NODE_ATTACKER, etc.)
5. **R5: Edge Case Handling (Medium)** — Handle death-with-orb, respawns, multiple bots targeting same orb, null pointers
6. **R6: Logging & Observability (Medium)** — Detailed logs for manual test validation
**Key finding:** The server-side scoring uses 3 concentric area triggers (6/4/2 pts per 5s), not the simplified 2-tier model in the playerbot data file. This is a minor data accuracy issue.
**Files to modify:** Primarily `BattlegroundAI.cpp` and `BattlegroundAI.h`. The coordination layer files are reused as-is.
Signed-off-by: luis <[email protected]>
Establish the lighthouse pattern by moving all TOK-specific runtime behavior
(orb pickup, escort, carrier movement, hunting, defense) from the generic
BattlegroundAI class into TempleOfKotmoguScript. BattlegroundAI now acts as
a thin delegation wrapper via the new IBGScript::ExecuteStrategy() virtual method.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Signed-off-by: luis <[email protected]>
Implement all 6 TOK functions with full orb interaction, role-based
strategy dispatch, combat engagement, escort formations, carrier
movement with center push logic, and survival retreat behavior.
Includes comprehensive null safety, edge case handling, and logging.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Signed-off-by: luis <[email protected]>
The plan is complete and correctly structured. The Planning step is marked `[x]` (complete), and the Implementation step has been replaced with 4 concrete implementation steps.
Here's a summary of the plan:
**4 Implementation Steps (mapping to spec's delivery phases):**
| Step | Scope | ~Lines |
|------|-------|--------|
| **Implement PickupOrb + basic dispatch** | `PickupOrb()` full impl, `ExecuteKotmoguStrategy()` role-based dispatch, header declarations, temporary stubs for 3 new functions | ~150 |
| **Implement HuntEnemyOrbCarrier + DefendOrbCarrier** | Combat engagement: enemy carrier hunting with priority targeting, friendly carrier defense with spatial cache | ~150 |
| **Implement EscortOrbCarrier + ExecuteOrbCarrierMovement** | Escort formations, center push logic with route navigation, defensive hold, ROAMER role completion | ~180 |
| **Polish, edge cases, build verification** | Null safety audit, edge case handling, logging completeness, HEALER_SUPPORT role, code style, final build | ~50 |
**Key design decisions:**
- Each step is independently buildable (stubs for not-yet-implemented functions)
- All implementations follow existing WSG/AB patterns (PickupFlag, ExecuteEscortBehavior, ExecuteDefenderBehavior, etc.)
- Only 2 files modified: `BattlegroundAI.cpp` and `BattlegroundAI.h`
- All coordination layer APIs already exist — the work is purely execution layer
- Verification at each step is "build compiles clean" since there are no automated unit tests for BattlegroundAI
Signed-off-by: luis <[email protected]>
## PRD Summary
The PRD at `.zenflow/tasks/tok-lighthouse-battleground-5045/requirements.md` documents:
**Core Problem:** The TOK coordination layer is ~80% complete (strategy, positions, role management, event tracking) but the execution layer is entirely stubbed out — bots never actually pick up orbs, attack enemies, or move to objectives.
**6 Requirements identified:**
1. **R1: Orb Pickup (Critical)** — Implement actual orb discovery, navigation, and GameObject interaction in `PickupOrb()`
2. **R2: Combat Engagement (Critical)** — Bots must call `Attack()` against enemies, especially enemy orb carriers
3. **R3: Center Push Execution (High)** — Orb carriers must navigate to center zone using pre-calculated routes when strategy dictates
4. **R4: Dynamic Strategy Execution (High)** — `ExecuteKotmoguStrategy()` must branch on the bot's assigned role (ORB_CARRIER, FLAG_ESCORT, NODE_ATTACKER, etc.)
5. **R5: Edge Case Handling (Medium)** — Handle death-with-orb, respawns, multiple bots targeting same orb, null pointers
6. **R6: Logging & Observability (Medium)** — Detailed logs for manual test validation
**Key finding:** The server-side scoring uses 3 concentric area triggers (6/4/2 pts per 5s), not the simplified 2-tier model in the playerbot data file. This is a minor data accuracy issue.
**Files to modify:** Primarily `BattlegroundAI.cpp` and `BattlegroundAI.h`. The coordination layer files are reused as-is.
Signed-off-by: luis <[email protected]>
Establish the lighthouse pattern by moving all TOK-specific runtime behavior
(orb pickup, escort, carrier movement, hunting, defense) from the generic
BattlegroundAI class into TempleOfKotmoguScript. BattlegroundAI now acts as
a thin delegation wrapper via the new IBGScript::ExecuteStrategy() virtual method.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Signed-off-by: luis <[email protected]>
Implement all 6 TOK functions with full orb interaction, role-based
strategy dispatch, combat engagement, escort formations, carrier
movement with center push logic, and survival retreat behavior.
Includes comprehensive null safety, edge case handling, and logging.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Signed-off-by: luis <[email protected]>
Work-in-progress from recovery-refactoring-work branch including:
- GameSystemsManager interface and implementation
- CombatCoordinationIntegrator scaffolding
- BotAI and BotMessage header updates
- CMakeLists.txt updates for new files
- Subsystem registry refactoring task spec and documentation
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: luis <[email protected]>
The plan is complete and correctly structured. The Planning step is marked `[x]` (complete), and the Implementation step has been replaced with 4 concrete implementation steps.
Here's a summary of the plan:
**4 Implementation Steps (mapping to spec's delivery phases):**
| Step | Scope | ~Lines |
|------|-------|--------|
| **Implement PickupOrb + basic dispatch** | `PickupOrb()` full impl, `ExecuteKotmoguStrategy()` role-based dispatch, header declarations, temporary stubs for 3 new functions | ~150 |
| **Implement HuntEnemyOrbCarrier + DefendOrbCarrier** | Combat engagement: enemy carrier hunting with priority targeting, friendly carrier defense with spatial cache | ~150 |
| **Implement EscortOrbCarrier + ExecuteOrbCarrierMovement** | Escort formations, center push logic with route navigation, defensive hold, ROAMER role completion | ~180 |
| **Polish, edge cases, build verification** | Null safety audit, edge case handling, logging completeness, HEALER_SUPPORT role, code style, final build | ~50 |
**Key design decisions:**
- Each step is independently buildable (stubs for not-yet-implemented functions)
- All implementations follow existing WSG/AB patterns (PickupFlag, ExecuteEscortBehavior, ExecuteDefenderBehavior, etc.)
- Only 2 files modified: `BattlegroundAI.cpp` and `BattlegroundAI.h`
- All coordination layer APIs already exist — the work is purely execution layer
- Verification at each step is "build compiles clean" since there are no automated unit tests for BattlegroundAI
Signed-off-by: luis <[email protected]>
## PRD Summary
The PRD at `.zenflow/tasks/tok-lighthouse-battleground-5045/requirements.md` documents:
**Core Problem:** The TOK coordination layer is ~80% complete (strategy, positions, role management, event tracking) but the execution layer is entirely stubbed out — bots never actually pick up orbs, attack enemies, or move to objectives.
**6 Requirements identified:**
1. **R1: Orb Pickup (Critical)** — Implement actual orb discovery, navigation, and GameObject interaction in `PickupOrb()`
2. **R2: Combat Engagement (Critical)** — Bots must call `Attack()` against enemies, especially enemy orb carriers
3. **R3: Center Push Execution (High)** — Orb carriers must navigate to center zone using pre-calculated routes when strategy dictates
4. **R4: Dynamic Strategy Execution (High)** — `ExecuteKotmoguStrategy()` must branch on the bot's assigned role (ORB_CARRIER, FLAG_ESCORT, NODE_ATTACKER, etc.)
5. **R5: Edge Case Handling (Medium)** — Handle death-with-orb, respawns, multiple bots targeting same orb, null pointers
6. **R6: Logging & Observability (Medium)** — Detailed logs for manual test validation
**Key finding:** The server-side scoring uses 3 concentric area triggers (6/4/2 pts per 5s), not the simplified 2-tier model in the playerbot data file. This is a minor data accuracy issue.
**Files to modify:** Primarily `BattlegroundAI.cpp` and `BattlegroundAI.h`. The coordination layer files are reused as-is.
Signed-off-by: luis <[email protected]>
Recovery Documentation:
- Complete recovery status documented
- All merge conflicts resolved
- Build verification successful
- 13 obsolete file references removed from CMakeLists.txt
New File:
- AuraEventBus.h: Type alias for generic EventBus<AuraEvent>
- Part of refactoring to consolidate event bus system
Signed-off-by: luis <[email protected]>
Resolved 4 conflicted files from git stash pop:
1. CooldownEvents.cpp/h: Took stashed version with better inline comments
- "Major CDs are high priority" comment preserved
- "Short expiry for coordination" comment preserved
- Better documentation for MajorCooldownTier enum
2. CMakeLists.txt: Merged both versions intelligently
- Kept Messaging files (buildable)
- Added Phase 3 audit comment block documenting Arena/Raid discovery
- Arena/Raid NOT included yet (stale APIs per audit)
3. PlayerbotModule.cpp: No actual conflicts (identical in both versions)
- Took upstream version
This preserves both:
- Work from the other Claude Code instance (refactoring)
- Stashed work containing improved comments and documentation
Recovery Status: Merge conflicts resolved, ready for continuation
Signed-off-by: luis <[email protected]>
- Complete root cause analysis with log evidence
- Technical deep dive into QueueStatePoller workflow
- Before/after comparison showing 32x overhead reduction
- Testing recommendations and monitoring guidelines
- Lessons learned and future improvements
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
CRITICAL BUG FIX - Resolves 32x bot overhead issue (629 bots instead of 19)
Root Cause:
- QueueStatePoller continued polling BG queues AFTER battleground started
- Detected "empty queue" as shortage every 5 seconds during gameplay
- Spawned hundreds of warm pool bots continuously during BG preparation/combat
- Human player GUID became Empty after entering BG, but spawning continued
The Fix:
1. Unregister BG queue from QueueStatePoller when BG starts
2. Unregister when last human leaves queue (before BG starts)
3. Prevents infinite spawning loop during active gameplay
Changes:
- BGBotManager::OnBattlegroundStart() - Call UnregisterActiveBGQueue()
- BGBotManager::OnPlayerLeaveQueue() - Check if last human, unregister queue
Impact:
- Fixes bot explosion from 19 ordered → 629 spawned
- Prevents warm pool exhaustion during single BG
- Stops session creation spam hitting bot limit
Testing:
- Verified build successful
- Log analysis confirmed continuous spawning pattern
- Fix targets exact polling mechanism causing issue
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
1. Warm Pool Bot BG Invitation Tracking:
- Add humanPlayerGuid tracking to InstanceBotSlot
- Propagate humanPlayerGuid through QueueStatePoller → AssignForBattleground → AssignBot → WarmUpBot
- Add GetQueuedHumanForBG() to BGBotManager for finding queued human players
- Enables proper BG invitation handling for warm pool bots
2. Temple of Kotmogu Dynamic Position Discovery:
- Fix game object entry IDs (212091-212094, not 212093-212096)
- Blue=212091, Purple=212092, Green=212093, Orange=212094
- Fixes dynamic orb discovery so bots move to correct positions
- Update fallback positions to correct Z level (~13, not ~29)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
Removes 1,526 LOC of pure delegation code by replacing wrapper classes with
direct GenericEventBus<T> template usage. All EventBus calls now go through
EventBus<XxxEvent>::instance() instead of XxxEventBus::instance().
EventBus Wrapper Removal:
- Deleted 12 wrapper classes (AuctionEventBus, AuraEventBus, CombatEventBus,
CooldownEventBus, GroupEventBus, InstanceEventBus, LootEventBus, NPCEventBus,
ProfessionEventBus, QuestEventBus, ResourceEventBus, SocialEventBus)
- Updated ~160 references across 29 files
- Replaced all SubscribeAll() calls with inline type enumeration loops
- Removed no-op GroupEventBus::ClearGroupEvents() calls
- Updated all PublishEvent/Subscribe/Unsubscribe calls to use template directly
DI Interface Cleanup (from previous session):
- Removed 100+ unused DI interface files from Core/DI/Interfaces/
- Removed ServiceContainer and ServiceRegistration (unused DI framework)
- All components now use direct singleton instances (sComponentName pattern)
- Maintained backward compatibility for all existing functionality
Build verified successful. Zero runtime impact - same template instantiations,
same performance, cleaner architecture.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
126 PublishEvent() calls were queuing events that were never processed, causing
unbounded memory growth. Added ProcessEvents() calls for Combat, Loot, Quest, Aura,
Cooldown, Resource, Social, Auction, NPC, Instance, and Profession event buses.
Events are now properly dispatched to BotAI handlers (987 LOC in BotAI_EventHandlers.cpp).
Includes queue health monitoring (60s intervals) and performance metrics integration.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
Complete the DI interface cleanup by adding missing fields and methods
that were previously defined in removed interface headers:
- ArenaBotManager.h: Add SKIRMISH_2v2/3v3 to ArenaBracketType enum
- InstanceCoordination.h: Add fields to InstanceProgress and
CoordinationMetrics (progressPercentage, isOnTrack, collectedLoot,
coordinationEvents, movementEfficiency, averageResponseTime, etc.)
- DungeonBehavior.h: Add averageCompletionTime and encounterWipes to
AtomicDungeonMetrics
- EncounterStrategy.h: Change strategy fields from strings to
StrategyCallback functions, add canMoveDuringCast to DpsStrategy
- DungeonScriptMgr.h: Define ScriptStats struct locally
- ArenaAI.h: Add rating, pillarKites, successfulBursts to ArenaMetrics
- PvPCombatAI.h: Add ccChainsExecuted, interruptsLanded to PvPMetrics
- ArenaState.h: Add SKIRMISH arena types
Build now succeeds with zero errors.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>