[CODING] Spec Proc bug...

From: CyberLord (tmillea@nfinity.com)
Date: 12/12/98


I figured out *what* is happening.. I just can't figure out *why*. :)

Somehow during the fight and the goto command the monster becomes the victim
and the player becomes the ch.  The required number of rounds goes by and
the monster is transported to the room instead of the player.

Then I do a goto command and I goto the monster who is already in the room
and
thats how *I* get into the room.

I fixed the code to look for this problem so I can 'return FALSE;' before
the monster
is moved into the room but this doesn't fix the problem of the victim
becoming the
monster in the first place.

If someone could shed some light on this for me (being new to the inner
workings
of CircleMUD) I sure would appreciate it.

Thanks :)

Snippet follows:

SPECIAL(monster)
{
        struct char_data *vict;
        static round;
        static max_rounds;

        if(max_rounds == 0) // if max_rounds has not been set yet
                max_rounds = number(3,6); // set it to a random number between 3 and 6

        if ((GET_POS(ch) == POS_FIGHTING))//if the mob is fighting
    {
                //need to let a few rounds go by first
                if(round < max_rounds)
                {
                        printf("spec_proc.c::SPECIAL(monster)::Round - %d\n",round); //debugging
code remove when done
                        round++;
                        return FALSE;//return for next round
                }

                else//if random number of rounds have occured
                {
                        vict = FIGHTING(ch);
                        printf("spec_proc.c::SPECIAL(monster)::Victim is: %s\n",GET_NAME vict));
//debugging code remove when done
                        printf("spec_proc.c::SPECIAL(monster)::Monster is: %s\n",GET_NAME(ch));
//debugging code remove when done

//this may not be required anymore
                        if(!vict)
                                return FALSE;

                        //if the victim somehow becomes the monster we need to return
                        if(strcmp(GET_NAME(vict), "monster name") == 0)
                        {
                                printf("spec_proc.c::SPECIAL(monster)::Hey.. mob became victim somehow,
need to return\n"); //debugging code remove when done
                                return FALSE;
                        }

                        //tell the player they have been moved
                        send_to_char("Blah Blah Blah...",vict);
//tell the room the player has been moved
                        act("Blah Blah Blah...", FALSE, vict, 0, 0, TO_NOTVICT);

                        round = 0; // reset round variables for next fight
                        max_rounds = 0; // reset max rounds variable for next fight

                        //move the player
                    char_from_room(vict);//remove player from current room

                        //move to random of 2 rooms
                        switch(number(0,1))
                        {
                        case 0:
                        char_to_room(vict, real_room(30004));//put him in room
                        break;
                        case 1:
                        char_to_room(vict, real_room(30005));//put him in room
                        break;
                        }//end switch

                        //have player look at new room
                        look_at_room(vict, 0);

                }//end else

        }//end if

        else//if monster is not fighting
        {
                round = 0; // reset round variables for next fight
                max_rounds = 0; // reset max rounds variable for next fight
                act("Special room action is done here...", FALSE, ch, 0, 0, TO_ROOM);
        }//end else

return FALSE;//return to regular code

}//end SPECIAL(monster)


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



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