Interface IMagic


public interface IMagic
Interface for interacting with the Magic skill and spellcasting system.

This interface provides methods for casting spells on various targets (items, NPCs, players, tile items, and tile objects), managing autocast settings, and checking spell selection states. It serves as the primary API for all magic-related operations within the game.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    cast(InteractMethod interactMethod, Spell spell)
    Casts a spell without a target using the specified interaction method.
    void
    cast(InteractMethod interactMethod, Spell spell, int actionIndex)
    Casts a spell by action index using the specified interaction method.
    void
    cast(InteractMethod interactMethod, Spell spell, String action)
    Casts a spell with a specific action name using the specified interaction method.
    void
    cast(InteractMethod interactMethod, Spell spell, INPC target)
    Casts a spell on an NPC using the specified interaction method.
    void
    cast(InteractMethod interactMethod, Spell spell, IPlayer target)
    Casts a spell on another player using the specified interaction method.
    void
    cast(InteractMethod interactMethod, Spell spell, IItem target)
    Casts a spell on an inventory item using the specified interaction method.
    void
    cast(InteractMethod interactMethod, Spell spell, ITileItem target)
    Casts a spell on a ground item using the specified interaction method.
    void
    cast(InteractMethod interactMethod, Spell spell, ITileObject target)
    Casts a spell on a tile object (game object) using the specified interaction method.
    default void
    cast(Spell spell)
    Casts a spell without a target using the default interaction method.
    default void
    cast(Spell spell, int actionIndex)
    Casts a spell by action index using the default interaction method.
    default void
    cast(Spell spell, String action)
    Casts a spell with a specific action name using the default interaction method.
    default void
    cast(Spell spell, INPC target)
    Casts a spell on an NPC using the default interaction method.
    default void
    cast(Spell spell, IPlayer target)
    Casts a spell on another player using the default interaction method.
    default void
    cast(Spell spell, IItem target)
    Casts a spell on an inventory item using the default interaction method.
    default void
    cast(Spell spell, ITileItem target)
    Casts a spell on a ground item using the default interaction method.
    default void
    cast(Spell spell, ITileObject target)
    Casts a spell on a tile object (game object) using the default interaction method.
    void
    Disables autocasting by deselecting the current autocast spell.
    Gets the timestamp of when the Home Teleport spell was last used.
    boolean
    Checks if any spell is currently set for autocasting.
    boolean
    Checks if a specific spell is currently set as the autocast spell.
    boolean
    Checks if defensive autocasting mode is currently active.
    boolean
    Checks if the Home Teleport spell is currently on cooldown.
    boolean
    Checks if a specific spell is currently selected for casting.
    void
    Selects a spell in the spellbook interface for casting on a target.
    void
    setAutoCast(Spell spell, boolean defensive)
    Sets the autocast spell for combat.
  • Method Details

    • isAutoCasting

      boolean isAutoCasting(Spell spell)
      Checks if a specific spell is currently set as the autocast spell.
      Parameters:
      spell - the spell to check for autocast status
      Returns:
      true if the specified spell is the current autocast spell, false otherwise
    • isAutoCasting

      boolean isAutoCasting()
      Checks if any spell is currently set for autocasting.
      Returns:
      true if autocasting is enabled with any spell, false otherwise
    • isDefensiveAutoCasting

      boolean isDefensiveAutoCasting()
      Checks if defensive autocasting mode is currently active.

      Defensive autocasting provides Defence experience in addition to Magic experience when casting combat spells.

      Returns:
      true if defensive autocasting is active, false otherwise
    • isSpellSelected

      boolean isSpellSelected(Spell spell)
      Checks if a specific spell is currently selected for casting.

      A spell is considered selected when it has been clicked in the spellbook and is ready to be cast on a target.

      Parameters:
      spell - the spell to check for selection status
      Returns:
      true if the specified spell is currently selected, false otherwise
    • cast

      void cast(InteractMethod interactMethod, Spell spell, IItem target)
      Casts a spell on an inventory item using the specified interaction method.
      Parameters:
      interactMethod - the method to use for interaction (e.g., mouse click, menu action), or null to use the default method
      spell - the spell to cast
      target - the inventory item to cast the spell on
    • cast

      default void cast(Spell spell, IItem target)
      Casts a spell on an inventory item using the default interaction method.
      Parameters:
      spell - the spell to cast
      target - the inventory item to cast the spell on
    • cast

      void cast(InteractMethod interactMethod, Spell spell, INPC target)
      Casts a spell on an NPC using the specified interaction method.
      Parameters:
      interactMethod - the method to use for interaction, or null for default
      spell - the spell to cast
      target - the NPC to cast the spell on
    • cast

      default void cast(Spell spell, INPC target)
      Casts a spell on an NPC using the default interaction method.
      Parameters:
      spell - the spell to cast
      target - the NPC to cast the spell on
    • cast

      void cast(InteractMethod interactMethod, Spell spell, IPlayer target)
      Casts a spell on another player using the specified interaction method.
      Parameters:
      interactMethod - the method to use for interaction, or null for default
      spell - the spell to cast
      target - the player to cast the spell on
    • cast

      default void cast(Spell spell, IPlayer target)
      Casts a spell on another player using the default interaction method.
      Parameters:
      spell - the spell to cast
      target - the player to cast the spell on
    • cast

      void cast(InteractMethod interactMethod, Spell spell, ITileItem target)
      Casts a spell on a ground item using the specified interaction method.
      Parameters:
      interactMethod - the method to use for interaction, or null for default
      spell - the spell to cast
      target - the ground item to cast the spell on
    • cast

      default void cast(Spell spell, ITileItem target)
      Casts a spell on a ground item using the default interaction method.
      Parameters:
      spell - the spell to cast
      target - the ground item to cast the spell on
    • cast

      void cast(InteractMethod interactMethod, Spell spell, ITileObject target)
      Casts a spell on a tile object (game object) using the specified interaction method.
      Parameters:
      interactMethod - the method to use for interaction, or null for default
      spell - the spell to cast
      target - the tile object to cast the spell on
    • cast

      default void cast(Spell spell, ITileObject target)
      Casts a spell on a tile object (game object) using the default interaction method.
      Parameters:
      spell - the spell to cast
      target - the tile object to cast the spell on
    • cast

      void cast(InteractMethod interactMethod, Spell spell)
      Casts a spell without a target using the specified interaction method.

      This is used for spells that don't require a target, such as teleport spells or self-buff spells.

      Parameters:
      interactMethod - the method to use for interaction, or null for default
      spell - the spell to cast
    • cast

      default void cast(Spell spell)
      Casts a spell without a target using the default interaction method.

      This is used for spells that don't require a target, such as teleport spells or self-buff spells.

      Parameters:
      spell - the spell to cast
    • cast

      void cast(InteractMethod interactMethod, Spell spell, String action)
      Casts a spell with a specific action name using the specified interaction method.

      Some spells have multiple actions available (e.g., teleport spells with "Cast" and "Configure" options). This method allows selecting a specific action.

      Parameters:
      interactMethod - the method to use for interaction, or null for default
      spell - the spell to cast
      action - the name of the action to perform on the spell
    • cast

      default void cast(Spell spell, String action)
      Casts a spell with a specific action name using the default interaction method.

      Some spells have multiple actions available (e.g., teleport spells with "Cast" and "Configure" options). This method allows selecting a specific action.

      Parameters:
      spell - the spell to cast
      action - the name of the action to perform on the spell
    • cast

      void cast(InteractMethod interactMethod, Spell spell, int actionIndex)
      Casts a spell by action index using the specified interaction method.

      This method allows casting a spell by specifying the index of the action in the spell's context menu.

      Parameters:
      interactMethod - the method to use for interaction, or null for default
      spell - the spell to cast
      actionIndex - the index of the action in the spell's context menu
    • cast

      default void cast(Spell spell, int actionIndex)
      Casts a spell by action index using the default interaction method.

      This method allows casting a spell by specifying the index of the action in the spell's context menu.

      Parameters:
      spell - the spell to cast
      actionIndex - the index of the action in the spell's context menu
    • selectSpell

      void selectSpell(Spell spell)
      Selects a spell in the spellbook interface for casting on a target.

      After calling this method, the spell will be selected and ready to be cast on a target by clicking on it.

      Parameters:
      spell - the spell to select
    • getLastHomeTeleportUsage

      Instant getLastHomeTeleportUsage()
      Gets the timestamp of when the Home Teleport spell was last used.
      Returns:
      the Instant when Home Teleport was last cast, or null if it has never been used this session
    • isHomeTeleportOnCooldown

      boolean isHomeTeleportOnCooldown()
      Checks if the Home Teleport spell is currently on cooldown.

      Home Teleport has a 30-minute cooldown between uses.

      Returns:
      true if Home Teleport is on cooldown, false otherwise
    • setAutoCast

      void setAutoCast(Spell spell, boolean defensive)
      Sets the autocast spell for combat.
      Parameters:
      spell - the spell to set as autocast
      defensive - true to use defensive casting (grants Defence XP), false for normal casting
    • deselectAutoCast

      void deselectAutoCast()
      Disables autocasting by deselecting the current autocast spell.