1013 lines
26 KiB
Markdown
1013 lines
26 KiB
Markdown
# TrinityCore PlayerBot - Comprehensive Implementation Plan
|
|||
|
|
**Created:** October 12, 2025
|
||
|
|
**Branch:** playerbot-dev
|
||
|
|
**Current Status:** 80% Complete (Phases 1-4 done, Phase 5 85%, Phase 6 not started)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 🎯 EXECUTIVE SUMMARY
|
||
|
|
|
||
|
|
This document provides a **detailed, actionable implementation plan** to complete the TrinityCore PlayerBot Module. Based on comprehensive analysis of 400+ files, 50,000+ lines of code, and 100+ documented TODOs, this plan prioritizes critical tasks needed to reach production readiness.
|
||
|
|
|
||
|
|
**Total Estimated Time**: 3-4 weeks (full-time equivalent)
|
||
|
|
**Critical Path**: Complete Phase 3 → Validate Phase 5 → Execute Phase 6
|
||
|
|
**Risk Level**: LOW (architecture solid, mostly polish remaining)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 📋 TABLE OF CONTENTS
|
||
|
|
|
||
|
|
1. [Priority 1: Critical Blockers (1 week)](#priority-1-critical-blockers)
|
||
|
|
2. [Priority 2: Feature Completion (1-2 weeks)](#priority-2-feature-completion)
|
||
|
|
3. [Priority 3: Polish & Optimization (1 week)](#priority-3-polish--optimization)
|
||
|
|
4. [Testing Strategy](#testing-strategy)
|
||
|
|
5. [Deployment Checklist](#deployment-checklist)
|
||
|
|
6. [Long-Term Roadmap](#long-term-roadmap)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## ✅ PRIORITY 1: CRITICAL BLOCKERS (Est: 1 week)
|
||
|
|
|
||
|
|
### 🔴 Task 1.1: Complete Quest System Pathfinding (3 days)
|
||
|
|
|
||
|
|
**File**: `AI/Strategy/QuestStrategy.cpp`
|
||
|
|
**Line**: 970
|
||
|
|
**Status**: Stubbed with TODO
|
||
|
|
**Priority**: CRITICAL
|
||
|
|
|
||
|
|
#### Current State
|
||
|
|
```cpp
|
||
|
|
// TODO: Implement pathfinding to known quest hubs based on bot level
|
||
|
|
```
|
||
|
|
|
||
|
|
#### Implementation Requirements
|
||
|
|
|
||
|
|
1. **Quest Hub Database** (6 hours)
|
||
|
|
```cpp
|
||
|
|
struct QuestHub {
|
||
|
|
uint32 zoneId;
|
||
|
|
Position location;
|
||
|
|
uint32 minLevel;
|
||
|
|
uint32 maxLevel;
|
||
|
|
std::vector<uint32> questIds;
|
||
|
|
};
|
||
|
|
|
||
|
|
class QuestHubDatabase {
|
||
|
|
public:
|
||
|
|
static std::vector<QuestHub> GetQuestHubsForLevel(uint32 level, uint32 faction);
|
||
|
|
static Position GetNearestQuestHub(Player* bot);
|
||
|
|
};
|
||
|
|
```
|
||
|
|
|
||
|
|
**Data Sources**:
|
||
|
|
- World database: `creature_queststarter` table
|
||
|
|
- Quest database: `quest_template` with level ranges
|
||
|
|
- Zone data: from DBC files
|
||
|
|
|
||
|
|
2. **Pathfinding Integration** (8 hours)
|
||
|
|
```cpp
|
||
|
|
void QuestStrategy::MoveToQuestHub()
|
||
|
|
{
|
||
|
|
Position hub = QuestHubDatabase::GetNearestQuestHub(_bot);
|
||
|
|
|
||
|
|
// Use PathfindingAdapter from Phase 3
|
||
|
|
PathfindingAdapter pathfinder(_bot);
|
||
|
|
auto path = pathfinder.GeneratePath(_bot->GetPosition(), hub);
|
||
|
|
|
||
|
|
if (path.IsValid())
|
||
|
|
{
|
||
|
|
_bot->GetMotionMaster()->MoveSplinePath(&path);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
3. **Quest Giver Detection** (4 hours)
|
||
|
|
- Scan creatures in range with `UNIT_NPC_FLAG_QUESTGIVER`
|
||
|
|
- Priority: quest starters > quest enders
|
||
|
|
- Filter by bot level and prerequisites
|
||
|
|
|
||
|
|
4. **Testing & Validation** (6 hours)
|
||
|
|
- Test with 10 different levels (1, 10, 20, ... 80)
|
||
|
|
- Validate pathfinding for each major zone
|
||
|
|
- Measure performance (<1ms calculation)
|
||
|
|
|
||
|
|
**Total Estimated Time**: 24 hours (3 days)
|
||
|
|
|
||
|
|
#### Acceptance Criteria
|
||
|
|
- ✅ Bot navigates to appropriate quest hubs by level
|
||
|
|
- ✅ Pathfinding uses TrinityCore navmesh
|
||
|
|
- ✅ Performance: <1ms per pathfinding calculation
|
||
|
|
- ✅ No crashes or infinite loops
|
||
|
|
- ✅ Works for all starting zones
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 🔴 Task 1.2: Implement Vendor Purchase System (2 days)
|
||
|
|
|
||
|
|
**Files**:
|
||
|
|
- `Game/NPCInteractionManager.cpp:272-274`
|
||
|
|
- `Advanced/EconomyManager.cpp:156-200`
|
||
|
|
|
||
|
|
**Status**: Simplified placeholder
|
||
|
|
**Priority**: CRITICAL
|
||
|
|
|
||
|
|
#### Current State
|
||
|
|
```cpp
|
||
|
|
// Simplified - actual vendor purchase would require VendorItemData lookup
|
||
|
|
TC_LOG_DEBUG("bot.playerbot", "Bot %s would buy item %u from vendor (not implemented)",
|
||
|
|
_bot->GetName().c_str(), itemId);
|
||
|
|
```
|
||
|
|
|
||
|
|
#### Implementation Requirements
|
||
|
|
|
||
|
|
1. **Vendor Item Lookup** (4 hours)
|
||
|
|
```cpp
|
||
|
|
struct VendorPurchaseRequest {
|
||
|
|
uint32 vendorEntry;
|
||
|
|
uint32 itemId;
|
||
|
|
uint32 quantity;
|
||
|
|
uint64 extendedCost; // For special currency
|
||
|
|
};
|
||
|
|
|
||
|
|
class VendorInteractionManager {
|
||
|
|
public:
|
||
|
|
bool PurchaseItem(Player* bot, VendorPurchaseRequest const& request);
|
||
|
|
bool CanAfford(Player* bot, uint32 itemId, uint32 quantity);
|
||
|
|
uint32 GetVendorPrice(uint32 vendorEntry, uint32 itemId);
|
||
|
|
};
|
||
|
|
```
|
||
|
|
|
||
|
|
2. **TrinityCore API Integration** (6 hours)
|
||
|
|
- Use `Creature::GetVendorItems()` to get available items
|
||
|
|
- Integrate with `Player::BuyItemFromVendorSlot()`
|
||
|
|
- Handle currency checks (gold + special currencies)
|
||
|
|
- Validate item availability and stock limits
|
||
|
|
|
||
|
|
3. **Smart Purchase Logic** (4 hours)
|
||
|
|
```cpp
|
||
|
|
// Priority system for purchases
|
||
|
|
enum PurchasePriority {
|
||
|
|
CRITICAL = 0, // Reagents for spells
|
||
|
|
HIGH = 1, // Consumables (food, water)
|
||
|
|
MEDIUM = 2, // Equipment upgrades
|
||
|
|
LOW = 3 // Luxury items
|
||
|
|
};
|
||
|
|
```
|
||
|
|
|
||
|
|
4. **Budget Management** (2 hours)
|
||
|
|
- Reserve gold for repairs
|
||
|
|
- Calculate affordable items
|
||
|
|
- Prioritize critical purchases
|
||
|
|
|
||
|
|
**Total Estimated Time**: 16 hours (2 days)
|
||
|
|
|
||
|
|
#### Acceptance Criteria
|
||
|
|
- ✅ Bot purchases items from vendors using TrinityCore API
|
||
|
|
- ✅ Gold deduction works correctly
|
||
|
|
- ✅ Inventory management (bag space check)
|
||
|
|
- ✅ Priority system respects budget
|
||
|
|
- ✅ No gold duplication bugs
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 🔴 Task 1.3: Implement Flight Master System (1 day)
|
||
|
|
|
||
|
|
**File**: `Game/NPCInteractionManager.cpp:470-474`
|
||
|
|
**Status**: Not implemented
|
||
|
|
**Priority**: CRITICAL
|
||
|
|
|
||
|
|
#### Current State
|
||
|
|
```cpp
|
||
|
|
// This would require TaxiPath integration - simplified for now
|
||
|
|
TC_LOG_DEBUG("bot.playerbot",
|
||
|
|
"Bot %s attempting flight master interaction (not implemented)",
|
||
|
|
_bot->GetName().c_str());
|
||
|
|
return false; // Not implemented yet
|
||
|
|
```
|
||
|
|
|
||
|
|
#### Implementation Requirements
|
||
|
|
|
||
|
|
1. **Taxi Path Lookup** (3 hours)
|
||
|
|
```cpp
|
||
|
|
class FlightMasterManager {
|
||
|
|
public:
|
||
|
|
bool CanUseFlightPath(Player* bot, uint32 destinationNode);
|
||
|
|
uint64 GetFlightCost(uint32 sourceNode, uint32 destNode);
|
||
|
|
void TakeFlight(Player* bot, uint32 destinationNode);
|
||
|
|
|
||
|
|
// Get discovered flight paths
|
||
|
|
std::vector<uint32> GetKnownFlightPaths(Player* bot);
|
||
|
|
};
|
||
|
|
```
|
||
|
|
|
||
|
|
2. **TrinityCore API Integration** (4 hours)
|
||
|
|
- Use `Player::ActivateTaxiPathTo()` for flights
|
||
|
|
- Check `Player::m_taxi` for known paths
|
||
|
|
- Validate flight master gossip options
|
||
|
|
- Handle flight duration and arrival
|
||
|
|
|
||
|
|
3. **Smart Flight Selection** (1 hour)
|
||
|
|
```cpp
|
||
|
|
uint32 SelectBestFlightPath(Player* bot, Position destination)
|
||
|
|
{
|
||
|
|
auto knownPaths = GetKnownFlightPaths(bot);
|
||
|
|
uint32 nearestNode = FindNearestTaxiNode(destination, knownPaths);
|
||
|
|
|
||
|
|
// Calculate cost vs walking time
|
||
|
|
if (GetFlightCost(bot->GetTaxiNode(), nearestNode) < bot->GetMoney() * 0.1)
|
||
|
|
return nearestNode;
|
||
|
|
|
||
|
|
return 0; // Walk instead
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**Total Estimated Time**: 8 hours (1 day)
|
||
|
|
|
||
|
|
#### Acceptance Criteria
|
||
|
|
- ✅ Bot uses flight paths when efficient
|
||
|
|
- ✅ Gold deduction for flight costs
|
||
|
|
- ✅ Bot arrives at destination correctly
|
||
|
|
- ✅ No infinite flight loops
|
||
|
|
- ✅ Fallback to walking when needed
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 🔴 Task 1.4: Implement Group Formation Algorithms (2 days)
|
||
|
|
|
||
|
|
**File**: `Group/GroupFormation.cpp:553-571`
|
||
|
|
**Status**: 4 formations stubbed
|
||
|
|
**Priority**: HIGH
|
||
|
|
|
||
|
|
#### Current State
|
||
|
|
```cpp
|
||
|
|
// TODO: Implement wedge formation algorithm
|
||
|
|
// TODO: Implement diamond formation algorithm
|
||
|
|
// TODO: Implement defensive square algorithm
|
||
|
|
// TODO: Implement arrow formation algorithm
|
||
|
|
```
|
||
|
|
|
||
|
|
#### Implementation Requirements
|
||
|
|
|
||
|
|
1. **Wedge Formation** (4 hours)
|
||
|
|
```cpp
|
||
|
|
Position CalculateWedgePosition(uint32 memberIndex, uint32 totalMembers,
|
||
|
|
Position leader, float direction)
|
||
|
|
{
|
||
|
|
// V-shape with leader at point
|
||
|
|
float angle = direction;
|
||
|
|
float sideOffset = (memberIndex % 2 == 0) ? -45.0f : 45.0f;
|
||
|
|
float row = memberIndex / 2;
|
||
|
|
|
||
|
|
return leader.GetPositionWithDistInFront(
|
||
|
|
3.0f * row,
|
||
|
|
angle + sideOffset
|
||
|
|
);
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
2. **Diamond Formation** (4 hours)
|
||
|
|
```cpp
|
||
|
|
Position CalculateDiamondPosition(uint32 memberIndex, uint32 totalMembers,
|
||
|
|
Position center, float facing)
|
||
|
|
{
|
||
|
|
// Four points: front, left, right, back
|
||
|
|
// Center for leader/healers
|
||
|
|
static const float angles[] = {0.0f, 90.0f, 180.0f, 270.0f};
|
||
|
|
float distance = 5.0f;
|
||
|
|
|
||
|
|
if (memberIndex == 0) return center; // Leader center
|
||
|
|
|
||
|
|
uint32 posIndex = (memberIndex - 1) % 4;
|
||
|
|
return center.GetPositionWithDistInDirection(
|
||
|
|
distance,
|
||
|
|
facing + angles[posIndex]
|
||
|
|
);
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
3. **Defensive Square** (3 hours)
|
||
|
|
- Four corners formation
|
||
|
|
- Tanks on corners, healers center
|
||
|
|
- DPS on edges
|
||
|
|
|
||
|
|
4. **Arrow Formation** (3 hours)
|
||
|
|
- Leader at point
|
||
|
|
- Tanks behind leader
|
||
|
|
- DPS on wings
|
||
|
|
- Healers in center
|
||
|
|
|
||
|
|
**Total Estimated Time**: 14 hours (2 days)
|
||
|
|
|
||
|
|
#### Acceptance Criteria
|
||
|
|
- ✅ All 4 formations implemented
|
||
|
|
- ✅ Smooth transitions between formations
|
||
|
|
- ✅ Role-appropriate positioning
|
||
|
|
- ✅ Collision detection working
|
||
|
|
- ✅ Performance: <0.1ms per formation update
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 🔴 Task 1.5: Database Persistence Implementation (1 day)
|
||
|
|
|
||
|
|
**Files**:
|
||
|
|
- `Account/BotAccountMgr.cpp:722`
|
||
|
|
- `Character/BotNameMgr.cpp:120, 173`
|
||
|
|
- `Lifecycle/BotLifecycleMgr.cpp:422, 467, 604`
|
||
|
|
|
||
|
|
**Status**: Multiple database TODOs
|
||
|
|
**Priority**: HIGH
|
||
|
|
|
||
|
|
#### Current State
|
||
|
|
```cpp
|
||
|
|
// TODO: Implement database storage when BotDatabasePool is available
|
||
|
|
// TODO: Implement with PBDB_ statements
|
||
|
|
// TODO: Cleanup database events when PBDB statements are ready
|
||
|
|
```
|
||
|
|
|
||
|
|
#### Implementation Requirements
|
||
|
|
|
||
|
|
1. **Database Statement Definitions** (2 hours)
|
||
|
|
```cpp
|
||
|
|
enum PlayerbotDatabaseStatements {
|
||
|
|
PBDB_INS_BOT_ACCOUNT,
|
||
|
|
PBDB_UPD_BOT_NAME,
|
||
|
|
PBDB_INS_LIFECYCLE_EVENT,
|
||
|
|
PBDB_DEL_OLD_EVENTS,
|
||
|
|
// ... 20 more statements
|
||
|
|
};
|
||
|
|
```
|
||
|
|
|
||
|
|
2. **Prepared Statement Registration** (3 hours)
|
||
|
|
```cpp
|
||
|
|
void PlayerbotDatabaseConnection::DoPrepareStatements()
|
||
|
|
{
|
||
|
|
PrepareStatement(PBDB_INS_BOT_ACCOUNT,
|
||
|
|
"INSERT INTO bot_accounts (account_id, creation_date, status) "
|
||
|
|
"VALUES (?, NOW(), ?)", CONNECTION_ASYNC);
|
||
|
|
|
||
|
|
PrepareStatement(PBDB_UPD_BOT_NAME,
|
||
|
|
"UPDATE bot_names SET is_used = 1 WHERE name = ?",
|
||
|
|
CONNECTION_ASYNC);
|
||
|
|
|
||
|
|
// ... implement all statements
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
3. **Async Execution** (3 hours)
|
||
|
|
- Use TrinityCore's async query system
|
||
|
|
- Callback handlers for results
|
||
|
|
- Error handling and retries
|
||
|
|
|
||
|
|
**Total Estimated Time**: 8 hours (1 day)
|
||
|
|
|
||
|
|
#### Acceptance Criteria
|
||
|
|
- ✅ All database operations use prepared statements
|
||
|
|
- ✅ Async execution with callbacks
|
||
|
|
- ✅ Error handling and logging
|
||
|
|
- ✅ No SQL injection vulnerabilities
|
||
|
|
- ✅ Performance: >1000 queries/second
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 🟡 PRIORITY 2: FEATURE COMPLETION (Est: 1-2 weeks)
|
||
|
|
|
||
|
|
### 🟡 Task 2.1: Chat Command Logic (2 days)
|
||
|
|
|
||
|
|
**File**: `Chat/BotChatCommandHandler.cpp:818-832`
|
||
|
|
**Status**: 3 commands stubbed
|
||
|
|
**Priority**: MEDIUM
|
||
|
|
|
||
|
|
#### Commands to Implement
|
||
|
|
|
||
|
|
1. **Follow Command** (4 hours)
|
||
|
|
```cpp
|
||
|
|
void HandleFollowCommand(Player* bot, Player* master)
|
||
|
|
{
|
||
|
|
// Stop current action
|
||
|
|
bot->GetAI()->ClearActions();
|
||
|
|
|
||
|
|
// Set follow target
|
||
|
|
bot->GetMotionMaster()->MoveFollow(
|
||
|
|
master,
|
||
|
|
PET_FOLLOW_DIST,
|
||
|
|
PET_FOLLOW_ANGLE
|
||
|
|
);
|
||
|
|
|
||
|
|
// Update bot state
|
||
|
|
bot->GetBotAI()->SetBehaviorState(BotBehaviorState::FOLLOWING);
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
2. **Stay Command** (3 hours)
|
||
|
|
```cpp
|
||
|
|
void HandleStayCommand(Player* bot)
|
||
|
|
{
|
||
|
|
// Stop all movement
|
||
|
|
bot->StopMoving();
|
||
|
|
bot->GetMotionMaster()->Clear();
|
||
|
|
bot->GetMotionMaster()->MoveIdle();
|
||
|
|
|
||
|
|
// Update bot state
|
||
|
|
bot->GetBotAI()->SetBehaviorState(BotBehaviorState::IDLE);
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
3. **Attack Command** (5 hours)
|
||
|
|
```cpp
|
||
|
|
void HandleAttackCommand(Player* bot, Unit* target)
|
||
|
|
{
|
||
|
|
if (!target || !bot->IsValidAttackTarget(target))
|
||
|
|
return;
|
||
|
|
|
||
|
|
// Enter combat
|
||
|
|
bot->GetBotAI()->EnterCombat(target);
|
||
|
|
bot->Attack(target, true);
|
||
|
|
|
||
|
|
// Update threat
|
||
|
|
if (bot->GetBotAI()->GetRole() == BotRole::TANK)
|
||
|
|
bot->AddThreat(target, 1000.0f);
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**Total Estimated Time**: 12 hours (1.5 days)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 🟡 Task 2.2: Group Coordination Logic (3 days)
|
||
|
|
|
||
|
|
**File**: `Group/GroupCoordination.cpp:568-586`
|
||
|
|
**Status**: 4 coordination methods stubbed
|
||
|
|
**Priority**: MEDIUM
|
||
|
|
|
||
|
|
#### Methods to Implement
|
||
|
|
|
||
|
|
1. **Tank Coordination** (6 hours)
|
||
|
|
- Threat generation rotation
|
||
|
|
- Tank swap mechanics
|
||
|
|
- Defensive cooldown coordination
|
||
|
|
|
||
|
|
2. **Healer Coordination** (6 hours)
|
||
|
|
- Heal assignment (tank/DPS priority)
|
||
|
|
- Mana management
|
||
|
|
- Dispel coordination
|
||
|
|
|
||
|
|
3. **DPS Coordination** (6 hours)
|
||
|
|
- Focus fire on priority targets
|
||
|
|
- Interrupt rotation
|
||
|
|
- Cooldown stacking
|
||
|
|
|
||
|
|
4. **Support Coordination** (6 hours)
|
||
|
|
- Buff management
|
||
|
|
- Crowd control rotation
|
||
|
|
- Utility spell usage
|
||
|
|
|
||
|
|
**Total Estimated Time**: 24 hours (3 days)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 🟡 Task 2.3: Role-Based Gear Scoring (2 days)
|
||
|
|
|
||
|
|
**File**: `Group/RoleAssignment.cpp:614, 636, 754`
|
||
|
|
**Status**: 3 gear scoring methods stubbed
|
||
|
|
**Priority**: MEDIUM
|
||
|
|
|
||
|
|
#### Implementation
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
float CalculateGearScoreForRole(Player* player, GroupRole role)
|
||
|
|
{
|
||
|
|
float score = 0.0f;
|
||
|
|
|
||
|
|
// Iterate all equipped items
|
||
|
|
for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
|
||
|
|
{
|
||
|
|
Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
|
||
|
|
if (!item) continue;
|
||
|
|
|
||
|
|
ItemTemplate const* proto = item->GetTemplate();
|
||
|
|
|
||
|
|
// Base item level score
|
||
|
|
score += proto->ItemLevel * 0.1f;
|
||
|
|
|
||
|
|
// Stat weights by role
|
||
|
|
score += GetStatScoreForRole(proto, role);
|
||
|
|
}
|
||
|
|
|
||
|
|
return score;
|
||
|
|
}
|
||
|
|
|
||
|
|
float GetStatScoreForRole(ItemTemplate const* item, GroupRole role)
|
||
|
|
{
|
||
|
|
switch (role)
|
||
|
|
{
|
||
|
|
case GroupRole::TANK:
|
||
|
|
return item->GetStamina() * 2.0f +
|
||
|
|
item->GetArmor() * 1.5f +
|
||
|
|
item->GetAvoidance() * 1.0f;
|
||
|
|
|
||
|
|
case GroupRole::HEALER:
|
||
|
|
return item->GetInt() * 2.0f +
|
||
|
|
item->GetSpirit() * 1.5f +
|
||
|
|
item->GetSpellPower() * 1.0f;
|
||
|
|
|
||
|
|
case GroupRole::MELEE_DPS:
|
||
|
|
return item->GetAgility() * 2.0f +
|
||
|
|
item->GetAttackPower() * 1.5f +
|
||
|
|
item->GetCritRating() * 1.0f;
|
||
|
|
|
||
|
|
case GroupRole::RANGED_DPS:
|
||
|
|
return item->GetInt() * 2.0f +
|
||
|
|
item->GetSpellPower() * 2.0f +
|
||
|
|
item->GetHasteRating() * 1.0f;
|
||
|
|
}
|
||
|
|
return 0.0f;
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**Total Estimated Time**: 16 hours (2 days)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 🟡 Task 2.4: Spec Detection Implementation (1 day)
|
||
|
|
|
||
|
|
**File**: `AI/Strategy/CombatMovementStrategy.cpp:250, 285, 292`
|
||
|
|
**Status**: Needs talent tree API
|
||
|
|
**Priority**: LOW-MEDIUM
|
||
|
|
|
||
|
|
#### Implementation
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
uint32 DetectPlayerSpec(Player* player)
|
||
|
|
{
|
||
|
|
// WoW 11.2 uses active spec index
|
||
|
|
uint8 activeSpec = player->GetActiveSpec();
|
||
|
|
|
||
|
|
// Map class + spec to specialization ID
|
||
|
|
uint32 classId = player->getClass();
|
||
|
|
|
||
|
|
// Use TrinityCore's ChrSpecialization.db2
|
||
|
|
return GetSpecializationId(classId, activeSpec);
|
||
|
|
}
|
||
|
|
|
||
|
|
bool HasTalent(Player* player, uint32 talentId)
|
||
|
|
{
|
||
|
|
return player->HasTalent(talentId, player->GetActiveSpec());
|
||
|
|
}
|
||
|
|
|
||
|
|
uint32 GetSpecializationId(uint32 classId, uint8 specIndex)
|
||
|
|
{
|
||
|
|
static const std::unordered_map<uint32, std::array<uint32, 4>> SPEC_MAP = {
|
||
|
|
{CLASS_WARRIOR, {71, 72, 73, 0}}, // Arms, Fury, Protection
|
||
|
|
{CLASS_PALADIN, {65, 66, 70, 0}}, // Holy, Protection, Retribution
|
||
|
|
{CLASS_HUNTER, {253, 254, 255, 0}}, // Beast Mastery, Marksmanship, Survival
|
||
|
|
// ... all 13 classes
|
||
|
|
};
|
||
|
|
|
||
|
|
return SPEC_MAP.at(classId)[specIndex];
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**Total Estimated Time**: 8 hours (1 day)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 🟡 Task 2.5: Economy Manager Completion (2 days)
|
||
|
|
|
||
|
|
**File**: `Advanced/EconomyManager.cpp:156-200`
|
||
|
|
**Status**: 4 auction methods stubbed
|
||
|
|
**Priority**: MEDIUM
|
||
|
|
|
||
|
|
#### Methods to Implement
|
||
|
|
|
||
|
|
1. **Auction Posting** (4 hours)
|
||
|
|
2. **Auction Bidding** (4 hours)
|
||
|
|
3. **Auction Buyout** (3 hours)
|
||
|
|
4. **Auction Cancellation** (3 hours)
|
||
|
|
|
||
|
|
**Total Estimated Time**: 14 hours (2 days)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 🟢 PRIORITY 3: POLISH & OPTIMIZATION (Est: 1 week)
|
||
|
|
|
||
|
|
### 🟢 Task 3.1: Lock-Free Data Structures (2 days)
|
||
|
|
|
||
|
|
**File**: `Lifecycle/BotSpawner.h:181-190`
|
||
|
|
**Status**: Uses std::mutex, needs upgrade
|
||
|
|
**Priority**: MEDIUM
|
||
|
|
|
||
|
|
#### Current Issues
|
||
|
|
```cpp
|
||
|
|
mutable std::mutex _zoneMutex; // TODO: Replace with lock-free hash map
|
||
|
|
mutable std::mutex _botMutex; // TODO: Replace with concurrent hash map
|
||
|
|
mutable std::mutex _spawnQueueMutex; // TODO: Replace with lock-free queue
|
||
|
|
```
|
||
|
|
|
||
|
|
#### Implementation
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
// Replace with tbb::concurrent_hash_map
|
||
|
|
tbb::concurrent_hash_map<uint32, ZoneInfo> _zoneCache;
|
||
|
|
tbb::concurrent_hash_map<ObjectGuid, BotInfo*> _botCache;
|
||
|
|
|
||
|
|
// Replace with lock-free queue
|
||
|
|
#include <tbb/concurrent_queue.h>
|
||
|
|
tbb::concurrent_queue<SpawnRequest> _spawnQueue;
|
||
|
|
|
||
|
|
// Usage example
|
||
|
|
void AddSpawnRequest(SpawnRequest request)
|
||
|
|
{
|
||
|
|
_spawnQueue.push(request); // Lock-free!
|
||
|
|
}
|
||
|
|
|
||
|
|
bool ProcessNextSpawn(SpawnRequest& out)
|
||
|
|
{
|
||
|
|
return _spawnQueue.try_pop(out); // Lock-free!
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**Total Estimated Time**: 16 hours (2 days)
|
||
|
|
|
||
|
|
#### Acceptance Criteria
|
||
|
|
- ✅ Zero mutex contention
|
||
|
|
- ✅ Performance: >10,000 ops/sec
|
||
|
|
- ✅ Thread-safe without locks
|
||
|
|
- ✅ No data races (TSan validated)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 🟢 Task 3.2: Memory Defragmentation (1 day)
|
||
|
|
|
||
|
|
**Status**: Not implemented
|
||
|
|
**Priority**: LOW-MEDIUM
|
||
|
|
|
||
|
|
#### Implementation
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
class MemoryDefragmenter {
|
||
|
|
public:
|
||
|
|
void ScheduleDefragmentation();
|
||
|
|
void RunDefragmentation();
|
||
|
|
|
||
|
|
private:
|
||
|
|
void CompactMemoryPool(MemoryPool<BotAI>& pool);
|
||
|
|
void ReclaimUnusedChunks();
|
||
|
|
void ReorganizeAllocations();
|
||
|
|
};
|
||
|
|
|
||
|
|
// Background thread
|
||
|
|
void MemoryDefragmentationThread()
|
||
|
|
{
|
||
|
|
while (_running)
|
||
|
|
{
|
||
|
|
std::this_thread::sleep_for(std::chrono::minutes(5));
|
||
|
|
|
||
|
|
if (GetMemoryPressure() > 0.8f)
|
||
|
|
{
|
||
|
|
MemoryDefragmenter::RunDefragmentation();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**Total Estimated Time**: 8 hours (1 day)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 🟢 Task 3.3: Advanced Profiling Features (1 day)
|
||
|
|
|
||
|
|
**Status**: Stack sampling not implemented
|
||
|
|
**Priority**: LOW
|
||
|
|
|
||
|
|
#### Implementation
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
class StackSampler {
|
||
|
|
public:
|
||
|
|
void StartSampling(uint32 frequency_hz = 1000);
|
||
|
|
void StopSampling();
|
||
|
|
void ExportFlameGraph(std::string const& filename);
|
||
|
|
|
||
|
|
private:
|
||
|
|
void SampleThread();
|
||
|
|
std::vector<StackTrace> _samples;
|
||
|
|
};
|
||
|
|
|
||
|
|
// Flame graph generation
|
||
|
|
void ExportFlameGraph(std::string const& filename)
|
||
|
|
{
|
||
|
|
std::ofstream file(filename);
|
||
|
|
|
||
|
|
// Generate SVG flame graph
|
||
|
|
FlameGraphGenerator generator(_samples);
|
||
|
|
file << generator.GenerateSVG();
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**Total Estimated Time**: 8 hours (1 day)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 🟢 Task 3.4: TODO Cleanup (2 days)
|
||
|
|
|
||
|
|
**Status**: 100+ TODOs documented
|
||
|
|
**Priority**: MEDIUM
|
||
|
|
|
||
|
|
#### Cleanup Strategy
|
||
|
|
|
||
|
|
1. **Critical TODOs** (completed in Priority 1)
|
||
|
|
2. **Medium TODOs** (address or document as future work)
|
||
|
|
3. **Low TODOs** (convert to GitHub issues)
|
||
|
|
|
||
|
|
#### Process
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Find all TODOs
|
||
|
|
grep -r "TODO\|FIXME\|HACK" src/modules/Playerbot/ > todos.txt
|
||
|
|
|
||
|
|
# Categorize
|
||
|
|
# - DONE: Already implemented (remove comment)
|
||
|
|
# - CRITICAL: Blocking (implement immediately)
|
||
|
|
# - MEDIUM: Important (schedule)
|
||
|
|
# - LOW: Nice-to-have (create issue, remove comment)
|
||
|
|
|
||
|
|
# Convert to GitHub issues
|
||
|
|
for todo in $(cat medium_todos.txt); do
|
||
|
|
gh issue create --title "$todo" --label "enhancement,todo"
|
||
|
|
done
|
||
|
|
```
|
||
|
|
|
||
|
|
**Total Estimated Time**: 16 hours (2 days)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### 🟢 Task 3.5: Warning Elimination (1 day)
|
||
|
|
|
||
|
|
**Status**: Minor warnings present
|
||
|
|
**Priority**: LOW
|
||
|
|
|
||
|
|
#### Warnings to Fix
|
||
|
|
|
||
|
|
1. **Unused variables** (2 hours)
|
||
|
|
2. **Deprecated API calls** (3 hours)
|
||
|
|
3. **Template visibility** (1 hour - already mostly fixed)
|
||
|
|
4. **Implicit conversions** (2 hours)
|
||
|
|
|
||
|
|
**Total Estimated Time**: 8 hours (1 day)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 🧪 TESTING STRATEGY
|
||
|
|
|
||
|
|
### Integration Testing (3 days)
|
||
|
|
|
||
|
|
#### Test 1: Single Bot Lifecycle (4 hours)
|
||
|
|
```cpp
|
||
|
|
TEST(BotIntegration, SingleBotLifecycle)
|
||
|
|
{
|
||
|
|
// Spawn bot
|
||
|
|
auto bot = BotSpawner::SpawnBot(1, CLASS_WARRIOR);
|
||
|
|
ASSERT_NE(bot, nullptr);
|
||
|
|
|
||
|
|
// Verify session
|
||
|
|
ASSERT_TRUE(bot->GetSession()->IsBot());
|
||
|
|
|
||
|
|
// Test movement
|
||
|
|
bot->TeleportTo(0, 0, 0, 0, 0);
|
||
|
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||
|
|
ASSERT_TRUE(bot->IsInWorld());
|
||
|
|
|
||
|
|
// Test combat
|
||
|
|
auto target = SpawnTestDummy();
|
||
|
|
bot->GetAI()->EnterCombat(target);
|
||
|
|
ASSERT_TRUE(bot->IsInCombat());
|
||
|
|
|
||
|
|
// Cleanup
|
||
|
|
BotSpawner::DespawnBot(bot);
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
#### Test 2: 100-Bot Stress Test (8 hours)
|
||
|
|
- Spawn 100 bots simultaneously
|
||
|
|
- Monitor CPU/memory usage
|
||
|
|
- Verify no crashes or deadlocks
|
||
|
|
- Measure performance metrics
|
||
|
|
|
||
|
|
#### Test 3: 1000-Bot Scalability Test (1 day)
|
||
|
|
- Spawn 1000 bots over 10 minutes
|
||
|
|
- Monitor system resources
|
||
|
|
- Verify linear scaling
|
||
|
|
- Check for memory leaks
|
||
|
|
|
||
|
|
#### Test 4: Combat Coordination (4 hours)
|
||
|
|
- Create 5-bot group (tank, healer, 3 DPS)
|
||
|
|
- Engage multiple enemies
|
||
|
|
- Verify role-based positioning
|
||
|
|
- Test interrupt rotation
|
||
|
|
- Validate threat management
|
||
|
|
|
||
|
|
#### Test 5: Quest Completion (4 hours)
|
||
|
|
- Bot picks up quest
|
||
|
|
- Bot navigates to objective
|
||
|
|
- Bot completes objective
|
||
|
|
- Bot turns in quest
|
||
|
|
- Verify gold/XP rewards
|
||
|
|
|
||
|
|
#### Test 6: Long-Running Stability (2 days)
|
||
|
|
- Run 100 bots for 48 hours
|
||
|
|
- Monitor for memory leaks
|
||
|
|
- Check for crashes
|
||
|
|
- Validate database integrity
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 📦 DEPLOYMENT CHECKLIST
|
||
|
|
|
||
|
|
### Pre-Deployment (1 day)
|
||
|
|
|
||
|
|
- [ ] All Priority 1 tasks complete
|
||
|
|
- [ ] All Priority 2 tasks complete (or documented as future work)
|
||
|
|
- [ ] Integration tests passing
|
||
|
|
- [ ] Performance benchmarks met
|
||
|
|
- [ ] Documentation updated
|
||
|
|
- [ ] Configuration examples provided
|
||
|
|
|
||
|
|
### Deployment Steps (2 hours)
|
||
|
|
|
||
|
|
1. **Database Migration** (30 min)
|
||
|
|
```sql
|
||
|
|
-- Apply all 6 migrations
|
||
|
|
SOURCE sql/migrations/001_initial_schema.sql;
|
||
|
|
SOURCE sql/migrations/002_account_management.sql;
|
||
|
|
SOURCE sql/migrations/003_lifecycle_management.sql;
|
||
|
|
SOURCE sql/migrations/004_character_distribution.sql;
|
||
|
|
SOURCE sql/migrations/005_initial_data.sql;
|
||
|
|
SOURCE sql/migrations/006_bot_names.sql;
|
||
|
|
```
|
||
|
|
|
||
|
|
2. **Configuration** (30 min)
|
||
|
|
```bash
|
||
|
|
cp conf/playerbots.conf.dist conf/playerbots.conf
|
||
|
|
# Edit playerbots.conf with server-specific settings
|
||
|
|
```
|
||
|
|
|
||
|
|
3. **Compilation** (30 min)
|
||
|
|
```bash
|
||
|
|
cd build
|
||
|
|
cmake .. -DBUILD_PLAYERBOT=1
|
||
|
|
make -j$(nproc)
|
||
|
|
```
|
||
|
|
|
||
|
|
4. **Validation** (30 min)
|
||
|
|
- Start worldserver
|
||
|
|
- Spawn 10 test bots
|
||
|
|
- Verify no errors in logs
|
||
|
|
- Test basic commands
|
||
|
|
|
||
|
|
### Post-Deployment Monitoring (ongoing)
|
||
|
|
|
||
|
|
- Monitor CPU/memory usage
|
||
|
|
- Check error logs daily
|
||
|
|
- Validate database integrity weekly
|
||
|
|
- Performance regression tests monthly
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 🚀 LONG-TERM ROADMAP
|
||
|
|
|
||
|
|
### Phase 7: Advanced AI (Est: 2-3 months)
|
||
|
|
|
||
|
|
1. **Machine Learning Integration**
|
||
|
|
- Player behavior learning
|
||
|
|
- Adaptive difficulty
|
||
|
|
- Performance optimization through RL
|
||
|
|
|
||
|
|
2. **Advanced Combat**
|
||
|
|
- Boss mechanic awareness
|
||
|
|
- Raid encounter strategies
|
||
|
|
- PvP intelligence
|
||
|
|
|
||
|
|
3. **Social Features**
|
||
|
|
- Chat bot integration
|
||
|
|
- Guild management
|
||
|
|
- Player interaction
|
||
|
|
|
||
|
|
### Phase 8: PvP Systems (Est: 1-2 months)
|
||
|
|
|
||
|
|
1. **Arena AI**
|
||
|
|
- 2v2, 3v3 strategies
|
||
|
|
- Composition-based tactics
|
||
|
|
- Rating system
|
||
|
|
|
||
|
|
2. **Battleground AI**
|
||
|
|
- Objective prioritization
|
||
|
|
- Team coordination
|
||
|
|
- Flag/base defense
|
||
|
|
|
||
|
|
### Phase 9: Economy Mastery (Est: 1 month)
|
||
|
|
|
||
|
|
1. **Advanced Auction House**
|
||
|
|
- Market prediction
|
||
|
|
- Arbitrage detection
|
||
|
|
- Automated trading
|
||
|
|
|
||
|
|
2. **Profession Optimization**
|
||
|
|
- Crafting profit analysis
|
||
|
|
- Gathering route optimization
|
||
|
|
- Material procurement
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 📊 IMPLEMENTATION TIMELINE
|
||
|
|
|
||
|
|
### Week 1: Critical Blockers
|
||
|
|
- Days 1-3: Quest pathfinding + vendor system
|
||
|
|
- Days 4-5: Flight master + formations
|
||
|
|
- Days 6-7: Database persistence
|
||
|
|
|
||
|
|
### Week 2: Feature Completion
|
||
|
|
- Days 1-2: Chat commands + gear scoring
|
||
|
|
- Days 3-5: Group coordination
|
||
|
|
- Days 6-7: Economy manager
|
||
|
|
|
||
|
|
### Week 3: Polish & Optimization
|
||
|
|
- Days 1-2: Lock-free structures
|
||
|
|
- Days 3-4: TODO cleanup
|
||
|
|
- Days 5-7: Testing
|
||
|
|
|
||
|
|
### Week 4: Validation & Deployment
|
||
|
|
- Days 1-3: Integration testing
|
||
|
|
- Days 4-5: Performance validation
|
||
|
|
- Days 6-7: Documentation + deployment
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 🎯 SUCCESS CRITERIA
|
||
|
|
|
||
|
|
### Minimum Viable Product (MVP)
|
||
|
|
|
||
|
|
- ✅ All Priority 1 tasks complete
|
||
|
|
- ✅ 100-bot stress test passing
|
||
|
|
- ✅ Zero critical bugs
|
||
|
|
- ✅ Performance targets met
|
||
|
|
- ✅ Documentation complete
|
||
|
|
|
||
|
|
### Production Ready
|
||
|
|
|
||
|
|
- ✅ All Priority 1 + 2 tasks complete
|
||
|
|
- ✅ 1000-bot scalability test passing
|
||
|
|
- ✅ 48-hour stability test passing
|
||
|
|
- ✅ All tests passing
|
||
|
|
- ✅ Deployment guide complete
|
||
|
|
|
||
|
|
### Enterprise Grade
|
||
|
|
|
||
|
|
- ✅ All tasks complete
|
||
|
|
- ✅ 5000-bot capacity validated
|
||
|
|
- ✅ Advanced profiling available
|
||
|
|
- ✅ Comprehensive monitoring
|
||
|
|
- ✅ API documentation (Doxygen)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 📝 NOTES
|
||
|
|
|
||
|
|
### Development Best Practices
|
||
|
|
|
||
|
|
1. **Branch Strategy**
|
||
|
|
- Use `playerbot-dev` for development
|
||
|
|
- Create feature branches for major tasks
|
||
|
|
- Merge to `master` only after full validation
|
||
|
|
|
||
|
|
2. **Commit Messages**
|
||
|
|
- Follow TrinityCore convention: `[PlayerBot] Category: Description`
|
||
|
|
- Reference issue numbers when applicable
|
||
|
|
- Include testing notes in commit body
|
||
|
|
|
||
|
|
3. **Code Review**
|
||
|
|
- Self-review against CLAUDE.md guidelines
|
||
|
|
- No shortcuts or TODOs in production code
|
||
|
|
- Performance validation for critical paths
|
||
|
|
|
||
|
|
4. **Testing**
|
||
|
|
- Write tests for new features
|
||
|
|
- Run existing tests before committing
|
||
|
|
- Performance benchmarks for optimization work
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 🏆 CONCLUSION
|
||
|
|
|
||
|
|
This implementation plan provides a **clear, actionable roadmap** to complete the TrinityCore PlayerBot Module. By focusing on **Priority 1 critical blockers** first, the project can reach MVP status within 1 week, with full production readiness achievable in 3-4 weeks.
|
||
|
|
|
||
|
|
The architecture is **solid and enterprise-grade**, with most difficult work already complete. The remaining tasks are primarily **feature completion and polish**, making this a **low-risk, high-value** effort.
|
||
|
|
|
||
|
|
**Recommended Approach**: Execute tasks in priority order, with emphasis on testing and validation at each stage. This ensures steady progress toward a robust, scalable bot system supporting 5000+ concurrent bots.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
**Document Version**: 1.0
|
||
|
|
**Status**: COMPREHENSIVE PLAN READY FOR EXECUTION ✅
|
||
|
|
**Next Review**: After Priority 1 completion
|
||
|
|
**Estimated Completion**: 3-4 weeks (full-time equivalent)
|