[Circle] [CODE] Listen Skill

From: Theodore Dubroff (ted@iag.net)
Date: 08/22/96


code and ideas from this list it only seems fitting to give back to it.
The code below is for a new skill (SKILL_LISTEN) that is intended primarily
to advance role-playing in muds.  Players will like it as it gives them a
chance to detect if someone is hiding in the room getting ready to pounce
on them.  There may be a parantheses error in the #define below but I don't
feel like checking as you will probably have to redefine it anyway.  Other 
than that this code only needs to be supported in spells.h, interpreter.c, 
and spell_parser.c (I believe).
   
If you use this code please credit: 

      The Immortal Staff of Eclipse of Fate
             eclipse.argy.com 7777



#define CAN_LISTEN_BEHIND_DOOR(ch,dir)  \
                ((GET_GUILD_RANK(ch, GUILD_THIEF) >= 3) && \
                (EXIT(ch, dir) && EXIT(ch, dir)->to_room != NOWHERE && \
                 IS_SET(EXIT(ch, dir)->exit_info, EX_CLOSED)))


ACMD(do_listen)
{
   struct char_data *tch, *tch_next;
   int dir, percent, found = 0;
   char *heard_nothing = "You don't hear anything unusual.\r\n";
   char *room_spiel    = "$n seems to listen intently for something.";

   percent = number(1,101);

   if(GET_SKILL(ch, SKILL_LISTEN) < percent) {
      send_to_char(heard_nothing, ch);
      return;
   }

   one_argument(argument, buf);

   if(!*buf) {  
      /* no argument means that the character is listening for
       * hidden or invisible beings in the room he/she is in
       */
      for(tch = world[ch->in_room].people; tch; tch = tch_next) {
         tch_next = tch->next_in_room;
         if((tch != ch) && !CAN_SEE(ch, tch) && (GET_LEVEL(tch) < LVL_IMMORT)) 
            found++;
      }
      if(found) {
         if(GET_LEVEL(ch) >= 15) {  
            /* being a higher level is better */
            sprintf(buf, "You hear what might be %d creatures invisible, or hiding.\r\n", \
                        MAX(1,(found+number(0,1)-number(0,1))));
         }
         else sprintf(buf, "You hear an odd rustling in the immediate area.\r\n");
         send_to_char(buf, ch);
      }
      else send_to_char(heard_nothing, ch);
      act(room_spiel, TRUE, ch, 0, 0, TO_ROOM);
      return;
   }
   else {
      /* the argument must be one of the cardinal directions: north, 
       * south, etc.
       */
      for(dir = 0; dir < NUM_OF_DIRS; dir++) {
         if(!strncmp(buf, dirs[dir], strlen(buf)))
            break;
      }
      if (dir == NUM_OF_DIRS) {
         send_to_char("Listen where?\r\n", ch);
         return;
      }
      if(CAN_GO(ch, dir) || CAN_LISTEN_BEHIND_DOOR(ch, dir)) {
         for(tch = world[EXIT(ch, dir)->to_room].people; tch; tch=tch_next) {
            tch_next = tch->next_in_room;
            found++;
         }
         if(found) {
            if(GET_LEVEL(ch) >= 15) {
               sprintf(buf, "You hear what might be %d creatures %s%s.\r\n", \
                        MAX(1,(found+number(0,1)-number(0,1))),
                        ((dir==5)?"below":(dir==4)?"above": "to the "), 
                        ((dir==5)?"":(dir==4)?"":dirs[dir]));
            }
            else sprintf(buf, "You hear sounds from %s%s.\r\n", \
                        ((dir==5)?"below":(dir==4)?"above": "the "), 
                        ((dir==5)?"":(dir==4)?"":dirs[dir]));
            send_to_char(buf, ch);
         }
         else send_to_char(heard_nothing, ch);
         act(room_spiel, TRUE, ch, 0, 0, TO_ROOM);
         return;
      }
      else send_to_char("You can't listen in that direction.\r\n", ch);
      return;
   }
   return;
}


+-----------------------------------------------------------+
| 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/07/00 PST