Can anyone point me in a good direction for giving rooms an array? The array would be possible positions within a grid, xpos, ypos, zpos.
Thanks,
Gadush
Thanks,
Gadush
This forum is a read-only archive of the Gammon Software forum (2000–2026). No new posts can be made. Search the archive.
Posted by Gadush on Mon 16 Feb 2004 02:55 PM — 13 posts, 37,990 views.
Top down view Elevation View
+----------+---------+ *|10
| | | | | |
| ---- * - |- * ---- | |
| | | | | |
|----------+---------| *|5
| | | | | |
|----- * - |- * ---- | |
| | | | | |
+--------------------+ ----------|
* = possible position
int coords[3];
#define XCOORD 0
#define YCOORD 1
#define ZCOORD 2
/* added to for rsize */
if ( !str_cmp( arg, "rsize" ) )
{
char xcoord[MAX_STRING_LENGTH];
char ycoord[MAX_STRING_LENGTH];
char zcoord[MAX_STRING_LENGTH];
argument = one_argument( argument, xcoord);
argument = one_argument( argument, ycoord);
argument = one_argument( argument, zcoord);
//Putting this here to verify that what your entering is valid
if ( !xcoord || xcoord[0] == '\0' || !ycoord || ycoord[0] == '\0' || !zcoord ||zcoord[0] == '\0')
{
send_to_char( "Set the room size: width, length, height.\n\r", ch );
send_to_char( "Usage: redit rsize <value> <value> <value>\n\r", ch );
return;
}
//Didn't realize it was location and not room
location->coords[XCOORD] = atoi(xcoord);
location->coords[YCOORD] = atoi(ycoord);
location->coords[ZCOORD] = atoi(zcoord);
ch_printf(ch, "Room size set to:\n\r\tWidth: %d\n\r\tLength %d\n\r\tHeight %d\n\r", location->x, location->y, location->z);
return;
}
ch_printf(ch, "X: %d Y%d Z%d\n\r", room->coords[XCOORD], room->coords[YCOORD], room->coords[ZCOORD]);if ( ch->room && ch->room->xcoord == ch->coords[XCOORD] )
send_to_char("Alas, you cannot go that way!", ch);
return;
ch->coords[XCOORD] = number_range(0, room->x);
ch->coords[YCOORD] = number_range(0, room->y);
ch->coords[ZCOORD] = number_range(0, room->z);
ch->coords[XCOORD] = number_range(0, room->x);
ch->coords[YCOORD] = number_range(0, room->y);
ch->coords[ZCOORD] = 0;
/*
* Check to see if a character can fall down, checks for looping -Thoric
*/
bool will_fall( CHAR_DATA *ch, int fall )
{
if ( IS_SET( ch->in_room->room_flags, ROOM_NOFLOOR )
&& CAN_GO(ch, DIR_DOWN)
&& (!IS_AFFECTED( ch, AFF_FLYING )
|| ( ch->mount && !IS_AFFECTED( ch->mount, AFF_FLYING ) ) ) )
{
if ( fall > 80 )
{
bug( "Falling (in a loop?) more than 80 rooms: vnum %d", ch->in_room->vnum );
char_from_room( ch );
char_to_room( ch, get_room_index( ROOM_VNUM_TEMPLE ) );
fall = 0;
return TRUE;
}
set_char_color( AT_FALLING, ch );
send_to_char( "You're falling down...\n\r", ch );
move_char( ch, get_exit(ch->in_room, DIR_DOWN), ++fall );
ch->coords[XCOORD] = number_range(0, room->x);
ch->coords[YCOORD] = number_range(0, room->y); /* random location in new room */
ch->coords[ZCOORD] = 0;
return TRUE;
}
return FALSE;
}
ch->coords[XCOORD] = number_range(0, get_exit(ch->in_room, DIR_DOWN)->to_room->x);
ch->coords[YCOORD] = number_range(0, get_exit(ch->in_room, DIR_DOWN)->to_room->y); /* random location in new room */
ch->coords[ZCOORD] = 0;/*
* Check to see if a character can fall down, checks for looping -Thoric
*/
bool will_fall( CHAR_DATA *ch, int fall )
{
ROOM_INDEX_DATA *room;
if ( IS_SET( ch->in_room->room_flags, ROOM_NOFLOOR )
&& CAN_GO(ch, DIR_DOWN)
&& (!IS_AFFECTED( ch, AFF_FLYING )
|| ( ch->mount && !IS_AFFECTED( ch->mount, AFF_FLYING ) ) ) )
{
if ( fall > 80 )
{
bug( "Falling (in a loop?) more than 80 rooms: vnum %d", ch->in_room->vnum );
char_from_room( ch );
char_to_room( ch, get_room_index( ROOM_VNUM_TEMPLE ) );
fall = 0;
return TRUE;
}
set_char_color( AT_FALLING, ch );
send_to_char( "You're falling down...\n\r", ch );
move_char( ch, get_exit(ch->in_room, DIR_DOWN), ++fall );
room = get_exit(ch->in_room, DIR_DOWN)->to_room;
ch->coords[XCOORD] = number_range(0, room->x);
ch->coords[YCOORD] = number_range(0, room->y); /* random location in new room */
ch->coords[ZCOORD] = 0;
return TRUE;
}
return FALSE;
}