6.1 KiB
PlayerBot Architecture Refactoring - Integration Report
Executive Summary
The architecture refactoring to fix bot following issues has been partially implemented. The core files have been updated with the new clean update chain architecture, but integration issues remain due to interface mismatches with existing code.
Completed Work
1. Core Files Updated ✅
- C:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\BotAI.h - Replaced with refactored version
- C:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\BotAI.cpp - Replaced with refactored version
- C:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\ClassAI\ClassAI.h - Replaced with refactored version
- C:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\ClassAI\ClassAI.cpp - Replaced with refactored version
2. Architecture Improvements Implemented ✅
- Single
UpdateAI()entry point - no moreDoUpdateAI/UpdateEnhancedconfusion - Clean
OnCombatUpdate()virtual method for combat specialization - No throttling of base behaviors - ensures smooth following
- Clear separation between base behaviors (BotAI) and combat specialization (ClassAI)
3. API Compatibility Fixes Applied ✅
- Fixed
ObjectGuidusage (usingObjectGuid::Emptyinstead ofnullptr) - Fixed
Groupiteration (usingGetMembers()with range-based for) - Fixed
Player::isMoving()API calls - Fixed
GetRelativeAngle()method usage - Fixed
SpellHistory::GetRemainingCooldown()API
Integration Issues Encountered
1. Strategy Interface Mismatch ❌
Issue: Refactored BotAI expects:
Strategy::Update(BotAI*, uint32)Strategy::OnCombatStart(BotAI*, Unit*)Strategy::OnCombatEnd(BotAI*)
Actual Interface:
Strategy::UpdateBehavior(BotAI*, uint32)- No combat lifecycle methods
Impact: BotAI.cpp compilation errors when calling non-existent methods
2. Trigger Interface Mismatch ❌
Issue: Refactored BotAI expects:
Trigger::GetResult(BotAI*)TriggerResult::actionName
Actual Interface: Different trigger result structure
Impact: Trigger processing logic fails to compile
3. BotAIFactory Methods Missing ❌
Issue: Factory methods don't match:
- Missing
CreateSpecializedAI(),CreatePvPAI(), etc. Player::getClass()vs actual API
Impact: AI creation logic fails
4. Class AI Member Variables ❌
Issue: Some class AIs have their own _currentTarget as ObjectGuid
- HunterAI, PaladinAI, MageAI, WarlockAI
Impact: Type conflicts and assignment errors
Recommended Next Steps
Option 1: Adapt Refactored Code (Recommended)
-
Fix Strategy Interface
// In BotAI.cpp, change: strategy->Update(this, diff); // To: strategy->UpdateBehavior(this, diff); -
Remove Combat Lifecycle from Strategies
- Remove calls to
OnCombatStart/Endon strategies - Keep these only on ClassAI level
- Remove calls to
-
Fix Trigger Processing
- Analyze actual
Triggerinterface - Adapt trigger processing to match
- Analyze actual
-
Clean Up Class AI Conflicts
- Remove duplicate
_currentTargetmembers - Use base class member consistently
- Remove duplicate
Option 2: Incremental Refactor
- Keep existing BotAI/ClassAI structure
- Only apply the key fix: Remove throttling from movement updates
- Add
OnCombatUpdate()as optional override - Gradually migrate functionality
Option 3: Full Revert and Redesign
- Revert all changes
- Design new architecture that matches existing interfaces
- Implement with full compatibility from start
Critical Success Factors
The main goal was to fix bot following issues caused by:
- Update throttling - PARTIALLY FIXED (architecture supports it, needs integration)
- Dual update paths - FIXED (single UpdateAI entry point)
- Movement control conflicts - FIXED (ClassAI no longer controls movement)
Performance Impact
- Every-frame updates now possible for strategies
- No throttling on core behaviors
- Combat updates cleanly separated
- Should achieve smooth following once integration issues resolved
Files Modified
Core Architecture Files
C:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\BotAI.hC:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\BotAI.cppC:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\ClassAI\ClassAI.hC:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\ClassAI\ClassAI.cpp
Class AI Files Requiring Updates
C:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\ClassAI\Hunters\HunterAI.cppC:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\ClassAI\Paladins\PaladinAI.cppC:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\ClassAI\Mages\MageAI_Specialization.cppC:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\ClassAI\Warlocks\WarlockAI_Specialization.cpp
Conclusion
The architecture refactoring provides a clean foundation for fixing the bot following issues. However, integration with the existing codebase requires additional work to adapt the interfaces. The core improvements are sound:
✅ Single update path established ✅ Combat specialization separated ✅ Movement control centralized ✅ Throttling removed from base behaviors
❌ Strategy interface adaptation needed ❌ Trigger processing needs adjustment ❌ Class AI member conflicts need resolution ❌ Factory methods need alignment
Recommendation: Continue with Option 1 - adapt the refactored code to match existing interfaces. The architectural improvements are valuable and worth preserving.
Build Commands for Testing
# Windows build command
cd /c/TrinityBots/TrinityCore && cmake --build build --config RelWithDebInfo --target worldserver -j4
# Check for errors
cmake --build build --config RelWithDebInfo --target worldserver -j4 2>&1 | grep -E "error|FAILED"
Backup Files Location
Original files are preserved as:
C:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\BotAI_Refactored.hC:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\BotAI_Refactored.cppC:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\ClassAI\ClassAI_Refactored.hC:\TrinityBots\TrinityCore\src\modules\Playerbot\AI\ClassAI\ClassAI_Refactored.cpp