MainPlayer Documentation¶
Overview¶
The MainPlayer class extends the PlayerEntity class and represents the primary player character in the HighSpell game. It builds on the capabilities of PlayerEntity and TranslateableEntity, adding specific functionality for managing the player’s combat stats, skills, inventory, bank storage, quests, and session-related data. This class is central to the game’s client-side logic, handling the player’s interactions with the game world.
Usefulness for botting¶
A MainPlayer is the core of your player character, serving as the foundation for all essential data. It stores information like _skills and _combat, which track your skill levels, total XP, and other details for both Combat and Non-Combat skills. Additionally, it manages your state, including _isMoving, and your _inventory, which contains an array, _items, of InventoryItem objects. Each InventoryItem includes the ItemDef for an item along with all its relevant details, making automated inventory actions seamless. This structure also applies to the player's _bankItems.
Inheritance¶
- Extends:
PlayerEntity - Inherits properties and methods from
PlayerEntity(e.g.,_type,_mentalClarityType),TranslateableEntity(e.g.,_combatLevel,_hitpoints,teleportTo), and indirectly fromEntity(e.g.,_entityId,_appearance). - Calls the parent constructor with core parameters and additional player-specific arguments.
Key Properties¶
The MainPlayer class defines additional properties, accessed via getters:
_combat: An object managing the player’s combat-related stats, passed from the constructor._skills: An object managing the player’s non-combat skills, passed from the constructor._inventory: AnItemInventoryobject for the player’s inventory, initialized withMenuTypesEnum.Inventory._bankItems: AnItemInventoryobject for the player’s bank storage, initialized withMenuTypesEnum.Bank._quests: An object managing the player’s quests, passed from the constructor._playerSessionId: A unique identifier for the player’s session._chatToken: A token used for chat functionality._didGetBankStorageItems: A boolean tracking whether bank items have been initialized._onReceivedBankItemsListeners: AMapstoring callbacks for bank item initialization events.
Constructor¶
- Signature:
constructor(e, t, i, n, r, s, a, o, l, h, c, u, d, p, f, _, m, g, v) - Parameters:
e,t,i,n,r,s,a,o,l,h,c,u,d,p: Passed to thePlayerEntityconstructor for entity ID, type ID, type, name, description, appearance, map level, position (x, y, z), actions, combat level, hitpoints, player type.f: Combat stats object, used to extract hitpoints for the parent constructor and set_combat._: Sets_skills.m: Sets_quests.g: Sets_playerSessionId.v: Sets_chatToken.
- Calls the
PlayerEntityconstructor with the first 14 parameters and the hitpoints derived fromf.getSkill(SkillEnum.hitpoints). - Initializes
_inventoryand_bankItemsasItemInventoryobjects with specific menu types. - Sets
_didGetBankStorageItemstofalseand creates_onReceivedBankItemsListenersas aMap.
Bank Item Management¶
setBankItems(e):- Initializes
_bankItemswith the provided items (e) if not already initialized (_didGetBankStorageItemsisfalse). - Sets
_didGetBankStorageItemstotrueand invokes all callbacks in_onReceivedBankItemsListenerswith the items. addReceivedBankItemsListener(e, t):- Adds a callback (
t) to_onReceivedBankItemsListenerswith keyeif not already present. - Returns
false(potentially a bug, as it does not indicate success). removeReceivedBankitemsListener(e):- Removes the callback with key
efrom_onReceivedBankItemsListeners. - Returns
trueif the callback was removed,falseotherwise.
Teleportation¶
teleportTo(e, t, i):- Calls the parent
TranslateableEntity’steleportToto update position and map level. - If the map level changes (
i !== _currentMapLevel), triggersWR.Instance.enterMapLevelandWorldMapManager.Instance.enterMapLevel. - Also triggers
WorldMapManager.Instance.enterMapLevelif the new position is in a new chunk. - Updates the minimap via
SerivceLocator.Manager.getController().MinimapQuadrantController.MinimapController.mainPlayerMoved. - Forces a wilderness position check via
SerivceLocator.Manager.getController().WildernessUIController.forceCheckWildernessPosition.
Stat Restoration¶
restoreStatsByOne(e):- Iterates through an array of skill IDs (
e) to restore stats:- Retrieves the skill from
_combat.Skills(ifRA(e[i])is true) or_skills.Skills. - Increases
CurrentLevelby 1 if belowLevel, or decreases by 1 if aboveLevel.
- Retrieves the skill from
- Logs the restoration action to the console.
Updates¶
update(e):- Overrides the parent’s
updatemethod to update_currentState, call_updateGamePosition, and update_uiOverlayControllerif it exists. - Reimplements
TranslateableEntity’supdatelogic without additional player-specific behavior.
Destruction¶
destroy():- Cleans up player-specific resources:
- Clears and nullifies
_onReceivedBankItemsListeners. - Destroys and nullifies
_uiOverlayController, logging messages for player entities. - Destroys and nullifies
_combat,_skills,_inventory, and_quests.
- Clears and nullifies
- Calls the parent
PlayerEntity’sdestroymethod to clean up inherited properties and listeners.
Technical Observations¶
- Event System: The
_onReceivedBankItemsListenersMap supports asynchronous bank item loading, suggesting networked data retrieval. - Potential Bug: The
addReceivedBankItemsListenermethod always returnsfalse, which may confuse callers expecting a success indicator.
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.