Eavesdrop Skill [by Siv]
Snippet Posted Wednesday, August 12th @ 11:26:45 PM, by George Greer in the Skills dept.
Added Apr 27, 1998. Click the link below to read it or download it.

From: ";P" <siv@CYBERENET.NET>
Subject: New Skill

here's a new skill for thieves and the like..it allows them to eavesdrop
on an adjacent room..

1 - add a struct char_data *listeners to the room_data struct..
2 - add a struct char_data *next_listener to the char_data struct..
3 - add a sh_int listening_to to the char_data struct..
4 - add in do_eavesdrop (prototyping whatever needs it):

ACMD(do_eavesdrop) {
  int dir;
  one_argument(argument, buf);

  if (!*buf) {
    send_to_char("In which direction would you like to eavesdrop?\r\n", ch);
    return;
  }
  if ((dir = search_block(buf, dirs, FALSE)) < 0) {
    send_to_char("Which directions is that?\r\n", ch);
    return;
  }
  if (!skill_check(ch, SKILL_EAVESDROP)) {
    send_to_char("You try to eavesdrop on that room, but fail.\r\n", ch);
    return;
  }
  if (EXIT(ch, dir)) {
    if (IS_SET(EXIT(ch, dir)->exit_info, EX_CLOSED) && EXIT(ch, dir)->keyword)
{
      sprintf(buf, "The %s is closed.\r\n", fname(EXIT(ch, dir)->keyword));
      send_to_char(buf, ch);
    } else {
      ch->next_listener = world[EXIT(ch, dir)->to_room].listening;
      world[EXIT(ch, dir)->to_room].listening = ch;
      ch->listening_to = EXIT(ch, dir)->to_room;
      send_to_char(OK, ch);
    }
  } else
    send_to_char("There is not a room there...\r\n", ch);
}

5 - change do_eavesdrop to use whatever skill checking method you like..
6 - change send_to_room in comm.c to look like this:

void send_to_room(char *messg, int room)
{
  struct char_data *i;

  if (messg) {
    for (i = world[room].people; i; i = i->next_in_room)
      if (i->desc)
        SEND_TO_Q(messg, i->desc);
    for (i = world[room].listening; i; i = i->next_listener)
      if (i->desc) {
/*  the ------'s are used to differentiate eavesdropped stuff from
 *  the stuff that is happening in the same room as the char..
 *  looks like:
 *  -------
 *  john dropped a sword
 *  ------
 */
        sprintf(buf, "----------\r\n%s----------\r\n", messg);
        SEND_TO_Q(buf, i->desc);
      }
  }
}

6 - add this command_interpreter in interpreter.c just below the removal
of the HIDE bit..
  if (ch->listening_to) {
    REMOVE_FROM_LIST(ch, world[ch->listening_to].listening, next_listener);
    ch->listening_to = NULL;
  }

that should be all..


<< Dual Wield [by Argon] | Reply | View as text | Threaded | Economy Code (for MercMuds) [by Maniac] >>

 


Related Links
  download
Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.