7 #include "room/rooms-vault.h"
8 #include "dungeon/dungeon-flag-types.h"
9 #include "floor/cave.h"
10 #include "floor/floor-generator-util.h"
11 #include "floor/floor-generator.h"
12 #include "floor/floor-town.h"
13 #include "floor/geometry.h"
14 #include "floor/wild.h"
15 #include "game-option/cheat-types.h"
16 #include "grid/door.h"
17 #include "grid/feature.h"
18 #include "grid/grid.h"
19 #include "grid/object-placer.h"
20 #include "grid/trap.h"
21 #include "monster-floor/monster-generator.h"
22 #include "monster-floor/place-monster-types.h"
23 #include "object-enchant/item-apply-magic.h"
24 #include "room/cave-filler.h"
25 #include "room/door-definition.h"
26 #include "room/lake-types.h"
27 #include "room/rooms-builder.h"
28 #include "room/rooms-maze-vault.h"
29 #include "room/space-finder.h"
30 #include "room/treasure-deployment.h"
31 #include "store/store-util.h"
32 #include "store/store.h"
33 #include "system/dungeon-data-definition.h"
34 #include "system/dungeon-info.h"
35 #include "system/floor-type-definition.h"
36 #include "system/grid-type-definition.h"
37 #include "system/player-type-definition.h"
38 #include "util/probability-table.h"
39 #include "wizard/wizard-messages.h"
42 * The vault generation arrays
44 std::vector<vault_type> vaults_info;
47 * This function creates a random vault that looks like a collection of bubbles.
48 * It works by getting a set of coordinates that represent the center of each
49 * bubble. The entire room is made by seeing which bubble center is closest. If
50 * two centers are equidistant then the square is a wall, otherwise it is a floor.
51 * The only exception is for squares really near a center, these are always floor.
52 * (It looks better than without this check.)
54 * Note: If two centers are on the same point then this algorithm will create a
55 * blank bubble filled with walls. - This is prevented from happening.
57 static void build_bubble_vault(PlayerType *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
59 #define BUBBLENUM 10 /* number of bubbles */
61 /* array of center points of bubbles */
62 coord center[BUBBLENUM];
65 POSITION x = 0, y = 0;
66 uint16_t min1, min2, temp;
69 /* Offset from center to top left hand corner */
70 POSITION xhsize = xsize / 2;
71 POSITION yhsize = ysize / 2;
73 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("泡型ランダムVaultを生成しました。", "Bubble-shaped Vault."));
75 /* Allocate center of bubbles */
76 center[0].x = (byte)randint1(xsize - 3) + 1;
77 center[0].y = (byte)randint1(ysize - 3) + 1;
79 for (i = 1; i < BUBBLENUM; i++) {
82 /* get center and check to see if it is unique */
86 x = randint1(xsize - 3) + 1;
87 y = randint1(ysize - 3) + 1;
89 for (j = 0; j < i; j++) {
90 /* rough test to see if there is an overlap */
91 if ((x == center[j].x) && (y == center[j].y)) {
101 /* Top and bottom boundaries */
102 auto *floor_ptr = player_ptr->current_floor_ptr;
103 for (i = 0; i < xsize; i++) {
104 int side_x = x0 - xhsize + i;
106 place_bold(player_ptr, y0 - yhsize + 0, side_x, GB_OUTER_NOPERM);
107 floor_ptr->grid_array[y0 - yhsize + 0][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
108 place_bold(player_ptr, y0 - yhsize + ysize - 1, side_x, GB_OUTER_NOPERM);
109 floor_ptr->grid_array[y0 - yhsize + ysize - 1][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
112 /* Left and right boundaries */
113 for (i = 1; i < ysize - 1; i++) {
114 int side_y = y0 - yhsize + i;
116 place_bold(player_ptr, side_y, x0 - xhsize + 0, GB_OUTER_NOPERM);
117 floor_ptr->grid_array[side_y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
118 place_bold(player_ptr, side_y, x0 - xhsize + xsize - 1, GB_OUTER_NOPERM);
119 floor_ptr->grid_array[side_y][x0 - xhsize + xsize - 1].info |= (CAVE_ROOM | CAVE_ICKY);
122 /* Fill in middle with bubbles */
123 for (x = 1; x < xsize - 1; x++) {
124 for (y = 1; y < ysize - 1; y++) {
125 /* Get distances to two closest centers */
127 min1 = (uint16_t)distance(x, y, center[0].x, center[0].y);
128 min2 = (uint16_t)distance(x, y, center[1].x, center[1].y);
131 /* swap if in wrong order */
138 for (i = 2; i < BUBBLENUM; i++) {
139 temp = (uint16_t)distance(x, y, center[i].x, center[i].y);
145 } else if (temp < min2) {
146 /* second smallest */
150 if (((min2 - min1) <= 2) && (!(min1 < 3))) {
151 /* Boundary at midpoint+ not at inner region of bubble */
152 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_OUTER_NOPERM);
154 /* middle of a bubble */
155 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_FLOOR);
158 /* clean up rest of flags */
159 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= (CAVE_ROOM | CAVE_ICKY);
163 /* Try to add some random doors */
164 for (i = 0; i < 500; i++) {
165 x = randint1(xsize - 3) - xhsize + x0 + 1;
166 y = randint1(ysize - 3) - yhsize + y0 + 1;
167 add_door(player_ptr, x, y);
170 /* Fill with monsters and treasure, low difficulty */
171 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5));
174 /* Create a random vault that looks like a collection of overlapping rooms */
175 static void build_room_vault(PlayerType *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
177 POSITION x1, x2, y1, y2, xhsize, yhsize;
180 /* get offset from center */
184 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("部屋型ランダムVaultを生成しました。", "Room Vault."));
186 /* fill area so don't get problems with on_defeat_arena_monster levels */
187 auto *floor_ptr = player_ptr->current_floor_ptr;
188 for (x1 = 0; x1 < xsize; x1++) {
189 POSITION x = x0 - xhsize + x1;
191 for (y1 = 0; y1 < ysize; y1++) {
192 POSITION y = y0 - yhsize + y1;
194 place_bold(player_ptr, y, x, GB_EXTRA);
195 floor_ptr->grid_array[y][x].info &= (~CAVE_ICKY);
199 /* add ten random rooms */
200 for (i = 0; i < 10; i++) {
201 x1 = randint1(xhsize) * 2 + x0 - xhsize;
202 x2 = randint1(xhsize) * 2 + x0 - xhsize;
203 y1 = randint1(yhsize) * 2 + y0 - yhsize;
204 y2 = randint1(yhsize) * 2 + y0 - yhsize;
205 build_room(player_ptr, x1, x2, y1, y2);
208 /* Add some random doors */
209 for (i = 0; i < 500; i++) {
210 x1 = randint1(xsize - 3) - xhsize + x0 + 1;
211 y1 = randint1(ysize - 3) - yhsize + y0 + 1;
212 add_door(player_ptr, x1, y1);
215 /* Fill with monsters and treasure, high difficulty */
216 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5);
219 /* Create a random vault out of a fractal grid */
220 static void build_cave_vault(PlayerType *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
222 int grd, roug, cutoff;
223 bool done, light, room;
224 POSITION xhsize, yhsize, xsize, ysize, x, y;
226 /* round to make sizes even */
232 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("洞穴ランダムVaultを生成しました。", "Cave Vault."));
234 light = done = false;
237 auto *floor_ptr = player_ptr->current_floor_ptr;
239 /* testing values for these parameters feel free to adjust */
240 grd = 1 << randint0(4);
242 /* want average of about 16 */
243 roug = randint1(8) * randint1(4);
246 cutoff = randint1(xsize / 4) + randint1(ysize / 4) + randint1(xsize / 4) + randint1(ysize / 4);
249 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, cutoff);
251 /* Convert to normal format+ clean up */
252 done = generate_fracave(player_ptr, y0, x0, xsize, ysize, cutoff, light, room);
255 /* Set icky flag because is a vault */
256 for (x = 0; x <= xsize; x++) {
257 for (y = 0; y <= ysize; y++) {
258 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
262 /* Fill with monsters and treasure, low difficulty */
263 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
267 * @brief Vault地形を回転、上下左右反転するための座標変換を返す / coordinate translation code
268 * @param x 変換したい点のX座標参照ポインタ
269 * @param y 変換したい点のY座標参照ポインタ
270 * @param xoffset Vault生成時の基準X座標
271 * @param yoffset Vault生成時の基準Y座標
272 * @param transno 処理ID
274 static void coord_trans(POSITION *x, POSITION *y, POSITION xoffset, POSITION yoffset, int transno)
280 * transno specifies what transformation is required. (0-7)
281 * The lower two bits indicate by how much the vault is rotated,
282 * and the upper bit indicates a reflection.
283 * This is done by using rotation matrices... however since
284 * these are mostly zeros for rotations by 90 degrees this can
285 * be expressed simply in terms of swapping and inverting the
286 * x and y coordinates.
288 for (i = 0; i < transno % 4; i++) {
289 /* rotate by 90 degrees */
296 /* Reflect depending on status of 3rd bit. */
300 /* Add offsets so vault stays in the first quadrant */
306 * @brief Vaultをフロアに配置する / Hack -- fill in "vault" rooms
307 * @param player_ptr プレイヤーへの参照ポインタ
308 * @param yval 生成基準Y座標
309 * @param xval 生成基準X座標
310 * @param ymax VaultのYサイズ
311 * @param xmax VaultのXサイズ
312 * @param data Vaultのデータ文字列
313 * @param xoffset 変換基準X座標
314 * @param yoffset 変換基準Y座標
315 * @param transno 変換ID
317 static void build_vault(
318 PlayerType *player_ptr, POSITION yval, POSITION xval, POSITION ymax, POSITION xmax, concptr data, POSITION xoffset, POSITION yoffset, int transno)
320 POSITION dx, dy, x, y, i, j;
324 /* Place dungeon features and objects */
325 auto *floor_ptr = player_ptr->current_floor_ptr;
326 for (t = data, dy = 0; dy < ymax; dy++) {
327 for (dx = 0; dx < xmax; dx++, t++) {
328 /* prevent loop counter from being overwritten */
333 coord_trans(&i, &j, xoffset, yoffset, transno);
335 if (transno % 2 == 0) {
337 x = xval - (xmax / 2) + i;
338 y = yval - (ymax / 2) + j;
341 x = xval - (ymax / 2) + i;
342 y = yval - (xmax / 2) + j;
345 /* Hack -- skip "non-grids" */
349 g_ptr = &floor_ptr->grid_array[y][x];
351 /* Lay down a floor */
352 place_grid(player_ptr, g_ptr, GB_FLOOR);
354 /* Remove any mimic */
357 /* Part of a vault */
358 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
360 /* Analyze the grid */
362 /* Granite wall (outer) */
364 place_grid(player_ptr, g_ptr, GB_OUTER_NOPERM);
367 /* Granite wall (inner) */
369 place_grid(player_ptr, g_ptr, GB_INNER);
372 /* Glass wall (inner) */
374 place_grid(player_ptr, g_ptr, GB_INNER);
375 g_ptr->feat = feat_glass_wall;
378 /* Permanent wall (inner) */
380 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
383 /* Permanent glass wall (inner) */
385 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
386 g_ptr->feat = feat_permanent_glass_wall;
391 if (randint0(100) < 75) {
392 place_object(player_ptr, y, x, 0L);
394 place_trap(player_ptr, y, x);
400 place_object(player_ptr, y, x, 0L);
405 g_ptr->feat = feat_tree;
410 place_secret_door(player_ptr, y, x, DOOR_DEFAULT);
413 /* Secret glass doors */
415 place_secret_door(player_ptr, y, x, DOOR_GLASS_DOOR);
416 if (is_closed_door(player_ptr, g_ptr->feat)) {
417 g_ptr->mimic = feat_glass_wall;
423 place_secret_door(player_ptr, y, x, DOOR_CURTAIN);
428 place_trap(player_ptr, y, x);
431 /* Black market in a dungeon */
433 set_cave_feat(floor_ptr, y, x, feat_black_market);
434 store_init(VALID_TOWNS, StoreSaleType::BLACK);
439 set_cave_feat(floor_ptr, y, x, feat_pattern_start);
443 set_cave_feat(floor_ptr, y, x, feat_pattern_1);
447 set_cave_feat(floor_ptr, y, x, feat_pattern_2);
451 set_cave_feat(floor_ptr, y, x, feat_pattern_3);
455 set_cave_feat(floor_ptr, y, x, feat_pattern_4);
459 set_cave_feat(floor_ptr, y, x, feat_pattern_end);
463 set_cave_feat(floor_ptr, y, x, feat_pattern_exit);
467 /* Reward for Pattern walk */
468 floor_ptr->object_level = floor_ptr->base_level + 12;
469 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
470 floor_ptr->object_level = floor_ptr->base_level;
474 set_cave_feat(floor_ptr, y, x, feat_shallow_water);
478 set_cave_feat(floor_ptr, y, x, feat_deep_water);
482 set_cave_feat(floor_ptr, y, x, feat_shallow_lava);
486 set_cave_feat(floor_ptr, y, x, feat_deep_lava);
490 set_cave_feat(floor_ptr, y, x, feat_shallow_acid_puddle);
494 set_cave_feat(floor_ptr, y, x, feat_deep_acid_puddle);
498 set_cave_feat(floor_ptr, y, x, feat_shallow_poisonous_puddle);
502 set_cave_feat(floor_ptr, y, x, feat_deep_poisonous_puddle);
506 set_cave_feat(floor_ptr, y, x, feat_cold_zone);
510 set_cave_feat(floor_ptr, y, x, feat_heavy_cold_zone);
514 set_cave_feat(floor_ptr, y, x, feat_electrical_zone);
518 set_cave_feat(floor_ptr, y, x, feat_heavy_electrical_zone);
524 /* Place dungeon monsters and objects */
525 for (t = data, dy = 0; dy < ymax; dy++) {
526 for (dx = 0; dx < xmax; dx++, t++) {
527 /* prevent loop counter from being overwritten */
532 coord_trans(&i, &j, xoffset, yoffset, transno);
534 if (transno % 2 == 0) {
536 x = xval - (xmax / 2) + i;
537 y = yval - (ymax / 2) + j;
540 x = xval - (ymax / 2) + i;
541 y = yval - (xmax / 2) + j;
544 /* Hack -- skip "non-grids" */
549 /* Analyze the symbol */
552 floor_ptr->monster_level = floor_ptr->base_level + 5;
553 place_random_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
554 floor_ptr->monster_level = floor_ptr->base_level;
560 floor_ptr->monster_level = floor_ptr->base_level + 11;
561 place_random_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
562 floor_ptr->monster_level = floor_ptr->base_level;
566 /* Meaner monster, plus treasure */
568 floor_ptr->monster_level = floor_ptr->base_level + 9;
569 place_random_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
570 floor_ptr->monster_level = floor_ptr->base_level;
571 floor_ptr->object_level = floor_ptr->base_level + 7;
572 place_object(player_ptr, y, x, AM_GOOD);
573 floor_ptr->object_level = floor_ptr->base_level;
577 /* Nasty monster and treasure */
579 floor_ptr->monster_level = floor_ptr->base_level + 40;
580 place_random_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
581 floor_ptr->monster_level = floor_ptr->base_level;
582 floor_ptr->object_level = floor_ptr->base_level + 20;
583 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
584 floor_ptr->object_level = floor_ptr->base_level;
588 /* Monster and/or object */
590 if (randint0(100) < 50) {
591 floor_ptr->monster_level = floor_ptr->base_level + 3;
592 place_random_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
593 floor_ptr->monster_level = floor_ptr->base_level;
595 if (randint0(100) < 50) {
596 floor_ptr->object_level = floor_ptr->base_level + 7;
597 place_object(player_ptr, y, x, 0L);
598 floor_ptr->object_level = floor_ptr->base_level;
608 * Build target vault.
609 * This is made by two concentric "crypts" with perpendicular
610 * walls creating the cross-hairs.
612 static void build_target_vault(PlayerType *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
616 /* Make a random metric */
617 POSITION h1, h2, h3, h4;
618 h1 = randint1(32) - 16;
621 h4 = randint1(32) - 16;
623 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Target Vault"));
625 /* work out outer radius */
633 auto *floor_ptr = player_ptr->current_floor_ptr;
634 for (x = x0 - rad; x <= x0 + rad; x++) {
635 for (y = y0 - rad; y <= y0 + rad; y++) {
636 /* clear room flag */
637 floor_ptr->grid_array[y][x].info &= ~(CAVE_ROOM);
639 /* Vault - so is "icky" */
640 floor_ptr->grid_array[y][x].info |= CAVE_ICKY;
642 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1) {
643 /* inside- so is floor */
644 place_bold(player_ptr, y, x, GB_FLOOR);
646 /* make granite outside so on_defeat_arena_monster works */
647 place_bold(player_ptr, y, x, GB_EXTRA);
650 /* proper boundary for on_defeat_arena_monster */
651 if (((y + rad) == y0) || ((y - rad) == y0) || ((x + rad) == x0) || ((x - rad) == x0)) {
652 place_bold(player_ptr, y, x, GB_EXTRA);
657 /* Find visible outer walls and set to be FEAT_OUTER */
658 add_outer_wall(player_ptr, x0, y0, false, x0 - rad - 1, y0 - rad - 1, x0 + rad + 1, y0 + rad + 1);
661 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++) {
662 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++) {
663 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2) {
664 /* Make an internal wall */
665 place_bold(player_ptr, y, x, GB_INNER);
670 /* Add perpendicular walls */
671 for (x = x0 - rad; x <= x0 + rad; x++) {
672 place_bold(player_ptr, y0, x, GB_INNER);
675 for (y = y0 - rad; y <= y0 + rad; y++) {
676 place_bold(player_ptr, y, x0, GB_INNER);
679 /* Make inner vault */
680 for (y = y0 - 1; y <= y0 + 1; y++) {
681 place_bold(player_ptr, y, x0 - 1, GB_INNER);
682 place_bold(player_ptr, y, x0 + 1, GB_INNER);
684 for (x = x0 - 1; x <= x0 + 1; x++) {
685 place_bold(player_ptr, y0 - 1, x, GB_INNER);
686 place_bold(player_ptr, y0 + 1, x, GB_INNER);
689 place_bold(player_ptr, y0, x0, GB_FLOOR);
691 /* Add doors to vault */
692 /* get two distances so can place doors relative to centre */
693 x = (rad - 2) / 4 + 1;
696 add_door(player_ptr, x0 + x, y0);
697 add_door(player_ptr, x0 + y, y0);
698 add_door(player_ptr, x0 - x, y0);
699 add_door(player_ptr, x0 - y, y0);
700 add_door(player_ptr, x0, y0 + x);
701 add_door(player_ptr, x0, y0 + y);
702 add_door(player_ptr, x0, y0 - x);
703 add_door(player_ptr, x0, y0 - y);
705 /* Fill with stuff - medium difficulty */
706 fill_treasure(player_ptr, x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
710 * This routine uses a modified version of the lake code to make a
711 * distribution of some terrain type over the vault. This type
712 * depends on the dungeon depth.
714 * Miniture rooms are then scattered across the vault.
716 static void build_elemental_vault(PlayerType *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
721 POSITION xsize, ysize, xhsize, yhsize, x, y;
725 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
727 /* round to make sizes even */
733 auto *floor_ptr = player_ptr->current_floor_ptr;
734 if (floor_ptr->dun_level < 25) {
735 /* Earth vault (Rubble) */
736 type = LAKE_T_EARTH_VAULT;
737 } else if (floor_ptr->dun_level < 50) {
738 /* Air vault (Trees) */
739 type = LAKE_T_AIR_VAULT;
740 } else if (floor_ptr->dun_level < 75) {
741 /* Water vault (shallow water) */
742 type = LAKE_T_WATER_VAULT;
744 /* Fire vault (shallow lava) */
745 type = LAKE_T_FIRE_VAULT;
749 /* testing values for these parameters: feel free to adjust */
750 grd = 1 << (randint0(3));
752 /* want average of about 16 */
753 roug = randint1(8) * randint1(4);
755 /* Make up size of various componants */
759 /* Deep water/lava */
760 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
762 /* Shallow boundary */
766 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, c3);
768 /* Convert to normal format+ clean up */
769 done = generate_lake(player_ptr, y0, x0, xsize, ysize, c1, c2, c3, type);
772 /* Set icky flag because is a vault */
773 for (x = 0; x <= xsize; x++) {
774 for (y = 0; y <= ysize; y++) {
775 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
779 /* make a few rooms in the vault */
780 for (i = 1; i <= (xsize * ysize) / 50; i++) {
781 build_small_room(player_ptr, x0 + randint0(xsize - 4) - xsize / 2 + 2, y0 + randint0(ysize - 4) - ysize / 2 + 2);
784 /* Fill with monsters and treasure, low difficulty */
785 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
788 /* Build a "mini" checkerboard vault
790 * This is done by making a permanent wall maze and setting
791 * the diagonal sqaures of the checker board to be granite.
792 * The vault has two entrances on opposite sides to guarantee
793 * a way to get in even if the vault abuts a side of the dungeon.
795 static void build_mini_c_vault(PlayerType *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
798 POSITION y1, x1, y2, x2, y, x, total;
799 int m, n, num_vertices;
801 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
803 /* Pick a random room size */
812 /* generate the room */
813 auto *floor_ptr = player_ptr->current_floor_ptr;
814 for (x = x1 - 2; x <= x2 + 2; x++) {
815 if (!in_bounds(floor_ptr, y1 - 2, x)) {
819 floor_ptr->grid_array[y1 - 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
821 place_bold(player_ptr, y1 - 2, x, GB_OUTER_NOPERM);
824 for (x = x1 - 2; x <= x2 + 2; x++) {
825 if (!in_bounds(floor_ptr, y2 + 2, x)) {
829 floor_ptr->grid_array[y2 + 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
831 place_bold(player_ptr, y2 + 2, x, GB_OUTER_NOPERM);
834 for (y = y1 - 2; y <= y2 + 2; y++) {
835 if (!in_bounds(floor_ptr, y, x1 - 2)) {
839 floor_ptr->grid_array[y][x1 - 2].info |= (CAVE_ROOM | CAVE_ICKY);
841 place_bold(player_ptr, y, x1 - 2, GB_OUTER_NOPERM);
844 for (y = y1 - 2; y <= y2 + 2; y++) {
845 if (!in_bounds(floor_ptr, y, x2 + 2)) {
849 floor_ptr->grid_array[y][x2 + 2].info |= (CAVE_ROOM | CAVE_ICKY);
851 place_bold(player_ptr, y, x2 + 2, GB_OUTER_NOPERM);
854 for (y = y1 - 1; y <= y2 + 1; y++) {
855 for (x = x1 - 1; x <= x2 + 1; x++) {
856 auto *g_ptr = &floor_ptr->grid_array[y][x];
858 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
860 /* Permanent walls */
861 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
865 /* dimensions of vertex array */
868 num_vertices = m * n;
870 /* initialize array of visited vertices */
871 std::vector<int> visited(num_vertices);
873 /* traverse the graph to create a spannng tree, pick a random root */
874 r_visit(player_ptr, y1, x1, y2, x2, randint0(num_vertices), 0, visited.data());
876 /* Make it look like a checker board vault */
877 for (x = x1; x <= x2; x++) {
878 for (y = y1; y <= y2; y++) {
879 total = x - x1 + y - y1;
880 /* If total is odd- and is a floor then make a wall */
881 if ((total % 2 == 1) && floor_ptr->grid_array[y][x].is_floor()) {
882 place_bold(player_ptr, y, x, GB_INNER);
887 /* Make a couple of entrances */
890 y = randint1(dy) + dy / 2;
891 place_bold(player_ptr, y1 + y, x1 - 1, GB_INNER);
892 place_bold(player_ptr, y1 + y, x2 + 1, GB_INNER);
895 x = randint1(dx) + dx / 2;
896 place_bold(player_ptr, y1 - 1, x1 + x, GB_INNER);
897 place_bold(player_ptr, y2 + 1, x1 + x, GB_INNER);
900 /* Fill with monsters and treasure, highest difficulty */
901 fill_treasure(player_ptr, x1, x2, y1, y2, 10);
905 /* Driver routine: clear the region and call the recursive
908 *This makes a vault that looks like a castle/ city in the dungeon.
910 static void build_castle_vault(PlayerType *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
913 POSITION y1, x1, y2, x2;
916 /* Pick a random room size */
925 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
927 /* generate the room */
928 auto *floor_ptr = player_ptr->current_floor_ptr;
929 for (y = y1 - 1; y <= y2 + 1; y++) {
930 for (x = x1 - 1; x <= x2 + 1; x++) {
931 floor_ptr->grid_array[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
932 /* Make everything a floor */
933 place_bold(player_ptr, y, x, GB_FLOOR);
937 /* Make the castle */
938 build_recursive_room(player_ptr, x1, y1, x2, y2, randint1(5));
940 /* Fill with monsters and treasure, low difficulty */
941 fill_treasure(player_ptr, x1, x2, y1, y2, randint1(3));
945 * @brief タイプ10の部屋…ランダム生成vault / Type 10 -- Random vaults
946 * @param player_ptr プレイヤーへの参照ポインタ
948 bool build_type10(PlayerType *player_ptr, dun_data_type *dd_ptr)
950 POSITION y0, x0, xsize, ysize, vtype;
952 /* big enough to look good, small enough to be fairly common. */
953 xsize = randint1(22) + 22;
954 ysize = randint1(11) + 11;
956 /* Find and reserve some space in the dungeon. Get center of room. */
957 auto *floor_ptr = player_ptr->current_floor_ptr;
958 if (!find_space(player_ptr, dd_ptr, &y0, &x0, ysize + 1, xsize + 1)) {
962 /* Select type of vault */
964 vtype = randint1(15);
965 } while (floor_ptr->get_dungeon_definition().flags.has(DungeonFeatureType::NO_CAVE) && ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
968 /* Build an appropriate room */
971 build_bubble_vault(player_ptr, x0, y0, xsize, ysize);
975 build_room_vault(player_ptr, x0, y0, xsize, ysize);
979 build_cave_vault(player_ptr, x0, y0, xsize, ysize);
983 build_maze_vault(player_ptr, x0, y0, xsize, ysize, true);
987 build_mini_c_vault(player_ptr, x0, y0, xsize, ysize);
991 build_castle_vault(player_ptr, x0, y0, xsize, ysize);
995 build_target_vault(player_ptr, x0, y0, xsize, ysize);
998 build_elemental_vault(player_ptr, x0, y0, xsize, ysize);
1000 /* I know how to add a few more... give me some time. */
1009 * @brief VaultDefinitions からの部屋生成
1011 bool build_fixed_room(PlayerType *player_ptr, dun_data_type *dd_ptr, int typ, bool more_space)
1013 vault_type *v_ptr = nullptr;
1015 POSITION xval, yval;
1016 POSITION xoffset, yoffset;
1019 ProbabilityTable<int> prob_table;
1021 /* Pick fixed room */
1022 for (const auto &v_ref : vaults_info) {
1023 if (v_ref.typ == typ) {
1024 prob_table.entry_item(v_ref.idx, 1);
1028 auto result = prob_table.pick_one_at_random();
1030 v_ptr = &vaults_info[result];
1032 /* pick type of transformation (0-7) */
1033 transno = randint0(8);
1035 /* calculate offsets */
1039 /* Some huge vault cannot be ratated to fit in the dungeon */
1040 auto *floor_ptr = player_ptr->current_floor_ptr;
1041 if (x + 2 > floor_ptr->height - 2) {
1042 /* Forbid 90 or 270 degree ratation */
1046 coord_trans(&x, &y, 0, 0, transno);
1061 * Try to allocate space for room. If fails, exit
1063 * Hack -- Prepare a bit larger space (+2, +2) to
1064 * prevent generation of vaults with no-entrance.
1066 int xsize = more_space ? abs(x) + 2 : abs(x);
1067 int ysize = more_space ? abs(y) + 2 : abs(y);
1068 /* Find and reserve some space in the dungeon. Get center of room. */
1069 if (!find_space(player_ptr, dd_ptr, &yval, &xval, ysize, xsize)) {
1073 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("固定部屋(%s)を生成しました。", "Fixed room (%s)."), v_ptr->name.data());
1075 /* Hack -- Build the vault */
1076 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid, v_ptr->text.data(), xoffset, yoffset, transno);