Interface Spell

All Known Implementing Classes:
SpellBook.Ancient, SpellBook.Lunar, SpellBook.Necromancy, SpellBook.Standard

public interface Spell
Represents a castable magic spell in the game.

This interface defines the contract for all spells across different spellbooks (Standard, Ancient, Lunar, and Necromancy). Each spell implementation provides information about its requirements, level, and casting capabilities.

Spells can be cast on various targets including items, NPCs, players, ground items, and game objects. Some spells are self-cast and don't require a target.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks whether this spell can currently be cast.
    default void
    Casts this spell without a target.
    default void
    cast(String action)
    Casts this spell with a specific action.
    default void
    castOn(Interactable interactable)
    Casts this spell on the specified interactable target.
    int
    Gets the autocast index for this spell.
    int
    Gets the component ID for this spell's widget in the spellbook interface.
    Deprecated, for removal: This API element is subject to removal in a future version.
    This method is scheduled for removal.
    int
    Gets the Magic level required to cast this spell.
    int
    Gets the menu identifier for this spell.
    Gets the rune requirements for casting this spell.
    Gets the spellbook that contains this spell.
  • Method Details

    • getLevel

      int getLevel()
      Gets the Magic level required to cast this spell.
      Returns:
      the minimum Magic level required
    • getComponent

      @Component int getComponent()
      Gets the component ID for this spell's widget in the spellbook interface.

      The component ID is a packed integer representing both the interface ID and the component index within that interface.

      Returns:
      the component ID for the spell's widget
    • getInterfaceAddress

      @Deprecated(forRemoval=true) default InterfaceAddress getInterfaceAddress()
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method is scheduled for removal. Use getComponent() instead.
      Gets the interface address for this spell.
      Returns:
      the InterfaceAddress for accessing this spell's widget
    • canCast

      boolean canCast()
      Checks whether this spell can currently be cast.

      This method verifies all requirements including:

      • The correct spellbook is active
      • The player has the required Magic level
      • The player has all required runes
      • The player meets any quest requirements
      • The player is in a members world (if required)
      • Any special equipment requirements are met

      Returns:
      true if the spell can be cast, false otherwise
    • getRequirements

      RuneRequirement[] getRequirements()
      Gets the rune requirements for casting this spell.

      Each RuneRequirement specifies a rune type and the quantity needed. Combination runes and staff bonuses are considered when checking if requirements are met.

      Returns:
      an array of RuneRequirement objects, or an empty array if no runes are required
    • getSpellBook

      SpellBook getSpellBook()
      Gets the spellbook that contains this spell.
      Returns:
      the SpellBook this spell belongs to
    • cast

      default void cast()
      Casts this spell without a target.

      This method is used for spells that don't require a target, such as teleport spells, utility spells like High Alchemy (when used alone), or self-buff spells.

    • cast

      default void cast(String action)
      Casts this spell with a specific action.

      Some spells have multiple available actions in their context menu. This method allows selecting a specific action by name.

      Parameters:
      action - the name of the action to perform (e.g., "Cast", "Configure")
    • castOn

      default void castOn(Interactable interactable)
      Casts this spell on the specified interactable target.

      This method automatically handles different target types including:

      Parameters:
      interactable - the target to cast the spell on
    • getMenuIdentifier

      int getMenuIdentifier()
      Gets the menu identifier for this spell.

      The menu identifier is used internally for spell interactions through the game's menu system.

      Returns:
      the menu identifier, or -1 if not applicable
    • getAutocastIndex

      int getAutocastIndex()
      Gets the autocast index for this spell.

      The autocast index is used to identify this spell in the autocast selection interface. Only combat spells that can be autocast have a valid autocast index.

      Returns:
      the autocast index, or -1 if this spell cannot be autocast