/**************************************************************************** Keypad snippet, made by -Riketsu. Use this to your discretion. I am not responsible for damage to area files, so, before installing this code, BACK UP YOUR AREA FILES. Even tho, it shouldnt bug, since I already tested it in a MUD. -Enderandrew: Made minor changes to port to SWFotE - If they're wrong, throw something at me via gangrel@punkass.com ****************************************************************************/ -------------------------------------------------------------------------- MUD.H ---- at the end of struct exit_data -------------------------------------------------------------------------- After: sh_int distance; /* how far to the next room */ Add: int keypad; /* Key Pad Password */ -------------------------------------------------------------------------- DB.C -------------------------------------------------------------------------- Find: sscanf( ln, "%d %d %d %d", &x1, &x2, &x3, &x4); locks = x1; pexit->key = x2; pexit->vnum = x3; pexit->vdir = door; pexit->distance = x4; Change to: sscanf( ln, "%d %d %d %d %d", &x1, &x2, &x3, &x4, &x5); locks = x1; pexit->key = x2; pexit->vnum = x3; pexit->vdir = door; pexit->distance = x4; pexit->keypad = x5; NOTE: You gotta change also... sscanf( ln, "%d %d %d %d %d %d %d", &x1, &x2, &x3, &x4, &x5, &x6, &x7 ); -You gotta make it that it holds also the pexit->keypad Enderandrew's Note: I'm not sure the above line needs changing. I could be wrong! -------------------------------------------------------------------------- BUILD.C -------------------------------------------------------------------------- Before: if ( !str_cmp( arg, "sector" ) ) Add: if ( !str_cmp( arg, "keypad" ) ) { argument = one_argument( argument, arg2 ); argument = one_argument( argument, arg3 ); if ( arg2[0] == '\0' || arg3[0] == '\0' ) { send_to_char( "Usage: redit keypad #####\n\r", ch ); return; } if ( arg2[0] == '#' ) { edir = atoi( arg2+1 ); xit = get_exit_num( location, edir ); } else { edir = get_dir( arg2 ); xit = get_exit( location, edir ); } value = atoi( arg3 ); if ( strlen(arg3) != 5 ) { send_to_char( "Usage: redit keypad #####\n\r", ch ); return; } if (!is_number(arg3)) { send_to_char( "Usage: redit keypad #####\n\r", ch ); return; } if ( !xit ) { send_to_char( "No exit in that direction. Use 'redit exit ...' first.\n\r", ch ); return; } xit->keypad = value; send_to_char( "Done.\n\r", ch ); return; } -------------------------------------------------------- Change: sprintf( buf, "Flags for exit direction: %d Keywords: %s Key: %d\n\r[ ", xit->vdir, xit->keyword, xit->key); To: sprintf( buf, "Flags for exit direction: %d Keywords: %s Key: %d KeyPad: %d\n\r[ ", xit->vdir, xit->keyword, xit->key, xit->keypad ); -------------------------------------------------------- Change: fprintf( fpout, "%d %d %d %d\n", xit->exit_info & ~EX_BASHED, xit->key, xit->vnum, xit->distance ); else fprintf( fpout, "%d %d %d\n", xit->exit_info & ~EX_BASHED, xit->key, xit->vnum ); To: fprintf( fpout, "%d %d %d %d %d\n", xit->exit_info & ~EX_BASHED, xit->key, xit->vnum, xit->distance, xit->keypad ); else fprintf( fpout, "%d %d %d %d\n", xit->exit_info & ~EX_BASHED, xit->key, xit->vnum, xit->keypad ); -------------------------------------------------------------------------- ACT_WIZ.C -------------------------------------------------------------------------- Change: "%2d) %2s to %-5d. Key: %d Flags: %d Keywords: '%s'.\n\rDescription: %sExit links back to vnum: %d Exit's RoomVnum: %d Distance: %d\n\r", ++cnt, dir_text[pexit->vdir], pexit->to_room ? pexit->to_room->vnum : 0, pexit->key, pexit->exit_info, pexit->keyword, pexit->description[0] != '\0' ? pexit->description : "(none).\n\r", pexit->rexit ? pexit->rexit->vnum : 0, pexit->rvnum, pexit->distance ); To: "%2d) %2s to %-5d. Key: %d Flags: %d Keywords: '%s'.\n\rDescription: %sExit links back to vnum: %d Exit's RoomVnum: %d Distance: %d Keypad: %d\n\r", ++cnt, dir_text[pexit->vdir], pexit->to_room ? pexit->to_room->vnum : 0, pexit->key, pexit->exit_info, pexit->keyword, pexit->description[0] != '\0' ? pexit->description : "(none).\n\r", pexit->rexit ? pexit->rexit->vnum : 0, pexit->rvnum, pexit->distance, pexit->keypad ); -------------------------------------------------------------------------- ACT_MOVE.C -------------------------------------------------------------------------- void do_keypad( CHAR_DATA *ch, char *argument ) { char arg[MAX_INPUT_LENGTH]; char arg1[MAX_INPUT_LENGTH]; EXIT_DATA *pexit; int password; argument = one_argument( argument, arg ); argument = one_argument( argument, arg1 ); password = atoi(arg1); if ( arg[0] == '\0' || arg1[0] == '\0') { send_to_char( "Syntax: Keypad #####\n\r", ch ); return; } if ( ( pexit = find_door( ch, arg, TRUE ) ) != NULL ) { /* 'unlock door' */ if (IS_SET(pexit->exit_info, EX_LOCKED) ) { if ( pexit->keypad == 0 ) { send_to_char( "You can't do that.\n\r", ch ); return; } if ( !IS_SET(pexit->exit_info, EX_ISDOOR) ) { send_to_char( "You can't do that.\n\r", ch ); return; } if ( !IS_SET(pexit->exit_info, EX_CLOSED) ) { send_to_char( "It's not closed.\n\r", ch ); return; } if ( pexit->keypad < 1 && !IS_SET(pexit->exit_info, EX_SECRET) ) { send_to_char( "It can't be unlocked.\n\r", ch ); return; } if ( password != pexit->keypad ) { send_to_char( "&RACCESS DENIED.\n\r", ch ); return; } if ( !IS_SET(pexit->exit_info, EX_SECRET) || (pexit->keyword && nifty_is_name( arg, pexit->keyword )) ) { send_to_char( "&GACCESS GRANTED!\n\rUnlocking...\n\r", ch ); act( AT_ACTION, "$n types a code on the keypad.", ch, NULL, NULL, TO_ROOM ); remove_bexit_flag( pexit, EX_LOCKED ); return; } } else if (!IS_SET(pexit->exit_info, EX_LOCKED) ) { /*lock door*/ if ( pexit->keypad == 0 ) { send_to_char( "You can't do that.\n\r", ch ); return; } if ( !IS_SET(pexit->exit_info, EX_ISDOOR) ) { send_to_char( "You can't do that.\n\r", ch ); return; } if ( !IS_SET(pexit->exit_info, EX_CLOSED) ) { send_to_char( "It's not closed.\n\r", ch ); return; } if ( pexit->keypad < 1 && !IS_SET(pexit->exit_info, EX_SECRET) ) { send_to_char( "It can't be unlocked.\n\r", ch ); return; } if ( password != pexit->keypad ) { send_to_char( "&RACCESS DENIED.\n\r", ch ); return; } if ( !IS_SET(pexit->exit_info, EX_SECRET) || (pexit->keyword && nifty_is_name( arg, pexit->keyword )) ) { send_to_char( "&GACCESS GRANTED!\n\rLocking...\n\r", ch ); act( AT_ACTION, "$n types a code on the keypad.", ch, NULL, NULL, TO_ROOM ); set_bexit_flag( pexit, EX_LOCKED ); return; } } } ch_printf( ch, "You see no %s here.\n\r", arg ); return; } -------------------------------------------------------------------------- None.C -------------------------------------------------------------------------- Add the proper definitions for tables.c and mud.h Add the command into the mud. Make Clean Make -Done.