*NEWBIE* Wearing off messages

From: Carlos Rodriguez (crodrigu@academ01.chs.itesm.mx)
Date: 07/17/96


   I've implemented the 'waterwalk' and 'fly' spells in my mud. They are
working great, but I want to add a check so that if any of these spells
wears off and you're standing in a FLYING or NO_SWIM sector you'll die.

   To prevent unfair kills, I put a warning in 'affect_update' in 
magic.c so that it warns you when the spell is going to wear off. This is 
how it looks:

---------
void affect_update(void)
{
  static struct affected_type *af, *next;
  static struct char_data *i;
  extern char *spell_wear_off_msg[];
  
  for (i = character_list; i; i = i->next)
    for (af = i->affected; af; af = next) {
      next = af->next;
      if (af->duration >= 1) {
        af->duration--;
>	   if (af->duration == 1) {   
>        	   if (IS_AFFECTED(ch, AFF_FLY))
>               	send_to_char("The flying spell is wearing off.", ch);
>           if (IS_AFFECTED(ch, AFF_WATERWALK))
>	                send_to_char("The waterwalk spell is wearing off.", ch);
>           }
      } else if (af->duration == -1)    /* No action */   
     	   af->duration = -1;      /* GODs only! unlimited */
      else {
        if ((af->type > 0) && (af->type <= MAX_SPELLS))
          if (!af->next || (af->next->type != af->type) ||
              (af->next->duration > 0))
            if (*spell_wear_off_msg[af->type]) {
              send_to_char(spell_wear_off_msg[af->type], i);
              send_to_char("\r\n", i);
            }
        affect_remove(i, af); 
      }
    }
}

-------------

 However, it gives me this error when compiling:

-----
magic.c: In function `affect_update':
magic.c:236: `ch' undeclared (first use this function)
magic.c:236: (Each undeclared identifier is reported only once
magic.c:236: for each function it appears in.)
The error code from the last failed command is 1.

Make Quitting.
The error code from the last failed command is 2.

Make Quitting.

-----

  How can I correct this mistake? 

  By the way, how can I kill the poor guy? I think this would do:

------
>  affect_remove(ch, ch->affected);
>  death_cry(ch);
>  extract_char(ch);
------

  Is it OK? Can i put it in 'affect_update' or is there a better place?

  Thanx!

------------------------------------------------------------------------------
  Visita Agharti!!!                 |             	    Carlos Rodriguez
    http://wwww.chs.itesm.mx:8080/  |		crodrigu@campus.chs.itesm.mx
    crodrigu/Agharti/		    |		webadmin@campus.chs.itesm.mx
				    |  http://www.chs.itesm.mx:8080/crodrigu/
------------------------------------------------------------------------------
 



This archive was generated by hypermail 2b30 : 12/07/00 PST