Code:
ASPELL(spell_dispel_magic)
{
int ld;
struct affected_type *af, *next;
if (ch == NULL || victim == NULL)
return;
/* Now I fixed up the levels system in affects we can do this properly */
for(af = victim->affected;af;af = next) {
next = af->next;
/* Non-spell affects cannot be dispelled, and no fail msg */
if ((af->type == SPELL_POISON) || (af->type > MAX_SPELLS))
continue;
/* level difference modifies casting chance */
ld = af->level - GET_LEVEL(ch) + 20;
if (ld < number(0,40)) {
if (*spell_wear_off_msg[af->type]) {
send_to_char(spell_wear_off_msg[af->type], victim);
send_to_char("\r\n", victim);
}
affect_remove(victim, af);
} else {
send_to_char("Part of the dispel fails!\r\n", ch);
}
}
}