TargetActionManager Documentation¶
Overview¶
The TargetActionManager class is a static utility class in the HighSpell game responsible for managing interactions between the player and entities or locations in the game world. It processes mouse pointer input to identify entities and their associated actions (e.g., inspect, attack, walk), handles action execution, and facilitates pathfinding for movement. This class is central to the game’s interaction system, enabling context-sensitive actions based on what the player clicks.
Usefulness for Botting¶
The TargetActionManager class is a critical component for bot development due to its role in processing player interactions with entities and the game world. Methods like handleTargetAction(e, t) allow bots to simulate actions such as attack, grab, or talk_to on specific entities (e.g., NPCs, players, or objects) by passing the appropriate TargetAction enum value and entity object. Similarly, handleWalkTo(e, t) enables automated navigation by specifying coordinates, leveraging the built-in client-side pathfinding to move the player efficiently. By combining these methods with data from classes like EntityManager, GroundItemManager, and WorldEntityManager, bots can identify targets and execute complex sequences of actions, such as looting items or engaging in combat.
Key Features¶
- Static Methods: All methods are static, indicating the class is a utility without instantiation.
- Mouse Interaction: Processes picking information from mouse clicks to identify entities and generate actionable options.
- Action Sorting: Prioritizes actions based on distance and type, with special handling for ground items.
- Pathfinding: Implements client-side pathfinding for player movement to clicked coordinates.
- Action Handling: Executes actions like inspecting, editing entities, or performing world interactions, with network communication for server-side validation.
- Event Emission: Sends action and movement requests to the server via sockets.
Static Methods¶
Mouse Interaction¶
getActionsAndEntitiesAtMousePointer(e, t, i):- Parameters:
e: Likely the mouse event or coordinates (x).t: Likely the mouse event or coordinates (z).i: Array of picking information (e.g., raycast results from mouse clicks).
- Functionality:
- Clears previous
_mousePointActionsAndEntitiesResultif it exists. - Returns a default
UVobject (null coordinates, no actions, no entities, not ground) ifiis empty or invalid. - Uses
HM.uniqByto filter unique picking info by mesh name. - Identifies entities based on mesh name prefixes:
_npc: Retrieves NPC viaEntityManager.Instance.getNPCByEntityId._ite: Retrieves ground item viaGroundItemManager.Instance.getGroundItemByEntityId._we_: Retrieves world entity viaWorldEntityManager.Instance.getWorldEntityById, with special handling for cave entrances/exits to avoid duplicates._pla: Retrieves player viaEntityManager.Instance.getPlayerByEntityId._pl@: Retrieves planet viaWorldEntityManager.Instance.getPlanetByEntityId._briorgrou: Marks as ground interaction, settingCoordinate2Dfor the clicked point.- Builds two action arrays:
a: Actions requiring combat level checks (e.g.,TargetAction.attackif target’s combat level exceeds the player’s).o: Other actions, including non-combat actions and attacks on lower-level targets.- If ground is clicked, adds a
walk_hereaction, optionally with an associated entity (prioritizes players). - In map editor mode, adds
add_entityaction if applicable. - Sorts actions by distance and type using
_sortActionsAndEntities. - Returns a
UVobject containing the clicked coordinates, combined actions, entity count, and ground interaction flag.
- Clears previous
Sorting and Comparison¶
_sortActionsAndEntities(e, t):- Sorts action-entity pairs (
VVobjects) by:- Distance from the camera using
_sortActionsAndEntitiesByDistanceFromCamera. - Action type (
e.Action - t.Action) if distances are equal. - Entity type ID (
EntityTypeID) if actions are equal, with special handling for ground items via_sortGroundItemsForContextMenu.
- Distance from the camera using
_sortActionsAndEntitiesByDistanceFromCamera(e, t):- Delegates to
_sortEntitiesByDistanceFromCamerato compare entity distances. _sortPickingInfoByDistanceFromCamera(e, t):- Compares picking info based on Manhattan distance from the camera to the picked mesh’s position.
_sortEntitiesByDistanceFromCamera(e, t):- Compares entities based on Manhattan distance from the camera to their
CurrentGamePosition. _sortGroundItemsForContextMenu(e, t):- Prioritizes specific ground item IDs (190, 39, 421) and sorts by
FullCostorDef.IDfor others.
Cave Action Deduplication¶
_isCaveAlreadyAddedToEntitiesArray(e, t, i, n):- Checks if a cave action (
i, e.g.,TargetAction.enter) at coordinates (e,t) is already in the action mapn. _isCaveAlreadyAddedToEntitiesArray2(e, t, i, n):- Checks if a cave action (
i) at coordinates (e,t) is already in the entity arrayn.
Action Insertion¶
_insertEntityIntoQuickActionArray(e, t):- Adds entity
eto the action mapt, using the first action orTargetAction.inspectas the key.
Action Handling¶
handleTargetAction(e, t):- Parameters:
e: The action to perform (e.g.,TargetAction.inspect).t: The target entity.
- Hides the minimap walk flag unless the action is
inspector the entity is environmental. - Handles specific actions:
edit_entity: Calls_handleEditEntityActionin development mode.inspect: Calls_handleInspectAction.moderate: Shows the moderation menu for the target’s name.open,mine_through,climb_same_map_level,go_through: Calls_handlePerformActionOnWorldEntityWithEntityEventActions.- Others: Emits the action via
_emitPerformActionOnEntityAction.
- Shows the walk flag for environmental entities if applicable.
_handleEditEntityAction(e):- Sets the entity for editing in
MapEditorif in development mode. _handleInspectAction(e):- Displays the entity’s description (and IDs in development mode) in the chat menu.
_handlePerformActionOnWorldEntityWithEntityEventActions(e, t):- Emits the action via
_emitPerformActionOnEntityActionif the entity hasEntityEventActions. handleItemOnEntityAction(e, t):- Handles using an item (
t) on an entity (e), hiding and showing the walk flag and emitting the action via_emitUseItemOnEntityAction.
Event Emission¶
_emitPerformActionOnEntityAction(e, t):- Emits a
PerformActionOnEntityActionpacket viaSocketManagerusing the action and entity’s ID (from_getEntityIdForPerformingTargetAction). _emitUseItemOnEntityAction(e, t):- Emits a
UseItemOnEntityActionpacket for using itemton entitye. _getEntityIdForPerformingTargetAction(e):- Returns the appropriate ID based on entity type (
EntityTypeIDfor environment/players,EntityIDfor items/NPCs).
Movement and Pathfinding¶
handleWalkTo(e, t):- Handles player movement to coordinates (
e,t):- Hides the minimap walk flag.
- Rounds coordinates to integers.
- Checks if the destination is the player’s current position or if in development mode.
- Performs client-side pathfinding using
pA.clientSidePathfindup to 13 attempts, adjusting coordinates if needed via_getNextPathfindCoordinates. - Emits a
SendMovementPathActionpacket to the server. - Shows the walk flag at the final coordinates.
_getNextPathfindCoordinates(e, t, i, n):- Adjusts target coordinates (
e) for pathfinding retries, testing adjacent tiles in a specific order (e.g., +1 Z, -1 Z, +1 X, etc.).
Reset¶
reset():- Destroys and nullifies
_mousePointActionsAndEntitiesResult.
Technical Observations¶
- Raycasting: Processes picking info from raycasts.
- Pathfinding: Implements client-side pathfinding with fallback coordinates.
- Network Integration: Uses
SocketManagerfor server communication, ensuring actions are validated server-side.
Ethical and Legal Notes¶
Per the HighSpell Botting Resources ethos: - This documentation is for educational purposes, analyzing observable game client behavior. - Using this information to create bots violates HighSpell’s terms of service, risking account bans.