-
- /* Place a full floor for room "a" */
- for (y = y1a - 1; y <= y2a + 1; y++)
- {
- for (x = x1a - 1; x <= x2a + 1; x++)
- {
- c_ptr = &cave[y][x];
- place_floor_grid(c_ptr);
- c_ptr->info |= (CAVE_ROOM);
- if (light) c_ptr->info |= (CAVE_GLOW);
- }
- }
-
- /* Place a full floor for room "b" */
- for (y = y1b - 1; y <= y2b + 1; y++)
- {
- for (x = x1b - 1; x <= x2b + 1; x++)
- {
- c_ptr = &cave[y][x];
- place_floor_grid(c_ptr);
- c_ptr->info |= (CAVE_ROOM);
- if (light) c_ptr->info |= (CAVE_GLOW);
- }
- }
-
-
- /* Place the walls around room "a" */
- for (y = y1a - 1; y <= y2a + 1; y++)
- {
- c_ptr = &cave[y][x1a - 1];
- place_outer_grid(c_ptr);
- c_ptr = &cave[y][x2a + 1];
- place_outer_grid(c_ptr);
- }
- for (x = x1a - 1; x <= x2a + 1; x++)
- {
- c_ptr = &cave[y1a - 1][x];
- place_outer_grid(c_ptr);
- c_ptr = &cave[y2a + 1][x];
- place_outer_grid(c_ptr);
- }
-
- /* Place the walls around room "b" */
- for (y = y1b - 1; y <= y2b + 1; y++)
- {
- c_ptr = &cave[y][x1b - 1];
- place_outer_grid(c_ptr);
- c_ptr = &cave[y][x2b + 1];
- place_outer_grid(c_ptr);
- }
- for (x = x1b - 1; x <= x2b + 1; x++)
- {
- c_ptr = &cave[y1b - 1][x];
- place_outer_grid(c_ptr);
- c_ptr = &cave[y2b + 1][x];
- place_outer_grid(c_ptr);
- }
-
-
-
- /* Replace the floor for room "a" */
- for (y = y1a; y <= y2a; y++)
- {
- for (x = x1a; x <= x2a; x++)
- {
- c_ptr = &cave[y][x];
- place_floor_grid(c_ptr);
- }
- }
-
- /* Replace the floor for room "b" */
- for (y = y1b; y <= y2b; y++)
- {
- for (x = x1b; x <= x2b; x++)
- {
- c_ptr = &cave[y][x];
- place_floor_grid(c_ptr);
- }
- }
-
- return TRUE;
-}
-
-
-
-/*
- * Type 3 -- Cross shaped rooms
- *
- * Builds a room at a row, column coordinate
- *
- * Room "a" runs north/south, and Room "b" runs east/east
- * So the "central pillar" runs from x1a, y1b to x2a, y2b.
- *
- * Note that currently, the "center" is always 3x3, but I think that
- * the code below will work (with "bounds checking") for 5x5, or even
- * for unsymetric values like 4x3 or 5x3 or 3x4 or 3x5, or even larger.
- */
-static bool build_type3(void)
-{
- int y, x, dy, dx, wy, wx;
- int y1a, x1a, y2a, x2a;
- int y1b, x1b, y2b, x2b;
- int yval, xval;
- bool light;
- cave_type *c_ptr;
-
-
- /* Find and reserve some space in the dungeon. Get center of room. */
- if (!find_space(&yval, &xval, 11, 25)) return FALSE;
-
-
- /* Choose lite or dark */
- light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
-
- /* For now, always 3x3 */
- wx = wy = 1;
-
- /* Pick max vertical size (at most 4) */
- dy = rand_range(3, 4);
-
- /* Pick max horizontal size (at most 15) */
- dx = rand_range(3, 11);
-
-
- /* Determine extents of the north/south room */
- y1a = yval - dy;
- y2a = yval + dy;
- x1a = xval - wx;
- x2a = xval + wx;
-
- /* Determine extents of the east/west room */
- y1b = yval - wy;
- y2b = yval + wy;
- x1b = xval - dx;
- x2b = xval + dx;
-
-
- /* Place a full floor for room "a" */
- for (y = y1a - 1; y <= y2a + 1; y++)
- {
- for (x = x1a - 1; x <= x2a + 1; x++)
- {
- c_ptr = &cave[y][x];
- place_floor_grid(c_ptr);
- c_ptr->info |= (CAVE_ROOM);
- if (light) c_ptr->info |= (CAVE_GLOW);
- }
- }
-
- /* Place a full floor for room "b" */
- for (y = y1b - 1; y <= y2b + 1; y++)
- {
- for (x = x1b - 1; x <= x2b + 1; x++)
- {
- c_ptr = &cave[y][x];
- place_floor_grid(c_ptr);
- c_ptr->info |= (CAVE_ROOM);
- if (light) c_ptr->info |= (CAVE_GLOW);
- }
- }
-
-
- /* Place the walls around room "a" */
- for (y = y1a - 1; y <= y2a + 1; y++)
- {
- c_ptr = &cave[y][x1a - 1];
- place_outer_grid(c_ptr);
- c_ptr = &cave[y][x2a + 1];
- place_outer_grid(c_ptr);
- }
- for (x = x1a - 1; x <= x2a + 1; x++)
- {
- c_ptr = &cave[y1a - 1][x];
- place_outer_grid(c_ptr);
- c_ptr = &cave[y2a + 1][x];
- place_outer_grid(c_ptr);
- }
-
- /* Place the walls around room "b" */
- for (y = y1b - 1; y <= y2b + 1; y++)
- {
- c_ptr = &cave[y][x1b - 1];
- place_outer_grid(c_ptr);
- c_ptr = &cave[y][x2b + 1];
- place_outer_grid(c_ptr);
- }
- for (x = x1b - 1; x <= x2b + 1; x++)
- {
- c_ptr = &cave[y1b - 1][x];
- place_outer_grid(c_ptr);
- c_ptr = &cave[y2b + 1][x];
- place_outer_grid(c_ptr);
- }
-
-
- /* Replace the floor for room "a" */
- for (y = y1a; y <= y2a; y++)
- {
- for (x = x1a; x <= x2a; x++)
- {
- c_ptr = &cave[y][x];
- place_floor_grid(c_ptr);
- }
- }
-
- /* Replace the floor for room "b" */
- for (y = y1b; y <= y2b; y++)
- {
- for (x = x1b; x <= x2b; x++)
- {
- c_ptr = &cave[y][x];
- place_floor_grid(c_ptr);
- }
- }
-
-
-
- /* Special features (3/4) */
- switch (randint0(4))
- {
- /* Large solid middle pillar */
- case 1:
- {
- for (y = y1b; y <= y2b; y++)
- {
- for (x = x1a; x <= x2a; x++)
- {
- c_ptr = &cave[y][x];
- place_inner_grid(c_ptr);
- }
- }
- break;
- }
-
- /* Inner treasure vault */
- case 2:
- {
- /* Build the vault */
- for (y = y1b; y <= y2b; y++)
- {
- c_ptr = &cave[y][x1a];
- place_inner_grid(c_ptr);
- c_ptr = &cave[y][x2a];
- place_inner_grid(c_ptr);
- }
- for (x = x1a; x <= x2a; x++)
- {
- c_ptr = &cave[y1b][x];
- place_inner_grid(c_ptr);
- c_ptr = &cave[y2b][x];
- place_inner_grid(c_ptr);
- }
-
- /* Place a secret door on the inner room */
- switch (randint0(4))
- {
- case 0: place_secret_door(y1b, xval); break;
- case 1: place_secret_door(y2b, xval); break;
- case 2: place_secret_door(yval, x1a); break;
- case 3: place_secret_door(yval, x2a); break;
- }
-
- /* Place a treasure in the vault */
- place_object(yval, xval, 0L);
-
- /* Let's guard the treasure well */
- vault_monsters(yval, xval, randint0(2) + 3);
-
- /* Traps naturally */
- vault_traps(yval, xval, 4, 4, randint0(3) + 2);
-
- break;
- }
-
- /* Something else */
- case 3:
- {
- /* Occasionally pinch the center shut */
- if (one_in_(3))
- {
- /* Pinch the east/west sides */
- for (y = y1b; y <= y2b; y++)
- {
- if (y == yval) continue;
- c_ptr = &cave[y][x1a - 1];
- place_inner_grid(c_ptr);
- c_ptr = &cave[y][x2a + 1];
- place_inner_grid(c_ptr);
- }
-
- /* Pinch the north/south sides */
- for (x = x1a; x <= x2a; x++)
- {
- if (x == xval) continue;
- c_ptr = &cave[y1b - 1][x];
- place_inner_grid(c_ptr);
- c_ptr = &cave[y2b + 1][x];
- place_inner_grid(c_ptr);
- }
-
- /* Sometimes shut using secret doors */
- if (one_in_(3))
- {
- place_secret_door(yval, x1a - 1);
- place_secret_door(yval, x2a + 1);
- place_secret_door(y1b - 1, xval);
- place_secret_door(y2b + 1, xval);
- }
- }
-
- /* Occasionally put a "plus" in the center */
- else if (one_in_(3))
- {
- c_ptr = &cave[yval][xval];
- place_inner_grid(c_ptr);
- c_ptr = &cave[y1b][xval];
- place_inner_grid(c_ptr);
- c_ptr = &cave[y2b][xval];
- place_inner_grid(c_ptr);
- c_ptr = &cave[yval][x1a];
- place_inner_grid(c_ptr);
- c_ptr = &cave[yval][x2a];
- place_inner_grid(c_ptr);
- }
-
- /* Occasionally put a pillar in the center */
- else if (one_in_(3))
- {
- c_ptr = &cave[yval][xval];
- place_inner_grid(c_ptr);
- }
-
- break;
- }
- }
-
- return TRUE;
-}
-
-
-/*
- * Type 4 -- Large room with inner features
- *
- * Possible sub-types:
- * 1 - Just an inner room with one door
- * 2 - An inner room within an inner room
- * 3 - An inner room with pillar(s)
- * 4 - Inner room has a maze
- * 5 - A set of four inner rooms
- */
-static bool build_type4(void)
-{
- int y, x, y1, x1;
- int y2, x2, tmp, yval, xval;
- bool light;
- cave_type *c_ptr;
-
-
- /* Find and reserve some space in the dungeon. Get center of room. */
- if (!find_space(&yval, &xval, 11, 25)) return FALSE;
-
- /* Choose lite or dark */
- light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
-
- /* Large room */
- y1 = yval - 4;
- y2 = yval + 4;
- x1 = xval - 11;
- x2 = xval + 11;
-
- /* Place a full floor under the room */
- for (y = y1 - 1; y <= y2 + 1; y++)
- {
- for (x = x1 - 1; x <= x2 + 1; x++)
- {
- c_ptr = &cave[y][x];
- place_floor_grid(c_ptr);
- c_ptr->info |= (CAVE_ROOM);
- if (light) c_ptr->info |= (CAVE_GLOW);
- }
- }
-
- /* Outer Walls */
- for (y = y1 - 1; y <= y2 + 1; y++)
- {
- c_ptr = &cave[y][x1 - 1];
- place_outer_grid(c_ptr);
- c_ptr = &cave[y][x2 + 1];
- place_outer_grid(c_ptr);
- }
- for (x = x1 - 1; x <= x2 + 1; x++)
- {
- c_ptr = &cave[y1 - 1][x];
- place_outer_grid(c_ptr);
- c_ptr = &cave[y2 + 1][x];
- place_outer_grid(c_ptr);
- }
-
-
- /* The inner room */
- y1 = y1 + 2;
- y2 = y2 - 2;
- x1 = x1 + 2;
- x2 = x2 - 2;
-
- /* The inner walls */
- for (y = y1 - 1; y <= y2 + 1; y++)
- {
- c_ptr = &cave[y][x1 - 1];
- place_inner_grid(c_ptr);
- c_ptr = &cave[y][x2 + 1];
- place_inner_grid(c_ptr);
- }
- for (x = x1 - 1; x <= x2 + 1; x++)
- {
- c_ptr = &cave[y1 - 1][x];
- place_inner_grid(c_ptr);
- c_ptr = &cave[y2 + 1][x];
- place_inner_grid(c_ptr);
- }
-
-
- /* Inner room variations */
- switch (randint1(5))
- {
- /* Just an inner room with a monster */
- case 1:
- {
- /* Place a secret door */
- switch (randint1(4))
- {
- case 1: place_secret_door(y1 - 1, xval); break;
- case 2: place_secret_door(y2 + 1, xval); break;
- case 3: place_secret_door(yval, x1 - 1); break;
- case 4: place_secret_door(yval, x2 + 1); break;
- }
-
- /* Place a monster in the room */
- vault_monsters(yval, xval, 1);
-
- break;
- }
-
- /* Treasure Vault (with a door) */
- case 2:
- {
- /* Place a secret door */
- switch (randint1(4))
- {
- case 1: place_secret_door(y1 - 1, xval); break;
- case 2: place_secret_door(y2 + 1, xval); break;
- case 3: place_secret_door(yval, x1 - 1); break;
- case 4: place_secret_door(yval, x2 + 1); break;
- }
-
- /* Place another inner room */
- for (y = yval - 1; y <= yval + 1; y++)
- {
- for (x = xval - 1; x <= xval + 1; x++)
- {
- if ((x == xval) && (y == yval)) continue;
- c_ptr = &cave[y][x];
- place_inner_grid(c_ptr);
- }
- }
-
- /* Place a locked door on the inner room */
- switch (randint1(4))
- {
- case 1: place_locked_door(yval - 1, xval); break;
- case 2: place_locked_door(yval + 1, xval); break;
- case 3: place_locked_door(yval, xval - 1); break;
- case 4: place_locked_door(yval, xval + 1); break;
- }
-
- /* Monsters to guard the "treasure" */
- vault_monsters(yval, xval, randint1(3) + 2);
-
- /* Object (80%) */
- if (randint0(100) < 80)
- {
- place_object(yval, xval, 0L);
- }
-
- /* Stairs (20%) */
- else
- {
- place_random_stairs(yval, xval);
- }
-
- /* Traps to protect the treasure */
- vault_traps(yval, xval, 4, 10, 2 + randint1(3));
-
- break;
- }
-
- /* Inner pillar(s). */
- case 3:
- {
- /* Place a secret door */
- switch (randint1(4))
- {
- case 1: place_secret_door(y1 - 1, xval); break;
- case 2: place_secret_door(y2 + 1, xval); break;
- case 3: place_secret_door(yval, x1 - 1); break;
- case 4: place_secret_door(yval, x2 + 1); break;
- }
-
- /* Large Inner Pillar */
- for (y = yval - 1; y <= yval + 1; y++)
- {
- for (x = xval - 1; x <= xval + 1; x++)
- {
- c_ptr = &cave[y][x];
- place_inner_grid(c_ptr);
- }
- }
-
- /* Occasionally, two more Large Inner Pillars */
- if (one_in_(2))
- {
- tmp = randint1(2);
- for (y = yval - 1; y <= yval + 1; y++)
- {
- for (x = xval - 5 - tmp; x <= xval - 3 - tmp; x++)
- {
- c_ptr = &cave[y][x];
- place_inner_grid(c_ptr);
- }
- for (x = xval + 3 + tmp; x <= xval + 5 + tmp; x++)
- {
- c_ptr = &cave[y][x];
- place_inner_grid(c_ptr);
- }
- }
- }
-
- /* Occasionally, some Inner rooms */
- if (one_in_(3))
- {
- /* Long horizontal walls */
- for (x = xval - 5; x <= xval + 5; x++)
- {
- c_ptr = &cave[yval - 1][x];
- place_inner_grid(c_ptr);
- c_ptr = &cave[yval + 1][x];
- place_inner_grid(c_ptr);
- }
-
- /* Close off the left/right edges */
- c_ptr = &cave[yval][xval - 5];
- place_inner_grid(c_ptr);
- c_ptr = &cave[yval][xval + 5];
- place_inner_grid(c_ptr);
-
- /* Secret doors (random top/bottom) */
- place_secret_door(yval - 3 + (randint1(2) * 2), xval - 3);
- place_secret_door(yval - 3 + (randint1(2) * 2), xval + 3);
-
- /* Monsters */
- vault_monsters(yval, xval - 2, randint1(2));
- vault_monsters(yval, xval + 2, randint1(2));
-
- /* Objects */
- if (one_in_(3)) place_object(yval, xval - 2, 0L);
- if (one_in_(3)) place_object(yval, xval + 2, 0L);
- }
-
- break;
- }
-
- /* Maze inside. */
- case 4:
- {
- /* Place a secret door */
- switch (randint1(4))
- {
- case 1: place_secret_door(y1 - 1, xval); break;
- case 2: place_secret_door(y2 + 1, xval); break;
- case 3: place_secret_door(yval, x1 - 1); break;
- case 4: place_secret_door(yval, x2 + 1); break;
- }
-
- /* Maze (really a checkerboard) */
- for (y = y1; y <= y2; y++)
- {
- for (x = x1; x <= x2; x++)
- {
- if (0x1 & (x + y))
- {
- c_ptr = &cave[y][x];
- place_inner_grid(c_ptr);
- }
- }
- }
-
- /* Monsters just love mazes. */
- vault_monsters(yval, xval - 5, randint1(3));
- vault_monsters(yval, xval + 5, randint1(3));
-
- /* Traps make them entertaining. */
- vault_traps(yval, xval - 3, 2, 8, randint1(3));
- vault_traps(yval, xval + 3, 2, 8, randint1(3));
-
- /* Mazes should have some treasure too. */
- vault_objects(yval, xval, 3);
-
- break;
- }
-
- /* Four small rooms. */
- case 5:
- {
- /* Inner "cross" */
- for (y = y1; y <= y2; y++)
- {
- c_ptr = &cave[y][xval];
- place_inner_grid(c_ptr);
- }
- for (x = x1; x <= x2; x++)
- {
- c_ptr = &cave[yval][x];
- place_inner_grid(c_ptr);
- }
-
- /* Doors into the rooms */
- if (randint0(100) < 50)
- {
- int i = randint1(10);
- place_secret_door(y1 - 1, xval - i);
- place_secret_door(y1 - 1, xval + i);
- place_secret_door(y2 + 1, xval - i);
- place_secret_door(y2 + 1, xval + i);
- }
- else
- {
- int i = randint1(3);
- place_secret_door(yval + i, x1 - 1);
- place_secret_door(yval - i, x1 - 1);
- place_secret_door(yval + i, x2 + 1);
- place_secret_door(yval - i, x2 + 1);
- }
-
- /* Treasure, centered at the center of the cross */
- vault_objects(yval, xval, 2 + randint1(2));
-
- /* Gotta have some monsters. */
- vault_monsters(yval + 1, xval - 4, randint1(4));
- vault_monsters(yval + 1, xval + 4, randint1(4));
- vault_monsters(yval - 1, xval - 4, randint1(4));
- vault_monsters(yval - 1, xval + 4, randint1(4));
-
- break;
- }
- }
-
- return TRUE;
-}
-
-
-/*
- * The following functions are used to determine if the given monster
- * is appropriate for inclusion in a monster nest or monster pit or
- * the given type.
- *
- * None of the pits/nests are allowed to include "unique" monsters.
- */
-
-
-/*
- * Monster validation macro
- *
- * Line 1 -- forbid town monsters
- * Line 2 -- forbid uniques
- * Line 3 -- forbid aquatic monsters
- */
-#define vault_monster_okay(I) \
- (mon_hook_dungeon(I) && \
- !(r_info[I].flags1 & RF1_UNIQUE) && \
- !(r_info[I].flags7 & RF7_UNIQUE2) && \
- !(r_info[I].flagsr & RFR_RES_ALL) && \
- !(r_info[I].flags7 & RF7_AQUATIC))
-
-
-/* Race index for "monster pit (clone)" */
-static int vault_aux_race;
-
-/* Race index for "monster pit (symbol clone)" */
-static char vault_aux_char;
-
-/* Breath mask for "monster pit (dragon)" */
-static u32b vault_aux_dragon_mask4;
-
-
-/*
- * Helper monster selection function
- */
-static bool vault_aux_simple(int r_idx)
-{
- /* Okay */
- return (vault_monster_okay(r_idx));
-}
-
-
-/*
- * Helper function for "monster nest (jelly)"
- */
-static bool vault_aux_jelly(int r_idx)
-{
- monster_race *r_ptr = &r_info[r_idx];
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
-
- /* Also decline evil jellies (like death molds and shoggoths) */
- if (r_ptr->flags3 & (RF3_EVIL)) return (FALSE);
-
- /* Require icky thing, jelly, mold, or mushroom */
- if (!strchr("ijm,", r_ptr->d_char)) return (FALSE);
-
- /* Okay */
- return (TRUE);
-}
-
-
-/*
- * Helper function for "monster nest (animal)"
- */
-static bool vault_aux_animal(int r_idx)
-{
- monster_race *r_ptr = &r_info[r_idx];
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- /* Require "animal" flag */
- if (!(r_ptr->flags3 & (RF3_ANIMAL))) return (FALSE);
-
- /* Okay */
- return (TRUE);
-}
-
-
-/*
- * Helper function for "monster nest (undead)"
- */
-static bool vault_aux_undead(int r_idx)
-{
- monster_race *r_ptr = &r_info[r_idx];
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- /* Require Undead */
- if (!(r_ptr->flags3 & (RF3_UNDEAD))) return (FALSE);
-
- /* Okay */
- return (TRUE);
-}
-
-
-/*
- * Helper function for "monster nest (chapel)"
- */
-static bool vault_aux_chapel_g(int r_idx)
-{
- static int chapel_list[] = {
- MON_NOV_PRIEST, MON_NOV_PALADIN, MON_NOV_PRIEST_G, MON_NOV_PALADIN_G,
- MON_PRIEST, MON_JADE_MONK, MON_IVORY_MONK, MON_ULTRA_PALADIN,
- MON_EBONY_MONK, MON_W_KNIGHT, MON_KNI_TEMPLAR, MON_PALADIN,
- MON_TOPAZ_MONK, 0};
-
- int i;
-
- monster_race *r_ptr = &r_info[r_idx];
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- if (r_ptr->flags3 & (RF3_EVIL)) return (FALSE);
- if ((r_idx == MON_A_GOLD) || (r_idx == MON_A_SILVER)) return (FALSE);
-
- /* Require "priest" or Angel */
-
- if (r_ptr->d_char == 'A') return TRUE;
-
- for (i = 0; chapel_list[i]; i++)
- if (r_idx == chapel_list[i]) return TRUE;
-
- return FALSE;
-}
-
-
-/*
- * Helper function for "monster nest (kennel)"
- */
-static bool vault_aux_kennel(int r_idx)
-{
- monster_race *r_ptr = &r_info[r_idx];
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- /* Require a Zephyr Hound or a dog */
- if (!strchr("CZ", r_ptr->d_char)) return (FALSE);
-
- /* Okay */
- return (TRUE);
-}
-
-
-/*
- * Helper function for "monster nest (mimic)"
- */
-static bool vault_aux_mimic(int r_idx)
-{
- monster_race *r_ptr = &r_info[r_idx];
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- /* Require mimic */
- if (!strchr("!|$?=", r_ptr->d_char)) return (FALSE);
-
- /* Okay */
- return (TRUE);
-}
-
-/*
- * Helper function for "monster nest (clone)"
- */
-static bool vault_aux_clone(int r_idx)
-{
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- return (r_idx == vault_aux_race);
-}
-
-
-/*
- * Helper function for "monster nest (symbol clone)"
- */
-static bool vault_aux_symbol_e(int r_idx)
-{
- monster_race *r_ptr = &r_info[r_idx];
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
-
- if (r_ptr->flags3 & (RF3_GOOD)) return (FALSE);
-
- /* Decline incorrect symbol */
- if (r_ptr->d_char != vault_aux_char) return (FALSE);
-
- /* Okay */
- return (TRUE);
-}
-
-
-/*
- * Helper function for "monster nest (symbol clone)"
- */
-static bool vault_aux_symbol_g(int r_idx)
-{
- monster_race *r_ptr = &r_info[r_idx];
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
-
- if (r_ptr->flags3 & (RF3_EVIL)) return (FALSE);
-
- /* Decline incorrect symbol */
- if (r_ptr->d_char != vault_aux_char) return (FALSE);
-
- /* Okay */
- return (TRUE);
-}
-
-
-/*
- * Helper function for "monster pit (orc)"
- */
-static bool vault_aux_orc(int r_idx)
-{
- monster_race *r_ptr = &r_info[r_idx];
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- /* Require orc */
- if (!(r_ptr->flags3 & RF3_ORC)) return (FALSE);
-
- /* Decline undead */
- if (r_ptr->flags3 & RF3_UNDEAD) return (FALSE);
-
- /* Okay */
- return (TRUE);
-}
-
-
-/*
- * Helper function for "monster pit (troll)"
- */
-static bool vault_aux_troll(int r_idx)
-{
- monster_race *r_ptr = &r_info[r_idx];
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- /* Require troll */
- if (!(r_ptr->flags3 & RF3_TROLL)) return (FALSE);
-
- /* Decline undead */
- if (r_ptr->flags3 & RF3_UNDEAD) return (FALSE);
-
- /* Okay */
- return (TRUE);
-}
-
-
-/*
- * Helper function for "monster pit (giant)"
- */
-static bool vault_aux_giant(int r_idx)
-{
- monster_race *r_ptr = &r_info[r_idx];
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- /* Require giant */
- if (!(r_ptr->flags3 & RF3_GIANT)) return (FALSE);
-
- if (r_ptr->flags3 & RF3_GOOD) return (FALSE);
-
- /* Decline undead */
- if (r_ptr->flags3 & RF3_UNDEAD) return (FALSE);
-
- /* Okay */
- return (TRUE);
-}
-
-
-/*
- * Helper function for "monster pit (dragon)"
- */
-static bool vault_aux_dragon(int r_idx)
-{
- monster_race *r_ptr = &r_info[r_idx];
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- /* Require dragon */
- if (!(r_ptr->flags3 & RF3_DRAGON)) return (FALSE);
-
- /* Hack -- Require correct "breath attack" */
- if (r_ptr->flags4 != vault_aux_dragon_mask4) return (FALSE);
-
- /* Decline undead */
- if (r_ptr->flags3 & RF3_UNDEAD) return (FALSE);
-
- /* Okay */
- return (TRUE);
-}
-
-
-/*
- * Helper function for "monster pit (demon)"
- */
-static bool vault_aux_demon(int r_idx)
-{
- monster_race *r_ptr = &r_info[r_idx];
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
-
- /* Require demon */
- if (!(r_ptr->flags3 & RF3_DEMON)) return (FALSE);
-
- /* Okay */
- return (TRUE);
-}
-
-
-/*
- * Helper function for "monster pit (lovecraftian)"
- */
-static bool vault_aux_cthulhu(int r_idx)
-{
- monster_race *r_ptr = &r_info[r_idx];
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return (FALSE);
-
- if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
-
- /* Require eldritch horror */
- if (!(r_ptr->flags2 & (RF2_ELDRITCH_HORROR))) return (FALSE);
-
- /* Okay */
- return (TRUE);
-}
-
-
-/*
- * Helper function for "monster pit (clone)"
- */
-static void vault_prep_clone(void)
-{
- /* Apply the monster restriction */
- get_mon_num_prep(vault_aux_simple, NULL);
-
- /* Pick a race to clone */
- vault_aux_race = get_mon_num(dun_level + 10);
-
- /* Remove the monster restriction */
- get_mon_num_prep(NULL, NULL);
-}
-
-
-/*
- * Helper function for "monster pit (symbol clone)"
- */
-static void vault_prep_symbol(void)
-{
- int r_idx;
-
- /* Apply the monster restriction */
- get_mon_num_prep(vault_aux_simple, NULL);
-
- /* Pick a race to clone */
- r_idx = get_mon_num(dun_level + 10);
-
- /* Remove the monster restriction */
- get_mon_num_prep(NULL, NULL);
-
- /* Extract the symbol */
- vault_aux_char = r_info[r_idx].d_char;
-}
-
-
-/*
- * Helper function for "monster pit (dragon)"
- */
-static void vault_prep_dragon(void)
-{
- /* Pick dragon type */
- switch (randint0(6))
- {
- /* Black */
- case 0:
- {
- /* Restrict dragon breath type */
- vault_aux_dragon_mask4 = RF4_BR_ACID;
-
- /* Done */
- break;
- }
-
- /* Blue */
- case 1:
- {
- /* Restrict dragon breath type */
- vault_aux_dragon_mask4 = RF4_BR_ELEC;
-
- /* Done */
- break;
- }
-
- /* Red */
- case 2:
- {
- /* Restrict dragon breath type */
- vault_aux_dragon_mask4 = RF4_BR_FIRE;
-
- /* Done */
- break;
- }
-
- /* White */
- case 3:
- {
- /* Restrict dragon breath type */
- vault_aux_dragon_mask4 = RF4_BR_COLD;
-
- /* Done */
- break;
- }
-
- /* Green */
- case 4:
- {
- /* Restrict dragon breath type */
- vault_aux_dragon_mask4 = RF4_BR_POIS;
-
- /* Done */
- break;
- }
-
- /* Multi-hued */
- default:
- {
- /* Restrict dragon breath type */
- vault_aux_dragon_mask4 = (RF4_BR_ACID | RF4_BR_ELEC |
- RF4_BR_FIRE | RF4_BR_COLD |
- RF4_BR_POIS);
-
- /* Done */
- break;
- }
- }
-}
-
-
-/*
- * Helper function for "monster pit (dark elf)"
- */
-static bool vault_aux_dark_elf(int r_idx)
-{
- int i;
- static int dark_elf_list[] =
- {
- MON_D_ELF, MON_D_ELF_MAGE, MON_D_ELF_WARRIOR, MON_D_ELF_PRIEST,
- MON_D_ELF_LORD, MON_D_ELF_WARLOCK, MON_D_ELF_DRUID, MON_NIGHTBLADE,
- MON_D_ELF_SORC, MON_D_ELF_SHADE, 0,
- };
-
- /* Validate the monster */
- if (!vault_monster_okay(r_idx)) return FALSE;
-
- /* Require dark elves */
- for (i = 0; dark_elf_list[i]; i++)
- if (r_idx == dark_elf_list[i]) return TRUE;
-
- /* Assume not */
- return FALSE;
-}
-
-
-typedef struct vault_aux_type vault_aux_type;
-
-
-struct vault_aux_type
-{
- cptr name;
- bool (*hook_func)(int r_idx);
- void (*prep_func)(void);
- int level;
- int chance;
-};
-
-
-static int pick_vault_type(vault_aux_type *l_ptr, s16b allow_flag_mask)
-{
- int tmp, total, count;
-
- vault_aux_type *n_ptr;
-
- /* Calculate the total possibilities */
- for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
- {
- /* Note end */
- if (!n_ptr->name) break;
-
- /* Ignore excessive depth */
- if (n_ptr->level > dun_level) continue;
-
- /* Not matched with pit/nest flag */
- if (!(allow_flag_mask & (1L << count))) continue;
-
- /* Count this possibility */
- total += n_ptr->chance * MAX_DEPTH / (MIN(dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
- }
-
- /* Pick a random type */
- tmp = randint0(total);
-
- /* Find this type */
- for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
- {
- /* Note end */
- if (!n_ptr->name) break;
-
- /* Ignore excessive depth */
- if (n_ptr->level > dun_level) continue;
-
- /* Not matched with pit/nest flag */
- if (!(allow_flag_mask & (1L << count))) continue;
-
- /* Count this possibility */
- total += n_ptr->chance * MAX_DEPTH / (MIN(dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
-
- /* Found the type */
- if (tmp < total) break;
- }
-
- return n_ptr->name ? count : -1;
-}
-
-static vault_aux_type nest_types[] =
-{
-#ifdef JP
- {"¥¯¥í¡¼¥ó", vault_aux_clone, vault_prep_clone, 5, 3},
- {"¥¼¥ê¡¼", vault_aux_jelly, NULL, 5, 6},
- {"¥·¥ó¥Ü¥ë(Á±)", vault_aux_symbol_g, vault_prep_symbol, 25, 2},
- {"¥·¥ó¥Ü¥ë(°)", vault_aux_symbol_e, vault_prep_symbol, 25, 2},
- {"¥ß¥ß¥Ã¥¯", vault_aux_mimic, NULL, 30, 4},
- {"¶¸µ¤", vault_aux_cthulhu, NULL, 70, 2},
- {"¸¤¾®²°", vault_aux_kennel, NULL, 45, 4},
- {"ưʪ±à", vault_aux_animal, NULL, 35, 5},
- {"¶µ²ñ", vault_aux_chapel_g, NULL, 75, 4},
- {"¥¢¥ó¥Ç¥Ã¥É", vault_aux_undead, NULL, 75, 5},
- {NULL, NULL, NULL, 0, 0},
-#else
- {"clone", vault_aux_clone, vault_prep_clone, 5, 3},
- {"jelly", vault_aux_jelly, NULL, 5, 6},
- {"symbol good", vault_aux_symbol_g, vault_prep_symbol, 25, 2},
- {"symbol evil", vault_aux_symbol_e, vault_prep_symbol, 25, 2},
- {"mimic", vault_aux_mimic, NULL, 30, 4},
- {"lovecraftian", vault_aux_cthulhu, NULL, 70, 2},
- {"kennel", vault_aux_kennel, NULL, 45, 4},
- {"animal", vault_aux_animal, NULL, 35, 5},
- {"chapel", vault_aux_chapel_g, NULL, 75, 4},
- {"undead", vault_aux_undead, NULL, 75, 5},
- {NULL, NULL, NULL, 0, 0},
-#endif
-};
-
-static vault_aux_type pit_types[] =
-{
-#ifdef JP
- {"¥ª¡¼¥¯", vault_aux_orc, NULL, 5, 6},
- {"¥È¥í¥ë", vault_aux_troll, NULL, 20, 6},
- {"¥¸¥ã¥¤¥¢¥ó¥È", vault_aux_giant, NULL, 50, 6},
- {"¶¸µ¤", vault_aux_cthulhu, NULL, 80, 2},
- {"¥·¥ó¥Ü¥ë(Á±)", vault_aux_symbol_g, vault_prep_symbol, 70, 1},
- {"¥·¥ó¥Ü¥ë(°)", vault_aux_symbol_e, vault_prep_symbol, 70, 1},
- {"¶µ²ñ", vault_aux_chapel_g, NULL, 65, 2},
- {"¥É¥é¥´¥ó", vault_aux_dragon, vault_prep_dragon, 70, 6},
- {"¥Ç¡¼¥â¥ó", vault_aux_demon, NULL, 80, 6},
- {"¥À¡¼¥¯¥¨¥ë¥Õ", vault_aux_dark_elf, NULL, 45, 4},
- {NULL, NULL, NULL, 0, 0},
-#else
- {"orc", vault_aux_orc, NULL, 5, 6},
- {"troll", vault_aux_troll, NULL, 20, 6},
- {"giant", vault_aux_giant, NULL, 50, 6},
- {"lovecraftian", vault_aux_cthulhu, NULL, 80, 2},
- {"symbol good", vault_aux_symbol_g, vault_prep_symbol, 70, 1},
- {"symbol evil", vault_aux_symbol_e, vault_prep_symbol, 70, 1},
- {"chapel", vault_aux_chapel_g, NULL, 65, 2},
- {"dragon", vault_aux_dragon, vault_prep_dragon, 70, 6},
- {"demon", vault_aux_demon, NULL, 80, 6},
- {"dark elf", vault_aux_dark_elf, NULL, 45, 4},
- {NULL, NULL, NULL, 0, 0},
-#endif
-};
-
-
-/* Nest types code */
-#define NEST_TYPE_CLONE 0
-#define NEST_TYPE_JELLY 1
-#define NEST_TYPE_SYMBOL_GOOD 2
-#define NEST_TYPE_SYMBOL_EVIL 3
-#define NEST_TYPE_MIMIC 4
-#define NEST_TYPE_LOVECRAFTIAN 5
-#define NEST_TYPE_KENNEL 6
-#define NEST_TYPE_ANIMAL 7
-#define NEST_TYPE_CHAPEL 8
-#define NEST_TYPE_UNDEAD 9
-
-/* Pit types code */
-#define PIT_TYPE_ORC 0
-#define PIT_TYPE_TROLL 1
-#define PIT_TYPE_GIANT 2
-#define PIT_TYPE_LOVECRAFTIAN 3
-#define PIT_TYPE_SYMBOL_GOOD 4
-#define PIT_TYPE_SYMBOL_EVIL 5
-#define PIT_TYPE_CHAPEL 6
-#define PIT_TYPE_DRAGON 7
-#define PIT_TYPE_DEMON 8
-#define PIT_TYPE_DARK_ELF 9
-
-
-/*
- * Hack -- Get the string describing subtype of pit/nest
- * Determined in prepare function (some pit/nest only)
- */
-static cptr pit_subtype_string(int type, bool nest)
-{
- static char inner_buf[256] = "";
-
- inner_buf[0] = '\0'; /* Init string */
-
- if (nest) /* Nests */
- {
- switch (type)
- {
- case NEST_TYPE_CLONE:
- sprintf(inner_buf, "(%s)", r_name + r_info[vault_aux_race].name);
- break;
- case NEST_TYPE_SYMBOL_GOOD:
- case NEST_TYPE_SYMBOL_EVIL:
- sprintf(inner_buf, "(%c)", vault_aux_char);
- break;
- }
- }
- else /* Pits */
- {
- switch (type)
- {
- case PIT_TYPE_SYMBOL_GOOD:
- case PIT_TYPE_SYMBOL_EVIL:
- sprintf(inner_buf, "(%c)", vault_aux_char);
- break;
- case PIT_TYPE_DRAGON:
- switch (vault_aux_dragon_mask4)
- {
-#ifdef JP
- case RF4_BR_ACID: strcpy(inner_buf, "(»À)"); break;
- case RF4_BR_ELEC: strcpy(inner_buf, "(°ðºÊ)"); break;
- case RF4_BR_FIRE: strcpy(inner_buf, "(²Ð±ê)"); break;
- case RF4_BR_COLD: strcpy(inner_buf, "(Î䵤)"); break;
- case RF4_BR_POIS: strcpy(inner_buf, "(ÆÇ)"); break;
- case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS):
- strcpy(inner_buf, "(Ëü¿§)"); break;
- default: strcpy(inner_buf, "(̤ÄêµÁ)"); break;
-#else
- case RF4_BR_ACID: strcpy(inner_buf, "(acid)"); break;
- case RF4_BR_ELEC: strcpy(inner_buf, "(lightning)"); break;
- case RF4_BR_FIRE: strcpy(inner_buf, "(fire)"); break;
- case RF4_BR_COLD: strcpy(inner_buf, "(frost)"); break;
- case RF4_BR_POIS: strcpy(inner_buf, "(poison)"); break;
- case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS):
- strcpy(inner_buf, "(multi-hued)"); break;
- default: strcpy(inner_buf, "(undefined)"); break;
-#endif
- }
- break;
- }
- }
-
- return inner_buf;
-}
-
-
-/* A struct for nest monster information with cheat_hear */
-typedef struct
-{
- s16b r_idx;
- bool used;
-}
-nest_mon_info_type;
-
-
-/*
- * Comp function for sorting nest monster information
- */
-static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
-{
- nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
- int w1 = nest_mon_info[a].r_idx;
- int w2 = nest_mon_info[b].r_idx;
- monster_race *r1_ptr = &r_info[w1];
- monster_race *r2_ptr = &r_info[w2];
- int z1, z2;
-
- /* Unused */
- (void)v;
-
- /* Extract used info */
- z1 = nest_mon_info[a].used;
- z2 = nest_mon_info[b].used;
-
- /* Compare used status */
- if (z1 < z2) return FALSE;
- if (z1 > z2) return TRUE;
-
- /* Compare levels */
- if (r1_ptr->level < r2_ptr->level) return TRUE;
- if (r1_ptr->level > r2_ptr->level) return FALSE;
-
- /* Compare experience */
- if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
- if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
-
- /* Compare indexes */
- return w1 <= w2;
-}
-
-
-/*
- * Swap function for sorting nest monster information
- */
-static void ang_sort_swap_nest_mon_info(vptr u, vptr v, int a, int b)
-{
- nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
- nest_mon_info_type holder;
-
- /* Unused */
- (void)v;
-
- /* Swap */
- holder = nest_mon_info[a];
- nest_mon_info[a] = nest_mon_info[b];
- nest_mon_info[b] = holder;
-}
-
-
-#define NUM_NEST_MON_TYPE 64
-
-/*
- * Type 5 -- Monster nests
- *
- * A monster nest is a "big" room, with an "inner" room, containing
- * a "collection" of monsters of a given type strewn about the room.
- *
- * The monsters are chosen from a set of 64 randomly selected monster
- * races, to allow the nest creation to fail instead of having "holes".
- *
- * Note the use of the "get_mon_num_prep()" function, and the special
- * "get_mon_num_hook()" restriction function, to prepare the "monster
- * allocation table" in such a way as to optimize the selection of
- * "appropriate" non-unique monsters for the nest.
- *
- * Note that the "get_mon_num()" function may (rarely) fail, in which
- * case the nest will be empty, and will not affect the level rating.
- *
- * Note that "monster nests" will never contain "unique" monsters.
- */
-static bool build_type5(void)
-{
- int y, x, y1, x1, y2, x2, xval, yval;
- int i;
- nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
-
- monster_type align;
-
- cave_type *c_ptr;
-
- int cur_nest_type = pick_vault_type(nest_types, d_info[dungeon_type].nest);
- vault_aux_type *n_ptr;
-
- /* No type available */
- if (cur_nest_type < 0) return FALSE;
-
- n_ptr = &nest_types[cur_nest_type];
-
- /* Process a preparation function if necessary */
- if (n_ptr->prep_func) (*(n_ptr->prep_func))();
-
- /* Prepare allocation table */
- get_mon_num_prep(n_ptr->hook_func, NULL);
-
- align.sub_align = SUB_ALIGN_NEUTRAL;
-
- /* Pick some monster types */
- for (i = 0; i < NUM_NEST_MON_TYPE; i++)
- {
- int r_idx = 0, attempts = 100;
- monster_race *r_ptr = NULL;
-
- while (attempts--)
- {
- /* Get a (hard) monster type */
- r_idx = get_mon_num(dun_level + 10);
- r_ptr = &r_info[r_idx];
-
- /* Decline incorrect alignment */
- if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
-
- /* Accept this monster */
- break;
- }
-
- /* Notice failure */
- if (!r_idx || !attempts) return FALSE;
-
- /* Note the alignment */
- if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
- if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
-
- nest_mon_info[i].r_idx = r_idx;
- nest_mon_info[i].used = FALSE;
- }
-
- /* Find and reserve some space in the dungeon. Get center of room. */
- if (!find_space(&yval, &xval, 11, 25)) return FALSE;
-
- /* Large room */
- y1 = yval - 4;
- y2 = yval + 4;
- x1 = xval - 11;
- x2 = xval + 11;
-
- /* Place the floor area */
- for (y = y1 - 1; y <= y2 + 1; y++)
- {
- for (x = x1 - 1; x <= x2 + 1; x++)
- {
- c_ptr = &cave[y][x];
- place_floor_grid(c_ptr);
- c_ptr->info |= (CAVE_ROOM);
- }
- }
-
- /* Place the outer walls */
- for (y = y1 - 1; y <= y2 + 1; y++)
- {
- c_ptr = &cave[y][x1 - 1];
- place_outer_grid(c_ptr);
- c_ptr = &cave[y][x2 + 1];
- place_outer_grid(c_ptr);
- }
- for (x = x1 - 1; x <= x2 + 1; x++)
- {
- c_ptr = &cave[y1 - 1][x];
- place_outer_grid(c_ptr);
- c_ptr = &cave[y2 + 1][x];
- place_outer_grid(c_ptr);
- }
-
-
- /* Advance to the center room */
- y1 = y1 + 2;
- y2 = y2 - 2;
- x1 = x1 + 2;
- x2 = x2 - 2;
-
- /* The inner walls */
- for (y = y1 - 1; y <= y2 + 1; y++)
- {
- c_ptr = &cave[y][x1 - 1];
- place_inner_grid(c_ptr);
- c_ptr = &cave[y][x2 + 1];
- place_inner_grid(c_ptr);
- }
-
- for (x = x1 - 1; x <= x2 + 1; x++)
- {
- c_ptr = &cave[y1 - 1][x];
- place_inner_grid(c_ptr);
- c_ptr = &cave[y2 + 1][x];
- place_inner_grid(c_ptr);
- }
- for (y = y1; y <= y2; y++)
- {
- for (x = x1; x <= x2; x++)
- {
- add_cave_info(y, x, CAVE_ICKY);
- }
- }
-
- /* Place a secret door */
- switch (randint1(4))
- {
- case 1: place_secret_door(y1 - 1, xval); break;
- case 2: place_secret_door(y2 + 1, xval); break;
- case 3: place_secret_door(yval, x1 - 1); break;
- case 4: place_secret_door(yval, x2 + 1); break;
- }
-
- /* Describe */
- if (cheat_room)
- {
- /* Room type */
-#ifdef JP
- msg_format("¥â¥ó¥¹¥¿¡¼Éô²°(nest)(%s%s)", n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
-#else
- msg_format("Monster nest (%s%s)", n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
-#endif
- }
-
- /* Increase the level rating */
- rating += 10;
-
- /* (Sometimes) Cause a "special feeling" (for "Monster Nests") */
- if ((dun_level <= 40) && (randint1(dun_level * dun_level + 50) < 300))
- {
- good_item_flag = TRUE;
- }
-
- /* Place some monsters */
- for (y = yval - 2; y <= yval + 2; y++)
- {
- for (x = xval - 9; x <= xval + 9; x++)
- {
- int r_idx;
-
- i = randint0(NUM_NEST_MON_TYPE);
- r_idx = nest_mon_info[i].r_idx;
-
- /* Place that "random" monster (no groups) */
- (void)place_monster_aux(0, y, x, r_idx, 0L);
-
- nest_mon_info[i].used = TRUE;
- }
- }
-
- if (cheat_room && cheat_hear)
- {
- ang_sort_comp = ang_sort_comp_nest_mon_info;
- ang_sort_swap = ang_sort_swap_nest_mon_info;
- ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE);
-
- /* Dump the entries (prevent multi-printing) */
- for (i = 0; i < NUM_NEST_MON_TYPE; i++)
- {
- if (!nest_mon_info[i].used) break;
- for (; i < NUM_NEST_MON_TYPE - 1; i++)
- {
- if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
- if (!nest_mon_info[i + 1].used) break;
- }
- msg_print(r_name + r_info[nest_mon_info[i].r_idx].name);
- }
- }
-
- return TRUE;
-}
-
-
-/*
- * Type 6 -- Monster pits
- *
- * A monster pit is a "big" room, with an "inner" room, containing
- * a "collection" of monsters of a given type organized in the room.
- *
- * The inside room in a monster pit appears as shown below, where the
- * actual monsters in each location depend on the type of the pit
- *
- * #####################
- * #0000000000000000000#
- * #0112233455543322110#
- * #0112233467643322110#
- * #0112233455543322110#
- * #0000000000000000000#
- * #####################
- *
- * Note that the monsters in the pit are now chosen by using "get_mon_num()"
- * to request 16 "appropriate" monsters, sorting them by level, and using
- * the "even" entries in this sorted list for the contents of the pit.
- *
- * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",
- * which is handled by requiring a specific "breath" attack for all of the
- * dragons. This may include "multi-hued" breath. Note that "wyrms" may
- * be present in many of the dragon pits, if they have the proper breath.
- *
- * Note the use of the "get_mon_num_prep()" function, and the special
- * "get_mon_num_hook()" restriction function, to prepare the "monster
- * allocation table" in such a way as to optimize the selection of
- * "appropriate" non-unique monsters for the pit.
- *
- * Note that the "get_mon_num()" function may (rarely) fail, in which case
- * the pit will be empty, and will not effect the level rating.
- *
- * Note that "monster pits" will never contain "unique" monsters.
- */
-static bool build_type6(void)
-{
- int y, x, y1, x1, y2, x2, xval, yval;
- int i, j;
-
- int what[16];
-
- monster_type align;
-
- cave_type *c_ptr;
-
- int cur_pit_type = pick_vault_type(pit_types, d_info[dungeon_type].pit);
- vault_aux_type *n_ptr;
-
- /* No type available */
- if (cur_pit_type < 0) return FALSE;
-
- n_ptr = &pit_types[cur_pit_type];
-
- /* Process a preparation function if necessary */
- if (n_ptr->prep_func) (*(n_ptr->prep_func))();
-
- /* Prepare allocation table */
- get_mon_num_prep(n_ptr->hook_func, NULL);
-
- align.sub_align = SUB_ALIGN_NEUTRAL;
-
- /* Pick some monster types */
- for (i = 0; i < 16; i++)
- {
- int r_idx = 0, attempts = 100;
- monster_race *r_ptr = NULL;
-
- while (attempts--)
- {
- /* Get a (hard) monster type */
- r_idx = get_mon_num(dun_level + 10);
- r_ptr = &r_info[r_idx];
-
- /* Decline incorrect alignment */
- if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
-
- /* Accept this monster */
- break;
- }
-
- /* Notice failure */
- if (!r_idx || !attempts) return FALSE;
-
- /* Note the alignment */
- if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
- if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
-
- what[i] = r_idx;
- }
-
- /* Find and reserve some space in the dungeon. Get center of room. */
- if (!find_space(&yval, &xval, 11, 25)) return FALSE;
-
- /* Large room */
- y1 = yval - 4;
- y2 = yval + 4;
- x1 = xval - 11;
- x2 = xval + 11;
-
- /* Place the floor area */
- for (y = y1 - 1; y <= y2 + 1; y++)
- {
- for (x = x1 - 1; x <= x2 + 1; x++)
- {
- c_ptr = &cave[y][x];
- place_floor_grid(c_ptr);
- c_ptr->info |= (CAVE_ROOM);
- }
- }
-
- /* Place the outer walls */
- for (y = y1 - 1; y <= y2 + 1; y++)
- {
- c_ptr = &cave[y][x1 - 1];
- place_outer_grid(c_ptr);
- c_ptr = &cave[y][x2 + 1];
- place_outer_grid(c_ptr);
- }
- for (x = x1 - 1; x <= x2 + 1; x++)
- {
- c_ptr = &cave[y1 - 1][x];
- place_outer_grid(c_ptr);
- c_ptr = &cave[y2 + 1][x];
- place_outer_grid(c_ptr);
- }
-
- /* Advance to the center room */
- y1 = y1 + 2;
- y2 = y2 - 2;
- x1 = x1 + 2;
- x2 = x2 - 2;
-
- /* The inner walls */
- for (y = y1 - 1; y <= y2 + 1; y++)
- {
- c_ptr = &cave[y][x1 - 1];
- place_inner_grid(c_ptr);
- c_ptr = &cave[y][x2 + 1];
- place_inner_grid(c_ptr);
- }
- for (x = x1 - 1; x <= x2 + 1; x++)
- {
- c_ptr = &cave[y1 - 1][x];
- place_inner_grid(c_ptr);
- c_ptr = &cave[y2 + 1][x];
- place_inner_grid(c_ptr);
- }
- for (y = y1; y <= y2; y++)
- {
- for (x = x1; x <= x2; x++)
- {
- add_cave_info(y, x, CAVE_ICKY);
- }
- }
-
- /* Place a secret door */
- switch (randint1(4))
- {
- case 1: place_secret_door(y1 - 1, xval); break;
- case 2: place_secret_door(y2 + 1, xval); break;
- case 3: place_secret_door(yval, x1 - 1); break;
- case 4: place_secret_door(yval, x2 + 1); break;
- }
-
- /* Sort the entries */
- for (i = 0; i < 16 - 1; i++)
- {
- /* Sort the entries */
- for (j = 0; j < 16 - 1; j++)
- {
- int i1 = j;
- int i2 = j + 1;
-
- int p1 = r_info[what[i1]].level;
- int p2 = r_info[what[i2]].level;
-
- /* Bubble */
- if (p1 > p2)
- {
- int tmp = what[i1];
- what[i1] = what[i2];
- what[i2] = tmp;
- }
- }
- }
-
- /* Message */
- if (cheat_room)
- {
- /* Room type */
-#ifdef JP
- msg_format("¥â¥ó¥¹¥¿¡¼Éô²°(pit)(%s%s)", n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
-#else
- msg_format("Monster pit (%s%s)", n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
-#endif
- }
-
- /* Select the entries */
- for (i = 0; i < 8; i++)
- {
- /* Every other entry */
- what[i] = what[i * 2];
-
- if (cheat_hear)
- {
- /* Message */
- msg_print(r_name + r_info[what[i]].name);
- }
- }
-
- /* Increase the level rating */
- rating += 10;
-
- /* (Sometimes) Cause a "special feeling" (for "Monster Pits") */
- if ((dun_level <= 40) && (randint1(dun_level * dun_level + 50) < 300))
- {
- good_item_flag = TRUE;
- }
-
- /* Top and bottom rows */
- for (x = xval - 9; x <= xval + 9; x++)
- {
- place_monster_aux(0, yval - 2, x, what[0], PM_NO_KAGE);
- place_monster_aux(0, yval + 2, x, what[0], PM_NO_KAGE);
- }
-
- /* Middle columns */
- for (y = yval - 1; y <= yval + 1; y++)
- {
- place_monster_aux(0, y, xval - 9, what[0], PM_NO_KAGE);
- place_monster_aux(0, y, xval + 9, what[0], PM_NO_KAGE);
-
- place_monster_aux(0, y, xval - 8, what[1], PM_NO_KAGE);
- place_monster_aux(0, y, xval + 8, what[1], PM_NO_KAGE);
-
- place_monster_aux(0, y, xval - 7, what[1], PM_NO_KAGE);
- place_monster_aux(0, y, xval + 7, what[1], PM_NO_KAGE);
-
- place_monster_aux(0, y, xval - 6, what[2], PM_NO_KAGE);
- place_monster_aux(0, y, xval + 6, what[2], PM_NO_KAGE);
-
- place_monster_aux(0, y, xval - 5, what[2], PM_NO_KAGE);
- place_monster_aux(0, y, xval + 5, what[2], PM_NO_KAGE);
-
- place_monster_aux(0, y, xval - 4, what[3], PM_NO_KAGE);
- place_monster_aux(0, y, xval + 4, what[3], PM_NO_KAGE);
-
- place_monster_aux(0, y, xval - 3, what[3], PM_NO_KAGE);
- place_monster_aux(0, y, xval + 3, what[3], PM_NO_KAGE);
-
- place_monster_aux(0, y, xval - 2, what[4], PM_NO_KAGE);
- place_monster_aux(0, y, xval + 2, what[4], PM_NO_KAGE);
- }
-
- /* Above/Below the center monster */
- for (x = xval - 1; x <= xval + 1; x++)
- {
- place_monster_aux(0, yval + 1, x, what[5], PM_NO_KAGE);
- place_monster_aux(0, yval - 1, x, what[5], PM_NO_KAGE);
- }
-
- /* Next to the center monster */
- place_monster_aux(0, yval, xval + 1, what[6], PM_NO_KAGE);
- place_monster_aux(0, yval, xval - 1, what[6], PM_NO_KAGE);
-
- /* Center monster */
- place_monster_aux(0, yval, xval, what[7], PM_NO_KAGE);
-
- return TRUE;
-}
-
-
-/* coordinate translation code */
-static void coord_trans(int *x, int *y, int xoffset, int yoffset, int transno)
-{
- int i;
- int temp;
-
- /*
- * transno specifies what transformation is required. (0-7)
- * The lower two bits indicate by how much the vault is rotated,
- * and the upper bit indicates a reflection.
- * This is done by using rotation matrices... however since
- * these are mostly zeros for rotations by 90 degrees this can
- * be expressed simply in terms of swapping and inverting the
- * x and y coordinates.
- */
- for (i = 0; i < transno % 4; i++)
- {
- /* rotate by 90 degrees */
- temp = *x;
- *x = -(*y);
- *y = temp;
- }
-
- if (transno / 4)
- {
- /* Reflect depending on status of 3rd bit. */
- *x = -(*x);
- }
-
- /* Add offsets so vault stays in the first quadrant */
- *x += xoffset;
- *y += yoffset;
-}
-
-
-/*
- * Hack -- fill in "vault" rooms
- */
-static void build_vault(int yval, int xval, int ymax, int xmax, cptr data,
- int xoffset, int yoffset, int transno)
-{
- int dx, dy, x, y, i, j;
-
- cptr t;
-
- cave_type *c_ptr;
-
-
- /* Place dungeon features and objects */
- for (t = data, dy = 0; dy < ymax; dy++)
- {
- for (dx = 0; dx < xmax; dx++, t++)
- {
- /* prevent loop counter from being overwritten */
- i = dx;
- j = dy;
-
- /* Flip / rotate */
- coord_trans(&i, &j, xoffset, yoffset, transno);
-
- /* Extract the location */
- if (transno % 2 == 0)
- {
- /* no swap of x/y */
- x = xval - (xmax / 2) + i;
- y = yval - (ymax / 2) + j;
- }
- else
- {
- /* swap of x/y */
- x = xval - (ymax / 2) + i;
- y = yval - (xmax / 2) + j;
- }
-
- /* Hack -- skip "non-grids" */
- if (*t == ' ') continue;
-
- /* Access the grid */
- c_ptr = &cave[y][x];
-
- /* Lay down a floor */
- place_floor_grid(c_ptr);
-
- /* Remove any mimic */
- c_ptr->mimic = 0;
-
- /* Part of a vault */
- c_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
-
- /* Analyze the grid */
- switch (*t)
- {
- /* Granite wall (outer) */
- case '%':
- place_outer_noperm_grid(c_ptr);
- break;
-
- /* Granite wall (inner) */
- case '#':
- place_inner_grid(c_ptr);
- break;
-
- /* Permanent wall (inner) */
- case 'X':
- c_ptr->feat = FEAT_PERM_INNER;
- c_ptr->info &= ~(CAVE_MASK);
- c_ptr->info |= CAVE_INNER;
- break;
-
- /* Treasure/trap */
- case '*':
- if (randint0(100) < 75)
- {
- place_object(y, x, 0L);
- }
- else
- {
- place_trap(y, x);
- }
- break;
-
- /* Secret doors */
- case '+':
- place_secret_door(y, x);
- break;
-
- /* Trap */
- case '^':
- place_trap(y, x);
- break;
-
- /* Black market in a dungeon */
- case 'S':
- set_cave_feat(y, x, FEAT_SHOP_HEAD + STORE_BLACK);
- store_init(NO_TOWN, STORE_BLACK);
- break;
-
- /* The Pattern */
- case 'p':
- set_cave_feat(y, x, FEAT_PATTERN_START);
- break;
-
- case 'a':
- set_cave_feat(y, x, FEAT_PATTERN_1);
- break;
-
- case 'b':
- set_cave_feat(y, x, FEAT_PATTERN_2);
- break;
-
- case 'c':
- set_cave_feat(y, x, FEAT_PATTERN_3);
- break;
-
- case 'd':
- set_cave_feat(y, x, FEAT_PATTERN_4);
- break;
-
- case 'P':
- set_cave_feat(y, x, FEAT_PATTERN_END);
- break;
-
- case 'B':
- set_cave_feat(y, x, FEAT_PATTERN_XTRA1);
- break;
-
- case 'A':
- /* Reward for Pattern walk */
- object_level = base_level + 12;
- place_object(y, x, AM_GOOD | AM_GREAT);
- object_level = base_level;
- break;
- }
- }
- }
-
-
- /* Place dungeon monsters and objects */
- for (t = data, dy = 0; dy < ymax; dy++)
- {
- for (dx = 0; dx < xmax; dx++, t++)
- {
- /* prevent loop counter from being overwritten */
- i = dx;
- j = dy;
-
- /* Flip / rotate */
- coord_trans(&i, &j, xoffset, yoffset, transno);
-
- /* Extract the location */
- if (transno % 2 == 0)
- {
- /* no swap of x/y */
- x = xval - (xmax / 2) + i;
- y = yval - (ymax / 2) + j;
- }
- else
- {
- /* swap of x/y */
- x = xval - (ymax / 2) + i;
- y = yval - (xmax / 2) + j;
- }
-
- /* Hack -- skip "non-grids" */
- if (*t == ' ') continue;
-
- /* Analyze the symbol */
- switch (*t)
- {
- /* Monster */
- case '&':
- {
- monster_level = base_level + 5;
- place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
- monster_level = base_level;
- break;
- }
-
- /* Meaner monster */
- case '@':
- {
- monster_level = base_level + 11;
- place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
- monster_level = base_level;
- break;
- }
-
- /* Meaner monster, plus treasure */
- case '9':
- {
- monster_level = base_level + 9;
- place_monster(y, x, PM_ALLOW_SLEEP);
- monster_level = base_level;
- object_level = base_level + 7;
- place_object(y, x, AM_GOOD);
- object_level = base_level;
- break;
- }
-
- /* Nasty monster and treasure */
- case '8':
- {
- monster_level = base_level + 40;
- place_monster(y, x, PM_ALLOW_SLEEP);
- monster_level = base_level;
- object_level = base_level + 20;
- place_object(y, x, AM_GOOD | AM_GREAT);
- object_level = base_level;
- break;
- }
-
- /* Monster and/or object */
- case ',':
- {
- if (randint0(100) < 50)
- {
- monster_level = base_level + 3;
- place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
- monster_level = base_level;
- }
- if (randint0(100) < 50)
- {
- object_level = base_level + 7;
- place_object(y, x, 0L);
- object_level = base_level;
- }
- break;
- }
-
- }
- }
- }
-}
-
-
-/*
- * Type 7 -- simple vaults (see "v_info.txt")
- */
-static bool build_type7(void)
-{
- vault_type *v_ptr;
- int dummy;
- int x, y;
- int xval, yval;
- int xoffset, yoffset;
- int transno;
-
- /* Pick a lesser vault */
- for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
- {
- /* Access a random vault record */
- v_ptr = &v_info[randint0(max_v_idx)];
-
- /* Accept the first lesser vault */
- if (v_ptr->typ == 7) break;
- }
-
- /* No lesser vault found */
- if (dummy >= SAFE_MAX_ATTEMPTS)
- {
- if (cheat_room)
- {
-#ifdef JP
- msg_print("·Ù¹ð¡ª¾®¤µ¤ÊÃϲ¼¼¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡ª");
-#else
- msg_print("Warning! Could not place lesser vault!");
-#endif
- }
- return FALSE;
- }
-
- /* pick type of transformation (0-7) */
- transno = randint0(8);
-
- /* calculate offsets */
- x = v_ptr->wid;
- y = v_ptr->hgt;
-
- /* Some huge vault cannot be ratated to fit in the dungeon */
- if (x+2 > cur_hgt-2)
- {
- /* Forbid 90 or 270 degree ratation */
- transno &= ~1;
- }
-
- coord_trans(&x, &y, 0, 0, transno);
-
- if (x < 0)
- {
- xoffset = -x - 1;
- }
- else
- {
- xoffset = 0;
- }
-
- if (y < 0)
- {
- yoffset = -y - 1;
- }
- else
- {
- yoffset = 0;
- }
-
- /* Find and reserve some space in the dungeon. Get center of room. */
- if (!find_space(&yval, &xval, abs(y), abs(x))) return FALSE;
-
-#ifdef FORCE_V_IDX
- v_ptr = &v_info[2];
-#endif
-
- /* Message */
-#ifdef JP
- if (cheat_room) msg_format("¾®¤µ¤ÊÃϲ¼¼¼(%s)", v_name + v_ptr->name);
-#else
- if (cheat_room) msg_format("Lesser vault (%s)", v_name + v_ptr->name);
-#endif
-
- /* Boost the rating */
- rating += v_ptr->rat;
-
- /* (Sometimes) Cause a special feeling */
- if ((dun_level <= 50) ||
- (randint1((dun_level - 40) * (dun_level - 40) + 50) < 400))
- {
- good_item_flag = TRUE;
- }
-
- /* Hack -- Build the vault */
- build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
- v_text + v_ptr->text, xoffset, yoffset, transno);
-
- return TRUE;
-}
-
-
-/*
- * Type 8 -- greater vaults (see "v_info.txt")
- */
-static bool build_type8(void)
-{
- vault_type *v_ptr;
- int dummy;
- int xval, yval;
- int x, y;
- int transno;
- int xoffset, yoffset;
-
- /* Pick a greater vault */
- for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
- {
- /* Access a random vault record */
- v_ptr = &v_info[randint0(max_v_idx)];
-
- /* Accept the first greater vault */
- if (v_ptr->typ == 8) break;
- }
-
- /* No greater vault found */
- if (dummy >= SAFE_MAX_ATTEMPTS)
- {
- if (cheat_room)
- {
-#ifdef JP
- msg_print("·Ù¹ð¡ªµðÂç¤ÊÃϲ¼¼¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡ª");
-#else
- msg_print("Warning! Could not place greater vault!");
-#endif
- }
- return FALSE;
- }
-
- /* pick type of transformation (0-7) */
- transno = randint0(8);
-
- /* calculate offsets */
- x = v_ptr->wid;
- y = v_ptr->hgt;
-
- /* Some huge vault cannot be ratated to fit in the dungeon */
- if (x+2 > cur_hgt-2)
- {
- /* Forbid 90 or 270 degree ratation */
- transno &= ~1;
- }
-
- coord_trans(&x, &y, 0, 0, transno);
-
- if (x < 0)
- {
- xoffset = - x - 1;
- }
- else
- {
- xoffset = 0;
- }
-
- if (y < 0)
- {
- yoffset = - y - 1;
- }
- else
- {
- yoffset = 0;
- }
-
- /*
- * Try to allocate space for room. If fails, exit
- *
- * Hack -- Prepare a bit larger space (+2, +2) to
- * prevent generation of vaults with no-entrance.
- */
- /* Find and reserve some space in the dungeon. Get center of room. */
- if (!find_space(&yval, &xval, abs(y) + 2, abs(x) + 2)) return FALSE;
-
-#ifdef FORCE_V_IDX
- v_ptr = &v_info[76 + randint1(3)];
-#endif
-
- /* Message */
-#ifdef JP
- if (cheat_room) msg_format("µðÂç¤ÊÃϲ¼¼¼(%s)", v_name + v_ptr->name);
-#else
- if (cheat_room) msg_format("Greater vault (%s)", v_name + v_ptr->name);
-#endif
-
- /* Boost the rating */
- rating += v_ptr->rat;
-
- /* (Sometimes) Cause a special feeling */
- if ((dun_level <= 50) ||
- (randint1((dun_level - 40) * (dun_level - 40) + 50) < 400))
- {
- good_item_flag = TRUE;
- }
-
- /* Hack -- Build the vault */
- build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
- v_text + v_ptr->text, xoffset, yoffset, transno);
-
- return TRUE;
-}
-
-/*
- * Structure to hold all "fill" data
- */
-
-typedef struct fill_data_type fill_data_type;
-
-struct fill_data_type
-{
- /* area size */
- int xmin;
- int ymin;
- int xmax;
- int ymax;
-
- /* cutoffs */
- int c1;
- int c2;
- int c3;
-
- /* features to fill with */
- int feat1;
- int feat2;
- int feat3;
-
- int info1;
- int info2;
- int info3;
-
- /* number of filled squares */
- int amount;
-};
-
-static fill_data_type fill_data;
-
-
-/* Store routine for the fractal cave generator */
-/* this routine probably should be an inline function or a macro. */
-static void store_height(int x, int y, int val)
-{
- /* if on boundary set val > cutoff so walls are not as square */
- if (((x == fill_data.xmin) || (y == fill_data.ymin) ||
- (x == fill_data.xmax) || (y == fill_data.ymax)) &&
- (val <= fill_data.c1)) val = fill_data.c1 + 1;
-
- /* store the value in height-map format */
- cave[y][x].feat = val;
-
- return;
-}
-
-
-/*
-* Explanation of the plasma fractal algorithm:
-*
-* A grid of points is created with the properties of a 'height-map'
-* This is done by making the corners of the grid have a random value.
-* The grid is then subdivided into one with twice the resolution.
-* The new points midway between two 'known' points can be calculated
-* by taking the average value of the 'known' ones and randomly adding
-* or subtracting an amount proportional to the distance between those
-* points. The final 'middle' points of the grid are then calculated
-* by averaging all four of the originally 'known' corner points. An
-* random amount is added or subtracted from this to get a value of the
-* height at that point. The scaling factor here is adjusted to the
-* slightly larger distance diagonally as compared to orthogonally.
-*
-* This is then repeated recursively to fill an entire 'height-map'
-* A rectangular map is done the same way, except there are different
-* scaling factors along the x and y directions.
-*
-* A hack to change the amount of correlation between points is done using
-* the grd variable. If the current step size is greater than grd then
-* the point will be random, otherwise it will be calculated by the
-* above algorithm. This makes a maximum distance at which two points on
-* the height map can affect each other.
-*
-* How fractal caves are made:
-*
-* When the map is complete, a cut-off value is used to create a cave.
-* Heights below this value are "floor", and heights above are "wall".
-* This also can be used to create lakes, by adding more height levels
-* representing shallow and deep water/ lava etc.
-*
-* The grd variable affects the width of passages.
-* The roug variable affects the roughness of those passages
-*
-* The tricky part is making sure the created cave is connected. This
-* is done by 'filling' from the inside and only keeping the 'filled'
-* floor. Walls bounding the 'filled' floor are also kept. Everything
-* else is converted to the normal granite FEAT_WALL_EXTRA.
- */
-
-
-/*
- * Note that this uses the cave.feat array in a very hackish way
- * the values are first set to zero, and then each array location
- * is used as a "heightmap"
- * The heightmap then needs to be converted back into the "feat" format.
- *
- * grd=level at which fractal turns on. smaller gives more mazelike caves
- * roug=roughness level. 16=normal. higher values make things more convoluted
- * small values are good for smooth walls.
- * size=length of the side of the square cave system.
- */
-static void generate_hmap(int y0, int x0, int xsiz, int ysiz, int grd, int roug, int cutoff)
-{
- int xhsize, yhsize, xsize, ysize, maxsize;
-
- /*
- * fixed point variables- these are stored as 256 x normal value
- * this gives 8 binary places of fractional part + 8 places of normal part
- */
-
- u16b xstep, xhstep, ystep, yhstep;
- u16b xstep2, xhstep2, ystep2, yhstep2;
- u16b i, j, ii, jj, diagsize, xxsize, yysize;
-
- /* Cache for speed */
- u16b xm, xp, ym, yp;
-
- /* redefine size so can change the value if out of range */
- xsize = xsiz;
- ysize = ysiz;
-
- /* Paranoia about size of the system of caves */
- if (xsize > 254) xsize = 254;
- if (xsize < 4) xsize = 4;
- if (ysize > 254) ysize = 254;
- if (ysize < 4) ysize = 4;
-
- /* get offsets to middle of array */
- xhsize = xsize / 2;
- yhsize = ysize / 2;