Interface IMagic
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 TypeMethodDescriptionvoidcast(InteractMethod interactMethod, Spell spell) Casts a spell without a target using the specified interaction method.voidcast(InteractMethod interactMethod, Spell spell, int actionIndex) Casts a spell by action index using the specified interaction method.voidcast(InteractMethod interactMethod, Spell spell, String action) Casts a spell with a specific action name using the specified interaction method.voidcast(InteractMethod interactMethod, Spell spell, INPC target) Casts a spell on an NPC using the specified interaction method.voidcast(InteractMethod interactMethod, Spell spell, IPlayer target) Casts a spell on another player using the specified interaction method.voidcast(InteractMethod interactMethod, Spell spell, IItem target) Casts a spell on an inventory item using the specified interaction method.voidcast(InteractMethod interactMethod, Spell spell, ITileItem target) Casts a spell on a ground item using the specified interaction method.voidcast(InteractMethod interactMethod, Spell spell, ITileObject target) Casts a spell on a tile object (game object) using the specified interaction method.default voidCasts a spell without a target using the default interaction method.default voidCasts a spell by action index using the default interaction method.default voidCasts a spell with a specific action name using the default interaction method.default voidCasts a spell on an NPC using the default interaction method.default voidCasts a spell on another player using the default interaction method.default voidCasts a spell on an inventory item using the default interaction method.default voidCasts a spell on a ground item using the default interaction method.default voidcast(Spell spell, ITileObject target) Casts a spell on a tile object (game object) using the default interaction method.voidDisables autocasting by deselecting the current autocast spell.Gets the timestamp of when the Home Teleport spell was last used.booleanChecks if any spell is currently set for autocasting.booleanisAutoCasting(Spell spell) Checks if a specific spell is currently set as the autocast spell.booleanChecks if defensive autocasting mode is currently active.booleanChecks if the Home Teleport spell is currently on cooldown.booleanisSpellSelected(Spell spell) Checks if a specific spell is currently selected for casting.voidselectSpell(Spell spell) Selects a spell in the spellbook interface for casting on a target.voidsetAutoCast(Spell spell, boolean defensive) Sets the autocast spell for combat.
-
Method Details
-
isAutoCasting
Checks if a specific spell is currently set as the autocast spell.- Parameters:
spell- the spell to check for autocast status- Returns:
trueif the specified spell is the current autocast spell,falseotherwise
-
isAutoCasting
boolean isAutoCasting()Checks if any spell is currently set for autocasting.- Returns:
trueif autocasting is enabled with any spell,falseotherwise
-
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:
trueif defensive autocasting is active,falseotherwise
-
isSpellSelected
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:
trueif the specified spell is currently selected,falseotherwise
-
cast
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), ornullto use the default methodspell- the spell to casttarget- the inventory item to cast the spell on
-
cast
Casts a spell on an inventory item using the default interaction method.- Parameters:
spell- the spell to casttarget- the inventory item to cast the spell on
-
cast
Casts a spell on an NPC using the specified interaction method.- Parameters:
interactMethod- the method to use for interaction, ornullfor defaultspell- the spell to casttarget- the NPC to cast the spell on
-
cast
Casts a spell on an NPC using the default interaction method.- Parameters:
spell- the spell to casttarget- the NPC to cast the spell on
-
cast
Casts a spell on another player using the specified interaction method.- Parameters:
interactMethod- the method to use for interaction, ornullfor defaultspell- the spell to casttarget- the player to cast the spell on
-
cast
Casts a spell on another player using the default interaction method.- Parameters:
spell- the spell to casttarget- the player to cast the spell on
-
cast
Casts a spell on a ground item using the specified interaction method.- Parameters:
interactMethod- the method to use for interaction, ornullfor defaultspell- the spell to casttarget- the ground item to cast the spell on
-
cast
Casts a spell on a ground item using the default interaction method.- Parameters:
spell- the spell to casttarget- the ground item to cast the spell on
-
cast
Casts a spell on a tile object (game object) using the specified interaction method.- Parameters:
interactMethod- the method to use for interaction, ornullfor defaultspell- the spell to casttarget- the tile object to cast the spell on
-
cast
Casts a spell on a tile object (game object) using the default interaction method.- Parameters:
spell- the spell to casttarget- the tile object to cast the spell on
-
cast
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, ornullfor defaultspell- the spell to cast
-
cast
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
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, ornullfor defaultspell- the spell to castaction- the name of the action to perform on the spell
-
cast
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 castaction- the name of the action to perform on the spell
-
cast
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, ornullfor defaultspell- the spell to castactionIndex- the index of the action in the spell's context menu
-
cast
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 castactionIndex- the index of the action in the spell's context menu
-
selectSpell
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
Instantwhen Home Teleport was last cast, ornullif 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:
trueif Home Teleport is on cooldown,falseotherwise
-
setAutoCast
Sets the autocast spell for combat.- Parameters:
spell- the spell to set as autocastdefensive-trueto use defensive casting (grants Defence XP),falsefor normal casting
-
deselectAutoCast
void deselectAutoCast()Disables autocasting by deselecting the current autocast spell.
-