/* * Knock code * * Written by John Patrick (j.s.patrick@ieee.org) * for Ansalon (ansalonmud.com 8679) * * I'm very big in intellectual property rights. In order to use * this code or any derivatives in your MUD, you must do the following: * * - E-mail me at j.s.patrick@ieee.org * - Have a helpfile for the item that includes a credit to me, with * the above e-mail address in it. (E.g. This code was written by * John Patrick (j.s.patrick@ieee.org) and used with permission.) * */ #include #include #include #include "merc.h" #include "recycle.h" /* Extern calls. */ extern int find_door args( ( CHAR_DATA *ch, char *arg ) ); /**************************************************************************/ /* * This function allows a character to knock on a door. */ void do_knock(CHAR_DATA *ch, char *argument) { /* Constructs taken from do_open(). */ int door; char arg[MAX_INPUT_LENGTH]; one_argument(argument,arg); if (arg[0] == '\0') { send_to_char("Knock on what?\n\r",ch); return; } if ( ( door = find_door( ch, arg ) ) >= 0 ) { ROOM_INDEX_DATA *to_room; EXIT_DATA *pexit; EXIT_DATA *pexit_rev; pexit = ch->in_room->exit[door]; act( "$n knocks on the $d.", ch, NULL, pexit->keyword, TO_ROOM); act( "You knock on the $d.", ch, NULL, pexit->keyword, TO_CHAR); /* Notify the other side. */ if ( ( to_room = pexit->u1.to_room ) != NULL && ( pexit_rev = to_room->exit[rev_dir[door]] ) != NULL && pexit_rev->u1.to_room == ch->in_room ) { CHAR_DATA *rch; for ( rch = to_room->people; rch != NULL; rch = rch->next_in_room ) act( "You hear someone knocking.", rch, NULL, pexit_rev->keyword, TO_CHAR); } } return; }