# Game Automation Features **Referenced Files in This Document** - [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs) - [AutolootEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs) - [AutolootConstraintEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs) - [PropertyEntry.cs](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs) - [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs) - [DressAgentEntry.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs) - [DressAgentItem.cs](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs) - [ScavengerManager.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs) - [ScavengerEntry.cs](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs) - [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs) - [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs) - [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs) - [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs) - [AutolootTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.xaml.cs) - [DressTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs) - [ScavengerTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.xaml.cs) - [VendorBuyTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml.cs) - [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs) ## Table of Contents 1. [Introduction](#introduction) 2. [Project Structure](#project-structure) 3. [Core Components](#core-components) 4. [Architecture Overview](#architecture-overview) 5. [Detailed Component Analysis](#detailed-component-analysis) 6. [Dependency Analysis](#dependency-analysis) 7. [Performance Considerations](#performance-considerations) 8. [Troubleshooting Guide](#troubleshooting-guide) 9. [Conclusion](#conclusion) ## Introduction ClassicAssist.Avalonia provides a comprehensive game automation framework designed to streamline repetitive gameplay tasks in Ultima Online. The system is built around an extensible agent architecture that powers various automated features including autoloot management, equipment dressing, resource scavenging, and vendor operations. This documentation covers the complete automation ecosystem, explaining how each component works together to provide seamless gameplay automation. The automation system is designed with performance and reliability in mind, featuring rule-based filtering, property matching, inventory management, and route optimization capabilities. Each agent operates independently while maintaining coordination through shared data structures and event-driven communication patterns. ## Project Structure The ClassicAssist.Avalonia automation system follows a modular architecture with clear separation between business logic, user interface, and data management layers. The core automation components are organized within the Shared library, while platform-specific implementations reside in the Avalonia UI layer. ```mermaid graph TB subgraph "Shared Core" Autoloot["Autoloot System"] Dress["Dress Manager"] Scavenger["Scavenger Agent"] Vendor["Vendor Agents"] end subgraph "Avalonia UI Layer" AutolootUI["Autoloot Tab Control"] DressUI["Dress Tab Control"] ScavengerUI["Scavenger Tab Control"] VendorUI["Vendor Tab Controls"] end subgraph "Game Engine Integration" PacketHandler["Packet Handler"] ObjectManager["Object Manager"] Inventory["Inventory Manager"] end Autoloot --> AutolootUI Dress --> DressUI Scavenger --> ScavengerUI Vendor --> VendorUI AutolootUI --> PacketHandler DressUI --> PacketHandler ScavengerUI --> PacketHandler VendorUI --> PacketHandler PacketHandler --> ObjectManager PacketHandler --> Inventory ``` **Diagram sources** - [AutolootManager.cs:1-50](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs#L1-L50) - [DressManager.cs:1-50](file://ClassicAssist.Shared/Data/Dress/DressManager.cs#L1-L50) - [ScavengerManager.cs:1-50](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs#L1-L50) - [VendorBuyAgentEntry.cs:1-50](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs#L1-L50) **Section sources** - [AutolootManager.cs:1-100](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs#L1-L100) - [DressManager.cs:1-100](file://ClassicAssist.Shared/Data/Dress/DressManager.cs#L1-L100) - [ScavengerManager.cs:1-100](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs#L1-L100) ## Core Components The automation system consists of several key components, each responsible for specific gameplay automation tasks: ### Agent Framework Architecture The agent framework provides a foundation for creating specialized automation agents. Each agent implements common interfaces for lifecycle management, configuration handling, and execution control. The framework supports both synchronous and asynchronous operation modes, allowing agents to run concurrently without interfering with each other. ### Autoloot System The autoloot system automatically collects items dropped by defeated enemies based on configurable rules. It supports complex filtering criteria including item properties, names, hues, and custom attributes. The system uses a priority-based approach to handle conflicts when multiple rules match the same item. ### Dress Manager The dress manager handles automatic equipment changes based on scenarios such as combat, resting, or skill training. It maintains multiple equipment sets and can switch between them automatically based on game state conditions. The system ensures proper equipment slot management and validates item compatibility before applying changes. ### Scavenger Agent The scavenger agent automates resource gathering by navigating to resource nodes and collecting materials. It includes intelligent pathfinding, inventory management, and route optimization to maximize collection efficiency. The agent can handle different resource types and adapts its behavior based on available tools and character skills. ### Vendor Agents The vendor agents automate buying and selling operations with shops. They support price tracking, stock monitoring, and bulk transactions. The buy agent can purchase items from shop inventories based on predefined lists, while the sell agent manages selling excess inventory to vendors. **Section sources** - [AutolootEntry.cs:1-100](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs#L1-L100) - [DressAgentEntry.cs:1-100](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs#L1-L100) - [ScavengerEntry.cs:1-100](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs#L1-L100) - [VendorBuyAgentEntry.cs:1-100](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs#L1-L100) - [VendorSellAgentEntry.cs:1-100](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs#L1-L100) ## Architecture Overview The automation system follows a layered architecture pattern with clear separation of concerns. The core logic resides in the Shared library, providing cross-platform compatibility, while the Avalonia layer handles user interface and platform-specific interactions. ```mermaid classDiagram class AgentBase { +string Name +bool IsEnabled +bool IsRunning +void Start() +void Stop() +void Pause() +void Resume() +void Configure(config) +object GetState() } class AutolootAgent { +AutolootRule[] Rules +void ProcessItem(item) +void AddRule(rule) +void RemoveRule(id) +bool ShouldCollect(item) } class DressAgent { +EquipmentSet[] Sets +string CurrentSet +void ApplySet(setName) +void SwitchToCombat() +void SwitchToRest() +void ValidateEquipment() } class ScavengerAgent { +ResourceNode[] TargetNodes +string CurrentRoute +void NavigateTo(node) +void CollectResources() +void OptimizeRoute() +void ManageInventory() } class VendorAgent { +ShopList[] BuyLists +SellList[] SellLists +void ExecuteBuy(listName) +void ExecuteSell(listName) +void UpdatePrices() +void MonitorStock() } AgentBase <|-- AutolootAgent AgentBase <|-- DressAgent AgentBase <|-- ScavengerAgent AgentBase <|-- VendorAgent AutolootAgent --> AutolootRule : "uses" DressAgent --> EquipmentSet : "manages" ScavengerAgent --> ResourceNode : "targets" VendorAgent --> ShopList : "processes" ``` **Diagram sources** - [AutolootManager.cs:1-150](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs#L1-L150) - [DressManager.cs:1-150](file://ClassicAssist.Shared/Data/Dress/DressManager.cs#L1-L150) - [ScavengerManager.cs:1-150](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs#L1-L150) - [VendorBuyAgentEntry.cs:1-150](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs#L1-L150) ## Detailed Component Analysis ### Autoloot System Architecture The autoloot system implements a sophisticated rule-based filtering engine that processes incoming item drops and determines whether they should be collected. The system supports multiple constraint types and logical operators for complex matching scenarios. ```mermaid sequenceDiagram participant Game as "Game Engine" participant Autoloot as "Autoloot Manager" participant RuleEngine as "Rule Engine" participant Filter as "Filter Processor" participant Action as "Action Handler" Game->>Autoloot : ItemDropEvent(item) Autoloot->>RuleEngine : EvaluateRules(item) RuleEngine->>Filter : CheckConstraints(item) Filter->>Filter : MatchProperties(item) Filter->>Filter : ValidateConditions(item) Filter-->>RuleEngine : MatchResult RuleEngine->>RuleEngine : ApplyLogicOperators() RuleEngine-->>Autoloot : Decision(collect/drop) Autoloot->>Action : ExecuteAction(decision) Action->>Game : PickupItem()/DropItem() ``` **Diagram sources** - [AutolootManager.cs:1-200](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs#L1-L200) - [AutolootEntry.cs:1-200](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs#L1-L200) - [AutolootConstraintEntry.cs:1-200](file://ClassicAssist.Shared/Data/Autoloot/AutolootConstraintEntry.cs#L1-L200) #### Autoloot Rule Syntax and Configuration The autoloot system supports a flexible rule syntax that allows players to define complex collection criteria. Rules can be combined using logical operators (AND, OR, NOT) to create sophisticated filtering conditions. Key rule components include: - **Property Matching**: Match items by name, hue, weight, value, or custom properties - **Conditional Logic**: Combine multiple conditions using boolean operators - **Priority Handling**: Assign priorities to resolve conflicts between matching rules - **Exception Lists**: Define exceptions to general collection policies **Section sources** - [AutolootManager.cs:1-300](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs#L1-L300) - [AutolootEntry.cs:1-300](file://ClassicAssist.Shared/Data/Autoloot/AutolootEntry.cs#L1-L300) - [PropertyEntry.cs:1-200](file://ClassicAssist.Shared/Data/Autoloot/PropertyEntry.cs#L1-L200) ### Dress Manager Implementation The dress manager provides automated equipment management with scenario-based switching capabilities. It maintains multiple equipment configurations and can automatically transition between them based on game state detection. ```mermaid flowchart TD Start([Equipment Change Request]) --> ValidateRequest["Validate Equipment Set"] ValidateRequest --> CheckCompatibility{"Items Compatible?"} CheckCompatibility --> |No| Error["Show Compatibility Error"] CheckCompatibility --> |Yes| CheckSlots["Check Equipment Slots"] CheckSlots --> SlotAvailable{"Slots Available?"} SlotAvailable --> |No| HandleConflict["Resolve Slot Conflicts"] SlotAvailable --> |Yes| EquipItems["Equip Items Sequentially"] HandleConflict --> ResolveStrategy{"Resolution Strategy"} ResolveStrategy --> |Auto| AutoResolve["Automatically Resolve"] ResolveStrategy --> |Manual| PromptUser["Prompt User Input"] AutoResolve --> EquipItems PromptUser --> EquipItems EquipItems --> VerifyEquipped["Verify Equipment Applied"] VerifyEquipped --> Success{"All Items Equipped?"} Success --> |No| RetryEquip["Retry Failed Equips"] Success --> |Yes| Complete["Complete Equipment Change"] RetryEquip --> VerifyEquipped Complete --> End([Equipment Change Complete]) Error --> End ``` **Diagram sources** - [DressManager.cs:1-250](file://ClassicAssist.Shared/Data/Dress/DressManager.cs#L1-L250) - [DressAgentEntry.cs:1-250](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs#L1-L250) - [DressAgentItem.cs:1-200](file://ClassicAssist.Shared/Data/Dress/DressAgentItem.cs#L1-L200) #### Equipment Set Management The dress manager supports multiple equipment sets with advanced validation and conflict resolution. Each set defines specific items for each equipment slot, with options for conditional application based on character state, location, or other factors. **Section sources** - [DressManager.cs:1-400](file://ClassicAssist.Shared/Data/Dress/DressManager.cs#L1-L400) - [DressAgentEntry.cs:1-400](file://ClassicAssist.Shared/Data/Dress/DressAgentEntry.cs#L1-L400) ### Scavenger Agent System The scavenger agent provides automated resource gathering with intelligent navigation and inventory management. It optimizes collection routes and adapts to changing game conditions to maximize efficiency. ```mermaid stateDiagram-v2 [*] --> Idle Idle --> Planning : "Start Collection" Planning --> Navigating : "Route Optimized" Navigating --> Collecting : "At Resource Node" Collecting --> InventoryCheck : "Collection Complete" InventoryCheck --> Full{"Inventory Full?"} Full --> |Yes| Returning : "Return to Base" Full --> |No| Planning : "Plan Next Route" Returning --> Restocking : "Deposit Resources" Restocking --> Planning : "Resupply Complete" Planning --> Idle : "Stop Collection" Navigating --> Idle : "Stop Collection" Collecting --> Idle : "Stop Collection" ``` **Diagram sources** - [ScavengerManager.cs:1-300](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs#L1-L300) - [ScavengerEntry.cs:1-300](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs#L1-L300) #### Resource Gathering Optimization The scavenger agent implements advanced algorithms for route optimization and resource prioritization. It considers factors such as distance, resource availability, character skills, and tool durability to determine optimal collection strategies. **Section sources** - [ScavengerManager.cs:1-500](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs#L1-L500) - [ScavengerEntry.cs:1-500](file://ClassicAssist.Shared/Data/Scavenger/ScavengerEntry.cs#L1-L500) ### Vendor Agent Framework The vendor agent system automates trading operations with comprehensive buy and sell functionality. It supports price tracking, stock monitoring, and bulk transaction processing with error handling and retry mechanisms. ```mermaid sequenceDiagram participant Player as "Player Character" participant VendorAgent as "Vendor Agent" participant Shop as "Shop Interface" participant Inventory as "Character Inventory" participant Bank as "Bank Storage" Note over VendorAgent : Buy Operation Player->>VendorAgent : ExecuteBuy(listName) VendorAgent->>Shop : OpenShop() Shop-->>VendorAgent : ShopInventory[] VendorAgent->>VendorAgent : CompareWithBuyList() VendorAgent->>Shop : PurchaseItems(items) Shop-->>VendorAgent : TransactionResult VendorAgent->>Inventory : StorePurchasedItems() VendorAgent-->>Player : BuyComplete(result) Note over VendorAgent : Sell Operation Player->>VendorAgent : ExecuteSell(listName) VendorAgent->>Inventory : ScanForSellItems() VendorAgent->>VendorAgent : FilterBySellList() VendorAgent->>Shop : OpenShop() VendorAgent->>Shop : SellItems(items) Shop-->>VendorAgent : TransactionResult VendorAgent-->>Player : SellComplete(result) ``` **Diagram sources** - [VendorBuyAgentEntry.cs:1-300](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs#L1-L300) - [VendorSellAgentEntry.cs:1-300](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs#L1-L300) - [ShopListEntry.cs:1-200](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs#L1-L200) - [SellListEntry.cs:1-200](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs#L1-L200) #### Price Tracking and Stock Monitoring The vendor agents maintain historical price data and monitor shop inventory changes to provide insights into market trends. This information helps optimize buying and selling strategies for maximum profit. **Section sources** - [VendorBuyAgentEntry.cs:1-400](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs#L1-L400) - [VendorSellAgentEntry.cs:1-400](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs#L1-L400) - [ShopListEntry.cs:1-300](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs#L1-L300) - [SellListEntry.cs:1-300](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs#L1-L300) ## Dependency Analysis The automation system exhibits careful dependency management with clear separation between core logic and UI components. Each agent operates independently while sharing common infrastructure services. ```mermaid graph TB subgraph "Core Dependencies" Engine["Game Engine API"] Network["Network Layer"] Storage["Configuration Storage"] Logging["Logging System"] end subgraph "Agent Dependencies" Autoloot["Autoloot Agent"] Dress["Dress Agent"] Scavenger["Scavenger Agent"] Vendor["Vendor Agents"] end subgraph "Shared Services" EventSystem["Event System"] QueueManager["Queue Manager"] ErrorHandler["Error Handler"] ConfigManager["Configuration Manager"] end Engine --> Autoloot Engine --> Dress Engine --> Scavenger Engine --> Vendor Network --> Autoloot Network --> Dress Network --> Scavenger Network --> Vendor Storage --> ConfigManager Logging --> ErrorHandler Autoloot --> EventSystem Dress --> EventSystem Scavenger --> EventSystem Vendor --> EventSystem Autoloot --> QueueManager Dress --> QueueManager Scavenger --> QueueManager Vendor --> QueueManager ``` **Diagram sources** - [AutolootManager.cs:1-100](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs#L1-L100) - [DressManager.cs:1-100](file://ClassicAssist.Shared/Data/Dress/DressManager.cs#L1-L100) - [ScavengerManager.cs:1-100](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs#L1-L100) - [VendorBuyAgentEntry.cs:1-100](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs#L1-L100) **Section sources** - [AutolootManager.cs:1-200](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs#L1-L200) - [DressManager.cs:1-200](file://ClassicAssist.Shared/Data/Dress/DressManager.cs#L1-L200) - [ScavengerManager.cs:1-200](file://ClassicAssist.Shared/Data/Scavenger/ScavengerManager.cs#L1-L200) ## Performance Considerations The automation system is designed with performance optimization as a primary concern. Several key strategies ensure efficient operation even with complex automation rules and large datasets. ### Memory Management - **Lazy Loading**: Agents load configuration and data only when needed - **Object Pooling**: Frequently used objects are pooled to reduce garbage collection pressure - **Memory Leaks Prevention**: Proper disposal patterns and weak references prevent memory accumulation ### Processing Efficiency - **Asynchronous Operations**: All long-running operations run asynchronously to prevent UI blocking - **Batch Processing**: Multiple operations are batched where possible to reduce overhead - **Caching Strategies**: Frequently accessed data is cached with appropriate invalidation policies ### Network Optimization - **Packet Throttling**: Outgoing packets are throttled to avoid overwhelming the game server - **Connection Resilience**: Automatic reconnection and retry mechanisms handle network interruptions - **Bandwidth Optimization**: Only necessary data is transmitted over the network ### Best Practices for Efficient Automation 1. **Rule Optimization**: Keep autoloot rules simple and well-ordered to minimize evaluation time 2. **Agent Coordination**: Avoid running conflicting agents simultaneously 3. **Resource Management**: Regularly clean up unused resources and reset agent states 4. **Monitoring**: Use logging and debugging tools to identify performance bottlenecks ## Troubleshooting Guide Common automation issues and their solutions: ### Autoloot Problems **Issue**: Items not being collected despite matching rules - **Solution**: Check rule priority order and verify property matching syntax - **Debug**: Enable detailed logging to see rule evaluation results **Issue**: False positives collecting unwanted items - **Solution**: Refine rule conditions and add more specific constraints - **Debug**: Test individual rules against sample items ### Dress Manager Issues **Issue**: Equipment changes failing or causing conflicts - **Solution**: Verify item compatibility and check equipment slot availability - **Debug**: Review equipment validation logs and error messages **Issue**: Automatic switching not triggering - **Solution**: Check condition evaluation logic and trigger events - **Debug**: Enable condition evaluation logging ### Scavenger Agent Problems **Issue**: Agent getting stuck or taking inefficient routes - **Solution**: Adjust pathfinding parameters and review resource node definitions - **Debug**: Enable navigation logging and route analysis **Issue**: Inventory management failures - **Solution**: Check storage access permissions and inventory capacity settings - **Debug**: Monitor inventory state changes and storage operations ### Vendor Agent Errors **Issue**: Buy/sell operations failing mid-transaction - **Solution**: Verify shop access and item availability - **Debug**: Enable transaction logging and error tracking **Issue**: Price tracking inaccuracies - **Solution**: Refresh price data and verify shop inventory synchronization - **Debug**: Monitor price update cycles and data consistency ### General Debugging Techniques 1. **Enable Verbose Logging**: Increase log detail level for problematic agents 2. **Use Debug Windows**: Utilize built-in debug interfaces for real-time monitoring 3. **Test Individual Components**: Isolate issues by testing agents independently 4. **Review Configuration**: Verify all settings and preferences are correctly configured 5. **Check Game State**: Ensure game conditions meet agent requirements **Section sources** - [AutolootTabControl.xaml.cs:1-200](file://ClassicAssist.Avalonia/Views/Agents/AutolootTabControl.xaml.cs#L1-L200) - [DressTabControl.xaml.cs:1-200](file://ClassicAssist.Avalonia/Views/Agents/DressTabControl.xaml.cs#L1-L200) - [ScavengerTabControl.xaml.cs:1-200](file://ClassicAssist.Avalonia/Views/Agents/ScavengerTabControl.xaml.cs#L1-L200) - [VendorBuyTabControl.xaml.cs:1-200](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml.cs#L1-L200) - [VendorSellTabControl.xaml.cs:1-200](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs#L1-L200) ## Conclusion ClassicAssist.Avalonia's game automation system provides a robust and flexible framework for automating repetitive gameplay tasks. The modular architecture ensures maintainability and extensibility, while the performance optimizations guarantee smooth operation even with complex automation scenarios. The system's strength lies in its comprehensive feature set, covering everything from basic item collection to sophisticated trading operations. Each agent is designed to operate independently while coordinating with others through shared infrastructure services. For users seeking to extend the automation capabilities, the well-documented agent framework provides a solid foundation for creating custom automation solutions. The consistent API design and comprehensive error handling make development straightforward while ensuring reliable operation in production environments. Future enhancements may include machine learning-based optimization, enhanced AI decision-making, and improved integration with external tools and services. The current architecture is well-positioned to accommodate these improvements while maintaining backward compatibility with existing configurations and plugins.