Overview
TheSpell class manages spell information, tracking, and casting in Lich. It provides methods to query spell data, check active spells, cast spells with proper preparation and stance management, and track spell durations.
Spells are loaded from effect-list.xml and include information about:
- Mana, spirit, and stamina costs
- Spell durations and formulas
- Active spell tracking with timers
- Type classification (attack, defense, utility)
- Availability (self-cast, group, all)
Quick Start
Instance Attributes
Spell number (e.g. 101, 202, 1711)
Spell name (e.g. “Spirit Warding I”, “Major Sanctuary”)
Spell type: “attack”, “defense”, “utility”, etc.
Spell circle number as string (“1” for Minor Spirit, “2” for Major Spirit, etc.)
Whether the spell is currently active on you
Who can receive the spell: “self-cast”, “group”, or “all”
Whether this spell requires offensive stance to cast
Whether this spell uses CHANNEL instead of CAST
Class Methods - Lookup
Spell[val]
Looks up a spell by number, name, or pattern.Spell number, name, or pattern to match
Spell object, or nil if not found
Spell.list
Returns all loaded spells.Array of all Spell objects
Spell.active
Returns all currently active spells.Array of active Spell objects
Spell.active?(val)
Checks if a specific spell is active.Spell number or name
True if the spell is active
Instance Methods - Information
active?
Checks if this spell is currently active.True if spell is active with time remaining
known?
Checks if you know this spell (have trained enough ranks).True if you have the ranks to cast this spell
available?(options = )
Checks if the spell is available to cast on the target.Optional hash with :target and :caster keys
True if spell can be cast with given parameters
timeleft
Returns remaining duration in minutes.Minutes remaining, or 0.0 if not active
secsleft
Returns remaining duration in seconds.Seconds remaining
circle_name
Returns the name of the spell circle.Name of the spell circle
Instance Methods - Costs
mana_cost(options = )
Calculates the mana cost for casting this spell.Options including :target, :caster, :multicast
Mana cost in points
spirit_cost(options = )
Calculates the spirit cost (for Paladin spells).Spirit cost in points
stamina_cost(options = )
Calculates the stamina cost (for Monk spells with Mental Acuity).Stamina cost in points
affordable?(options = )
Checks if you have enough resources to cast this spell.True if you can afford to cast the spell
Instance Methods - Casting
cast(target = nil, results_of_interest = nil, arg_options = nil, force_stance: nil)
Casts the spell with automatic preparation, stance management, and error handling.Target for the spell (GameObj, ID, or name). Use “target” for current target.
Additional patterns to watch for in results
Additional casting options (e.g. “at door”, “channel”, “evoke”)
Override stance behavior (true = force offensive, false = never change)
Result text from the cast, or false on failure
force_cast(target = nil, arg_options = nil, results_of_interest = nil, force_stance: nil)
Forces CAST command (never uses INCANT).force_channel(target = nil, arg_options = nil, results_of_interest = nil, force_stance: nil)
Forces CHANNEL command.force_evoke(target = nil, arg_options = nil, results_of_interest = nil, force_stance: nil)
Forces EVOKE command.force_incant(arg_options = nil, results_of_interest = nil, force_stance: nil)
Forces INCANT command.Instance Methods - Duration Management
putup(options = )
Manually activates the spell with calculated duration.Options for duration calculation
putdown
Manually deactivates the spell and sets timeleft to 0.stackable?(options = )
Checks if the spell duration stacks when recast.True if spell stacks
refreshable?(options = )
Checks if the spell duration refreshes when recast.True if spell refreshes
Class Methods - Utilities
Spell.load(filename = nil)
Loads spell data from XML file.Path to effect-list.xml (defaults to DATA_DIR)
True on success, false on failure
