GroundItem Documentation¶
Overview¶
The GroundItem
class extends the Entity
class in the HighSpell game and represents an item that appears on the ground, such as dropped loot or resources. It encapsulates properties like item definition, quantity, IOU status, and total cost, and handles rendering adjustments specific to ground items. This class is managed by GroundItemManager
and is critical for player interactions like picking up items using the grab
action defined in TargetActionOriginal
.
Usefulness for Botting¶
The GroundItem
class provides access to critical data about items on the ground, including their Def
(item definition with ID, name, and cost), Amount
, IsIOU
status, and CurrentGamePosition
. This allows for easy identification and interaction with ground items, such as targeting specific items for pickup based on their location or value. The class’s integration with GroundItemManager
enables bots to query all ground items in the game world, facilitating automation of tasks like looting or resource collection.
Inheritance¶
- Extends:
Entity
- Inherits properties and methods from
Entity
(e.g.,_entityId
,_appearance
,destroy
). - Calls the parent constructor with core entity parameters.
Key Properties¶
The GroundItem
class defines properties, accessed via getters:
_def
: The item’s definition, containing metadata like ID, name, and cost._amount
: The quantity of the item._isIOU
: A boolean indicating if the item is a placeholder (IOU, e.g., for promised items)._fullCost
: The total cost of the item, calculated asDef.Cost * _amount
.
Constructor¶
- Signature:
constructor(e, t, i, n, r, s, a, o, l, h, c, u, d)
- Parameters:
e
,t
,i
,n
,r
,s
,a
,o
,l
,h
: Passed to theEntity
constructor for entity ID, type ID, type (set toWorldEntityTypesEnum.Item
), name, description, appearance, map level, and position (x, y, z).c
: Sets_def
(item definition).u
: Sets_amount
(quantity).d
: Sets_isIOU
(IOU status).
- Functionality:
- Calls the
Entity
constructor with the first 11 parameters, setting_entityType
toWorldEntityTypesEnum.Item
. - Initializes
_def
,_amount
, and_isIOU
. - Calculates
_fullCost
asDef.Cost * _amount
.
- Calls the
Methods¶
draw(e, t, i)
:- Parameters:
e
,t
,i
: Rendering context, delta time, and a boolean flag (likely for initial rendering).
-
Functionality:
- Exits if
_appearance
is absent. - On first draw or if
i
is true, sets_didLoadInitialY
totrue
and calls_setYCoordinate
to adjust the item’s Y-position. - If the appearance’s camera target matches
_currentGamePosition
(offset by 0.5 for centering), skips further updates. - Otherwise, sets the appearance’s X and Z positions to
_currentGamePosition.X + 0.5
and_currentGamePosition.Z + 0.5
.
- Exits if
-
_setYCoordinate()
: -
Functionality:
- Determines the item’s Y-position based on the tile at
CurrentGamePosition
(viaWorldMapManager.Instance.getTileAtGameCoordinates
). - If the tile is closed (
Cost & uA.Closed
) and contains world entities, checks for specific entity types (crate
,counter
,table
) and sets the Y-position to the top of the entity plus a quarter of its height. - If no matching entity is found, sets the Y-position to the ground height via
WorldMapManager.Instance.getGroundHeightAtEntity
. - Updates
_appearance.setPositionY
with the calculated height.
- Determines the item’s Y-position based on the tile at
-
destroy()
: - Functionality:
- Nullifies
_def
,_amount
,_isIOU
, and_fullCost
. - Calls the parent
Entity
’sdestroy
method to clean up inherited properties.
- Nullifies
Technical Observations¶
- Dependencies: Relies on external classes (
WorldMapManager
,WorldEntityManager
) and enums (WorldEntityType
,WorldEntityTypesEnum
,uA
) for positioning and entity interaction. - Rendering: Adjusts the item’s position to align with the game world’s terrain or objects, suggesting integration with a 3D engine (e.g., Babylon.js, given
_appearance.CameraTarget
). - Positioning Logic: The
_setYCoordinate
method accounts for items placed on elevated surfaces (e.g., tables). - Item Representation: Shares similarities with
InventoryItem
(e.g.,Def
,Amount
,IsIOU
), but is tailored for world-placed items with visual representation. - Error Handling: Both
draw
and_setYCoordinate
include try-catch blocks to log errors, ensuring robustness during rendering.
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.