11 * This function creates a random vault that looks like a collection of bubbles.
12 * It works by getting a set of coordinates that represent the center of each
13 * bubble. The entire room is made by seeing which bubble center is closest. If
14 * two centers are equidistant then the square is a wall, otherwise it is a floor.
15 * The only exception is for squares really near a center, these are always floor.
16 * (It looks better than without this check.)
18 * Note: If two centers are on the same point then this algorithm will create a
19 * blank bubble filled with walls. - This is prevented from happening.
21 static void build_bubble_vault(POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
23 #define BUBBLENUM 10 /* number of bubbles */
25 /* array of center points of bubbles */
26 coord center[BUBBLENUM];
29 POSITION x = 0, y = 0;
30 u16b min1, min2, temp;
33 /* Offset from center to top left hand corner */
34 POSITION xhsize = xsize / 2;
35 POSITION yhsize = ysize / 2;
37 msg_print_wizard(CHEAT_DUNGEON, _("泡型ランダムVaultを生成しました。", "Bubble-shaped Vault."));
39 /* Allocate center of bubbles */
40 center[0].x = (byte)randint1(xsize - 3) + 1;
41 center[0].y = (byte)randint1(ysize - 3) + 1;
43 for (i = 1; i < BUBBLENUM; i++)
47 /* get center and check to see if it is unique */
52 x = randint1(xsize - 3) + 1;
53 y = randint1(ysize - 3) + 1;
55 for (j = 0; j < i; j++)
57 /* rough test to see if there is an overlap */
58 if ((x == center[j].x) && (y == center[j].y)) done = FALSE;
67 /* Top and bottom boundaries */
68 for (i = 0; i < xsize; i++)
70 int side_x = x0 - xhsize + i;
72 place_outer_noperm_bold(y0 - yhsize + 0, side_x);
73 current_floor_ptr->grid_array[y0 - yhsize + 0][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
74 place_outer_noperm_bold(y0 - yhsize + ysize - 1, side_x);
75 current_floor_ptr->grid_array[y0 - yhsize + ysize - 1][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
78 /* Left and right boundaries */
79 for (i = 1; i < ysize - 1; i++)
81 int side_y = y0 - yhsize + i;
83 place_outer_noperm_bold(side_y, x0 - xhsize + 0);
84 current_floor_ptr->grid_array[side_y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
85 place_outer_noperm_bold(side_y, x0 - xhsize + xsize - 1);
86 current_floor_ptr->grid_array[side_y][x0 - xhsize + xsize - 1].info |= (CAVE_ROOM | CAVE_ICKY);
89 /* Fill in middle with bubbles */
90 for (x = 1; x < xsize - 1; x++)
92 for (y = 1; y < ysize - 1; y++)
94 /* Get distances to two closest centers */
96 min1 = (u16b)distance(x, y, center[0].x, center[0].y);
97 min2 = (u16b)distance(x, y, center[1].x, center[1].y);
101 /* swap if in wrong order */
108 for (i = 2; i < BUBBLENUM; i++)
110 temp = (u16b)distance(x, y, center[i].x, center[i].y);
118 else if (temp < min2)
120 /* second smallest */
124 if (((min2 - min1) <= 2) && (!(min1 < 3)))
126 /* Boundary at midpoint+ not at inner region of bubble */
127 place_outer_noperm_bold(y0 - yhsize + y, x0 - xhsize + x);
131 /* middle of a bubble */
132 place_floor_bold(y0 - yhsize + y, x0 - xhsize + x);
135 /* clean up rest of flags */
136 current_floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= (CAVE_ROOM | CAVE_ICKY);
140 /* Try to add some random doors */
141 for (i = 0; i < 500; i++)
143 x = randint1(xsize - 3) - xhsize + x0 + 1;
144 y = randint1(ysize - 3) - yhsize + y0 + 1;
148 /* Fill with monsters and treasure, low difficulty */
149 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5));
152 /* Create a random vault that looks like a collection of overlapping rooms */
153 static void build_room_vault(POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
155 POSITION x1, x2, y1, y2, xhsize, yhsize;
158 /* get offset from center */
162 msg_print_wizard(CHEAT_DUNGEON, _("部屋型ランダムVaultを生成しました。", "Room Vault."));
164 /* fill area so don't get problems with arena levels */
165 for (x1 = 0; x1 < xsize; x1++)
167 POSITION x = x0 - xhsize + x1;
169 for (y1 = 0; y1 < ysize; y1++)
171 POSITION y = y0 - yhsize + y1;
173 place_extra_bold(y, x);
174 current_floor_ptr->grid_array[y][x].info &= (~CAVE_ICKY);
178 /* add ten random rooms */
179 for (i = 0; i < 10; i++)
181 x1 = randint1(xhsize) * 2 + x0 - xhsize;
182 x2 = randint1(xhsize) * 2 + x0 - xhsize;
183 y1 = randint1(yhsize) * 2 + y0 - yhsize;
184 y2 = randint1(yhsize) * 2 + y0 - yhsize;
185 build_room(x1, x2, y1, y2);
188 /* Add some random doors */
189 for (i = 0; i < 500; i++)
191 x1 = randint1(xsize - 3) - xhsize + x0 + 1;
192 y1 = randint1(ysize - 3) - yhsize + y0 + 1;
196 /* Fill with monsters and treasure, high difficulty */
197 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5);
201 /* Create a random vault out of a fractal current_floor_ptr->grid_array */
202 static void build_cave_vault(POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
204 int grd, roug, cutoff;
205 bool done, light, room;
206 POSITION xhsize, yhsize, xsize, ysize, x, y;
208 /* round to make sizes even */
214 msg_print_wizard(CHEAT_DUNGEON, _("洞穴ランダムVaultを生成しました。", "Cave Vault."));
216 light = done = FALSE;
221 /* testing values for these parameters feel free to adjust */
222 grd = 1 << randint0(4);
224 /* want average of about 16 */
225 roug = randint1(8) * randint1(4);
228 cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
229 randint1(xsize / 4) + randint1(ysize / 4);
232 generate_hmap(y0, x0, xsize, ysize, grd, roug, cutoff);
234 /* Convert to normal format+ clean up */
235 done = generate_fracave(y0, x0, xsize, ysize, cutoff, light, room);
238 /* Set icky flag because is a vault */
239 for (x = 0; x <= xsize; x++)
241 for (y = 0; y <= ysize; y++)
243 current_floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
247 /* Fill with monsters and treasure, low difficulty */
248 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
254 * @brief Vault地形を回転、上下左右反転するための座標変換を返す / coordinate translation code
255 * @param x 変換したい点のX座標参照ポインタ
256 * @param y 変換したい点のY座標参照ポインタ
257 * @param xoffset Vault生成時の基準X座標
258 * @param yoffset Vault生成時の基準Y座標
259 * @param transno 処理ID
262 static void coord_trans(POSITION *x, POSITION *y, POSITION xoffset, POSITION yoffset, int transno)
268 * transno specifies what transformation is required. (0-7)
269 * The lower two bits indicate by how much the vault is rotated,
270 * and the upper bit indicates a reflection.
271 * This is done by using rotation matrices... however since
272 * these are mostly zeros for rotations by 90 degrees this can
273 * be expressed simply in terms of swapping and inverting the
274 * x and y coordinates.
276 for (i = 0; i < transno % 4; i++)
278 /* rotate by 90 degrees */
286 /* Reflect depending on status of 3rd bit. */
290 /* Add offsets so vault stays in the first quadrant */
297 * @brief Vaultをフロアに配置する / Hack -- fill in "vault" rooms
298 * @param yval 生成基準Y座標
299 * @param xval 生成基準X座標
300 * @param ymax VaultのYサイズ
301 * @param xmax VaultのXサイズ
302 * @param data Vaultのデータ文字列
303 * @param xoffset 変換基準X座標
304 * @param yoffset 変換基準Y座標
305 * @param transno 変換ID
308 static void build_vault(POSITION yval, POSITION xval, POSITION ymax, POSITION xmax, concptr data,
309 POSITION xoffset, POSITION yoffset, int transno)
311 POSITION dx, dy, x, y, i, j;
315 /* Place dungeon features and objects */
316 for (t = data, dy = 0; dy < ymax; dy++)
318 for (dx = 0; dx < xmax; dx++, t++)
320 /* prevent loop counter from being overwritten */
325 coord_trans(&i, &j, xoffset, yoffset, transno);
327 /* Extract the location */
328 if (transno % 2 == 0)
331 x = xval - (xmax / 2) + i;
332 y = yval - (ymax / 2) + j;
337 x = xval - (ymax / 2) + i;
338 y = yval - (xmax / 2) + j;
341 /* Hack -- skip "non-grids" */
342 if (*t == ' ') continue;
343 g_ptr = ¤t_floor_ptr->grid_array[y][x];
345 /* Lay down a floor */
346 place_floor_grid(g_ptr);
348 /* Remove any mimic */
351 /* Part of a vault */
352 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
354 /* Analyze the grid */
357 /* Granite wall (outer) */
359 place_outer_noperm_grid(g_ptr);
362 /* Granite wall (inner) */
364 place_inner_grid(g_ptr);
367 /* Glass wall (inner) */
369 place_inner_grid(g_ptr);
370 g_ptr->feat = feat_glass_wall;
373 /* Permanent wall (inner) */
375 place_inner_perm_grid(g_ptr);
378 /* Permanent glass wall (inner) */
380 place_inner_perm_grid(g_ptr);
381 g_ptr->feat = feat_permanent_glass_wall;
386 if (randint0(100) < 75)
388 place_object(y, x, 0L);
398 place_object(y, x, 0L);
403 g_ptr->feat = feat_tree;
408 place_secret_door(y, x, DOOR_DEFAULT);
411 /* Secret glass doors */
413 place_secret_door(y, x, DOOR_GLASS_DOOR);
414 if (is_closed_door(g_ptr->feat)) g_ptr->mimic = feat_glass_wall;
419 place_secret_door(y, x, DOOR_CURTAIN);
427 /* Black market in a dungeon */
429 set_cave_feat(y, x, feat_black_market);
430 store_init(NO_TOWN, STORE_BLACK);
435 set_cave_feat(y, x, feat_pattern_start);
439 set_cave_feat(y, x, feat_pattern_1);
443 set_cave_feat(y, x, feat_pattern_2);
447 set_cave_feat(y, x, feat_pattern_3);
451 set_cave_feat(y, x, feat_pattern_4);
455 set_cave_feat(y, x, feat_pattern_end);
459 set_cave_feat(y, x, feat_pattern_exit);
463 /* Reward for Pattern walk */
464 current_floor_ptr->object_level = current_floor_ptr->base_level + 12;
465 place_object(y, x, AM_GOOD | AM_GREAT);
466 current_floor_ptr->object_level = current_floor_ptr->base_level;
470 set_cave_feat(y, x, feat_shallow_water);
474 set_cave_feat(y, x, feat_deep_water);
478 set_cave_feat(y, x, feat_shallow_lava);
482 set_cave_feat(y, x, feat_deep_lava);
486 set_cave_feat(y, x, feat_shallow_acid_puddle);
490 set_cave_feat(y, x, feat_deep_acid_puddle);
494 set_cave_feat(y, x, feat_shallow_poisonous_puddle);
498 set_cave_feat(y, x, feat_deep_poisonous_puddle);
502 set_cave_feat(y, x, feat_cold_zone);
506 set_cave_feat(y, x, feat_heavy_cold_zone);
510 set_cave_feat(y, x, feat_electrical_zone);
514 set_cave_feat(y, x, feat_heavy_electrical_zone);
522 /* Place dungeon monsters and objects */
523 for (t = data, dy = 0; dy < ymax; dy++)
525 for (dx = 0; dx < xmax; dx++, t++)
527 /* prevent loop counter from being overwritten */
532 coord_trans(&i, &j, xoffset, yoffset, transno);
534 /* Extract the location */
535 if (transno % 2 == 0)
538 x = xval - (xmax / 2) + i;
539 y = yval - (ymax / 2) + j;
544 x = xval - (ymax / 2) + i;
545 y = yval - (xmax / 2) + j;
548 /* Hack -- skip "non-grids" */
549 if (*t == ' ') continue;
551 /* Analyze the symbol */
556 current_floor_ptr->monster_level = current_floor_ptr->base_level + 5;
557 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
558 current_floor_ptr->monster_level = current_floor_ptr->base_level;
565 current_floor_ptr->monster_level = current_floor_ptr->base_level + 11;
566 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
567 current_floor_ptr->monster_level = current_floor_ptr->base_level;
571 /* Meaner monster, plus treasure */
574 current_floor_ptr->monster_level = current_floor_ptr->base_level + 9;
575 place_monster(y, x, PM_ALLOW_SLEEP);
576 current_floor_ptr->monster_level = current_floor_ptr->base_level;
577 current_floor_ptr->object_level = current_floor_ptr->base_level + 7;
578 place_object(y, x, AM_GOOD);
579 current_floor_ptr->object_level = current_floor_ptr->base_level;
583 /* Nasty monster and treasure */
586 current_floor_ptr->monster_level = current_floor_ptr->base_level + 40;
587 place_monster(y, x, PM_ALLOW_SLEEP);
588 current_floor_ptr->monster_level = current_floor_ptr->base_level;
589 current_floor_ptr->object_level = current_floor_ptr->base_level + 20;
590 place_object(y, x, AM_GOOD | AM_GREAT);
591 current_floor_ptr->object_level = current_floor_ptr->base_level;
595 /* Monster and/or object */
598 if (randint0(100) < 50)
600 current_floor_ptr->monster_level = current_floor_ptr->base_level + 3;
601 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
602 current_floor_ptr->monster_level = current_floor_ptr->base_level;
604 if (randint0(100) < 50)
606 current_floor_ptr->object_level = current_floor_ptr->base_level + 7;
607 place_object(y, x, 0L);
608 current_floor_ptr->object_level = current_floor_ptr->base_level;
621 * @brief タイプ7の部屋…v_info.txtより小型vaultを生成する / Type 7 -- simple vaults (see "v_info.txt")
624 bool build_type7(void)
626 vault_type *v_ptr = NULL;
630 POSITION xoffset, yoffset;
633 /* Pick a lesser vault */
634 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
636 /* Access a random vault record */
637 v_ptr = &v_info[randint0(max_v_idx)];
639 /* Accept the first lesser vault */
640 if (v_ptr->typ == 7) break;
643 /* No lesser vault found */
644 if (dummy >= SAFE_MAX_ATTEMPTS)
646 msg_print_wizard(CHEAT_DUNGEON, _("小型固定Vaultを配置できませんでした。", "Could not place lesser vault."));
650 /* pick type of transformation (0-7) */
651 transno = randint0(8);
653 /* calculate offsets */
657 /* Some huge vault cannot be ratated to fit in the dungeon */
658 if (x + 2 > current_floor_ptr->height - 2)
660 /* Forbid 90 or 270 degree ratation */
664 coord_trans(&x, &y, 0, 0, transno);
684 /* Find and reserve some space in the dungeon. Get center of room. */
685 if (!find_space(&yval, &xval, abs(y), abs(x))) return FALSE;
691 msg_format_wizard(CHEAT_DUNGEON, _("小型Vault(%s)を生成しました。", "Lesser vault (%s)."), v_name + v_ptr->name);
693 /* Hack -- Build the vault */
694 build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
695 v_text + v_ptr->text, xoffset, yoffset, transno);
701 * @brief タイプ8の部屋…v_info.txtより大型vaultを生成する / Type 8 -- greater vaults (see "v_info.txt")
704 bool build_type8(void)
711 POSITION xoffset, yoffset;
713 /* Pick a greater vault */
714 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
716 /* Access a random vault record */
717 v_ptr = &v_info[randint0(max_v_idx)];
719 /* Accept the first greater vault */
720 if (v_ptr->typ == 8) break;
723 /* No greater vault found */
724 if (dummy >= SAFE_MAX_ATTEMPTS)
726 msg_print_wizard(CHEAT_DUNGEON, _("大型固定Vaultを配置できませんでした。", "Could not place greater vault."));
730 /* pick type of transformation (0-7) */
731 transno = randint0(8);
733 /* calculate offsets */
737 /* Some huge vault cannot be ratated to fit in the dungeon */
738 if (x + 2 > current_floor_ptr->height - 2)
740 /* Forbid 90 or 270 degree ratation */
744 coord_trans(&x, &y, 0, 0, transno);
765 * Try to allocate space for room. If fails, exit
767 * Hack -- Prepare a bit larger space (+2, +2) to
768 * prevent generation of vaults with no-entrance.
770 /* Find and reserve some space in the dungeon. Get center of room. */
771 if (!find_space(&yval, &xval, (POSITION)(abs(y) + 2), (POSITION)(abs(x) + 2))) return FALSE;
774 v_ptr = &v_info[76 + randint1(3)];
777 msg_format_wizard(CHEAT_DUNGEON, _("大型固定Vault(%s)を生成しました。", "Greater vault (%s)."), v_name + v_ptr->name);
779 /* Hack -- Build the vault */
780 build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
781 v_text + v_ptr->text, xoffset, yoffset, transno);
788 * Build target vault.
789 * This is made by two concentric "crypts" with perpendicular
790 * walls creating the cross-hairs.
792 static void build_target_vault(POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
796 /* Make a random metric */
797 POSITION h1, h2, h3, h4;
798 h1 = randint1(32) - 16;
801 h4 = randint1(32) - 16;
803 msg_print_wizard(CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Target Vault"));
805 /* work out outer radius */
816 for (x = x0 - rad; x <= x0 + rad; x++)
818 for (y = y0 - rad; y <= y0 + rad; y++)
820 /* clear room flag */
821 current_floor_ptr->grid_array[y][x].info &= ~(CAVE_ROOM);
823 /* Vault - so is "icky" */
824 current_floor_ptr->grid_array[y][x].info |= CAVE_ICKY;
826 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1)
828 /* inside- so is floor */
829 place_floor_bold(y, x);
833 /* make granite outside so arena works */
834 place_extra_bold(y, x);
837 /* proper boundary for arena */
838 if (((y + rad) == y0) || ((y - rad) == y0) ||
839 ((x + rad) == x0) || ((x - rad) == x0))
841 place_extra_bold(y, x);
846 /* Find visible outer walls and set to be FEAT_OUTER */
847 add_outer_wall(x0, y0, FALSE, x0 - rad - 1, y0 - rad - 1,
848 x0 + rad + 1, y0 + rad + 1);
851 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++)
853 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++)
855 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2)
857 /* Make an internal wall */
858 place_inner_bold(y, x);
863 /* Add perpendicular walls */
864 for (x = x0 - rad; x <= x0 + rad; x++)
866 place_inner_bold(y0, x);
869 for (y = y0 - rad; y <= y0 + rad; y++)
871 place_inner_bold(y, x0);
874 /* Make inner vault */
875 for (y = y0 - 1; y <= y0 + 1; y++)
877 place_inner_bold(y, x0 - 1);
878 place_inner_bold(y, x0 + 1);
880 for (x = x0 - 1; x <= x0 + 1; x++)
882 place_inner_bold(y0 - 1, x);
883 place_inner_bold(y0 + 1, x);
886 place_floor_bold(y0, x0);
889 /* Add doors to vault */
890 /* get two distances so can place doors relative to centre */
891 x = (rad - 2) / 4 + 1;
894 add_door(x0 + x, y0);
895 add_door(x0 + y, y0);
896 add_door(x0 - x, y0);
897 add_door(x0 - y, y0);
898 add_door(x0, y0 + x);
899 add_door(x0, y0 + y);
900 add_door(x0, y0 - x);
901 add_door(x0, y0 - y);
903 /* Fill with stuff - medium difficulty */
904 fill_treasure(x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
908 #ifdef ALLOW_CAVERNS_AND_LAKES
910 * This routine uses a modified version of the lake code to make a
911 * distribution of some terrain type over the vault. This type
912 * depends on the dungeon depth.
914 * Miniture rooms are then scattered across the vault.
916 static void build_elemental_vault(POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
921 POSITION xsize, ysize, xhsize, yhsize, x, y;
925 msg_print_wizard(CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
927 /* round to make sizes even */
933 if (current_floor_ptr->dun_level < 25)
935 /* Earth vault (Rubble) */
936 type = LAKE_T_EARTH_VAULT;
938 else if (current_floor_ptr->dun_level < 50)
940 /* Air vault (Trees) */
941 type = LAKE_T_AIR_VAULT;
943 else if (current_floor_ptr->dun_level < 75)
945 /* Water vault (shallow water) */
946 type = LAKE_T_WATER_VAULT;
950 /* Fire vault (shallow lava) */
951 type = LAKE_T_FIRE_VAULT;
956 /* testing values for these parameters: feel free to adjust */
957 grd = 1 << (randint0(3));
959 /* want average of about 16 */
960 roug = randint1(8) * randint1(4);
962 /* Make up size of various componants */
966 /* Deep water/lava */
967 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
969 /* Shallow boundary */
973 generate_hmap(y0, x0, xsize, ysize, grd, roug, c3);
975 /* Convert to normal format+ clean up */
976 done = generate_lake(y0, x0, xsize, ysize, c1, c2, c3, type);
979 /* Set icky flag because is a vault */
980 for (x = 0; x <= xsize; x++)
982 for (y = 0; y <= ysize; y++)
984 current_floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
988 /* make a few rooms in the vault */
989 for (i = 1; i <= (xsize * ysize) / 50; i++)
991 build_small_room(x0 + randint0(xsize - 4) - xsize / 2 + 2,
992 y0 + randint0(ysize - 4) - ysize / 2 + 2);
995 /* Fill with monsters and treasure, low difficulty */
996 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 1,
997 y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
999 #endif /* ALLOW_CAVERNS_AND_LAKES */
1002 /* Build a "mini" checkerboard vault
1004 * This is done by making a permanent wall maze and setting
1005 * the diagonal sqaures of the checker board to be granite.
1006 * The vault has two entrances on opposite sides to guarantee
1007 * a way to get in even if the vault abuts a side of the dungeon.
1009 static void build_mini_c_vault(POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1012 POSITION y1, x1, y2, x2, y, x, total;
1013 int m, n, num_vertices;
1016 msg_print_wizard(CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
1018 /* Pick a random room size */
1028 /* generate the room */
1029 for (x = x1 - 2; x <= x2 + 2; x++)
1031 if (!in_bounds(y1 - 2, x)) break;
1033 current_floor_ptr->grid_array[y1 - 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1035 place_outer_noperm_bold(y1 - 2, x);
1038 for (x = x1 - 2; x <= x2 + 2; x++)
1040 if (!in_bounds(y2 + 2, x)) break;
1042 current_floor_ptr->grid_array[y2 + 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1044 place_outer_noperm_bold(y2 + 2, x);
1047 for (y = y1 - 2; y <= y2 + 2; y++)
1049 if (!in_bounds(y, x1 - 2)) break;
1051 current_floor_ptr->grid_array[y][x1 - 2].info |= (CAVE_ROOM | CAVE_ICKY);
1053 place_outer_noperm_bold(y, x1 - 2);
1056 for (y = y1 - 2; y <= y2 + 2; y++)
1058 if (!in_bounds(y, x2 + 2)) break;
1060 current_floor_ptr->grid_array[y][x2 + 2].info |= (CAVE_ROOM | CAVE_ICKY);
1062 place_outer_noperm_bold(y, x2 + 2);
1065 for (y = y1 - 1; y <= y2 + 1; y++)
1067 for (x = x1 - 1; x <= x2 + 1; x++)
1069 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1071 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
1073 /* Permanent walls */
1074 place_inner_perm_grid(g_ptr);
1079 /* dimensions of vertex array */
1082 num_vertices = m * n;
1084 /* initialize array of visited vertices */
1085 C_MAKE(visited, num_vertices, int);
1087 /* traverse the graph to create a spannng tree, pick a random root */
1088 r_visit(y1, x1, y2, x2, randint0(num_vertices), 0, visited);
1090 /* Make it look like a checker board vault */
1091 for (x = x1; x <= x2; x++)
1093 for (y = y1; y <= y2; y++)
1095 total = x - x1 + y - y1;
1096 /* If total is odd- and is a floor then make a wall */
1097 if ((total % 2 == 1) && is_floor_bold(y, x))
1099 place_inner_bold(y, x);
1104 /* Make a couple of entrances */
1107 /* left and right */
1108 y = randint1(dy) + dy / 2;
1109 place_inner_bold(y1 + y, x1 - 1);
1110 place_inner_bold(y1 + y, x2 + 1);
1114 /* top and bottom */
1115 x = randint1(dx) + dx / 2;
1116 place_inner_bold(y1 - 1, x1 + x);
1117 place_inner_bold(y2 + 1, x1 + x);
1120 /* Fill with monsters and treasure, highest difficulty */
1121 fill_treasure(x1, x2, y1, y2, 10);
1123 C_KILL(visited, num_vertices, int);
1126 /* Build a castle */
1127 /* Driver routine: clear the region and call the recursive
1130 *This makes a vault that looks like a castle/ city in the dungeon.
1132 static void build_castle_vault(POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1135 POSITION y1, x1, y2, x2;
1138 /* Pick a random room size */
1147 msg_print_wizard(CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
1149 /* generate the room */
1150 for (y = y1 - 1; y <= y2 + 1; y++)
1152 for (x = x1 - 1; x <= x2 + 1; x++)
1154 current_floor_ptr->grid_array[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
1155 /* Make everything a floor */
1156 place_floor_bold(y, x);
1160 /* Make the castle */
1161 build_recursive_room(x1, y1, x2, y2, randint1(5));
1163 /* Fill with monsters and treasure, low difficulty */
1164 fill_treasure(x1, x2, y1, y2, randint1(3));
1170 * @brief タイプ10の部屋…ランダム生成vault / Type 10 -- Random vaults
1173 bool build_type10(void)
1175 POSITION y0, x0, xsize, ysize, vtype;
1177 /* big enough to look good, small enough to be fairly common. */
1178 xsize = randint1(22) + 22;
1179 ysize = randint1(11) + 11;
1181 /* Find and reserve some space in the dungeon. Get center of room. */
1182 if (!find_space(&y0, &x0, ysize + 1, xsize + 1)) return FALSE;
1184 /* Select type of vault */
1185 #ifdef ALLOW_CAVERNS_AND_LAKES
1188 vtype = randint1(15);
1189 } while ((d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) &&
1190 ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
1191 #else /* ALLOW_CAVERNS_AND_LAKES */
1194 vtype = randint1(7);
1195 } while ((d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) &&
1196 ((vtype == 1) || (vtype == 3)));
1197 #endif /* ALLOW_CAVERNS_AND_LAKES */
1201 /* Build an appropriate room */
1202 case 1: case 9: build_bubble_vault(x0, y0, xsize, ysize); break;
1203 case 2: case 10: build_room_vault(x0, y0, xsize, ysize); break;
1204 case 3: case 11: build_cave_vault(x0, y0, xsize, ysize); break;
1205 case 4: case 12: build_maze_vault(x0, y0, xsize, ysize, TRUE); break;
1206 case 5: case 13: build_mini_c_vault(x0, y0, xsize, ysize); break;
1207 case 6: case 14: build_castle_vault(x0, y0, xsize, ysize); break;
1208 case 7: case 15: build_target_vault(x0, y0, xsize, ysize); break;
1209 #ifdef ALLOW_CAVERNS_AND_LAKES
1210 case 8: build_elemental_vault(x0, y0, xsize, ysize); break;
1211 #endif /* ALLOW_CAVERNS_AND_LAKES */
1212 /* I know how to add a few more... give me some time. */
1213 default: return FALSE;
1221 * @brief タイプ17の部屋…v_info.txtより固定特殊部屋を生成する / Type 17 -- fixed special room (see "v_info.txt")
1224 bool build_type17(void)
1226 vault_type *v_ptr = NULL;
1229 POSITION xval, yval;
1230 POSITION xoffset, yoffset;
1233 /* Pick a lesser vault */
1234 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
1236 /* Access a random vault record */
1237 v_ptr = &v_info[randint0(max_v_idx)];
1239 /* Accept the special fix room. */
1240 if (v_ptr->typ == 17) break;
1243 /* No lesser vault found */
1244 if (dummy >= SAFE_MAX_ATTEMPTS)
1246 msg_print_wizard(CHEAT_DUNGEON, _("固定特殊部屋を配置できませんでした。", "Could not place fixed special room."));
1250 /* pick type of transformation (0-7) */
1251 transno = randint0(8);
1253 /* calculate offsets */
1257 /* Some huge vault cannot be ratated to fit in the dungeon */
1258 if (x + 2 > current_floor_ptr->height - 2)
1260 /* Forbid 90 or 270 degree ratation */
1264 coord_trans(&x, &y, 0, 0, transno);
1284 /* Find and reserve some space in the dungeon. Get center of room. */
1285 if (!find_space(&yval, &xval, abs(y), abs(x))) return FALSE;
1291 msg_format_wizard(CHEAT_DUNGEON, _("特殊固定部屋(%s)を生成しました。", "Special Fixed Room (%s)."), v_name + v_ptr->name);
1293 /* Hack -- Build the vault */
1294 build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
1295 v_text + v_ptr->text, xoffset, yoffset, transno);