
From Exemplary Game Magic Systems to Code Recipes ◾ 51
sure that casting requirements are met. A player must have the ability
to cast spells, must have light, must not be confused, and must have a
spell book. If any of these re quirements is not met, the player receives an
error message and casting stops.
RECIPE 11: SPELL MISFIRE EFFECTS (HELLBAND, C)
/* Spell failure chance */
chance = spell_chance(spell,use_realm-1);
/* Failed spell */
if (rand_int(100) < chance)
{
if (flush_failure) flush();
msg _format("You failed to get the%s off!",
prayer);
if (o_ptr->tval = = TV_CHAOS_BOOK &&
(randint(100)<spell))
{
msg_print("You ...