Interface Spell
- All Known Implementing Classes:
SpellBook.Ancient,SpellBook.Lunar,SpellBook.Necromancy,SpellBook.Standard
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 TypeMethodDescriptionbooleancanCast()Checks whether this spell can currently be cast.default voidcast()Casts this spell without a target.default voidCasts this spell with a specific action.default voidcastOn(Interactable interactable) Casts this spell on the specified interactable target.intGets the autocast index for this spell.intGets the component ID for this spell's widget in the spellbook interface.default InterfaceAddressDeprecated, for removal: This API element is subject to removal in a future version.This method is scheduled for removal.intgetLevel()Gets the Magic level required to cast this spell.intGets 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, for removal: This API element is subject to removal in a future version.This method is scheduled for removal. UsegetComponent()instead.Gets the interface address for this spell.- Returns:
- the
InterfaceAddressfor 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:
trueif the spell can be cast,falseotherwise
-
getRequirements
RuneRequirement[] getRequirements()Gets the rune requirements for casting this spell.Each
RuneRequirementspecifies a rune type and the quantity needed. Combination runes and staff bonuses are considered when checking if requirements are met.- Returns:
- an array of
RuneRequirementobjects, or an empty array if no runes are required
-
getSpellBook
SpellBook getSpellBook()Gets the spellbook that contains this spell.- Returns:
- the
SpellBookthis 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
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
Casts this spell on the specified interactable target.This method automatically handles different target types including:
IItem- Inventory itemsINPC- Non-player charactersIPlayer- Other playersITileItem- Items on the groundITileObject- Game objects in the world
- 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
-