Spellcasting
version 2 by Jim Aikin
Section 2 - Trapping Non-Allowed References to Spell Objects & Spell-Casting Verb
Instead of doing anything when the noun is a magic-spell (this is the pretend the spell is invisible rule):
if the current action is casting something:
continue the action;
otherwise if the current action is casting something at something:
continue the action;
otherwise if the current action is zapping:
continue the action;
otherwise:
say "[cant-see-any-such]".
[This rule handles the case where the player types 'cast X'. When the intended action is "cast", we want a different error message, not "You can't see any such thing," since one can't see spells. However, if word 1 is "cast" and word 2 is the name of a spell, then we're getting the parser error because something later in the input made no sense, so in this case we DO want "You can't see any such thing."]
Rule for printing a parser error when the latest parser error is can't see any such thing error (this is the new can't see any such thing rule):
let T be indexed text;
let T be the player's command;
if word number 1 in T is "cast":
let W be word number 2 in T;
repeat with N running from 1 to the number of rows in the Table of Spells:
let S be the spell in row N of the Table of Spells;
let SS be the printed name of S;
if W is SS:
say "[cant-see-any-such]";
stop the action;
say "[unknown-spell]";
otherwise:
say "[cant-see-any-such]".
[This rule handles the case where the player tries to cast a spell (learned or unlearned) at an object that is not in scope or does not exist. Without this rule, Inform would reply, "That's not a verb I recognize," which would be misleading if the spell were known. So we need to trap the first word in the input and look at it. If it's a spell, we need to output a different error message.]
Rule for printing a parser error when the latest parser error is not a verb I recognise error (this is the new not a verb I recognise rule):
let T be indexed text;
let T be the player's command;
let W be word number 1 in T;
repeat with N running from 1 to the number of rows in the Table of Spells:
let S be the [name of the] spell in row N of the Table of Spells;
let SS be the printed name of S;
if W is SS:
say "[cant-see-any-such]";
stop the action;
continue the action.