Spells
Technically, Spells are just Skills that don't have their own functions; they are all used by typing 'cast' followed by the name of the spell. This gives all spells some common properties.
Remember that you can always type help <spell name> in the game itself to get skill info.
The slookup <skill/spell name> command can also show additional interesting info.
Spell Usage
The base chance of a spell succeeding is slightly greater than the player's skill% in that spell. If a spell fails to cast, the player receives the 'lost your concentration' message and only 1/3 of the normal mana cost is used. There is always a 2% chance of spell failure, however.
- The Deliver spell is exceptional in that there is no base 2% failure chance, but the amount of mana consumed on failing is half its normal cost. I don't know why this is.
Attempting to cast a spell causes a set amount of lag to the player, depending on the spell used.
When a monster casts a spell, it goes through a different but similar function; most notably, mob spells don't consume mana, don't cause lag, and ignore cooldown.
No player spells can be cast when the player is sitting, resting, or sleeping. Some can only be cast out of combat, but there are none yet that can only be cast in combat.
Because of their common activation requirements, Spells can also be used via items like potions and wands. This differentiates them from skills.
Spell Modifiers
There are several flags that can affect the way spells get cast. Unless otherwise noted, all these affects apply when mobs cast spells as well.
- The Choke flag reduces the level of any spell cast by 1/4.
- Berserk, Seraph Form, or Oozaru characters can't cast spells at all! This is not true for mobs.
- The Reflect flag (granted by the Wandering Eye spell) will make offensive and defensive spells bounce back to their caster. Area-effect spells are unaffected.
Target types
Spells have a target type specified in their definition. This mostly determines how the spellcasting functions look for targets, or what target they default to if one isn't specified.
Skills also have target types specified and could be sorted out using them, but this isn't actually used anywhere in the code right now.
- TAR_IGNORE
- Spells with no targeting needed.
- Like Create Food or Overgrowth.
- TAR_CHAR_OFFENSIVE
- Offensive single-target spells. The assumed target is whoever the caster is fighting, or the spell will fail if no target is specified and the caster isn't fighting.
- Like Acid Blast or Blind.
- TAR_CHAR_DEFENSIVE
- Defensive spells that target the caster by default.
- Like Charge or Mend.
- TAR_CHAR_SELF
- Spells that can only target the caster. Fail to cast if targeting anyone or anything else.
- Like Golem Skin or Wizen.
- TAR_OBJ_INV
- Spells that target an object worn by the caster or in the caster's inventory. Fail to cast if an object by the specified name isn't found.
- Like Create Water or Scan.
- TAR_OBJ_CHAR_DEF
- Nominally defensive spells that can also be used on objects in the caster's inventory (but not worn). Prefers to be cast on a mob/player if there is any ambiguity.
- Only Invisibility, Detect Poison, and Uncurse use this.
- TAR_OBJ_CHAR_OFF
- Nominally offensive spells that can also be used on objects in the caster's inventory (but not worn). Prefers to be cast on a mob if there is any ambiguity.
- Only Blight and Bio use this.
- TAR_OBJ_TRAN
- Special kludges for the Deliver spell, since it takes TWO arguments -- an object in the caster's inventory AND a player name that might be anywhere in the world.
- Only Deliver uses this.
- TAR_OBJ_WEP
- Targets a weapon, and only a weapon, wielded by the caster or in the caster's inventory. Defaults to the wielded weapon if nothing is specified.
- Like the various Saber spells.
- TAR_OBJ_HERE
- Targets an object in the caster's loose in the room, in the caster's inventory, or work by the caster (and checks in that order). Fails if an object by the specified name isn't found.
- Only Recharge and Phlogiston use this.
- TAR_PASSIVE
- Not assigned to any extant spells, only skills (where it's not used anyway).
- TAR_IGNORE_OFFENSIVE
- Nominally offensive spells that don't take an argument, usually "area" attacks. Set as a separate type so they can be affected by Echomagic and Powersurge.
- Like Tractor Beam or Pyroclasm.
- TAR_IGNORE_DEFENSIVE
- Nominally defensive spells that don't take an argument, usually "group" buffs. Set as a separate type so they can be affected by Powersurge.
- Used only by Rejuvenation and Life Support.
- The Nurse spell also uses this targeting type and gets its additional argument in a roundabout way.