3 * @brief ¥À¥ó¥¸¥ç¥ó¥Õ¥í¥¢¤ÎÉô²°À¸À®½èÍý / make rooms. Used by generate.c when creating dungeons.
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
7 * This software may be copied and distributed for educational, research,\n
8 * and not for profit purposes provided that this copyright and statement\n
9 * are included in all such copies. Other copyrights may also apply.\n
10 * 2014 Deskull rearranged comment for Doxygen. \n
12 * Room building routines.\n
18 * 4 -- large room with features\n
19 * 5 -- monster nests\n
21 * 7 -- simple vaults\n
22 * 8 -- greater vaults\n
23 * 9 -- fractal caves\n
24 * 10 -- random vaults\n
25 * 11 -- circular rooms\n
27 * 13 -- trapped monster pits\n
28 * 14 -- trapped room\n
30 * 16 -- underground arcade\n
32 * Some functions are used to determine if the given monster\n
33 * is appropriate for inclusion in a monster nest or monster pit or\n
36 * None of the pits/nests are allowed to include "unique" monsters.\n
46 * ³ÆÉô²°¥¿¥¤¥×¤ÎÀ¸À®ÈæÄêµÁ
47 *[from SAngband (originally from OAngband)]\n
49 * Table of values that control how many times each type of room will\n
50 * appear. Each type of room has its own row, and each column\n
51 * corresponds to dungeon levels 0, 10, 20, and so on. The final\n
52 * value is the minimum depth the room can appear at. -LM-\n
54 * Level 101 and below use the values for level 100.\n
56 * Rooms with lots of monsters or loot may not be generated if the\n
57 * object or monster lists are already nearly full. Rooms will not\n
58 * appear above their minimum depth. Tiny levels will not have space\n
59 * for all the rooms you ask for.\n
61 static room_info_type room_info_normal[ROOM_T_MAX] =
64 /* 0 10 20 30 40 50 60 70 80 90 100 min limit */
66 {{999,900,800,700,600,500,400,300,200,100, 0}, 0}, /*NORMAL */
67 {{ 1, 10, 20, 30, 40, 50, 60, 70, 80, 90,100}, 1}, /*OVERLAP */
68 {{ 1, 10, 20, 30, 40, 50, 60, 70, 80, 90,100}, 3}, /*CROSS */
69 {{ 1, 10, 20, 30, 40, 50, 60, 70, 80, 90,100}, 3}, /*INNER_F */
70 {{ 0, 1, 1, 1, 2, 3, 5, 6, 8, 10, 13}, 10}, /*NEST */
71 {{ 0, 1, 1, 2, 3, 4, 6, 8, 10, 13, 16}, 10}, /*PIT */
72 {{ 0, 1, 1, 1, 2, 2, 3, 5, 6, 8, 10}, 10}, /*LESSER_V */
73 {{ 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4}, 20}, /*GREATER_V*/
74 {{ 0,100,200,300,400,500,600,700,800,900,999}, 10}, /*FRACAVE */
75 {{ 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2}, 10}, /*RANDOM_V */
76 {{ 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40}, 3}, /*OVAL */
77 {{ 1, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60}, 10}, /*CRYPT */
78 {{ 0, 0, 1, 1, 1, 2, 3, 4, 5, 6, 8}, 20}, /*TRAP_PIT */
79 {{ 0, 0, 1, 1, 1, 2, 3, 4, 5, 6, 8}, 20}, /*TRAP */
80 {{ 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2}, 40}, /*GLASS */
81 {{ 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3}, 1}, /*ARCADE */
85 /*! Éô²°¤ÎÀ¸À®½èÍý½ç / Build rooms in descending order of difficulty. */
86 static byte room_build_order[ROOM_T_MAX] = {
106 * @brief ¸°¤Î¤«¤«¤Ã¤¿¥É¥¢¤òÇÛÃÖ¤¹¤ë
107 * @param y ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎYºÂɸ
108 * @param x ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎXºÂɸ
111 static void place_locked_door(int y, int x)
113 if (d_info[dungeon_type].flags1 & DF1_NO_DOORS)
115 place_floor_bold(y, x);
119 set_cave_feat(y, x, feat_locked_door_random((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR));
120 cave[y][x].info &= ~(CAVE_FLOOR);
121 delete_monster(y, x);
126 * @brief ±£¤·¥É¥¢¤òÇÛÃÖ¤¹¤ë
127 * @param y ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎYºÂɸ
128 * @param x ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎXºÂɸ
129 * @param type #DOOR_DEFAULT / #DOOR_DOOR / #DOOR_GLASS_DOOR / #DOOR_CURTAIN ¤Î¤¤¤º¤ì¤«
132 static void place_secret_door(int y, int x, int type)
134 if (d_info[dungeon_type].flags1 & DF1_NO_DOORS)
136 place_floor_bold(y, x);
140 cave_type *c_ptr = &cave[y][x];
142 if (type == DOOR_DEFAULT)
144 type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
145 one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
146 ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
149 /* Create secret door */
150 place_closed_door(y, x, type);
152 if (type != DOOR_CURTAIN)
154 /* Hide by inner wall because this is used in rooms only */
155 c_ptr->mimic = feat_wall_inner;
157 /* Floor type terrain cannot hide a door */
158 if (feat_supports_los(c_ptr->mimic) && !feat_supports_los(c_ptr->feat))
160 if (have_flag(f_info[c_ptr->mimic].flags, FF_MOVE) || have_flag(f_info[c_ptr->mimic].flags, FF_CAN_FLY))
162 c_ptr->feat = one_in_(2) ? c_ptr->mimic : floor_type[randint0(100)];
168 c_ptr->info &= ~(CAVE_FLOOR);
169 delete_monster(y, x);
174 * @brief 1¥Þ¥¹¤À¤±¤ÎÉô²°¤òºîÀ®¤·¡¢¾å²¼º¸±¦¤¤¤º¤ì¤«°ì¤Ä¤Ë±£¤·¥É¥¢¤òÇÛÃÖ¤¹¤ë¡£
175 * @param y0 ÇÛÃÖ¤·¤¿¤¤Ãæ¿´¤ÎYºÂɸ
176 * @param x0 ÇÛÃÖ¤·¤¿¤¤Ãæ¿´¤ÎXºÂɸ
178 * This funtion makes a very small room centred at (x0, y0)
179 * This is used in crypts, and random elemental vaults.
181 * Note - this should be used only on allocated regions
182 * within another room.
184 static void build_small_room(int x0, int y0)
188 for (y = y0 - 1; y <= y0 + 1; y++)
190 place_inner_bold(y, x0 - 1);
191 place_inner_bold(y, x0 + 1);
194 for (x = x0 - 1; x <= x0 + 1; x++)
196 place_inner_bold(y0 - 1, x);
197 place_inner_bold(y0 + 1, x);
200 /* Place a secret door on one side */
203 case 0: place_secret_door(y0, x0 - 1, DOOR_DEFAULT); break;
204 case 1: place_secret_door(y0, x0 + 1, DOOR_DEFAULT); break;
205 case 2: place_secret_door(y0 - 1, x0, DOOR_DEFAULT); break;
206 case 3: place_secret_door(y0 + 1, x0, DOOR_DEFAULT); break;
209 /* Clear mimic type */
210 cave[y0][x0].mimic = 0;
212 /* Add inner open space */
213 place_floor_bold(y0, x0);
218 * »ØÄêÈϰϤËÄÌÏ©¤¬Ä̤äƤ¤¤ë¤³¤È¤ò³Îǧ¤·¤¿¾å¤Ç¾²¤ÇËä¤á¤ë
219 * This function tunnels around a room if it will cut off part of a cave system.
220 * @param x1 ÈϰϤκ¸Ã¼
221 * @param y1 ÈϰϤξåü
222 * @param x2 ÈϰϤα¦Ã¼
223 * @param y2 ÈϰϤβ¼Ã¼
226 static void check_room_boundary(int x1, int y1, int x2, int y2)
229 bool old_is_floor, new_is_floor;
235 old_is_floor = get_is_floor(x1 - 1, y1);
238 * Count the number of floor-wall boundaries around the room
239 * Note: diagonal squares are ignored since the player can move diagonally
240 * to bypass these if needed.
243 /* Above the top boundary */
244 for (x = x1; x <= x2; x++)
246 new_is_floor = get_is_floor(x, y1 - 1);
248 /* Increment counter if they are different */
249 if (new_is_floor != old_is_floor) count++;
251 old_is_floor = new_is_floor;
255 for (y = y1; y <= y2; y++)
257 new_is_floor = get_is_floor(x2 + 1, y);
259 /* increment counter if they are different */
260 if (new_is_floor != old_is_floor) count++;
262 old_is_floor = new_is_floor;
265 /* Bottom boundary */
266 for (x = x2; x >= x1; x--)
268 new_is_floor = get_is_floor(x, y2 + 1);
270 /* increment counter if they are different */
271 if (new_is_floor != old_is_floor) count++;
273 old_is_floor = new_is_floor;
277 for (y = y2; y >= y1; y--)
279 new_is_floor = get_is_floor(x1 - 1, y);
281 /* increment counter if they are different */
282 if (new_is_floor != old_is_floor) count++;
284 old_is_floor = new_is_floor;
287 /* If all the same, or only one connection exit. */
288 if (count <= 2) return;
291 /* Tunnel around the room so to prevent problems with caves */
292 for (y = y1; y <= y2; y++)
294 for (x = x1; x <= x2; x++)
304 * find_space()¤ÎͽÈ÷½èÍý¤È¤·¤ÆÉô²°¤ÎÀ¸À®¤¬²Äǽ¤«¤òȽÄꤹ¤ë /
305 * Helper function for find_space(). Is this a good location?
306 * @param block_high ÈϰϤι⤵
307 * @param block_wide ÈϰϤÎÉý
308 * @param block_y ÈϰϤξåü
309 * @param block_x ÈϰϤκ¸Ã¼
312 static bool find_space_aux(int blocks_high, int blocks_wide, int block_y, int block_x)
314 int by1, bx1, by2, bx2, by, bx;
316 /* Itty-bitty rooms must shift about within their rectangle */
319 if ((blocks_wide == 2) && (block_x % 3) == 2)
323 /* Rooms with width divisible by 3 must be fitted to a rectangle. */
324 else if ((blocks_wide % 3) == 0)
326 /* Must be aligned to the left edge of a 11x33 rectangle. */
327 if ((block_x % 3) != 0)
332 * Big rooms that do not have a width divisible by 3 must be
333 * aligned towards the edge of the dungeon closest to them.
337 /* Shift towards left edge of dungeon. */
338 if (block_x + (blocks_wide / 2) <= dun->col_rooms / 2)
340 if (((block_x % 3) == 2) && ((blocks_wide % 3) == 2))
342 if ((block_x % 3) == 1)
346 /* Shift toward right edge of dungeon. */
349 if (((block_x % 3) == 2) && ((blocks_wide % 3) == 2))
351 if ((block_x % 3) == 1)
359 by2 = block_y + blocks_high;
360 bx2 = block_x + blocks_wide;
362 /* Never run off the screen */
363 if ((by1 < 0) || (by2 > dun->row_rooms)) return FALSE;
364 if ((bx1 < 0) || (bx2 > dun->col_rooms)) return FALSE;
366 /* Verify available space */
367 for (by = by1; by < by2; by++)
369 for (bx = bx1; bx < bx2; bx++)
371 if (dun->room_map[by][bx])
378 /* This location is okay */
384 * @brief Éô²°À¸À®¤¬²Äǽ¤Ê¥¹¥Ú¡¼¥¹¤ò³ÎÊݤ¹¤ë / Find a good spot for the next room. -LM-
385 * @param y Éô²°¤ÎÀ¸À®¤¬²Äǽ¤ÊÃæ¿´YºÂɸ¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
386 * @param x Éô²°¤ÎÀ¸À®¤¬²Äǽ¤ÊÃæ¿´XºÂɸ¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
387 * @param height ³ÎÊݤ·¤¿¤¤Îΰè¤Î¹â¤µ
388 * @param width ³ÎÊݤ·¤¿¤¤Îΰè¤ÎÉý
389 * @return ½êÄê¤ÎÈϰϤ¬³ÎÊݤǤ¤¿¾ì¹çTRUE¤òÊÖ¤¹
391 * Find and allocate a free space in the dungeon large enough to hold\n
392 * the room calling this function.\n
394 * We allocate space in 11x11 blocks, but want to make sure that rooms\n
395 * align neatly on the standard screen. Therefore, we make them use\n
396 * blocks in few 11x33 rectangles as possible.\n
398 * Be careful to include the edges of the room in height and width!\n
400 * Return TRUE and values for the center of the room if all went well.\n
401 * Otherwise, return FALSE.\n
403 static bool find_space(int *y, int *x, int height, int width)
405 int candidates, pick;
406 int by, bx, by1, bx1, by2, bx2;
407 int block_y = 0, block_x = 0;
410 /* Find out how many blocks we need. */
411 int blocks_high = 1 + ((height - 1) / BLOCK_HGT);
412 int blocks_wide = 1 + ((width - 1) / BLOCK_WID);
414 /* There are no way to allocate such huge space */
415 if (dun->row_rooms < blocks_high) return FALSE;
416 if (dun->col_rooms < blocks_wide) return FALSE;
421 /* Count the number of valid places */
422 for (block_y = dun->row_rooms - blocks_high; block_y >= 0; block_y--)
424 for (block_x = dun->col_rooms - blocks_wide; block_x >= 0; block_x--)
426 if (find_space_aux(blocks_high, blocks_wide, block_y, block_x))
428 /* Find a valid place */
441 if (!(d_info[dungeon_type].flags1 & DF1_NO_CAVE))
443 /* Choose a random one */
444 pick = randint1(candidates);
447 /* NO_CAVE dungeon (Castle) */
450 /* Always choose the center one */
451 pick = candidates/2 + 1;
454 /* Pick up the choosen location */
455 for (block_y = dun->row_rooms - blocks_high; block_y >= 0; block_y--)
457 for (block_x = dun->col_rooms - blocks_wide; block_x >= 0; block_x--)
459 if (find_space_aux(blocks_high, blocks_wide, block_y, block_x))
463 /* This one is picked? */
474 by2 = block_y + blocks_high;
475 bx2 = block_x + blocks_wide;
478 * It is *extremely* important that the following calculation
479 * be *exactly* correct to prevent memory errors
482 /* Acquire the location of the room */
483 (*y) = ((by1 + by2) * BLOCK_HGT) / 2;
484 (*x) = ((bx1 + bx2) * BLOCK_WID) / 2;
486 /* Save the room location */
487 if (dun->cent_n < CENT_MAX)
489 dun->cent[dun->cent_n].y = *y;
490 dun->cent[dun->cent_n].x = *x;
494 /* Reserve some blocks. */
495 for (by = by1; by < by2; by++)
497 for (bx = bx1; bx < bx2; bx++)
499 dun->room_map[by][bx] = TRUE;
505 * Hack- See if room will cut off a cavern.
507 * If so, fix by tunneling outside the room in such a
508 * way as to connect the caves.
510 check_room_boundary(*x - width / 2 - 1, *y - height / 2 - 1, *x + (width - 1) / 2 + 1, *y + (height - 1) / 2 + 1);
520 * @brief ¥¿¥¤¥×1¤ÎÉô²°¡ÄÄ̾ï²ÄÊÑĹÊý·Á¤ÎÉô²°¤òÀ¸À®¤¹¤ë / Type 1 -- normal rectangular rooms
523 static bool build_type1(void)
525 int y, x, y2, x2, yval, xval;
526 int y1, x1, xsize, ysize;
532 bool curtain = (d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
533 one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 48 : 512);
535 /* Pick a room size */
544 /* Find and reserve some space in the dungeon. Get center of room. */
545 if (!find_space(&yval, &xval, ysize + 2, xsize + 2))
547 /* Limit to the minimum room size, and retry */
556 /* Find and reserve some space in the dungeon. Get center of room. */
557 if (!find_space(&yval, &xval, ysize + 2, xsize + 2)) return FALSE;
560 /* Choose lite or dark */
561 light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
564 /* Get corner values */
565 y1 = yval - ysize / 2;
566 x1 = xval - xsize / 2;
567 y2 = yval + (ysize - 1) / 2;
568 x2 = xval + (xsize - 1) / 2;
571 /* Place a full floor under the room */
572 for (y = y1 - 1; y <= y2 + 1; y++)
574 for (x = x1 - 1; x <= x2 + 1; x++)
577 place_floor_grid(c_ptr);
578 c_ptr->info |= (CAVE_ROOM);
579 if (light) c_ptr->info |= (CAVE_GLOW);
583 /* Walls around the room */
584 for (y = y1 - 1; y <= y2 + 1; y++)
586 c_ptr = &cave[y][x1 - 1];
587 place_outer_grid(c_ptr);
588 c_ptr = &cave[y][x2 + 1];
589 place_outer_grid(c_ptr);
591 for (x = x1 - 1; x <= x2 + 1; x++)
593 c_ptr = &cave[y1 - 1][x];
594 place_outer_grid(c_ptr);
595 c_ptr = &cave[y2 + 1][x];
596 place_outer_grid(c_ptr);
600 /* Hack -- Occasional curtained room */
601 if (curtain && (y2 - y1 > 2) && (x2 - x1 > 2))
603 for (y = y1; y <= y2; y++)
605 c_ptr = &cave[y][x1];
606 c_ptr->feat = feat_door[DOOR_CURTAIN].closed;
607 c_ptr->info &= ~(CAVE_MASK);
608 c_ptr = &cave[y][x2];
609 c_ptr->feat = feat_door[DOOR_CURTAIN].closed;
610 c_ptr->info &= ~(CAVE_MASK);
612 for (x = x1; x <= x2; x++)
614 c_ptr = &cave[y1][x];
615 c_ptr->feat = feat_door[DOOR_CURTAIN].closed;
616 c_ptr->info &= ~(CAVE_MASK);
617 c_ptr = &cave[y2][x];
618 c_ptr->feat = feat_door[DOOR_CURTAIN].closed;
619 c_ptr->info &= ~(CAVE_MASK);
624 /* Hack -- Occasional pillar room */
627 for (y = y1; y <= y2; y += 2)
629 for (x = x1; x <= x2; x += 2)
632 place_inner_grid(c_ptr);
637 /* Hack -- Occasional room with four pillars */
638 else if (one_in_(20))
640 if ((y1 + 4 < y2) && (x1 + 4 < x2))
642 c_ptr = &cave[y1 + 1][x1 + 1];
643 place_inner_grid(c_ptr);
645 c_ptr = &cave[y1 + 1][x2 - 1];
646 place_inner_grid(c_ptr);
648 c_ptr = &cave[y2 - 1][x1 + 1];
649 place_inner_grid(c_ptr);
651 c_ptr = &cave[y2 - 1][x2 - 1];
652 place_inner_grid(c_ptr);
656 /* Hack -- Occasional ragged-edge room */
657 else if (one_in_(50))
659 for (y = y1 + 2; y <= y2 - 2; y += 2)
661 c_ptr = &cave[y][x1];
662 place_inner_grid(c_ptr);
663 c_ptr = &cave[y][x2];
664 place_inner_grid(c_ptr);
666 for (x = x1 + 2; x <= x2 - 2; x += 2)
668 c_ptr = &cave[y1][x];
669 place_inner_grid(c_ptr);
670 c_ptr = &cave[y2][x];
671 place_inner_grid(c_ptr);
674 /* Hack -- Occasional divided room */
675 else if (one_in_(50))
677 bool curtain2 = (d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
678 one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 2 : 128);
680 if (randint1(100) < 50)
682 /* Horizontal wall */
683 for (x = x1; x <= x2; x++)
685 place_inner_bold(yval, x);
686 if (curtain2) cave[yval][x].feat = feat_door[DOOR_CURTAIN].closed;
689 /* Prevent edge of wall from being tunneled */
690 place_solid_bold(yval, x1 - 1);
691 place_solid_bold(yval, x2 + 1);
696 for (y = y1; y <= y2; y++)
698 place_inner_bold(y, xval);
699 if (curtain2) cave[y][xval].feat = feat_door[DOOR_CURTAIN].closed;
702 /* Prevent edge of wall from being tunneled */
703 place_solid_bold(y1 - 1, xval);
704 place_solid_bold(y2 + 1, xval);
707 place_random_door(yval, xval, TRUE);
708 if (curtain2) cave[yval][xval].feat = feat_door[DOOR_CURTAIN].closed;
715 * @brief ¥¿¥¤¥×2¤ÎÉô²°¡ÄÆó½ÅĹÊý·Á¤ÎÉô²°¤òÀ¸À®¤¹¤ë / Type 2 -- Overlapping rectangular rooms
718 static bool build_type2(void)
720 int y, x, xval, yval;
721 int y1a, x1a, y2a, x2a;
722 int y1b, x1b, y2b, x2b;
726 /* Find and reserve some space in the dungeon. Get center of room. */
727 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
729 /* Choose lite or dark */
730 light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
732 /* Determine extents of the first room */
733 y1a = yval - randint1(4);
734 y2a = yval + randint1(3);
735 x1a = xval - randint1(11);
736 x2a = xval + randint1(10);
738 /* Determine extents of the second room */
739 y1b = yval - randint1(3);
740 y2b = yval + randint1(4);
741 x1b = xval - randint1(10);
742 x2b = xval + randint1(11);
745 /* Place a full floor for room "a" */
746 for (y = y1a - 1; y <= y2a + 1; y++)
748 for (x = x1a - 1; x <= x2a + 1; x++)
751 place_floor_grid(c_ptr);
752 c_ptr->info |= (CAVE_ROOM);
753 if (light) c_ptr->info |= (CAVE_GLOW);
757 /* Place a full floor for room "b" */
758 for (y = y1b - 1; y <= y2b + 1; y++)
760 for (x = x1b - 1; x <= x2b + 1; x++)
763 place_floor_grid(c_ptr);
764 c_ptr->info |= (CAVE_ROOM);
765 if (light) c_ptr->info |= (CAVE_GLOW);
770 /* Place the walls around room "a" */
771 for (y = y1a - 1; y <= y2a + 1; y++)
773 c_ptr = &cave[y][x1a - 1];
774 place_outer_grid(c_ptr);
775 c_ptr = &cave[y][x2a + 1];
776 place_outer_grid(c_ptr);
778 for (x = x1a - 1; x <= x2a + 1; x++)
780 c_ptr = &cave[y1a - 1][x];
781 place_outer_grid(c_ptr);
782 c_ptr = &cave[y2a + 1][x];
783 place_outer_grid(c_ptr);
786 /* Place the walls around room "b" */
787 for (y = y1b - 1; y <= y2b + 1; y++)
789 c_ptr = &cave[y][x1b - 1];
790 place_outer_grid(c_ptr);
791 c_ptr = &cave[y][x2b + 1];
792 place_outer_grid(c_ptr);
794 for (x = x1b - 1; x <= x2b + 1; x++)
796 c_ptr = &cave[y1b - 1][x];
797 place_outer_grid(c_ptr);
798 c_ptr = &cave[y2b + 1][x];
799 place_outer_grid(c_ptr);
804 /* Replace the floor for room "a" */
805 for (y = y1a; y <= y2a; y++)
807 for (x = x1a; x <= x2a; x++)
810 place_floor_grid(c_ptr);
814 /* Replace the floor for room "b" */
815 for (y = y1b; y <= y2b; y++)
817 for (x = x1b; x <= x2b; x++)
820 place_floor_grid(c_ptr);
830 * @brief ¥¿¥¤¥×2¤ÎÉô²°¡Ä½½»ú·¿¤ÎÉô²°¤òÀ¸À®¤¹¤ë / Type 3 -- Cross shaped rooms
833 * Builds a room at a row, column coordinate\n
835 * Room "a" runs north/south, and Room "b" runs east/east\n
836 * So the "central pillar" runs from x1a, y1b to x2a, y2b.\n
838 * Note that currently, the "center" is always 3x3, but I think that\n
839 * the code below will work (with "bounds checking") for 5x5, or even\n
840 * for unsymetric values like 4x3 or 5x3 or 3x4 or 3x5, or even larger.\n
842 static bool build_type3(void)
844 int y, x, dy, dx, wy, wx;
845 int y1a, x1a, y2a, x2a;
846 int y1b, x1b, y2b, x2b;
852 /* Find and reserve some space in the dungeon. Get center of room. */
853 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
856 /* Choose lite or dark */
857 light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
859 /* For now, always 3x3 */
862 /* Pick max vertical size (at most 4) */
863 dy = rand_range(3, 4);
865 /* Pick max horizontal size (at most 15) */
866 dx = rand_range(3, 11);
869 /* Determine extents of the north/south room */
875 /* Determine extents of the east/west room */
882 /* Place a full floor for room "a" */
883 for (y = y1a - 1; y <= y2a + 1; y++)
885 for (x = x1a - 1; x <= x2a + 1; x++)
888 place_floor_grid(c_ptr);
889 c_ptr->info |= (CAVE_ROOM);
890 if (light) c_ptr->info |= (CAVE_GLOW);
894 /* Place a full floor for room "b" */
895 for (y = y1b - 1; y <= y2b + 1; y++)
897 for (x = x1b - 1; x <= x2b + 1; x++)
900 place_floor_grid(c_ptr);
901 c_ptr->info |= (CAVE_ROOM);
902 if (light) c_ptr->info |= (CAVE_GLOW);
907 /* Place the walls around room "a" */
908 for (y = y1a - 1; y <= y2a + 1; y++)
910 c_ptr = &cave[y][x1a - 1];
911 place_outer_grid(c_ptr);
912 c_ptr = &cave[y][x2a + 1];
913 place_outer_grid(c_ptr);
915 for (x = x1a - 1; x <= x2a + 1; x++)
917 c_ptr = &cave[y1a - 1][x];
918 place_outer_grid(c_ptr);
919 c_ptr = &cave[y2a + 1][x];
920 place_outer_grid(c_ptr);
923 /* Place the walls around room "b" */
924 for (y = y1b - 1; y <= y2b + 1; y++)
926 c_ptr = &cave[y][x1b - 1];
927 place_outer_grid(c_ptr);
928 c_ptr = &cave[y][x2b + 1];
929 place_outer_grid(c_ptr);
931 for (x = x1b - 1; x <= x2b + 1; x++)
933 c_ptr = &cave[y1b - 1][x];
934 place_outer_grid(c_ptr);
935 c_ptr = &cave[y2b + 1][x];
936 place_outer_grid(c_ptr);
940 /* Replace the floor for room "a" */
941 for (y = y1a; y <= y2a; y++)
943 for (x = x1a; x <= x2a; x++)
946 place_floor_grid(c_ptr);
950 /* Replace the floor for room "b" */
951 for (y = y1b; y <= y2b; y++)
953 for (x = x1b; x <= x2b; x++)
956 place_floor_grid(c_ptr);
962 /* Special features (3/4) */
965 /* Large solid middle pillar */
968 for (y = y1b; y <= y2b; y++)
970 for (x = x1a; x <= x2a; x++)
973 place_inner_grid(c_ptr);
979 /* Inner treasure vault */
982 /* Build the vault */
983 for (y = y1b; y <= y2b; y++)
985 c_ptr = &cave[y][x1a];
986 place_inner_grid(c_ptr);
987 c_ptr = &cave[y][x2a];
988 place_inner_grid(c_ptr);
990 for (x = x1a; x <= x2a; x++)
992 c_ptr = &cave[y1b][x];
993 place_inner_grid(c_ptr);
994 c_ptr = &cave[y2b][x];
995 place_inner_grid(c_ptr);
998 /* Place a secret door on the inner room */
1001 case 0: place_secret_door(y1b, xval, DOOR_DEFAULT); break;
1002 case 1: place_secret_door(y2b, xval, DOOR_DEFAULT); break;
1003 case 2: place_secret_door(yval, x1a, DOOR_DEFAULT); break;
1004 case 3: place_secret_door(yval, x2a, DOOR_DEFAULT); break;
1007 /* Place a treasure in the vault */
1008 place_object(yval, xval, 0L);
1010 /* Let's guard the treasure well */
1011 vault_monsters(yval, xval, randint0(2) + 3);
1013 /* Traps naturally */
1014 vault_traps(yval, xval, 4, 4, randint0(3) + 2);
1019 /* Something else */
1022 /* Occasionally pinch the center shut */
1025 /* Pinch the east/west sides */
1026 for (y = y1b; y <= y2b; y++)
1028 if (y == yval) continue;
1029 c_ptr = &cave[y][x1a - 1];
1030 place_inner_grid(c_ptr);
1031 c_ptr = &cave[y][x2a + 1];
1032 place_inner_grid(c_ptr);
1035 /* Pinch the north/south sides */
1036 for (x = x1a; x <= x2a; x++)
1038 if (x == xval) continue;
1039 c_ptr = &cave[y1b - 1][x];
1040 place_inner_grid(c_ptr);
1041 c_ptr = &cave[y2b + 1][x];
1042 place_inner_grid(c_ptr);
1045 /* Sometimes shut using secret doors */
1048 int door_type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
1049 one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
1050 ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
1052 place_secret_door(yval, x1a - 1, door_type);
1053 place_secret_door(yval, x2a + 1, door_type);
1054 place_secret_door(y1b - 1, xval, door_type);
1055 place_secret_door(y2b + 1, xval, door_type);
1059 /* Occasionally put a "plus" in the center */
1060 else if (one_in_(3))
1062 c_ptr = &cave[yval][xval];
1063 place_inner_grid(c_ptr);
1064 c_ptr = &cave[y1b][xval];
1065 place_inner_grid(c_ptr);
1066 c_ptr = &cave[y2b][xval];
1067 place_inner_grid(c_ptr);
1068 c_ptr = &cave[yval][x1a];
1069 place_inner_grid(c_ptr);
1070 c_ptr = &cave[yval][x2a];
1071 place_inner_grid(c_ptr);
1074 /* Occasionally put a pillar in the center */
1075 else if (one_in_(3))
1077 c_ptr = &cave[yval][xval];
1078 place_inner_grid(c_ptr);
1090 * @brief ¥¿¥¤¥×4¤ÎÉô²°¡Ä¸ÇÄꥵ¥¤¥º¤ÎÆó½Å¹½Â¤Éô²°¤òÀ¸À®¤¹¤ë / Type 4 -- Large room with inner features
1093 * Possible sub-types:\n
1094 * 1 - Just an inner room with one door\n
1095 * 2 - An inner room within an inner room\n
1096 * 3 - An inner room with pillar(s)\n
1097 * 4 - Inner room has a maze\n
1098 * 5 - A set of four inner rooms\n
1100 static bool build_type4(void)
1103 int y2, x2, tmp, yval, xval;
1108 /* Find and reserve some space in the dungeon. Get center of room. */
1109 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
1111 /* Choose lite or dark */
1112 light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
1120 /* Place a full floor under the room */
1121 for (y = y1 - 1; y <= y2 + 1; y++)
1123 for (x = x1 - 1; x <= x2 + 1; x++)
1125 c_ptr = &cave[y][x];
1126 place_floor_grid(c_ptr);
1127 c_ptr->info |= (CAVE_ROOM);
1128 if (light) c_ptr->info |= (CAVE_GLOW);
1133 for (y = y1 - 1; y <= y2 + 1; y++)
1135 c_ptr = &cave[y][x1 - 1];
1136 place_outer_grid(c_ptr);
1137 c_ptr = &cave[y][x2 + 1];
1138 place_outer_grid(c_ptr);
1140 for (x = x1 - 1; x <= x2 + 1; x++)
1142 c_ptr = &cave[y1 - 1][x];
1143 place_outer_grid(c_ptr);
1144 c_ptr = &cave[y2 + 1][x];
1145 place_outer_grid(c_ptr);
1149 /* The inner room */
1155 /* The inner walls */
1156 for (y = y1 - 1; y <= y2 + 1; y++)
1158 c_ptr = &cave[y][x1 - 1];
1159 place_inner_grid(c_ptr);
1160 c_ptr = &cave[y][x2 + 1];
1161 place_inner_grid(c_ptr);
1163 for (x = x1 - 1; x <= x2 + 1; x++)
1165 c_ptr = &cave[y1 - 1][x];
1166 place_inner_grid(c_ptr);
1167 c_ptr = &cave[y2 + 1][x];
1168 place_inner_grid(c_ptr);
1172 /* Inner room variations */
1173 switch (randint1(5))
1175 /* Just an inner room with a monster */
1178 /* Place a secret door */
1179 switch (randint1(4))
1181 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
1182 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
1183 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
1184 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
1187 /* Place a monster in the room */
1188 vault_monsters(yval, xval, 1);
1193 /* Treasure Vault (with a door) */
1196 /* Place a secret door */
1197 switch (randint1(4))
1199 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
1200 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
1201 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
1202 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
1205 /* Place another inner room */
1206 for (y = yval - 1; y <= yval + 1; y++)
1208 for (x = xval - 1; x <= xval + 1; x++)
1210 if ((x == xval) && (y == yval)) continue;
1211 c_ptr = &cave[y][x];
1212 place_inner_grid(c_ptr);
1216 /* Place a locked door on the inner room */
1217 switch (randint1(4))
1219 case 1: place_locked_door(yval - 1, xval); break;
1220 case 2: place_locked_door(yval + 1, xval); break;
1221 case 3: place_locked_door(yval, xval - 1); break;
1222 case 4: place_locked_door(yval, xval + 1); break;
1225 /* Monsters to guard the "treasure" */
1226 vault_monsters(yval, xval, randint1(3) + 2);
1229 if (randint0(100) < 80)
1231 place_object(yval, xval, 0L);
1237 place_random_stairs(yval, xval);
1240 /* Traps to protect the treasure */
1241 vault_traps(yval, xval, 4, 10, 2 + randint1(3));
1246 /* Inner pillar(s). */
1249 /* Place a secret door */
1250 switch (randint1(4))
1252 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
1253 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
1254 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
1255 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
1258 /* Large Inner Pillar */
1259 for (y = yval - 1; y <= yval + 1; y++)
1261 for (x = xval - 1; x <= xval + 1; x++)
1263 c_ptr = &cave[y][x];
1264 place_inner_grid(c_ptr);
1268 /* Occasionally, two more Large Inner Pillars */
1272 for (y = yval - 1; y <= yval + 1; y++)
1274 for (x = xval - 5 - tmp; x <= xval - 3 - tmp; x++)
1276 c_ptr = &cave[y][x];
1277 place_inner_grid(c_ptr);
1279 for (x = xval + 3 + tmp; x <= xval + 5 + tmp; x++)
1281 c_ptr = &cave[y][x];
1282 place_inner_grid(c_ptr);
1287 /* Occasionally, some Inner rooms */
1290 int door_type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
1291 one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
1292 ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
1294 /* Long horizontal walls */
1295 for (x = xval - 5; x <= xval + 5; x++)
1297 c_ptr = &cave[yval - 1][x];
1298 place_inner_grid(c_ptr);
1299 c_ptr = &cave[yval + 1][x];
1300 place_inner_grid(c_ptr);
1303 /* Close off the left/right edges */
1304 c_ptr = &cave[yval][xval - 5];
1305 place_inner_grid(c_ptr);
1306 c_ptr = &cave[yval][xval + 5];
1307 place_inner_grid(c_ptr);
1309 /* Secret doors (random top/bottom) */
1310 place_secret_door(yval - 3 + (randint1(2) * 2), xval - 3, door_type);
1311 place_secret_door(yval - 3 + (randint1(2) * 2), xval + 3, door_type);
1314 vault_monsters(yval, xval - 2, randint1(2));
1315 vault_monsters(yval, xval + 2, randint1(2));
1318 if (one_in_(3)) place_object(yval, xval - 2, 0L);
1319 if (one_in_(3)) place_object(yval, xval + 2, 0L);
1328 /* Place a secret door */
1329 switch (randint1(4))
1331 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
1332 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
1333 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
1334 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
1337 /* Maze (really a checkerboard) */
1338 for (y = y1; y <= y2; y++)
1340 for (x = x1; x <= x2; x++)
1344 c_ptr = &cave[y][x];
1345 place_inner_grid(c_ptr);
1350 /* Monsters just love mazes. */
1351 vault_monsters(yval, xval - 5, randint1(3));
1352 vault_monsters(yval, xval + 5, randint1(3));
1354 /* Traps make them entertaining. */
1355 vault_traps(yval, xval - 3, 2, 8, randint1(3));
1356 vault_traps(yval, xval + 3, 2, 8, randint1(3));
1358 /* Mazes should have some treasure too. */
1359 vault_objects(yval, xval, 3);
1364 /* Four small rooms. */
1367 int door_type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
1368 one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
1369 ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
1372 for (y = y1; y <= y2; y++)
1374 c_ptr = &cave[y][xval];
1375 place_inner_grid(c_ptr);
1377 for (x = x1; x <= x2; x++)
1379 c_ptr = &cave[yval][x];
1380 place_inner_grid(c_ptr);
1383 /* Doors into the rooms */
1384 if (randint0(100) < 50)
1386 int i = randint1(10);
1387 place_secret_door(y1 - 1, xval - i, door_type);
1388 place_secret_door(y1 - 1, xval + i, door_type);
1389 place_secret_door(y2 + 1, xval - i, door_type);
1390 place_secret_door(y2 + 1, xval + i, door_type);
1394 int i = randint1(3);
1395 place_secret_door(yval + i, x1 - 1, door_type);
1396 place_secret_door(yval - i, x1 - 1, door_type);
1397 place_secret_door(yval + i, x2 + 1, door_type);
1398 place_secret_door(yval - i, x2 + 1, door_type);
1401 /* Treasure, centered at the center of the cross */
1402 vault_objects(yval, xval, 2 + randint1(2));
1404 /* Gotta have some monsters. */
1405 vault_monsters(yval + 1, xval - 4, randint1(4));
1406 vault_monsters(yval + 1, xval + 4, randint1(4));
1407 vault_monsters(yval - 1, xval - 4, randint1(4));
1408 vault_monsters(yval - 1, xval + 4, randint1(4));
1420 * vault¤ËÇÛÃÖ²Äǽ¤Ê¥â¥ó¥¹¥¿¡¼¤Î¾ò·ï¤ò»ØÄꤹ¤ë¥Þ¥¯¥í / Monster validation macro
1422 * Line 1 -- forbid town monsters
1423 * Line 2 -- forbid uniques
1424 * Line 3 -- forbid aquatic monsters
1426 #define vault_monster_okay(I) \
1427 (mon_hook_dungeon(I) && \
1428 !(r_info[I].flags1 & RF1_UNIQUE) && \
1429 !(r_info[I].flags7 & RF7_UNIQUE2) && \
1430 !(r_info[I].flagsr & RFR_RES_ALL) && \
1431 !(r_info[I].flags7 & RF7_AQUATIC))
1434 /*! Ä̾ïpitÀ¸À®»þ¤Î¥â¥ó¥¹¥¿¡¼¤Î¹½À®¾ò·ïID / Race index for "monster pit (clone)" */
1435 static int vault_aux_race;
1437 /*! ñ°ì¥·¥ó¥Ü¥ëpitÀ¸À®»þ¤Î»ØÄꥷ¥ó¥Ü¥ë / Race index for "monster pit (symbol clone)" */
1438 static char vault_aux_char;
1440 /*! ¥Ö¥ì¥¹Â°À¤Ë´ð¤Å¤¯¥É¥é¥´¥ópitÀ¸À®»þ¾ò·ï¥Þ¥¹¥¯ / Breath mask for "monster pit (dragon)" */
1441 static u32b vault_aux_dragon_mask4;
1445 * @brief ¥â¥ó¥¹¥¿¡¼¤¬VaultÀ¸À®¤ÎºÇÄãɬÍ×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1446 * Helper monster selection function
1447 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1448 * @return VaultÀ¸À®¤ÎºÇÄãɬÍ×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1450 static bool vault_aux_simple(int r_idx)
1453 return (vault_monster_okay(r_idx));
1458 * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥¼¥ê¡¼nest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1459 * Helper function for "monster nest (jelly)"
1460 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1461 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1463 static bool vault_aux_jelly(int r_idx)
1465 monster_race *r_ptr = &r_info[r_idx];
1467 /* Validate the monster */
1468 if (!vault_monster_okay(r_idx)) return (FALSE);
1470 if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
1472 /* Also decline evil jellies (like death molds and shoggoths) */
1473 if (r_ptr->flags3 & (RF3_EVIL)) return (FALSE);
1475 /* Require icky thing, jelly, mold, or mushroom */
1476 if (!my_strchr("ijm,", r_ptr->d_char)) return (FALSE);
1483 * @brief ¥â¥ó¥¹¥¿¡¼¤¬Æ°Êªnest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1484 * Helper function for "monster nest (animal)"
1485 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1486 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1488 static bool vault_aux_animal(int r_idx)
1490 monster_race *r_ptr = &r_info[r_idx];
1492 /* Validate the monster */
1493 if (!vault_monster_okay(r_idx)) return (FALSE);
1495 /* Require "animal" flag */
1496 if (!(r_ptr->flags3 & (RF3_ANIMAL))) return (FALSE);
1504 * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥¢¥ó¥Ç¥Ã¥Énest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1505 * Helper function for "monster nest (undead)"
1506 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1507 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1509 static bool vault_aux_undead(int r_idx)
1511 monster_race *r_ptr = &r_info[r_idx];
1513 /* Validate the monster */
1514 if (!vault_monster_okay(r_idx)) return (FALSE);
1516 /* Require Undead */
1517 if (!(r_ptr->flags3 & (RF3_UNDEAD))) return (FALSE);
1524 * @brief ¥â¥ó¥¹¥¿¡¼¤¬À»Æ²nest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1525 * Helper function for "monster nest (chapel)"
1526 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1527 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1529 static bool vault_aux_chapel_g(int r_idx)
1531 static int chapel_list[] = {
1532 MON_NOV_PRIEST, MON_NOV_PALADIN, MON_NOV_PRIEST_G, MON_NOV_PALADIN_G,
1533 MON_PRIEST, MON_JADE_MONK, MON_IVORY_MONK, MON_ULTRA_PALADIN,
1534 MON_EBONY_MONK, MON_W_KNIGHT, MON_KNI_TEMPLAR, MON_PALADIN,
1539 monster_race *r_ptr = &r_info[r_idx];
1541 /* Validate the monster */
1542 if (!vault_monster_okay(r_idx)) return (FALSE);
1544 if (r_ptr->flags3 & (RF3_EVIL)) return (FALSE);
1545 if ((r_idx == MON_A_GOLD) || (r_idx == MON_A_SILVER)) return (FALSE);
1547 /* Require "priest" or Angel */
1549 if (r_ptr->d_char == 'A') return TRUE;
1551 for (i = 0; chapel_list[i]; i++)
1552 if (r_idx == chapel_list[i]) return TRUE;
1558 * @brief ¥â¥ó¥¹¥¿¡¼¤¬¸¤¾®²°nest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1559 * Helper function for "monster nest (kennel)"
1560 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1561 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1563 static bool vault_aux_kennel(int r_idx)
1565 monster_race *r_ptr = &r_info[r_idx];
1567 /* Validate the monster */
1568 if (!vault_monster_okay(r_idx)) return (FALSE);
1570 /* Require a Zephyr Hound or a dog */
1571 if (!my_strchr("CZ", r_ptr->d_char)) return (FALSE);
1578 * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥ß¥ß¥Ã¥¯nest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1579 * Helper function for "monster nest (mimic)"
1580 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1581 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1583 static bool vault_aux_mimic(int r_idx)
1585 monster_race *r_ptr = &r_info[r_idx];
1587 /* Validate the monster */
1588 if (!vault_monster_okay(r_idx)) return (FALSE);
1591 if (!my_strchr("!$&(/=?[\\|", r_ptr->d_char)) return (FALSE);
1598 * @brief ¥â¥ó¥¹¥¿¡¼¤¬Ã±°ì¥¯¥í¡¼¥ónest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1599 * Helper function for "monster nest (clone)"
1600 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1601 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1603 static bool vault_aux_clone(int r_idx)
1605 /* Validate the monster */
1606 if (!vault_monster_okay(r_idx)) return (FALSE);
1608 return (r_idx == vault_aux_race);
1613 * @brief ¥â¥ó¥¹¥¿¡¼¤¬¼Ù°Â°À¥·¥ó¥Ü¥ë¥¯¥í¡¼¥ónest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1614 * Helper function for "monster nest (symbol clone)"
1615 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1616 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1618 static bool vault_aux_symbol_e(int r_idx)
1620 monster_race *r_ptr = &r_info[r_idx];
1622 /* Validate the monster */
1623 if (!vault_monster_okay(r_idx)) return (FALSE);
1625 if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
1627 if (r_ptr->flags3 & (RF3_GOOD)) return (FALSE);
1629 /* Decline incorrect symbol */
1630 if (r_ptr->d_char != vault_aux_char) return (FALSE);
1638 * @brief ¥â¥ó¥¹¥¿¡¼¤¬Á±ÎÉ°À¥·¥ó¥Ü¥ë¥¯¥í¡¼¥ónest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1639 * Helper function for "monster nest (symbol clone)"
1640 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1641 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1643 static bool vault_aux_symbol_g(int r_idx)
1645 monster_race *r_ptr = &r_info[r_idx];
1647 /* Validate the monster */
1648 if (!vault_monster_okay(r_idx)) return (FALSE);
1650 if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
1652 if (r_ptr->flags3 & (RF3_EVIL)) return (FALSE);
1654 /* Decline incorrect symbol */
1655 if (r_ptr->d_char != vault_aux_char) return (FALSE);
1663 * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥ª¡¼¥¯pit¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1664 * Helper function for "monster pit (orc)"
1665 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1666 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1668 static bool vault_aux_orc(int r_idx)
1670 monster_race *r_ptr = &r_info[r_idx];
1672 /* Validate the monster */
1673 if (!vault_monster_okay(r_idx)) return (FALSE);
1676 if (!(r_ptr->flags3 & RF3_ORC)) return (FALSE);
1678 /* Decline undead */
1679 if (r_ptr->flags3 & RF3_UNDEAD) return (FALSE);
1687 * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥È¥í¥ëpit¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1688 * Helper function for "monster pit (troll)"
1689 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1690 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1692 static bool vault_aux_troll(int r_idx)
1694 monster_race *r_ptr = &r_info[r_idx];
1696 /* Validate the monster */
1697 if (!vault_monster_okay(r_idx)) return (FALSE);
1700 if (!(r_ptr->flags3 & RF3_TROLL)) return (FALSE);
1702 /* Decline undead */
1703 if (r_ptr->flags3 & RF3_UNDEAD) return (FALSE);
1711 * @brief ¥â¥ó¥¹¥¿¡¼¤¬µð¿Ípit¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1712 * Helper function for "monster pit (giant)"
1713 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1714 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1716 static bool vault_aux_giant(int r_idx)
1718 monster_race *r_ptr = &r_info[r_idx];
1720 /* Validate the monster */
1721 if (!vault_monster_okay(r_idx)) return (FALSE);
1724 if (!(r_ptr->flags3 & RF3_GIANT)) return (FALSE);
1726 if (r_ptr->flags3 & RF3_GOOD) return (FALSE);
1728 /* Decline undead */
1729 if (r_ptr->flags3 & RF3_UNDEAD) return (FALSE);
1737 * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥É¥é¥´¥ópit¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1738 * Helper function for "monster pit (dragon)"
1739 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1740 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1742 static bool vault_aux_dragon(int r_idx)
1744 monster_race *r_ptr = &r_info[r_idx];
1746 /* Validate the monster */
1747 if (!vault_monster_okay(r_idx)) return (FALSE);
1749 /* Require dragon */
1750 if (!(r_ptr->flags3 & RF3_DRAGON)) return (FALSE);
1752 /* Hack -- Require correct "breath attack" */
1753 if (r_ptr->flags4 != vault_aux_dragon_mask4) return (FALSE);
1755 /* Decline undead */
1756 if (r_ptr->flags3 & RF3_UNDEAD) return (FALSE);
1764 * @brief ¥â¥ó¥¹¥¿¡¼¤¬°Ëâpit¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1765 * Helper function for "monster pit (demon)"
1766 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1767 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1769 static bool vault_aux_demon(int r_idx)
1771 monster_race *r_ptr = &r_info[r_idx];
1773 /* Validate the monster */
1774 if (!vault_monster_okay(r_idx)) return (FALSE);
1776 if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
1779 if (!(r_ptr->flags3 & RF3_DEMON)) return (FALSE);
1787 * @brief ¥â¥ó¥¹¥¿¡¼¤¬¶¸µ¤pit¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1788 * Helper function for "monster pit (lovecraftian)"
1789 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1790 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1792 static bool vault_aux_cthulhu(int r_idx)
1794 monster_race *r_ptr = &r_info[r_idx];
1796 /* Validate the monster */
1797 if (!vault_monster_okay(r_idx)) return (FALSE);
1799 if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
1801 /* Require eldritch horror */
1802 if (!(r_ptr->flags2 & (RF2_ELDRITCH_HORROR))) return (FALSE);
1810 * @brief pit/nest¤Î´ð½à¤È¤Ê¤ëñ¼ï¥â¥ó¥¹¥¿¡¼¤ò·è¤á¤ë /
1813 static void vault_prep_clone(void)
1815 /* Apply the monster restriction */
1816 get_mon_num_prep(vault_aux_simple, NULL);
1818 /* Pick a race to clone */
1819 vault_aux_race = get_mon_num(dun_level + 10);
1821 /* Remove the monster restriction */
1822 get_mon_num_prep(NULL, NULL);
1827 * @brief pit/nest¤Î´ð½à¤È¤Ê¤ë¥â¥ó¥¹¥¿¡¼¥·¥ó¥Ü¥ë¤ò·è¤á¤ë /
1830 static void vault_prep_symbol(void)
1834 /* Apply the monster restriction */
1835 get_mon_num_prep(vault_aux_simple, NULL);
1837 /* Pick a race to clone */
1838 r_idx = get_mon_num(dun_level + 10);
1840 /* Remove the monster restriction */
1841 get_mon_num_prep(NULL, NULL);
1843 /* Extract the symbol */
1844 vault_aux_char = r_info[r_idx].d_char;
1848 * @brief pit/nest¤Î´ð½à¤È¤Ê¤ë¥É¥é¥´¥ó¤Î¼ïÎà¤ò·è¤á¤ë /
1851 static void vault_prep_dragon(void)
1853 /* Pick dragon type */
1854 switch (randint0(6))
1859 /* Restrict dragon breath type */
1860 vault_aux_dragon_mask4 = RF4_BR_ACID;
1869 /* Restrict dragon breath type */
1870 vault_aux_dragon_mask4 = RF4_BR_ELEC;
1879 /* Restrict dragon breath type */
1880 vault_aux_dragon_mask4 = RF4_BR_FIRE;
1889 /* Restrict dragon breath type */
1890 vault_aux_dragon_mask4 = RF4_BR_COLD;
1899 /* Restrict dragon breath type */
1900 vault_aux_dragon_mask4 = RF4_BR_POIS;
1909 /* Restrict dragon breath type */
1910 vault_aux_dragon_mask4 = (RF4_BR_ACID | RF4_BR_ELEC |
1911 RF4_BR_FIRE | RF4_BR_COLD |
1922 * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥À¡¼¥¯¥¨¥ë¥Õpit¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1923 * Helper function for "monster pit (dark elf)"
1924 * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
1925 * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
1927 static bool vault_aux_dark_elf(int r_idx)
1930 static int dark_elf_list[] =
1932 MON_D_ELF, MON_D_ELF_MAGE, MON_D_ELF_WARRIOR, MON_D_ELF_PRIEST,
1933 MON_D_ELF_LORD, MON_D_ELF_WARLOCK, MON_D_ELF_DRUID, MON_NIGHTBLADE,
1934 MON_D_ELF_SORC, MON_D_ELF_SHADE, 0,
1937 /* Validate the monster */
1938 if (!vault_monster_okay(r_idx)) return FALSE;
1940 /* Require dark elves */
1941 for (i = 0; dark_elf_list[i]; i++)
1942 if (r_idx == dark_elf_list[i]) return TRUE;
1948 /*! pit/nest·¿¾ðÊó¤Îtypedef */
1949 typedef struct vault_aux_type vault_aux_type;
1951 /*! pit/nest·¿¾ðÊó¤Î¹½Â¤ÂÎÄêµÁ */
1952 struct vault_aux_type
1955 bool (*hook_func)(int r_idx);
1956 void (*prep_func)(void);
1962 * @brief ¥À¥ó¥¸¥ç¥óËè¤Ë»ØÄꤵ¤ì¤¿¥Ô¥Ã¥ÈÇÛÎó¤ò´ð½à¤Ë¥é¥ó¥À¥à¤Êpit/nest¥¿¥¤¥×¤ò·è¤á¤ë
1963 * @param l_ptr ÁªÂò¤µ¤ì¤¿pit/nest¾ðÊó¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
1964 * @param allow_flag_mask À¸À®¤¬µö¤µ¤ì¤ëpit/nest¤Î¥Ó¥Ã¥ÈÇÛÎó
1965 * @return ÁªÂò¤µ¤ì¤¿pit/nest¤ÎID¡¢ÁªÂò¼ºÇÔ¤·¤¿¾ì¹ç-1¤òÊÖ¤¹¡£
1967 static int pick_vault_type(vault_aux_type *l_ptr, s16b allow_flag_mask)
1969 int tmp, total, count;
1971 vault_aux_type *n_ptr;
1973 /* Calculate the total possibilities */
1974 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
1977 if (!n_ptr->name) break;
1979 /* Ignore excessive depth */
1980 if (n_ptr->level > dun_level) continue;
1982 /* Not matched with pit/nest flag */
1983 if (!(allow_flag_mask & (1L << count))) continue;
1985 /* Count this possibility */
1986 total += n_ptr->chance * MAX_DEPTH / (MIN(dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
1989 /* Pick a random type */
1990 tmp = randint0(total);
1992 /* Find this type */
1993 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
1996 if (!n_ptr->name) break;
1998 /* Ignore excessive depth */
1999 if (n_ptr->level > dun_level) continue;
2001 /* Not matched with pit/nest flag */
2002 if (!(allow_flag_mask & (1L << count))) continue;
2004 /* Count this possibility */
2005 total += n_ptr->chance * MAX_DEPTH / (MIN(dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
2007 /* Found the type */
2008 if (tmp < total) break;
2011 return n_ptr->name ? count : -1;
2014 /*!nest¾ðÊó¥Æ¡¼¥Ö¥ë*/
2015 static vault_aux_type nest_types[] =
2018 {"¥¯¥í¡¼¥ó", vault_aux_clone, vault_prep_clone, 5, 3},
2019 {"¥¼¥ê¡¼", vault_aux_jelly, NULL, 5, 6},
2020 {"¥·¥ó¥Ü¥ë(Á±)", vault_aux_symbol_g, vault_prep_symbol, 25, 2},
2021 {"¥·¥ó¥Ü¥ë(°)", vault_aux_symbol_e, vault_prep_symbol, 25, 2},
2022 {"¥ß¥ß¥Ã¥¯", vault_aux_mimic, NULL, 30, 4},
2023 {"¶¸µ¤", vault_aux_cthulhu, NULL, 70, 2},
2024 {"¸¤¾®²°", vault_aux_kennel, NULL, 45, 4},
2025 {"ưʪ±à", vault_aux_animal, NULL, 35, 5},
2026 {"¶µ²ñ", vault_aux_chapel_g, NULL, 75, 4},
2027 {"¥¢¥ó¥Ç¥Ã¥É", vault_aux_undead, NULL, 75, 5},
2028 {NULL, NULL, NULL, 0, 0},
2030 {"clone", vault_aux_clone, vault_prep_clone, 5, 3},
2031 {"jelly", vault_aux_jelly, NULL, 5, 6},
2032 {"symbol good", vault_aux_symbol_g, vault_prep_symbol, 25, 2},
2033 {"symbol evil", vault_aux_symbol_e, vault_prep_symbol, 25, 2},
2034 {"mimic", vault_aux_mimic, NULL, 30, 4},
2035 {"lovecraftian", vault_aux_cthulhu, NULL, 70, 2},
2036 {"kennel", vault_aux_kennel, NULL, 45, 4},
2037 {"animal", vault_aux_animal, NULL, 35, 5},
2038 {"chapel", vault_aux_chapel_g, NULL, 75, 4},
2039 {"undead", vault_aux_undead, NULL, 75, 5},
2040 {NULL, NULL, NULL, 0, 0},
2044 /*!pit¾ðÊó¥Æ¡¼¥Ö¥ë*/
2045 static vault_aux_type pit_types[] =
2048 {"¥ª¡¼¥¯", vault_aux_orc, NULL, 5, 6},
2049 {"¥È¥í¥ë", vault_aux_troll, NULL, 20, 6},
2050 {"¥¸¥ã¥¤¥¢¥ó¥È", vault_aux_giant, NULL, 50, 6},
2051 {"¶¸µ¤", vault_aux_cthulhu, NULL, 80, 2},
2052 {"¥·¥ó¥Ü¥ë(Á±)", vault_aux_symbol_g, vault_prep_symbol, 70, 1},
2053 {"¥·¥ó¥Ü¥ë(°)", vault_aux_symbol_e, vault_prep_symbol, 70, 1},
2054 {"¶µ²ñ", vault_aux_chapel_g, NULL, 65, 2},
2055 {"¥É¥é¥´¥ó", vault_aux_dragon, vault_prep_dragon, 70, 6},
2056 {"¥Ç¡¼¥â¥ó", vault_aux_demon, NULL, 80, 6},
2057 {"¥À¡¼¥¯¥¨¥ë¥Õ", vault_aux_dark_elf, NULL, 45, 4},
2058 {NULL, NULL, NULL, 0, 0},
2060 {"orc", vault_aux_orc, NULL, 5, 6},
2061 {"troll", vault_aux_troll, NULL, 20, 6},
2062 {"giant", vault_aux_giant, NULL, 50, 6},
2063 {"lovecraftian", vault_aux_cthulhu, NULL, 80, 2},
2064 {"symbol good", vault_aux_symbol_g, vault_prep_symbol, 70, 1},
2065 {"symbol evil", vault_aux_symbol_e, vault_prep_symbol, 70, 1},
2066 {"chapel", vault_aux_chapel_g, NULL, 65, 2},
2067 {"dragon", vault_aux_dragon, vault_prep_dragon, 70, 6},
2068 {"demon", vault_aux_demon, NULL, 80, 6},
2069 {"dark elf", vault_aux_dark_elf, NULL, 45, 4},
2070 {NULL, NULL, NULL, 0, 0},
2075 /* Nest types code */
2076 #define NEST_TYPE_CLONE 0
2077 #define NEST_TYPE_JELLY 1
2078 #define NEST_TYPE_SYMBOL_GOOD 2
2079 #define NEST_TYPE_SYMBOL_EVIL 3
2080 #define NEST_TYPE_MIMIC 4
2081 #define NEST_TYPE_LOVECRAFTIAN 5
2082 #define NEST_TYPE_KENNEL 6
2083 #define NEST_TYPE_ANIMAL 7
2084 #define NEST_TYPE_CHAPEL 8
2085 #define NEST_TYPE_UNDEAD 9
2087 /* Pit types code */
2088 #define PIT_TYPE_ORC 0
2089 #define PIT_TYPE_TROLL 1
2090 #define PIT_TYPE_GIANT 2
2091 #define PIT_TYPE_LOVECRAFTIAN 3
2092 #define PIT_TYPE_SYMBOL_GOOD 4
2093 #define PIT_TYPE_SYMBOL_EVIL 5
2094 #define PIT_TYPE_CHAPEL 6
2095 #define PIT_TYPE_DRAGON 7
2096 #define PIT_TYPE_DEMON 8
2097 #define PIT_TYPE_DARK_ELF 9
2101 * Hack -- Get the string describing subtype of pit/nest
2102 * Determined in prepare function (some pit/nest only)
2104 static cptr pit_subtype_string(int type, bool nest)
2106 static char inner_buf[256] = "";
2108 inner_buf[0] = '\0'; /* Init string */
2110 if (nest) /* Nests */
2114 case NEST_TYPE_CLONE:
2115 sprintf(inner_buf, "(%s)", r_name + r_info[vault_aux_race].name);
2117 case NEST_TYPE_SYMBOL_GOOD:
2118 case NEST_TYPE_SYMBOL_EVIL:
2119 sprintf(inner_buf, "(%c)", vault_aux_char);
2127 case PIT_TYPE_SYMBOL_GOOD:
2128 case PIT_TYPE_SYMBOL_EVIL:
2129 sprintf(inner_buf, "(%c)", vault_aux_char);
2131 case PIT_TYPE_DRAGON:
2132 switch (vault_aux_dragon_mask4)
2135 case RF4_BR_ACID: strcpy(inner_buf, "(»À)"); break;
2136 case RF4_BR_ELEC: strcpy(inner_buf, "(°ðºÊ)"); break;
2137 case RF4_BR_FIRE: strcpy(inner_buf, "(²Ð±ê)"); break;
2138 case RF4_BR_COLD: strcpy(inner_buf, "(Î䵤)"); break;
2139 case RF4_BR_POIS: strcpy(inner_buf, "(ÆÇ)"); break;
2140 case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS):
2141 strcpy(inner_buf, "(Ëü¿§)"); break;
2142 default: strcpy(inner_buf, "(̤ÄêµÁ)"); break;
2144 case RF4_BR_ACID: strcpy(inner_buf, "(acid)"); break;
2145 case RF4_BR_ELEC: strcpy(inner_buf, "(lightning)"); break;
2146 case RF4_BR_FIRE: strcpy(inner_buf, "(fire)"); break;
2147 case RF4_BR_COLD: strcpy(inner_buf, "(frost)"); break;
2148 case RF4_BR_POIS: strcpy(inner_buf, "(poison)"); break;
2149 case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS):
2150 strcpy(inner_buf, "(multi-hued)"); break;
2151 default: strcpy(inner_buf, "(undefined)"); break;
2162 /* A struct for nest monster information with cheat_hear */
2172 * Comp function for sorting nest monster information
2174 static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
2176 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
2177 int w1 = nest_mon_info[a].r_idx;
2178 int w2 = nest_mon_info[b].r_idx;
2179 monster_race *r1_ptr = &r_info[w1];
2180 monster_race *r2_ptr = &r_info[w2];
2186 /* Extract used info */
2187 z1 = nest_mon_info[a].used;
2188 z2 = nest_mon_info[b].used;
2190 /* Compare used status */
2191 if (z1 < z2) return FALSE;
2192 if (z1 > z2) return TRUE;
2194 /* Compare levels */
2195 if (r1_ptr->level < r2_ptr->level) return TRUE;
2196 if (r1_ptr->level > r2_ptr->level) return FALSE;
2198 /* Compare experience */
2199 if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
2200 if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
2202 /* Compare indexes */
2208 * Swap function for sorting nest monster information
2210 static void ang_sort_swap_nest_mon_info(vptr u, vptr v, int a, int b)
2212 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
2213 nest_mon_info_type holder;
2219 holder = nest_mon_info[a];
2220 nest_mon_info[a] = nest_mon_info[b];
2221 nest_mon_info[b] = holder;
2225 #define NUM_NEST_MON_TYPE 64
2228 * Type 5 -- Monster nests
2230 * A monster nest is a "big" room, with an "inner" room, containing
2231 * a "collection" of monsters of a given type strewn about the room.
2233 * The monsters are chosen from a set of 64 randomly selected monster
2234 * races, to allow the nest creation to fail instead of having "holes".
2236 * Note the use of the "get_mon_num_prep()" function, and the special
2237 * "get_mon_num_hook()" restriction function, to prepare the "monster
2238 * allocation table" in such a way as to optimize the selection of
2239 * "appropriate" non-unique monsters for the nest.
2241 * Note that the "get_mon_num()" function may (rarely) fail, in which
2242 * case the nest will be empty.
2244 * Note that "monster nests" will never contain "unique" monsters.
2246 static bool build_type5(void)
2248 int y, x, y1, x1, y2, x2, xval, yval;
2250 nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
2256 int cur_nest_type = pick_vault_type(nest_types, d_info[dungeon_type].nest);
2257 vault_aux_type *n_ptr;
2259 /* No type available */
2260 if (cur_nest_type < 0) return FALSE;
2262 n_ptr = &nest_types[cur_nest_type];
2264 /* Process a preparation function if necessary */
2265 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
2267 /* Prepare allocation table */
2268 get_mon_num_prep(n_ptr->hook_func, NULL);
2270 align.sub_align = SUB_ALIGN_NEUTRAL;
2272 /* Pick some monster types */
2273 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
2275 int r_idx = 0, attempts = 100;
2276 monster_race *r_ptr = NULL;
2280 /* Get a (hard) monster type */
2281 r_idx = get_mon_num(dun_level + 11);
2282 r_ptr = &r_info[r_idx];
2284 /* Decline incorrect alignment */
2285 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
2287 /* Accept this monster */
2291 /* Notice failure */
2292 if (!r_idx || !attempts) return FALSE;
2294 /* Note the alignment */
2295 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
2296 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
2298 nest_mon_info[i].r_idx = r_idx;
2299 nest_mon_info[i].used = FALSE;
2302 /* Find and reserve some space in the dungeon. Get center of room. */
2303 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
2311 /* Place the floor area */
2312 for (y = y1 - 1; y <= y2 + 1; y++)
2314 for (x = x1 - 1; x <= x2 + 1; x++)
2316 c_ptr = &cave[y][x];
2317 place_floor_grid(c_ptr);
2318 c_ptr->info |= (CAVE_ROOM);
2322 /* Place the outer walls */
2323 for (y = y1 - 1; y <= y2 + 1; y++)
2325 c_ptr = &cave[y][x1 - 1];
2326 place_outer_grid(c_ptr);
2327 c_ptr = &cave[y][x2 + 1];
2328 place_outer_grid(c_ptr);
2330 for (x = x1 - 1; x <= x2 + 1; x++)
2332 c_ptr = &cave[y1 - 1][x];
2333 place_outer_grid(c_ptr);
2334 c_ptr = &cave[y2 + 1][x];
2335 place_outer_grid(c_ptr);
2339 /* Advance to the center room */
2345 /* The inner walls */
2346 for (y = y1 - 1; y <= y2 + 1; y++)
2348 c_ptr = &cave[y][x1 - 1];
2349 place_inner_grid(c_ptr);
2350 c_ptr = &cave[y][x2 + 1];
2351 place_inner_grid(c_ptr);
2354 for (x = x1 - 1; x <= x2 + 1; x++)
2356 c_ptr = &cave[y1 - 1][x];
2357 place_inner_grid(c_ptr);
2358 c_ptr = &cave[y2 + 1][x];
2359 place_inner_grid(c_ptr);
2361 for (y = y1; y <= y2; y++)
2363 for (x = x1; x <= x2; x++)
2365 add_cave_info(y, x, CAVE_ICKY);
2369 /* Place a secret door */
2370 switch (randint1(4))
2372 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
2373 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
2374 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
2375 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
2383 msg_format("¥â¥ó¥¹¥¿¡¼Éô²°(nest)(%s%s)", n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
2385 msg_format("Monster nest (%s%s)", n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
2389 /* Place some monsters */
2390 for (y = yval - 2; y <= yval + 2; y++)
2392 for (x = xval - 9; x <= xval + 9; x++)
2396 i = randint0(NUM_NEST_MON_TYPE);
2397 r_idx = nest_mon_info[i].r_idx;
2399 /* Place that "random" monster (no groups) */
2400 (void)place_monster_aux(0, y, x, r_idx, 0L);
2402 nest_mon_info[i].used = TRUE;
2406 if (cheat_room && cheat_hear)
2408 ang_sort_comp = ang_sort_comp_nest_mon_info;
2409 ang_sort_swap = ang_sort_swap_nest_mon_info;
2410 ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE);
2412 /* Dump the entries (prevent multi-printing) */
2413 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
2415 if (!nest_mon_info[i].used) break;
2416 for (; i < NUM_NEST_MON_TYPE - 1; i++)
2418 if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
2419 if (!nest_mon_info[i + 1].used) break;
2421 msg_print(r_name + r_info[nest_mon_info[i].r_idx].name);
2430 * Type 6 -- Monster pits
2432 * A monster pit is a "big" room, with an "inner" room, containing
2433 * a "collection" of monsters of a given type organized in the room.
2435 * The inside room in a monster pit appears as shown below, where the
2436 * actual monsters in each location depend on the type of the pit
2438 * #####################
2439 * #0000000000000000000#
2440 * #0112233455543322110#
2441 * #0112233467643322110#
2442 * #0112233455543322110#
2443 * #0000000000000000000#
2444 * #####################
2446 * Note that the monsters in the pit are now chosen by using "get_mon_num()"
2447 * to request 16 "appropriate" monsters, sorting them by level, and using
2448 * the "even" entries in this sorted list for the contents of the pit.
2450 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",
2451 * which is handled by requiring a specific "breath" attack for all of the
2452 * dragons. This may include "multi-hued" breath. Note that "wyrms" may
2453 * be present in many of the dragon pits, if they have the proper breath.
2455 * Note the use of the "get_mon_num_prep()" function, and the special
2456 * "get_mon_num_hook()" restriction function, to prepare the "monster
2457 * allocation table" in such a way as to optimize the selection of
2458 * "appropriate" non-unique monsters for the pit.
2460 * Note that the "get_mon_num()" function may (rarely) fail, in which case
2461 * the pit will be empty.
2463 * Note that "monster pits" will never contain "unique" monsters.
2465 static bool build_type6(void)
2467 int y, x, y1, x1, y2, x2, xval, yval;
2476 int cur_pit_type = pick_vault_type(pit_types, d_info[dungeon_type].pit);
2477 vault_aux_type *n_ptr;
2479 /* No type available */
2480 if (cur_pit_type < 0) return FALSE;
2482 n_ptr = &pit_types[cur_pit_type];
2484 /* Process a preparation function if necessary */
2485 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
2487 /* Prepare allocation table */
2488 get_mon_num_prep(n_ptr->hook_func, NULL);
2490 align.sub_align = SUB_ALIGN_NEUTRAL;
2492 /* Pick some monster types */
2493 for (i = 0; i < 16; i++)
2495 int r_idx = 0, attempts = 100;
2496 monster_race *r_ptr = NULL;
2500 /* Get a (hard) monster type */
2501 r_idx = get_mon_num(dun_level + 11);
2502 r_ptr = &r_info[r_idx];
2504 /* Decline incorrect alignment */
2505 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
2507 /* Accept this monster */
2511 /* Notice failure */
2512 if (!r_idx || !attempts) return FALSE;
2514 /* Note the alignment */
2515 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
2516 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
2521 /* Find and reserve some space in the dungeon. Get center of room. */
2522 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
2530 /* Place the floor area */
2531 for (y = y1 - 1; y <= y2 + 1; y++)
2533 for (x = x1 - 1; x <= x2 + 1; x++)
2535 c_ptr = &cave[y][x];
2536 place_floor_grid(c_ptr);
2537 c_ptr->info |= (CAVE_ROOM);
2541 /* Place the outer walls */
2542 for (y = y1 - 1; y <= y2 + 1; y++)
2544 c_ptr = &cave[y][x1 - 1];
2545 place_outer_grid(c_ptr);
2546 c_ptr = &cave[y][x2 + 1];
2547 place_outer_grid(c_ptr);
2549 for (x = x1 - 1; x <= x2 + 1; x++)
2551 c_ptr = &cave[y1 - 1][x];
2552 place_outer_grid(c_ptr);
2553 c_ptr = &cave[y2 + 1][x];
2554 place_outer_grid(c_ptr);
2557 /* Advance to the center room */
2563 /* The inner walls */
2564 for (y = y1 - 1; y <= y2 + 1; y++)
2566 c_ptr = &cave[y][x1 - 1];
2567 place_inner_grid(c_ptr);
2568 c_ptr = &cave[y][x2 + 1];
2569 place_inner_grid(c_ptr);
2571 for (x = x1 - 1; x <= x2 + 1; x++)
2573 c_ptr = &cave[y1 - 1][x];
2574 place_inner_grid(c_ptr);
2575 c_ptr = &cave[y2 + 1][x];
2576 place_inner_grid(c_ptr);
2578 for (y = y1; y <= y2; y++)
2580 for (x = x1; x <= x2; x++)
2582 add_cave_info(y, x, CAVE_ICKY);
2586 /* Place a secret door */
2587 switch (randint1(4))
2589 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
2590 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
2591 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
2592 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
2595 /* Sort the entries */
2596 for (i = 0; i < 16 - 1; i++)
2598 /* Sort the entries */
2599 for (j = 0; j < 16 - 1; j++)
2604 int p1 = r_info[what[i1]].level;
2605 int p2 = r_info[what[i2]].level;
2611 what[i1] = what[i2];
2622 msg_format("¥â¥ó¥¹¥¿¡¼Éô²°(pit)(%s%s)", n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
2624 msg_format("Monster pit (%s%s)", n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
2628 /* Select the entries */
2629 for (i = 0; i < 8; i++)
2631 /* Every other entry */
2632 what[i] = what[i * 2];
2637 msg_print(r_name + r_info[what[i]].name);
2641 /* Top and bottom rows */
2642 for (x = xval - 9; x <= xval + 9; x++)
2644 place_monster_aux(0, yval - 2, x, what[0], PM_NO_KAGE);
2645 place_monster_aux(0, yval + 2, x, what[0], PM_NO_KAGE);
2648 /* Middle columns */
2649 for (y = yval - 1; y <= yval + 1; y++)
2651 place_monster_aux(0, y, xval - 9, what[0], PM_NO_KAGE);
2652 place_monster_aux(0, y, xval + 9, what[0], PM_NO_KAGE);
2654 place_monster_aux(0, y, xval - 8, what[1], PM_NO_KAGE);
2655 place_monster_aux(0, y, xval + 8, what[1], PM_NO_KAGE);
2657 place_monster_aux(0, y, xval - 7, what[1], PM_NO_KAGE);
2658 place_monster_aux(0, y, xval + 7, what[1], PM_NO_KAGE);
2660 place_monster_aux(0, y, xval - 6, what[2], PM_NO_KAGE);
2661 place_monster_aux(0, y, xval + 6, what[2], PM_NO_KAGE);
2663 place_monster_aux(0, y, xval - 5, what[2], PM_NO_KAGE);
2664 place_monster_aux(0, y, xval + 5, what[2], PM_NO_KAGE);
2666 place_monster_aux(0, y, xval - 4, what[3], PM_NO_KAGE);
2667 place_monster_aux(0, y, xval + 4, what[3], PM_NO_KAGE);
2669 place_monster_aux(0, y, xval - 3, what[3], PM_NO_KAGE);
2670 place_monster_aux(0, y, xval + 3, what[3], PM_NO_KAGE);
2672 place_monster_aux(0, y, xval - 2, what[4], PM_NO_KAGE);
2673 place_monster_aux(0, y, xval + 2, what[4], PM_NO_KAGE);
2676 /* Above/Below the center monster */
2677 for (x = xval - 1; x <= xval + 1; x++)
2679 place_monster_aux(0, yval + 1, x, what[5], PM_NO_KAGE);
2680 place_monster_aux(0, yval - 1, x, what[5], PM_NO_KAGE);
2683 /* Next to the center monster */
2684 place_monster_aux(0, yval, xval + 1, what[6], PM_NO_KAGE);
2685 place_monster_aux(0, yval, xval - 1, what[6], PM_NO_KAGE);
2687 /* Center monster */
2688 place_monster_aux(0, yval, xval, what[7], PM_NO_KAGE);
2694 /* coordinate translation code */
2695 static void coord_trans(int *x, int *y, int xoffset, int yoffset, int transno)
2701 * transno specifies what transformation is required. (0-7)
2702 * The lower two bits indicate by how much the vault is rotated,
2703 * and the upper bit indicates a reflection.
2704 * This is done by using rotation matrices... however since
2705 * these are mostly zeros for rotations by 90 degrees this can
2706 * be expressed simply in terms of swapping and inverting the
2707 * x and y coordinates.
2709 for (i = 0; i < transno % 4; i++)
2711 /* rotate by 90 degrees */
2719 /* Reflect depending on status of 3rd bit. */
2723 /* Add offsets so vault stays in the first quadrant */
2730 * Hack -- fill in "vault" rooms
2732 static void build_vault(int yval, int xval, int ymax, int xmax, cptr data,
2733 int xoffset, int yoffset, int transno)
2735 int dx, dy, x, y, i, j;
2742 /* Place dungeon features and objects */
2743 for (t = data, dy = 0; dy < ymax; dy++)
2745 for (dx = 0; dx < xmax; dx++, t++)
2747 /* prevent loop counter from being overwritten */
2752 coord_trans(&i, &j, xoffset, yoffset, transno);
2754 /* Extract the location */
2755 if (transno % 2 == 0)
2757 /* no swap of x/y */
2758 x = xval - (xmax / 2) + i;
2759 y = yval - (ymax / 2) + j;
2764 x = xval - (ymax / 2) + i;
2765 y = yval - (xmax / 2) + j;
2768 /* Hack -- skip "non-grids" */
2769 if (*t == ' ') continue;
2771 /* Access the grid */
2772 c_ptr = &cave[y][x];
2774 /* Lay down a floor */
2775 place_floor_grid(c_ptr);
2777 /* Remove any mimic */
2780 /* Part of a vault */
2781 c_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
2783 /* Analyze the grid */
2786 /* Granite wall (outer) */
2788 place_outer_noperm_grid(c_ptr);
2791 /* Granite wall (inner) */
2793 place_inner_grid(c_ptr);
2796 /* Glass wall (inner) */
2798 place_inner_grid(c_ptr);
2799 c_ptr->feat = feat_glass_wall;
2802 /* Permanent wall (inner) */
2804 place_inner_perm_grid(c_ptr);
2807 /* Permanent glass wall (inner) */
2809 place_inner_perm_grid(c_ptr);
2810 c_ptr->feat = feat_permanent_glass_wall;
2815 if (randint0(100) < 75)
2817 place_object(y, x, 0L);
2827 place_secret_door(y, x, DOOR_DEFAULT);
2830 /* Secret glass doors */
2832 place_secret_door(y, x, DOOR_GLASS_DOOR);
2833 if (is_closed_door(c_ptr->feat)) c_ptr->mimic = feat_glass_wall;
2838 place_secret_door(y, x, DOOR_CURTAIN);
2846 /* Black market in a dungeon */
2848 set_cave_feat(y, x, feat_black_market);
2849 store_init(NO_TOWN, STORE_BLACK);
2854 set_cave_feat(y, x, feat_pattern_start);
2858 set_cave_feat(y, x, feat_pattern_1);
2862 set_cave_feat(y, x, feat_pattern_2);
2866 set_cave_feat(y, x, feat_pattern_3);
2870 set_cave_feat(y, x, feat_pattern_4);
2874 set_cave_feat(y, x, feat_pattern_end);
2878 set_cave_feat(y, x, feat_pattern_exit);
2882 /* Reward for Pattern walk */
2883 object_level = base_level + 12;
2884 place_object(y, x, AM_GOOD | AM_GREAT);
2885 object_level = base_level;
2892 /* Place dungeon monsters and objects */
2893 for (t = data, dy = 0; dy < ymax; dy++)
2895 for (dx = 0; dx < xmax; dx++, t++)
2897 /* prevent loop counter from being overwritten */
2902 coord_trans(&i, &j, xoffset, yoffset, transno);
2904 /* Extract the location */
2905 if (transno % 2 == 0)
2907 /* no swap of x/y */
2908 x = xval - (xmax / 2) + i;
2909 y = yval - (ymax / 2) + j;
2914 x = xval - (ymax / 2) + i;
2915 y = yval - (xmax / 2) + j;
2918 /* Hack -- skip "non-grids" */
2919 if (*t == ' ') continue;
2921 /* Analyze the symbol */
2927 monster_level = base_level + 5;
2928 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
2929 monster_level = base_level;
2933 /* Meaner monster */
2936 monster_level = base_level + 11;
2937 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
2938 monster_level = base_level;
2942 /* Meaner monster, plus treasure */
2945 monster_level = base_level + 9;
2946 place_monster(y, x, PM_ALLOW_SLEEP);
2947 monster_level = base_level;
2948 object_level = base_level + 7;
2949 place_object(y, x, AM_GOOD);
2950 object_level = base_level;
2954 /* Nasty monster and treasure */
2957 monster_level = base_level + 40;
2958 place_monster(y, x, PM_ALLOW_SLEEP);
2959 monster_level = base_level;
2960 object_level = base_level + 20;
2961 place_object(y, x, AM_GOOD | AM_GREAT);
2962 object_level = base_level;
2966 /* Monster and/or object */
2969 if (randint0(100) < 50)
2971 monster_level = base_level + 3;
2972 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
2973 monster_level = base_level;
2975 if (randint0(100) < 50)
2977 object_level = base_level + 7;
2978 place_object(y, x, 0L);
2979 object_level = base_level;
2991 * Type 7 -- simple vaults (see "v_info.txt")
2993 static bool build_type7(void)
2999 int xoffset, yoffset;
3002 /* Pick a lesser vault */
3003 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
3005 /* Access a random vault record */
3006 v_ptr = &v_info[randint0(max_v_idx)];
3008 /* Accept the first lesser vault */
3009 if (v_ptr->typ == 7) break;
3012 /* No lesser vault found */
3013 if (dummy >= SAFE_MAX_ATTEMPTS)
3018 msg_print("·Ù¹ð¡ª¾®¤µ¤ÊÃϲ¼¼¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡ª");
3020 msg_print("Warning! Could not place lesser vault!");
3026 /* pick type of transformation (0-7) */
3027 transno = randint0(8);
3029 /* calculate offsets */
3033 /* Some huge vault cannot be ratated to fit in the dungeon */
3034 if (x+2 > cur_hgt-2)
3036 /* Forbid 90 or 270 degree ratation */
3040 coord_trans(&x, &y, 0, 0, transno);
3060 /* Find and reserve some space in the dungeon. Get center of room. */
3061 if (!find_space(&yval, &xval, abs(y), abs(x))) return FALSE;
3069 if (cheat_room) msg_format("¾®¤µ¤ÊÃϲ¼¼¼(%s)", v_name + v_ptr->name);
3071 if (cheat_room) msg_format("Lesser vault (%s)", v_name + v_ptr->name);
3074 /* Hack -- Build the vault */
3075 build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
3076 v_text + v_ptr->text, xoffset, yoffset, transno);
3083 * Type 8 -- greater vaults (see "v_info.txt")
3085 static bool build_type8(void)
3092 int xoffset, yoffset;
3094 /* Pick a greater vault */
3095 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
3097 /* Access a random vault record */
3098 v_ptr = &v_info[randint0(max_v_idx)];
3100 /* Accept the first greater vault */
3101 if (v_ptr->typ == 8) break;
3104 /* No greater vault found */
3105 if (dummy >= SAFE_MAX_ATTEMPTS)
3110 msg_print("·Ù¹ð¡ªµðÂç¤ÊÃϲ¼¼¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡ª");
3112 msg_print("Warning! Could not place greater vault!");
3118 /* pick type of transformation (0-7) */
3119 transno = randint0(8);
3121 /* calculate offsets */
3125 /* Some huge vault cannot be ratated to fit in the dungeon */
3126 if (x+2 > cur_hgt-2)
3128 /* Forbid 90 or 270 degree ratation */
3132 coord_trans(&x, &y, 0, 0, transno);
3153 * Try to allocate space for room. If fails, exit
3155 * Hack -- Prepare a bit larger space (+2, +2) to
3156 * prevent generation of vaults with no-entrance.
3158 /* Find and reserve some space in the dungeon. Get center of room. */
3159 if (!find_space(&yval, &xval, abs(y) + 2, abs(x) + 2)) return FALSE;
3162 v_ptr = &v_info[76 + randint1(3)];
3167 if (cheat_room) msg_format("µðÂç¤ÊÃϲ¼¼¼(%s)", v_name + v_ptr->name);
3169 if (cheat_room) msg_format("Greater vault (%s)", v_name + v_ptr->name);
3172 /* Hack -- Build the vault */
3173 build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
3174 v_text + v_ptr->text, xoffset, yoffset, transno);
3180 * Structure to hold all "fill" data
3183 typedef struct fill_data_type fill_data_type;
3185 struct fill_data_type
3198 /* features to fill with */
3207 /* number of filled squares */
3211 static fill_data_type fill_data;
3214 /* Store routine for the fractal cave generator */
3215 /* this routine probably should be an inline function or a macro. */
3216 static void store_height(int x, int y, int val)
3218 /* if on boundary set val > cutoff so walls are not as square */
3219 if (((x == fill_data.xmin) || (y == fill_data.ymin) ||
3220 (x == fill_data.xmax) || (y == fill_data.ymax)) &&
3221 (val <= fill_data.c1)) val = fill_data.c1 + 1;
3223 /* store the value in height-map format */
3224 cave[y][x].feat = val;
3231 * Explanation of the plasma fractal algorithm:
3233 * A grid of points is created with the properties of a 'height-map'
3234 * This is done by making the corners of the grid have a random value.
3235 * The grid is then subdivided into one with twice the resolution.
3236 * The new points midway between two 'known' points can be calculated
3237 * by taking the average value of the 'known' ones and randomly adding
3238 * or subtracting an amount proportional to the distance between those
3239 * points. The final 'middle' points of the grid are then calculated
3240 * by averaging all four of the originally 'known' corner points. An
3241 * random amount is added or subtracted from this to get a value of the
3242 * height at that point. The scaling factor here is adjusted to the
3243 * slightly larger distance diagonally as compared to orthogonally.
3245 * This is then repeated recursively to fill an entire 'height-map'
3246 * A rectangular map is done the same way, except there are different
3247 * scaling factors along the x and y directions.
3249 * A hack to change the amount of correlation between points is done using
3250 * the grd variable. If the current step size is greater than grd then
3251 * the point will be random, otherwise it will be calculated by the
3252 * above algorithm. This makes a maximum distance at which two points on
3253 * the height map can affect each other.
3255 * How fractal caves are made:
3257 * When the map is complete, a cut-off value is used to create a cave.
3258 * Heights below this value are "floor", and heights above are "wall".
3259 * This also can be used to create lakes, by adding more height levels
3260 * representing shallow and deep water/ lava etc.
3262 * The grd variable affects the width of passages.
3263 * The roug variable affects the roughness of those passages
3265 * The tricky part is making sure the created cave is connected. This
3266 * is done by 'filling' from the inside and only keeping the 'filled'
3267 * floor. Walls bounding the 'filled' floor are also kept. Everything
3268 * else is converted to the normal _extra_.
3273 * Note that this uses the cave.feat array in a very hackish way
3274 * the values are first set to zero, and then each array location
3275 * is used as a "heightmap"
3276 * The heightmap then needs to be converted back into the "feat" format.
3278 * grd=level at which fractal turns on. smaller gives more mazelike caves
3279 * roug=roughness level. 16=normal. higher values make things more convoluted
3280 * small values are good for smooth walls.
3281 * size=length of the side of the square cave system.
3283 static void generate_hmap(int y0, int x0, int xsiz, int ysiz, int grd, int roug, int cutoff)
3285 int xhsize, yhsize, xsize, ysize, maxsize;
3288 * fixed point variables- these are stored as 256 x normal value
3289 * this gives 8 binary places of fractional part + 8 places of normal part
3292 u16b xstep, xhstep, ystep, yhstep;
3293 u16b xstep2, xhstep2, ystep2, yhstep2;
3294 u16b i, j, ii, jj, diagsize, xxsize, yysize;
3296 /* Cache for speed */
3297 u16b xm, xp, ym, yp;
3299 /* redefine size so can change the value if out of range */
3303 /* Paranoia about size of the system of caves */
3304 if (xsize > 254) xsize = 254;
3305 if (xsize < 4) xsize = 4;
3306 if (ysize > 254) ysize = 254;
3307 if (ysize < 4) ysize = 4;
3309 /* get offsets to middle of array */
3313 /* fix rounding problem */
3317 /* get limits of region */
3318 fill_data.xmin = x0 - xhsize;
3319 fill_data.ymin = y0 - yhsize;
3320 fill_data.xmax = x0 + xhsize;
3321 fill_data.ymax = y0 + yhsize;
3323 /* Store cutoff in global for quick access */
3324 fill_data.c1 = cutoff;
3327 * Scale factor for middle points:
3328 * About sqrt(2) * 256 - correct for a square lattice
3329 * approximately correct for everything else.
3333 /* maximum of xsize and ysize */
3334 maxsize = (xsize > ysize) ? xsize : ysize;
3336 /* Clear the section */
3337 for (i = 0; i <= xsize; i++)
3339 for (j = 0; j <= ysize; j++)
3341 /* -1 is a flag for "not done yet" */
3342 cave[(int)(fill_data.ymin + j)][(int)(fill_data.xmin + i)].feat = -1;
3343 /* Clear icky flag because may be redoing the cave */
3344 cave[(int)(fill_data.ymin + j)][(int)(fill_data.xmin + i)].info &= ~(CAVE_ICKY);
3348 /* Boundaries are walls */
3349 cave[fill_data.ymin][fill_data.xmin].feat = maxsize;
3350 cave[fill_data.ymax][fill_data.xmin].feat = maxsize;
3351 cave[fill_data.ymin][fill_data.xmax].feat = maxsize;
3352 cave[fill_data.ymax][fill_data.xmax].feat = maxsize;
3354 /* Set the middle square to be an open area. */
3355 cave[y0][x0].feat = 0;
3357 /* Initialize the step sizes */
3358 xstep = xhstep = xsize * 256;
3359 ystep = yhstep = ysize * 256;
3360 xxsize = xsize * 256;
3361 yysize = ysize * 256;
3364 * Fill in the rectangle with fractal height data -
3365 * like the 'plasma fractal' in fractint.
3367 while ((xhstep > 256) || (yhstep > 256))
3369 /* Halve the step sizes */
3375 /* cache well used values */
3376 xstep2 = xstep / 256;
3377 ystep2 = ystep / 256;
3379 xhstep2 = xhstep / 256;
3380 yhstep2 = yhstep / 256;
3382 /* middle top to bottom. */
3383 for (i = xhstep; i <= xxsize - xhstep; i += xstep)
3385 for (j = 0; j <= yysize; j += ystep)
3387 /* cache often used values */
3388 ii = i / 256 + fill_data.xmin;
3389 jj = j / 256 + fill_data.ymin;
3392 if (cave[jj][ii].feat == -1)
3396 /* If greater than 'grid' level then is random */
3397 store_height(ii, jj, randint1(maxsize));
3401 /* Average of left and right points +random bit */
3402 store_height(ii, jj,
3403 (cave[jj][fill_data.xmin + (i - xhstep) / 256].feat
3404 + cave[jj][fill_data.xmin + (i + xhstep) / 256].feat) / 2
3405 + (randint1(xstep2) - xhstep2) * roug / 16);
3412 /* middle left to right. */
3413 for (j = yhstep; j <= yysize - yhstep; j += ystep)
3415 for (i = 0; i <= xxsize; i += xstep)
3417 /* cache often used values */
3418 ii = i / 256 + fill_data.xmin;
3419 jj = j / 256 + fill_data.ymin;
3422 if (cave[jj][ii].feat == -1)
3426 /* If greater than 'grid' level then is random */
3427 store_height(ii, jj, randint1(maxsize));
3431 /* Average of up and down points +random bit */
3432 store_height(ii, jj,
3433 (cave[fill_data.ymin + (j - yhstep) / 256][ii].feat
3434 + cave[fill_data.ymin + (j + yhstep) / 256][ii].feat) / 2
3435 + (randint1(ystep2) - yhstep2) * roug / 16);
3442 for (i = xhstep; i <= xxsize - xhstep; i += xstep)
3444 for (j = yhstep; j <= yysize - yhstep; j += ystep)
3446 /* cache often used values */
3447 ii = i / 256 + fill_data.xmin;
3448 jj = j / 256 + fill_data.ymin;
3451 if (cave[jj][ii].feat == -1)
3455 /* If greater than 'grid' level then is random */
3456 store_height(ii, jj, randint1(maxsize));
3460 /* Cache reused values. */
3461 xm = fill_data.xmin + (i - xhstep) / 256;
3462 xp = fill_data.xmin + (i + xhstep) / 256;
3463 ym = fill_data.ymin + (j - yhstep) / 256;
3464 yp = fill_data.ymin + (j + yhstep) / 256;
3467 * Average over all four corners + scale by diagsize to
3468 * reduce the effect of the square grid on the shape of the fractal
3470 store_height(ii, jj,
3471 (cave[ym][xm].feat + cave[yp][xm].feat
3472 + cave[ym][xp].feat + cave[yp][xp].feat) / 4
3473 + (randint1(xstep2) - xhstep2) * (diagsize / 16) / 256 * roug);
3482 static bool hack_isnt_wall(int y, int x, int c1, int c2, int c3, int feat1, int feat2, int feat3, int info1, int info2, int info3)
3485 * function used to convert from height-map back to the
3486 * normal angband cave format
3488 if (cave[y][x].info & CAVE_ICKY)
3495 /* Show that have looked at this square */
3496 cave[y][x].info|= (CAVE_ICKY);
3498 /* Use cutoffs c1-c3 to allocate regions of floor /water/ lava etc. */
3499 if (cave[y][x].feat <= c1)
3501 /* 25% of the time use the other tile : it looks better this way */
3502 if (randint1(100) < 75)
3504 cave[y][x].feat = feat1;
3505 cave[y][x].info &= ~(CAVE_MASK);
3506 cave[y][x].info |= info1;
3511 cave[y][x].feat = feat2;
3512 cave[y][x].info &= ~(CAVE_MASK);
3513 cave[y][x].info |= info2;
3517 else if (cave[y][x].feat <= c2)
3519 /* 25% of the time use the other tile : it looks better this way */
3520 if (randint1(100) < 75)
3522 cave[y][x].feat = feat2;
3523 cave[y][x].info &= ~(CAVE_MASK);
3524 cave[y][x].info |= info2;
3529 cave[y][x].feat = feat1;
3530 cave[y][x].info &= ~(CAVE_MASK);
3531 cave[y][x].info |= info1;
3535 else if (cave[y][x].feat <= c3)
3537 cave[y][x].feat = feat3;
3538 cave[y][x].info &= ~(CAVE_MASK);
3539 cave[y][x].info |= info3;
3542 /* if greater than cutoff then is a wall */
3545 place_outer_bold(y, x);
3555 * Quick and nasty fill routine used to find the connected region
3556 * of floor in the middle of the cave
3558 static void cave_fill(byte y, byte x)
3567 /*** Start Grid ***/
3569 /* Enqueue that entry */
3574 /* Now process the queue */
3575 while (flow_head != flow_tail)
3577 /* Extract the next entry */
3578 ty = temp_y[flow_head];
3579 tx = temp_x[flow_head];
3581 /* Forget that entry */
3582 if (++flow_head == TEMP_MAX) flow_head = 0;
3584 /* Add the "children" */
3585 for (d = 0; d < 8; d++)
3587 int old_head = flow_tail;
3589 /* Child location */
3590 j = ty + ddy_ddd[d];
3591 i = tx + ddx_ddd[d];
3593 /* Paranoia Don't leave the cave */
3594 if (!in_bounds(j, i))
3596 /* affect boundary */
3597 cave[j][i].info |= CAVE_ICKY;
3601 /* If within bounds */
3602 else if ((i > fill_data.xmin) && (i < fill_data.xmax)
3603 && (j > fill_data.ymin) && (j < fill_data.ymax))
3605 /* If not a wall or floor done before */
3606 if (hack_isnt_wall(j, i,
3607 fill_data.c1, fill_data.c2, fill_data.c3,
3608 fill_data.feat1, fill_data.feat2, fill_data.feat3,
3609 fill_data.info1, fill_data.info2, fill_data.info3))
3611 /* Enqueue that entry */
3612 temp_y[flow_tail] = j;
3613 temp_x[flow_tail] = i;
3615 /* Advance the queue */
3616 if (++flow_tail == TEMP_MAX) flow_tail = 0;
3618 /* Hack -- Overflow by forgetting new entry */
3619 if (flow_tail == flow_head)
3621 flow_tail = old_head;
3625 /* keep tally of size of cave system */
3626 (fill_data.amount)++;
3632 /* affect boundary */
3633 cave[j][i].info |= CAVE_ICKY;
3640 static bool generate_fracave(int y0, int x0, int xsize, int ysize, int cutoff, bool light, bool room)
3642 int x, y, i, xhsize, yhsize;
3644 /* offsets to middle from corner */
3650 * select region connected to center of cave system
3651 * this gets rid of alot of isolated one-sqaures that
3652 * can make teleport traps instadeaths...
3656 fill_data.c1 = cutoff;
3660 /* features to fill with */
3661 fill_data.feat1 = floor_type[randint0(100)];
3662 fill_data.feat2 = floor_type[randint0(100)];
3663 fill_data.feat3 = floor_type[randint0(100)];
3665 fill_data.info1 = CAVE_FLOOR;
3666 fill_data.info2 = CAVE_FLOOR;
3667 fill_data.info3 = CAVE_FLOOR;
3669 /* number of filled squares */
3670 fill_data.amount = 0;
3672 cave_fill((byte)y0, (byte)x0);
3674 /* if tally too small, try again */
3675 if (fill_data.amount < 10)
3677 /* too small - clear area and try again later */
3678 for (x = 0; x <= xsize; ++x)
3680 for (y = 0; y <= ysize; ++y)
3682 place_extra_bold(y0 + y - yhsize, x0 + x - xhsize);
3683 cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY | CAVE_ROOM);
3690 * Do boundarys-check to see if they are next to a filled region
3691 * If not then they are set to normal granite
3692 * If so then they are marked as room walls.
3694 for (i = 0; i <= xsize; ++i)
3697 if ((cave[0 + y0 - yhsize][i + x0 - xhsize].info & CAVE_ICKY) && (room))
3699 /* Next to a 'filled' region? - set to be room walls */
3700 place_outer_bold(y0 + 0 - yhsize, x0 + i - xhsize);
3701 if (light) cave[y0 + 0 - yhsize][x0 + i - xhsize].info |= (CAVE_GLOW);
3702 cave[y0 + 0 - yhsize][x0 + i - xhsize].info |= (CAVE_ROOM);
3703 place_outer_bold(y0 + 0 - yhsize, x0 + i - xhsize);
3707 /* set to be normal granite */
3708 place_extra_bold(y0 + 0 - yhsize, x0 + i - xhsize);
3711 /* bottom boundary */
3712 if ((cave[ysize + y0 - yhsize][i + x0 - xhsize].info & CAVE_ICKY) && (room))
3714 /* Next to a 'filled' region? - set to be room walls */
3715 place_outer_bold(y0 + ysize - yhsize, x0 + i - xhsize);
3716 if (light) cave[y0 + ysize - yhsize][x0 + i - xhsize].info|=(CAVE_GLOW);
3717 cave[y0 + ysize - yhsize][x0 + i - xhsize].info|=(CAVE_ROOM);
3718 place_outer_bold(y0 + ysize - yhsize, x0 + i - xhsize);
3722 /* set to be normal granite */
3723 place_extra_bold(y0 + ysize - yhsize, x0 + i - xhsize);
3726 /* clear the icky flag-don't need it any more */
3727 cave[y0 + 0 - yhsize][x0 + i - xhsize].info &= ~(CAVE_ICKY);
3728 cave[y0 + ysize - yhsize][x0 + i - xhsize].info &= ~(CAVE_ICKY);
3731 /* Do the left and right boundaries minus the corners (done above) */
3732 for (i = 1; i < ysize; ++i)
3735 if ((cave[i + y0 - yhsize][0 + x0 - xhsize].info & CAVE_ICKY) && room)
3738 place_outer_bold(y0 + i - yhsize, x0 + 0 - xhsize);
3739 if (light) cave[y0 + i - yhsize][x0 + 0 - xhsize].info |= (CAVE_GLOW);
3740 cave[y0 + i - yhsize][x0 + 0 - xhsize].info |= (CAVE_ROOM);
3741 place_outer_bold(y0 + i - yhsize, x0 + 0 - xhsize);
3746 place_extra_bold(y0 + i - yhsize, x0 + 0 - xhsize);
3748 /* right boundary */
3749 if ((cave[i + y0 - yhsize][xsize + x0 - xhsize].info & CAVE_ICKY) && room)
3752 place_outer_bold(y0 + i - yhsize, x0 + xsize - xhsize);
3753 if (light) cave[y0 + i - yhsize][x0 + xsize - xhsize].info |= (CAVE_GLOW);
3754 cave[y0 + i - yhsize][x0 + xsize - xhsize].info |= (CAVE_ROOM);
3755 place_outer_bold(y0 + i - yhsize, x0 + xsize - xhsize);
3760 place_extra_bold(y0 + i - yhsize, x0 + xsize - xhsize);
3763 /* clear icky flag -done with it */
3764 cave[y0 + i - yhsize][x0 + 0 - xhsize].info &= ~(CAVE_ICKY);
3765 cave[y0 + i - yhsize][x0 + xsize - xhsize].info &= ~(CAVE_ICKY);
3769 /* Do the rest: convert back to the normal format */
3770 for (x = 1; x < xsize; ++x)
3772 for (y = 1; y < ysize; ++y)
3774 if (is_floor_bold(y0 + y - yhsize, x0 + x - xhsize) &&
3775 (cave[y0 + y - yhsize][x0 + x - xhsize].info & CAVE_ICKY))
3777 /* Clear the icky flag in the filled region */
3778 cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~CAVE_ICKY;
3780 /* Set appropriate flags */
3781 if (light) cave[y0 + y - yhsize][x0 + x - xhsize].info |= (CAVE_GLOW);
3782 if (room) cave[y0 + y - yhsize][x0 + x - xhsize].info |= (CAVE_ROOM);
3784 else if (is_outer_bold(y0 + y - yhsize, x0 + x - xhsize) &&
3785 (cave[y0 + y - yhsize][x0 + x - xhsize].info & CAVE_ICKY))
3788 cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY);
3789 if (light) cave[y0 + y - yhsize][x0 + x - xhsize].info |= (CAVE_GLOW);
3792 cave[y0 + y - yhsize][x0 + x - xhsize].info |= (CAVE_ROOM);
3797 place_extra_bold(y0 + y - yhsize, x0 + x - xhsize);
3798 cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ROOM);
3803 /* Clear the unconnected regions */
3804 place_extra_bold(y0 + y - yhsize, x0 + x - xhsize);
3805 cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY | CAVE_ROOM);
3811 * XXX XXX XXX There is a slight problem when tunnels pierce the caves:
3812 * Extra doors appear inside the system. (Its not very noticeable though.)
3813 * This can be removed by "filling" from the outside in. This allows a separation
3814 * from _outer_ with _inner_. (Internal walls are _outer_ instead.)
3815 * The extra effort for what seems to be only a minor thing (even non-existant if you
3816 * think of the caves not as normal rooms, but as holes in the dungeon), doesn't seem
3825 * Driver routine to create fractal cave system
3827 static bool build_type9(void)
3829 int grd, roug, cutoff, xsize, ysize, y0, x0;
3831 bool done, light, room;
3833 /* get size: note 'Evenness'*/
3834 xsize = randint1(22) * 2 + 6;
3835 ysize = randint1(15) * 2 + 6;
3837 /* Find and reserve some space in the dungeon. Get center of room. */
3838 if (!find_space(&y0, &x0, ysize + 1, xsize + 1))
3840 /* Limit to the minimum room size, and retry */
3844 /* Find and reserve some space in the dungeon. Get center of room. */
3845 if (!find_space(&y0, &x0, ysize + 1, xsize + 1))
3851 return build_type1();
3855 light = done = FALSE;
3858 if ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS)) light = TRUE;
3862 /* Note: size must be even or there are rounding problems
3863 * This causes the tunnels not to connect properly to the room */
3865 /* testing values for these parameters feel free to adjust */
3866 grd = 1 << (randint0(4));
3868 /* want average of about 16 */
3869 roug = randint1(8) * randint1(4);
3872 cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
3873 randint1(xsize / 4) + randint1(ysize / 4);
3876 generate_hmap(y0, x0, xsize, ysize, grd, roug, cutoff);
3878 /* Convert to normal format + clean up */
3879 done = generate_fracave(y0, x0, xsize, ysize, cutoff, light, room);
3885 #ifdef ALLOW_CAVERNS_AND_LAKES
3887 * Builds a cave system in the center of the dungeon.
3889 void build_cavern(void)
3891 int grd, roug, cutoff, xsize, ysize, x0, y0;
3894 light = done = FALSE;
3895 if ((dun_level <= randint1(50)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS)) light = TRUE;
3897 /* Make a cave the size of the dungeon */
3898 xsize = cur_wid - 1;
3899 ysize = cur_hgt - 1;
3903 /* Paranoia: make size even */
3909 /* testing values for these parameters: feel free to adjust */
3910 grd = randint1(4) + 4;
3912 /* want average of about 16 */
3913 roug = randint1(8) * randint1(4);
3919 generate_hmap(y0 + 1, x0 + 1, xsize, ysize, grd, roug, cutoff);
3921 /* Convert to normal format+ clean up */
3922 done = generate_fracave(y0 + 1, x0 + 1, xsize, ysize, cutoff, light, FALSE);
3926 static bool generate_lake(int y0, int x0, int xsize, int ysize, int c1, int c2, int c3, int type)
3928 int x, y, i, xhsize, yhsize;
3929 int feat1, feat2, feat3;
3931 /* offsets to middle from corner */
3935 /* Get features based on type */
3938 case LAKE_T_LAVA: /* Lava */
3939 feat1 = feat_deep_lava;
3940 feat2 = feat_shallow_lava;
3941 feat3 = floor_type[randint0(100)];
3943 case LAKE_T_WATER: /* Water */
3944 feat1 = feat_deep_water;
3945 feat2 = feat_shallow_water;
3946 feat3 = floor_type[randint0(100)];
3948 case LAKE_T_CAVE: /* Collapsed cave */
3949 feat1 = floor_type[randint0(100)];
3950 feat2 = floor_type[randint0(100)];
3951 feat3 = feat_rubble;
3953 case LAKE_T_EARTH_VAULT: /* Earth vault */
3954 feat1 = feat_rubble;
3955 feat2 = floor_type[randint0(100)];
3956 feat3 = feat_rubble;
3958 case LAKE_T_AIR_VAULT: /* Air vault */
3963 case LAKE_T_WATER_VAULT: /* Water vault */
3964 feat1 = feat_shallow_water;
3965 feat2 = feat_deep_water;
3966 feat3 = feat_shallow_water;
3968 case LAKE_T_FIRE_VAULT: /* Fire Vault */
3969 feat1 = feat_shallow_lava;
3970 feat2 = feat_deep_lava;
3971 feat3 = feat_shallow_lava;
3975 default: return FALSE;
3979 * select region connected to center of cave system
3980 * this gets rid of alot of isolated one-sqaures that
3981 * can make teleport traps instadeaths...
3989 /* features to fill with */
3990 fill_data.feat1 = feat1;
3991 fill_data.feat2 = feat2;
3992 fill_data.feat3 = feat3;
3994 fill_data.info1 = 0;
3995 fill_data.info2 = 0;
3996 fill_data.info3 = 0;
3998 /* number of filled squares */
3999 fill_data.amount = 0;
4001 /* select region connected to center of cave system
4002 * this gets rid of alot of isolated one-sqaures that
4003 * can make teleport traps instadeaths... */
4004 cave_fill((byte)y0, (byte)x0);
4006 /* if tally too small, try again */
4007 if (fill_data.amount < 10)
4009 /* too small -clear area and try again later */
4010 for (x = 0; x <= xsize; ++x)
4012 for (y = 0; y <= ysize; ++y)
4014 place_floor_bold(y0 + y - yhsize, x0 + x - xhsize);
4015 cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY);
4021 /* Do boundarys- set to normal granite */
4022 for (i = 0; i <= xsize; ++i)
4024 place_extra_bold(y0 + 0 - yhsize, x0 + i - xhsize);
4025 place_extra_bold(y0 + ysize - yhsize, x0 + i - xhsize);
4027 /* clear the icky flag-don't need it any more */
4028 cave[y0 + 0 - yhsize][x0 + i - xhsize].info &= ~(CAVE_ICKY);
4029 cave[y0 + ysize - yhsize][x0 + i - xhsize].info &= ~(CAVE_ICKY);
4032 /* Do the left and right boundaries minus the corners (done above) */
4034 for (i = 1; i < ysize; ++i)
4036 place_extra_bold(y0 + i - yhsize, x0 + 0 - xhsize);
4037 place_extra_bold(y0 + i - yhsize, x0 + xsize - xhsize);
4039 /* clear icky flag -done with it */
4040 cave[y0 + i - yhsize][x0 + 0 - xhsize].info &= ~(CAVE_ICKY);
4041 cave[y0 + i - yhsize][x0 + xsize - xhsize].info &= ~(CAVE_ICKY);
4045 /* Do the rest: convert back to the normal format */
4046 for (x = 1; x < xsize; ++x)
4048 for (y = 1; y < ysize; ++y)
4050 /* Fill unconnected regions with granite */
4051 if ((!(cave[y0 + y - yhsize][x0 + x - xhsize].info & CAVE_ICKY)) ||
4052 is_outer_bold(y0 + y - yhsize, x0 + x - xhsize))
4053 place_extra_bold(y0 + y - yhsize, x0 + x - xhsize);
4055 /* turn off icky flag (no longer needed.) */
4056 cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY | CAVE_ROOM);
4059 if (cave_have_flag_bold(y0 + y - yhsize, x0 + x - xhsize, FF_LAVA))
4061 if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS)) cave[y0 + y - yhsize][x0 + x - xhsize].info |= CAVE_GLOW;
4071 * makes a lake/collapsed cave system in the center of the dungeon
4073 void build_lake(int type)
4075 int grd, roug, xsize, ysize, x0, y0;
4079 /* paranoia - exit if lake type out of range. */
4080 if ((type < LAKE_T_LAVA) || (type > LAKE_T_FIRE_VAULT))
4082 msg_format("Invalid lake type (%d)", type);
4086 /* Make the size of the dungeon */
4087 xsize = cur_wid - 1;
4088 ysize = cur_hgt - 1;
4092 /* Paranoia: make size even */
4098 /* testing values for these parameters: feel free to adjust */
4099 grd = randint1(3) + 4;
4101 /* want average of about 16 */
4102 roug = randint1(8) * randint1(4);
4104 /* Make up size of various componants */
4108 /* Deep water/lava */
4109 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
4111 /* Shallow boundary */
4115 generate_hmap(y0 + 1, x0 + 1, xsize, ysize, grd, roug, c3);
4117 /* Convert to normal format+ clean up */
4118 done = generate_lake(y0 + 1, x0 + 1, xsize, ysize, c1, c2, c3, type);
4121 #endif /* ALLOW_CAVERNS_AND_LAKES */
4125 * Routine used by the random vault creators to add a door to a location
4126 * Note that range checking has to be done in the calling routine.
4128 * The doors must be INSIDE the allocated region.
4130 static void add_door(int x, int y)
4132 /* Need to have a wall in the center square */
4133 if (!is_outer_bold(y, x)) return;
4140 * where x=don't care
4144 if (is_floor_bold(y-1,x) && is_floor_bold(y+1,x) &&
4145 (is_outer_bold(y, x - 1) && is_outer_bold(y, x + 1)))
4148 place_secret_door(y, x, DOOR_DEFAULT);
4150 /* set boundarys so don't get wide doors */
4151 place_solid_bold(y, x - 1);
4152 place_solid_bold(y, x + 1);
4161 * where x = don't care
4164 if (is_outer_bold(y - 1, x) && is_outer_bold(y + 1, x) &&
4165 is_floor_bold(y,x-1) && is_floor_bold(y,x+1))
4168 place_secret_door(y, x, DOOR_DEFAULT);
4170 /* set boundarys so don't get wide doors */
4171 place_solid_bold(y - 1, x);
4172 place_solid_bold(y + 1, x);
4178 * Routine that fills the empty areas of a room with treasure and monsters.
4180 static void fill_treasure(int x1, int x2, int y1, int y2, int difficulty)
4182 int x, y, cx, cy, size;
4185 /* center of room:*/
4189 /* Rough measure of size of vault= sum of lengths of sides */
4190 size = abs(x2 - x1) + abs(y2 - y1);
4192 for (x = x1; x <= x2; x++)
4194 for (y = y1; y <= y2; y++)
4196 /* Thing added based on distance to center of vault
4197 * Difficulty is 1-easy to 10-hard */
4198 value = ((((s32b)(distance(cx, cy, x, y))) * 100) / size) + randint1(10) - difficulty;
4200 /* hack- empty square part of the time */
4201 if ((randint1(100) - difficulty * 3) > 50) value = 20;
4203 /* if floor, shallow water and lava */
4204 if (is_floor_bold(y, x) ||
4205 (cave_have_flag_bold(y, x, FF_PLACE) && cave_have_flag_bold(y, x, FF_DROP)))
4207 /* The smaller 'value' is, the better the stuff */
4210 /* Meanest monster + treasure */
4211 monster_level = base_level + 40;
4212 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4213 monster_level = base_level;
4214 object_level = base_level + 20;
4215 place_object(y, x, AM_GOOD);
4216 object_level = base_level;
4220 /* Mean monster +treasure */
4221 monster_level = base_level + 20;
4222 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4223 monster_level = base_level;
4224 object_level = base_level + 10;
4225 place_object(y, x, AM_GOOD);
4226 object_level = base_level;
4228 else if (value < 10)
4231 monster_level = base_level + 9;
4232 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4233 monster_level = base_level;
4235 else if (value < 17)
4237 /* Intentional Blank space */
4240 * (Want some of the vault to be empty
4241 * so have room for group monsters.
4242 * This is used in the hack above to lower
4243 * the density of stuff in the vault.)
4246 else if (value < 23)
4248 /* Object or trap */
4249 if (randint0(100) < 25)
4251 place_object(y, x, 0L);
4258 else if (value < 30)
4260 /* Monster and trap */
4261 monster_level = base_level + 5;
4262 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4263 monster_level = base_level;
4266 else if (value < 40)
4268 /* Monster or object */
4269 if (randint0(100) < 50)
4271 monster_level = base_level + 3;
4272 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4273 monster_level = base_level;
4275 if (randint0(100) < 50)
4277 object_level = base_level + 7;
4278 place_object(y, x, 0L);
4279 object_level = base_level;
4282 else if (value < 50)
4291 /* 20% monster, 40% trap, 20% object, 20% blank space */
4292 if (randint0(100) < 20)
4294 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4296 else if (randint0(100) < 50)
4300 else if (randint0(100) < 50)
4302 place_object(y, x, 0L);
4313 * This function creates a random vault that looks like a collection of bubbles.
4314 * It works by getting a set of coordinates that represent the center of each
4315 * bubble. The entire room is made by seeing which bubble center is closest. If
4316 * two centers are equidistant then the square is a wall, otherwise it is a floor.
4317 * The only exception is for squares really near a center, these are always floor.
4318 * (It looks better than without this check.)
4320 * Note: If two centers are on the same point then this algorithm will create a
4321 * blank bubble filled with walls. - This is prevented from happening.
4323 static void build_bubble_vault(int x0, int y0, int xsize, int ysize)
4325 #define BUBBLENUM 10 /* number of bubbles */
4327 /* array of center points of bubbles */
4328 coord center[BUBBLENUM];
4331 u16b min1, min2, temp;
4334 /* Offset from center to top left hand corner */
4335 int xhsize = xsize / 2;
4336 int yhsize = ysize / 2;
4339 if (cheat_room) msg_print("Bubble Vault");
4341 /* Allocate center of bubbles */
4342 center[0].x = (byte)randint1(xsize - 3) + 1;
4343 center[0].y = (byte)randint1(ysize - 3) + 1;
4345 for (i = 1; i < BUBBLENUM; i++)
4349 /* get center and check to see if it is unique */
4354 x = randint1(xsize - 3) + 1;
4355 y = randint1(ysize - 3) + 1;
4357 for (j = 0; j < i; j++)
4359 /* rough test to see if there is an overlap */
4360 if ((x == center[j].x) && (y == center[j].y)) done = FALSE;
4369 /* Top and bottom boundaries */
4370 for (i = 0; i < xsize; i++)
4372 int x = x0 - xhsize + i;
4374 place_outer_noperm_bold(y0 - yhsize + 0, x);
4375 cave[y0 - yhsize + 0][x].info |= (CAVE_ROOM | CAVE_ICKY);
4376 place_outer_noperm_bold(y0 - yhsize + ysize - 1, x);
4377 cave[y0 - yhsize + ysize - 1][x].info |= (CAVE_ROOM | CAVE_ICKY);
4380 /* Left and right boundaries */
4381 for (i = 1; i < ysize - 1; i++)
4383 int y = y0 - yhsize + i;
4385 place_outer_noperm_bold(y, x0 - xhsize + 0);
4386 cave[y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
4387 place_outer_noperm_bold(y, x0 - xhsize + xsize - 1);
4388 cave[y][x0 - xhsize + xsize - 1].info |= (CAVE_ROOM | CAVE_ICKY);
4391 /* Fill in middle with bubbles */
4392 for (x = 1; x < xsize - 1; x++)
4394 for (y = 1; y < ysize - 1; y++)
4396 /* Get distances to two closest centers */
4399 min1 = distance(x, y, center[0].x, center[0].y);
4400 min2 = distance(x, y, center[1].x, center[1].y);
4404 /* swap if in wrong order */
4411 for (i = 2; i < BUBBLENUM; i++)
4413 temp = distance(x, y, center[i].x, center[i].y);
4421 else if (temp < min2)
4423 /* second smallest */
4427 if (((min2 - min1) <= 2) && (!(min1 < 3)))
4429 /* Boundary at midpoint+ not at inner region of bubble */
4430 place_outer_noperm_bold(y0 - yhsize + y, x0 - xhsize + x);
4434 /* middle of a bubble */
4435 place_floor_bold(y0 - yhsize + y, x0 - xhsize + x);
4438 /* clean up rest of flags */
4439 cave[y0 - yhsize + y][x0 - xhsize + x].info |= (CAVE_ROOM | CAVE_ICKY);
4443 /* Try to add some random doors */
4444 for (i = 0; i < 500; i++)
4446 x = randint1(xsize - 3) - xhsize + x0 + 1;
4447 y = randint1(ysize - 3) - yhsize + y0 + 1;
4451 /* Fill with monsters and treasure, low difficulty */
4452 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5));
4457 * Overlay a rectangular room given its bounds
4458 * This routine is used by build_room_vault
4459 * The area inside the walls is not touched:
4460 * only granite is removed- normal walls stay
4462 static void build_room(int x1, int x2, int y1, int y2)
4464 int x, y, i, xsize, ysize, temp;
4466 /* Check if rectangle has no width */
4467 if ((x1 == x2) || (y1 == y2)) return;
4472 /* Swap boundaries if in wrong order */
4480 /* Swap boundaries if in wrong order */
4486 /* get total widths */
4491 /* Top and bottom boundaries */
4492 for (i = 0; i <= xsize; i++)
4494 place_outer_noperm_bold(y1, x1 + i);
4495 cave[y1][x1 + i].info |= (CAVE_ROOM | CAVE_ICKY);
4496 place_outer_noperm_bold(y2, x1 + i);
4497 cave[y2][x1 + i].info |= (CAVE_ROOM | CAVE_ICKY);
4500 /* Left and right boundaries */
4501 for (i = 1; i < ysize; i++)
4503 place_outer_noperm_bold(y1 + i, x1);
4504 cave[y1 + i][x1].info|=(CAVE_ROOM | CAVE_ICKY);
4505 place_outer_noperm_bold(y1 + i, x2);
4506 cave[y1 + i][x2].info|=(CAVE_ROOM | CAVE_ICKY);
4510 for (x = 1; x < xsize; x++)
4512 for (y = 1; y < ysize; y++)
4514 if (is_extra_bold(y1+y, x1+x))
4516 /* clear the untouched region */
4517 place_floor_bold(y1 + y, x1 + x);
4518 cave[y1 + y][x1 + x].info |= (CAVE_ROOM | CAVE_ICKY);
4522 /* make it a room- but don't touch */
4523 cave[y1 + y][x1 + x].info |= (CAVE_ROOM | CAVE_ICKY);
4530 /* Create a random vault that looks like a collection of overlapping rooms */
4532 static void build_room_vault(int x0, int y0, int xsize, int ysize)
4534 int i, x1, x2, y1, y2, xhsize, yhsize;
4536 /* get offset from center */
4540 if (cheat_room) msg_print("Room Vault");
4542 /* fill area so don't get problems with arena levels */
4543 for (x1 = 0; x1 < xsize; x1++)
4545 int x = x0 - xhsize + x1;
4547 for (y1 = 0; y1 < ysize; y1++)
4549 int y = y0 - yhsize + y1;
4551 place_extra_bold(y, x);
4552 cave[y][x].info &= (~CAVE_ICKY);
4556 /* add ten random rooms */
4557 for (i = 0; i < 10; i++)
4559 x1 = randint1(xhsize) * 2 + x0 - xhsize;
4560 x2 = randint1(xhsize) * 2 + x0 - xhsize;
4561 y1 = randint1(yhsize) * 2 + y0 - yhsize;
4562 y2 = randint1(yhsize) * 2 + y0 - yhsize;
4563 build_room(x1, x2, y1, y2);
4566 /* Add some random doors */
4567 for (i = 0; i < 500; i++)
4569 x1 = randint1(xsize - 3) - xhsize + x0 + 1;
4570 y1 = randint1(ysize - 3) - yhsize + y0 + 1;
4574 /* Fill with monsters and treasure, high difficulty */
4575 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5);
4579 /* Create a random vault out of a fractal cave */
4580 static void build_cave_vault(int x0, int y0, int xsiz, int ysiz)
4582 int grd, roug, cutoff, xhsize, yhsize, xsize, ysize, x, y;
4583 bool done, light, room;
4585 /* round to make sizes even */
4591 if (cheat_room) msg_print("Cave Vault");
4593 light = done = FALSE;
4598 /* testing values for these parameters feel free to adjust */
4599 grd = 1 << randint0(4);
4601 /* want average of about 16 */
4602 roug = randint1(8) * randint1(4);
4605 cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
4606 randint1(xsize / 4) + randint1(ysize / 4);
4609 generate_hmap(y0, x0, xsize, ysize, grd, roug, cutoff);
4611 /* Convert to normal format+ clean up */
4612 done = generate_fracave(y0, x0, xsize, ysize, cutoff, light, room);
4615 /* Set icky flag because is a vault */
4616 for (x = 0; x <= xsize; x++)
4618 for (y = 0; y <= ysize; y++)
4620 cave[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
4624 /* Fill with monsters and treasure, low difficulty */
4625 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
4629 * maze vault -- rectangular labyrinthine rooms
4631 * maze vault uses two routines:
4632 * r_visit - a recursive routine that builds the labyrinth
4633 * build_maze_vault - a driver routine that calls r_visit and adds
4634 * monsters, traps and treasure
4636 * The labyrinth is built by creating a spanning tree of a graph.
4637 * The graph vertices are at
4638 * (x, y) = (2j + x1, 2k + y1) j = 0,...,m-1 k = 0,...,n-1
4639 * and the edges are the vertical and horizontal nearest neighbors.
4641 * The spanning tree is created by performing a suitably randomized
4642 * depth-first traversal of the graph. The only adjustable parameter
4643 * is the randint0(3) below; it governs the relative density of
4644 * twists and turns in the labyrinth: smaller number, more twists.
4646 static void r_visit(int y1, int x1, int y2, int x2,
4647 int node, int dir, int *visited)
4649 int i, j, m, n, temp, x, y, adj[4];
4651 /* dimensions of vertex array */
4652 m = (x2 - x1) / 2 + 1;
4653 n = (y2 - y1) / 2 + 1;
4655 /* mark node visited and set it to a floor */
4657 x = 2 * (node % m) + x1;
4658 y = 2 * (node / m) + y1;
4659 place_floor_bold(y, x);
4661 /* setup order of adjacent node visits */
4664 /* pick a random ordering */
4665 for (i = 0; i < 4; i++)
4667 for (i = 0; i < 4; i++)
4678 /* pick a random ordering with dir first */
4680 for (i = 1; i < 4; i++)
4682 for (i = 1; i < 4; i++)
4684 j = 1 + randint0(3);
4691 for (i = 0; i < 4; i++)
4696 /* (0,+) - check for bottom boundary */
4697 if ((node / m < n - 1) && (visited[node + m] == 0))
4699 place_floor_bold(y + 1, x);
4700 r_visit(y1, x1, y2, x2, node + m, dir, visited);
4704 /* (0,-) - check for top boundary */
4705 if ((node / m > 0) && (visited[node - m] == 0))
4707 place_floor_bold(y - 1, x);
4708 r_visit(y1, x1, y2, x2, node - m, dir, visited);
4712 /* (+,0) - check for right boundary */
4713 if ((node % m < m - 1) && (visited[node + 1] == 0))
4715 place_floor_bold(y, x + 1);
4716 r_visit(y1, x1, y2, x2, node + 1, dir, visited);
4720 /* (-,0) - check for left boundary */
4721 if ((node % m > 0) && (visited[node - 1] == 0))
4723 place_floor_bold(y, x - 1);
4724 r_visit(y1, x1, y2, x2, node - 1, dir, visited);
4731 void build_maze_vault(int x0, int y0, int xsize, int ysize, bool is_vault)
4735 int m, n, num_vertices, *visited;
4740 if (cheat_room && is_vault) msg_print("Maze Vault");
4742 /* Choose lite or dark */
4743 light = ((dun_level <= randint1(25)) && is_vault && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
4745 /* Pick a random room size - randomized by calling routine */
4754 /* generate the room */
4755 for (y = y1 - 1; y <= y2 + 1; y++)
4757 for (x = x1 - 1; x <= x2 + 1; x++)
4759 c_ptr = &cave[y][x];
4760 c_ptr->info |= CAVE_ROOM;
4761 if (is_vault) c_ptr->info |= CAVE_ICKY;
4762 if ((x == x1 - 1) || (x == x2 + 1) || (y == y1 - 1) || (y == y2 + 1))
4764 place_outer_grid(c_ptr);
4768 place_extra_grid(c_ptr);
4772 place_inner_grid(c_ptr);
4774 if (light) c_ptr->info |= (CAVE_GLOW);
4778 /* dimensions of vertex array */
4781 num_vertices = m * n;
4783 /* initialize array of visited vertices */
4784 C_MAKE(visited, num_vertices, int);
4786 /* traverse the graph to create a spaning tree, pick a random root */
4787 r_visit(y1, x1, y2, x2, randint0(num_vertices), 0, visited);
4789 /* Fill with monsters and treasure, low difficulty */
4790 if (is_vault) fill_treasure(x1, x2, y1, y2, randint1(5));
4792 C_KILL(visited, num_vertices, int);
4796 /* Build a "mini" checkerboard vault
4798 * This is done by making a permanent wall maze and setting
4799 * the diagonal sqaures of the checker board to be granite.
4800 * The vault has two entrances on opposite sides to guarantee
4801 * a way to get in even if the vault abuts a side of the dungeon.
4803 static void build_mini_c_vault(int x0, int y0, int xsize, int ysize)
4806 int y1, x1, y2, x2, y, x, total;
4807 int m, n, num_vertices;
4810 if (cheat_room) msg_print("Mini Checker Board Vault");
4812 /* Pick a random room size */
4822 /* generate the room */
4823 for (x = x1 - 2; x <= x2 + 2; x++)
4825 if (!in_bounds(y1-2,x)) break;
4827 cave[y1-2][x].info |= (CAVE_ROOM | CAVE_ICKY);
4829 place_outer_noperm_bold(y1-2, x);
4832 for (x = x1 - 2; x <= x2 + 2; x++)
4834 if (!in_bounds(y2+2,x)) break;
4836 cave[y2+2][x].info |= (CAVE_ROOM | CAVE_ICKY);
4838 place_outer_noperm_bold(y2+2, x);
4841 for (y = y1 - 2; y <= y2 + 2; y++)
4843 if (!in_bounds(y,x1-2)) break;
4845 cave[y][x1-2].info |= (CAVE_ROOM | CAVE_ICKY);
4847 place_outer_noperm_bold(y, x1-2);
4850 for (y = y1 - 2; y <= y2 + 2; y++)
4852 if (!in_bounds(y,x2+2)) break;
4854 cave[y][x2+2].info |= (CAVE_ROOM | CAVE_ICKY);
4856 place_outer_noperm_bold(y, x2+2);
4859 for (y = y1 - 1; y <= y2 + 1; y++)
4861 for (x = x1 - 1; x <= x2 + 1; x++)
4863 cave_type *c_ptr = &cave[y][x];
4865 c_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
4867 /* Permanent walls */
4868 place_inner_perm_grid(c_ptr);
4873 /* dimensions of vertex array */
4876 num_vertices = m * n;
4878 /* initialize array of visited vertices */
4879 C_MAKE(visited, num_vertices, int);
4881 /* traverse the graph to create a spannng tree, pick a random root */
4882 r_visit(y1, x1, y2, x2, randint0(num_vertices), 0, visited);
4884 /* Make it look like a checker board vault */
4885 for (x = x1; x <= x2; x++)
4887 for (y = y1; y <= y2; y++)
4889 total = x - x1 + y - y1;
4890 /* If total is odd- and is a floor then make a wall */
4891 if ((total % 2 == 1) && is_floor_bold(y, x))
4893 place_inner_bold(y, x);
4898 /* Make a couple of entrances */
4901 /* left and right */
4902 y = randint1(dy) + dy / 2;
4903 place_inner_bold(y1 + y, x1 - 1);
4904 place_inner_bold(y1 + y, x2 + 1);
4908 /* top and bottom */
4909 x = randint1(dx) + dx / 2;
4910 place_inner_bold(y1 - 1, x1 + x);
4911 place_inner_bold(y2 + 1, x1 + x);
4914 /* Fill with monsters and treasure, highest difficulty */
4915 fill_treasure(x1, x2, y1, y2, 10);
4917 C_KILL(visited, num_vertices, int);
4921 /* Build a town/ castle by using a recursive algorithm.
4922 * Basically divide each region in a probalistic way to create
4923 * smaller regions. When the regions get too small stop.
4925 * The power variable is a measure of how well defended a region is.
4926 * This alters the possible choices.
4928 static void build_recursive_room(int x1, int y1, int x2, int y2, int power)
4934 /* Temp variables */
4940 if ((power < 3) && (xsize > 12) && (ysize > 12))
4942 /* Need outside wall +keep */
4949 /* Make rooms + subdivide */
4950 if ((randint1(10) > 2) && (xsize < 8) && (ysize < 8))
4956 choice = randint1(2) + 1;
4961 /* Mostly subdivide */
4962 choice = randint1(3) + 1;
4966 /* Based on the choice made above, do something */
4974 /* top and bottom */
4975 for (x = x1; x <= x2; x++)
4977 place_outer_bold(y1, x);
4978 place_outer_bold(y2, x);
4981 /* left and right */
4982 for (y = y1 + 1; y < y2; y++)
4984 place_outer_bold(y, x1);
4985 place_outer_bold(y, x2);
4988 /* Make a couple of entrances */
4991 /* left and right */
4992 y = randint1(ysize) + y1;
4993 place_floor_bold(y, x1);
4994 place_floor_bold(y, x2);
4998 /* top and bottom */
4999 x = randint1(xsize) + x1;
5000 place_floor_bold(y1, x);
5001 place_floor_bold(y2, x);
5004 /* Select size of keep */
5005 t1 = randint1(ysize / 3) + y1;
5006 t2 = y2 - randint1(ysize / 3);
5007 t3 = randint1(xsize / 3) + x1;
5008 t4 = x2 - randint1(xsize / 3);
5010 /* Do outside areas */
5012 /* Above and below keep */
5013 build_recursive_room(x1 + 1, y1 + 1, x2 - 1, t1, power + 1);
5014 build_recursive_room(x1 + 1, t2, x2 - 1, y2, power + 1);
5016 /* Left and right of keep */
5017 build_recursive_room(x1 + 1, t1 + 1, t3, t2 - 1, power + 3);
5018 build_recursive_room(t4, t1 + 1, x2 - 1, t2 - 1, power + 3);
5020 /* Make the keep itself: */
5033 /* Try to build a room */
5034 if ((xsize < 3) || (ysize < 3))
5036 for (y = y1; y < y2; y++)
5038 for (x = x1; x < x2; x++)
5040 place_inner_bold(y, x);
5048 /* Make outside walls */
5049 /* top and bottom */
5050 for (x = x1 + 1; x <= x2 - 1; x++)
5052 place_inner_bold(y1 + 1, x);
5053 place_inner_bold(y2 - 1, x);
5056 /* left and right */
5057 for (y = y1 + 1; y <= y2 - 1; y++)
5059 place_inner_bold(y, x1 + 1);
5060 place_inner_bold(y, x2 - 1);
5064 y = randint1(ysize - 3) + y1 + 1;
5069 place_floor_bold(y, x1 + 1);
5074 place_floor_bold(y, x2 - 1);
5077 /* Build the room */
5078 build_recursive_room(x1 + 2, y1 + 2, x2 - 2, y2 - 2, power + 3);
5083 /* Try and divide vertically */
5087 for (y = y1; y < y2; y++)
5089 for (x = x1; x < x2; x++)
5091 place_inner_bold(y, x);
5097 t1 = randint1(xsize - 2) + x1 + 1;
5098 build_recursive_room(x1, y1, t1, y2, power - 2);
5099 build_recursive_room(t1 + 1, y1, x2, y2, power - 2);
5104 /* Try and divide horizontally */
5108 for (y = y1; y < y2; y++)
5110 for (x = x1; x < x2; x++)
5112 place_inner_bold(y, x);
5118 t1 = randint1(ysize - 2) + y1 + 1;
5119 build_recursive_room(x1, y1, x2, t1, power - 2);
5120 build_recursive_room(x1, t1 + 1, x2, y2, power - 2);
5127 /* Build a castle */
5129 /* Driver routine: clear the region and call the recursive
5132 *This makes a vault that looks like a castle/ city in the dungeon.
5134 static void build_castle_vault(int x0, int y0, int xsize, int ysize)
5140 /* Pick a random room size */
5149 if (cheat_room) msg_print("Castle Vault");
5151 /* generate the room */
5152 for (y = y1 - 1; y <= y2 + 1; y++)
5154 for (x = x1 - 1; x <= x2 + 1; x++)
5156 cave[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
5157 /* Make everything a floor */
5158 place_floor_bold(y, x);
5162 /* Make the castle */
5163 build_recursive_room(x1, y1, x2, y2, randint1(5));
5165 /* Fill with monsters and treasure, low difficulty */
5166 fill_treasure(x1, x2, y1, y2, randint1(3));
5171 * Add outer wall to a floored region
5172 * Note: no range checking is done so must be inside dungeon
5173 * This routine also stomps on doors
5175 static void add_outer_wall(int x, int y, int light, int x1, int y1, int x2, int y2)
5178 feature_type *f_ptr;
5181 if (!in_bounds(y, x)) return;
5183 c_ptr = &cave[y][x];
5185 /* hack- check to see if square has been visited before
5186 * if so, then exit (use room flag to do this) */
5187 if (c_ptr->info & CAVE_ROOM) return;
5190 c_ptr->info |= CAVE_ROOM;
5192 f_ptr = &f_info[c_ptr->feat];
5194 if (is_floor_bold(y, x))
5196 for (i = -1; i <= 1; i++)
5198 for (j = -1; j <= 1; j++)
5200 if ((x + i >= x1) && (x + i <= x2) &&
5201 (y + j >= y1) && (y + j <= y2))
5203 add_outer_wall(x + i, y + j, light, x1, y1, x2, y2);
5204 if (light) c_ptr->info |= CAVE_GLOW;
5209 else if (is_extra_bold(y, x))
5211 /* Set bounding walls */
5212 place_outer_bold(y, x);
5213 if (light) c_ptr->info |= CAVE_GLOW;
5215 else if (permanent_wall(f_ptr))
5217 /* Set bounding walls */
5218 if (light) c_ptr->info |= CAVE_GLOW;
5224 * Hacked distance formula - gives the 'wrong' answer.
5225 * Used to build crypts
5227 static int dist2(int x1, int y1, int x2, int y2,
5228 int h1, int h2, int h3, int h4)
5234 /* Basically this works by taking the normal pythagorean formula
5235 * and using an expansion to express this in a way without the
5236 * square root. This approximate formula is then perturbed to give
5237 * the distorted results. (I found this by making a mistake when I was
5238 * trying to fix the circular rooms.)
5241 /* h1-h4 are constants that describe the metric */
5242 if (dx >= 2 * dy) return (dx + (dy * h1) / h2);
5243 if (dy >= 2 * dx) return (dy + (dx * h1) / h2);
5244 return (((dx + dy) * 128) / 181 +
5245 (dx * dx / (dy * h3) + dy * dy / (dx * h3)) * h4);
5246 /* 128/181 is approx. 1/sqrt(2) */
5251 * Build target vault.
5252 * This is made by two concentric "crypts" with perpendicular
5253 * walls creating the cross-hairs.
5255 static void build_target_vault(int x0, int y0, int xsize, int ysize)
5259 /* Make a random metric */
5261 h1 = randint1(32) - 16;
5264 h4 = randint1(32) - 16;
5266 if (cheat_room) msg_print("Target Vault");
5268 /* work out outer radius */
5279 for (x = x0 - rad; x <= x0 + rad; x++)
5281 for (y = y0 - rad; y <= y0 + rad; y++)
5283 /* clear room flag */
5284 cave[y][x].info &= ~(CAVE_ROOM);
5286 /* Vault - so is "icky" */
5287 cave[y][x].info |= CAVE_ICKY;
5289 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1)
5291 /* inside- so is floor */
5292 place_floor_bold(y, x);
5296 /* make granite outside so arena works */
5297 place_extra_bold(y, x);
5300 /* proper boundary for arena */
5301 if (((y + rad) == y0) || ((y - rad) == y0) ||
5302 ((x + rad) == x0) || ((x - rad) == x0))
5304 place_extra_bold(y, x);
5309 /* Find visible outer walls and set to be FEAT_OUTER */
5310 add_outer_wall(x0, y0, FALSE, x0 - rad - 1, y0 - rad - 1,
5311 x0 + rad + 1, y0 + rad + 1);
5313 /* Add inner wall */
5314 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++)
5316 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++)
5318 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2)
5320 /* Make an internal wall */
5321 place_inner_bold(y, x);
5326 /* Add perpendicular walls */
5327 for (x = x0 - rad; x <= x0 + rad; x++)
5329 place_inner_bold(y0, x);
5332 for (y = y0 - rad; y <= y0 + rad; y++)
5334 place_inner_bold(y, x0);
5337 /* Make inner vault */
5338 for (y = y0 - 1; y <= y0 + 1; y++)
5340 place_inner_bold(y, x0 - 1);
5341 place_inner_bold(y, x0 + 1);
5343 for (x = x0 - 1; x <= x0 + 1; x++)
5345 place_inner_bold(y0 - 1, x);
5346 place_inner_bold(y0 + 1, x);
5349 place_floor_bold(y0, x0);
5352 /* Add doors to vault */
5353 /* get two distances so can place doors relative to centre */
5354 x = (rad - 2) / 4 + 1;
5357 add_door(x0 + x, y0);
5358 add_door(x0 + y, y0);
5359 add_door(x0 - x, y0);
5360 add_door(x0 - y, y0);
5361 add_door(x0, y0 + x);
5362 add_door(x0, y0 + y);
5363 add_door(x0, y0 - x);
5364 add_door(x0, y0 - y);
5366 /* Fill with stuff - medium difficulty */
5367 fill_treasure(x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
5371 #ifdef ALLOW_CAVERNS_AND_LAKES
5373 * This routine uses a modified version of the lake code to make a
5374 * distribution of some terrain type over the vault. This type
5375 * depends on the dungeon depth.
5377 * Miniture rooms are then scattered across the vault.
5379 static void build_elemental_vault(int x0, int y0, int xsiz, int ysiz)
5384 int xsize, ysize, xhsize, yhsize, x, y, i;
5388 if (cheat_room) msg_print("Elemental Vault");
5390 /* round to make sizes even */
5398 /* Earth vault (Rubble) */
5399 type = LAKE_T_EARTH_VAULT;
5401 else if (dun_level < 50)
5403 /* Air vault (Trees) */
5404 type = LAKE_T_AIR_VAULT;
5406 else if (dun_level < 75)
5408 /* Water vault (shallow water) */
5409 type = LAKE_T_WATER_VAULT;
5413 /* Fire vault (shallow lava) */
5414 type = LAKE_T_FIRE_VAULT;
5419 /* testing values for these parameters: feel free to adjust */
5420 grd = 1 << (randint0(3));
5422 /* want average of about 16 */
5423 roug = randint1(8) * randint1(4);
5425 /* Make up size of various componants */
5429 /* Deep water/lava */
5430 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
5432 /* Shallow boundary */
5436 generate_hmap(y0, x0, xsize, ysize, grd, roug, c3);
5438 /* Convert to normal format+ clean up */
5439 done = generate_lake(y0, x0, xsize, ysize, c1, c2, c3, type);
5442 /* Set icky flag because is a vault */
5443 for (x = 0; x <= xsize; x++)
5445 for (y = 0; y <= ysize; y++)
5447 cave[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
5451 /* make a few rooms in the vault */
5452 for (i = 1; i <= (xsize * ysize) / 50; i++)
5454 build_small_room(x0 + randint0(xsize - 4) - xsize / 2 + 2,
5455 y0 + randint0(ysize - 4) - ysize / 2 + 2);
5458 /* Fill with monsters and treasure, low difficulty */
5459 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 1,
5460 y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
5462 #endif /* ALLOW_CAVERNS_AND_LAKES */
5468 static bool build_type10(void)
5470 int y0, x0, xsize, ysize, vtype;
5473 /* big enough to look good, small enough to be fairly common. */
5474 xsize = randint1(22) + 22;
5475 ysize = randint1(11) + 11;
5477 /* Find and reserve some space in the dungeon. Get center of room. */
5478 if (!find_space(&y0, &x0, ysize + 1, xsize + 1)) return FALSE;
5480 /* Select type of vault */
5481 #ifdef ALLOW_CAVERNS_AND_LAKES
5484 vtype = randint1(15);
5486 while ((d_info[dungeon_type].flags1 & DF1_NO_CAVE) &&
5487 ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
5488 #else /* ALLOW_CAVERNS_AND_LAKES */
5491 vtype = randint1(7);
5493 while ((d_info[dungeon_type].flags1 & DF1_NO_CAVE) &&
5494 ((vtype == 1) || (vtype == 3)));
5495 #endif /* ALLOW_CAVERNS_AND_LAKES */
5499 /* Build an appropriate room */
5500 case 1: case 9: build_bubble_vault(x0, y0, xsize, ysize); break;
5501 case 2: case 10: build_room_vault(x0, y0, xsize, ysize); break;
5502 case 3: case 11: build_cave_vault(x0, y0, xsize, ysize); break;
5503 case 4: case 12: build_maze_vault(x0, y0, xsize, ysize, TRUE); break;
5504 case 5: case 13: build_mini_c_vault(x0, y0, xsize, ysize); break;
5505 case 6: case 14: build_castle_vault(x0, y0, xsize, ysize); break;
5506 case 7: case 15: build_target_vault(x0, y0, xsize, ysize); break;
5507 #ifdef ALLOW_CAVERNS_AND_LAKES
5508 case 8: build_elemental_vault(x0, y0, xsize, ysize); break;
5509 #endif /* ALLOW_CAVERNS_AND_LAKES */
5510 /* I know how to add a few more... give me some time. */
5513 default: return FALSE;
5521 * Build an vertical oval room.
5522 * For every grid in the possible square, check the distance.
5523 * If it's less than the radius, make it a room square.
5525 * When done fill from the inside to find the walls,
5527 static bool build_type11(void)
5529 int rad, x, y, x0, y0;
5532 /* Occasional light */
5533 if ((randint1(dun_level) <= 15) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS)) light = TRUE;
5537 /* Find and reserve some space in the dungeon. Get center of room. */
5538 if (!find_space(&y0, &x0, rad * 2 + 1, rad * 2 + 1)) return FALSE;
5540 /* Make circular floor */
5541 for (x = x0 - rad; x <= x0 + rad; x++)
5543 for (y = y0 - rad; y <= y0 + rad; y++)
5545 if (distance(y0, x0, y, x) <= rad - 1)
5547 /* inside- so is floor */
5548 place_floor_bold(y, x);
5550 else if (distance(y0, x0, y, x) <= rad + 1)
5552 /* make granite outside so arena works */
5553 place_extra_bold(y, x);
5558 /* Find visible outer walls and set to be FEAT_OUTER */
5559 add_outer_wall(x0, y0, light, x0 - rad, y0 - rad, x0 + rad, y0 + rad);
5567 * For every grid in the possible square, check the (fake) distance.
5568 * If it's less than the radius, make it a room square.
5570 * When done fill from the inside to find the walls,
5572 static bool build_type12(void)
5574 int rad, x, y, x0, y0;
5576 bool emptyflag = TRUE;
5578 /* Make a random metric */
5580 h1 = randint1(32) - 16;
5583 h4 = randint1(32) - 16;
5585 /* Occasional light */
5586 if ((randint1(dun_level) <= 5) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS)) light = TRUE;
5590 /* Find and reserve some space in the dungeon. Get center of room. */
5591 if (!find_space(&y0, &x0, rad * 2 + 3, rad * 2 + 3)) return FALSE;
5594 for (x = x0 - rad; x <= x0 + rad; x++)
5596 for (y = y0 - rad; y <= y0 + rad; y++)
5598 /* clear room flag */
5599 cave[y][x].info &= ~(CAVE_ROOM);
5601 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1)
5603 /* inside - so is floor */
5604 place_floor_bold(y, x);
5606 else if (distance(y0, x0, y, x) < 3)
5608 place_floor_bold(y, x);
5612 /* make granite outside so arena works */
5613 place_extra_bold(y, x);
5616 /* proper boundary for arena */
5617 if (((y + rad) == y0) || ((y - rad) == y0) ||
5618 ((x + rad) == x0) || ((x - rad) == x0))
5620 place_extra_bold(y, x);
5625 /* Find visible outer walls and set to be FEAT_OUTER */
5626 add_outer_wall(x0, y0, light, x0 - rad - 1, y0 - rad - 1,
5627 x0 + rad + 1, y0 + rad + 1);
5629 /* Check to see if there is room for an inner vault */
5630 for (x = x0 - 2; x <= x0 + 2; x++)
5632 for (y = y0 - 2; y <= y0 + 2; y++)
5634 if (!is_floor_bold(y, x))
5636 /* Wall in the way */
5642 if (emptyflag && one_in_(2))
5644 /* Build the vault */
5645 build_small_room(x0, y0);
5647 /* Place a treasure in the vault */
5648 place_object(y0, x0, 0L);
5650 /* Let's guard the treasure well */
5651 vault_monsters(y0, x0, randint0(2) + 3);
5653 /* Traps naturally */
5654 vault_traps(y0, x0, 4, 4, randint0(3) + 2);
5662 * Helper function for "trapped monster pit"
5664 static bool vault_aux_trapped_pit(int r_idx)
5666 monster_race *r_ptr = &r_info[r_idx];
5668 /* Validate the monster */
5669 if (!vault_monster_okay(r_idx)) return (FALSE);
5671 /* No wall passing monster */
5672 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return (FALSE);
5680 * Type 13 -- Trapped monster pits
5682 * A trapped monster pit is a "big" room with a straight corridor in
5683 * which wall opening traps are placed, and with two "inner" rooms
5684 * containing a "collection" of monsters of a given type organized in
5687 * The trapped monster pit appears as shown below, where the actual
5688 * monsters in each location depend on the type of the pit
5690 * #########################
5692 * ####################### #
5693 * #####001123454321100### #
5694 * ###0012234567654322100# #
5695 * ####################### #
5697 * # #######################
5698 * # #0012234567654322100###
5699 * # ###001123454321100#####
5700 * # #######################
5702 * #########################
5704 * Note that the monsters in the pit are now chosen by using "get_mon_num()"
5705 * to request 16 "appropriate" monsters, sorting them by level, and using
5706 * the "even" entries in this sorted list for the contents of the pit.
5708 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",
5709 * which is handled by requiring a specific "breath" attack for all of the
5710 * dragons. This may include "multi-hued" breath. Note that "wyrms" may
5711 * be present in many of the dragon pits, if they have the proper breath.
5713 * Note the use of the "get_mon_num_prep()" function, and the special
5714 * "get_mon_num_hook()" restriction function, to prepare the "monster
5715 * allocation table" in such a way as to optimize the selection of
5716 * "appropriate" non-unique monsters for the pit.
5718 * Note that the "get_mon_num()" function may (rarely) fail, in which case
5719 * the pit will be empty.
5721 * Note that "monster pits" will never contain "unique" monsters.
5723 static bool build_type13(void)
5725 static int placing[][3] = {
5726 {-2, -9, 0}, {-2, -8, 0}, {-3, -7, 0}, {-3, -6, 0},
5727 {+2, -9, 0}, {+2, -8, 0}, {+3, -7, 0}, {+3, -6, 0},
5728 {-2, +9, 0}, {-2, +8, 0}, {-3, +7, 0}, {-3, +6, 0},
5729 {+2, +9, 0}, {+2, +8, 0}, {+3, +7, 0}, {+3, +6, 0},
5730 {-2, -7, 1}, {-3, -5, 1}, {-3, -4, 1},
5731 {+2, -7, 1}, {+3, -5, 1}, {+3, -4, 1},
5732 {-2, +7, 1}, {-3, +5, 1}, {-3, +4, 1},
5733 {+2, +7, 1}, {+3, +5, 1}, {+3, +4, 1},
5734 {-2, -6, 2}, {-2, -5, 2}, {-3, -3, 2},
5735 {+2, -6, 2}, {+2, -5, 2}, {+3, -3, 2},
5736 {-2, +6, 2}, {-2, +5, 2}, {-3, +3, 2},
5737 {+2, +6, 2}, {+2, +5, 2}, {+3, +3, 2},
5738 {-2, -4, 3}, {-3, -2, 3},
5739 {+2, -4, 3}, {+3, -2, 3},
5740 {-2, +4, 3}, {-3, +2, 3},
5741 {+2, +4, 3}, {+3, +2, 3},
5742 {-2, -3, 4}, {-3, -1, 4},
5743 {+2, -3, 4}, {+3, -1, 4},
5744 {-2, +3, 4}, {-3, +1, 4},
5745 {+2, +3, 4}, {+3, +1, 4},
5746 {-2, -2, 5}, {-3, 0, 5}, {-2, +2, 5},
5747 {+2, -2, 5}, {+3, 0, 5}, {+2, +2, 5},
5748 {-2, -1, 6}, {-2, +1, 6},
5749 {+2, -1, 6}, {+2, +1, 6},
5750 {-2, 0, 7}, {+2, 0, 7},
5754 int y, x, y1, x1, y2, x2, xval, yval;
5763 int cur_pit_type = pick_vault_type(pit_types, d_info[dungeon_type].pit);
5764 vault_aux_type *n_ptr;
5766 /* Only in Angband */
5767 if (dungeon_type != DUNGEON_ANGBAND) return FALSE;
5769 /* No type available */
5770 if (cur_pit_type < 0) return FALSE;
5772 n_ptr = &pit_types[cur_pit_type];
5774 /* Process a preparation function if necessary */
5775 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
5777 /* Prepare allocation table */
5778 get_mon_num_prep(n_ptr->hook_func, vault_aux_trapped_pit);
5780 align.sub_align = SUB_ALIGN_NEUTRAL;
5782 /* Pick some monster types */
5783 for (i = 0; i < 16; i++)
5785 int r_idx = 0, attempts = 100;
5786 monster_race *r_ptr = NULL;
5790 /* Get a (hard) monster type */
5791 r_idx = get_mon_num(dun_level + 0);
5792 r_ptr = &r_info[r_idx];
5794 /* Decline incorrect alignment */
5795 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
5797 /* Accept this monster */
5801 /* Notice failure */
5802 if (!r_idx || !attempts) return FALSE;
5804 /* Note the alignment */
5805 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
5806 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
5811 /* Find and reserve some space in the dungeon. Get center of room. */
5812 if (!find_space(&yval, &xval, 13, 25)) return FALSE;
5820 /* Fill with inner walls */
5821 for (y = y1 - 1; y <= y2 + 1; y++)
5823 for (x = x1 - 1; x <= x2 + 1; x++)
5825 c_ptr = &cave[y][x];
5826 place_inner_grid(c_ptr);
5827 c_ptr->info |= (CAVE_ROOM);
5831 /* Place the floor area 1 */
5832 for (x = x1 + 3; x <= x2 - 3; x++)
5834 c_ptr = &cave[yval-2][x];
5835 place_floor_grid(c_ptr);
5836 add_cave_info(yval-2, x, CAVE_ICKY);
5838 c_ptr = &cave[yval+2][x];
5839 place_floor_grid(c_ptr);
5840 add_cave_info(yval+2, x, CAVE_ICKY);
5843 /* Place the floor area 2 */
5844 for (x = x1 + 5; x <= x2 - 5; x++)
5846 c_ptr = &cave[yval-3][x];
5847 place_floor_grid(c_ptr);
5848 add_cave_info(yval-3, x, CAVE_ICKY);
5850 c_ptr = &cave[yval+3][x];
5851 place_floor_grid(c_ptr);
5852 add_cave_info(yval+3, x, CAVE_ICKY);
5856 for (x = x1; x <= x2; x++)
5858 c_ptr = &cave[yval][x];
5859 place_floor_grid(c_ptr);
5860 c_ptr = &cave[y1][x];
5861 place_floor_grid(c_ptr);
5862 c_ptr = &cave[y2][x];
5863 place_floor_grid(c_ptr);
5866 /* Place the outer walls */
5867 for (y = y1 - 1; y <= y2 + 1; y++)
5869 c_ptr = &cave[y][x1 - 1];
5870 place_outer_grid(c_ptr);
5871 c_ptr = &cave[y][x2 + 1];
5872 place_outer_grid(c_ptr);
5874 for (x = x1 - 1; x <= x2 + 1; x++)
5876 c_ptr = &cave[y1 - 1][x];
5877 place_outer_grid(c_ptr);
5878 c_ptr = &cave[y2 + 1][x];
5879 place_outer_grid(c_ptr);
5882 /* Random corridor */
5885 for (y = y1; y <= yval; y++)
5887 place_floor_bold(y, x2);
5888 place_solid_bold(y, x1-1);
5890 for (y = yval; y <= y2 + 1; y++)
5892 place_floor_bold(y, x1);
5893 place_solid_bold(y, x2+1);
5898 for (y = yval; y <= y2 + 1; y++)
5900 place_floor_bold(y, x1);
5901 place_solid_bold(y, x2+1);
5903 for (y = y1; y <= yval; y++)
5905 place_floor_bold(y, x2);
5906 place_solid_bold(y, x1-1);
5910 /* Place the wall open trap */
5911 cave[yval][xval].mimic = cave[yval][xval].feat;
5912 cave[yval][xval].feat = feat_trap_open;
5914 /* Sort the entries */
5915 for (i = 0; i < 16 - 1; i++)
5917 /* Sort the entries */
5918 for (j = 0; j < 16 - 1; j++)
5923 int p1 = r_info[what[i1]].level;
5924 int p2 = r_info[what[i2]].level;
5930 what[i1] = what[i2];
5941 msg_format("%s%s¤Î櫥ԥåÈ", n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
5943 msg_format("Trapped monster pit (%s%s)", n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
5947 /* Select the entries */
5948 for (i = 0; i < 8; i++)
5950 /* Every other entry */
5951 what[i] = what[i * 2];
5956 msg_print(r_name + r_info[what[i]].name);
5960 for (i = 0; placing[i][2] >= 0; i++)
5962 y = yval + placing[i][0];
5963 x = xval + placing[i][1];
5964 place_monster_aux(0, y, x, what[placing[i][2]], PM_NO_KAGE);
5972 * Type 14 -- trapped rooms
5974 * A special trap is placed at center of the room
5976 static bool build_type14(void)
5978 int y, x, y2, x2, yval, xval;
5979 int y1, x1, xsize, ysize;
5986 /* Pick a room size */
5992 xsize = x1 + x2 + 1;
5993 ysize = y1 + y2 + 1;
5995 /* Find and reserve some space in the dungeon. Get center of room. */
5996 if (!find_space(&yval, &xval, ysize + 2, xsize + 2)) return FALSE;
5998 /* Choose lite or dark */
5999 light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
6002 /* Get corner values */
6003 y1 = yval - ysize / 2;
6004 x1 = xval - xsize / 2;
6005 y2 = yval + (ysize - 1) / 2;
6006 x2 = xval + (xsize - 1) / 2;
6009 /* Place a full floor under the room */
6010 for (y = y1 - 1; y <= y2 + 1; y++)
6012 for (x = x1 - 1; x <= x2 + 1; x++)
6014 c_ptr = &cave[y][x];
6015 place_floor_grid(c_ptr);
6016 c_ptr->info |= (CAVE_ROOM);
6017 if (light) c_ptr->info |= (CAVE_GLOW);
6021 /* Walls around the room */
6022 for (y = y1 - 1; y <= y2 + 1; y++)
6024 c_ptr = &cave[y][x1 - 1];
6025 place_outer_grid(c_ptr);
6026 c_ptr = &cave[y][x2 + 1];
6027 place_outer_grid(c_ptr);
6029 for (x = x1 - 1; x <= x2 + 1; x++)
6031 c_ptr = &cave[y1 - 1][x];
6032 place_outer_grid(c_ptr);
6033 c_ptr = &cave[y2 + 1][x];
6034 place_outer_grid(c_ptr);
6037 if (dun_level < 30 + randint1(30))
6038 trap = feat_trap_piranha;
6040 trap = feat_trap_armageddon;
6042 /* Place a special trap */
6043 c_ptr = &cave[rand_spread(yval, ysize/4)][rand_spread(xval, xsize/4)];
6044 c_ptr->mimic = c_ptr->feat;
6051 msg_format("%s¤ÎÉô²°", f_name + f_info[trap].name);
6053 msg_format("Room of %s", f_name + f_info[trap].name);
6062 * Helper function for "glass room"
6064 static bool vault_aux_lite(int r_idx)
6066 monster_race *r_ptr = &r_info[r_idx];
6068 /* Validate the monster */
6069 if (!vault_monster_okay(r_idx)) return FALSE;
6071 /* Require lite attack */
6072 if (!(r_ptr->flags4 & RF4_BR_LITE) && !(r_ptr->flags5 & RF5_BA_LITE)) return FALSE;
6074 /* No wall passing monsters */
6075 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return FALSE;
6077 /* No disintegrating monsters */
6078 if (r_ptr->flags4 & RF4_BR_DISI) return FALSE;
6084 * Helper function for "glass room"
6086 static bool vault_aux_shards(int r_idx)
6088 monster_race *r_ptr = &r_info[r_idx];
6090 /* Validate the monster */
6091 if (!vault_monster_okay(r_idx)) return FALSE;
6093 /* Require shards breath attack */
6094 if (!(r_ptr->flags4 & RF4_BR_SHAR)) return FALSE;
6100 * Hack -- determine if a template is potion
6102 static bool kind_is_potion(int k_idx)
6104 return k_info[k_idx].tval == TV_POTION;
6108 * Type 15 -- glass rooms
6110 static bool build_type15(void)
6112 int y, x, y2, x2, yval, xval;
6113 int y1, x1, xsize, ysize;
6118 /* Pick a room size */
6119 xsize = rand_range(9, 13);
6120 ysize = rand_range(9, 13);
6122 /* Find and reserve some space in the dungeon. Get center of room. */
6123 if (!find_space(&yval, &xval, ysize + 2, xsize + 2)) return FALSE;
6125 /* Choose lite or dark */
6126 light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
6128 /* Get corner values */
6129 y1 = yval - ysize / 2;
6130 x1 = xval - xsize / 2;
6131 y2 = yval + (ysize - 1) / 2;
6132 x2 = xval + (xsize - 1) / 2;
6134 /* Place a full floor under the room */
6135 for (y = y1 - 1; y <= y2 + 1; y++)
6137 for (x = x1 - 1; x <= x2 + 1; x++)
6139 c_ptr = &cave[y][x];
6140 place_floor_grid(c_ptr);
6141 c_ptr->feat = feat_glass_floor;
6142 c_ptr->info |= (CAVE_ROOM);
6143 if (light) c_ptr->info |= (CAVE_GLOW);
6147 /* Walls around the room */
6148 for (y = y1 - 1; y <= y2 + 1; y++)
6150 c_ptr = &cave[y][x1 - 1];
6151 place_outer_grid(c_ptr);
6152 c_ptr->feat = feat_glass_wall;
6153 c_ptr = &cave[y][x2 + 1];
6154 place_outer_grid(c_ptr);
6155 c_ptr->feat = feat_glass_wall;
6157 for (x = x1 - 1; x <= x2 + 1; x++)
6159 c_ptr = &cave[y1 - 1][x];
6160 place_outer_grid(c_ptr);
6161 c_ptr->feat = feat_glass_wall;
6162 c_ptr = &cave[y2 + 1][x];
6163 place_outer_grid(c_ptr);
6164 c_ptr->feat = feat_glass_wall;
6167 switch (randint1(3))
6169 case 1: /* 4 lite breathers + potion */
6173 /* Prepare allocation table */
6174 get_mon_num_prep(vault_aux_lite, NULL);
6176 /* Place fixed lite berathers */
6177 for (dir1 = 4; dir1 < 8; dir1++)
6179 int r_idx = get_mon_num(dun_level);
6181 y = yval + 2 * ddy_ddd[dir1];
6182 x = xval + 2 * ddx_ddd[dir1];
6183 if (r_idx) place_monster_aux(0, y, x, r_idx, PM_ALLOW_SLEEP);
6185 /* Walls around the breather */
6186 for (dir2 = 0; dir2 < 8; dir2++)
6188 c_ptr = &cave[y + ddy_ddd[dir2]][x + ddx_ddd[dir2]];
6189 place_inner_grid(c_ptr);
6190 c_ptr->feat = feat_glass_wall;
6194 /* Walls around the potion */
6195 for (dir1 = 0; dir1 < 4; dir1++)
6197 y = yval + 2 * ddy_ddd[dir1];
6198 x = xval + 2 * ddx_ddd[dir1];
6199 c_ptr = &cave[y][x];
6200 place_inner_perm_grid(c_ptr);
6201 c_ptr->feat = feat_permanent_glass_wall;
6202 cave[yval + ddy_ddd[dir1]][xval + ddx_ddd[dir1]].info |= (CAVE_ICKY);
6207 y = yval + 2 * ddy_ddd[dir1];
6208 x = xval + 2 * ddx_ddd[dir1];
6209 place_secret_door(y, x, DOOR_GLASS_DOOR);
6210 c_ptr = &cave[y][x];
6211 if (is_closed_door(c_ptr->feat)) c_ptr->mimic = feat_glass_wall;
6213 /* Place a potion */
6214 get_obj_num_hook = kind_is_potion;
6215 place_object(yval, xval, AM_NO_FIXED_ART);
6216 cave[yval][xval].info |= (CAVE_ICKY);
6220 case 2: /* 1 lite breather + random object */
6225 c_ptr = &cave[y1 + 1][x1 + 1];
6226 place_inner_grid(c_ptr);
6227 c_ptr->feat = feat_glass_wall;
6229 c_ptr = &cave[y1 + 1][x2 - 1];
6230 place_inner_grid(c_ptr);
6231 c_ptr->feat = feat_glass_wall;
6233 c_ptr = &cave[y2 - 1][x1 + 1];
6234 place_inner_grid(c_ptr);
6235 c_ptr->feat = feat_glass_wall;
6237 c_ptr = &cave[y2 - 1][x2 - 1];
6238 place_inner_grid(c_ptr);
6239 c_ptr->feat = feat_glass_wall;
6241 /* Prepare allocation table */
6242 get_mon_num_prep(vault_aux_lite, NULL);
6244 r_idx = get_mon_num(dun_level);
6245 if (r_idx) place_monster_aux(0, yval, xval, r_idx, 0L);
6247 /* Walls around the breather */
6248 for (dir1 = 0; dir1 < 8; dir1++)
6250 c_ptr = &cave[yval + ddy_ddd[dir1]][xval + ddx_ddd[dir1]];
6251 place_inner_grid(c_ptr);
6252 c_ptr->feat = feat_glass_wall;
6255 /* Curtains around the breather */
6256 for (y = yval - 1; y <= yval + 1; y++)
6258 place_closed_door(y, xval - 2, DOOR_CURTAIN);
6259 place_closed_door(y, xval + 2, DOOR_CURTAIN);
6261 for (x = xval - 1; x <= xval + 1; x++)
6263 place_closed_door(yval - 2, x, DOOR_CURTAIN);
6264 place_closed_door(yval + 2, x, DOOR_CURTAIN);
6267 /* Place an object */
6268 place_object(yval, xval, AM_NO_FIXED_ART);
6269 cave[yval][xval].info |= (CAVE_ICKY);
6273 case 3: /* 4 shards breathers + 2 potions */
6277 /* Walls around the potion */
6278 for (y = yval - 2; y <= yval + 2; y++)
6280 c_ptr = &cave[y][xval - 3];
6281 place_inner_grid(c_ptr);
6282 c_ptr->feat = feat_glass_wall;
6283 c_ptr = &cave[y][xval + 3];
6284 place_inner_grid(c_ptr);
6285 c_ptr->feat = feat_glass_wall;
6287 for (x = xval - 2; x <= xval + 2; x++)
6289 c_ptr = &cave[yval - 3][x];
6290 place_inner_grid(c_ptr);
6291 c_ptr->feat = feat_glass_wall;
6292 c_ptr = &cave[yval + 3][x];
6293 place_inner_grid(c_ptr);
6294 c_ptr->feat = feat_glass_wall;
6296 for (dir1 = 4; dir1 < 8; dir1++)
6298 c_ptr = &cave[yval + 2 * ddy_ddd[dir1]][xval + 2 * ddx_ddd[dir1]];
6299 place_inner_grid(c_ptr);
6300 c_ptr->feat = feat_glass_wall;
6303 /* Prepare allocation table */
6304 get_mon_num_prep(vault_aux_shards, NULL);
6306 /* Place shard berathers */
6307 for (dir1 = 4; dir1 < 8; dir1++)
6309 int r_idx = get_mon_num(dun_level);
6311 y = yval + ddy_ddd[dir1];
6312 x = xval + ddx_ddd[dir1];
6313 if (r_idx) place_monster_aux(0, y, x, r_idx, 0L);
6316 /* Place two potions */
6319 get_obj_num_hook = kind_is_potion;
6320 place_object(yval, xval - 1, AM_NO_FIXED_ART);
6321 get_obj_num_hook = kind_is_potion;
6322 place_object(yval, xval + 1, AM_NO_FIXED_ART);
6326 get_obj_num_hook = kind_is_potion;
6327 place_object(yval - 1, xval, AM_NO_FIXED_ART);
6328 get_obj_num_hook = kind_is_potion;
6329 place_object(yval + 1, xval, AM_NO_FIXED_ART);
6332 for (y = yval - 2; y <= yval + 2; y++)
6333 for (x = xval - 2; x <= xval + 2; x++)
6334 cave[y][x].info |= (CAVE_ICKY);
6344 msg_print("¥¬¥é¥¹¤ÎÉô²°");
6346 msg_print("Glass room");
6354 /* Create a new floor room with optional light */
6355 void generate_room_floor(int y1, int x1, int y2, int x2, int light)
6361 for (y = y1; y <= y2; y++)
6363 for (x = x1; x <= x2; x++)
6366 c_ptr = &cave[y][x];
6367 place_floor_grid(c_ptr);
6368 c_ptr->info |= (CAVE_ROOM);
6369 if (light) c_ptr->info |= (CAVE_GLOW);
6374 void generate_fill_perm_bold(int y1, int x1, int y2, int x2)
6378 for (y = y1; y <= y2; y++)
6380 for (x = x1; x <= x2; x++)
6383 place_inner_perm_bold(y, x);
6388 /* Minimum & maximum town size */
6389 #define MIN_TOWN_WID ((MAX_WID / 3) / 2)
6390 #define MIN_TOWN_HGT ((MAX_HGT / 3) / 2)
6391 #define MAX_TOWN_WID ((MAX_WID / 3) * 2 / 3)
6392 #define MAX_TOWN_HGT ((MAX_HGT / 3) * 2 / 3)
6394 /* Struct for build underground buildings */
6397 int y0, x0; /* North-west corner (relative) */
6398 int y1, x1; /* South-east corner (relative) */
6402 ugbldg_type *ugbldg;
6405 * Precalculate buildings' location of underground arcade
6407 static bool precalc_ugarcade(int town_hgt, int town_wid, int n)
6409 int i, y, x, center_y, center_x, tmp, attempt = 10000;
6410 int max_bldg_hgt = 3 * town_hgt / MAX_TOWN_HGT;
6411 int max_bldg_wid = 5 * town_wid / MAX_TOWN_WID;
6412 ugbldg_type *cur_ugbldg;
6413 bool **ugarcade_used, abort;
6415 /* Allocate "ugarcade_used" array (2-dimension) */
6416 C_MAKE(ugarcade_used, town_hgt, bool *);
6417 C_MAKE(*ugarcade_used, town_hgt * town_wid, bool);
6418 for (y = 1; y < town_hgt; y++) ugarcade_used[y] = *ugarcade_used + y * town_wid;
6420 /* Calculate building locations */
6421 for (i = 0; i < n; i++)
6423 cur_ugbldg = &ugbldg[i];
6424 (void)WIPE(cur_ugbldg, ugbldg_type);
6428 /* Find the "center" of the store */
6429 center_y = rand_range(2, town_hgt - 3);
6430 center_x = rand_range(2, town_wid - 3);
6432 /* Determine the store boundaries */
6433 tmp = center_y - randint1(max_bldg_hgt);
6434 cur_ugbldg->y0 = MAX(tmp, 1);
6435 tmp = center_x - randint1(max_bldg_wid);
6436 cur_ugbldg->x0 = MAX(tmp, 1);
6437 tmp = center_y + randint1(max_bldg_hgt);
6438 cur_ugbldg->y1 = MIN(tmp, town_hgt - 2);
6439 tmp = center_x + randint1(max_bldg_wid);
6440 cur_ugbldg->x1 = MIN(tmp, town_wid - 2);
6442 /* Scan this building's area */
6443 for (abort = FALSE, y = cur_ugbldg->y0; (y <= cur_ugbldg->y1) && !abort; y++)
6445 for (x = cur_ugbldg->x0; x <= cur_ugbldg->x1; x++)
6447 if (ugarcade_used[y][x])
6457 while (abort && attempt); /* Accept this building if no overlapping */
6459 /* Failed to generate underground arcade */
6460 if (!attempt) break;
6463 * Mark to ugarcade_used[][] as "used"
6464 * Note: Building-adjacent grids are included for preventing
6465 * connected bulidings.
6467 for (y = cur_ugbldg->y0 - 1; y <= cur_ugbldg->y1 + 1; y++)
6469 for (x = cur_ugbldg->x0 - 1; x <= cur_ugbldg->x1 + 1; x++)
6471 ugarcade_used[y][x] = TRUE;
6476 /* Free "ugarcade_used" array (2-dimension) */
6477 C_KILL(*ugarcade_used, town_hgt * town_wid, bool);
6478 C_KILL(ugarcade_used, town_hgt, bool *);
6480 /* If i < n, generation is not allowed */
6485 * Actually create buildings
6486 * Note: ltcy and ltcx indicate "left top corner".
6488 static void build_stores(int ltcy, int ltcx, int stores[], int n)
6491 ugbldg_type *cur_ugbldg;
6493 for (i = 0; i < n; i++)
6495 cur_ugbldg = &ugbldg[i];
6497 /* Generate new room */
6498 generate_room_floor(
6499 ltcy + cur_ugbldg->y0 - 2, ltcx + cur_ugbldg->x0 - 2,
6500 ltcy + cur_ugbldg->y1 + 2, ltcx + cur_ugbldg->x1 + 2,
6504 for (i = 0; i < n; i++)
6506 cur_ugbldg = &ugbldg[i];
6508 /* Build an invulnerable rectangular building */
6509 generate_fill_perm_bold(
6510 ltcy + cur_ugbldg->y0, ltcx + cur_ugbldg->x0,
6511 ltcy + cur_ugbldg->y1, ltcx + cur_ugbldg->x1);
6513 /* Pick a door direction (S,N,E,W) */
6514 switch (randint0(4))
6519 x = rand_range(cur_ugbldg->x0, cur_ugbldg->x1);
6525 x = rand_range(cur_ugbldg->x0, cur_ugbldg->x1);
6530 y = rand_range(cur_ugbldg->y0, cur_ugbldg->y1);
6536 y = rand_range(cur_ugbldg->y0, cur_ugbldg->y1);
6541 for (j = 0; j < max_f_idx; j++)
6543 if (have_flag(f_info[j].flags, FF_STORE))
6545 if (f_info[j].subtype == stores[i]) break;
6549 /* Clear previous contents, add a store door */
6552 cave_set_feat(ltcy + y, ltcx + x, j);
6555 store_init(NO_TOWN, stores[i]);
6562 * Type 16 -- Underground Arcade
6564 * Town logic flow for generation of new town
6565 * Originally from Vanilla 3.0.3
6567 * We start with a fully wiped cave of normal floors.
6569 * Note that town_gen_hack() plays games with the R.N.G.
6571 * This function does NOT do anything about the owners of the stores,
6572 * nor the contents thereof. It only handles the physical layout.
6574 static bool build_type16(void)
6578 STORE_GENERAL, STORE_ARMOURY, STORE_WEAPON, STORE_TEMPLE,
6579 STORE_ALCHEMIST, STORE_MAGIC, STORE_BLACK, STORE_BOOK,
6581 int n = sizeof stores / sizeof (int);
6582 int i, y, x, y1, x1, yval, xval;
6583 int town_hgt = rand_range(MIN_TOWN_HGT, MAX_TOWN_HGT);
6584 int town_wid = rand_range(MIN_TOWN_WID, MAX_TOWN_WID);
6585 bool prevent_bm = FALSE;
6587 /* Hack -- If already exist black market, prevent building */
6588 for (y = 0; (y < cur_hgt) && !prevent_bm; y++)
6590 for (x = 0; x < cur_wid; x++)
6592 if (cave[y][x].feat == FF_STORE)
6594 prevent_bm = (f_info[cave[y][x].feat].subtype == STORE_BLACK);
6599 for (i = 0; i < n; i++)
6601 if ((stores[i] == STORE_BLACK) && prevent_bm) stores[i] = stores[--n];
6603 if (!n) return FALSE;
6605 /* Allocate buildings array */
6606 C_MAKE(ugbldg, n, ugbldg_type);
6608 /* If cannot build stores, abort */
6609 if (!precalc_ugarcade(town_hgt, town_wid, n))
6611 /* Free buildings array */
6612 C_KILL(ugbldg, n, ugbldg_type);
6616 /* Find and reserve some space in the dungeon. Get center of room. */
6617 if (!find_space(&yval, &xval, town_hgt + 4, town_wid + 4))
6619 /* Free buildings array */
6620 C_KILL(ugbldg, n, ugbldg_type);
6624 /* Get top left corner */
6625 y1 = yval - (town_hgt / 2);
6626 x1 = xval - (town_wid / 2);
6628 /* Generate new room */
6629 generate_room_floor(
6630 y1 + town_hgt / 3, x1 + town_wid / 3,
6631 y1 + town_hgt * 2 / 3, x1 + town_wid * 2 / 3, FALSE);
6634 build_stores(y1, x1, stores, n);
6637 if (cheat_room) msg_print("Ãϲ¼³¹");
6639 if (cheat_room) msg_print("Underground Arcade");
6642 /* Free buildings array */
6643 C_KILL(ugbldg, n, ugbldg_type);
6650 * Attempt to build a room of the given type at the given block
6652 * Note that we restrict the number of "crowded" rooms to reduce
6653 * the chance of overflowing the monster list during level creation.
6655 static bool room_build(int typ)
6660 /* Build an appropriate room */
6661 case ROOM_T_NORMAL: return build_type1();
6662 case ROOM_T_OVERLAP: return build_type2();
6663 case ROOM_T_CROSS: return build_type3();
6664 case ROOM_T_INNER_FEAT: return build_type4();
6665 case ROOM_T_NEST: return build_type5();
6666 case ROOM_T_PIT: return build_type6();
6667 case ROOM_T_LESSER_VAULT: return build_type7();
6668 case ROOM_T_GREATER_VAULT: return build_type8();
6669 case ROOM_T_FRACAVE: return build_type9();
6670 case ROOM_T_RANDOM_VAULT: return build_type10();
6671 case ROOM_T_OVAL: return build_type11();
6672 case ROOM_T_CRYPT: return build_type12();
6673 case ROOM_T_TRAP_PIT: return build_type13();
6674 case ROOM_T_TRAP: return build_type14();
6675 case ROOM_T_GLASS: return build_type15();
6676 case ROOM_T_ARCADE: return build_type16();
6684 #define MOVE_PLIST(dst, src) (prob_list[dst] += prob_list[src], prob_list[src] = 0)
6687 * [from SAngband (originally from OAngband)]
6689 * Generate rooms in dungeon. Build bigger rooms at first.
6691 bool generate_rooms(void)
6697 int prob_list[ROOM_T_MAX];
6698 int rooms_built = 0;
6699 int area_size = 100 * (cur_hgt*cur_wid) / (MAX_HGT*MAX_WID);
6700 int level_index = MIN(10, div_round(dun_level, 10));
6702 /* Number of each type of room on this level */
6703 s16b room_num[ROOM_T_MAX];
6705 /* Limit number of rooms */
6706 int dun_rooms = DUN_ROOMS_MAX * area_size / 100;
6708 /* Assume normal cave */
6709 room_info_type *room_info_ptr = room_info_normal;
6712 * Initialize probability list.
6714 for (i = 0; i < ROOM_T_MAX; i++)
6716 /* No rooms allowed above their minimum depth. */
6717 if (dun_level < room_info_ptr[i].min_level)
6723 prob_list[i] = room_info_ptr[i].prob[level_index];
6728 * XXX -- Various dungeon types and options.
6731 /* Ironman sees only Greater Vaults */
6732 if (ironman_rooms && !((d_info[dungeon_type].flags1 & (DF1_BEGINNER | DF1_CHAMELEON | DF1_SMALLEST))))
6734 for (i = 0; i < ROOM_T_MAX; i++)
6736 if (i == ROOM_T_GREATER_VAULT) prob_list[i] = 1;
6737 else prob_list[i] = 0;
6741 /* Forbidden vaults */
6742 else if (d_info[dungeon_type].flags1 & DF1_NO_VAULT)
6744 prob_list[ROOM_T_LESSER_VAULT] = 0;
6745 prob_list[ROOM_T_GREATER_VAULT] = 0;
6746 prob_list[ROOM_T_RANDOM_VAULT] = 0;
6750 /* NO_CAVE dungeon (Castle)*/
6751 if (d_info[dungeon_type].flags1 & DF1_NO_CAVE)
6753 MOVE_PLIST(ROOM_T_NORMAL, ROOM_T_FRACAVE);
6754 MOVE_PLIST(ROOM_T_INNER_FEAT, ROOM_T_CRYPT);
6755 MOVE_PLIST(ROOM_T_INNER_FEAT, ROOM_T_OVAL);
6758 /* CAVE dungeon (Orc cave etc.) */
6759 else if (d_info[dungeon_type].flags1 & DF1_CAVE)
6761 MOVE_PLIST(ROOM_T_FRACAVE, ROOM_T_NORMAL);
6764 /* No caves when a (random) cavern exists: they look bad */
6765 else if (dun->cavern || dun->empty_level)
6767 prob_list[ROOM_T_FRACAVE] = 0;
6770 /* Forbidden glass rooms */
6771 if (!(d_info[dungeon_type].flags1 & DF1_GLASS_ROOM))
6773 prob_list[ROOM_T_GLASS] = 0;
6776 if (!(d_info[dungeon_type].flags1 & DF1_ARCADE))
6778 prob_list[ROOM_T_ARCADE] = 0;
6782 * Initialize number of rooms,
6783 * And calcurate total probability.
6785 for (total_prob = 0, i = 0; i < ROOM_T_MAX; i++)
6788 total_prob += prob_list[i];
6792 * Prepare the number of rooms, of all types, we should build
6795 for (i = dun_rooms; i > 0; i--)
6798 int rand = randint0(total_prob);
6800 /* Get room_type randomly */
6801 for (room_type = 0; room_type < ROOM_T_MAX; room_type++)
6803 if (rand < prob_list[room_type]) break;
6804 else rand -= prob_list[room_type];
6808 if (room_type >= ROOM_T_MAX) room_type = ROOM_T_NORMAL;
6810 /* Increase the number of rooms of that type we should build. */
6811 room_num[room_type]++;
6817 case ROOM_T_LESSER_VAULT:
6818 case ROOM_T_TRAP_PIT:
6826 case ROOM_T_GREATER_VAULT:
6827 case ROOM_T_RANDOM_VAULT:
6836 * Build each type of room one by one until we cannot build any more.
6837 * [from SAngband (originally from OAngband)]
6841 /* Assume no remaining rooms */
6844 for (i = 0; i < ROOM_T_MAX; i++)
6846 /* What type of room are we building now? */
6847 int room_type = room_build_order[i];
6849 /* Go next if none available */
6850 if (!room_num[room_type]) continue;
6852 /* Use up one unit */
6853 room_num[room_type]--;
6855 /* Build the room. */
6856 if (room_build(room_type))
6858 /* Increase the room built count. */
6861 /* Mark as there was some remaining rooms */
6868 case ROOM_T_TRAP_PIT:
6870 /* Avoid too many monsters */
6873 room_num[ROOM_T_PIT] = 0;
6874 room_num[ROOM_T_NEST] = 0;
6875 room_num[ROOM_T_TRAP_PIT] = 0;
6881 /* Avoid double-town */
6882 room_num[ROOM_T_ARCADE] = 0;
6888 /* End loop if no room remain */
6892 if (rooms_built < 2) return FALSE;
6897 msg_format("Éô²°¿ô: %d", rooms_built);
6899 msg_format("Number of Rooms: %d", rooms_built);