3 #include "rooms-vault.h"
5 #include "floor-generate.h"
17 * The vault generation arrays
24 * Maximum number of vaults in v_info.txt
29 * This function creates a random vault that looks like a collection of bubbles.
30 * It works by getting a set of coordinates that represent the center of each
31 * bubble. The entire room is made by seeing which bubble center is closest. If
32 * two centers are equidistant then the square is a wall, otherwise it is a floor.
33 * The only exception is for squares really near a center, these are always floor.
34 * (It looks better than without this check.)
36 * Note: If two centers are on the same point then this algorithm will create a
37 * blank bubble filled with walls. - This is prevented from happening.
39 static void build_bubble_vault(POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
41 #define BUBBLENUM 10 /* number of bubbles */
43 /* array of center points of bubbles */
44 coord center[BUBBLENUM];
47 POSITION x = 0, y = 0;
48 u16b min1, min2, temp;
51 /* Offset from center to top left hand corner */
52 POSITION xhsize = xsize / 2;
53 POSITION yhsize = ysize / 2;
55 msg_print_wizard(CHEAT_DUNGEON, _("泡型ランダムVaultを生成しました。", "Room Vault."));
57 /* Allocate center of bubbles */
58 center[0].x = (byte)randint1(xsize - 3) + 1;
59 center[0].y = (byte)randint1(ysize - 3) + 1;
61 for (i = 1; i < BUBBLENUM; i++)
65 /* get center and check to see if it is unique */
70 x = randint1(xsize - 3) + 1;
71 y = randint1(ysize - 3) + 1;
73 for (j = 0; j < i; j++)
75 /* rough test to see if there is an overlap */
76 if ((x == center[j].x) && (y == center[j].y)) done = FALSE;
85 /* Top and bottom boundaries */
86 for (i = 0; i < xsize; i++)
88 int side_x = x0 - xhsize + i;
90 place_outer_noperm_bold(y0 - yhsize + 0, side_x);
91 current_floor_ptr->grid_array[y0 - yhsize + 0][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
92 place_outer_noperm_bold(y0 - yhsize + ysize - 1, side_x);
93 current_floor_ptr->grid_array[y0 - yhsize + ysize - 1][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
96 /* Left and right boundaries */
97 for (i = 1; i < ysize - 1; i++)
99 int side_y = y0 - yhsize + i;
101 place_outer_noperm_bold(side_y, x0 - xhsize + 0);
102 current_floor_ptr->grid_array[side_y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
103 place_outer_noperm_bold(side_y, x0 - xhsize + xsize - 1);
104 current_floor_ptr->grid_array[side_y][x0 - xhsize + xsize - 1].info |= (CAVE_ROOM | CAVE_ICKY);
107 /* Fill in middle with bubbles */
108 for (x = 1; x < xsize - 1; x++)
110 for (y = 1; y < ysize - 1; y++)
112 /* Get distances to two closest centers */
114 min1 = (u16b)distance(x, y, center[0].x, center[0].y);
115 min2 = (u16b)distance(x, y, center[1].x, center[1].y);
119 /* swap if in wrong order */
126 for (i = 2; i < BUBBLENUM; i++)
128 temp = (u16b)distance(x, y, center[i].x, center[i].y);
136 else if (temp < min2)
138 /* second smallest */
142 if (((min2 - min1) <= 2) && (!(min1 < 3)))
144 /* Boundary at midpoint+ not at inner region of bubble */
145 place_outer_noperm_bold(y0 - yhsize + y, x0 - xhsize + x);
149 /* middle of a bubble */
150 place_floor_bold(y0 - yhsize + y, x0 - xhsize + x);
153 /* clean up rest of flags */
154 current_floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= (CAVE_ROOM | CAVE_ICKY);
158 /* Try to add some random doors */
159 for (i = 0; i < 500; i++)
161 x = randint1(xsize - 3) - xhsize + x0 + 1;
162 y = randint1(ysize - 3) - yhsize + y0 + 1;
166 /* Fill with monsters and treasure, low difficulty */
167 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5));
170 /* Create a random vault that looks like a collection of overlapping rooms */
171 static void build_room_vault(POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
173 POSITION x1, x2, y1, y2, xhsize, yhsize;
176 /* get offset from center */
180 msg_print_wizard(CHEAT_DUNGEON, _("部屋型ランダムVaultを生成しました。", "Room Vault."));
182 /* fill area so don't get problems with arena levels */
183 for (x1 = 0; x1 < xsize; x1++)
185 POSITION x = x0 - xhsize + x1;
187 for (y1 = 0; y1 < ysize; y1++)
189 POSITION y = y0 - yhsize + y1;
191 place_extra_bold(y, x);
192 current_floor_ptr->grid_array[y][x].info &= (~CAVE_ICKY);
196 /* add ten random rooms */
197 for (i = 0; i < 10; i++)
199 x1 = randint1(xhsize) * 2 + x0 - xhsize;
200 x2 = randint1(xhsize) * 2 + x0 - xhsize;
201 y1 = randint1(yhsize) * 2 + y0 - yhsize;
202 y2 = randint1(yhsize) * 2 + y0 - yhsize;
203 build_room(x1, x2, y1, y2);
206 /* Add some random doors */
207 for (i = 0; i < 500; i++)
209 x1 = randint1(xsize - 3) - xhsize + x0 + 1;
210 y1 = randint1(ysize - 3) - yhsize + y0 + 1;
214 /* Fill with monsters and treasure, high difficulty */
215 fill_treasure(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 current_floor_ptr->grid_array */
220 static void build_cave_vault(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(CHEAT_DUNGEON, _("洞穴ランダムVaultを生成しました。", "Cave Vault."));
234 light = done = FALSE;
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) +
247 randint1(xsize / 4) + randint1(ysize / 4);
250 generate_hmap(y0, x0, xsize, ysize, grd, roug, cutoff);
252 /* Convert to normal format+ clean up */
253 done = generate_fracave(y0, x0, xsize, ysize, cutoff, light, room);
256 /* Set icky flag because is a vault */
257 for (x = 0; x <= xsize; x++)
259 for (y = 0; y <= ysize; y++)
261 current_floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
265 /* Fill with monsters and treasure, low difficulty */
266 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
272 * @brief Vault地形を回転、上下左右反転するための座標変換を返す / coordinate translation code
273 * @param x 変換したい点のX座標参照ポインタ
274 * @param y 変換したい点のY座標参照ポインタ
275 * @param xoffset Vault生成時の基準X座標
276 * @param yoffset Vault生成時の基準Y座標
277 * @param transno 処理ID
280 static void coord_trans(POSITION *x, POSITION *y, POSITION xoffset, POSITION yoffset, int transno)
286 * transno specifies what transformation is required. (0-7)
287 * The lower two bits indicate by how much the vault is rotated,
288 * and the upper bit indicates a reflection.
289 * This is done by using rotation matrices... however since
290 * these are mostly zeros for rotations by 90 degrees this can
291 * be expressed simply in terms of swapping and inverting the
292 * x and y coordinates.
294 for (i = 0; i < transno % 4; i++)
296 /* rotate by 90 degrees */
304 /* Reflect depending on status of 3rd bit. */
308 /* Add offsets so vault stays in the first quadrant */
315 * @brief Vaultをフロアに配置する / Hack -- fill in "vault" rooms
316 * @param yval 生成基準Y座標
317 * @param xval 生成基準X座標
318 * @param ymax VaultのYサイズ
319 * @param xmax VaultのXサイズ
320 * @param data Vaultのデータ文字列
321 * @param xoffset 変換基準X座標
322 * @param yoffset 変換基準Y座標
323 * @param transno 変換ID
326 static void build_vault(POSITION yval, POSITION xval, POSITION ymax, POSITION xmax, concptr data,
327 POSITION xoffset, POSITION yoffset, int transno)
329 POSITION dx, dy, x, y, i, j;
333 /* Place dungeon features and objects */
334 for (t = data, dy = 0; dy < ymax; dy++)
336 for (dx = 0; dx < xmax; dx++, t++)
338 /* prevent loop counter from being overwritten */
343 coord_trans(&i, &j, xoffset, yoffset, transno);
345 /* Extract the location */
346 if (transno % 2 == 0)
349 x = xval - (xmax / 2) + i;
350 y = yval - (ymax / 2) + j;
355 x = xval - (ymax / 2) + i;
356 y = yval - (xmax / 2) + j;
359 /* Hack -- skip "non-grids" */
360 if (*t == ' ') continue;
361 g_ptr = ¤t_floor_ptr->grid_array[y][x];
363 /* Lay down a floor */
364 place_floor_grid(g_ptr);
366 /* Remove any mimic */
369 /* Part of a vault */
370 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
372 /* Analyze the grid */
375 /* Granite wall (outer) */
377 place_outer_noperm_grid(g_ptr);
380 /* Granite wall (inner) */
382 place_inner_grid(g_ptr);
385 /* Glass wall (inner) */
387 place_inner_grid(g_ptr);
388 g_ptr->feat = feat_glass_wall;
391 /* Permanent wall (inner) */
393 place_inner_perm_grid(g_ptr);
396 /* Permanent glass wall (inner) */
398 place_inner_perm_grid(g_ptr);
399 g_ptr->feat = feat_permanent_glass_wall;
404 if (randint0(100) < 75)
406 place_object(y, x, 0L);
416 place_object(y, x, 0L);
421 g_ptr->feat = feat_tree;
426 place_secret_door(y, x, DOOR_DEFAULT);
429 /* Secret glass doors */
431 place_secret_door(y, x, DOOR_GLASS_DOOR);
432 if (is_closed_door(g_ptr->feat)) g_ptr->mimic = feat_glass_wall;
437 place_secret_door(y, x, DOOR_CURTAIN);
445 /* Black market in a dungeon */
447 set_cave_feat(y, x, feat_black_market);
448 store_init(NO_TOWN, STORE_BLACK);
453 set_cave_feat(y, x, feat_pattern_start);
457 set_cave_feat(y, x, feat_pattern_1);
461 set_cave_feat(y, x, feat_pattern_2);
465 set_cave_feat(y, x, feat_pattern_3);
469 set_cave_feat(y, x, feat_pattern_4);
473 set_cave_feat(y, x, feat_pattern_end);
477 set_cave_feat(y, x, feat_pattern_exit);
481 /* Reward for Pattern walk */
482 current_floor_ptr->object_level = current_floor_ptr->base_level + 12;
483 place_object(y, x, AM_GOOD | AM_GREAT);
484 current_floor_ptr->object_level = current_floor_ptr->base_level;
488 set_cave_feat(y, x, feat_shallow_water);
492 set_cave_feat(y, x, feat_deep_water);
496 set_cave_feat(y, x, feat_shallow_lava);
500 set_cave_feat(y, x, feat_deep_lava);
504 set_cave_feat(y, x, feat_shallow_acid_puddle);
508 set_cave_feat(y, x, feat_deep_acid_puddle);
512 set_cave_feat(y, x, feat_shallow_poisonous_puddle);
516 set_cave_feat(y, x, feat_deep_poisonous_puddle);
520 set_cave_feat(y, x, feat_cold_zone);
524 set_cave_feat(y, x, feat_heavy_cold_zone);
528 set_cave_feat(y, x, feat_electrical_zone);
532 set_cave_feat(y, x, feat_heavy_electrical_zone);
540 /* Place dungeon monsters and objects */
541 for (t = data, dy = 0; dy < ymax; dy++)
543 for (dx = 0; dx < xmax; dx++, t++)
545 /* prevent loop counter from being overwritten */
550 coord_trans(&i, &j, xoffset, yoffset, transno);
552 /* Extract the location */
553 if (transno % 2 == 0)
556 x = xval - (xmax / 2) + i;
557 y = yval - (ymax / 2) + j;
562 x = xval - (ymax / 2) + i;
563 y = yval - (xmax / 2) + j;
566 /* Hack -- skip "non-grids" */
567 if (*t == ' ') continue;
569 /* Analyze the symbol */
574 current_floor_ptr->monster_level = current_floor_ptr->base_level + 5;
575 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
576 current_floor_ptr->monster_level = current_floor_ptr->base_level;
583 current_floor_ptr->monster_level = current_floor_ptr->base_level + 11;
584 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
585 current_floor_ptr->monster_level = current_floor_ptr->base_level;
589 /* Meaner monster, plus treasure */
592 current_floor_ptr->monster_level = current_floor_ptr->base_level + 9;
593 place_monster(y, x, PM_ALLOW_SLEEP);
594 current_floor_ptr->monster_level = current_floor_ptr->base_level;
595 current_floor_ptr->object_level = current_floor_ptr->base_level + 7;
596 place_object(y, x, AM_GOOD);
597 current_floor_ptr->object_level = current_floor_ptr->base_level;
601 /* Nasty monster and treasure */
604 current_floor_ptr->monster_level = current_floor_ptr->base_level + 40;
605 place_monster(y, x, PM_ALLOW_SLEEP);
606 current_floor_ptr->monster_level = current_floor_ptr->base_level;
607 current_floor_ptr->object_level = current_floor_ptr->base_level + 20;
608 place_object(y, x, AM_GOOD | AM_GREAT);
609 current_floor_ptr->object_level = current_floor_ptr->base_level;
613 /* Monster and/or object */
616 if (randint0(100) < 50)
618 current_floor_ptr->monster_level = current_floor_ptr->base_level + 3;
619 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
620 current_floor_ptr->monster_level = current_floor_ptr->base_level;
622 if (randint0(100) < 50)
624 current_floor_ptr->object_level = current_floor_ptr->base_level + 7;
625 place_object(y, x, 0L);
626 current_floor_ptr->object_level = current_floor_ptr->base_level;
639 * @brief タイプ7の部屋…v_info.txtより小型vaultを生成する / Type 7 -- simple vaults (see "v_info.txt")
642 bool build_type7(void)
644 vault_type *v_ptr = NULL;
648 POSITION xoffset, yoffset;
651 /* Pick a lesser vault */
652 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
654 /* Access a random vault record */
655 v_ptr = &v_info[randint0(max_v_idx)];
657 /* Accept the first lesser vault */
658 if (v_ptr->typ == 7) break;
661 /* No lesser vault found */
662 if (dummy >= SAFE_MAX_ATTEMPTS)
664 msg_print_wizard(CHEAT_DUNGEON, _("小型固定Vaultを配置できませんでした。", "Could not place lesser vault."));
668 /* pick type of transformation (0-7) */
669 transno = randint0(8);
671 /* calculate offsets */
675 /* Some huge vault cannot be ratated to fit in the dungeon */
676 if (x + 2 > current_floor_ptr->height - 2)
678 /* Forbid 90 or 270 degree ratation */
682 coord_trans(&x, &y, 0, 0, transno);
702 /* Find and reserve some space in the dungeon. Get center of room. */
703 if (!find_space(&yval, &xval, abs(y), abs(x))) return FALSE;
709 msg_format_wizard(CHEAT_DUNGEON, _("小型Vault(%s)を生成しました。", "Lesser vault (%s)."), v_name + v_ptr->name);
711 /* Hack -- Build the vault */
712 build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
713 v_text + v_ptr->text, xoffset, yoffset, transno);
719 * @brief タイプ8の部屋…v_info.txtより大型vaultを生成する / Type 8 -- greater vaults (see "v_info.txt")
722 bool build_type8(void)
729 POSITION xoffset, yoffset;
731 /* Pick a greater vault */
732 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
734 /* Access a random vault record */
735 v_ptr = &v_info[randint0(max_v_idx)];
737 /* Accept the first greater vault */
738 if (v_ptr->typ == 8) break;
741 /* No greater vault found */
742 if (dummy >= SAFE_MAX_ATTEMPTS)
744 msg_print_wizard(CHEAT_DUNGEON, _("大型固定Vaultを配置できませんでした。", "Could not place greater vault."));
748 /* pick type of transformation (0-7) */
749 transno = randint0(8);
751 /* calculate offsets */
755 /* Some huge vault cannot be ratated to fit in the dungeon */
756 if (x + 2 > current_floor_ptr->height - 2)
758 /* Forbid 90 or 270 degree ratation */
762 coord_trans(&x, &y, 0, 0, transno);
783 * Try to allocate space for room. If fails, exit
785 * Hack -- Prepare a bit larger space (+2, +2) to
786 * prevent generation of vaults with no-entrance.
788 /* Find and reserve some space in the dungeon. Get center of room. */
789 if (!find_space(&yval, &xval, (POSITION)(abs(y) + 2), (POSITION)(abs(x) + 2))) return FALSE;
792 v_ptr = &v_info[76 + randint1(3)];
795 msg_format_wizard(CHEAT_DUNGEON, _("大型固定Vault(%s)を生成しました。", "Greater vault (%s)."), v_name + v_ptr->name);
797 /* Hack -- Build the vault */
798 build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
799 v_text + v_ptr->text, xoffset, yoffset, transno);
806 * Build target vault.
807 * This is made by two concentric "crypts" with perpendicular
808 * walls creating the cross-hairs.
810 static void build_target_vault(POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
814 /* Make a random metric */
815 POSITION h1, h2, h3, h4;
816 h1 = randint1(32) - 16;
819 h4 = randint1(32) - 16;
821 msg_print_wizard(CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Elemental Vault"));
823 /* work out outer radius */
834 for (x = x0 - rad; x <= x0 + rad; x++)
836 for (y = y0 - rad; y <= y0 + rad; y++)
838 /* clear room flag */
839 current_floor_ptr->grid_array[y][x].info &= ~(CAVE_ROOM);
841 /* Vault - so is "icky" */
842 current_floor_ptr->grid_array[y][x].info |= CAVE_ICKY;
844 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1)
846 /* inside- so is floor */
847 place_floor_bold(y, x);
851 /* make granite outside so arena works */
852 place_extra_bold(y, x);
855 /* proper boundary for arena */
856 if (((y + rad) == y0) || ((y - rad) == y0) ||
857 ((x + rad) == x0) || ((x - rad) == x0))
859 place_extra_bold(y, x);
864 /* Find visible outer walls and set to be FEAT_OUTER */
865 add_outer_wall(x0, y0, FALSE, x0 - rad - 1, y0 - rad - 1,
866 x0 + rad + 1, y0 + rad + 1);
869 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++)
871 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++)
873 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2)
875 /* Make an internal wall */
876 place_inner_bold(y, x);
881 /* Add perpendicular walls */
882 for (x = x0 - rad; x <= x0 + rad; x++)
884 place_inner_bold(y0, x);
887 for (y = y0 - rad; y <= y0 + rad; y++)
889 place_inner_bold(y, x0);
892 /* Make inner vault */
893 for (y = y0 - 1; y <= y0 + 1; y++)
895 place_inner_bold(y, x0 - 1);
896 place_inner_bold(y, x0 + 1);
898 for (x = x0 - 1; x <= x0 + 1; x++)
900 place_inner_bold(y0 - 1, x);
901 place_inner_bold(y0 + 1, x);
904 place_floor_bold(y0, x0);
907 /* Add doors to vault */
908 /* get two distances so can place doors relative to centre */
909 x = (rad - 2) / 4 + 1;
912 add_door(x0 + x, y0);
913 add_door(x0 + y, y0);
914 add_door(x0 - x, y0);
915 add_door(x0 - y, y0);
916 add_door(x0, y0 + x);
917 add_door(x0, y0 + y);
918 add_door(x0, y0 - x);
919 add_door(x0, y0 - y);
921 /* Fill with stuff - medium difficulty */
922 fill_treasure(x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
926 #ifdef ALLOW_CAVERNS_AND_LAKES
928 * This routine uses a modified version of the lake code to make a
929 * distribution of some terrain type over the vault. This type
930 * depends on the dungeon depth.
932 * Miniture rooms are then scattered across the vault.
934 static void build_elemental_vault(POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
939 POSITION xsize, ysize, xhsize, yhsize, x, y;
943 msg_print_wizard(CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
945 /* round to make sizes even */
951 if (current_floor_ptr->dun_level < 25)
953 /* Earth vault (Rubble) */
954 type = LAKE_T_EARTH_VAULT;
956 else if (current_floor_ptr->dun_level < 50)
958 /* Air vault (Trees) */
959 type = LAKE_T_AIR_VAULT;
961 else if (current_floor_ptr->dun_level < 75)
963 /* Water vault (shallow water) */
964 type = LAKE_T_WATER_VAULT;
968 /* Fire vault (shallow lava) */
969 type = LAKE_T_FIRE_VAULT;
974 /* testing values for these parameters: feel free to adjust */
975 grd = 1 << (randint0(3));
977 /* want average of about 16 */
978 roug = randint1(8) * randint1(4);
980 /* Make up size of various componants */
984 /* Deep water/lava */
985 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
987 /* Shallow boundary */
991 generate_hmap(y0, x0, xsize, ysize, grd, roug, c3);
993 /* Convert to normal format+ clean up */
994 done = generate_lake(y0, x0, xsize, ysize, c1, c2, c3, type);
997 /* Set icky flag because is a vault */
998 for (x = 0; x <= xsize; x++)
1000 for (y = 0; y <= ysize; y++)
1002 current_floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
1006 /* make a few rooms in the vault */
1007 for (i = 1; i <= (xsize * ysize) / 50; i++)
1009 build_small_room(x0 + randint0(xsize - 4) - xsize / 2 + 2,
1010 y0 + randint0(ysize - 4) - ysize / 2 + 2);
1013 /* Fill with monsters and treasure, low difficulty */
1014 fill_treasure(x0 - xhsize + 1, x0 - xhsize + xsize - 1,
1015 y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
1017 #endif /* ALLOW_CAVERNS_AND_LAKES */
1020 /* Build a "mini" checkerboard vault
1022 * This is done by making a permanent wall maze and setting
1023 * the diagonal sqaures of the checker board to be granite.
1024 * The vault has two entrances on opposite sides to guarantee
1025 * a way to get in even if the vault abuts a side of the dungeon.
1027 static void build_mini_c_vault(POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1030 POSITION y1, x1, y2, x2, y, x, total;
1031 int m, n, num_vertices;
1034 msg_print_wizard(CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
1036 /* Pick a random room size */
1046 /* generate the room */
1047 for (x = x1 - 2; x <= x2 + 2; x++)
1049 if (!in_bounds(y1 - 2, x)) break;
1051 current_floor_ptr->grid_array[y1 - 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1053 place_outer_noperm_bold(y1 - 2, x);
1056 for (x = x1 - 2; x <= x2 + 2; x++)
1058 if (!in_bounds(y2 + 2, x)) break;
1060 current_floor_ptr->grid_array[y2 + 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1062 place_outer_noperm_bold(y2 + 2, x);
1065 for (y = y1 - 2; y <= y2 + 2; y++)
1067 if (!in_bounds(y, x1 - 2)) break;
1069 current_floor_ptr->grid_array[y][x1 - 2].info |= (CAVE_ROOM | CAVE_ICKY);
1071 place_outer_noperm_bold(y, x1 - 2);
1074 for (y = y1 - 2; y <= y2 + 2; y++)
1076 if (!in_bounds(y, x2 + 2)) break;
1078 current_floor_ptr->grid_array[y][x2 + 2].info |= (CAVE_ROOM | CAVE_ICKY);
1080 place_outer_noperm_bold(y, x2 + 2);
1083 for (y = y1 - 1; y <= y2 + 1; y++)
1085 for (x = x1 - 1; x <= x2 + 1; x++)
1087 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1089 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
1091 /* Permanent walls */
1092 place_inner_perm_grid(g_ptr);
1097 /* dimensions of vertex array */
1100 num_vertices = m * n;
1102 /* initialize array of visited vertices */
1103 C_MAKE(visited, num_vertices, int);
1105 /* traverse the graph to create a spannng tree, pick a random root */
1106 r_visit(y1, x1, y2, x2, randint0(num_vertices), 0, visited);
1108 /* Make it look like a checker board vault */
1109 for (x = x1; x <= x2; x++)
1111 for (y = y1; y <= y2; y++)
1113 total = x - x1 + y - y1;
1114 /* If total is odd- and is a floor then make a wall */
1115 if ((total % 2 == 1) && is_floor_bold(y, x))
1117 place_inner_bold(y, x);
1122 /* Make a couple of entrances */
1125 /* left and right */
1126 y = randint1(dy) + dy / 2;
1127 place_inner_bold(y1 + y, x1 - 1);
1128 place_inner_bold(y1 + y, x2 + 1);
1132 /* top and bottom */
1133 x = randint1(dx) + dx / 2;
1134 place_inner_bold(y1 - 1, x1 + x);
1135 place_inner_bold(y2 + 1, x1 + x);
1138 /* Fill with monsters and treasure, highest difficulty */
1139 fill_treasure(x1, x2, y1, y2, 10);
1141 C_KILL(visited, num_vertices, int);
1144 /* Build a castle */
1145 /* Driver routine: clear the region and call the recursive
1148 *This makes a vault that looks like a castle/ city in the dungeon.
1150 static void build_castle_vault(POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1153 POSITION y1, x1, y2, x2;
1156 /* Pick a random room size */
1165 msg_print_wizard(CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
1167 /* generate the room */
1168 for (y = y1 - 1; y <= y2 + 1; y++)
1170 for (x = x1 - 1; x <= x2 + 1; x++)
1172 current_floor_ptr->grid_array[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
1173 /* Make everything a floor */
1174 place_floor_bold(y, x);
1178 /* Make the castle */
1179 build_recursive_room(x1, y1, x2, y2, randint1(5));
1181 /* Fill with monsters and treasure, low difficulty */
1182 fill_treasure(x1, x2, y1, y2, randint1(3));
1188 * @brief タイプ10の部屋…ランダム生成vault / Type 10 -- Random vaults
1191 bool build_type10(void)
1193 POSITION y0, x0, xsize, ysize, vtype;
1195 /* big enough to look good, small enough to be fairly common. */
1196 xsize = randint1(22) + 22;
1197 ysize = randint1(11) + 11;
1199 /* Find and reserve some space in the dungeon. Get center of room. */
1200 if (!find_space(&y0, &x0, ysize + 1, xsize + 1)) return FALSE;
1202 /* Select type of vault */
1203 #ifdef ALLOW_CAVERNS_AND_LAKES
1206 vtype = randint1(15);
1207 } while ((d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) &&
1208 ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
1209 #else /* ALLOW_CAVERNS_AND_LAKES */
1212 vtype = randint1(7);
1213 } while ((d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) &&
1214 ((vtype == 1) || (vtype == 3)));
1215 #endif /* ALLOW_CAVERNS_AND_LAKES */
1219 /* Build an appropriate room */
1220 case 1: case 9: build_bubble_vault(x0, y0, xsize, ysize); break;
1221 case 2: case 10: build_room_vault(x0, y0, xsize, ysize); break;
1222 case 3: case 11: build_cave_vault(x0, y0, xsize, ysize); break;
1223 case 4: case 12: build_maze_vault(x0, y0, xsize, ysize, TRUE); break;
1224 case 5: case 13: build_mini_c_vault(x0, y0, xsize, ysize); break;
1225 case 6: case 14: build_castle_vault(x0, y0, xsize, ysize); break;
1226 case 7: case 15: build_target_vault(x0, y0, xsize, ysize); break;
1227 #ifdef ALLOW_CAVERNS_AND_LAKES
1228 case 8: build_elemental_vault(x0, y0, xsize, ysize); break;
1229 #endif /* ALLOW_CAVERNS_AND_LAKES */
1230 /* I know how to add a few more... give me some time. */
1231 default: return FALSE;
1239 * @brief タイプ17の部屋…v_info.txtより固定特殊部屋を生成する / Type 17 -- fixed special room (see "v_info.txt")
1242 bool build_type17(void)
1244 vault_type *v_ptr = NULL;
1247 POSITION xval, yval;
1248 POSITION xoffset, yoffset;
1251 /* Pick a lesser vault */
1252 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
1254 /* Access a random vault record */
1255 v_ptr = &v_info[randint0(max_v_idx)];
1257 /* Accept the special fix room. */
1258 if (v_ptr->typ == 17) break;
1261 /* No lesser vault found */
1262 if (dummy >= SAFE_MAX_ATTEMPTS)
1264 msg_print_wizard(CHEAT_DUNGEON, _("固定特殊部屋を配置できませんでした。", "Could not place fixed special room."));
1268 /* pick type of transformation (0-7) */
1269 transno = randint0(8);
1271 /* calculate offsets */
1275 /* Some huge vault cannot be ratated to fit in the dungeon */
1276 if (x + 2 > current_floor_ptr->height - 2)
1278 /* Forbid 90 or 270 degree ratation */
1282 coord_trans(&x, &y, 0, 0, transno);
1302 /* Find and reserve some space in the dungeon. Get center of room. */
1303 if (!find_space(&yval, &xval, abs(y), abs(x))) return FALSE;
1309 msg_format_wizard(CHEAT_DUNGEON, _("特殊固定部屋(%s)を生成しました。", "Special Fix room (%s)."), v_name + v_ptr->name);
1311 /* Hack -- Build the vault */
1312 build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
1313 v_text + v_ptr->text, xoffset, yoffset, transno);