[Code] knock

From: Patrick Dughi (dughi@imaxx.net)
Date: 05/10/99


        Here's the important part of a snippet that I've taken for
granted, lets you knock on closed doors, people on the other side hear
you. Good if you think it's rude to poof into certain rooms.  Much of it
is the do_gen_door procedure hacked up.  You'll probably want to put this
in act.movement.c else many of the macros defined therein will not work so
well huh?

ACMD(do_knock) {
  int door = -1;
  struct obj_data *obj=NULL;
  char type[MAX_INPUT_LENGTH], dir[MAX_INPUT_LENGTH];

  skip_spaces(&argument);
  if (!*argument) {
    send_to_char("Knock on what, exactly?", ch);
    return;
  }

  two_arguments(argument, type, dir);
  door = find_door(ch, type, dir, cmd_door[subcmd]);

  if(door < 0) {
    send_to_char("There's nothing like that here.\r\n",ch);
    return;
  }
  if (!(DOOR_IS_OPENABLE(ch, obj, door))) {
    act("You can't knock on that!", FALSE, ch, 0, 0, TO_CHAR);
    return;
  } else if (!DOOR_IS_CLOSED(ch, obj, door) &&
            IS_SET(flags_door[subcmd], NEED_CLOSED)) {
    send_to_char("But it's currently open!\r\n", ch);
    return;
  }

  sprintf(buf,"$n knocks on the %s.", (!(EXIT(ch, door)->keyword) ?
       "door" : fname(EXIT(ch, door)->keyword)));

  act(buf,FALSE, ch, 0, 0, TO_ROOM);

  sprintf(buf,"You knock on the %s.", (!(EXIT(ch, door)->keyword) ?
       "door" : fname(EXIT(ch, door)->keyword)));

  act(buf,FALSE, ch, 0, 0, TO_CHAR);

  sprintf(buf,"There is a loud knock from the %s.",
    (!(EXIT(ch,door)->keyword) ? "door" :
       fname(EXIT(ch, door)->keyword)));

  send_to_room(buf,EXIT(ch,door)->to_room);
  return;
}

                                                        PjD


     +------------------------------------------------------------+
     | 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