# User:Paxed/HowTo AddNewRoomType
This page documents how to add a new special room type, such as a beehive.

Edit include/mkroom.h[1] and add the room number, like
#define MYROOM 14

before the SHOPBASE definition, and renumber the room definitions that come after it.

Edit the levelflags struct in include/rm.h[2] and add
Bitfield(has_myroom,1);

in it.

Edit check_special_room() in src/hack.c[3] and add something like this in there in the proper place:
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;

The message You enter a strange room! is shown to player when he enters the room, and clearing the has_myroom flag ensures the message is only shown once per room.

Edit clear_level_structures() in src/mklev.c[4] adding
level.flags.has_myroom = 0;

somewhere near where the other lines like it are.

Also in src/mklev.c, near the end of makelevel()[5], add something like this:
else if (u_depth &gt; 11 &amp;&amp; !rn2(6)) mkroom(MYROOM);

in the block where other lines like that are. u_depth &gt; 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.

Edit mkroom() in src/mkroom.c[6], by adding a line like this:
case MYROOM:    mkzoo(MYROOM); break;

near where there are lines like it.

Also in src/mkroom.c, edit fill_zoo()[7] 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
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.

Edit fill_room() in src/sp_lev.c[8] and add something like this:
   case MYROOM:
       level.flags.has_myroom = TRUE;
       break;

Edit dosounds() in src/sounds.c[9] and add the ambient sounds when a your room is on a level, for example:
if (level.flags.has_myroom &amp;&amp; !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]);
}

This will show one of the messages at random for the player when there is a room of the new type on the level.
The chance of player hearing one of the messages for your room is 1 in 400 each turn.

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

This allows the room to be used in the special levels.

↑ mkroom.h#line50

↑ rm.h#line444

↑ hack.c#line1717

↑ mklev.c#line537

↑ mklev.c#line727

↑ mkroom.c#line46

↑ mkroom.c#line226

↑ sp_lev.c#line1457

↑ sounds.c#line35