User:Paxed/HowTo AddNewRoomType

From NetHackWiki
< User:Paxed
Revision as of 18:06, 20 March 2007 by Paxed (talk | contribs) (testing, import my rgrn post)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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;
  • 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 > 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.

  • Edit mkroom() in src/mkroom.c, 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() 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 dosounds() in src/sounds.c and add the ambient sounds when a your room is on a level, for example:
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 fill_room() in src/sp_lev.c and add something like this:
   case MYROOM:
       level.flags.has_myroom = TRUE;
       break;
  • 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 },