Files
Beyhan Oğur d5f52cc3d3 first commit
2026-09-03 04:45:36 +03:00

482 lines
22 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Action Commands
<cite>
**Referenced Files in This Document**
- [ActionCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ActionCommands.cs)
- [MacroInvoker.cs](file://ClassicAssist.Shared/Data/Macros/MacroInvoker.cs)
- [Targeting.cs](file://ClassicAssist.Shared/Data/Hotkeys/Commands/Targeting.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
- [DragItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DragItem.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [Entity.cs](file://ClassicAssist.Shared/UO/Objects/Entity.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
- [Gump.cs](file://ClassicAssist.Shared/UO/Objects/Gumps/Gump.cs)
</cite>
## 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
This document explains the action commands available in the ClassicAssist.Avalonia macro system, focusing on user interaction automation such as clicking, right-clicking, dragging and dropping, context menu interactions, and button presses. It provides parameter specifications, return values, usage examples, common pitfalls, multi-step patterns, error handling strategies, execution context, timing considerations, and performance tips. The goal is to help you build robust macros that interact reliably with game entities, items, gumps, and menus.
## Project Structure
The action command functionality is implemented primarily in shared macro command modules and integrates with network packet handling and object models:
- Macro command definitions and invoker orchestration
- Targeting helpers for selecting entities
- Network packets for client actions (context menu, drag/drop, use)
- Packet queues and handlers for reliable delivery and response processing
- Object model classes for entities, items, mobiles, and gumps
```mermaid
graph TB
subgraph "Macros"
AC["ActionCommands.cs"]
MI["MacroInvoker.cs"]
TG["Targeting.cs"]
end
subgraph "UO Network"
Q["ActionPacketQueue.cs"]
IPH["IncomingPacketHandlers.cs"]
OPH["OutgoingPacketHandlers.cs"]
CM["ContextMenuClick.cs"]
DI["DragItem.cs"]
DO["DropItem.cs"]
UO["UseObject.cs"]
end
subgraph "UO Objects"
E["Entity.cs"]
I["Item.cs"]
M["Mobile.cs"]
G["Gump.cs"]
end
AC --> MI
AC --> TG
AC --> Q
AC --> CM
AC --> DI
AC --> DO
AC --> UO
Q --> IPH
Q --> OPH
AC --> E
AC --> I
AC --> M
AC --> G
```
**Diagram sources**
- [ActionCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ActionCommands.cs)
- [MacroInvoker.cs](file://ClassicAssist.Shared/Data/Macros/MacroInvoker.cs)
- [Targeting.cs](file://ClassicAssist.Shared/Data/Hotkeys/Commands/Targeting.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
- [DragItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DragItem.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [Entity.cs](file://ClassicAssist.Shared/UO/Objects/Entity.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
- [Gump.cs](file://ClassicAssist.Shared/UO/Objects/Gumps/Gump.cs)
**Section sources**
- [ActionCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ActionCommands.cs)
- [MacroInvoker.cs](file://ClassicAssist.Shared/Data/Macros/MacroInvoker.cs)
- [Targeting.cs](file://ClassicAssist.Shared/Data/Hotkeys/Commands/Targeting.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
- [DragItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DragItem.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [Entity.cs](file://ClassicAssist.Shared/UO/Objects/Entity.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
- [Gump.cs](file://ClassicAssist.Shared/UO/Objects/Gumps/Gump.cs)
## Core Components
- ActionCommands: Defines macro commands for click, right-click, drag-and-drop, context menu selection, and button presses. It resolves targets, constructs appropriate network packets, and enqueues them for sending.
- MacroInvoker: Orchestrates macro execution, parameter parsing, and command dispatch.
- Targeting: Provides helpers to resolve target references by ID or other criteria.
- Network Packets: ContextMenuClick, DragItem, DropItem, UseObject represent concrete actions sent to the server.
- ActionPacketQueue: Queues outgoing action packets and coordinates ordering and timing.
- Incoming/Outgoing Handlers: Process responses and ensure state consistency after actions.
- Object Models: Entity, Item, Mobile, Gump provide data used to validate and address actions.
Key responsibilities:
- Resolve target objects safely before issuing actions
- Build correct packet payloads with IDs, indices, and coordinates
- Enqueue actions with proper timing to avoid race conditions
- Handle success/failure feedback via packet responses
**Section sources**
- [ActionCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ActionCommands.cs)
- [MacroInvoker.cs](file://ClassicAssist.Shared/Data/Macros/MacroInvoker.cs)
- [Targeting.cs](file://ClassicAssist.Shared/Data/Hotkeys/Commands/Targeting.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
- [DragItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DragItem.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [Entity.cs](file://ClassicAssist.Shared/UO/Objects/Entity.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
- [Gump.cs](file://ClassicAssist.Shared/UO/Objects/Gumps/Gump.cs)
## Architecture Overview
The macro system composes high-level commands into low-level network operations:
- Macros call ActionCommands methods
- ActionCommands validates inputs, resolves targets, and creates packets
- ActionPacketQueue orders and sends packets
- Handlers process incoming responses and update UI/state
```mermaid
sequenceDiagram
participant Macro as "Macro Script"
participant Invoker as "MacroInvoker"
participant Actions as "ActionCommands"
participant Queue as "ActionPacketQueue"
participant Net as "Network Handlers"
participant Game as "Game Server"
Macro->>Invoker : Execute macro step
Invoker->>Actions : Call action method (e.g., Click, RightClick, DragDrop)
Actions->>Actions : Validate parameters and resolve target
Actions->>Queue : Enqueue packet (UseObject/ContextMenuClick/DragItem/DropItem)
Queue->>Net : Send packet(s)
Net-->>Actions : Response events (success/failure)
Actions-->>Invoker : Return status/result
Invoker-->>Macro : Continue or handle error
```
**Diagram sources**
- [MacroInvoker.cs](file://ClassicAssist.Shared/Data/Macros/MacroInvoker.cs)
- [ActionCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ActionCommands.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
- [DragItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DragItem.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
## Detailed Component Analysis
### Click Command
Purpose: Perform a left-click on a target entity or item.
Parameters:
- Target reference: ID or resolved object (Entity/Item/Mobile)
- Optional offset: Relative coordinates if supported by the underlying operation
- Optional delay: Milliseconds to wait before executing
Return value:
- Boolean indicating success or failure based on packet send and response
Usage example:
- Click an item in your backpack to inspect it
- Left-click a mobile to initiate interaction
Common pitfalls:
- Target not visible or invalid ID leads to failure
- Rapid successive clicks may be throttled; add delays between clicks
Timing considerations:
- Insert small delays when chaining multiple clicks to avoid queue saturation
Integration:
- Often followed by context menu selection or property inspection
Error handling:
- Check return value and log failures
- Retry with updated target resolution if needed
**Section sources**
- [ActionCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ActionCommands.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [Entity.cs](file://ClassicAssist.Shared/UO/Objects/Entity.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
### Right-Click Command
Purpose: Open a context menu for a target entity or item.
Parameters:
- Target reference: ID or resolved object
- Optional delay: Milliseconds to wait before opening the menu
Return value:
- Boolean indicating success or failure
Usage example:
- Right-click a vendor to open buy/sell options
- Right-click a container to view contents
Common pitfalls:
- Some objects do not support context menus; verify capability before invoking
- Ensure the target is in range and valid
Timing considerations:
- Allow time for the context menu to appear before selecting an option
Integration:
- Typically followed by a context menu selection command
Error handling:
- If no menu appears, abort subsequent steps and report error
**Section sources**
- [ActionCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ActionCommands.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [Entity.cs](file://ClassicAssist.Shared/UO/Objects/Entity.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
### Drag-and-Drop Operations
Purpose: Initiate a drag from a source object and drop onto a destination.
Parameters:
- Source reference: ID or resolved object (Item/Mobile)
- Destination reference: ID or resolved object (Container/Location)
- Optional offsets: Relative coordinates for precise placement
- Optional delay: Milliseconds between drag start and drop
Return value:
- Boolean indicating success or failure
Usage example:
- Move an item from backpack to a specific container slot
- Transfer gold from one bag to another
Common pitfalls:
- Invalid source or destination types cause immediate failure
- Insufficient space at destination results in drop failure
- Race conditions if multiple macros manipulate inventory concurrently
Timing considerations:
- Add a short delay after initiating the drag to allow server acknowledgment
- Delay before drop to ensure destination is ready
Integration:
- Combine with context menu to open containers prior to drop
Error handling:
- Detect drop failure via packet responses and retry with adjusted parameters
**Section sources**
- [ActionCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ActionCommands.cs)
- [DragItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DragItem.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
### Context Menu Selection
Purpose: Select a specific menu entry for a previously opened context menu.
Parameters:
- Menu index or identifier: Numeric index or named entry depending on implementation
- Optional delay: Milliseconds to wait before selection
Return value:
- Boolean indicating success or failure
Usage example:
- Choose “Open” from a container’s context menu
- Select “Buy” from a vendor’s menu
Common pitfalls:
- Menu entries vary by object type and shard behavior; always verify expected index
- Stale menu state if previous context menu did not open correctly
Timing considerations:
- Wait until the context menu is fully rendered before selecting
Integration:
- Follows a right-click command; often precedes further actions like buying or inspecting
Error handling:
- If selection fails, re-open the context menu and retry
**Section sources**
- [ActionCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ActionCommands.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
### Button Press (Gump Interaction)
Purpose: Interact with gump buttons to confirm dialogs, navigate menus, or trigger actions.
Parameters:
- Gump ID: Identifier of the target gump
- Button ID: Specific button within the gump
- Optional delay: Milliseconds to wait before pressing
Return value:
- Boolean indicating success or failure
Usage example:
- Confirm a trade window by pressing the accept button
- Navigate through wizard-style gumps by pressing next/previous buttons
Common pitfalls:
- Gump may have closed or changed state; verify presence before pressing
- Button IDs can differ across shards or versions
Timing considerations:
- Ensure the gump is fully loaded before interacting
Integration:
- Often follows context menu selections or confirmation prompts
Error handling:
- If the gump is not found, abort and report missing dialog
**Section sources**
- [ActionCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ActionCommands.cs)
- [Gump.cs](file://ClassicAssist.Shared/UO/Objects/Gumps/Gump.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
### Multi-Step Automation Example
Scenario: Buy an item from a vendor using a macro sequence.
Steps:
1. Right-click the vendor to open its context menu
2. Select the “Buy” menu entry
3. Locate the desired item in the vendor list
4. Click the buy button or press the corresponding gump button
5. Confirm the transaction if prompted
6. Verify purchase success and proceed
```mermaid
flowchart TD
Start(["Start"]) --> RC["Right-click Vendor"]
RC --> |Success| BM["Select 'Buy' Entry"]
RC --> |Failure| AbortRC["Abort: No Menu"]
BM --> |Success| LI["Locate Item"]
BM --> |Failure| AbortBM["Abort: Wrong Index"]
LI --> |Found| BB["Press Buy Button"]
LI --> |Not Found| AbortLI["Abort: Item Missing"]
BB --> |Success| Conf["Confirm Transaction"]
BB --> |Failure| AbortBB["Abort: Button Error"]
Conf --> |Success| Done(["Done"])
Conf --> |Failure| AbortConf["Abort: Confirmation Failed"]
```
[No sources needed since this diagram shows conceptual workflow, not actual code structure]
## Dependency Analysis
Action commands depend on several subsystems:
- MacroInvoker for command dispatch and parameter handling
- Targeting for resolving target references
- Network packets for constructing and sending actions
- Packet queue for ordering and timing
- Handlers for processing responses and updating state
```mermaid
graph LR
MI["MacroInvoker.cs"] --> AC["ActionCommands.cs"]
AC --> TG["Targeting.cs"]
AC --> CM["ContextMenuClick.cs"]
AC --> DI["DragItem.cs"]
AC --> DO["DropItem.cs"]
AC --> UO["UseObject.cs"]
AC --> Q["ActionPacketQueue.cs"]
Q --> IPH["IncomingPacketHandlers.cs"]
Q --> OPH["OutgoingPacketHandlers.cs"]
AC --> E["Entity.cs"]
AC --> I["Item.cs"]
AC --> M["Mobile.cs"]
AC --> G["Gump.cs"]
```
**Diagram sources**
- [MacroInvoker.cs](file://ClassicAssist.Shared/Data/Macros/MacroInvoker.cs)
- [ActionCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ActionCommands.cs)
- [Targeting.cs](file://ClassicAssist.Shared/Data/Hotkeys/Commands/Targeting.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
- [DragItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DragItem.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [Entity.cs](file://ClassicAssist.Shared/UO/Objects/Entity.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
- [Gump.cs](file://ClassicAssist.Shared/UO/Objects/Gumps/Gump.cs)
**Section sources**
- [MacroInvoker.cs](file://ClassicAssist.Shared/Data/Macros/MacroInvoker.cs)
- [ActionCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ActionCommands.cs)
- [Targeting.cs](file://ClassicAssist.Shared/Data/Hotkeys/Commands/Targeting.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [ContextMenuClick.cs](file://ClassicAssist.Shared/UO/Network/Packets/ContextMenuClick.cs)
- [DragItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DragItem.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [Entity.cs](file://ClassicAssist.Shared/UO/Objects/Entity.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
- [Gump.cs](file://ClassicAssist.Shared/UO/Objects/Gumps/Gump.cs)
## Performance Considerations
- Batch actions where possible: Group related clicks or menu selections to reduce overhead
- Use minimal delays: Only add necessary pauses to avoid race conditions
- Avoid redundant target resolution: Cache resolved IDs when safe to reuse
- Monitor packet queue depth: Excessive queuing can cause latency; throttle macro speed
- Prefer direct object references: When possible, pass resolved objects instead of repeated lookups
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and resolutions:
- Target not found: Validate IDs and visibility before action; implement fallback logic
- Context menu does not open: Re-attempt right-click; verify object supports context menus
- Drag-and-drop fails: Check destination capacity and type compatibility; adjust offsets
- Gump button press ignored: Confirm gump exists and button ID matches current state
- Timing errors: Increase delays between steps; observe server responses for readiness
Error handling patterns:
- Always check return values of action commands
- Log detailed context (target ID, action type, parameters) on failure
- Implement retries with backoff for transient failures
- Provide clear macro termination points when prerequisites are not met
**Section sources**
- [ActionCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ActionCommands.cs)
- [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs)
- [OutgoingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/OutgoingPacketHandlers.cs)
- [ActionPacketQueue.cs](file://ClassicAssist.Shared/UO/Network/ActionPacketQueue.cs)
## Conclusion
Action commands in the ClassicAssist.Avalonia macro system enable powerful automation of clicks, context menu interactions, drag-and-drop, and gump button presses. By understanding parameter specifications, return values, timing, and integration points, you can construct robust macros that handle complex workflows reliably. Apply the recommended error handling and performance practices to minimize failures and optimize execution speed.