SpellDef and SpellDefs Documentation¶
Overview¶
The SpellDef class represents a single spell definition in the HighSpell game, encapsulating properties like ID, name, type, level, experience, damage, and requirements. The SpellDefs class is a static utility that manages a collection of spell definitions, providing methods to load and retrieve them from JSON data. These classes are integral to the game’s magic system, used by classes like CW (SpellManager) to handle spell-related actions.
Usefulness for Botting¶
The SpellDef class provides detailed metadata about spells, including their Type, Requirements, and Actions, enabling bots to select and cast spells based on their properties (e.g., targeting combat spells for damage or teleport spells for movement). The SpellDefs class allows access to all spell definitions via getDefById, facilitating automation of spell selection and usage. For example, a bot could query spell requirements to ensure the player meets them before casting.
SpellDef Class¶
Inheritance¶
- None:
SpellDefis a standalone class, not extending any parent class.
Key Properties¶
_id(getter:ID): The unique identifier of the spell._name(getter:Name): The spell’s name, capitalized for display._description(getter:Description): The spell’s description._type(getter:Type): The spell type (e.g.,SpellTypeEnum.combat,SpellTypeEnum.teleport)._level(getter:Level): The required Magic skill level to cast the spell._exp(getter:Exp): The experience points granted for casting the spell._maxDamage(getter:MaxDamage): The maximum damage for combat spells (0 for non-combat spells)._splashDamage(getter:SplashDamage): The splash damage properties for area effects._recipe(getter:Recipe): The items or resources required to cast the spell._actions(getter:Actions): The available actions (e.g.,TargetAction.cast,TargetAction.auto_cast)._requirements(getter:Requirements): The skill or item requirements for casting.
Constructor¶
- Signature:
constructor(e, t, i, n, r, s, a, o, l, h) - Parameters:
e: Spell ID (_id).t: Spell name (_name).i: Spell description (_description).n: Spell type (_type, fromSpellTypeEnum).r: Required level (_level).s: Experience points (_exp).a: Maximum damage (_maxDamage).o: Splash damage (_splashDamage).l: Recipe (_recipe).h: Requirements (_requirements).
- Functionality:
- Initializes all properties with provided values.
- Sets
_actionsbased on_type: inventory,status,teleport:[TargetAction.cast].combat:[TargetAction.cast, TargetAction.auto_cast].
Static Methods¶
fromJSON(e):- Parameters:
e: JSON object containing spell data.
- Functionality:
- Validates numeric fields (
_id,lvl,exp,maxDamage) usingHighSpellUtil.isNumberSafeAndPositive. - Converts
typetoSpellTypeEnumusingJF(likely a type mapping). - Maps
requirementsto objects usingtM.fromJSON. - Creates a
SpellDefinstance with parsed data, includingSpellSplashDamage.fromJSONand_P.fromJSONfor splash damage and recipe. - Throws an error if validation or conversion fails.
- Validates numeric fields (
Instance Methods¶
destroy():- Functionality:
- Nullifies all properties (
_id,_name,_description,_type,_level,_exp,_maxDamage). - Destroys and nullifies
_splashDamageand_recipeif they exist. - Nullifies each element in
_actionsand_requirements, then nullifies the arrays.
- Nullifies all properties (
SpellDefs Class¶
Inheritance¶
- None:
SpellDefsis a static utility class, not instantiated.
Key Properties¶
_defMap(static, getter:Defs): AMapstoring spell definitions, with spell IDs as keys andSpellDefinstances as values.
Constructor¶
- Signature:
constructor() - Empty constructor, as the class is static and not instantiated.
Static Methods¶
loadFromJSON(e):- Parameters:
e: Array of JSON objects containing spell definitions.
-
Functionality:
- Warns if
_defMapis already initialized. - Creates a new
_defMapand populates it withSpellDefinstances created from JSON data. - Throws errors if JSON is invalid or if duplicate spell IDs are found.
- Warns if
-
getDefById(e): - Parameters:
e: Spell ID.
- Functionality:
- Retrieves a
SpellDeffrom_defMapby ID, returningundefinedif not found.
- Retrieves a
Technical Observations¶
- Dependencies:
SpellDefrelies onSpellTypeEnum,TargetAction, and other classes (tM,_P,SpellSplashDamage) for requirements and recipes.SpellDefsintegrates withAssetManager(implied by JSON loading). - Data Management:
SpellDefsuses aMapfor efficient lookup, andfromJSONensures data integrity with validation checks. - Network Integration: Spell definitions are loaded from server-provided JSON, as seen in
ItemManager.loadAsync, suggesting networked initialization.
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.