TranslateableEntity Documentation¶
Overview¶
The TranslateableEntity
class extends the Entity
class and represents entities in the HighSpell game that can move or be teleported, such as players or NPCs. It adds properties and methods for handling movement, combat, equipment, and UI overlays, making it suitable for dynamic entities with combat capabilities and inventory management. This class is a key component of the game’s entity system, building on the foundational Entity
class to support interactive and mobile game objects.
Usefulness for botting¶
TranslateableEntity
acts as a basis for all NPCs and Player Characters the user will see in the world. As such, it holds useful information such as _isMoving
which can be used to validate a walking automation command, as well as _hitpoints
for if a monster is undamaged and possibly free for attack.
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 TranslateableEntity
class defines additional properties, primarily accessed via getters and setters:
_combatLevel
: The entity’s combat level (getter and setter)._hitpoints
: The entity’s current hitpoints, representing health._lastGamePosition
: ACoordinate3D
object storing the entity’s previous position._nextGamePosition
: ACoordinate3D
object storing the entity’s target position for movement (getter and setter)._movementSpeed
: The entity’s movement speed (default1
), with a setter that triggers_onSprintChangeListener
if changed (e.g., sprinting at speed2
)._isMoving
: A boolean indicating if the entity is currently moving._currentTarget
: The entity’s current target (e.g., another entity for combat), with a setter that updates the entity’s direction based on the target’s position._uiOverlayController
: AUIOverlayController
managing UI elements (e.g., health bars) attached to the entity’s halo or hitbox nodes._loadout
: AnItemInventory
for equipped items, initialized withMenuTypesEnum.Loadout
._equipmentBonuses
: AnEquipmentBonuses
object tracking stat bonuses from equipped items (e.g., strength, accuracy), initialized for human entities._onMoveToNewTileListener
: AListeners
object for tile movement events._onTeleportedListener
: AListeners
object for teleportation events._onEquipItemListener
: AListeners
object for item equip events._onUnequipItemListener
: AListeners
object for item unequip events._onSprintChangeListener
: AListeners
object for sprint state changes._moveToNewTilePointEventArgs
: APositionEntity
object for tile movement events._drawAppearancePointEventArgs
: APositionEntity
object for appearance position updates.
Constructor MIGHT BE INCORRECT¶
- Signature:
constructor(entityId, entityTypeId, entityType, name, description, appearance, currentMapLevel, positionX, positionY, positionZ, actions, combatLevel, hitpoints)
- Parameters:
entityId
,entityTypeId
,entityType
,name
,description
,appearance
,currentMapLevel
,positionX
,positionY
,positionZ
,actions
: Passed to theEntity
constructor.combatLevel
: Sets_combatLevel
.hitpoints
: Sets_hitpoints
.
- Initializes inherited properties via the
Entity
constructor. - Sets
_lastGamePosition
to aCoordinate3D
withpositionX
,0
,positionZ
. - Initializes
_movementSpeed
to1
. - Creates
_uiOverlayController
with the entity’s halo and hitbox nodes and hitpoints. - Initializes
_loadout
as anItemInventory
for equipment. - Creates event argument objects (
_moveToNewTilePointEventArgs
,_drawAppearancePointEventArgs
) with the entity’s initial position and map level. - Initializes additional listeners for movement, teleportation, equipment, and sprinting.
- For human entities (
_appearance.Type === sA.Human
), sets_equipmentBonuses
to a newEquipmentBonuses
object and overrides_entityType
toWorldEntityTypesEnum.Player
.
Movement and Positioning¶
teleportTo(e, t, i)
:- Teleports the entity to coordinates (
e
,0
,t
) on map leveli
. - Updates
_currentGamePosition
,_appearance
position, and_moveToNewTilePointEventArgs
. - Invokes
_onTeleportedListener
with the updated position. _updateGamePosition()
:- Updates
_currentGamePosition
to_nextGamePosition
if set. - Adjusts the entity’s direction based on the target’s position or
_nextGamePosition
usingHighSpellUtil.getDirectionFromAToB3D
. - Updates
_moveToNewTilePointEventArgs
and invokes_onMoveToNewTileListener
. - Clears
_nextGamePosition
after updating.
Equipment Management¶
initializeEquippedItems(e)
:- Equips multiple items by calling
equippedItem
for each item in the provided array. equippedItem(e)
:- Equips an item by ID, retrieves its definition via
ItemDefs.getDefById
, and invokes_onEquipItemListener
with aDF
event object. - Calls
_recalculateEquipmentBonuses
to update stat bonuses. unequippedItem(e)
:- Unequips an item by ID, retrieves its definition, and invokes
_onUnequipItemListener
with aGF
event object. - Calls
_recalculateEquipmentBonuses
. _recalculateEquipmentBonuses()
:- Iterates through
_loadout.Items
to sum bonuses fromEquippableEffects
(e.g., strength, accuracy, defense, magic, range). - Updates
_equipmentBonuses
properties if changed.
Rendering and Updates¶
draw(e, t, i)
:- Adjusts the entity’s Y-position on first draw or if
i
is true, usingWorldMapManager.Instance.getGroundHeightAtEntity
. - Updates
_uiOverlayController
and draws it. - Checks if the appearance’s camera target matches
_currentGamePosition
(offset by 0.5 for centering):- If matched, stops animations, sets
_isMoving
tofalse
, and invokes_onMoveListener
if moving. - If not matched, starts animations, sets
_isMoving
totrue
, updates the apparent position via_updateApparentPosition
, and invokes_onMoveListener
every 60ms.
- If matched, stops animations, sets
- Calls
_appearance.draw(e, t, i)
. _updateApparentPosition(e, t)
:- Interpolates the entity’s visual position between
_lastGamePosition
and_currentGamePosition
using factore
. - Sets the Y-position based on
WorldMapManager.Instance.getGroundHeightAtEntity
. update(e)
:- Updates
_currentState
,_uiOverlayController
, and calls_updateGamePosition
.
Destruction¶
destroy()
:- Nullifies movement-related properties (
_lastGamePosition
,_nextGamePosition
,_currentTarget
). - Destroys and nullifies
_uiOverlayController
, logging specific messages for player entities. - Destroys and nullifies
_equipmentBonuses
for human entities. - Destroys and nullifies additional listeners (
_onMoveToNewTileListener
,_onTeleportedListener
,_onEquipItemListener
,_onUnequipItemListener
,_onSprintChangeListener
). - Nullifies event argument objects and
_hitpoints
. - Calls the parent
Entity
class’sdestroy
method.
Technical Observations¶
- Movement System: Supports smooth movement with interpolation (
_updateApparentPosition
) and discrete tile-based updates (_updateGamePosition
). - Event-Driven Design: Extensive use of listeners for movement, teleportation, and equipment changes supports a reactive architecture.
- Player-Specific Logic: Special handling for human/player entities (e.g.,
_equipmentBonuses
,_entityType
override) suggests tailored behavior for player characters. - Rendering: Likely integrates with a 3D engine (e.g., Babylon.js, given
HaloNode
,HitboxNode
), with dynamic ground height adjustments.
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.