Re: Newbie question--next_in_room

From: Justin (c616077@SHOWME.MISSOURI.EDU)
Date: 09/19/97


> > Does next_in_room ever equal NULL, or does it just wrap around to the
> > first person/npc again?  I'm trying to find an example in the code where
> > it goes through the occupants on a room one by one so that I can make a
> > spell that hits a character at random.  Anyone know of a place in the code

> Here's a piece of code to do that:
>
> struct char_data *vict, *next_v;
>
>   for (vict = world[ch->in_room].people; vict; vict = next_v) {
>        next_v = vict->next_in_room;
>        if (vict && (vict->in_room == ch->in_room)) {
>         /* put your spell on vict here */

Now, isn't this going to go through each and every char/npc in room except
the caster?  I need it to just hit _one_ character/npc, at random, and
then stop.  Like two mages fighting, one has previously cast "reflect
electricity", and the other casts "call lightning".  It's going to bounce
off the first mage's shield and possibly hit something else in the room,
but not nesseccarily.  Will this work?  Looks like I need to add some
checks for ch=vict...

Not sure,
Salvatore


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



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