Rgrid Command Original author: Mark Mealman(Dracones) Port to SmaugWiz by Zanthoris Installation Instructions ------------------------- 1. In smaug.h look for: DECLARE_DO_FUN(do_revert); add this line after it: DECLARE_DO_FUN(do_rgrid); also in smaug.h look for: #define MAX_ITEM_IMPACT 30 and add: #define MAX_RGRID_ROOMS 4096 /* for rgrid - Drac */ 2. In skills.cpp look for: if (!str_cmp (name, "do_revert")) return do_revert; and after it add this line: if (!str_cmp( name, "do_rgrid")) return do_rgrid; also in skills.cpp look for: if (skill == do_revert) return "do_revert"; and add: if ( skill == do_rgrid ) return "do_rgrid"; 3. In build.cpp add this new function: /* rgrid command by Dracones */ /* Ported to SmaugWiz by Zanthoris on 11/08/2000 */ void do_rgrid( CCharacter *ch, char *argument ) { char arg [MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char arg3[MAX_INPUT_LENGTH]; CExitData *xit; char buf [MAX_STRING_LENGTH]; CRoomIndexData *location, *ch_location, *tmp; CAreaData *pArea; int vnum, maxnum, x, y, z; int room_count; int room_hold [MAX_RGRID_ROOMS]; set_char_color( AT_PLAIN, ch ); ch_location = ch->GetInRoom(); pArea = ch->GetArea(); argument = one_argument( argument, arg ); argument = one_argument( argument, arg2 ); argument = one_argument( argument, arg3 ); if ( !arg || arg[0] == '\0' ) { ch->SendText("Create a block of rooms.\n\r"); ch->SendText("Usage: rgrid <x> <y> <z>\n\r"); return; } x = atoi(arg); y = atoi(arg2); z = atoi(arg3); if(x < 1 || y < 1) { ch->SendText("You must specify an x and y of at least 1.\r\n"); return; } if(z < 1) z = 1; maxnum = x * y * z; sprintf(buf, "Attempting to create a block of %d rooms, %d x %d x %d.\r\n", maxnum, x, y, z); ch->SendText(buf); if(maxnum > MAX_RGRID_ROOMS) { sprintf(buf, "The maximum number of rooms this mud can create at once is %d.\r\n", MAX_RGRID_ROOMS); ch->SendText(buf); ch->SendText("Please try to create a smaller block of rooms.\r\n"); return; } room_count = 0; ch->SendText( "Checking for available rooms...\r\n"); if(pArea->low_r_vnum + maxnum > pArea->hi_r_vnum) { ch->SendText( "You don't even have that many rooms assigned to you.\r\n"); return; } for(vnum = pArea->low_r_vnum; vnum <= pArea->hi_r_vnum; vnum++) { if(RoomTable.GetRoom(vnum) == NULL) room_count++; if(room_count >= maxnum) break; } if(room_count < maxnum) { ch->SendText( "There aren't enough free rooms in your assigned range!\r\n"); return; } ch->SendText( "Enough free rooms were found, creating the rooms...\r\n"); room_count = 0; vnum = pArea->low_r_vnum; while(room_count < maxnum) { if(RoomTable.GetRoom(vnum) == NULL) { room_hold[room_count++] = vnum; location = make_room( vnum ); if ( !location ) { bug( "rgrid: make_room failed", 0 ); return; } location->SetArea(pArea); location->SetName(ch_location->GetName()); location->SetDescription(ch_location->GetDescription()); location->sector_type = ch_location->sector_type; location->SetRoomFlags(ch_location->GetRoomFlags()); } vnum++; } ch->SendText( "Rooms created, linking the exits...\r\n"); for(room_count = 1; room_count <= maxnum; room_count++) { vnum = room_hold[room_count - 1]; // Check to see if we can make N exits if(room_count % x) { location = RoomTable.GetRoom(vnum); tmp = RoomTable.GetRoom(room_hold[room_count]); xit = make_exit( location, tmp, 0 ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; // xit->exit_info = 0; } // Check to see if we can make S exits if((room_count - 1) % x) { location = RoomTable.GetRoom(vnum); tmp = RoomTable.GetRoom(room_hold[room_count - 2]); xit = make_exit( location, tmp, 2 ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; // xit->exit_info = 0; } // Check to see if we can make E exits if( (room_count - 1) % (x * y) < x * y - x ) { location = RoomTable.GetRoom(vnum); tmp = RoomTable.GetRoom(room_hold[room_count + x - 1]); xit = make_exit( location, tmp, 1 ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; // xit->exit_info = 0; } // Check to see if we can make W exits if( ( room_count - 1) % (x * y) >= x ) { location = RoomTable.GetRoom(vnum); tmp = RoomTable.GetRoom(room_hold[room_count - x - 1]); xit = make_exit( location, tmp, 3 ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; // xit->exit_info = 0; } // Check to see if we can make D exits if( room_count > x * y ) { location = RoomTable.GetRoom(vnum); tmp = RoomTable.GetRoom(room_hold[room_count - x * y - 1]); xit = make_exit( location, tmp, 5 ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; // xit->exit_info = 0; } // Check to see if we can make U exits if( room_count <= maxnum - (x * y) ) { location = RoomTable.GetRoom(vnum); tmp = RoomTable.GetRoom(room_hold[room_count + x * y - 1]); xit = make_exit( location, tmp, 4 ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; // xit->exit_info = 0; } } return; } 4. Make clean, then recompile. 5. Create an rgrid command, setting it to the desired level or just put the following in your commands.dat file: #COMMAND Name rgrid~ Code do_rgrid Position 100 Level 60 Log 3 End command usage: rgrid <x> <y> <z> rgrid allows a builder to quickly create large blocks of rooms. Simply create a single room with the desc, flags, sector_type and name that you want for all your new rooms and issue the rgrid command. The new block of rooms will not be connected to any current room in your zone, however all created rooms have the proper north, south, east and west exits to each other. ex/ rgrid 10 10 10 - will create 1000 rooms WARNING: This command has _no_ checks in place for security. Also this command uses the character's assigned edit room range(pArea) when creating new rooms, so you should only use this command in your build-zone. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= This snippet was written for and tested on SmaugWiz version 2.01, I cannot guarantee that it will work in previous versions without some modification (though I expect it will). If you have problems with this snippet let me know! -=Zanthoris=- zanthoris@hotmail.com telnet:\\zanthoris.dhs.org:4000 http:\\zanthoris.home.dhs.org