User:Paxed/HowTo AddNewRoomType

This page documents how to add a new special room type, such as a beehive.

before the SHOPBASE definition, and renumber the room definitions that come after it.
 * Edit include/mkroom.h and add the room number, like
 * 1) define MYROOM 14

Bitfield(has_myroom,1); in it.
 * Edit the levelflags struct in include/rm.h and add

case MYROOM: You("enter a strange room!"); break; and slightly later in the same function add something like case MYROOM: level.flags.has_myroom = 0; break;
 * Edit check_special_room in src/hack.c and add something like this in there in the proper place:

level.flags.has_myroom = 0; somewhere near where the other lines like it are.
 * Edit clear_level_structures in src/mklev.c adding

else if (u_depth > 11 && !rn2(6)) mkroom(MYROOM); in the block where other lines like that are. u_depth > 11 means that the dungeon level must be deeper than 11 levels from top of dungeon and rn2(6) must be zero before your level is created in the dungeon level. rn2(6) returns a random value between 0 to 5, inclusive.
 * Also in src/mklev.c, near the end of makelevel, add something like this:

case MYROOM:   mkzoo(MYROOM); break; near where there are lines like it.
 * Edit mkroom in src/mkroom.c, by adding a line like this:

case MYROOM: level.flags.has_myroom = 0; break; near the end of that function, where there are other lines like that. This is the part that requires most coding.
 * Also in src/mkroom.c, edit fill_zoo by adding cases for your special room, so that it will get stocked with monsters and whatever you want. Look how the other zoo-like rooms are done in fill_zoo. Also remember to add the

if (level.flags.has_myroom && !rn2(400)) { static const char * const myroom_msg[4] = { "first random sound.", "second random sound.", "third random sound.", "fourth, hallucinatory, random sound!", };	You_hear(myroom_msg[rn2(3)+hallu]); }
 * Edit dosounds in src/sounds.c and add the ambient sounds when a your room is on a level, for example:

case MYROOM: level.flags.has_myroom = TRUE; break;
 * Edit fill_room in src/sp_lev.c and add something like this:

{ "myroom",     MYROOM },
 * Edit util/lev_main.c and add your room to the room_types array for example adding a line like this in it: