# Object Commands
**Referenced Files in This Document**
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Entity.cs](file://ClassicAssist.Shared/UO/Objects/Entity.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [TargetManager.cs](file://ClassicAssist.Shared/UO/Targeting/TargetManager.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [EquipRequest.cs](file://ClassicAssist.Shared/UO/Network/Packets/EquipRequest.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)
10. [Appendices](#appendices)
## Introduction
This document provides comprehensive documentation for the ObjectCommands macro commands that enable item and world object manipulation within ClassicAssist. It covers object inspection, property access, container management, querying by location and ownership, and lifecycle considerations. It also explains integration points with autoloot and dressing systems, and includes examples for inventory scanning, filtering, and automation workflows.
## Project Structure
The ObjectCommands functionality is implemented as part of the macro command system and interacts with core UO objects (items, mobiles, entities), networking packets, and agent managers (autoloot, dress, organizer). The relevant areas include:
- Macro commands: ObjectCommands
- Core objects: Item, Entity, Mobile, Property
- Networking: UseObject, DropItem, EquipRequest
- Agents: AutolootManager, DressManager, OrganizerManager
- Targeting: TargetManager
```mermaid
graph TB
subgraph "Macro Commands"
OC["ObjectCommands"]
end
subgraph "UO Objects"
E["Entity"]
I["Item"]
M["Mobile"]
P["Property"]
end
subgraph "Networking"
UO["UseObject Packet"]
DI["DropItem Packet"]
EQ["EquipRequest Packet"]
end
subgraph "Agents"
AL["AutolootManager"]
DR["DressManager"]
ORG["OrganizerManager"]
end
subgraph "Targeting"
TM["TargetManager"]
end
OC --> I
OC --> M
OC --> E
OC --> P
OC --> TM
OC --> UO
OC --> DI
OC --> EQ
OC --> AL
OC --> DR
OC --> ORG
```
**Diagram sources**
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Entity.cs](file://ClassicAssist.Shared/UO/Objects/Entity.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [EquipRequest.cs](file://ClassicAssist.Shared/UO/Network/Packets/EquipRequest.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [TargetManager.cs](file://ClassicAssist.Shared/UO/Targeting/TargetManager.cs)
**Section sources**
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Entity.cs](file://ClassicAssist.Shared/UO/Objects/Entity.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [EquipRequest.cs](file://ClassicAssist.Shared/UO/Network/Packets/EquipRequest.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [TargetManager.cs](file://ClassicAssist.Shared/UO/Targeting/TargetManager.cs)
## Core Components
- ObjectCommands: Provides macro commands to inspect, query, and manipulate items and world objects. It exposes methods for listing objects, retrieving properties, checking ownership, moving/dropping/equipping items, and interacting with containers.
- Item: Represents an in-game item with attributes such as serial, name, hue, weight, stackable status, and container relationships.
- Entity: Base class for all game entities including items and mobiles; provides common fields like position and map.
- Mobile: Represents player or NPC characters; extends entity with additional state and equipment slots.
- Property: Encapsulates dynamic or static properties associated with objects, enabling flexible inspection and filtering.
- Networking Packets: UseObject, DropItem, EquipRequest are used to perform actions on items via the client-server protocol.
- Agent Managers: AutolootManager, DressManager, OrganizerManager integrate with object commands to automate collection, dressing, and organization tasks.
Key responsibilities:
- Querying: Find items by criteria (name, type, hue, weight, location, owner).
- Inspection: Retrieve properties and metadata for display or decision-making.
- Manipulation: Use, drop, equip, move into/out of containers.
- Integration: Coordinate with autoloot rules, dress sets, and organizer entries.
**Section sources**
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Entity.cs](file://ClassicAssist.Shared/UO/Objects/Entity.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [EquipRequest.cs](file://ClassicAssist.Shared/UO/Network/Packets/EquipRequest.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
## Architecture Overview
ObjectCommands acts as a bridge between macro scripts and the underlying UO object model and network layer. It uses Entity/Item/Mobile abstractions to represent game objects, Property to expose attributes, and packet-based operations to interact with the server. Agent managers provide higher-level automation hooks.
```mermaid
sequenceDiagram
participant Macro as "Macro Script"
participant OC as "ObjectCommands"
participant Obj as "Item/Entity/Mobile"
participant Net as "Network Packets"
participant Agent as "Agent Manager"
Macro->>OC : Invoke object command (e.g., find, inspect, use, drop)
OC->>Obj : Resolve target(s) by criteria
OC->>Net : Send action packet (Use/Drop/Equip)
Net-->>OC : Acknowledge/State update
OC->>Agent : Notify or apply rule (autoloot/dress/organize)
Agent-->>OC : Result or next action
OC-->>Macro : Return result/status
```
**Diagram sources**
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Entity.cs](file://ClassicAssist.Shared/UO/Objects/Entity.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [EquipRequest.cs](file://ClassicAssist.Shared/UO/Network/Packets/EquipRequest.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
## Detailed Component Analysis
### ObjectCommands API Surface
ObjectCommands exposes macro-friendly methods for:
- Listing and filtering objects
- Inspecting properties
- Performing actions (use, drop, equip, move)
- Verifying ownership and targeting
- Coordinating with agents (autoloot, dress, organizer)
Representative method categories:
- Querying:
- Find items by name/type/hue/weight/location/owner
- List nearby items or items in a specific container
- Get first/last/matching item based on predicate
- Inspection:
- Read properties (static/dynamic)
- Retrieve metadata (serial, name, description)
- Manipulation:
- Use item
- Drop item
- Equip item to slot
- Move item into/out of container
- Ownership and targeting:
- Check if item belongs to player or another mobile
- Target an item or mobile
- Integration:
- Apply autoloot rules to picked-up items
- Update dress set when equipping/unequipping
- Organize items according to organizer entries
Method signatures overview (descriptive):
- FindItems(criteria): returns list of matching items
- GetProperties(object): returns collection of properties
- UseItem(item): performs use action
- DropItem(item): drops item at current location
- EquipItem(item, slot): attempts to equip item
- IsOwnedByPlayer(item): checks ownership
- TargetItem(item): targets an item
- MoveToContainer(item, container): moves item into container
- ApplyAutolootRules(item): evaluates autoloot constraints
- UpdateDressSet(equipAction): updates dress manager state
- OrganizeItem(item): applies organizer rules
Examples of usage patterns:
- Inventory scanning: iterate over player’s backpack contents, filter by type/name, and act on matches.
- Item filtering: build predicates combining hue, weight, and property values to select desired items.
- Container organization: scan ground items, match organizer entries, and move them into appropriate containers.
**Section sources**
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
- [Item.cs](file://ClassicAssist.Shared/UO/Objects/Item.cs)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
### Object Model Relationships
The object model centers around Entity as the base, with Item and Mobile as specialized types. Properties attach to objects to provide dynamic attributes.
```mermaid
classDiagram
class Entity {
+int Serial
+string Name
+int Hue
+int Weight
+Map Map
+Point2D Location
}
class Item {
+bool Stackable
+int Amount
+Item ParentContainer
+Item[] Children
+GetProperties()
}
class Mobile {
+EquipmentSlots Slots
+bool IsPlayer
+bool IsDead
+GetEquippedItem(slot)
}
class Property {
+string Key
+string Value
+Type ValueType
}
Entity <|-- Item
Entity <|-- Mobile
Item --> Property : "has many"
Mobile --> Property : "has many"
```
**Diagram sources**
- [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)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
**Section sources**
- [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)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
### Network Interaction Flow
Actions like using, dropping, and equipping items involve sending packets to the server and handling responses.
```mermaid
sequenceDiagram
participant OC as "ObjectCommands"
participant Net as "Network Layer"
participant Server as "Game Server"
OC->>Net : UseObject(itemSerial)
Net-->>Server : UseObject packet
Server-->>Net : Response/Update
Net-->>OC : State change acknowledged
OC->>Net : DropItem(itemSerial, destination)
Net-->>Server : DropItem packet
Server-->>Net : Response/Update
Net-->>OC : State change acknowledged
OC->>Net : EquipRequest(itemSerial, slot)
Net-->>Server : EquipRequest packet
Server-->>Net : Response/Update
Net-->>OC : State change acknowledged
```
**Diagram sources**
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [EquipRequest.cs](file://ClassicAssist.Shared/UO/Network/Packets/EquipRequest.cs)
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
**Section sources**
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [EquipRequest.cs](file://ClassicAssist.Shared/UO/Network/Packets/EquipRequest.cs)
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
### Autoloot Integration
ObjectCommands integrates with AutolootManager to evaluate rules when items are acquired or inspected. Typical flow:
- On item pickup or detection, ObjectCommands calls ApplyAutolootRules.
- AutolootManager checks constraints (type, hue, weight, properties).
- If matched, ObjectCommands may auto-use, drop, or move the item per configuration.
```mermaid
flowchart TD
Start(["Item Acquired"]) --> Evaluate["Evaluate Autoloot Rules"]
Evaluate --> Match{"Rule Matches?"}
Match --> |Yes| Action["Perform Auto Action
Use/Drop/Move"]
Match --> |No| Skip["Skip or Log"]
Action --> End(["Done"])
Skip --> End
```
**Diagram sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
**Section sources**
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
### Dress System Integration
When equipping or unequipping items, ObjectCommands can notify DressManager to maintain consistent dress sets. For example:
- EquipItem triggers UpdateDressSet to record changes.
- DressManager ensures future dressing actions align with current state.
```mermaid
sequenceDiagram
participant OC as "ObjectCommands"
participant DM as "DressManager"
participant Player as "Player Mobile"
OC->>DM : UpdateDressSet(equipAction, item, slot)
DM->>Player : Adjust equipped slots
DM-->>OC : Confirmation
```
**Diagram sources**
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
**Section sources**
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
- [Mobile.cs](file://ClassicAssist.Shared/UO/Objects/Mobile.cs)
### Organizer Integration
For container organization automation:
- ObjectCommands scans items and matches OrganizerManager entries.
- Items are moved into designated containers based on rules.
```mermaid
flowchart TD
Scan(["Scan Ground/Containers"]) --> MatchOrg["Match Organizer Entries"]
MatchOrg --> Move["Move Item to Target Container"]
Move --> Repeat{"More Items?"}
Repeat --> |Yes| Scan
Repeat --> |No| Done(["Complete"])
```
**Diagram sources**
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
**Section sources**
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
## Dependency Analysis
ObjectCommands depends on:
- Core object model (Entity, Item, Mobile, Property)
- Networking packets (UseObject, DropItem, EquipRequest)
- Agent managers (AutolootManager, DressManager, OrganizerManager)
- Targeting subsystem (TargetManager)
```mermaid
graph TB
OC["ObjectCommands"] --> E["Entity"]
OC --> I["Item"]
OC --> M["Mobile"]
OC --> P["Property"]
OC --> UO["UseObject"]
OC --> DI["DropItem"]
OC --> EQ["EquipRequest"]
OC --> AL["AutolootManager"]
OC --> DR["DressManager"]
OC --> ORG["OrganizerManager"]
OC --> TM["TargetManager"]
```
**Diagram sources**
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.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)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [EquipRequest.cs](file://ClassicAssist.Shared/UO/Network/Packets/EquipRequest.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [TargetManager.cs](file://ClassicAssist.Shared/UO/Targeting/TargetManager.cs)
**Section sources**
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.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)
- [Property.cs](file://ClassicAssist.Shared/UO/Objects/Property.cs)
- [UseObject.cs](file://ClassicAssist.Shared/UO/Network/Packets/UseObject.cs)
- [DropItem.cs](file://ClassicAssist.Shared/UO/Network/Packets/DropItem.cs)
- [EquipRequest.cs](file://ClassicAssist.Shared/UO/Network/Packets/EquipRequest.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [OrganizerManager.cs](file://ClassicAssist.Shared/Data/Organizer/OrganizerManager.cs)
- [TargetManager.cs](file://ClassicAssist.Shared/UO/Targeting/TargetManager.cs)
## Performance Considerations
- Batch queries: Prefer bulk item listing and filtering rather than repeated single-item lookups to reduce overhead.
- Predicate composition: Combine filters (type, hue, weight, properties) early to minimize iteration cost.
- Avoid excessive packet sends: Coalesce actions where possible to prevent network congestion.
- Cache results: Reuse filtered lists when multiple commands operate on the same dataset.
- Memory efficiency: Release references to large collections after processing; avoid retaining unnecessary object graphs.
[No sources needed since this section provides general guidance]
## Troubleshooting Guide
Common issues and resolutions:
- Ownership errors: Verify IsOwnedByPlayer before manipulating items; ensure correct context (player vs. other mobile).
- Targeting failures: Confirm TargetManager state and visibility; re-target if necessary.
- Network timeouts: Retry failed actions with backoff; check server response codes.
- Autoloot conflicts: Review constraint definitions; ensure no conflicting rules block intended actions.
- Dress set inconsistencies: Re-sync DressManager after manual equipment changes.
**Section sources**
- [ObjectCommands.cs](file://ClassicAssist.Shared/Data/Macros/Commands/ObjectCommands.cs)
- [AutolootManager.cs](file://ClassicAssist.Shared/Data/Autoloot/AutolootManager.cs)
- [DressManager.cs](file://ClassicAssist.Shared/Data/Dress/DressManager.cs)
- [TargetManager.cs](file://ClassicAssist.Shared/UO/Targeting/TargetManager.cs)
## Conclusion
ObjectCommands provides a robust interface for macro-driven item and world object manipulation. By leveraging the core object model, property inspection, and agent integrations, it enables powerful automation scenarios such as inventory scanning, intelligent filtering, and container organization. Proper attention to performance and error handling ensures reliable operation across diverse gameplay contexts.
[No sources needed since this section summarizes without analyzing specific files]
## Appendices
### Example Workflows
#### Inventory Scanning and Filtering
- Iterate over player’s backpack contents.
- Filter items by type, hue, and weight thresholds.
- Act on matches (use, drop, move).
#### Container Organization Automation
- Scan ground and open containers.
- Match items against OrganizerManager entries.
- Move items into designated containers.
#### Autoloot Coordination
- On item acquisition, evaluate AutolootManager rules.
- Auto-use consumables or auto-drop non-valuable items.
- Log decisions for debugging.
[No sources needed since this section provides conceptual examples]