Skip to main content

Spell script structure

Each spell has a Lua file in scripts/actions/spells/ organized by spell school. Spells expose standard handler functions.

Spell handler reference

Damage spell calculations

scripts/globals/spells/damage_spell.lua contains xi.spells.damage, used for all direct-damage magic (Black, White, Dark, Ninjutsu). Damage parameters are stored in a table indexed by spell ID:
Call xi.spells.damage.useDamageSpell(caster, target, spell) to run the full pipeline including:
  • Base power lookup from the parameter table
  • Stat modifier (INT/MND) application
  • Magic accuracy vs. magic evasion (resist rate from magic_hit_rate.lua)
  • Day/weather bonus (damage_multipliers.lua)
  • Magic burst multiplier (magicburst.lua)
  • Stoneskin, Phalanx, One For All absorption
  • Final HP adjustment

Cure spells

Cure calculations live in scripts/globals/magic.lua:

Enfeebling and enhancing spells

Helper modules in scripts/globals/spells/ cover other spell families:

Blue magic

scripts/globals/bluemagic.lua provides xi.spells.blue with calculation routines for Blue Mage spells. Blue magic spells can be physical or magical and reuse the mob skill calculation pipeline.
Blue magic physical spells use WSC alpha scaling based on the caster’s level:
Individual blue magic spell scripts live in scripts/actions/spells/blue/ and call into xi.spells.blue helpers.

Job abilities

scripts/globals/ability.lua provides xi.ability.adjustDamage(), which applies universal modifiers to job ability damage:
Individual job ability scripts live in scripts/actions/abilities/ and return a table with:

Ninjutsu

Ninjutsu tools are checked and consumed automatically by the C++ core. Ninjutsu spell scripts follow the same structure as regular spells but may reference scripts/globals/spells/enhancing_ninjutsu.lua for buff ninjutsu.

Spell object API

The spell object passed to all spell handlers is a CLuaSpell (bound in src/map/lua/lua_spell.cpp).