Re: [CIRCLE][CODE]complainer

From: Alvoria MUD (mudguy@conan.ids.net)
Date: 12/15/96


On Sat, 14 Dec 1996, Hydragon wrote:
> I have recently installed the complainer code from the list and did 
> a few fix ups to allow it to compile without errors, now the game
> crashes after only a few seconds of active connection.

I'm very sorry people... I probably should have tested the code before
submitting it :P. Here is a corrected version (once again). I think I
won't be submitting code written from the mailer again... :P I found a lot
more bugs than I had expected (including logic errors that compiled, but
led to the wrong effect...) beyond the one that led to Hydragon's crash.
Hopefully there aren't any bugs left now. Whew...

  - mendar

--

/* start of the proc stuff... */

int get_people_room(const int room)
{
  struct char_data *person;
  int i=0;

  for(person=world[room].people ; person; person=person->next_in_room)
    {
      if(person)
        i++;
    }

  return i;
}

struct char_data *select_person_room(const int room, const int whom)
{
  struct char_data *person;
  int i;

  i=get_people_room(room);

  if(i==NULL)
    return NULL;

  if(whom>i)
    return NULL;

  if(whom==1)
    {
      return (world[room].people);
    }

  i=whom;

  i--;

  for(person=world[room].people; i; person=person->next_in_room)
    {
      i--;
    }

  return person;
}

SPECIAL(complainer)
{
  ACMD(do_sleep);
  ACMD(do_say);
  ACMD(do_flee);
  ACMD(do_wake);

  struct char_data *vict1,*self;

  self=(struct char_data *)me;

  if((!AWAKE(self))&&(!IS_AFFECTED(self, AFF_SLEEP)))
    {
      if(cmd)
        {
          if(number(0,1))
            {
              act("$n awakens.", TRUE, self, 0, 0, TO_ROOM);
              GET_POS(self) = POS_STANDING;
            }
          return (0);
        }
      else
        {
          if(number(1,5)==5)
            {
              act("$n awakens.", TRUE, self, 0, 0, TO_ROOM);
              GET_POS(self) = POS_STANDING;
            }
          return (1);
        }
    }

  if(CMD_IS("flee")&&CAN_SEE(self,ch))
    {
      switch(number(1,6))
        {
          case 1:
            act("$n tells you 'Run! Run! Flee while you can!'", FALSE,
                self, 0, ch, TO_VICT);
          break;
          case 2:
            act("$n tells you 'You wimp.'", FALSE, self,
                0, ch, TO_VICT);
          break;
          case 3:
            act("$n tells you 'You wuss! haha...'", FALSE, self,
                0, ch, TO_VICT);
          break;
          default:
          break;
        }

      do_flee(ch,argument,cmd,0);

      switch(number(1,6))
        {
          case 1:
            act("$n says 'I bet $N just peed $S pants.'", FALSE,
                self, 0, ch, TO_ROOM);
          break;
          case 2:
            act("$n says 'I heard $N runs from $S own shadow too.'", FALSE,
                self, 0, ch, TO_ROOM);
          break;
          case 3:
            act("$n says 'I bet $N's afraid of the dark too.'", FALSE,
                self, 0, ch, TO_ROOM);
          break;
          default:
          break;
        }
      return (1);
    }

  if(CMD_IS("sleep")&&CAN_SEE(self,ch))
    {
      do_sleep(ch,argument,cmd,0);
      switch(number(1,6))
        {
          case 1:
            do_say(self, "Ok everyone... Shhhhhh.", 0, 0);
          break;          

          case 2:
            do_say(self, "That's a good idea... I'm going to sleep too.", 0, 0);
            do_sleep(self,0,0,0);
          break;          

          case 3:
            do_say(self, "Heh. What a sleepyhead.", 0, 0);
          break;          

          default:
          break;          
        }
      return (1);
    }

  if(cmd)
    return (0);

  if(FIGHTING(self))
    {
      switch(number(1,10))
        {
          case 1:
            do_say(self,"I think I'm losing...",0,0);
          break;
          case 2:
            do_say(self,"The world won't miss a loudmouth like me. Hah.",0,0);
          break;
          case 3:
            if(GET_HIT(self)<(GET_MAX_HIT(self)/3))
              {
                do_say(self,"I'll live...",0,0);
                do_say(self,"My cuts are only flesh wounds.",0,0);
              }
          break;
          default:
          break;
        }
      return (1);
    }

  if(get_people_room(self->in_room)<=1)
    return (0);

  vict1=select_person_room(self->in_room,
                           number(1,get_people_room(self->in_room)));

  if(vict1==self)
    return (0);

  if(!CAN_SEE(self,vict1))
    return (0);

  if(FIGHTING(vict1))
    {
      if((number(0,1))&&
         (CAN_SEE(self,vict1))&&
         (FIGHTING(vict1)!=self))
        {
          vict1=FIGHTING(vict1);  /* swap the person we're talking about */
                                  /* makes it more interesting. */
        }

      switch(number(1,20))
        {
          case 1:
            act("$n says '$N started it!'", FALSE, self, 0, vict1,
                TO_NOTVICT);
            act("$n says 'I KNOW you started it!'", FALSE, self, 0, vict1,
                TO_VICT);
          break;
          case 2:
            act("$n says '$N's fighting technique is so lame...'", FALSE,
                self, 0, vict1, TO_NOTVICT);
            act("$n says 'Your fighting technique is so lame...'", FALSE,
                self, 0, vict1, TO_VICT);
          break;
          case 3:
            act("$n says 'Hehe. I think $N is going to die.'", FALSE,
                self, 0, vict1,TO_NOTVICT);
          break;
          case 4:
            act("$n says 'Hehe. I hope $N loses. $E's such a jerk.'", FALSE,
                self, 0, vict1, TO_NOTVICT);
          default:
          break;
        }
      return (1);
    }

  /* just a summary of how we can get to this point :P. (for those who
     might be lost already) */
  /* execution gets here only if the mob assigned with this is not sleeping,
     not fighting, if a person hasn't fled or gone to sleep, or the person
     we've chosen isn't fighting and awake. */

  switch(number(1,40))
    {
      case 1:
        do_say(self,"I talk too much!",0,0);
      break;
      case 2:
        do_say(self,"I think I'm brainless.",0,0);
      break;
      case 3:
        do_say(self,"I think YOU'RE brainless.",0,0);
      break;
      case 4:
        do_say(self,"People are stupid.",0,0);
      break;
      case 5:
        do_say(self,"Who's to blame?",0,0);
      break;
      case 6:
        if(IS_NPC(vict1) && MEMORY(vict1))
          act("$n says 'I think $N is after someone.'", FALSE, self,
              0, vict1, TO_NOTVICT);
      break;
      case 7:
        act("$n says 'I think $N sleeps too much.'", FALSE, self, 0,
            vict1, TO_NOTVICT);
      break;
      case 8:
        act("$n says 'Run everyone!!! $N is going to kill you!'", FALSE, self,
            0, vict1, TO_NOTVICT);
      break;
      case 9:
        act("$n says 'I saw $N eat the crumbs on the floor of the"
            " bakery.'", FALSE, self, 0, vict1, TO_NOTVICT);
        act("$n says 'Bleeech.'", FALSE, self, 0, vict1, TO_ROOM);
      break;
      case 10:
        act("$n says 'I think $N did it. I'm sure...'", FALSE, self, 0,
            vict1, TO_NOTVICT);
      break;
      default:
      break;
    }
  return (1);
}

Alvoria MUD -- "Exedrin worked really nicely... wow..."
  Address   -- telnet://conan.ids.net:4000/
  Homepage  -- http://users.ids.net/~mudguy/
  (under construction, perhaps not even updated for months to come)

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



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