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: ACoordinate3Dobject storing the entity’s previous position._nextGamePosition: ACoordinate3Dobject storing the entity’s target position for movement (getter and setter)._movementSpeed: The entity’s movement speed (default1), with a setter that triggers_onSprintChangeListenerif 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: AUIOverlayControllermanaging UI elements (e.g., health bars) attached to the entity’s halo or hitbox nodes._loadout: AnItemInventoryfor equipped items, initialized withMenuTypesEnum.Loadout._equipmentBonuses: AnEquipmentBonusesobject tracking stat bonuses from equipped items (e.g., strength, accuracy), initialized for human entities._onMoveToNewTileListener: AListenersobject for tile movement events._onTeleportedListener: AListenersobject for teleportation events._onEquipItemListener: AListenersobject for item equip events._onUnequipItemListener: AListenersobject for item unequip events._onSprintChangeListener: AListenersobject for sprint state changes._moveToNewTilePointEventArgs: APositionEntityobject for tile movement events._drawAppearancePointEventArgs: APositionEntityobject 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 theEntityconstructor.combatLevel: Sets_combatLevel.hitpoints: Sets_hitpoints.
- Initializes inherited properties via the
Entityconstructor. - Sets
_lastGamePositionto aCoordinate3DwithpositionX,0,positionZ. - Initializes
_movementSpeedto1. - Creates
_uiOverlayControllerwith the entity’s halo and hitbox nodes and hitpoints. - Initializes
_loadoutas anItemInventoryfor 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_equipmentBonusesto a newEquipmentBonusesobject and overrides_entityTypetoWorldEntityTypesEnum.Player.
Movement and Positioning¶
teleportTo(e, t, i):- Teleports the entity to coordinates (
e,0,t) on map leveli. - Updates
_currentGamePosition,_appearanceposition, and_moveToNewTilePointEventArgs. - Invokes
_onTeleportedListenerwith the updated position. _updateGamePosition():- Updates
_currentGamePositionto_nextGamePositionif set. - Adjusts the entity’s direction based on the target’s position or
_nextGamePositionusingHighSpellUtil.getDirectionFromAToB3D. - Updates
_moveToNewTilePointEventArgsand invokes_onMoveToNewTileListener. - Clears
_nextGamePositionafter updating.
Equipment Management¶
initializeEquippedItems(e):- Equips multiple items by calling
equippedItemfor each item in the provided array. equippedItem(e):- Equips an item by ID, retrieves its definition via
ItemDefs.getDefById, and invokes_onEquipItemListenerwith aDFevent object. - Calls
_recalculateEquipmentBonusesto update stat bonuses. unequippedItem(e):- Unequips an item by ID, retrieves its definition, and invokes
_onUnequipItemListenerwith aGFevent object. - Calls
_recalculateEquipmentBonuses. _recalculateEquipmentBonuses():- Iterates through
_loadout.Itemsto sum bonuses fromEquippableEffects(e.g., strength, accuracy, defense, magic, range). - Updates
_equipmentBonusesproperties if changed.
Rendering and Updates¶
draw(e, t, i):- Adjusts the entity’s Y-position on first draw or if
iis true, usingWorldMapManager.Instance.getGroundHeightAtEntity. - Updates
_uiOverlayControllerand draws it. - Checks if the appearance’s camera target matches
_currentGamePosition(offset by 0.5 for centering):- If matched, stops animations, sets
_isMovingtofalse, and invokes_onMoveListenerif moving. - If not matched, starts animations, sets
_isMovingtotrue, updates the apparent position via_updateApparentPosition, and invokes_onMoveListenerevery 60ms.
- If matched, stops animations, sets
- Calls
_appearance.draw(e, t, i). _updateApparentPosition(e, t):- Interpolates the entity’s visual position between
_lastGamePositionand_currentGamePositionusing 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
_equipmentBonusesfor human entities. - Destroys and nullifies additional listeners (
_onMoveToNewTileListener,_onTeleportedListener,_onEquipItemListener,_onUnequipItemListener,_onSprintChangeListener). - Nullifies event argument objects and
_hitpoints. - Calls the parent
Entityclass’sdestroymethod.
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,_entityTypeoverride) 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.