[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  Compiling the server
. . -> [Subject]  Grid maker

Grid maker

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Gareth555   (14 posts)  [Biography] bio
Date Mon 23 Jun 2003 10:24 PM (UTC)
Message
Anyone got some code to make a big grid?
like 500 rooms?

I'd deeply appreciate any tips. I'm not a coder..
perhaps a link to a snippet or something?
[Go to top] top

Posted by Zhamel   USA  (67 posts)  [Biography] bio
Date Reply #1 on Mon 23 Jun 2003 11:35 PM (UTC)

Amended on Mon 23 Jun 2003 11:37 PM (UTC) by Zhamel

Message
This should be what you're looking for. Should have to define MAX_RGRID_ROOMS in mud.h. The help says it doesn't copy exits, what it does is create exits within the grid so each room is connected to another in the grid.

The simple help:
Quote:
This command allows 3 dimensional patterning of the room you're
currently standing in, using the next available vnums from your
assigned vnum list. (everything but exits are copied. Flags, sector, etc)

i.e. rgrid 10 10 would create 10 by 10 rooms exactly like the one you
are standing in. 10 10 10 would be 3-dimensional, as in, 1000 rooms in a
cube shape.


void do_rgrid( CHAR_DATA *ch, char *argument )
{
    char arg [MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    char arg3[MAX_INPUT_LENGTH];

    EXIT_DATA		*xit;
    char buf [MAX_STRING_LENGTH];
    ROOM_INDEX_DATA	*location, *ch_location, *tmp;
    AREA_DATA           *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->in_room;
    pArea = ch->pcdata->area;


    argument = one_argument( argument, arg );
    argument = one_argument( argument, arg2 );
    argument = one_argument( argument, arg3 );

    if ( !arg || arg[0] == '\0' )
      {
	send_to_char( "Create a block of rooms.\n\r", ch );
	send_to_char( "Usage: rgrid <x> <y> <z>\n\r", ch );
	return;
      }
    x = atoi(arg);
    y = atoi(arg2);
    z = atoi(arg3);

    if(x < 1 || y < 1) {

      send_to_char( "You must specify an x and y of at least 1.\r\n", ch);
      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);
    send_to_char( buf, ch );

    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);
      send_to_char( buf, ch );
      send_to_char( "Please try to create a smaller block of rooms.\r\n", ch);
      return;
    }

    room_count = 0;
    send_to_char( "Checking for available rooms...\r\n", ch);

    if(pArea->low_r_vnum + maxnum > pArea->hi_r_vnum) {

      send_to_char( "You don't even have that many rooms assigned to you.\r\n", ch);
      return;
    }


    for(vnum = pArea->low_r_vnum; vnum <= pArea->hi_r_vnum; vnum++) {

      if(get_room_index(vnum) == NULL)
	room_count++;

      if(room_count >= maxnum)
	break;
    }
      


    if(room_count < maxnum) {
      send_to_char( "There aren't enough free rooms in your assigned range!\r\n", ch);
      return;
    }

    send_to_char( "Enough free rooms were found, creating the rooms...\r\n", ch);

    room_count = 0;
    vnum = pArea->low_r_vnum;

    while(room_count < maxnum) {

      if(get_room_index(vnum) == NULL) {

	room_hold[room_count++] = vnum;

	location = make_room( vnum );
	if ( !location ) {
	  bug( "rgrid: make_room failed", 0 );
	  return;
	}

	location->area = ch->pcdata->area;
	
	location->name = ch_location->name;
	location->description = ch_location->description;
	location->sector_type = ch_location->sector_type;
	location->room_flags = ch_location->room_flags;

	/* 
	 * Below here you may add anything else you wish to be
	 * copied into the rgrided rooms.
	 */



      }
      vnum++;
    }

    send_to_char( "Rooms created, linking the exits...\r\n", ch);

    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 = get_room_index(vnum);
	  tmp = get_room_index(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 = get_room_index(vnum);
	  tmp = get_room_index(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 = get_room_index(vnum);
	  tmp = get_room_index(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 = get_room_index(vnum);
	  tmp = get_room_index(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 = get_room_index(vnum);
	  tmp = get_room_index(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 = get_room_index(vnum);
	  tmp = get_room_index(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;

}
[Go to top] top

Posted by Gareth555   (14 posts)  [Biography] bio
Date Reply #2 on Mon 23 Jun 2003 11:56 PM (UTC)
Message

when you say i have to define MAX_RGRID_ROOMS in mud.h
I am not a coder sadly.
does this mean this snippet get pasted in mud.h?
does it get its own .c file?
er, do i have do define void do_rgrid in mud h?

[Go to top] top

Posted by Zhamel   USA  (67 posts)  [Biography] bio
Date Reply #3 on Tue 24 Jun 2003 12:11 AM (UTC)
Message
Simplest way to add this:

1. Cut/paste the code into build.c.

2. Open mud.h add this #define MAX_RGRID_ROOMS ####
right above this

/*
* Structure types.
*/

3. Add the command to tables.c and mud.h

4. Make clean and make. Then you need to add the commands online via cedit, cedit rgrid create do_rgrid, then set the level and cedit save cmdtable.
[Go to top] top

Posted by Gareth555   (14 posts)  [Biography] bio
Date Reply #4 on Tue 24 Jun 2003 01:24 AM (UTC)
Message
great, got it, and i learned a great deal too.
thanks very much. seems to work fine. for
some reason it didnt pick up on my
sw se nw ne and just used n s e w
but this is a
great start! thanks a MILLION!
[Go to top] top

Posted by Gareth555   (14 posts)  [Biography] bio
Date Reply #5 on Tue 24 Jun 2003 01:36 AM (UTC)
Message
Heres an interesting problem...
it won't save my command to the cmdtable.
the only clue i have is that when
i go cedit rgrid

it displays the code as hex, like <0x51a924> instead
of go_rgrid

execution works fine.. but it wont save over boot.

any ideas?
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


15,605 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]