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
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);
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.
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 blocks_high 範囲の高さ
307 * @param blocks_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(POSITION *y, POSITION *x, POSITION height, POSITION 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 = (byte_hack)*y;
490 dun->cent[dun->cent_n].x = (byte_hack)*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);
519 * @brief タイプ1の部屋…通常可変長方形の部屋を生成する / Type 1 -- normal rectangular rooms
522 static bool build_type1(void)
524 POSITION y, x, y2, x2, yval, xval;
525 POSITION y1, x1, xsize, ysize;
531 bool curtain = (d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
532 one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 48 : 512);
534 /* Pick a room size */
543 /* Find and reserve some space in the dungeon. Get center of room. */
544 if (!find_space(&yval, &xval, ysize + 2, xsize + 2))
546 /* Limit to the minimum room size, and retry */
555 /* Find and reserve some space in the dungeon. Get center of room. */
556 if (!find_space(&yval, &xval, ysize + 2, xsize + 2)) return FALSE;
559 /* Choose lite or dark */
560 light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
563 /* Get corner values */
564 y1 = yval - ysize / 2;
565 x1 = xval - xsize / 2;
566 y2 = yval + (ysize - 1) / 2;
567 x2 = xval + (xsize - 1) / 2;
570 /* Place a full floor under the room */
571 for (y = y1 - 1; y <= y2 + 1; y++)
573 for (x = x1 - 1; x <= x2 + 1; x++)
576 place_floor_grid(c_ptr);
577 c_ptr->info |= (CAVE_ROOM);
578 if (light) c_ptr->info |= (CAVE_GLOW);
582 /* Walls around the room */
583 for (y = y1 - 1; y <= y2 + 1; y++)
585 c_ptr = &cave[y][x1 - 1];
586 place_outer_grid(c_ptr);
587 c_ptr = &cave[y][x2 + 1];
588 place_outer_grid(c_ptr);
590 for (x = x1 - 1; x <= x2 + 1; x++)
592 c_ptr = &cave[y1 - 1][x];
593 place_outer_grid(c_ptr);
594 c_ptr = &cave[y2 + 1][x];
595 place_outer_grid(c_ptr);
599 /* Hack -- Occasional curtained room */
600 if (curtain && (y2 - y1 > 2) && (x2 - x1 > 2))
602 for (y = y1; y <= y2; y++)
604 c_ptr = &cave[y][x1];
605 c_ptr->feat = feat_door[DOOR_CURTAIN].closed;
606 c_ptr->info &= ~(CAVE_MASK);
607 c_ptr = &cave[y][x2];
608 c_ptr->feat = feat_door[DOOR_CURTAIN].closed;
609 c_ptr->info &= ~(CAVE_MASK);
611 for (x = x1; x <= x2; x++)
613 c_ptr = &cave[y1][x];
614 c_ptr->feat = feat_door[DOOR_CURTAIN].closed;
615 c_ptr->info &= ~(CAVE_MASK);
616 c_ptr = &cave[y2][x];
617 c_ptr->feat = feat_door[DOOR_CURTAIN].closed;
618 c_ptr->info &= ~(CAVE_MASK);
623 /* Hack -- Occasional pillar room */
626 for (y = y1; y <= y2; y += 2)
628 for (x = x1; x <= x2; x += 2)
631 place_inner_grid(c_ptr);
636 /* Hack -- Occasional room with four pillars */
637 else if (one_in_(20))
639 if ((y1 + 4 < y2) && (x1 + 4 < x2))
641 c_ptr = &cave[y1 + 1][x1 + 1];
642 place_inner_grid(c_ptr);
644 c_ptr = &cave[y1 + 1][x2 - 1];
645 place_inner_grid(c_ptr);
647 c_ptr = &cave[y2 - 1][x1 + 1];
648 place_inner_grid(c_ptr);
650 c_ptr = &cave[y2 - 1][x2 - 1];
651 place_inner_grid(c_ptr);
655 /* Hack -- Occasional ragged-edge room */
656 else if (one_in_(50))
658 for (y = y1 + 2; y <= y2 - 2; y += 2)
660 c_ptr = &cave[y][x1];
661 place_inner_grid(c_ptr);
662 c_ptr = &cave[y][x2];
663 place_inner_grid(c_ptr);
665 for (x = x1 + 2; x <= x2 - 2; x += 2)
667 c_ptr = &cave[y1][x];
668 place_inner_grid(c_ptr);
669 c_ptr = &cave[y2][x];
670 place_inner_grid(c_ptr);
673 /* Hack -- Occasional divided room */
674 else if (one_in_(50))
676 bool curtain2 = (d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
677 one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 2 : 128);
679 if (randint1(100) < 50)
681 /* Horizontal wall */
682 for (x = x1; x <= x2; x++)
684 place_inner_bold(yval, x);
685 if (curtain2) cave[yval][x].feat = feat_door[DOOR_CURTAIN].closed;
688 /* Prevent edge of wall from being tunneled */
689 place_solid_bold(yval, x1 - 1);
690 place_solid_bold(yval, x2 + 1);
695 for (y = y1; y <= y2; y++)
697 place_inner_bold(y, xval);
698 if (curtain2) cave[y][xval].feat = feat_door[DOOR_CURTAIN].closed;
701 /* Prevent edge of wall from being tunneled */
702 place_solid_bold(y1 - 1, xval);
703 place_solid_bold(y2 + 1, xval);
706 place_random_door(yval, xval, TRUE);
707 if (curtain2) cave[yval][xval].feat = feat_door[DOOR_CURTAIN].closed;
714 * @brief タイプ2の部屋…二重長方形の部屋を生成する / Type 2 -- Overlapping rectangular rooms
717 static bool build_type2(void)
719 POSITION y, x, xval, yval;
720 POSITION y1a, x1a, y2a, x2a;
721 POSITION y1b, x1b, y2b, x2b;
725 /* Find and reserve some space in the dungeon. Get center of room. */
726 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
728 /* Choose lite or dark */
729 light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
731 /* Determine extents of the first room */
732 y1a = yval - randint1(4);
733 y2a = yval + randint1(3);
734 x1a = xval - randint1(11);
735 x2a = xval + randint1(10);
737 /* Determine extents of the second room */
738 y1b = yval - randint1(3);
739 y2b = yval + randint1(4);
740 x1b = xval - randint1(10);
741 x2b = xval + randint1(11);
744 /* Place a full floor for room "a" */
745 for (y = y1a - 1; y <= y2a + 1; y++)
747 for (x = x1a - 1; x <= x2a + 1; x++)
750 place_floor_grid(c_ptr);
751 c_ptr->info |= (CAVE_ROOM);
752 if (light) c_ptr->info |= (CAVE_GLOW);
756 /* Place a full floor for room "b" */
757 for (y = y1b - 1; y <= y2b + 1; y++)
759 for (x = x1b - 1; x <= x2b + 1; x++)
762 place_floor_grid(c_ptr);
763 c_ptr->info |= (CAVE_ROOM);
764 if (light) c_ptr->info |= (CAVE_GLOW);
769 /* Place the walls around room "a" */
770 for (y = y1a - 1; y <= y2a + 1; y++)
772 c_ptr = &cave[y][x1a - 1];
773 place_outer_grid(c_ptr);
774 c_ptr = &cave[y][x2a + 1];
775 place_outer_grid(c_ptr);
777 for (x = x1a - 1; x <= x2a + 1; x++)
779 c_ptr = &cave[y1a - 1][x];
780 place_outer_grid(c_ptr);
781 c_ptr = &cave[y2a + 1][x];
782 place_outer_grid(c_ptr);
785 /* Place the walls around room "b" */
786 for (y = y1b - 1; y <= y2b + 1; y++)
788 c_ptr = &cave[y][x1b - 1];
789 place_outer_grid(c_ptr);
790 c_ptr = &cave[y][x2b + 1];
791 place_outer_grid(c_ptr);
793 for (x = x1b - 1; x <= x2b + 1; x++)
795 c_ptr = &cave[y1b - 1][x];
796 place_outer_grid(c_ptr);
797 c_ptr = &cave[y2b + 1][x];
798 place_outer_grid(c_ptr);
803 /* Replace the floor for room "a" */
804 for (y = y1a; y <= y2a; y++)
806 for (x = x1a; x <= x2a; x++)
809 place_floor_grid(c_ptr);
813 /* Replace the floor for room "b" */
814 for (y = y1b; y <= y2b; y++)
816 for (x = x1b; x <= x2b; x++)
819 place_floor_grid(c_ptr);
829 * @brief タイプ2の部屋…十字型の部屋を生成する / Type 3 -- Cross shaped rooms
832 * Builds a room at a row, column coordinate\n
834 * Room "a" runs north/south, and Room "b" runs east/east\n
835 * So the "central pillar" runs from x1a, y1b to x2a, y2b.\n
837 * Note that currently, the "center" is always 3x3, but I think that\n
838 * the code below will work (with "bounds checking") for 5x5, or even\n
839 * for unsymetric values like 4x3 or 5x3 or 3x4 or 3x5, or even larger.\n
841 static bool build_type3(void)
843 POSITION y, x, dy, dx, wy, wx;
844 POSITION y1a, x1a, y2a, x2a;
845 POSITION y1b, x1b, y2b, x2b;
851 /* Find and reserve some space in the dungeon. Get center of room. */
852 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
855 /* Choose lite or dark */
856 light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
858 /* For now, always 3x3 */
861 /* Pick max vertical size (at most 4) */
862 dy = rand_range(3, 4);
864 /* Pick max horizontal size (at most 15) */
865 dx = rand_range(3, 11);
868 /* Determine extents of the north/south room */
874 /* Determine extents of the east/west room */
881 /* Place a full floor for room "a" */
882 for (y = y1a - 1; y <= y2a + 1; y++)
884 for (x = x1a - 1; x <= x2a + 1; x++)
887 place_floor_grid(c_ptr);
888 c_ptr->info |= (CAVE_ROOM);
889 if (light) c_ptr->info |= (CAVE_GLOW);
893 /* Place a full floor for room "b" */
894 for (y = y1b - 1; y <= y2b + 1; y++)
896 for (x = x1b - 1; x <= x2b + 1; x++)
899 place_floor_grid(c_ptr);
900 c_ptr->info |= (CAVE_ROOM);
901 if (light) c_ptr->info |= (CAVE_GLOW);
906 /* Place the walls around room "a" */
907 for (y = y1a - 1; y <= y2a + 1; y++)
909 c_ptr = &cave[y][x1a - 1];
910 place_outer_grid(c_ptr);
911 c_ptr = &cave[y][x2a + 1];
912 place_outer_grid(c_ptr);
914 for (x = x1a - 1; x <= x2a + 1; x++)
916 c_ptr = &cave[y1a - 1][x];
917 place_outer_grid(c_ptr);
918 c_ptr = &cave[y2a + 1][x];
919 place_outer_grid(c_ptr);
922 /* Place the walls around room "b" */
923 for (y = y1b - 1; y <= y2b + 1; y++)
925 c_ptr = &cave[y][x1b - 1];
926 place_outer_grid(c_ptr);
927 c_ptr = &cave[y][x2b + 1];
928 place_outer_grid(c_ptr);
930 for (x = x1b - 1; x <= x2b + 1; x++)
932 c_ptr = &cave[y1b - 1][x];
933 place_outer_grid(c_ptr);
934 c_ptr = &cave[y2b + 1][x];
935 place_outer_grid(c_ptr);
939 /* Replace the floor for room "a" */
940 for (y = y1a; y <= y2a; y++)
942 for (x = x1a; x <= x2a; x++)
945 place_floor_grid(c_ptr);
949 /* Replace the floor for room "b" */
950 for (y = y1b; y <= y2b; y++)
952 for (x = x1b; x <= x2b; x++)
955 place_floor_grid(c_ptr);
961 /* Special features (3/4) */
964 /* Large solid middle pillar */
967 for (y = y1b; y <= y2b; y++)
969 for (x = x1a; x <= x2a; x++)
972 place_inner_grid(c_ptr);
978 /* Inner treasure vault */
981 /* Build the vault */
982 for (y = y1b; y <= y2b; y++)
984 c_ptr = &cave[y][x1a];
985 place_inner_grid(c_ptr);
986 c_ptr = &cave[y][x2a];
987 place_inner_grid(c_ptr);
989 for (x = x1a; x <= x2a; x++)
991 c_ptr = &cave[y1b][x];
992 place_inner_grid(c_ptr);
993 c_ptr = &cave[y2b][x];
994 place_inner_grid(c_ptr);
997 /* Place a secret door on the inner room */
1000 case 0: place_secret_door(y1b, xval, DOOR_DEFAULT); break;
1001 case 1: place_secret_door(y2b, xval, DOOR_DEFAULT); break;
1002 case 2: place_secret_door(yval, x1a, DOOR_DEFAULT); break;
1003 case 3: place_secret_door(yval, x2a, DOOR_DEFAULT); break;
1006 /* Place a treasure in the vault */
1007 place_object(yval, xval, 0L);
1009 /* Let's guard the treasure well */
1010 vault_monsters(yval, xval, randint0(2) + 3);
1012 /* Traps naturally */
1013 vault_traps(yval, xval, 4, 4, randint0(3) + 2);
1018 /* Something else */
1021 /* Occasionally pinch the center shut */
1024 /* Pinch the east/west sides */
1025 for (y = y1b; y <= y2b; y++)
1027 if (y == yval) continue;
1028 c_ptr = &cave[y][x1a - 1];
1029 place_inner_grid(c_ptr);
1030 c_ptr = &cave[y][x2a + 1];
1031 place_inner_grid(c_ptr);
1034 /* Pinch the north/south sides */
1035 for (x = x1a; x <= x2a; x++)
1037 if (x == xval) continue;
1038 c_ptr = &cave[y1b - 1][x];
1039 place_inner_grid(c_ptr);
1040 c_ptr = &cave[y2b + 1][x];
1041 place_inner_grid(c_ptr);
1044 /* Sometimes shut using secret doors */
1047 int door_type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
1048 one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
1049 ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
1051 place_secret_door(yval, x1a - 1, door_type);
1052 place_secret_door(yval, x2a + 1, door_type);
1053 place_secret_door(y1b - 1, xval, door_type);
1054 place_secret_door(y2b + 1, xval, door_type);
1058 /* Occasionally put a "plus" in the center */
1059 else if (one_in_(3))
1061 c_ptr = &cave[yval][xval];
1062 place_inner_grid(c_ptr);
1063 c_ptr = &cave[y1b][xval];
1064 place_inner_grid(c_ptr);
1065 c_ptr = &cave[y2b][xval];
1066 place_inner_grid(c_ptr);
1067 c_ptr = &cave[yval][x1a];
1068 place_inner_grid(c_ptr);
1069 c_ptr = &cave[yval][x2a];
1070 place_inner_grid(c_ptr);
1073 /* Occasionally put a pillar in the center */
1074 else if (one_in_(3))
1076 c_ptr = &cave[yval][xval];
1077 place_inner_grid(c_ptr);
1089 * @brief タイプ4の部屋…固定サイズの二重構造部屋を生成する / Type 4 -- Large room with inner features
1092 * Possible sub-types:\n
1093 * 1 - Just an inner room with one door\n
1094 * 2 - An inner room within an inner room\n
1095 * 3 - An inner room with pillar(s)\n
1096 * 4 - Inner room has a maze\n
1097 * 5 - A set of four inner rooms\n
1099 static bool build_type4(void)
1101 POSITION y, x, y1, x1;
1102 POSITION y2, x2, tmp, yval, xval;
1107 /* Find and reserve some space in the dungeon. Get center of room. */
1108 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
1110 /* Choose lite or dark */
1111 light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
1119 /* Place a full floor under the room */
1120 for (y = y1 - 1; y <= y2 + 1; y++)
1122 for (x = x1 - 1; x <= x2 + 1; x++)
1124 c_ptr = &cave[y][x];
1125 place_floor_grid(c_ptr);
1126 c_ptr->info |= (CAVE_ROOM);
1127 if (light) c_ptr->info |= (CAVE_GLOW);
1132 for (y = y1 - 1; y <= y2 + 1; y++)
1134 c_ptr = &cave[y][x1 - 1];
1135 place_outer_grid(c_ptr);
1136 c_ptr = &cave[y][x2 + 1];
1137 place_outer_grid(c_ptr);
1139 for (x = x1 - 1; x <= x2 + 1; x++)
1141 c_ptr = &cave[y1 - 1][x];
1142 place_outer_grid(c_ptr);
1143 c_ptr = &cave[y2 + 1][x];
1144 place_outer_grid(c_ptr);
1148 /* The inner room */
1154 /* The inner walls */
1155 for (y = y1 - 1; y <= y2 + 1; y++)
1157 c_ptr = &cave[y][x1 - 1];
1158 place_inner_grid(c_ptr);
1159 c_ptr = &cave[y][x2 + 1];
1160 place_inner_grid(c_ptr);
1162 for (x = x1 - 1; x <= x2 + 1; x++)
1164 c_ptr = &cave[y1 - 1][x];
1165 place_inner_grid(c_ptr);
1166 c_ptr = &cave[y2 + 1][x];
1167 place_inner_grid(c_ptr);
1171 /* Inner room variations */
1172 switch (randint1(5))
1174 /* Just an inner room with a monster */
1177 /* Place a secret door */
1178 switch (randint1(4))
1180 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
1181 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
1182 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
1183 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
1186 /* Place a monster in the room */
1187 vault_monsters(yval, xval, 1);
1192 /* Treasure Vault (with a door) */
1195 /* Place a secret door */
1196 switch (randint1(4))
1198 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
1199 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
1200 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
1201 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
1204 /* Place another inner room */
1205 for (y = yval - 1; y <= yval + 1; y++)
1207 for (x = xval - 1; x <= xval + 1; x++)
1209 if ((x == xval) && (y == yval)) continue;
1210 c_ptr = &cave[y][x];
1211 place_inner_grid(c_ptr);
1215 /* Place a locked door on the inner room */
1216 switch (randint1(4))
1218 case 1: place_locked_door(yval - 1, xval); break;
1219 case 2: place_locked_door(yval + 1, xval); break;
1220 case 3: place_locked_door(yval, xval - 1); break;
1221 case 4: place_locked_door(yval, xval + 1); break;
1224 /* Monsters to guard the "treasure" */
1225 vault_monsters(yval, xval, randint1(3) + 2);
1228 if (randint0(100) < 80)
1230 place_object(yval, xval, 0L);
1236 place_random_stairs(yval, xval);
1239 /* Traps to protect the treasure */
1240 vault_traps(yval, xval, 4, 10, 2 + randint1(3));
1245 /* Inner pillar(s). */
1248 /* Place a secret door */
1249 switch (randint1(4))
1251 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
1252 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
1253 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
1254 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
1257 /* Large Inner Pillar */
1258 for (y = yval - 1; y <= yval + 1; y++)
1260 for (x = xval - 1; x <= xval + 1; x++)
1262 c_ptr = &cave[y][x];
1263 place_inner_grid(c_ptr);
1267 /* Occasionally, two more Large Inner Pillars */
1271 for (y = yval - 1; y <= yval + 1; y++)
1273 for (x = xval - 5 - tmp; x <= xval - 3 - tmp; x++)
1275 c_ptr = &cave[y][x];
1276 place_inner_grid(c_ptr);
1278 for (x = xval + 3 + tmp; x <= xval + 5 + tmp; x++)
1280 c_ptr = &cave[y][x];
1281 place_inner_grid(c_ptr);
1286 /* Occasionally, some Inner rooms */
1289 int door_type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
1290 one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
1291 ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
1293 /* Long horizontal walls */
1294 for (x = xval - 5; x <= xval + 5; x++)
1296 c_ptr = &cave[yval - 1][x];
1297 place_inner_grid(c_ptr);
1298 c_ptr = &cave[yval + 1][x];
1299 place_inner_grid(c_ptr);
1302 /* Close off the left/right edges */
1303 c_ptr = &cave[yval][xval - 5];
1304 place_inner_grid(c_ptr);
1305 c_ptr = &cave[yval][xval + 5];
1306 place_inner_grid(c_ptr);
1308 /* Secret doors (random top/bottom) */
1309 place_secret_door(yval - 3 + (randint1(2) * 2), xval - 3, door_type);
1310 place_secret_door(yval - 3 + (randint1(2) * 2), xval + 3, door_type);
1313 vault_monsters(yval, xval - 2, randint1(2));
1314 vault_monsters(yval, xval + 2, randint1(2));
1317 if (one_in_(3)) place_object(yval, xval - 2, 0L);
1318 if (one_in_(3)) place_object(yval, xval + 2, 0L);
1327 /* Place a secret door */
1328 switch (randint1(4))
1330 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
1331 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
1332 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
1333 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
1336 /* Maze (really a checkerboard) */
1337 for (y = y1; y <= y2; y++)
1339 for (x = x1; x <= x2; x++)
1343 c_ptr = &cave[y][x];
1344 place_inner_grid(c_ptr);
1349 /* Monsters just love mazes. */
1350 vault_monsters(yval, xval - 5, randint1(3));
1351 vault_monsters(yval, xval + 5, randint1(3));
1353 /* Traps make them entertaining. */
1354 vault_traps(yval, xval - 3, 2, 8, randint1(3));
1355 vault_traps(yval, xval + 3, 2, 8, randint1(3));
1357 /* Mazes should have some treasure too. */
1358 vault_objects(yval, xval, 3);
1363 /* Four small rooms. */
1366 int door_type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
1367 one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
1368 ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
1371 for (y = y1; y <= y2; y++)
1373 c_ptr = &cave[y][xval];
1374 place_inner_grid(c_ptr);
1376 for (x = x1; x <= x2; x++)
1378 c_ptr = &cave[yval][x];
1379 place_inner_grid(c_ptr);
1382 /* Doors into the rooms */
1383 if (randint0(100) < 50)
1385 int i = randint1(10);
1386 place_secret_door(y1 - 1, xval - i, door_type);
1387 place_secret_door(y1 - 1, xval + i, door_type);
1388 place_secret_door(y2 + 1, xval - i, door_type);
1389 place_secret_door(y2 + 1, xval + i, door_type);
1393 int i = randint1(3);
1394 place_secret_door(yval + i, x1 - 1, door_type);
1395 place_secret_door(yval - i, x1 - 1, door_type);
1396 place_secret_door(yval + i, x2 + 1, door_type);
1397 place_secret_door(yval - i, x2 + 1, door_type);
1400 /* Treasure, centered at the center of the cross */
1401 vault_objects(yval, xval, 2 + randint1(2));
1403 /* Gotta have some monsters. */
1404 vault_monsters(yval + 1, xval - 4, randint1(4));
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));
1419 * vaultに配置可能なモンスターの条件を指定するマクロ / Monster validation macro
1421 * Line 1 -- forbid town monsters
1422 * Line 2 -- forbid uniques
1423 * Line 3 -- forbid aquatic monsters
1425 #define vault_monster_okay(I) \
1426 (mon_hook_dungeon(I) && \
1427 !(r_info[I].flags1 & RF1_UNIQUE) && \
1428 !(r_info[I].flags7 & RF7_UNIQUE2) && \
1429 !(r_info[I].flagsr & RFR_RES_ALL) && \
1430 !(r_info[I].flags7 & RF7_AQUATIC))
1433 /*! 通常pit生成時のモンスターの構成条件ID / Race index for "monster pit (clone)" */
1434 static int vault_aux_race;
1436 /*! 単一シンボルpit生成時の指定シンボル / Race index for "monster pit (symbol clone)" */
1437 static char vault_aux_char;
1439 /*! ブレス属性に基づくドラゴンpit生成時条件マスク / Breath mask for "monster pit (dragon)" */
1440 static u32b vault_aux_dragon_mask4;
1444 * @brief モンスターがVault生成の最低必要条件を満たしているかを返す /
1445 * Helper monster selection function
1446 * @param r_idx 確認したいモンスター種族ID
1447 * @return Vault生成の最低必要条件を満たしているならTRUEを返す。
1449 static bool vault_aux_simple(MONRACE_IDX r_idx)
1452 return (vault_monster_okay(r_idx));
1457 * @brief モンスターがゼリーnestの生成必要条件を満たしているかを返す /
1458 * Helper function for "monster nest (jelly)"
1459 * @param r_idx 確認したいモンスター種族ID
1460 * @return 生成必要条件を満たしているならTRUEを返す。
1462 static bool vault_aux_jelly(MONRACE_IDX r_idx)
1464 monster_race *r_ptr = &r_info[r_idx];
1466 /* Validate the monster */
1467 if (!vault_monster_okay(r_idx)) return (FALSE);
1469 if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
1471 /* Also decline evil jellies (like death molds and shoggoths) */
1472 if (r_ptr->flags3 & (RF3_EVIL)) return (FALSE);
1474 /* Require icky thing, jelly, mold, or mushroom */
1475 if (!my_strchr("ijm,", r_ptr->d_char)) return (FALSE);
1482 * @brief モンスターが動物nestの生成必要条件を満たしているかを返す /
1483 * Helper function for "monster nest (animal)"
1484 * @param r_idx 確認したいモンスター種族ID
1485 * @return 生成必要条件を満たしているならTRUEを返す。
1487 static bool vault_aux_animal(MONRACE_IDX r_idx)
1489 monster_race *r_ptr = &r_info[r_idx];
1491 /* Validate the monster */
1492 if (!vault_monster_okay(r_idx)) return (FALSE);
1494 /* Require "animal" flag */
1495 if (!(r_ptr->flags3 & (RF3_ANIMAL))) return (FALSE);
1503 * @brief モンスターがアンデッドnestの生成必要条件を満たしているかを返す /
1504 * Helper function for "monster nest (undead)"
1505 * @param r_idx 確認したいモンスター種族ID
1506 * @return 生成必要条件を満たしているならTRUEを返す。
1508 static bool vault_aux_undead(MONRACE_IDX r_idx)
1510 monster_race *r_ptr = &r_info[r_idx];
1512 /* Validate the monster */
1513 if (!vault_monster_okay(r_idx)) return (FALSE);
1515 /* Require Undead */
1516 if (!(r_ptr->flags3 & (RF3_UNDEAD))) return (FALSE);
1523 * @brief モンスターが聖堂nestの生成必要条件を満たしているかを返す /
1524 * Helper function for "monster nest (chapel)"
1525 * @param r_idx 確認したいモンスター種族ID
1526 * @return 生成必要条件を満たしているならTRUEを返す。
1528 static bool vault_aux_chapel_g(MONRACE_IDX r_idx)
1530 static int chapel_list[] = {
1531 MON_NOV_PRIEST, MON_NOV_PALADIN, MON_NOV_PRIEST_G, MON_NOV_PALADIN_G,
1532 MON_PRIEST, MON_JADE_MONK, MON_IVORY_MONK, MON_ULTRA_PALADIN,
1533 MON_EBONY_MONK, MON_W_KNIGHT, MON_KNI_TEMPLAR, MON_PALADIN,
1538 monster_race *r_ptr = &r_info[r_idx];
1540 /* Validate the monster */
1541 if (!vault_monster_okay(r_idx)) return (FALSE);
1543 if (r_ptr->flags3 & (RF3_EVIL)) return (FALSE);
1544 if ((r_idx == MON_A_GOLD) || (r_idx == MON_A_SILVER)) return (FALSE);
1546 /* Require "priest" or Angel */
1548 if (r_ptr->d_char == 'A') return TRUE;
1550 for (i = 0; chapel_list[i]; i++)
1551 if (r_idx == chapel_list[i]) return TRUE;
1557 * @brief モンスターが犬小屋nestの生成必要条件を満たしているかを返す /
1558 * Helper function for "monster nest (kennel)"
1559 * @param r_idx 確認したいモンスター種族ID
1560 * @return 生成必要条件を満たしているならTRUEを返す。
1562 static bool vault_aux_kennel(MONRACE_IDX r_idx)
1564 monster_race *r_ptr = &r_info[r_idx];
1566 /* Validate the monster */
1567 if (!vault_monster_okay(r_idx)) return (FALSE);
1569 /* Require a Zephyr Hound or a dog */
1570 if (!my_strchr("CZ", r_ptr->d_char)) return (FALSE);
1577 * @brief モンスターがミミックnestの生成必要条件を満たしているかを返す /
1578 * Helper function for "monster nest (mimic)"
1579 * @param r_idx 確認したいモンスター種族ID
1580 * @return 生成必要条件を満たしているならTRUEを返す。
1582 static bool vault_aux_mimic(MONRACE_IDX r_idx)
1584 monster_race *r_ptr = &r_info[r_idx];
1586 /* Validate the monster */
1587 if (!vault_monster_okay(r_idx)) return (FALSE);
1590 if (!my_strchr("!$&(/=?[\\|", r_ptr->d_char)) return (FALSE);
1597 * @brief モンスターが単一クローンnestの生成必要条件を満たしているかを返す /
1598 * Helper function for "monster nest (clone)"
1599 * @param r_idx 確認したいモンスター種族ID
1600 * @return 生成必要条件を満たしているならTRUEを返す。
1602 static bool vault_aux_clone(MONRACE_IDX r_idx)
1604 /* Validate the monster */
1605 if (!vault_monster_okay(r_idx)) return (FALSE);
1607 return (r_idx == vault_aux_race);
1612 * @brief モンスターが邪悪属性シンボルクローンnestの生成必要条件を満たしているかを返す /
1613 * Helper function for "monster nest (symbol clone)"
1614 * @param r_idx 確認したいモンスター種族ID
1615 * @return 生成必要条件を満たしているならTRUEを返す。
1617 static bool vault_aux_symbol_e(MONRACE_IDX r_idx)
1619 monster_race *r_ptr = &r_info[r_idx];
1621 /* Validate the monster */
1622 if (!vault_monster_okay(r_idx)) return (FALSE);
1624 if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
1626 if (r_ptr->flags3 & (RF3_GOOD)) return (FALSE);
1628 /* Decline incorrect symbol */
1629 if (r_ptr->d_char != vault_aux_char) return (FALSE);
1637 * @brief モンスターが善良属性シンボルクローンnestの生成必要条件を満たしているかを返す /
1638 * Helper function for "monster nest (symbol clone)"
1639 * @param r_idx 確認したいモンスター種族ID
1640 * @return 生成必要条件を満たしているならTRUEを返す。
1642 static bool vault_aux_symbol_g(MONRACE_IDX r_idx)
1644 monster_race *r_ptr = &r_info[r_idx];
1646 /* Validate the monster */
1647 if (!vault_monster_okay(r_idx)) return (FALSE);
1649 if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
1651 if (r_ptr->flags3 & (RF3_EVIL)) return (FALSE);
1653 /* Decline incorrect symbol */
1654 if (r_ptr->d_char != vault_aux_char) return (FALSE);
1662 * @brief モンスターがオークpitの生成必要条件を満たしているかを返す /
1663 * Helper function for "monster pit (orc)"
1664 * @param r_idx 確認したいモンスター種族ID
1665 * @return 生成必要条件を満たしているならTRUEを返す。
1667 static bool vault_aux_orc(MONRACE_IDX r_idx)
1669 monster_race *r_ptr = &r_info[r_idx];
1671 /* Validate the monster */
1672 if (!vault_monster_okay(r_idx)) return (FALSE);
1675 if (!(r_ptr->flags3 & RF3_ORC)) return (FALSE);
1677 /* Decline undead */
1678 if (r_ptr->flags3 & RF3_UNDEAD) return (FALSE);
1686 * @brief モンスターがトロルpitの生成必要条件を満たしているかを返す /
1687 * Helper function for "monster pit (troll)"
1688 * @param r_idx 確認したいモンスター種族ID
1689 * @return 生成必要条件を満たしているならTRUEを返す。
1691 static bool vault_aux_troll(MONRACE_IDX r_idx)
1693 monster_race *r_ptr = &r_info[r_idx];
1695 /* Validate the monster */
1696 if (!vault_monster_okay(r_idx)) return (FALSE);
1699 if (!(r_ptr->flags3 & RF3_TROLL)) return (FALSE);
1701 /* Decline undead */
1702 if (r_ptr->flags3 & RF3_UNDEAD) return (FALSE);
1710 * @brief モンスターが巨人pitの生成必要条件を満たしているかを返す /
1711 * Helper function for "monster pit (giant)"
1712 * @param r_idx 確認したいモンスター種族ID
1713 * @return 生成必要条件を満たしているならTRUEを返す。
1715 static bool vault_aux_giant(MONRACE_IDX r_idx)
1717 monster_race *r_ptr = &r_info[r_idx];
1719 /* Validate the monster */
1720 if (!vault_monster_okay(r_idx)) return (FALSE);
1723 if (!(r_ptr->flags3 & RF3_GIANT)) return (FALSE);
1725 if (r_ptr->flags3 & RF3_GOOD) return (FALSE);
1727 /* Decline undead */
1728 if (r_ptr->flags3 & RF3_UNDEAD) return (FALSE);
1736 * @brief モンスターがドラゴンpitの生成必要条件を満たしているかを返す /
1737 * Helper function for "monster pit (dragon)"
1738 * @param r_idx 確認したいモンスター種族ID
1739 * @return 生成必要条件を満たしているならTRUEを返す。
1741 static bool vault_aux_dragon(MONRACE_IDX r_idx)
1743 monster_race *r_ptr = &r_info[r_idx];
1745 /* Validate the monster */
1746 if (!vault_monster_okay(r_idx)) return (FALSE);
1748 /* Require dragon */
1749 if (!(r_ptr->flags3 & RF3_DRAGON)) return (FALSE);
1751 /* Hack -- Require correct "breath attack" */
1752 if (r_ptr->flags4 != vault_aux_dragon_mask4) return (FALSE);
1754 /* Decline undead */
1755 if (r_ptr->flags3 & RF3_UNDEAD) return (FALSE);
1763 * @brief モンスターが悪魔pitの生成必要条件を満たしているかを返す /
1764 * Helper function for "monster pit (demon)"
1765 * @param r_idx 確認したいモンスター種族ID
1766 * @return 生成必要条件を満たしているならTRUEを返す。
1768 static bool vault_aux_demon(MONRACE_IDX r_idx)
1770 monster_race *r_ptr = &r_info[r_idx];
1772 /* Validate the monster */
1773 if (!vault_monster_okay(r_idx)) return (FALSE);
1775 if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
1778 if (!(r_ptr->flags3 & RF3_DEMON)) return (FALSE);
1786 * @brief モンスターが狂気pitの生成必要条件を満たしているかを返す /
1787 * Helper function for "monster pit (lovecraftian)"
1788 * @param r_idx 確認したいモンスター種族ID
1789 * @return 生成必要条件を満たしているならTRUEを返す。
1791 static bool vault_aux_cthulhu(MONRACE_IDX r_idx)
1793 monster_race *r_ptr = &r_info[r_idx];
1795 /* Validate the monster */
1796 if (!vault_monster_okay(r_idx)) return (FALSE);
1798 if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
1800 /* Require eldritch horror */
1801 if (!(r_ptr->flags2 & (RF2_ELDRITCH_HORROR))) return (FALSE);
1809 * @brief pit/nestの基準となる単種モンスターを決める /
1812 static void vault_prep_clone(void)
1814 /* Apply the monster restriction */
1815 get_mon_num_prep(vault_aux_simple, NULL);
1817 /* Pick a race to clone */
1818 vault_aux_race = get_mon_num(dun_level + 10);
1820 /* Remove the monster restriction */
1821 get_mon_num_prep(NULL, NULL);
1826 * @brief pit/nestの基準となるモンスターシンボルを決める /
1829 static void vault_prep_symbol(void)
1833 /* Apply the monster restriction */
1834 get_mon_num_prep(vault_aux_simple, NULL);
1836 /* Pick a race to clone */
1837 r_idx = get_mon_num(dun_level + 10);
1839 /* Remove the monster restriction */
1840 get_mon_num_prep(NULL, NULL);
1842 /* Extract the symbol */
1843 vault_aux_char = r_info[r_idx].d_char;
1847 * @brief pit/nestの基準となるドラゴンの種類を決める /
1850 static void vault_prep_dragon(void)
1852 /* Pick dragon type */
1853 switch (randint0(6))
1858 /* Restrict dragon breath type */
1859 vault_aux_dragon_mask4 = RF4_BR_ACID;
1868 /* Restrict dragon breath type */
1869 vault_aux_dragon_mask4 = RF4_BR_ELEC;
1878 /* Restrict dragon breath type */
1879 vault_aux_dragon_mask4 = RF4_BR_FIRE;
1888 /* Restrict dragon breath type */
1889 vault_aux_dragon_mask4 = RF4_BR_COLD;
1898 /* Restrict dragon breath type */
1899 vault_aux_dragon_mask4 = RF4_BR_POIS;
1908 /* Restrict dragon breath type */
1909 vault_aux_dragon_mask4 = (RF4_BR_ACID | RF4_BR_ELEC |
1910 RF4_BR_FIRE | RF4_BR_COLD |
1921 * @brief モンスターがダークエルフpitの生成必要条件を満たしているかを返す /
1922 * Helper function for "monster pit (dark elf)"
1923 * @param r_idx 確認したいモンスター種族ID
1924 * @return 生成必要条件を満たしているならTRUEを返す。
1926 static bool vault_aux_dark_elf(MONRACE_IDX r_idx)
1929 static int dark_elf_list[] =
1931 MON_D_ELF, MON_D_ELF_MAGE, MON_D_ELF_WARRIOR, MON_D_ELF_PRIEST,
1932 MON_D_ELF_LORD, MON_D_ELF_WARLOCK, MON_D_ELF_DRUID, MON_NIGHTBLADE,
1933 MON_D_ELF_SORC, MON_D_ELF_SHADE, 0,
1936 /* Validate the monster */
1937 if (!vault_monster_okay(r_idx)) return FALSE;
1939 /* Require dark elves */
1940 for (i = 0; dark_elf_list[i]; i++)
1941 if (r_idx == dark_elf_list[i]) return TRUE;
1947 /*! pit/nest型情報のtypedef */
1948 typedef struct vault_aux_type vault_aux_type;
1950 /*! pit/nest型情報の構造体定義 */
1951 struct vault_aux_type
1954 bool (*hook_func)(MONRACE_IDX r_idx);
1955 void (*prep_func)(void);
1961 * @brief ダンジョン毎に指定されたピット配列を基準にランダムなpit/nestタイプを決める
1962 * @param l_ptr 選択されたpit/nest情報を返す参照ポインタ
1963 * @param allow_flag_mask 生成が許されるpit/nestのビット配列
1964 * @return 選択されたpit/nestのID、選択失敗した場合-1を返す。
1966 static int pick_vault_type(vault_aux_type *l_ptr, s16b allow_flag_mask)
1968 int tmp, total, count;
1970 vault_aux_type *n_ptr;
1972 /* Calculate the total possibilities */
1973 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
1976 if (!n_ptr->name) break;
1978 /* Ignore excessive depth */
1979 if (n_ptr->level > dun_level) continue;
1981 /* Not matched with pit/nest flag */
1982 if (!(allow_flag_mask & (1L << count))) continue;
1984 /* Count this possibility */
1985 total += n_ptr->chance * MAX_DEPTH / (MIN(dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
1988 /* Pick a random type */
1989 tmp = randint0(total);
1991 /* Find this type */
1992 for (n_ptr = l_ptr, total = 0, count = 0; TRUE; n_ptr++, count++)
1995 if (!n_ptr->name) break;
1997 /* Ignore excessive depth */
1998 if (n_ptr->level > dun_level) continue;
2000 /* Not matched with pit/nest flag */
2001 if (!(allow_flag_mask & (1L << count))) continue;
2003 /* Count this possibility */
2004 total += n_ptr->chance * MAX_DEPTH / (MIN(dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
2006 /* Found the type */
2007 if (tmp < total) break;
2010 return n_ptr->name ? count : -1;
2014 static vault_aux_type nest_types[] =
2017 {"クローン", vault_aux_clone, vault_prep_clone, 5, 3},
2018 {"ゼリー", vault_aux_jelly, NULL, 5, 6},
2019 {"シンボル(善)", vault_aux_symbol_g, vault_prep_symbol, 25, 2},
2020 {"シンボル(悪)", vault_aux_symbol_e, vault_prep_symbol, 25, 2},
2021 {"ミミック", vault_aux_mimic, NULL, 30, 4},
2022 {"狂気", vault_aux_cthulhu, NULL, 70, 2},
2023 {"犬小屋", vault_aux_kennel, NULL, 45, 4},
2024 {"動物園", vault_aux_animal, NULL, 35, 5},
2025 {"教会", vault_aux_chapel_g, NULL, 75, 4},
2026 {"アンデッド", vault_aux_undead, NULL, 75, 5},
2027 {NULL, NULL, NULL, 0, 0},
2029 {"clone", vault_aux_clone, vault_prep_clone, 5, 3},
2030 {"jelly", vault_aux_jelly, NULL, 5, 6},
2031 {"symbol good", vault_aux_symbol_g, vault_prep_symbol, 25, 2},
2032 {"symbol evil", vault_aux_symbol_e, vault_prep_symbol, 25, 2},
2033 {"mimic", vault_aux_mimic, NULL, 30, 4},
2034 {"lovecraftian", vault_aux_cthulhu, NULL, 70, 2},
2035 {"kennel", vault_aux_kennel, NULL, 45, 4},
2036 {"animal", vault_aux_animal, NULL, 35, 5},
2037 {"chapel", vault_aux_chapel_g, NULL, 75, 4},
2038 {"undead", vault_aux_undead, NULL, 75, 5},
2039 {NULL, NULL, NULL, 0, 0},
2044 static vault_aux_type pit_types[] =
2047 {"オーク", vault_aux_orc, NULL, 5, 6},
2048 {"トロル", vault_aux_troll, NULL, 20, 6},
2049 {"ジャイアント", vault_aux_giant, NULL, 50, 6},
2050 {"狂気", vault_aux_cthulhu, NULL, 80, 2},
2051 {"シンボル(善)", vault_aux_symbol_g, vault_prep_symbol, 70, 1},
2052 {"シンボル(悪)", vault_aux_symbol_e, vault_prep_symbol, 70, 1},
2053 {"教会", vault_aux_chapel_g, NULL, 65, 2},
2054 {"ドラゴン", vault_aux_dragon, vault_prep_dragon, 70, 6},
2055 {"デーモン", vault_aux_demon, NULL, 80, 6},
2056 {"ダークエルフ", vault_aux_dark_elf, NULL, 45, 4},
2057 {NULL, NULL, NULL, 0, 0},
2059 {"orc", vault_aux_orc, NULL, 5, 6},
2060 {"troll", vault_aux_troll, NULL, 20, 6},
2061 {"giant", vault_aux_giant, NULL, 50, 6},
2062 {"lovecraftian", vault_aux_cthulhu, NULL, 80, 2},
2063 {"symbol good", vault_aux_symbol_g, vault_prep_symbol, 70, 1},
2064 {"symbol evil", vault_aux_symbol_e, vault_prep_symbol, 70, 1},
2065 {"chapel", vault_aux_chapel_g, NULL, 65, 2},
2066 {"dragon", vault_aux_dragon, vault_prep_dragon, 70, 6},
2067 {"demon", vault_aux_demon, NULL, 80, 6},
2068 {"dark elf", vault_aux_dark_elf, NULL, 45, 4},
2069 {NULL, NULL, NULL, 0, 0},
2074 /*! nestのID定義 / Nest types code */
2075 #define NEST_TYPE_CLONE 0
2076 #define NEST_TYPE_JELLY 1
2077 #define NEST_TYPE_SYMBOL_GOOD 2
2078 #define NEST_TYPE_SYMBOL_EVIL 3
2079 #define NEST_TYPE_MIMIC 4
2080 #define NEST_TYPE_LOVECRAFTIAN 5
2081 #define NEST_TYPE_KENNEL 6
2082 #define NEST_TYPE_ANIMAL 7
2083 #define NEST_TYPE_CHAPEL 8
2084 #define NEST_TYPE_UNDEAD 9
2086 /*! pitのID定義 / Pit types code */
2087 #define PIT_TYPE_ORC 0
2088 #define PIT_TYPE_TROLL 1
2089 #define PIT_TYPE_GIANT 2
2090 #define PIT_TYPE_LOVECRAFTIAN 3
2091 #define PIT_TYPE_SYMBOL_GOOD 4
2092 #define PIT_TYPE_SYMBOL_EVIL 5
2093 #define PIT_TYPE_CHAPEL 6
2094 #define PIT_TYPE_DRAGON 7
2095 #define PIT_TYPE_DEMON 8
2096 #define PIT_TYPE_DARK_ELF 9
2100 * @brief デバッグ時に生成されたpit/nestの型を出力する処理
2101 * @param type pit/nestの型ID
2102 * @param nest TRUEならばnest、FALSEならばpit
2103 * @return デバッグ表示文字列の参照ポインタ
2105 * Hack -- Get the string describing subtype of pit/nest
2106 * Determined in prepare function (some pit/nest only)
2108 static cptr pit_subtype_string(int type, bool nest)
2110 static char inner_buf[256] = "";
2112 inner_buf[0] = '\0'; /* Init string */
2114 if (nest) /* Nests */
2118 case NEST_TYPE_CLONE:
2119 sprintf(inner_buf, "(%s)", r_name + r_info[vault_aux_race].name);
2121 case NEST_TYPE_SYMBOL_GOOD:
2122 case NEST_TYPE_SYMBOL_EVIL:
2123 sprintf(inner_buf, "(%c)", vault_aux_char);
2131 case PIT_TYPE_SYMBOL_GOOD:
2132 case PIT_TYPE_SYMBOL_EVIL:
2133 sprintf(inner_buf, "(%c)", vault_aux_char);
2135 case PIT_TYPE_DRAGON:
2136 switch (vault_aux_dragon_mask4)
2139 case RF4_BR_ACID: strcpy(inner_buf, "(酸)"); break;
2140 case RF4_BR_ELEC: strcpy(inner_buf, "(稲妻)"); break;
2141 case RF4_BR_FIRE: strcpy(inner_buf, "(火炎)"); break;
2142 case RF4_BR_COLD: strcpy(inner_buf, "(冷気)"); break;
2143 case RF4_BR_POIS: strcpy(inner_buf, "(毒)"); break;
2144 case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS):
2145 strcpy(inner_buf, "(万色)"); break;
2146 default: strcpy(inner_buf, "(未定義)"); break;
2148 case RF4_BR_ACID: strcpy(inner_buf, "(acid)"); break;
2149 case RF4_BR_ELEC: strcpy(inner_buf, "(lightning)"); break;
2150 case RF4_BR_FIRE: strcpy(inner_buf, "(fire)"); break;
2151 case RF4_BR_COLD: strcpy(inner_buf, "(frost)"); break;
2152 case RF4_BR_POIS: strcpy(inner_buf, "(poison)"); break;
2153 case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS):
2154 strcpy(inner_buf, "(multi-hued)"); break;
2155 default: strcpy(inner_buf, "(undefined)"); break;
2166 /*! デバッグ時にnestのモンスター情報を確認するための構造体 / A struct for nest monster information with cheat_hear */
2176 *! @brief nestのモンスターリストをソートするための関数 /
2177 * Comp function for sorting nest monster information
2178 * @param u ソート処理対象配列ポインタ
2180 * @param a 比較対象参照ID1
2181 * @param b 比較対象参照ID2
2183 static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
2185 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
2186 int w1 = nest_mon_info[a].r_idx;
2187 int w2 = nest_mon_info[b].r_idx;
2188 monster_race *r1_ptr = &r_info[w1];
2189 monster_race *r2_ptr = &r_info[w2];
2195 /* Extract used info */
2196 z1 = nest_mon_info[a].used;
2197 z2 = nest_mon_info[b].used;
2199 /* Compare used status */
2200 if (z1 < z2) return FALSE;
2201 if (z1 > z2) return TRUE;
2203 /* Compare levels */
2204 if (r1_ptr->level < r2_ptr->level) return TRUE;
2205 if (r1_ptr->level > r2_ptr->level) return FALSE;
2207 /* Compare experience */
2208 if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
2209 if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
2211 /* Compare indexes */
2216 * @brief nestのモンスターリストをスワップするための関数 /
2217 * Swap function for sorting nest monster information
2218 * @param u スワップ処理対象配列ポインタ
2220 * @param a スワップ対象参照ID1
2221 * @param b スワップ対象参照ID2
2223 static void ang_sort_swap_nest_mon_info(vptr u, vptr v, int a, int b)
2225 nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
2226 nest_mon_info_type holder;
2232 holder = nest_mon_info[a];
2233 nest_mon_info[a] = nest_mon_info[b];
2234 nest_mon_info[b] = holder;
2238 #define NUM_NEST_MON_TYPE 64 /*!<nestの種別数 */
2242 * @brief タイプ5の部屋…nestを生成する / Type 5 -- Monster nests
2245 * A monster nest is a "big" room, with an "inner" room, containing\n
2246 * a "collection" of monsters of a given type strewn about the room.\n
2248 * The monsters are chosen from a set of 64 randomly selected monster\n
2249 * races, to allow the nest creation to fail instead of having "holes".\n
2251 * Note the use of the "get_mon_num_prep()" function, and the special\n
2252 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
2253 * allocation table" in such a way as to optimize the selection of\n
2254 * "appropriate" non-unique monsters for the nest.\n
2256 * Note that the "get_mon_num()" function may (rarely) fail, in which\n
2257 * case the nest will be empty.\n
2259 * Note that "monster nests" will never contain "unique" monsters.\n
2261 static bool build_type5(void)
2263 POSITION y, x, y1, x1, y2, x2, xval, yval;
2265 nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
2271 int cur_nest_type = pick_vault_type(nest_types, d_info[dungeon_type].nest);
2272 vault_aux_type *n_ptr;
2274 /* No type available */
2275 if (cur_nest_type < 0) return FALSE;
2277 n_ptr = &nest_types[cur_nest_type];
2279 /* Process a preparation function if necessary */
2280 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
2282 /* Prepare allocation table */
2283 get_mon_num_prep(n_ptr->hook_func, NULL);
2285 align.sub_align = SUB_ALIGN_NEUTRAL;
2287 /* Pick some monster types */
2288 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
2290 MONRACE_IDX r_idx = 0;
2292 monster_race *r_ptr = NULL;
2296 /* Get a (hard) monster type */
2297 r_idx = get_mon_num(dun_level + 11);
2298 r_ptr = &r_info[r_idx];
2300 /* Decline incorrect alignment */
2301 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
2303 /* Accept this monster */
2307 /* Notice failure */
2308 if (!r_idx || !attempts) return FALSE;
2310 /* Note the alignment */
2311 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
2312 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
2314 nest_mon_info[i].r_idx = (s16b)r_idx;
2315 nest_mon_info[i].used = FALSE;
2318 /* Find and reserve some space in the dungeon. Get center of room. */
2319 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
2327 /* Place the floor area */
2328 for (y = y1 - 1; y <= y2 + 1; y++)
2330 for (x = x1 - 1; x <= x2 + 1; x++)
2332 c_ptr = &cave[y][x];
2333 place_floor_grid(c_ptr);
2334 c_ptr->info |= (CAVE_ROOM);
2338 /* Place the outer walls */
2339 for (y = y1 - 1; y <= y2 + 1; y++)
2341 c_ptr = &cave[y][x1 - 1];
2342 place_outer_grid(c_ptr);
2343 c_ptr = &cave[y][x2 + 1];
2344 place_outer_grid(c_ptr);
2346 for (x = x1 - 1; x <= x2 + 1; x++)
2348 c_ptr = &cave[y1 - 1][x];
2349 place_outer_grid(c_ptr);
2350 c_ptr = &cave[y2 + 1][x];
2351 place_outer_grid(c_ptr);
2355 /* Advance to the center room */
2361 /* The inner walls */
2362 for (y = y1 - 1; y <= y2 + 1; y++)
2364 c_ptr = &cave[y][x1 - 1];
2365 place_inner_grid(c_ptr);
2366 c_ptr = &cave[y][x2 + 1];
2367 place_inner_grid(c_ptr);
2370 for (x = x1 - 1; x <= x2 + 1; x++)
2372 c_ptr = &cave[y1 - 1][x];
2373 place_inner_grid(c_ptr);
2374 c_ptr = &cave[y2 + 1][x];
2375 place_inner_grid(c_ptr);
2377 for (y = y1; y <= y2; y++)
2379 for (x = x1; x <= x2; x++)
2381 add_cave_info(y, x, CAVE_ICKY);
2385 /* Place a secret door */
2386 switch (randint1(4))
2388 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
2389 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
2390 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
2391 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
2394 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(nest)(%s%s)を生成します。", "Monster nest (%s%s)"), n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
2396 /* Place some monsters */
2397 for (y = yval - 2; y <= yval + 2; y++)
2399 for (x = xval - 9; x <= xval + 9; x++)
2403 i = randint0(NUM_NEST_MON_TYPE);
2404 r_idx = nest_mon_info[i].r_idx;
2406 /* Place that "random" monster (no groups) */
2407 (void)place_monster_aux(0, y, x, r_idx, 0L);
2409 nest_mon_info[i].used = TRUE;
2415 ang_sort_comp = ang_sort_comp_nest_mon_info;
2416 ang_sort_swap = ang_sort_swap_nest_mon_info;
2417 ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE);
2419 /* Dump the entries (prevent multi-printing) */
2420 for (i = 0; i < NUM_NEST_MON_TYPE; i++)
2422 if (!nest_mon_info[i].used) break;
2423 for (; i < NUM_NEST_MON_TYPE - 1; i++)
2425 if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
2426 if (!nest_mon_info[i + 1].used) break;
2428 msg_format_wizard(CHEAT_DUNGEON, "Nest構成モンスターNo.%d:%s", i, r_name + r_info[nest_mon_info[i].r_idx].name);
2437 * @brief タイプ6の部屋…pitを生成する / Type 6 -- Monster pits
2440 * A monster pit is a "big" room, with an "inner" room, containing\n
2441 * a "collection" of monsters of a given type organized in the room.\n
2443 * The inside room in a monster pit appears as shown below, where the\n
2444 * actual monsters in each location depend on the type of the pit\n
2446 * XXXXXXXXXXXXXXXXXXXXX\n
2447 * X0000000000000000000X\n
2448 * X0112233455543322110X\n
2449 * X0112233467643322110X\n
2450 * X0112233455543322110X\n
2451 * X0000000000000000000X\n
2452 * XXXXXXXXXXXXXXXXXXXXX\n
2454 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
2455 * to request 16 "appropriate" monsters, sorting them by level, and using\n
2456 * the "even" entries in this sorted list for the contents of the pit.\n
2458 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
2459 * which is handled by requiring a specific "breath" attack for all of the\n
2460 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
2461 * be present in many of the dragon pits, if they have the proper breath.\n
2463 * Note the use of the "get_mon_num_prep()" function, and the special\n
2464 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
2465 * allocation table" in such a way as to optimize the selection of\n
2466 * "appropriate" non-unique monsters for the pit.\n
2468 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
2469 * the pit will be empty.\n
2471 * Note that "monster pits" will never contain "unique" monsters.\n
2473 static bool build_type6(void)
2475 int y, x, y1, x1, y2, x2, xval, yval;
2478 MONRACE_IDX what[16];
2484 int cur_pit_type = pick_vault_type(pit_types, d_info[dungeon_type].pit);
2485 vault_aux_type *n_ptr;
2487 /* No type available */
2488 if (cur_pit_type < 0) return FALSE;
2490 n_ptr = &pit_types[cur_pit_type];
2492 /* Process a preparation function if necessary */
2493 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
2495 /* Prepare allocation table */
2496 get_mon_num_prep(n_ptr->hook_func, NULL);
2498 align.sub_align = SUB_ALIGN_NEUTRAL;
2500 /* Pick some monster types */
2501 for (i = 0; i < 16; i++)
2503 MONRACE_IDX r_idx = 0;
2505 monster_race *r_ptr = NULL;
2509 /* Get a (hard) monster type */
2510 r_idx = get_mon_num(dun_level + 11);
2511 r_ptr = &r_info[r_idx];
2513 /* Decline incorrect alignment */
2514 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
2516 /* Accept this monster */
2520 /* Notice failure */
2521 if (!r_idx || !attempts) return FALSE;
2523 /* Note the alignment */
2524 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
2525 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
2530 /* Find and reserve some space in the dungeon. Get center of room. */
2531 if (!find_space(&yval, &xval, 11, 25)) return FALSE;
2539 /* Place the floor area */
2540 for (y = y1 - 1; y <= y2 + 1; y++)
2542 for (x = x1 - 1; x <= x2 + 1; x++)
2544 c_ptr = &cave[y][x];
2545 place_floor_grid(c_ptr);
2546 c_ptr->info |= (CAVE_ROOM);
2550 /* Place the outer walls */
2551 for (y = y1 - 1; y <= y2 + 1; y++)
2553 c_ptr = &cave[y][x1 - 1];
2554 place_outer_grid(c_ptr);
2555 c_ptr = &cave[y][x2 + 1];
2556 place_outer_grid(c_ptr);
2558 for (x = x1 - 1; x <= x2 + 1; x++)
2560 c_ptr = &cave[y1 - 1][x];
2561 place_outer_grid(c_ptr);
2562 c_ptr = &cave[y2 + 1][x];
2563 place_outer_grid(c_ptr);
2566 /* Advance to the center room */
2572 /* The inner walls */
2573 for (y = y1 - 1; y <= y2 + 1; y++)
2575 c_ptr = &cave[y][x1 - 1];
2576 place_inner_grid(c_ptr);
2577 c_ptr = &cave[y][x2 + 1];
2578 place_inner_grid(c_ptr);
2580 for (x = x1 - 1; x <= x2 + 1; x++)
2582 c_ptr = &cave[y1 - 1][x];
2583 place_inner_grid(c_ptr);
2584 c_ptr = &cave[y2 + 1][x];
2585 place_inner_grid(c_ptr);
2587 for (y = y1; y <= y2; y++)
2589 for (x = x1; x <= x2; x++)
2591 add_cave_info(y, x, CAVE_ICKY);
2595 /* Place a secret door */
2596 switch (randint1(4))
2598 case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
2599 case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
2600 case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
2601 case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
2604 /* Sort the entries */
2605 for (i = 0; i < 16 - 1; i++)
2607 /* Sort the entries */
2608 for (j = 0; j < 16 - 1; j++)
2613 int p1 = r_info[what[i1]].level;
2614 int p2 = r_info[what[i2]].level;
2619 MONRACE_IDX tmp = what[i1];
2620 what[i1] = what[i2];
2626 msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(pit)(%s%s)を生成します。", "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];
2633 msg_format_wizard(CHEAT_DUNGEON, _("Nest構成モンスター選択No.%d:%s", "Nest Monster Select No.%d:%s"), i, r_name + r_info[what[i]].name);
2636 /* Top and bottom rows */
2637 for (x = xval - 9; x <= xval + 9; x++)
2639 place_monster_aux(0, yval - 2, x, what[0], PM_NO_KAGE);
2640 place_monster_aux(0, yval + 2, x, what[0], PM_NO_KAGE);
2643 /* Middle columns */
2644 for (y = yval - 1; y <= yval + 1; y++)
2646 place_monster_aux(0, y, xval - 9, what[0], PM_NO_KAGE);
2647 place_monster_aux(0, y, xval + 9, what[0], PM_NO_KAGE);
2649 place_monster_aux(0, y, xval - 8, what[1], PM_NO_KAGE);
2650 place_monster_aux(0, y, xval + 8, what[1], PM_NO_KAGE);
2652 place_monster_aux(0, y, xval - 7, what[1], PM_NO_KAGE);
2653 place_monster_aux(0, y, xval + 7, what[1], PM_NO_KAGE);
2655 place_monster_aux(0, y, xval - 6, what[2], PM_NO_KAGE);
2656 place_monster_aux(0, y, xval + 6, what[2], PM_NO_KAGE);
2658 place_monster_aux(0, y, xval - 5, what[2], PM_NO_KAGE);
2659 place_monster_aux(0, y, xval + 5, what[2], PM_NO_KAGE);
2661 place_monster_aux(0, y, xval - 4, what[3], PM_NO_KAGE);
2662 place_monster_aux(0, y, xval + 4, what[3], PM_NO_KAGE);
2664 place_monster_aux(0, y, xval - 3, what[3], PM_NO_KAGE);
2665 place_monster_aux(0, y, xval + 3, what[3], PM_NO_KAGE);
2667 place_monster_aux(0, y, xval - 2, what[4], PM_NO_KAGE);
2668 place_monster_aux(0, y, xval + 2, what[4], PM_NO_KAGE);
2671 /* Above/Below the center monster */
2672 for (x = xval - 1; x <= xval + 1; x++)
2674 place_monster_aux(0, yval + 1, x, what[5], PM_NO_KAGE);
2675 place_monster_aux(0, yval - 1, x, what[5], PM_NO_KAGE);
2678 /* Next to the center monster */
2679 place_monster_aux(0, yval, xval + 1, what[6], PM_NO_KAGE);
2680 place_monster_aux(0, yval, xval - 1, what[6], PM_NO_KAGE);
2682 /* Center monster */
2683 place_monster_aux(0, yval, xval, what[7], PM_NO_KAGE);
2690 * @brief Vault地形を回転、上下左右反転するための座標変換を返す / coordinate translation code
2691 * @param x 変換したい点のX座標参照ポインタ
2692 * @param y 変換したい点のY座標参照ポインタ
2693 * @param xoffset Vault生成時の基準X座標
2694 * @param yoffset Vault生成時の基準Y座標
2695 * @param transno 処理ID
2698 static void coord_trans(int *x, int *y, int xoffset, int yoffset, int transno)
2704 * transno specifies what transformation is required. (0-7)
2705 * The lower two bits indicate by how much the vault is rotated,
2706 * and the upper bit indicates a reflection.
2707 * This is done by using rotation matrices... however since
2708 * these are mostly zeros for rotations by 90 degrees this can
2709 * be expressed simply in terms of swapping and inverting the
2710 * x and y coordinates.
2712 for (i = 0; i < transno % 4; i++)
2714 /* rotate by 90 degrees */
2722 /* Reflect depending on status of 3rd bit. */
2726 /* Add offsets so vault stays in the first quadrant */
2732 * @brief Vaultをフロアに配置する / Hack -- fill in "vault" rooms
2733 * @param yval 生成基準Y座標
2734 * @param xval 生成基準X座標
2735 * @param ymax VaultのYサイズ
2736 * @param xmax VaultのXサイズ
2737 * @param data Vaultのデータ文字列
2738 * @param xoffset 変換基準X座標
2739 * @param yoffset 変換基準Y座標
2740 * @param transno 変換ID
2743 static void build_vault(int yval, int xval, int ymax, int xmax, cptr data,
2744 int xoffset, int yoffset, int transno)
2746 int dx, dy, x, y, i, j;
2753 /* Place dungeon features and objects */
2754 for (t = data, dy = 0; dy < ymax; dy++)
2756 for (dx = 0; dx < xmax; dx++, t++)
2758 /* prevent loop counter from being overwritten */
2763 coord_trans(&i, &j, xoffset, yoffset, transno);
2765 /* Extract the location */
2766 if (transno % 2 == 0)
2768 /* no swap of x/y */
2769 x = xval - (xmax / 2) + i;
2770 y = yval - (ymax / 2) + j;
2775 x = xval - (ymax / 2) + i;
2776 y = yval - (xmax / 2) + j;
2779 /* Hack -- skip "non-grids" */
2780 if (*t == ' ') continue;
2782 /* Access the grid */
2783 c_ptr = &cave[y][x];
2785 /* Lay down a floor */
2786 place_floor_grid(c_ptr);
2788 /* Remove any mimic */
2791 /* Part of a vault */
2792 c_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
2794 /* Analyze the grid */
2797 /* Granite wall (outer) */
2799 place_outer_noperm_grid(c_ptr);
2802 /* Granite wall (inner) */
2804 place_inner_grid(c_ptr);
2807 /* Glass wall (inner) */
2809 place_inner_grid(c_ptr);
2810 c_ptr->feat = feat_glass_wall;
2813 /* Permanent wall (inner) */
2815 place_inner_perm_grid(c_ptr);
2818 /* Permanent glass wall (inner) */
2820 place_inner_perm_grid(c_ptr);
2821 c_ptr->feat = feat_permanent_glass_wall;
2826 if (randint0(100) < 75)
2828 place_object(y, x, 0L);
2838 place_secret_door(y, x, DOOR_DEFAULT);
2841 /* Secret glass doors */
2843 place_secret_door(y, x, DOOR_GLASS_DOOR);
2844 if (is_closed_door(c_ptr->feat)) c_ptr->mimic = feat_glass_wall;
2849 place_secret_door(y, x, DOOR_CURTAIN);
2857 /* Black market in a dungeon */
2859 set_cave_feat(y, x, feat_black_market);
2860 store_init(NO_TOWN, STORE_BLACK);
2865 set_cave_feat(y, x, feat_pattern_start);
2869 set_cave_feat(y, x, feat_pattern_1);
2873 set_cave_feat(y, x, feat_pattern_2);
2877 set_cave_feat(y, x, feat_pattern_3);
2881 set_cave_feat(y, x, feat_pattern_4);
2885 set_cave_feat(y, x, feat_pattern_end);
2889 set_cave_feat(y, x, feat_pattern_exit);
2893 /* Reward for Pattern walk */
2894 object_level = base_level + 12;
2895 place_object(y, x, AM_GOOD | AM_GREAT);
2896 object_level = base_level;
2903 /* Place dungeon monsters and objects */
2904 for (t = data, dy = 0; dy < ymax; dy++)
2906 for (dx = 0; dx < xmax; dx++, t++)
2908 /* prevent loop counter from being overwritten */
2913 coord_trans(&i, &j, xoffset, yoffset, transno);
2915 /* Extract the location */
2916 if (transno % 2 == 0)
2918 /* no swap of x/y */
2919 x = xval - (xmax / 2) + i;
2920 y = yval - (ymax / 2) + j;
2925 x = xval - (ymax / 2) + i;
2926 y = yval - (xmax / 2) + j;
2929 /* Hack -- skip "non-grids" */
2930 if (*t == ' ') continue;
2932 /* Analyze the symbol */
2938 monster_level = base_level + 5;
2939 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
2940 monster_level = base_level;
2944 /* Meaner monster */
2947 monster_level = base_level + 11;
2948 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
2949 monster_level = base_level;
2953 /* Meaner monster, plus treasure */
2956 monster_level = base_level + 9;
2957 place_monster(y, x, PM_ALLOW_SLEEP);
2958 monster_level = base_level;
2959 object_level = base_level + 7;
2960 place_object(y, x, AM_GOOD);
2961 object_level = base_level;
2965 /* Nasty monster and treasure */
2968 monster_level = base_level + 40;
2969 place_monster(y, x, PM_ALLOW_SLEEP);
2970 monster_level = base_level;
2971 object_level = base_level + 20;
2972 place_object(y, x, AM_GOOD | AM_GREAT);
2973 object_level = base_level;
2977 /* Monster and/or object */
2980 if (randint0(100) < 50)
2982 monster_level = base_level + 3;
2983 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
2984 monster_level = base_level;
2986 if (randint0(100) < 50)
2988 object_level = base_level + 7;
2989 place_object(y, x, 0L);
2990 object_level = base_level;
3002 * @brief タイプ7の部屋…v_info.txtより小型vaultを生成する / Type 7 -- simple vaults (see "v_info.txt")
3005 static bool build_type7(void)
3007 vault_type *v_ptr = NULL;
3010 POSITION xval, yval;
3011 POSITION xoffset, yoffset;
3014 /* Pick a lesser vault */
3015 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
3017 /* Access a random vault record */
3018 v_ptr = &v_info[randint0(max_v_idx)];
3020 /* Accept the first lesser vault */
3021 if (v_ptr->typ == 7) break;
3024 /* No lesser vault found */
3025 if (dummy >= SAFE_MAX_ATTEMPTS)
3027 msg_print_wizard(CHEAT_DUNGEON, _("小型固定Vaultを配置できませんでした。", "Could not place lesser vault."));
3031 /* pick type of transformation (0-7) */
3032 transno = randint0(8);
3034 /* calculate offsets */
3038 /* Some huge vault cannot be ratated to fit in the dungeon */
3039 if (x+2 > cur_hgt-2)
3041 /* Forbid 90 or 270 degree ratation */
3045 coord_trans(&x, &y, 0, 0, transno);
3065 /* Find and reserve some space in the dungeon. Get center of room. */
3066 if (!find_space(&yval, &xval, abs(y), abs(x))) return FALSE;
3073 msg_format_wizard(CHEAT_DUNGEON, _("小型Vault(%s)を生成しました。", "Lesser vault (%s)."), v_name + v_ptr->name);
3075 /* Hack -- Build the vault */
3076 build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
3077 v_text + v_ptr->text, xoffset, yoffset, transno);
3083 * @brief タイプ8の部屋…v_info.txtより大型vaultを生成する / Type 8 -- greater vaults (see "v_info.txt")
3086 static bool build_type8(void)
3093 int xoffset, yoffset;
3095 /* Pick a greater vault */
3096 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
3098 /* Access a random vault record */
3099 v_ptr = &v_info[randint0(max_v_idx)];
3101 /* Accept the first greater vault */
3102 if (v_ptr->typ == 8) break;
3105 /* No greater vault found */
3106 if (dummy >= SAFE_MAX_ATTEMPTS)
3108 msg_print_wizard(CHEAT_DUNGEON, _("大型固定Vaultを配置できませんでした。", "Could not place greater vault."));
3112 /* pick type of transformation (0-7) */
3113 transno = randint0(8);
3115 /* calculate offsets */
3119 /* Some huge vault cannot be ratated to fit in the dungeon */
3120 if (x+2 > cur_hgt-2)
3122 /* Forbid 90 or 270 degree ratation */
3126 coord_trans(&x, &y, 0, 0, transno);
3147 * Try to allocate space for room. If fails, exit
3149 * Hack -- Prepare a bit larger space (+2, +2) to
3150 * prevent generation of vaults with no-entrance.
3152 /* Find and reserve some space in the dungeon. Get center of room. */
3153 if (!find_space(&yval, &xval, abs(y) + 2, abs(x) + 2)) return FALSE;
3156 v_ptr = &v_info[76 + randint1(3)];
3159 msg_format_wizard(CHEAT_DUNGEON, _("大型固定Vault(%s)を生成しました。", "Greater vault (%s)."), v_name + v_ptr->name);
3161 /* Hack -- Build the vault */
3162 build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
3163 v_text + v_ptr->text, xoffset, yoffset, transno);
3169 * Structure to hold all "fill" data
3172 typedef struct fill_data_type fill_data_type;
3174 struct fill_data_type
3187 /* features to fill with */
3196 /* number of filled squares */
3200 static fill_data_type fill_data;
3203 /* Store routine for the fractal cave generator */
3204 /* this routine probably should be an inline function or a macro. */
3205 static void store_height(int x, int y, int val)
3207 /* if on boundary set val > cutoff so walls are not as square */
3208 if (((x == fill_data.xmin) || (y == fill_data.ymin) ||
3209 (x == fill_data.xmax) || (y == fill_data.ymax)) &&
3210 (val <= fill_data.c1)) val = fill_data.c1 + 1;
3212 /* store the value in height-map format */
3213 cave[y][x].feat = (s16b)val;
3220 * Explanation of the plasma fractal algorithm:
3222 * A grid of points is created with the properties of a 'height-map'
3223 * This is done by making the corners of the grid have a random value.
3224 * The grid is then subdivided into one with twice the resolution.
3225 * The new points midway between two 'known' points can be calculated
3226 * by taking the average value of the 'known' ones and randomly adding
3227 * or subtracting an amount proportional to the distance between those
3228 * points. The final 'middle' points of the grid are then calculated
3229 * by averaging all four of the originally 'known' corner points. An
3230 * random amount is added or subtracted from this to get a value of the
3231 * height at that point. The scaling factor here is adjusted to the
3232 * slightly larger distance diagonally as compared to orthogonally.
3234 * This is then repeated recursively to fill an entire 'height-map'
3235 * A rectangular map is done the same way, except there are different
3236 * scaling factors along the x and y directions.
3238 * A hack to change the amount of correlation between points is done using
3239 * the grd variable. If the current step size is greater than grd then
3240 * the point will be random, otherwise it will be calculated by the
3241 * above algorithm. This makes a maximum distance at which two points on
3242 * the height map can affect each other.
3244 * How fractal caves are made:
3246 * When the map is complete, a cut-off value is used to create a cave.
3247 * Heights below this value are "floor", and heights above are "wall".
3248 * This also can be used to create lakes, by adding more height levels
3249 * representing shallow and deep water/ lava etc.
3251 * The grd variable affects the width of passages.
3252 * The roug variable affects the roughness of those passages
3254 * The tricky part is making sure the created cave is connected. This
3255 * is done by 'filling' from the inside and only keeping the 'filled'
3256 * floor. Walls bounding the 'filled' floor are also kept. Everything
3257 * else is converted to the normal _extra_.
3262 * Note that this uses the cave.feat array in a very hackish way
3263 * the values are first set to zero, and then each array location
3264 * is used as a "heightmap"
3265 * The heightmap then needs to be converted back into the "feat" format.
3267 * grd=level at which fractal turns on. smaller gives more mazelike caves
3268 * roug=roughness level. 16=normal. higher values make things more convoluted
3269 * small values are good for smooth walls.
3270 * size=length of the side of the square cave system.
3272 static void generate_hmap(int y0, int x0, int xsiz, int ysiz, int grd, int roug, int cutoff)
3274 int xhsize, yhsize, xsize, ysize, maxsize;
3277 * fixed point variables- these are stored as 256 x normal value
3278 * this gives 8 binary places of fractional part + 8 places of normal part
3281 u16b xstep, xhstep, ystep, yhstep;
3282 u16b xstep2, xhstep2, ystep2, yhstep2;
3283 u16b i, j, ii, jj, diagsize, xxsize, yysize;
3285 /* Cache for speed */
3286 u16b xm, xp, ym, yp;
3288 /* redefine size so can change the value if out of range */
3292 /* Paranoia about size of the system of caves */
3293 if (xsize > 254) xsize = 254;
3294 if (xsize < 4) xsize = 4;
3295 if (ysize > 254) ysize = 254;
3296 if (ysize < 4) ysize = 4;
3298 /* get offsets to middle of array */
3302 /* fix rounding problem */
3306 /* get limits of region */
3307 fill_data.xmin = x0 - xhsize;
3308 fill_data.ymin = y0 - yhsize;
3309 fill_data.xmax = x0 + xhsize;
3310 fill_data.ymax = y0 + yhsize;
3312 /* Store cutoff in global for quick access */
3313 fill_data.c1 = cutoff;
3316 * Scale factor for middle points:
3317 * About sqrt(2) * 256 - correct for a square lattice
3318 * approximately correct for everything else.
3322 /* maximum of xsize and ysize */
3323 maxsize = (xsize > ysize) ? xsize : ysize;
3325 /* Clear the section */
3326 for (i = 0; i <= xsize; i++)
3328 for (j = 0; j <= ysize; j++)
3330 /* -1 is a flag for "not done yet" */
3331 cave[(int)(fill_data.ymin + j)][(int)(fill_data.xmin + i)].feat = -1;
3332 /* Clear icky flag because may be redoing the cave */
3333 cave[(int)(fill_data.ymin + j)][(int)(fill_data.xmin + i)].info &= ~(CAVE_ICKY);
3337 /* Boundaries are walls */
3338 cave[fill_data.ymin][fill_data.xmin].feat = (s16b)maxsize;
3339 cave[fill_data.ymax][fill_data.xmin].feat = (s16b)maxsize;
3340 cave[fill_data.ymin][fill_data.xmax].feat = (s16b)maxsize;
3341 cave[fill_data.ymax][fill_data.xmax].feat = (s16b)maxsize;
3343 /* Set the middle square to be an open area. */
3344 cave[y0][x0].feat = 0;
3346 /* Initialize the step sizes */
3347 xstep = xhstep = xsize * 256;
3348 ystep = yhstep = ysize * 256;
3349 xxsize = xsize * 256;
3350 yysize = ysize * 256;
3353 * Fill in the rectangle with fractal height data -
3354 * like the 'plasma fractal' in fractint.
3356 while ((xhstep > 256) || (yhstep > 256))
3358 /* Halve the step sizes */
3364 /* cache well used values */
3365 xstep2 = xstep / 256;
3366 ystep2 = ystep / 256;
3368 xhstep2 = xhstep / 256;
3369 yhstep2 = yhstep / 256;
3371 /* middle top to bottom. */
3372 for (i = xhstep; i <= xxsize - xhstep; i += xstep)
3374 for (j = 0; j <= yysize; j += ystep)
3376 /* cache often used values */
3377 ii = i / 256 + fill_data.xmin;
3378 jj = j / 256 + fill_data.ymin;
3381 if (cave[jj][ii].feat == -1)
3385 /* If greater than 'grid' level then is random */
3386 store_height(ii, jj, randint1(maxsize));
3390 /* Average of left and right points +random bit */
3391 store_height(ii, jj,
3392 (cave[jj][fill_data.xmin + (i - xhstep) / 256].feat
3393 + cave[jj][fill_data.xmin + (i + xhstep) / 256].feat) / 2
3394 + (randint1(xstep2) - xhstep2) * roug / 16);
3401 /* middle left to right. */
3402 for (j = yhstep; j <= yysize - yhstep; j += ystep)
3404 for (i = 0; i <= xxsize; i += xstep)
3406 /* cache often used values */
3407 ii = i / 256 + fill_data.xmin;
3408 jj = j / 256 + fill_data.ymin;
3411 if (cave[jj][ii].feat == -1)
3415 /* If greater than 'grid' level then is random */
3416 store_height(ii, jj, randint1(maxsize));
3420 /* Average of up and down points +random bit */
3421 store_height(ii, jj,
3422 (cave[fill_data.ymin + (j - yhstep) / 256][ii].feat
3423 + cave[fill_data.ymin + (j + yhstep) / 256][ii].feat) / 2
3424 + (randint1(ystep2) - yhstep2) * roug / 16);
3431 for (i = xhstep; i <= xxsize - xhstep; i += xstep)
3433 for (j = yhstep; j <= yysize - yhstep; j += ystep)
3435 /* cache often used values */
3436 ii = i / 256 + fill_data.xmin;
3437 jj = j / 256 + fill_data.ymin;
3440 if (cave[jj][ii].feat == -1)
3444 /* If greater than 'grid' level then is random */
3445 store_height(ii, jj, randint1(maxsize));
3449 /* Cache reused values. */
3450 xm = fill_data.xmin + (i - xhstep) / 256;
3451 xp = fill_data.xmin + (i + xhstep) / 256;
3452 ym = fill_data.ymin + (j - yhstep) / 256;
3453 yp = fill_data.ymin + (j + yhstep) / 256;
3456 * Average over all four corners + scale by diagsize to
3457 * reduce the effect of the square grid on the shape of the fractal
3459 store_height(ii, jj,
3460 (cave[ym][xm].feat + cave[yp][xm].feat
3461 + cave[ym][xp].feat + cave[yp][xp].feat) / 4
3462 + (randint1(xstep2) - xhstep2) * (diagsize / 16) / 256 * roug);
3471 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)
3474 * function used to convert from height-map back to the
3475 * normal angband cave format
3477 if (cave[y][x].info & CAVE_ICKY)
3484 /* Show that have looked at this square */
3485 cave[y][x].info|= (CAVE_ICKY);
3487 /* Use cutoffs c1-c3 to allocate regions of floor /water/ lava etc. */
3488 if (cave[y][x].feat <= c1)
3490 /* 25% of the time use the other tile : it looks better this way */
3491 if (randint1(100) < 75)
3493 cave[y][x].feat = (s16b)feat1;
3494 cave[y][x].info &= ~(CAVE_MASK);
3495 cave[y][x].info |= info1;
3500 cave[y][x].feat = (s16b)feat2;
3501 cave[y][x].info &= ~(CAVE_MASK);
3502 cave[y][x].info |= info2;
3506 else if (cave[y][x].feat <= c2)
3508 /* 25% of the time use the other tile : it looks better this way */
3509 if (randint1(100) < 75)
3511 cave[y][x].feat = (s16b)feat2;
3512 cave[y][x].info &= ~(CAVE_MASK);
3513 cave[y][x].info |= info2;
3518 cave[y][x].feat = (s16b)feat1;
3519 cave[y][x].info &= ~(CAVE_MASK);
3520 cave[y][x].info |= info1;
3524 else if (cave[y][x].feat <= c3)
3526 cave[y][x].feat = (s16b)feat3;
3527 cave[y][x].info &= ~(CAVE_MASK);
3528 cave[y][x].info |= info3;
3531 /* if greater than cutoff then is a wall */
3534 place_outer_bold(y, x);
3544 * Quick and nasty fill routine used to find the connected region
3545 * of floor in the middle of the cave
3547 static void cave_fill(POSITION y, POSITION x)
3556 /*** Start Grid ***/
3558 /* Enqueue that entry */
3563 /* Now process the queue */
3564 while (flow_head != flow_tail)
3566 /* Extract the next entry */
3567 ty = temp_y[flow_head];
3568 tx = temp_x[flow_head];
3570 /* Forget that entry */
3571 if (++flow_head == TEMP_MAX) flow_head = 0;
3573 /* Add the "children" */
3574 for (d = 0; d < 8; d++)
3576 int old_head = flow_tail;
3578 /* Child location */
3579 j = ty + ddy_ddd[d];
3580 i = tx + ddx_ddd[d];
3582 /* Paranoia Don't leave the cave */
3583 if (!in_bounds(j, i))
3585 /* affect boundary */
3586 cave[j][i].info |= CAVE_ICKY;
3590 /* If within bounds */
3591 else if ((i > fill_data.xmin) && (i < fill_data.xmax)
3592 && (j > fill_data.ymin) && (j < fill_data.ymax))
3594 /* If not a wall or floor done before */
3595 if (hack_isnt_wall(j, i,
3596 fill_data.c1, fill_data.c2, fill_data.c3,
3597 fill_data.feat1, fill_data.feat2, fill_data.feat3,
3598 fill_data.info1, fill_data.info2, fill_data.info3))
3600 /* Enqueue that entry */
3601 temp_y[flow_tail] = (byte_hack)j;
3602 temp_x[flow_tail] = (byte_hack)i;
3604 /* Advance the queue */
3605 if (++flow_tail == TEMP_MAX) flow_tail = 0;
3607 /* Hack -- Overflow by forgetting new entry */
3608 if (flow_tail == flow_head)
3610 flow_tail = old_head;
3614 /* keep tally of size of cave system */
3615 (fill_data.amount)++;
3621 /* affect boundary */
3622 cave[j][i].info |= CAVE_ICKY;
3629 static bool generate_fracave(int y0, int x0, int xsize, int ysize, int cutoff, bool light, bool room)
3631 int x, y, i, xhsize, yhsize;
3633 /* offsets to middle from corner */
3639 * select region connected to center of cave system
3640 * this gets rid of alot of isolated one-sqaures that
3641 * can make teleport traps instadeaths...
3645 fill_data.c1 = cutoff;
3649 /* features to fill with */
3650 fill_data.feat1 = floor_type[randint0(100)];
3651 fill_data.feat2 = floor_type[randint0(100)];
3652 fill_data.feat3 = floor_type[randint0(100)];
3654 fill_data.info1 = CAVE_FLOOR;
3655 fill_data.info2 = CAVE_FLOOR;
3656 fill_data.info3 = CAVE_FLOOR;
3658 /* number of filled squares */
3659 fill_data.amount = 0;
3661 cave_fill((byte)y0, (byte)x0);
3663 /* if tally too small, try again */
3664 if (fill_data.amount < 10)
3666 /* too small - clear area and try again later */
3667 for (x = 0; x <= xsize; ++x)
3669 for (y = 0; y <= ysize; ++y)
3671 place_extra_bold(y0 + y - yhsize, x0 + x - xhsize);
3672 cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY | CAVE_ROOM);
3679 * Do boundarys-check to see if they are next to a filled region
3680 * If not then they are set to normal granite
3681 * If so then they are marked as room walls.
3683 for (i = 0; i <= xsize; ++i)
3686 if ((cave[0 + y0 - yhsize][i + x0 - xhsize].info & CAVE_ICKY) && (room))
3688 /* Next to a 'filled' region? - set to be room walls */
3689 place_outer_bold(y0 + 0 - yhsize, x0 + i - xhsize);
3690 if (light) cave[y0 + 0 - yhsize][x0 + i - xhsize].info |= (CAVE_GLOW);
3691 cave[y0 + 0 - yhsize][x0 + i - xhsize].info |= (CAVE_ROOM);
3692 place_outer_bold(y0 + 0 - yhsize, x0 + i - xhsize);
3696 /* set to be normal granite */
3697 place_extra_bold(y0 + 0 - yhsize, x0 + i - xhsize);
3700 /* bottom boundary */
3701 if ((cave[ysize + y0 - yhsize][i + x0 - xhsize].info & CAVE_ICKY) && (room))
3703 /* Next to a 'filled' region? - set to be room walls */
3704 place_outer_bold(y0 + ysize - yhsize, x0 + i - xhsize);
3705 if (light) cave[y0 + ysize - yhsize][x0 + i - xhsize].info|=(CAVE_GLOW);
3706 cave[y0 + ysize - yhsize][x0 + i - xhsize].info|=(CAVE_ROOM);
3707 place_outer_bold(y0 + ysize - yhsize, x0 + i - xhsize);
3711 /* set to be normal granite */
3712 place_extra_bold(y0 + ysize - yhsize, x0 + i - xhsize);
3715 /* clear the icky flag-don't need it any more */
3716 cave[y0 + 0 - yhsize][x0 + i - xhsize].info &= ~(CAVE_ICKY);
3717 cave[y0 + ysize - yhsize][x0 + i - xhsize].info &= ~(CAVE_ICKY);
3720 /* Do the left and right boundaries minus the corners (done above) */
3721 for (i = 1; i < ysize; ++i)
3724 if ((cave[i + y0 - yhsize][0 + x0 - xhsize].info & CAVE_ICKY) && room)
3727 place_outer_bold(y0 + i - yhsize, x0 + 0 - xhsize);
3728 if (light) cave[y0 + i - yhsize][x0 + 0 - xhsize].info |= (CAVE_GLOW);
3729 cave[y0 + i - yhsize][x0 + 0 - xhsize].info |= (CAVE_ROOM);
3730 place_outer_bold(y0 + i - yhsize, x0 + 0 - xhsize);
3735 place_extra_bold(y0 + i - yhsize, x0 + 0 - xhsize);
3737 /* right boundary */
3738 if ((cave[i + y0 - yhsize][xsize + x0 - xhsize].info & CAVE_ICKY) && room)
3741 place_outer_bold(y0 + i - yhsize, x0 + xsize - xhsize);
3742 if (light) cave[y0 + i - yhsize][x0 + xsize - xhsize].info |= (CAVE_GLOW);
3743 cave[y0 + i - yhsize][x0 + xsize - xhsize].info |= (CAVE_ROOM);
3744 place_outer_bold(y0 + i - yhsize, x0 + xsize - xhsize);
3749 place_extra_bold(y0 + i - yhsize, x0 + xsize - xhsize);
3752 /* clear icky flag -done with it */
3753 cave[y0 + i - yhsize][x0 + 0 - xhsize].info &= ~(CAVE_ICKY);
3754 cave[y0 + i - yhsize][x0 + xsize - xhsize].info &= ~(CAVE_ICKY);
3758 /* Do the rest: convert back to the normal format */
3759 for (x = 1; x < xsize; ++x)
3761 for (y = 1; y < ysize; ++y)
3763 if (is_floor_bold(y0 + y - yhsize, x0 + x - xhsize) &&
3764 (cave[y0 + y - yhsize][x0 + x - xhsize].info & CAVE_ICKY))
3766 /* Clear the icky flag in the filled region */
3767 cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~CAVE_ICKY;
3769 /* Set appropriate flags */
3770 if (light) cave[y0 + y - yhsize][x0 + x - xhsize].info |= (CAVE_GLOW);
3771 if (room) cave[y0 + y - yhsize][x0 + x - xhsize].info |= (CAVE_ROOM);
3773 else if (is_outer_bold(y0 + y - yhsize, x0 + x - xhsize) &&
3774 (cave[y0 + y - yhsize][x0 + x - xhsize].info & CAVE_ICKY))
3777 cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY);
3778 if (light) cave[y0 + y - yhsize][x0 + x - xhsize].info |= (CAVE_GLOW);
3781 cave[y0 + y - yhsize][x0 + x - xhsize].info |= (CAVE_ROOM);
3786 place_extra_bold(y0 + y - yhsize, x0 + x - xhsize);
3787 cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ROOM);
3792 /* Clear the unconnected regions */
3793 place_extra_bold(y0 + y - yhsize, x0 + x - xhsize);
3794 cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY | CAVE_ROOM);
3800 * XXX XXX XXX There is a slight problem when tunnels pierce the caves:
3801 * Extra doors appear inside the system. (Its not very noticeable though.)
3802 * This can be removed by "filling" from the outside in. This allows a separation
3803 * from _outer_ with _inner_. (Internal walls are _outer_ instead.)
3804 * The extra effort for what seems to be only a minor thing (even non-existant if you
3805 * think of the caves not as normal rooms, but as holes in the dungeon), doesn't seem
3814 * @brief タイプ9の部屋…フラクタルカーブによる洞窟生成 / Type 9 -- Driver routine to create fractal cave system
3817 static bool build_type9(void)
3819 int grd, roug, cutoff;
3820 POSITION xsize, ysize, y0, x0;
3822 bool done, light, room;
3824 /* get size: note 'Evenness'*/
3825 xsize = randint1(22) * 2 + 6;
3826 ysize = randint1(15) * 2 + 6;
3828 /* Find and reserve some space in the dungeon. Get center of room. */
3829 if (!find_space(&y0, &x0, ysize + 1, xsize + 1))
3831 /* Limit to the minimum room size, and retry */
3835 /* Find and reserve some space in the dungeon. Get center of room. */
3836 if (!find_space(&y0, &x0, ysize + 1, xsize + 1))
3842 return build_type1();
3846 light = done = FALSE;
3849 if ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS)) light = TRUE;
3853 /* Note: size must be even or there are rounding problems
3854 * This causes the tunnels not to connect properly to the room */
3856 /* testing values for these parameters feel free to adjust */
3857 grd = 1 << (randint0(4));
3859 /* want average of about 16 */
3860 roug = randint1(8) * randint1(4);
3863 cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
3864 randint1(xsize / 4) + randint1(ysize / 4);
3867 generate_hmap(y0, x0, xsize, ysize, grd, roug, cutoff);
3869 /* Convert to normal format + clean up */
3870 done = generate_fracave(y0, x0, xsize, ysize, cutoff, light, room);
3876 #ifdef ALLOW_CAVERNS_AND_LAKES
3878 * Builds a cave system in the center of the dungeon.
3880 void build_cavern(void)
3882 int grd, roug, cutoff, xsize, ysize, x0, y0;
3885 light = done = FALSE;
3886 if ((dun_level <= randint1(50)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS)) light = TRUE;
3888 /* Make a cave the size of the dungeon */
3889 xsize = cur_wid - 1;
3890 ysize = cur_hgt - 1;
3894 /* Paranoia: make size even */
3900 /* testing values for these parameters: feel free to adjust */
3901 grd = randint1(4) + 4;
3903 /* want average of about 16 */
3904 roug = randint1(8) * randint1(4);
3910 generate_hmap(y0 + 1, x0 + 1, xsize, ysize, grd, roug, cutoff);
3912 /* Convert to normal format+ clean up */
3913 done = generate_fracave(y0 + 1, x0 + 1, xsize, ysize, cutoff, light, FALSE);
3917 static bool generate_lake(int y0, int x0, int xsize, int ysize, int c1, int c2, int c3, int type)
3919 int x, y, i, xhsize, yhsize;
3920 int feat1, feat2, feat3;
3922 /* offsets to middle from corner */
3926 /* Get features based on type */
3929 case LAKE_T_LAVA: /* Lava */
3930 feat1 = feat_deep_lava;
3931 feat2 = feat_shallow_lava;
3932 feat3 = floor_type[randint0(100)];
3934 case LAKE_T_WATER: /* Water */
3935 feat1 = feat_deep_water;
3936 feat2 = feat_shallow_water;
3937 feat3 = floor_type[randint0(100)];
3939 case LAKE_T_CAVE: /* Collapsed cave */
3940 feat1 = floor_type[randint0(100)];
3941 feat2 = floor_type[randint0(100)];
3942 feat3 = feat_rubble;
3944 case LAKE_T_EARTH_VAULT: /* Earth vault */
3945 feat1 = feat_rubble;
3946 feat2 = floor_type[randint0(100)];
3947 feat3 = feat_rubble;
3949 case LAKE_T_AIR_VAULT: /* Air vault */
3954 case LAKE_T_WATER_VAULT: /* Water vault */
3955 feat1 = feat_shallow_water;
3956 feat2 = feat_deep_water;
3957 feat3 = feat_shallow_water;
3959 case LAKE_T_FIRE_VAULT: /* Fire Vault */
3960 feat1 = feat_shallow_lava;
3961 feat2 = feat_deep_lava;
3962 feat3 = feat_shallow_lava;
3966 default: return FALSE;
3970 * select region connected to center of cave system
3971 * this gets rid of alot of isolated one-sqaures that
3972 * can make teleport traps instadeaths...
3980 /* features to fill with */
3981 fill_data.feat1 = feat1;
3982 fill_data.feat2 = feat2;
3983 fill_data.feat3 = feat3;
3985 fill_data.info1 = 0;
3986 fill_data.info2 = 0;
3987 fill_data.info3 = 0;
3989 /* number of filled squares */
3990 fill_data.amount = 0;
3992 /* select region connected to center of cave system
3993 * this gets rid of alot of isolated one-sqaures that
3994 * can make teleport traps instadeaths... */
3995 cave_fill((byte)y0, (byte)x0);
3997 /* if tally too small, try again */
3998 if (fill_data.amount < 10)
4000 /* too small -clear area and try again later */
4001 for (x = 0; x <= xsize; ++x)
4003 for (y = 0; y <= ysize; ++y)
4005 place_floor_bold(y0 + y - yhsize, x0 + x - xhsize);
4006 cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY);
4012 /* Do boundarys- set to normal granite */
4013 for (i = 0; i <= xsize; ++i)
4015 place_extra_bold(y0 + 0 - yhsize, x0 + i - xhsize);
4016 place_extra_bold(y0 + ysize - yhsize, x0 + i - xhsize);
4018 /* clear the icky flag-don't need it any more */
4019 cave[y0 + 0 - yhsize][x0 + i - xhsize].info &= ~(CAVE_ICKY);
4020 cave[y0 + ysize - yhsize][x0 + i - xhsize].info &= ~(CAVE_ICKY);
4023 /* Do the left and right boundaries minus the corners (done above) */
4025 for (i = 1; i < ysize; ++i)
4027 place_extra_bold(y0 + i - yhsize, x0 + 0 - xhsize);
4028 place_extra_bold(y0 + i - yhsize, x0 + xsize - xhsize);
4030 /* clear icky flag -done with it */
4031 cave[y0 + i - yhsize][x0 + 0 - xhsize].info &= ~(CAVE_ICKY);
4032 cave[y0 + i - yhsize][x0 + xsize - xhsize].info &= ~(CAVE_ICKY);
4036 /* Do the rest: convert back to the normal format */
4037 for (x = 1; x < xsize; ++x)
4039 for (y = 1; y < ysize; ++y)
4041 /* Fill unconnected regions with granite */
4042 if ((!(cave[y0 + y - yhsize][x0 + x - xhsize].info & CAVE_ICKY)) ||
4043 is_outer_bold(y0 + y - yhsize, x0 + x - xhsize))
4044 place_extra_bold(y0 + y - yhsize, x0 + x - xhsize);
4046 /* turn off icky flag (no longer needed.) */
4047 cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY | CAVE_ROOM);
4050 if (cave_have_flag_bold(y0 + y - yhsize, x0 + x - xhsize, FF_LAVA))
4052 if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS)) cave[y0 + y - yhsize][x0 + x - xhsize].info |= CAVE_GLOW;
4062 * makes a lake/collapsed cave system in the center of the dungeon
4064 void build_lake(int type)
4066 int grd, roug, xsize, ysize, x0, y0;
4070 /* paranoia - exit if lake type out of range. */
4071 if ((type < LAKE_T_LAVA) || (type > LAKE_T_FIRE_VAULT))
4073 msg_format("Invalid lake type (%d)", type);
4077 /* Make the size of the dungeon */
4078 xsize = cur_wid - 1;
4079 ysize = cur_hgt - 1;
4083 /* Paranoia: make size even */
4089 /* testing values for these parameters: feel free to adjust */
4090 grd = randint1(3) + 4;
4092 /* want average of about 16 */
4093 roug = randint1(8) * randint1(4);
4095 /* Make up size of various componants */
4099 /* Deep water/lava */
4100 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
4102 /* Shallow boundary */
4106 generate_hmap(y0 + 1, x0 + 1, xsize, ysize, grd, roug, c3);
4108 /* Convert to normal format+ clean up */
4109 done = generate_lake(y0 + 1, x0 + 1, xsize, ysize, c1, c2, c3, type);
4112 #endif /* ALLOW_CAVERNS_AND_LAKES */
4116 * Routine used by the random vault creators to add a door to a location
4117 * Note that range checking has to be done in the calling routine.
4119 * The doors must be INSIDE the allocated region.
4121 static void add_door(int x, int y)
4123 /* Need to have a wall in the center square */
4124 if (!is_outer_bold(y, x)) return;
4131 * where x=don't care
4135 if (is_floor_bold(y-1,x) && is_floor_bold(y+1,x) &&
4136 (is_outer_bold(y, x - 1) && is_outer_bold(y, x + 1)))
4139 place_secret_door(y, x, DOOR_DEFAULT);
4141 /* set boundarys so don't get wide doors */
4142 place_solid_bold(y, x - 1);
4143 place_solid_bold(y, x + 1);
4152 * where x = don't care
4155 if (is_outer_bold(y - 1, x) && is_outer_bold(y + 1, x) &&
4156 is_floor_bold(y,x-1) && is_floor_bold(y,x+1))
4159 place_secret_door(y, x, DOOR_DEFAULT);
4161 /* set boundarys so don't get wide doors */
4162 place_solid_bold(y - 1, x);
4163 place_solid_bold(y + 1, x);
4169 * Routine that fills the empty areas of a room with treasure and monsters.
4171 static void fill_treasure(int x1, int x2, int y1, int y2, int difficulty)
4173 int x, y, cx, cy, size;
4176 /* center of room:*/
4180 /* Rough measure of size of vault= sum of lengths of sides */
4181 size = abs(x2 - x1) + abs(y2 - y1);
4183 for (x = x1; x <= x2; x++)
4185 for (y = y1; y <= y2; y++)
4187 /* Thing added based on distance to center of vault
4188 * Difficulty is 1-easy to 10-hard */
4189 value = ((((s32b)(distance(cx, cy, x, y))) * 100) / size) + randint1(10) - difficulty;
4191 /* hack- empty square part of the time */
4192 if ((randint1(100) - difficulty * 3) > 50) value = 20;
4194 /* if floor, shallow water and lava */
4195 if (is_floor_bold(y, x) ||
4196 (cave_have_flag_bold(y, x, FF_PLACE) && cave_have_flag_bold(y, x, FF_DROP)))
4198 /* The smaller 'value' is, the better the stuff */
4201 /* Meanest monster + treasure */
4202 monster_level = base_level + 40;
4203 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4204 monster_level = base_level;
4205 object_level = base_level + 20;
4206 place_object(y, x, AM_GOOD);
4207 object_level = base_level;
4211 /* Mean monster +treasure */
4212 monster_level = base_level + 20;
4213 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4214 monster_level = base_level;
4215 object_level = base_level + 10;
4216 place_object(y, x, AM_GOOD);
4217 object_level = base_level;
4219 else if (value < 10)
4222 monster_level = base_level + 9;
4223 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4224 monster_level = base_level;
4226 else if (value < 17)
4228 /* Intentional Blank space */
4231 * (Want some of the vault to be empty
4232 * so have room for group monsters.
4233 * This is used in the hack above to lower
4234 * the density of stuff in the vault.)
4237 else if (value < 23)
4239 /* Object or trap */
4240 if (randint0(100) < 25)
4242 place_object(y, x, 0L);
4249 else if (value < 30)
4251 /* Monster and trap */
4252 monster_level = base_level + 5;
4253 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4254 monster_level = base_level;
4257 else if (value < 40)
4259 /* Monster or object */
4260 if (randint0(100) < 50)
4262 monster_level = base_level + 3;
4263 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4264 monster_level = base_level;
4266 if (randint0(100) < 50)
4268 object_level = base_level + 7;
4269 place_object(y, x, 0L);
4270 object_level = base_level;
4273 else if (value < 50)
4282 /* 20% monster, 40% trap, 20% object, 20% blank space */
4283 if (randint0(100) < 20)
4285 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
4287 else if (randint0(100) < 50)
4291 else if (randint0(100) < 50)
4293 place_object(y, x, 0L);
4304 * This function creates a random vault that looks like a collection of bubbles.
4305 * It works by getting a set of coordinates that represent the center of each
4306 * bubble. The entire room is made by seeing which bubble center is closest. If
4307 * two centers are equidistant then the square is a wall, otherwise it is a floor.
4308 * The only exception is for squares really near a center, these are always floor.
4309 * (It looks better than without this check.)
4311 * Note: If two centers are on the same point then this algorithm will create a
4312 * blank bubble filled with walls. - This is prevented from happening.
4314 static void build_bubble_vault(int x0, int y0, int xsize, int ysize)
4316 #define BUBBLENUM 10 /* number of bubbles */
4318 /* array of center points of bubbles */
4319 coord center[BUBBLENUM];
4322 u16b min1, min2, temp;
4325 /* Offset from center to top left hand corner */
4326 int xhsize = xsize / 2;
4327 int yhsize = ysize / 2;
4329 msg_print_wizard(CHEAT_DUNGEON, _("泡型ランダムVaultを生成しました。", "Room Vault."));
4331 /* Allocate center of bubbles */
4332 center[0].x = (byte)randint1(xsize - 3) + 1;
4333 center[0].y = (byte)randint1(ysize - 3) + 1;
4335 for (i = 1; i < BUBBLENUM; i++)
4339 /* get center and check to see if it is unique */
4344 x = randint1(xsize - 3) + 1;
4345 y = randint1(ysize - 3) + 1;
4347 for (j = 0; j < i; j++)
4349 /* rough test to see if there is an overlap */
4350 if ((x == center[j].x) && (y == center[j].y)) done = FALSE;
4354 center[i].x = (byte_hack)x;
4355 center[i].y = (byte_hack)y;
4359 /* Top and bottom boundaries */
4360 for (i = 0; i < xsize; i++)
4362 int side_x = x0 - xhsize + i;
4364 place_outer_noperm_bold(y0 - yhsize + 0, side_x);
4365 cave[y0 - yhsize + 0][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
4366 place_outer_noperm_bold(y0 - yhsize + ysize - 1, side_x);
4367 cave[y0 - yhsize + ysize - 1][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
4370 /* Left and right boundaries */
4371 for (i = 1; i < ysize - 1; i++)
4373 int side_y = y0 - yhsize + i;
4375 place_outer_noperm_bold(side_y, x0 - xhsize + 0);
4376 cave[side_y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
4377 place_outer_noperm_bold(side_y, x0 - xhsize + xsize - 1);
4378 cave[side_y][x0 - xhsize + xsize - 1].info |= (CAVE_ROOM | CAVE_ICKY);
4381 /* Fill in middle with bubbles */
4382 for (x = 1; x < xsize - 1; x++)
4384 for (y = 1; y < ysize - 1; y++)
4386 /* Get distances to two closest centers */
4389 min1 = (u16b)distance(x, y, center[0].x, center[0].y);
4390 min2 = (u16b)distance(x, y, center[1].x, center[1].y);
4394 /* swap if in wrong order */
4401 for (i = 2; i < BUBBLENUM; i++)
4403 temp = (u16b)distance(x, y, center[i].x, center[i].y);
4411 else if (temp < min2)
4413 /* second smallest */
4417 if (((min2 - min1) <= 2) && (!(min1 < 3)))
4419 /* Boundary at midpoint+ not at inner region of bubble */
4420 place_outer_noperm_bold(y0 - yhsize + y, x0 - xhsize + x);
4424 /* middle of a bubble */
4425 place_floor_bold(y0 - yhsize + y, x0 - xhsize + x);
4428 /* clean up rest of flags */
4429 cave[y0 - yhsize + y][x0 - xhsize + x].info |= (CAVE_ROOM | CAVE_ICKY);
4433 /* Try to add some random doors */
4434 for (i = 0; i < 500; i++)
4436 x = randint1(xsize - 3) - xhsize + x0 + 1;
4437 y = randint1(ysize - 3) - yhsize + y0 + 1;
4441 /* Fill with monsters and treasure, low difficulty */
4442 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5));
4447 * Overlay a rectangular room given its bounds
4448 * This routine is used by build_room_vault
4449 * The area inside the walls is not touched:
4450 * only granite is removed- normal walls stay
4452 static void build_room(int x1, int x2, int y1, int y2)
4454 int x, y, i, xsize, ysize, temp;
4456 /* Check if rectangle has no width */
4457 if ((x1 == x2) || (y1 == y2)) return;
4462 /* Swap boundaries if in wrong order */
4470 /* Swap boundaries if in wrong order */
4476 /* get total widths */
4481 /* Top and bottom boundaries */
4482 for (i = 0; i <= xsize; i++)
4484 place_outer_noperm_bold(y1, x1 + i);
4485 cave[y1][x1 + i].info |= (CAVE_ROOM | CAVE_ICKY);
4486 place_outer_noperm_bold(y2, x1 + i);
4487 cave[y2][x1 + i].info |= (CAVE_ROOM | CAVE_ICKY);
4490 /* Left and right boundaries */
4491 for (i = 1; i < ysize; i++)
4493 place_outer_noperm_bold(y1 + i, x1);
4494 cave[y1 + i][x1].info|=(CAVE_ROOM | CAVE_ICKY);
4495 place_outer_noperm_bold(y1 + i, x2);
4496 cave[y1 + i][x2].info|=(CAVE_ROOM | CAVE_ICKY);
4500 for (x = 1; x < xsize; x++)
4502 for (y = 1; y < ysize; y++)
4504 if (is_extra_bold(y1+y, x1+x))
4506 /* clear the untouched region */
4507 place_floor_bold(y1 + y, x1 + x);
4508 cave[y1 + y][x1 + x].info |= (CAVE_ROOM | CAVE_ICKY);
4512 /* make it a room- but don't touch */
4513 cave[y1 + y][x1 + x].info |= (CAVE_ROOM | CAVE_ICKY);
4520 /* Create a random vault that looks like a collection of overlapping rooms */
4522 static void build_room_vault(int x0, int y0, int xsize, int ysize)
4524 int i, x1, x2, y1, y2, xhsize, yhsize;
4526 /* get offset from center */
4530 msg_print_wizard(CHEAT_DUNGEON, _("部屋型ランダムVaultを生成しました。", "Room Vault."));
4532 /* fill area so don't get problems with arena levels */
4533 for (x1 = 0; x1 < xsize; x1++)
4535 int x = x0 - xhsize + x1;
4537 for (y1 = 0; y1 < ysize; y1++)
4539 int y = y0 - yhsize + y1;
4541 place_extra_bold(y, x);
4542 cave[y][x].info &= (~CAVE_ICKY);
4546 /* add ten random rooms */
4547 for (i = 0; i < 10; i++)
4549 x1 = randint1(xhsize) * 2 + x0 - xhsize;
4550 x2 = randint1(xhsize) * 2 + x0 - xhsize;
4551 y1 = randint1(yhsize) * 2 + y0 - yhsize;
4552 y2 = randint1(yhsize) * 2 + y0 - yhsize;
4553 build_room(x1, x2, y1, y2);
4556 /* Add some random doors */
4557 for (i = 0; i < 500; i++)
4559 x1 = randint1(xsize - 3) - xhsize + x0 + 1;
4560 y1 = randint1(ysize - 3) - yhsize + y0 + 1;
4564 /* Fill with monsters and treasure, high difficulty */
4565 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5);
4569 /* Create a random vault out of a fractal cave */
4570 static void build_cave_vault(int x0, int y0, int xsiz, int ysiz)
4572 int grd, roug, cutoff, xhsize, yhsize, xsize, ysize, x, y;
4573 bool done, light, room;
4575 /* round to make sizes even */
4581 msg_print_wizard(CHEAT_DUNGEON, _("洞穴ランダムVaultを生成しました。", "Cave Vault."));
4583 light = done = FALSE;
4588 /* testing values for these parameters feel free to adjust */
4589 grd = 1 << randint0(4);
4591 /* want average of about 16 */
4592 roug = randint1(8) * randint1(4);
4595 cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
4596 randint1(xsize / 4) + randint1(ysize / 4);
4599 generate_hmap(y0, x0, xsize, ysize, grd, roug, cutoff);
4601 /* Convert to normal format+ clean up */
4602 done = generate_fracave(y0, x0, xsize, ysize, cutoff, light, room);
4605 /* Set icky flag because is a vault */
4606 for (x = 0; x <= xsize; x++)
4608 for (y = 0; y <= ysize; y++)
4610 cave[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
4614 /* Fill with monsters and treasure, low difficulty */
4615 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
4619 * maze vault -- rectangular labyrinthine rooms
4621 * maze vault uses two routines:
4622 * r_visit - a recursive routine that builds the labyrinth
4623 * build_maze_vault - a driver routine that calls r_visit and adds
4624 * monsters, traps and treasure
4626 * The labyrinth is built by creating a spanning tree of a graph.
4627 * The graph vertices are at
4628 * (x, y) = (2j + x1, 2k + y1) j = 0,...,m-1 k = 0,...,n-1
4629 * and the edges are the vertical and horizontal nearest neighbors.
4631 * The spanning tree is created by performing a suitably randomized
4632 * depth-first traversal of the graph. The only adjustable parameter
4633 * is the randint0(3) below; it governs the relative density of
4634 * twists and turns in the labyrinth: smaller number, more twists.
4636 static void r_visit(int y1, int x1, int y2, int x2,
4637 int node, int dir, int *visited)
4639 int i, j, m, n, temp, x, y, adj[4];
4641 /* dimensions of vertex array */
4642 m = (x2 - x1) / 2 + 1;
4643 n = (y2 - y1) / 2 + 1;
4645 /* mark node visited and set it to a floor */
4647 x = 2 * (node % m) + x1;
4648 y = 2 * (node / m) + y1;
4649 place_floor_bold(y, x);
4651 /* setup order of adjacent node visits */
4654 /* pick a random ordering */
4655 for (i = 0; i < 4; i++)
4657 for (i = 0; i < 4; i++)
4668 /* pick a random ordering with dir first */
4670 for (i = 1; i < 4; i++)
4672 for (i = 1; i < 4; i++)
4674 j = 1 + randint0(3);
4681 for (i = 0; i < 4; i++)
4686 /* (0,+) - check for bottom boundary */
4687 if ((node / m < n - 1) && (visited[node + m] == 0))
4689 place_floor_bold(y + 1, x);
4690 r_visit(y1, x1, y2, x2, node + m, dir, visited);
4694 /* (0,-) - check for top boundary */
4695 if ((node / m > 0) && (visited[node - m] == 0))
4697 place_floor_bold(y - 1, x);
4698 r_visit(y1, x1, y2, x2, node - m, dir, visited);
4702 /* (+,0) - check for right boundary */
4703 if ((node % m < m - 1) && (visited[node + 1] == 0))
4705 place_floor_bold(y, x + 1);
4706 r_visit(y1, x1, y2, x2, node + 1, dir, visited);
4710 /* (-,0) - check for left boundary */
4711 if ((node % m > 0) && (visited[node - 1] == 0))
4713 place_floor_bold(y, x - 1);
4714 r_visit(y1, x1, y2, x2, node - 1, dir, visited);
4721 void build_maze_vault(int x0, int y0, int xsize, int ysize, bool is_vault)
4725 int m, n, num_vertices, *visited;
4729 msg_print_wizard(CHEAT_DUNGEON, _("迷路ランダムVaultを生成しました。", "Maze Vault."));
4731 /* Choose lite or dark */
4732 light = ((dun_level <= randint1(25)) && is_vault && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
4734 /* Pick a random room size - randomized by calling routine */
4743 /* generate the room */
4744 for (y = y1 - 1; y <= y2 + 1; y++)
4746 for (x = x1 - 1; x <= x2 + 1; x++)
4748 c_ptr = &cave[y][x];
4749 c_ptr->info |= CAVE_ROOM;
4750 if (is_vault) c_ptr->info |= CAVE_ICKY;
4751 if ((x == x1 - 1) || (x == x2 + 1) || (y == y1 - 1) || (y == y2 + 1))
4753 place_outer_grid(c_ptr);
4757 place_extra_grid(c_ptr);
4761 place_inner_grid(c_ptr);
4763 if (light) c_ptr->info |= (CAVE_GLOW);
4767 /* dimensions of vertex array */
4770 num_vertices = m * n;
4772 /* initialize array of visited vertices */
4773 C_MAKE(visited, num_vertices, int);
4775 /* traverse the graph to create a spaning tree, pick a random root */
4776 r_visit(y1, x1, y2, x2, randint0(num_vertices), 0, visited);
4778 /* Fill with monsters and treasure, low difficulty */
4779 if (is_vault) fill_treasure(x1, x2, y1, y2, randint1(5));
4781 C_KILL(visited, num_vertices, int);
4785 /* Build a "mini" checkerboard vault
4787 * This is done by making a permanent wall maze and setting
4788 * the diagonal sqaures of the checker board to be granite.
4789 * The vault has two entrances on opposite sides to guarantee
4790 * a way to get in even if the vault abuts a side of the dungeon.
4792 static void build_mini_c_vault(int x0, int y0, int xsize, int ysize)
4795 int y1, x1, y2, x2, y, x, total;
4796 int m, n, num_vertices;
4799 msg_print_wizard(CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
4801 /* Pick a random room size */
4811 /* generate the room */
4812 for (x = x1 - 2; x <= x2 + 2; x++)
4814 if (!in_bounds(y1-2,x)) break;
4816 cave[y1-2][x].info |= (CAVE_ROOM | CAVE_ICKY);
4818 place_outer_noperm_bold(y1-2, x);
4821 for (x = x1 - 2; x <= x2 + 2; x++)
4823 if (!in_bounds(y2+2,x)) break;
4825 cave[y2+2][x].info |= (CAVE_ROOM | CAVE_ICKY);
4827 place_outer_noperm_bold(y2+2, x);
4830 for (y = y1 - 2; y <= y2 + 2; y++)
4832 if (!in_bounds(y,x1-2)) break;
4834 cave[y][x1-2].info |= (CAVE_ROOM | CAVE_ICKY);
4836 place_outer_noperm_bold(y, x1-2);
4839 for (y = y1 - 2; y <= y2 + 2; y++)
4841 if (!in_bounds(y,x2+2)) break;
4843 cave[y][x2+2].info |= (CAVE_ROOM | CAVE_ICKY);
4845 place_outer_noperm_bold(y, x2+2);
4848 for (y = y1 - 1; y <= y2 + 1; y++)
4850 for (x = x1 - 1; x <= x2 + 1; x++)
4852 cave_type *c_ptr = &cave[y][x];
4854 c_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
4856 /* Permanent walls */
4857 place_inner_perm_grid(c_ptr);
4862 /* dimensions of vertex array */
4865 num_vertices = m * n;
4867 /* initialize array of visited vertices */
4868 C_MAKE(visited, num_vertices, int);
4870 /* traverse the graph to create a spannng tree, pick a random root */
4871 r_visit(y1, x1, y2, x2, randint0(num_vertices), 0, visited);
4873 /* Make it look like a checker board vault */
4874 for (x = x1; x <= x2; x++)
4876 for (y = y1; y <= y2; y++)
4878 total = x - x1 + y - y1;
4879 /* If total is odd- and is a floor then make a wall */
4880 if ((total % 2 == 1) && is_floor_bold(y, x))
4882 place_inner_bold(y, x);
4887 /* Make a couple of entrances */
4890 /* left and right */
4891 y = randint1(dy) + dy / 2;
4892 place_inner_bold(y1 + y, x1 - 1);
4893 place_inner_bold(y1 + y, x2 + 1);
4897 /* top and bottom */
4898 x = randint1(dx) + dx / 2;
4899 place_inner_bold(y1 - 1, x1 + x);
4900 place_inner_bold(y2 + 1, x1 + x);
4903 /* Fill with monsters and treasure, highest difficulty */
4904 fill_treasure(x1, x2, y1, y2, 10);
4906 C_KILL(visited, num_vertices, int);
4910 /* Build a town/ castle by using a recursive algorithm.
4911 * Basically divide each region in a probalistic way to create
4912 * smaller regions. When the regions get too small stop.
4914 * The power variable is a measure of how well defended a region is.
4915 * This alters the possible choices.
4917 static void build_recursive_room(int x1, int y1, int x2, int y2, int power)
4923 /* Temp variables */
4929 if ((power < 3) && (xsize > 12) && (ysize > 12))
4931 /* Need outside wall +keep */
4938 /* Make rooms + subdivide */
4939 if ((randint1(10) > 2) && (xsize < 8) && (ysize < 8))
4945 choice = randint1(2) + 1;
4950 /* Mostly subdivide */
4951 choice = randint1(3) + 1;
4955 /* Based on the choice made above, do something */
4963 /* top and bottom */
4964 for (x = x1; x <= x2; x++)
4966 place_outer_bold(y1, x);
4967 place_outer_bold(y2, x);
4970 /* left and right */
4971 for (y = y1 + 1; y < y2; y++)
4973 place_outer_bold(y, x1);
4974 place_outer_bold(y, x2);
4977 /* Make a couple of entrances */
4980 /* left and right */
4981 y = randint1(ysize) + y1;
4982 place_floor_bold(y, x1);
4983 place_floor_bold(y, x2);
4987 /* top and bottom */
4988 x = randint1(xsize) + x1;
4989 place_floor_bold(y1, x);
4990 place_floor_bold(y2, x);
4993 /* Select size of keep */
4994 t1 = randint1(ysize / 3) + y1;
4995 t2 = y2 - randint1(ysize / 3);
4996 t3 = randint1(xsize / 3) + x1;
4997 t4 = x2 - randint1(xsize / 3);
4999 /* Do outside areas */
5001 /* Above and below keep */
5002 build_recursive_room(x1 + 1, y1 + 1, x2 - 1, t1, power + 1);
5003 build_recursive_room(x1 + 1, t2, x2 - 1, y2, power + 1);
5005 /* Left and right of keep */
5006 build_recursive_room(x1 + 1, t1 + 1, t3, t2 - 1, power + 3);
5007 build_recursive_room(t4, t1 + 1, x2 - 1, t2 - 1, power + 3);
5009 /* Make the keep itself: */
5022 /* Try to build a room */
5023 if ((xsize < 3) || (ysize < 3))
5025 for (y = y1; y < y2; y++)
5027 for (x = x1; x < x2; x++)
5029 place_inner_bold(y, x);
5037 /* Make outside walls */
5038 /* top and bottom */
5039 for (x = x1 + 1; x <= x2 - 1; x++)
5041 place_inner_bold(y1 + 1, x);
5042 place_inner_bold(y2 - 1, x);
5045 /* left and right */
5046 for (y = y1 + 1; y <= y2 - 1; y++)
5048 place_inner_bold(y, x1 + 1);
5049 place_inner_bold(y, x2 - 1);
5053 y = randint1(ysize - 3) + y1 + 1;
5058 place_floor_bold(y, x1 + 1);
5063 place_floor_bold(y, x2 - 1);
5066 /* Build the room */
5067 build_recursive_room(x1 + 2, y1 + 2, x2 - 2, y2 - 2, power + 3);
5072 /* Try and divide vertically */
5076 for (y = y1; y < y2; y++)
5078 for (x = x1; x < x2; x++)
5080 place_inner_bold(y, x);
5086 t1 = randint1(xsize - 2) + x1 + 1;
5087 build_recursive_room(x1, y1, t1, y2, power - 2);
5088 build_recursive_room(t1 + 1, y1, x2, y2, power - 2);
5093 /* Try and divide horizontally */
5097 for (y = y1; y < y2; y++)
5099 for (x = x1; x < x2; x++)
5101 place_inner_bold(y, x);
5107 t1 = randint1(ysize - 2) + y1 + 1;
5108 build_recursive_room(x1, y1, x2, t1, power - 2);
5109 build_recursive_room(x1, t1 + 1, x2, y2, power - 2);
5116 /* Build a castle */
5118 /* Driver routine: clear the region and call the recursive
5121 *This makes a vault that looks like a castle/ city in the dungeon.
5123 static void build_castle_vault(int x0, int y0, int xsize, int ysize)
5129 /* Pick a random room size */
5138 msg_print_wizard(CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
5140 /* generate the room */
5141 for (y = y1 - 1; y <= y2 + 1; y++)
5143 for (x = x1 - 1; x <= x2 + 1; x++)
5145 cave[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
5146 /* Make everything a floor */
5147 place_floor_bold(y, x);
5151 /* Make the castle */
5152 build_recursive_room(x1, y1, x2, y2, randint1(5));
5154 /* Fill with monsters and treasure, low difficulty */
5155 fill_treasure(x1, x2, y1, y2, randint1(3));
5160 * Add outer wall to a floored region
5161 * Note: no range checking is done so must be inside dungeon
5162 * This routine also stomps on doors
5164 static void add_outer_wall(int x, int y, int light, int x1, int y1, int x2, int y2)
5167 feature_type *f_ptr;
5170 if (!in_bounds(y, x)) return;
5172 c_ptr = &cave[y][x];
5174 /* hack- check to see if square has been visited before
5175 * if so, then exit (use room flag to do this) */
5176 if (c_ptr->info & CAVE_ROOM) return;
5179 c_ptr->info |= CAVE_ROOM;
5181 f_ptr = &f_info[c_ptr->feat];
5183 if (is_floor_bold(y, x))
5185 for (i = -1; i <= 1; i++)
5187 for (j = -1; j <= 1; j++)
5189 if ((x + i >= x1) && (x + i <= x2) &&
5190 (y + j >= y1) && (y + j <= y2))
5192 add_outer_wall(x + i, y + j, light, x1, y1, x2, y2);
5193 if (light) c_ptr->info |= CAVE_GLOW;
5198 else if (is_extra_bold(y, x))
5200 /* Set bounding walls */
5201 place_outer_bold(y, x);
5202 if (light) c_ptr->info |= CAVE_GLOW;
5204 else if (permanent_wall(f_ptr))
5206 /* Set bounding walls */
5207 if (light) c_ptr->info |= CAVE_GLOW;
5213 * Hacked distance formula - gives the 'wrong' answer.
5214 * Used to build crypts
5216 static int dist2(int x1, int y1, int x2, int y2,
5217 int h1, int h2, int h3, int h4)
5223 /* Basically this works by taking the normal pythagorean formula
5224 * and using an expansion to express this in a way without the
5225 * square root. This approximate formula is then perturbed to give
5226 * the distorted results. (I found this by making a mistake when I was
5227 * trying to fix the circular rooms.)
5230 /* h1-h4 are constants that describe the metric */
5231 if (dx >= 2 * dy) return (dx + (dy * h1) / h2);
5232 if (dy >= 2 * dx) return (dy + (dx * h1) / h2);
5233 return (((dx + dy) * 128) / 181 +
5234 (dx * dx / (dy * h3) + dy * dy / (dx * h3)) * h4);
5235 /* 128/181 is approx. 1/sqrt(2) */
5240 * Build target vault.
5241 * This is made by two concentric "crypts" with perpendicular
5242 * walls creating the cross-hairs.
5244 static void build_target_vault(int x0, int y0, int xsize, int ysize)
5248 /* Make a random metric */
5250 h1 = randint1(32) - 16;
5253 h4 = randint1(32) - 16;
5255 msg_print_wizard(CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Elemental Vault"));
5257 /* work out outer radius */
5268 for (x = x0 - rad; x <= x0 + rad; x++)
5270 for (y = y0 - rad; y <= y0 + rad; y++)
5272 /* clear room flag */
5273 cave[y][x].info &= ~(CAVE_ROOM);
5275 /* Vault - so is "icky" */
5276 cave[y][x].info |= CAVE_ICKY;
5278 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1)
5280 /* inside- so is floor */
5281 place_floor_bold(y, x);
5285 /* make granite outside so arena works */
5286 place_extra_bold(y, x);
5289 /* proper boundary for arena */
5290 if (((y + rad) == y0) || ((y - rad) == y0) ||
5291 ((x + rad) == x0) || ((x - rad) == x0))
5293 place_extra_bold(y, x);
5298 /* Find visible outer walls and set to be FEAT_OUTER */
5299 add_outer_wall(x0, y0, FALSE, x0 - rad - 1, y0 - rad - 1,
5300 x0 + rad + 1, y0 + rad + 1);
5302 /* Add inner wall */
5303 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++)
5305 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++)
5307 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2)
5309 /* Make an internal wall */
5310 place_inner_bold(y, x);
5315 /* Add perpendicular walls */
5316 for (x = x0 - rad; x <= x0 + rad; x++)
5318 place_inner_bold(y0, x);
5321 for (y = y0 - rad; y <= y0 + rad; y++)
5323 place_inner_bold(y, x0);
5326 /* Make inner vault */
5327 for (y = y0 - 1; y <= y0 + 1; y++)
5329 place_inner_bold(y, x0 - 1);
5330 place_inner_bold(y, x0 + 1);
5332 for (x = x0 - 1; x <= x0 + 1; x++)
5334 place_inner_bold(y0 - 1, x);
5335 place_inner_bold(y0 + 1, x);
5338 place_floor_bold(y0, x0);
5341 /* Add doors to vault */
5342 /* get two distances so can place doors relative to centre */
5343 x = (rad - 2) / 4 + 1;
5346 add_door(x0 + x, y0);
5347 add_door(x0 + y, y0);
5348 add_door(x0 - x, y0);
5349 add_door(x0 - y, y0);
5350 add_door(x0, y0 + x);
5351 add_door(x0, y0 + y);
5352 add_door(x0, y0 - x);
5353 add_door(x0, y0 - y);
5355 /* Fill with stuff - medium difficulty */
5356 fill_treasure(x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
5360 #ifdef ALLOW_CAVERNS_AND_LAKES
5362 * This routine uses a modified version of the lake code to make a
5363 * distribution of some terrain type over the vault. This type
5364 * depends on the dungeon depth.
5366 * Miniture rooms are then scattered across the vault.
5368 static void build_elemental_vault(int x0, int y0, int xsiz, int ysiz)
5373 int xsize, ysize, xhsize, yhsize, x, y, i;
5376 msg_print_wizard(CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
5378 /* round to make sizes even */
5386 /* Earth vault (Rubble) */
5387 type = LAKE_T_EARTH_VAULT;
5389 else if (dun_level < 50)
5391 /* Air vault (Trees) */
5392 type = LAKE_T_AIR_VAULT;
5394 else if (dun_level < 75)
5396 /* Water vault (shallow water) */
5397 type = LAKE_T_WATER_VAULT;
5401 /* Fire vault (shallow lava) */
5402 type = LAKE_T_FIRE_VAULT;
5407 /* testing values for these parameters: feel free to adjust */
5408 grd = 1 << (randint0(3));
5410 /* want average of about 16 */
5411 roug = randint1(8) * randint1(4);
5413 /* Make up size of various componants */
5417 /* Deep water/lava */
5418 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
5420 /* Shallow boundary */
5424 generate_hmap(y0, x0, xsize, ysize, grd, roug, c3);
5426 /* Convert to normal format+ clean up */
5427 done = generate_lake(y0, x0, xsize, ysize, c1, c2, c3, type);
5430 /* Set icky flag because is a vault */
5431 for (x = 0; x <= xsize; x++)
5433 for (y = 0; y <= ysize; y++)
5435 cave[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
5439 /* make a few rooms in the vault */
5440 for (i = 1; i <= (xsize * ysize) / 50; i++)
5442 build_small_room(x0 + randint0(xsize - 4) - xsize / 2 + 2,
5443 y0 + randint0(ysize - 4) - ysize / 2 + 2);
5446 /* Fill with monsters and treasure, low difficulty */
5447 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 1,
5448 y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
5450 #endif /* ALLOW_CAVERNS_AND_LAKES */
5454 * @brief タイプ10の部屋…ランダム生成vault / Type 10 -- Random vaults
5457 static bool build_type10(void)
5459 int y0, x0, xsize, ysize, vtype;
5462 /* big enough to look good, small enough to be fairly common. */
5463 xsize = randint1(22) + 22;
5464 ysize = randint1(11) + 11;
5466 /* Find and reserve some space in the dungeon. Get center of room. */
5467 if (!find_space(&y0, &x0, ysize + 1, xsize + 1)) return FALSE;
5469 /* Select type of vault */
5470 #ifdef ALLOW_CAVERNS_AND_LAKES
5473 vtype = randint1(15);
5475 while ((d_info[dungeon_type].flags1 & DF1_NO_CAVE) &&
5476 ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
5477 #else /* ALLOW_CAVERNS_AND_LAKES */
5480 vtype = randint1(7);
5482 while ((d_info[dungeon_type].flags1 & DF1_NO_CAVE) &&
5483 ((vtype == 1) || (vtype == 3)));
5484 #endif /* ALLOW_CAVERNS_AND_LAKES */
5488 /* Build an appropriate room */
5489 case 1: case 9: build_bubble_vault(x0, y0, xsize, ysize); break;
5490 case 2: case 10: build_room_vault(x0, y0, xsize, ysize); break;
5491 case 3: case 11: build_cave_vault(x0, y0, xsize, ysize); break;
5492 case 4: case 12: build_maze_vault(x0, y0, xsize, ysize, TRUE); break;
5493 case 5: case 13: build_mini_c_vault(x0, y0, xsize, ysize); break;
5494 case 6: case 14: build_castle_vault(x0, y0, xsize, ysize); break;
5495 case 7: case 15: build_target_vault(x0, y0, xsize, ysize); break;
5496 #ifdef ALLOW_CAVERNS_AND_LAKES
5497 case 8: build_elemental_vault(x0, y0, xsize, ysize); break;
5498 #endif /* ALLOW_CAVERNS_AND_LAKES */
5499 /* I know how to add a few more... give me some time. */
5502 default: return FALSE;
5510 * @brief タイプ11の部屋…円形部屋の生成 / Type 11 -- Build an vertical oval room.
5513 * For every grid in the possible square, check the distance.\n
5514 * If it's less than the radius, make it a room square.\n
5516 * When done fill from the inside to find the walls,\n
5518 static bool build_type11(void)
5520 POSITION rad, x, y, x0, y0;
5523 /* Occasional light */
5524 if ((randint1(dun_level) <= 15) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS)) light = TRUE;
5528 /* Find and reserve some space in the dungeon. Get center of room. */
5529 if (!find_space(&y0, &x0, rad * 2 + 1, rad * 2 + 1)) return FALSE;
5531 /* Make circular floor */
5532 for (x = x0 - rad; x <= x0 + rad; x++)
5534 for (y = y0 - rad; y <= y0 + rad; y++)
5536 if (distance(y0, x0, y, x) <= rad - 1)
5538 /* inside- so is floor */
5539 place_floor_bold(y, x);
5541 else if (distance(y0, x0, y, x) <= rad + 1)
5543 /* make granite outside so arena works */
5544 place_extra_bold(y, x);
5549 /* Find visible outer walls and set to be FEAT_OUTER */
5550 add_outer_wall(x0, y0, light, x0 - rad, y0 - rad, x0 + rad, y0 + rad);
5557 * @brief タイプ12の部屋…ドーム型部屋の生成 / Type 12 -- Build crypt room.
5560 * For every grid in the possible square, check the (fake) distance.\n
5561 * If it's less than the radius, make it a room square.\n
5563 * When done fill from the inside to find the walls,\n
5565 static bool build_type12(void)
5567 int rad, x, y, x0, y0;
5569 bool emptyflag = TRUE;
5571 /* Make a random metric */
5573 h1 = randint1(32) - 16;
5576 h4 = randint1(32) - 16;
5578 /* Occasional light */
5579 if ((randint1(dun_level) <= 5) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS)) light = TRUE;
5583 /* Find and reserve some space in the dungeon. Get center of room. */
5584 if (!find_space(&y0, &x0, rad * 2 + 3, rad * 2 + 3)) return FALSE;
5587 for (x = x0 - rad; x <= x0 + rad; x++)
5589 for (y = y0 - rad; y <= y0 + rad; y++)
5591 /* clear room flag */
5592 cave[y][x].info &= ~(CAVE_ROOM);
5594 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1)
5596 /* inside - so is floor */
5597 place_floor_bold(y, x);
5599 else if (distance(y0, x0, y, x) < 3)
5601 place_floor_bold(y, x);
5605 /* make granite outside so arena works */
5606 place_extra_bold(y, x);
5609 /* proper boundary for arena */
5610 if (((y + rad) == y0) || ((y - rad) == y0) ||
5611 ((x + rad) == x0) || ((x - rad) == x0))
5613 place_extra_bold(y, x);
5618 /* Find visible outer walls and set to be FEAT_OUTER */
5619 add_outer_wall(x0, y0, light, x0 - rad - 1, y0 - rad - 1,
5620 x0 + rad + 1, y0 + rad + 1);
5622 /* Check to see if there is room for an inner vault */
5623 for (x = x0 - 2; x <= x0 + 2; x++)
5625 for (y = y0 - 2; y <= y0 + 2; y++)
5627 if (!is_floor_bold(y, x))
5629 /* Wall in the way */
5635 if (emptyflag && one_in_(2))
5637 /* Build the vault */
5638 build_small_room(x0, y0);
5640 /* Place a treasure in the vault */
5641 place_object(y0, x0, 0L);
5643 /* Let's guard the treasure well */
5644 vault_monsters(y0, x0, randint0(2) + 3);
5646 /* Traps naturally */
5647 vault_traps(y0, x0, 4, 4, randint0(3) + 2);
5655 * Helper function for "trapped monster pit"
5657 static bool vault_aux_trapped_pit(MONRACE_IDX r_idx)
5659 monster_race *r_ptr = &r_info[r_idx];
5661 /* Validate the monster */
5662 if (!vault_monster_okay(r_idx)) return (FALSE);
5664 /* No wall passing monster */
5665 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return (FALSE);
5673 * @brief タイプ13の部屋…トラップpitの生成 / Type 13 -- Trapped monster pits
5676 * A trapped monster pit is a "big" room with a straight corridor in\n
5677 * which wall opening traps are placed, and with two "inner" rooms\n
5678 * containing a "collection" of monsters of a given type organized in\n
5681 * The trapped monster pit appears as shown below, where the actual\n
5682 * monsters in each location depend on the type of the pit\n
5684 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
5686 * XXXXXXXXXXXXXXXXXXXXXXX X\n
5687 * XXXXX001123454321100XXX X\n
5688 * XXX0012234567654322100X X\n
5689 * XXXXXXXXXXXXXXXXXXXXXXX X\n
5691 * X XXXXXXXXXXXXXXXXXXXXXXX\n
5692 * X X0012234567654322100XXX\n
5693 * X XXX001123454321100XXXXX\n
5694 * X XXXXXXXXXXXXXXXXXXXXXXX\n
5696 * XXXXXXXXXXXXXXXXXXXXXXXXX\n
5698 * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
5699 * to request 16 "appropriate" monsters, sorting them by level, and using\n
5700 * the "even" entries in this sorted list for the contents of the pit.\n
5702 * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
5703 * which is handled by requiring a specific "breath" attack for all of the\n
5704 * dragons. This may include "multi-hued" breath. Note that "wyrms" may\n
5705 * be present in many of the dragon pits, if they have the proper breath.\n
5707 * Note the use of the "get_mon_num_prep()" function, and the special\n
5708 * "get_mon_num_hook()" restriction function, to prepare the "monster\n
5709 * allocation table" in such a way as to optimize the selection of\n
5710 * "appropriate" non-unique monsters for the pit.\n
5712 * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
5713 * the pit will be empty.\n
5715 * Note that "monster pits" will never contain "unique" monsters.\n
5717 static bool build_type13(void)
5719 static int placing[][3] = {
5720 {-2, -9, 0}, {-2, -8, 0}, {-3, -7, 0}, {-3, -6, 0},
5721 {+2, -9, 0}, {+2, -8, 0}, {+3, -7, 0}, {+3, -6, 0},
5722 {-2, +9, 0}, {-2, +8, 0}, {-3, +7, 0}, {-3, +6, 0},
5723 {+2, +9, 0}, {+2, +8, 0}, {+3, +7, 0}, {+3, +6, 0},
5724 {-2, -7, 1}, {-3, -5, 1}, {-3, -4, 1},
5725 {+2, -7, 1}, {+3, -5, 1}, {+3, -4, 1},
5726 {-2, +7, 1}, {-3, +5, 1}, {-3, +4, 1},
5727 {+2, +7, 1}, {+3, +5, 1}, {+3, +4, 1},
5728 {-2, -6, 2}, {-2, -5, 2}, {-3, -3, 2},
5729 {+2, -6, 2}, {+2, -5, 2}, {+3, -3, 2},
5730 {-2, +6, 2}, {-2, +5, 2}, {-3, +3, 2},
5731 {+2, +6, 2}, {+2, +5, 2}, {+3, +3, 2},
5732 {-2, -4, 3}, {-3, -2, 3},
5733 {+2, -4, 3}, {+3, -2, 3},
5734 {-2, +4, 3}, {-3, +2, 3},
5735 {+2, +4, 3}, {+3, +2, 3},
5736 {-2, -3, 4}, {-3, -1, 4},
5737 {+2, -3, 4}, {+3, -1, 4},
5738 {-2, +3, 4}, {-3, +1, 4},
5739 {+2, +3, 4}, {+3, +1, 4},
5740 {-2, -2, 5}, {-3, 0, 5}, {-2, +2, 5},
5741 {+2, -2, 5}, {+3, 0, 5}, {+2, +2, 5},
5742 {-2, -1, 6}, {-2, +1, 6},
5743 {+2, -1, 6}, {+2, +1, 6},
5744 {-2, 0, 7}, {+2, 0, 7},
5748 POSITION y, x, y1, x1, y2, x2, xval, yval;
5751 MONRACE_IDX what[16];
5757 int cur_pit_type = pick_vault_type(pit_types, d_info[dungeon_type].pit);
5758 vault_aux_type *n_ptr;
5760 /* Only in Angband */
5761 if (dungeon_type != DUNGEON_ANGBAND) return FALSE;
5763 /* No type available */
5764 if (cur_pit_type < 0) return FALSE;
5766 n_ptr = &pit_types[cur_pit_type];
5768 /* Process a preparation function if necessary */
5769 if (n_ptr->prep_func) (*(n_ptr->prep_func))();
5771 /* Prepare allocation table */
5772 get_mon_num_prep(n_ptr->hook_func, vault_aux_trapped_pit);
5774 align.sub_align = SUB_ALIGN_NEUTRAL;
5776 /* Pick some monster types */
5777 for (i = 0; i < 16; i++)
5779 MONRACE_IDX r_idx = 0;
5781 monster_race *r_ptr = NULL;
5785 /* Get a (hard) monster type */
5786 r_idx = get_mon_num(dun_level + 0);
5787 r_ptr = &r_info[r_idx];
5789 /* Decline incorrect alignment */
5790 if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
5792 /* Accept this monster */
5796 /* Notice failure */
5797 if (!r_idx || !attempts) return FALSE;
5799 /* Note the alignment */
5800 if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
5801 if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
5806 /* Find and reserve some space in the dungeon. Get center of room. */
5807 if (!find_space(&yval, &xval, 13, 25)) return FALSE;
5815 /* Fill with inner walls */
5816 for (y = y1 - 1; y <= y2 + 1; y++)
5818 for (x = x1 - 1; x <= x2 + 1; x++)
5820 c_ptr = &cave[y][x];
5821 place_inner_grid(c_ptr);
5822 c_ptr->info |= (CAVE_ROOM);
5826 /* Place the floor area 1 */
5827 for (x = x1 + 3; x <= x2 - 3; x++)
5829 c_ptr = &cave[yval-2][x];
5830 place_floor_grid(c_ptr);
5831 add_cave_info(yval-2, x, CAVE_ICKY);
5833 c_ptr = &cave[yval+2][x];
5834 place_floor_grid(c_ptr);
5835 add_cave_info(yval+2, x, CAVE_ICKY);
5838 /* Place the floor area 2 */
5839 for (x = x1 + 5; x <= x2 - 5; x++)
5841 c_ptr = &cave[yval-3][x];
5842 place_floor_grid(c_ptr);
5843 add_cave_info(yval-3, x, CAVE_ICKY);
5845 c_ptr = &cave[yval+3][x];
5846 place_floor_grid(c_ptr);
5847 add_cave_info(yval+3, x, CAVE_ICKY);
5851 for (x = x1; x <= x2; x++)
5853 c_ptr = &cave[yval][x];
5854 place_floor_grid(c_ptr);
5855 c_ptr = &cave[y1][x];
5856 place_floor_grid(c_ptr);
5857 c_ptr = &cave[y2][x];
5858 place_floor_grid(c_ptr);
5861 /* Place the outer walls */
5862 for (y = y1 - 1; y <= y2 + 1; y++)
5864 c_ptr = &cave[y][x1 - 1];
5865 place_outer_grid(c_ptr);
5866 c_ptr = &cave[y][x2 + 1];
5867 place_outer_grid(c_ptr);
5869 for (x = x1 - 1; x <= x2 + 1; x++)
5871 c_ptr = &cave[y1 - 1][x];
5872 place_outer_grid(c_ptr);
5873 c_ptr = &cave[y2 + 1][x];
5874 place_outer_grid(c_ptr);
5877 /* Random corridor */
5880 for (y = y1; y <= yval; y++)
5882 place_floor_bold(y, x2);
5883 place_solid_bold(y, x1-1);
5885 for (y = yval; y <= y2 + 1; y++)
5887 place_floor_bold(y, x1);
5888 place_solid_bold(y, x2+1);
5893 for (y = yval; y <= y2 + 1; y++)
5895 place_floor_bold(y, x1);
5896 place_solid_bold(y, x2+1);
5898 for (y = y1; y <= yval; y++)
5900 place_floor_bold(y, x2);
5901 place_solid_bold(y, x1-1);
5905 /* Place the wall open trap */
5906 cave[yval][xval].mimic = cave[yval][xval].feat;
5907 cave[yval][xval].feat = feat_trap_open;
5909 /* Sort the entries */
5910 for (i = 0; i < 16 - 1; i++)
5912 /* Sort the entries */
5913 for (j = 0; j < 16 - 1; j++)
5918 int p1 = r_info[what[i1]].level;
5919 int p2 = r_info[what[i2]].level;
5925 what[i1] = what[i2];
5931 msg_format_wizard(CHEAT_DUNGEON, _("%s%sの罠ピットが生成されました。", "Trapped monster pit (%s%s)"),
5932 n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
5934 /* Select the entries */
5935 for (i = 0; i < 8; i++)
5937 /* Every other entry */
5938 what[i] = what[i * 2];
5943 msg_print(r_name + r_info[what[i]].name);
5947 for (i = 0; placing[i][2] >= 0; i++)
5949 y = yval + placing[i][0];
5950 x = xval + placing[i][1];
5951 place_monster_aux(0, y, x, what[placing[i][2]], PM_NO_KAGE);
5959 * @brief タイプ14の部屋…特殊トラップ部屋の生成 / Type 14 -- trapped rooms
5962 * A special trap is placed at center of the room
5964 static bool build_type14(void)
5966 POSITION y, x, y2, x2, yval, xval;
5967 POSITION y1, x1, xsize, ysize;
5974 /* Pick a room size */
5980 xsize = x1 + x2 + 1;
5981 ysize = y1 + y2 + 1;
5983 /* Find and reserve some space in the dungeon. Get center of room. */
5984 if (!find_space(&yval, &xval, ysize + 2, xsize + 2)) return FALSE;
5986 /* Choose lite or dark */
5987 light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
5990 /* Get corner values */
5991 y1 = yval - ysize / 2;
5992 x1 = xval - xsize / 2;
5993 y2 = yval + (ysize - 1) / 2;
5994 x2 = xval + (xsize - 1) / 2;
5997 /* Place a full floor under the room */
5998 for (y = y1 - 1; y <= y2 + 1; y++)
6000 for (x = x1 - 1; x <= x2 + 1; x++)
6002 c_ptr = &cave[y][x];
6003 place_floor_grid(c_ptr);
6004 c_ptr->info |= (CAVE_ROOM);
6005 if (light) c_ptr->info |= (CAVE_GLOW);
6009 /* Walls around the room */
6010 for (y = y1 - 1; y <= y2 + 1; y++)
6012 c_ptr = &cave[y][x1 - 1];
6013 place_outer_grid(c_ptr);
6014 c_ptr = &cave[y][x2 + 1];
6015 place_outer_grid(c_ptr);
6017 for (x = x1 - 1; x <= x2 + 1; x++)
6019 c_ptr = &cave[y1 - 1][x];
6020 place_outer_grid(c_ptr);
6021 c_ptr = &cave[y2 + 1][x];
6022 place_outer_grid(c_ptr);
6025 if (dun_level < 30 + randint1(30))
6026 trap = feat_trap_piranha;
6028 trap = feat_trap_armageddon;
6030 /* Place a special trap */
6031 c_ptr = &cave[rand_spread(yval, ysize/4)][rand_spread(xval, xsize/4)];
6032 c_ptr->mimic = c_ptr->feat;
6035 msg_format_wizard(CHEAT_DUNGEON, _("%sの部屋が生成されました。", "Room of %s was generated."), f_name + f_info[trap].name);
6042 * Helper function for "glass room"
6044 static bool vault_aux_lite(MONRACE_IDX r_idx)
6046 monster_race *r_ptr = &r_info[r_idx];
6048 /* Validate the monster */
6049 if (!vault_monster_okay(r_idx)) return FALSE;
6051 /* Require lite attack */
6052 if (!(r_ptr->flags4 & RF4_BR_LITE) && !(r_ptr->a_ability_flags1 & RF5_BA_LITE)) return FALSE;
6054 /* No wall passing monsters */
6055 if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return FALSE;
6057 /* No disintegrating monsters */
6058 if (r_ptr->flags4 & RF4_BR_DISI) return FALSE;
6064 * Helper function for "glass room"
6066 static bool vault_aux_shards(MONRACE_IDX r_idx)
6068 monster_race *r_ptr = &r_info[r_idx];
6070 /* Validate the monster */
6071 if (!vault_monster_okay(r_idx)) return FALSE;
6073 /* Require shards breath attack */
6074 if (!(r_ptr->flags4 & RF4_BR_SHAR)) return FALSE;
6080 * Hack -- determine if a template is potion
6082 static bool kind_is_potion(int k_idx)
6084 return k_info[k_idx].tval == TV_POTION;
6088 * @brief タイプ15の部屋…ガラス部屋の生成 / Type 15 -- glass rooms
6091 static bool build_type15(void)
6093 POSITION y, x, y2, x2, yval, xval;
6094 POSITION y1, x1, xsize, ysize;
6099 /* Pick a room size */
6100 xsize = rand_range(9, 13);
6101 ysize = rand_range(9, 13);
6103 /* Find and reserve some space in the dungeon. Get center of room. */
6104 if (!find_space(&yval, &xval, ysize + 2, xsize + 2)) return FALSE;
6106 /* Choose lite or dark */
6107 light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
6109 /* Get corner values */
6110 y1 = yval - ysize / 2;
6111 x1 = xval - xsize / 2;
6112 y2 = yval + (ysize - 1) / 2;
6113 x2 = xval + (xsize - 1) / 2;
6115 /* Place a full floor under the room */
6116 for (y = y1 - 1; y <= y2 + 1; y++)
6118 for (x = x1 - 1; x <= x2 + 1; x++)
6120 c_ptr = &cave[y][x];
6121 place_floor_grid(c_ptr);
6122 c_ptr->feat = feat_glass_floor;
6123 c_ptr->info |= (CAVE_ROOM);
6124 if (light) c_ptr->info |= (CAVE_GLOW);
6128 /* Walls around the room */
6129 for (y = y1 - 1; y <= y2 + 1; y++)
6131 c_ptr = &cave[y][x1 - 1];
6132 place_outer_grid(c_ptr);
6133 c_ptr->feat = feat_glass_wall;
6134 c_ptr = &cave[y][x2 + 1];
6135 place_outer_grid(c_ptr);
6136 c_ptr->feat = feat_glass_wall;
6138 for (x = x1 - 1; x <= x2 + 1; x++)
6140 c_ptr = &cave[y1 - 1][x];
6141 place_outer_grid(c_ptr);
6142 c_ptr->feat = feat_glass_wall;
6143 c_ptr = &cave[y2 + 1][x];
6144 place_outer_grid(c_ptr);
6145 c_ptr->feat = feat_glass_wall;
6148 switch (randint1(3))
6150 case 1: /* 4 lite breathers + potion */
6154 /* Prepare allocation table */
6155 get_mon_num_prep(vault_aux_lite, NULL);
6157 /* Place fixed lite berathers */
6158 for (dir1 = 4; dir1 < 8; dir1++)
6160 MONRACE_IDX r_idx = get_mon_num(dun_level);
6162 y = yval + 2 * ddy_ddd[dir1];
6163 x = xval + 2 * ddx_ddd[dir1];
6164 if (r_idx) place_monster_aux(0, y, x, r_idx, PM_ALLOW_SLEEP);
6166 /* Walls around the breather */
6167 for (dir2 = 0; dir2 < 8; dir2++)
6169 c_ptr = &cave[y + ddy_ddd[dir2]][x + ddx_ddd[dir2]];
6170 place_inner_grid(c_ptr);
6171 c_ptr->feat = feat_glass_wall;
6175 /* Walls around the potion */
6176 for (dir1 = 0; dir1 < 4; dir1++)
6178 y = yval + 2 * ddy_ddd[dir1];
6179 x = xval + 2 * ddx_ddd[dir1];
6180 c_ptr = &cave[y][x];
6181 place_inner_perm_grid(c_ptr);
6182 c_ptr->feat = feat_permanent_glass_wall;
6183 cave[yval + ddy_ddd[dir1]][xval + ddx_ddd[dir1]].info |= (CAVE_ICKY);
6188 y = yval + 2 * ddy_ddd[dir1];
6189 x = xval + 2 * ddx_ddd[dir1];
6190 place_secret_door(y, x, DOOR_GLASS_DOOR);
6191 c_ptr = &cave[y][x];
6192 if (is_closed_door(c_ptr->feat)) c_ptr->mimic = feat_glass_wall;
6194 /* Place a potion */
6195 get_obj_num_hook = kind_is_potion;
6196 place_object(yval, xval, AM_NO_FIXED_ART);
6197 cave[yval][xval].info |= (CAVE_ICKY);
6201 case 2: /* 1 lite breather + random object */
6207 c_ptr = &cave[y1 + 1][x1 + 1];
6208 place_inner_grid(c_ptr);
6209 c_ptr->feat = feat_glass_wall;
6211 c_ptr = &cave[y1 + 1][x2 - 1];
6212 place_inner_grid(c_ptr);
6213 c_ptr->feat = feat_glass_wall;
6215 c_ptr = &cave[y2 - 1][x1 + 1];
6216 place_inner_grid(c_ptr);
6217 c_ptr->feat = feat_glass_wall;
6219 c_ptr = &cave[y2 - 1][x2 - 1];
6220 place_inner_grid(c_ptr);
6221 c_ptr->feat = feat_glass_wall;
6223 /* Prepare allocation table */
6224 get_mon_num_prep(vault_aux_lite, NULL);
6226 r_idx = get_mon_num(dun_level);
6227 if (r_idx) place_monster_aux(0, yval, xval, r_idx, 0L);
6229 /* Walls around the breather */
6230 for (dir1 = 0; dir1 < 8; dir1++)
6232 c_ptr = &cave[yval + ddy_ddd[dir1]][xval + ddx_ddd[dir1]];
6233 place_inner_grid(c_ptr);
6234 c_ptr->feat = feat_glass_wall;
6237 /* Curtains around the breather */
6238 for (y = yval - 1; y <= yval + 1; y++)
6240 place_closed_door(y, xval - 2, DOOR_CURTAIN);
6241 place_closed_door(y, xval + 2, DOOR_CURTAIN);
6243 for (x = xval - 1; x <= xval + 1; x++)
6245 place_closed_door(yval - 2, x, DOOR_CURTAIN);
6246 place_closed_door(yval + 2, x, DOOR_CURTAIN);
6249 /* Place an object */
6250 place_object(yval, xval, AM_NO_FIXED_ART);
6251 cave[yval][xval].info |= (CAVE_ICKY);
6255 case 3: /* 4 shards breathers + 2 potions */
6259 /* Walls around the potion */
6260 for (y = yval - 2; y <= yval + 2; y++)
6262 c_ptr = &cave[y][xval - 3];
6263 place_inner_grid(c_ptr);
6264 c_ptr->feat = feat_glass_wall;
6265 c_ptr = &cave[y][xval + 3];
6266 place_inner_grid(c_ptr);
6267 c_ptr->feat = feat_glass_wall;
6269 for (x = xval - 2; x <= xval + 2; x++)
6271 c_ptr = &cave[yval - 3][x];
6272 place_inner_grid(c_ptr);
6273 c_ptr->feat = feat_glass_wall;
6274 c_ptr = &cave[yval + 3][x];
6275 place_inner_grid(c_ptr);
6276 c_ptr->feat = feat_glass_wall;
6278 for (dir1 = 4; dir1 < 8; dir1++)
6280 c_ptr = &cave[yval + 2 * ddy_ddd[dir1]][xval + 2 * ddx_ddd[dir1]];
6281 place_inner_grid(c_ptr);
6282 c_ptr->feat = feat_glass_wall;
6285 /* Prepare allocation table */
6286 get_mon_num_prep(vault_aux_shards, NULL);
6288 /* Place shard berathers */
6289 for (dir1 = 4; dir1 < 8; dir1++)
6291 MONRACE_IDX r_idx = get_mon_num(dun_level);
6293 y = yval + ddy_ddd[dir1];
6294 x = xval + ddx_ddd[dir1];
6295 if (r_idx) place_monster_aux(0, y, x, r_idx, 0L);
6298 /* Place two potions */
6301 get_obj_num_hook = kind_is_potion;
6302 place_object(yval, xval - 1, AM_NO_FIXED_ART);
6303 get_obj_num_hook = kind_is_potion;
6304 place_object(yval, xval + 1, AM_NO_FIXED_ART);
6308 get_obj_num_hook = kind_is_potion;
6309 place_object(yval - 1, xval, AM_NO_FIXED_ART);
6310 get_obj_num_hook = kind_is_potion;
6311 place_object(yval + 1, xval, AM_NO_FIXED_ART);
6314 for (y = yval - 2; y <= yval + 2; y++)
6315 for (x = xval - 2; x <= xval + 2; x++)
6316 cave[y][x].info |= (CAVE_ICKY);
6322 msg_print_wizard(CHEAT_DUNGEON, _("ガラスの部屋が生成されました。", "Glass room was generated."));
6328 /* Create a new floor room with optional light */
6329 void generate_room_floor(int y1, int x1, int y2, int x2, int light)
6335 for (y = y1; y <= y2; y++)
6337 for (x = x1; x <= x2; x++)
6340 c_ptr = &cave[y][x];
6341 place_floor_grid(c_ptr);
6342 c_ptr->info |= (CAVE_ROOM);
6343 if (light) c_ptr->info |= (CAVE_GLOW);
6348 void generate_fill_perm_bold(int y1, int x1, int y2, int x2)
6352 for (y = y1; y <= y2; y++)
6354 for (x = x1; x <= x2; x++)
6357 place_inner_perm_bold(y, x);
6362 /* Minimum & maximum town size */
6363 #define MIN_TOWN_WID ((MAX_WID / 3) / 2)
6364 #define MIN_TOWN_HGT ((MAX_HGT / 3) / 2)
6365 #define MAX_TOWN_WID ((MAX_WID / 3) * 2 / 3)
6366 #define MAX_TOWN_HGT ((MAX_HGT / 3) * 2 / 3)
6368 /* Struct for build underground buildings */
6371 int y0, x0; /* North-west corner (relative) */
6372 int y1, x1; /* South-east corner (relative) */
6376 ugbldg_type *ugbldg;
6379 * Precalculate buildings' location of underground arcade
6381 static bool precalc_ugarcade(int town_hgt, int town_wid, int n)
6383 int i, y, x, center_y, center_x, tmp, attempt = 10000;
6384 int max_bldg_hgt = 3 * town_hgt / MAX_TOWN_HGT;
6385 int max_bldg_wid = 5 * town_wid / MAX_TOWN_WID;
6386 ugbldg_type *cur_ugbldg;
6387 bool **ugarcade_used, abort;
6389 /* Allocate "ugarcade_used" array (2-dimension) */
6390 C_MAKE(ugarcade_used, town_hgt, bool *);
6391 C_MAKE(*ugarcade_used, town_hgt * town_wid, bool);
6392 for (y = 1; y < town_hgt; y++) ugarcade_used[y] = *ugarcade_used + y * town_wid;
6394 /* Calculate building locations */
6395 for (i = 0; i < n; i++)
6397 cur_ugbldg = &ugbldg[i];
6398 (void)WIPE(cur_ugbldg, ugbldg_type);
6402 /* Find the "center" of the store */
6403 center_y = rand_range(2, town_hgt - 3);
6404 center_x = rand_range(2, town_wid - 3);
6406 /* Determine the store boundaries */
6407 tmp = center_y - randint1(max_bldg_hgt);
6408 cur_ugbldg->y0 = MAX(tmp, 1);
6409 tmp = center_x - randint1(max_bldg_wid);
6410 cur_ugbldg->x0 = MAX(tmp, 1);
6411 tmp = center_y + randint1(max_bldg_hgt);
6412 cur_ugbldg->y1 = MIN(tmp, town_hgt - 2);
6413 tmp = center_x + randint1(max_bldg_wid);
6414 cur_ugbldg->x1 = MIN(tmp, town_wid - 2);
6416 /* Scan this building's area */
6417 for (abort = FALSE, y = cur_ugbldg->y0; (y <= cur_ugbldg->y1) && !abort; y++)
6419 for (x = cur_ugbldg->x0; x <= cur_ugbldg->x1; x++)
6421 if (ugarcade_used[y][x])
6431 while (abort && attempt); /* Accept this building if no overlapping */
6433 /* Failed to generate underground arcade */
6434 if (!attempt) break;
6437 * Mark to ugarcade_used[][] as "used"
6438 * Note: Building-adjacent grids are included for preventing
6439 * connected bulidings.
6441 for (y = cur_ugbldg->y0 - 1; y <= cur_ugbldg->y1 + 1; y++)
6443 for (x = cur_ugbldg->x0 - 1; x <= cur_ugbldg->x1 + 1; x++)
6445 ugarcade_used[y][x] = TRUE;
6450 /* Free "ugarcade_used" array (2-dimension) */
6451 C_KILL(*ugarcade_used, town_hgt * town_wid, bool);
6452 C_KILL(ugarcade_used, town_hgt, bool *);
6454 /* If i < n, generation is not allowed */
6459 * @brief タイプ16の部屋…地下都市生成のサブルーチン / Actually create buildings
6461 * @param ltcy 生成基準Y座標
6462 * @param ltcx 生成基準X座標
6463 * @param stotes[] 生成する店舗のリスト
6466 * Note: ltcy and ltcx indicate "left top corner".
6468 static void build_stores(int ltcy, int ltcx, int stores[], int n)
6472 ugbldg_type *cur_ugbldg;
6474 for (i = 0; i < n; i++)
6476 cur_ugbldg = &ugbldg[i];
6478 /* Generate new room */
6479 generate_room_floor(
6480 ltcy + cur_ugbldg->y0 - 2, ltcx + cur_ugbldg->x0 - 2,
6481 ltcy + cur_ugbldg->y1 + 2, ltcx + cur_ugbldg->x1 + 2,
6485 for (i = 0; i < n; i++)
6487 cur_ugbldg = &ugbldg[i];
6489 /* Build an invulnerable rectangular building */
6490 generate_fill_perm_bold(
6491 ltcy + cur_ugbldg->y0, ltcx + cur_ugbldg->x0,
6492 ltcy + cur_ugbldg->y1, ltcx + cur_ugbldg->x1);
6494 /* Pick a door direction (S,N,E,W) */
6495 switch (randint0(4))
6500 x = rand_range(cur_ugbldg->x0, cur_ugbldg->x1);
6506 x = rand_range(cur_ugbldg->x0, cur_ugbldg->x1);
6511 y = rand_range(cur_ugbldg->y0, cur_ugbldg->y1);
6517 y = rand_range(cur_ugbldg->y0, cur_ugbldg->y1);
6522 for (j = 0; j < max_f_idx; j++)
6524 if (have_flag(f_info[j].flags, FF_STORE))
6526 if (f_info[j].subtype == stores[i]) break;
6530 /* Clear previous contents, add a store door */
6533 cave_set_feat(ltcy + y, ltcx + x, j);
6536 store_init(NO_TOWN, stores[i]);
6543 * @brief タイプ16の部屋…地下都市の生成 / Type 16 -- Underground Arcade
6546 * Town logic flow for generation of new town\n
6547 * Originally from Vanilla 3.0.3\n
6549 * We start with a fully wiped cave of normal floors.\n
6551 * Note that town_gen_hack() plays games with the R.N.G.\n
6553 * This function does NOT do anything about the owners of the stores,\n
6554 * nor the contents thereof. It only handles the physical layout.\n
6556 static bool build_type16(void)
6560 STORE_GENERAL, STORE_ARMOURY, STORE_WEAPON, STORE_TEMPLE,
6561 STORE_ALCHEMIST, STORE_MAGIC, STORE_BLACK, STORE_BOOK,
6563 int n = sizeof stores / sizeof (int);
6564 int i, y, x, y1, x1, yval, xval;
6565 int town_hgt = rand_range(MIN_TOWN_HGT, MAX_TOWN_HGT);
6566 int town_wid = rand_range(MIN_TOWN_WID, MAX_TOWN_WID);
6567 bool prevent_bm = FALSE;
6569 /* Hack -- If already exist black market, prevent building */
6570 for (y = 0; (y < cur_hgt) && !prevent_bm; y++)
6572 for (x = 0; x < cur_wid; x++)
6574 if (cave[y][x].feat == FF_STORE)
6576 prevent_bm = (f_info[cave[y][x].feat].subtype == STORE_BLACK);
6581 for (i = 0; i < n; i++)
6583 if ((stores[i] == STORE_BLACK) && prevent_bm) stores[i] = stores[--n];
6585 if (!n) return FALSE;
6587 /* Allocate buildings array */
6588 C_MAKE(ugbldg, n, ugbldg_type);
6590 /* If cannot build stores, abort */
6591 if (!precalc_ugarcade(town_hgt, town_wid, n))
6593 /* Free buildings array */
6594 C_KILL(ugbldg, n, ugbldg_type);
6598 /* Find and reserve some space in the dungeon. Get center of room. */
6599 if (!find_space(&yval, &xval, town_hgt + 4, town_wid + 4))
6601 /* Free buildings array */
6602 C_KILL(ugbldg, n, ugbldg_type);
6606 /* Get top left corner */
6607 y1 = yval - (town_hgt / 2);
6608 x1 = xval - (town_wid / 2);
6610 /* Generate new room */
6611 generate_room_floor(
6612 y1 + town_hgt / 3, x1 + town_wid / 3,
6613 y1 + town_hgt * 2 / 3, x1 + town_wid * 2 / 3, FALSE);
6616 build_stores(y1, x1, stores, n);
6618 msg_print_wizard(CHEAT_DUNGEON, _("地下街を生成しました", "Underground arcade was generated."));
6620 /* Free buildings array */
6621 C_KILL(ugbldg, n, ugbldg_type);
6628 * @brief 与えられた部屋型IDに応じて部屋の生成処理分岐を行い結果を返す / Attempt to build a room of the given type at the given block
6630 * @note that we restrict the number of "crowded" rooms to reduce the chance of overflowing the monster list during level creation.
6631 * @return 部屋の精製に成功した場合 TRUE を返す。
6633 static bool room_build(int typ)
6638 /* Build an appropriate room */
6639 case ROOM_T_NORMAL: return build_type1();
6640 case ROOM_T_OVERLAP: return build_type2();
6641 case ROOM_T_CROSS: return build_type3();
6642 case ROOM_T_INNER_FEAT: return build_type4();
6643 case ROOM_T_NEST: return build_type5();
6644 case ROOM_T_PIT: return build_type6();
6645 case ROOM_T_LESSER_VAULT: return build_type7();
6646 case ROOM_T_GREATER_VAULT: return build_type8();
6647 case ROOM_T_FRACAVE: return build_type9();
6648 case ROOM_T_RANDOM_VAULT: return build_type10();
6649 case ROOM_T_OVAL: return build_type11();
6650 case ROOM_T_CRYPT: return build_type12();
6651 case ROOM_T_TRAP_PIT: return build_type13();
6652 case ROOM_T_TRAP: return build_type14();
6653 case ROOM_T_GLASS: return build_type15();
6654 case ROOM_T_ARCADE: return build_type16();
6662 * @brief 指定した部屋の生成確率を別の部屋に加算し、指定した部屋の生成率を0にする
6663 * @param dst 確率を移す先の部屋種ID
6664 * @param src 確率を与える元の部屋種ID
6666 #define MOVE_PLIST(dst, src) (prob_list[dst] += prob_list[src], prob_list[src] = 0)
6669 * @brief 部屋生成処理のメインルーチン(Sangbandを経由してOangbandからの実装を引用) / Generate rooms in dungeon. Build bigger rooms at first. [from SAngband (originally from OAngband)]
6670 * @return 部屋生成に成功した場合 TRUE を返す。
6672 bool generate_rooms(void)
6678 int prob_list[ROOM_T_MAX];
6679 int rooms_built = 0;
6680 int area_size = 100 * (cur_hgt*cur_wid) / (MAX_HGT*MAX_WID);
6681 int level_index = MIN(10, div_round(dun_level, 10));
6683 /* Number of each type of room on this level */
6684 s16b room_num[ROOM_T_MAX];
6686 /* Limit number of rooms */
6687 int dun_rooms = DUN_ROOMS_MAX * area_size / 100;
6689 /* Assume normal cave */
6690 room_info_type *room_info_ptr = room_info_normal;
6693 * Initialize probability list.
6695 for (i = 0; i < ROOM_T_MAX; i++)
6697 /* No rooms allowed above their minimum depth. */
6698 if (dun_level < room_info_ptr[i].min_level)
6704 prob_list[i] = room_info_ptr[i].prob[level_index];
6709 * XXX -- Various dungeon types and options.
6712 /*! @details ダンジョンにBEGINNER、CHAMELEON、SMALLESTいずれのフラグもなく、かつ「常に通常でない部屋を生成する」フラグがONならば、GRATER_VAULTのみを生成対象とする。 / Ironman sees only Greater Vaults */
6713 if (ironman_rooms && !((d_info[dungeon_type].flags1 & (DF1_BEGINNER | DF1_CHAMELEON | DF1_SMALLEST))))
6715 for (i = 0; i < ROOM_T_MAX; i++)
6717 if (i == ROOM_T_GREATER_VAULT) prob_list[i] = 1;
6718 else prob_list[i] = 0;
6722 /*! @details ダンジョンにNO_VAULTフラグがあるならば、LESSER_VAULT / GREATER_VAULT/ RANDOM_VAULTを除外 / Forbidden vaults */
6723 else if (d_info[dungeon_type].flags1 & DF1_NO_VAULT)
6725 prob_list[ROOM_T_LESSER_VAULT] = 0;
6726 prob_list[ROOM_T_GREATER_VAULT] = 0;
6727 prob_list[ROOM_T_RANDOM_VAULT] = 0;
6730 /*! @details ダンジョンにNO_CAVEフラグがある場合、FRACAVEの生成枠がNORMALに与えられる。CRIPT、OVALの生成枠がINNER_Fに与えられる。/ NO_CAVE dungeon (Castle)*/
6731 if (d_info[dungeon_type].flags1 & DF1_NO_CAVE)
6733 MOVE_PLIST(ROOM_T_NORMAL, ROOM_T_FRACAVE);
6734 MOVE_PLIST(ROOM_T_INNER_FEAT, ROOM_T_CRYPT);
6735 MOVE_PLIST(ROOM_T_INNER_FEAT, ROOM_T_OVAL);
6738 /*! @details ダンジョンにCAVEフラグがある場合、NORMALの生成枠がFRACAVEに与えられる。/ CAVE dungeon (Orc cave etc.) */
6739 else if (d_info[dungeon_type].flags1 & DF1_CAVE)
6741 MOVE_PLIST(ROOM_T_FRACAVE, ROOM_T_NORMAL);
6744 /*! @details ダンジョンの基本地形が最初から渓谷かアリーナ型の場合 FRACAVE は生成から除外。 / No caves when a (random) cavern exists: they look bad */
6745 else if (dun->cavern || dun->empty_level)
6747 prob_list[ROOM_T_FRACAVE] = 0;
6750 /*! @details ダンジョンに最初からGLASS_ROOMフラグがある場合、GLASS を生成から除外。/ Forbidden glass rooms */
6751 if (!(d_info[dungeon_type].flags1 & DF1_GLASS_ROOM))
6753 prob_list[ROOM_T_GLASS] = 0;
6756 /*! @details ARCADEは同フラグがダンジョンにないと生成されない。 / Forbidden glass rooms */
6757 if (!(d_info[dungeon_type].flags1 & DF1_ARCADE))
6759 prob_list[ROOM_T_ARCADE] = 0;
6763 * Initialize number of rooms,
6764 * And calcurate total probability.
6766 for (total_prob = 0, i = 0; i < ROOM_T_MAX; i++)
6769 total_prob += prob_list[i];
6773 * Prepare the number of rooms, of all types, we should build
6776 for (i = dun_rooms; i > 0; i--)
6779 int rand = randint0(total_prob);
6781 /* Get room_type randomly */
6782 for (room_type = 0; room_type < ROOM_T_MAX; room_type++)
6784 if (rand < prob_list[room_type]) break;
6785 else rand -= prob_list[room_type];
6789 if (room_type >= ROOM_T_MAX) room_type = ROOM_T_NORMAL;
6791 /* Increase the number of rooms of that type we should build. */
6792 room_num[room_type]++;
6798 case ROOM_T_LESSER_VAULT:
6799 case ROOM_T_TRAP_PIT:
6807 case ROOM_T_GREATER_VAULT:
6808 case ROOM_T_RANDOM_VAULT:
6817 * Build each type of room one by one until we cannot build any more.
6818 * [from SAngband (originally from OAngband)]
6822 /* Assume no remaining rooms */
6825 for (i = 0; i < ROOM_T_MAX; i++)
6827 /* What type of room are we building now? */
6828 int room_type = room_build_order[i];
6830 /* Go next if none available */
6831 if (!room_num[room_type]) continue;
6833 /* Use up one unit */
6834 room_num[room_type]--;
6836 /* Build the room. */
6837 if (room_build(room_type))
6839 /* Increase the room built count. */
6842 /* Mark as there was some remaining rooms */
6849 case ROOM_T_TRAP_PIT:
6851 /* Avoid too many monsters */
6854 room_num[ROOM_T_PIT] = 0;
6855 room_num[ROOM_T_NEST] = 0;
6856 room_num[ROOM_T_TRAP_PIT] = 0;
6862 /* Avoid double-town */
6863 room_num[ROOM_T_ARCADE] = 0;
6869 /* End loop if no room remain */
6873 /*! @details 部屋生成数が2未満の場合生成失敗を返す */
6874 if (rooms_built < 2)
6876 msg_format_wizard(CHEAT_DUNGEON, _("部屋数が2未満でした。生成を再試行します。", "Number of rooms was under 2. Retry."), rooms_built);
6880 msg_format_wizard(CHEAT_DUNGEON, _("このダンジョンの部屋数は %d です。", "Number of Rooms: %d"), rooms_built);