Spells
constSpells:object
Defined in: client/api.d.ts:5517
Local spell-unlock enforcement and spell-diamond access.
Type Declaration
Section titled “Type Declaration”broomCastReady()
Section titled “broomCastReady()”broomCastReady():
boolean
True while broom-mounted with a usable wand; gate keybinds on this so they stay inert on foot.
Returns
Section titled “Returns”boolean
broomCastTry()
Section titled “broomCastTry()”broomCastTry(
slot,aimMode?):string
Casts the slot’s spell via ActivateSpellTool + SpellTool::Start, bypassing the ground cast path. Fires a real spell.
Parameters
Section titled “Parameters”number
Equipped diamond slot 0-3.
aimMode?
Section titled “aimMode?”number
0 tool’s own aim (rider-forward on a broom), 1/2 wand-cast tracker, 5 per-cast override on the tool.
Returns
Section titled “Returns”string
cast()
Section titled “cast()”cast(
slot):SpellCastResult
Loads the slotted spell tools and taps the requested spell through the production WandTool OnSpell_Pressed/OnSpell_Released route. The result confirms dispatch; observe localSpellCast for native cast completion.
Parameters
Section titled “Parameters”number
Diamond slot 0-3.
Returns
Section titled “Returns”castRecord()
Section titled “castRecord()”castRecord(
recordPath,aimMode?):SpellCastResult
Loads a modded SpellToolRecord and casts it through the local wand. On foot it goes through the game’s own cast entry, so the cast gesture plays and fires it; on a mount, or with aimMode 5, the tool is started directly. A record a Spells.define definition runs is cast as that spell. Vanilla /Game paths are rejected.
Parameters
Section titled “Parameters”recordPath
Section titled “recordPath”string
Plugin-rooted Package.Object path to a modded SpellToolRecord.
aimMode?
Section titled “aimMode?”number
0 uses the tool’s aim; 1/2 use the target tracker; 5 uses a per-cast camera override.
Returns
Section titled “Returns”cooldowns()
Section titled “cooldowns()”cooldowns():
SpellCooldown[]
The local player’s spells on cooldown, read from the game’s own cooldown table: only spells actually cooling down, with every reduction, reset and combat rule already applied. Spells whose cast set no cooldown are absent. Empty without a player. spellCooldownChanged reports the changes.
Returns
Section titled “Returns”currentLoadout()
Section titled “currentLoadout()”currentLoadout():
number|null
The spell set (0-3) the player has selected: the one the HUD shows and casts from. spellLoadoutChanged reports switches.
Returns
Section titled “Returns”number | null
fizzle()
Section titled “fizzle()”fizzle():
boolean
Plays the game’s own failed cast on the local player: the wand’s fail sound, its spark at the tip and the arm’s failed-cast pose for 1.7 s. False without a player or wand, or while a fizzle is still playing.
Returns
Section titled “Returns”boolean
isHeld()
Section titled “isHeld()”isHeld(
slot?):boolean
Whether a cast input is held down, as the wand sees it: true from a press whose cast went through until its release. A press the game refused (a cooldown, stopped input, a locked spell) never reads as held. False without a wand.
Parameters
Section titled “Parameters”number
Diamond slot 0-3. Omitted: the basic cast, the left click.
Returns
Section titled “Returns”boolean
isLoadoutKeysEnabled()
Section titled “isLoadoutKeysEnabled()”isLoadoutKeysEnabled():
boolean
False while any resource holds the spell-set keys.
Returns
Section titled “Returns”boolean
isLoadoutWheelEnabled()
Section titled “isLoadoutWheelEnabled()”isLoadoutWheelEnabled():
boolean
False while any resource holds the mouse wheel’s spell-set switching.
Returns
Section titled “Returns”boolean
loadout()
Section titled “loadout()”loadout(
loadoutIndex?):SpellLoadoutState|null
Reads one live spell-diamond loadout through QuickActionManager.
Parameters
Section titled “Parameters”loadoutIndex?
Section titled “loadoutIndex?”number
Defaults to the currently selected loadout.
Returns
Section titled “Returns”SpellLoadoutState | null
setCurrentLoadout()
Section titled “setCurrentLoadout()”setCurrentLoadout(
loadoutIndex):boolean
Selects a spell set as the player’s set keys do: the HUD switches to it and casting follows, and spellLoadoutChanged fires. Works while setLoadoutKeysEnabled or setLoadoutWheelEnabled holds the player’s own switching. Silent, unlike a key press, which plays the game’s swap sound. True once the set is selected, including when it already was. False when the index is out of range, the set is not unlocked (the game opens one set plus one per bonus loadout, see setPolicy), or there is no player or HUD to take the switch yet.
Parameters
Section titled “Parameters”loadoutIndex
Section titled “loadoutIndex”number
The spell set to select, 0-3.
Returns
Section titled “Returns”boolean
setLoadoutKeysEnabled()
Section titled “setLoadoutKeysEnabled()”setLoadoutKeysEnabled(
enabled):void
Stops the game’s spell-set keys from switching sets, so a resource can put its own menus on them: F1-F4 and 5-8 by default, or whatever keys the player bound to the four sets. The keys still reach Key.bind, and the mouse wheel is separate (setLoadoutWheelEnabled). Spells.setCurrentLoadout still switches, and so does the action screen’s own set row (Game.setActionScreenEnabled shuts that screen). Same contract as Game.setPauseMenuEnabled: one idempotent hold per resource, held while any resource holds, dropped when the resource stops or reloads and on disconnect.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
false stops the set keys from switching spell sets; true gives this resource’s hold back.
Returns
Section titled “Returns”void
setLoadoutSlot()
Section titled “setLoadoutSlot()”setLoadoutSlot(
slot,spellName,loadoutIndex?,emitAssignmentEvent?):boolean
Assigns a live native spell-diamond slot through QuickActionManager, verifies readback, and emits spellAssignment with source ‘api’ after success. Modded record paths are valid persistence identities but require a modded slot provider rather than QuickActionManager.
Parameters
Section titled “Parameters”number
Diamond slot 0-3.
spellName
Section titled “spellName”string | null
Native gameplay name or plugin-rooted modded SpellToolRecord path, or null to clear.
loadoutIndex?
Section titled “loadoutIndex?”number
Defaults to the currently selected loadout.
emitAssignmentEvent?
Section titled “emitAssignmentEvent?”boolean
Defaults to true. Internal state restoration passes false to avoid reporting synchronization as a user assignment.
Returns
Section titled “Returns”boolean
setLoadoutWheelEnabled()
Section titled “setLoadoutWheelEnabled()”setLoadoutWheelEnabled(
enabled):void
Stops the mouse wheel from switching spell sets, so a resource can use the wheel itself (Key.bind(“wheelup”) and “wheeldown” still fire). The set keys are separate (setLoadoutKeysEnabled), and Spells.setCurrentLoadout still switches. Same contract as Game.setPauseMenuEnabled: one idempotent hold per resource, held while any resource holds, dropped when the resource stops or reloads and on disconnect.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
false stops the mouse wheel from switching spell sets; true gives this resource’s hold back.
Returns
Section titled “Returns”void
setPolicy()
Section titled “setPolicy()”setPolicy(
lockIds,bonusLoadouts?,relockIds?):void
Sets the spell policy.
Parameters
Section titled “Parameters”lockIds
Section titled “lockIds”string[]
bonusLoadouts?
Section titled “bonusLoadouts?”number
relockIds?
Section titled “relockIds?”string[]
Granted-then-revoked spell LockIDs to actively re-lock and clear from every quick slot — dropping an id from lockIds cannot undo an unlock on its own. ‘Spell_Stupefy’ also takes back the basic (left-click) cast.
Returns
Section titled “Returns”void