3 #include "rooms-vault.h"
5 #include "floor-generate.h"
18 * The vault generation arrays
25 * Maximum number of vaults in v_info.txt
30 * This function creates a random vault that looks like a collection of bubbles.
31 * It works by getting a set of coordinates that represent the center of each
32 * bubble. The entire room is made by seeing which bubble center is closest. If
33 * two centers are equidistant then the square is a wall, otherwise it is a floor.
34 * The only exception is for squares really near a center, these are always floor.
35 * (It looks better than without this check.)
37 * Note: If two centers are on the same point then this algorithm will create a
38 * blank bubble filled with walls. - This is prevented from happening.
40 static void build_bubble_vault(floor_type *floor_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
42 #define BUBBLENUM 10 /* number of bubbles */
44 /* array of center points of bubbles */
45 coord center[BUBBLENUM];
48 POSITION x = 0, y = 0;
49 u16b min1, min2, temp;
52 /* Offset from center to top left hand corner */
53 POSITION xhsize = xsize / 2;
54 POSITION yhsize = ysize / 2;
56 msg_print_wizard(CHEAT_DUNGEON, _("泡型ランダムVaultを生成しました。", "Room Vault."));
58 /* Allocate center of bubbles */
59 center[0].x = (byte)randint1(xsize - 3) + 1;
60 center[0].y = (byte)randint1(ysize - 3) + 1;
62 for (i = 1; i < BUBBLENUM; i++)
66 /* get center and check to see if it is unique */
71 x = randint1(xsize - 3) + 1;
72 y = randint1(ysize - 3) + 1;
74 for (j = 0; j < i; j++)
76 /* rough test to see if there is an overlap */
77 if ((x == center[j].x) && (y == center[j].y)) done = FALSE;
86 /* Top and bottom boundaries */
87 for (i = 0; i < xsize; i++)
89 int side_x = x0 - xhsize + i;
91 place_outer_noperm_bold(y0 - yhsize + 0, side_x);
92 floor_ptr->grid_array[y0 - yhsize + 0][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
93 place_outer_noperm_bold(y0 - yhsize + ysize - 1, side_x);
94 floor_ptr->grid_array[y0 - yhsize + ysize - 1][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
97 /* Left and right boundaries */
98 for (i = 1; i < ysize - 1; i++)
100 int side_y = y0 - yhsize + i;
102 place_outer_noperm_bold(side_y, x0 - xhsize + 0);
103 floor_ptr->grid_array[side_y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
104 place_outer_noperm_bold(side_y, x0 - xhsize + xsize - 1);
105 floor_ptr->grid_array[side_y][x0 - xhsize + xsize - 1].info |= (CAVE_ROOM | CAVE_ICKY);
108 /* Fill in middle with bubbles */
109 for (x = 1; x < xsize - 1; x++)
111 for (y = 1; y < ysize - 1; y++)
113 /* Get distances to two closest centers */
115 min1 = (u16b)distance(x, y, center[0].x, center[0].y);
116 min2 = (u16b)distance(x, y, center[1].x, center[1].y);
120 /* swap if in wrong order */
127 for (i = 2; i < BUBBLENUM; i++)
129 temp = (u16b)distance(x, y, center[i].x, center[i].y);
137 else if (temp < min2)
139 /* second smallest */
143 if (((min2 - min1) <= 2) && (!(min1 < 3)))
145 /* Boundary at midpoint+ not at inner region of bubble */
146 place_outer_noperm_bold(y0 - yhsize + y, x0 - xhsize + x);
150 /* middle of a bubble */
151 place_floor_bold(y0 - yhsize + y, x0 - xhsize + x);
154 /* clean up rest of flags */
155 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= (CAVE_ROOM | CAVE_ICKY);
159 /* Try to add some random doors */
160 for (i = 0; i < 500; i++)
162 x = randint1(xsize - 3) - xhsize + x0 + 1;
163 y = randint1(ysize - 3) - yhsize + y0 + 1;
167 /* Fill with monsters and treasure, low difficulty */
168 fill_treasure(floor_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5));
171 /* Create a random vault that looks like a collection of overlapping rooms */
172 static void build_room_vault(floor_type *floor_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
174 POSITION x1, x2, y1, y2, xhsize, yhsize;
177 /* get offset from center */
181 msg_print_wizard(CHEAT_DUNGEON, _("部屋型ランダムVaultを生成しました。", "Room Vault."));
183 /* fill area so don't get problems with arena levels */
184 for (x1 = 0; x1 < xsize; x1++)
186 POSITION x = x0 - xhsize + x1;
188 for (y1 = 0; y1 < ysize; y1++)
190 POSITION y = y0 - yhsize + y1;
192 place_extra_bold(y, x);
193 floor_ptr->grid_array[y][x].info &= (~CAVE_ICKY);
197 /* add ten random rooms */
198 for (i = 0; i < 10; i++)
200 x1 = randint1(xhsize) * 2 + x0 - xhsize;
201 x2 = randint1(xhsize) * 2 + x0 - xhsize;
202 y1 = randint1(yhsize) * 2 + y0 - yhsize;
203 y2 = randint1(yhsize) * 2 + y0 - yhsize;
204 build_room(floor_ptr, x1, x2, y1, y2);
207 /* Add some random doors */
208 for (i = 0; i < 500; i++)
210 x1 = randint1(xsize - 3) - xhsize + x0 + 1;
211 y1 = randint1(ysize - 3) - yhsize + y0 + 1;
215 /* Fill with monsters and treasure, high difficulty */
216 fill_treasure(floor_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5);
220 /* Create a random vault out of a fractal p_ptr->current_floor_ptr->grid_array */
221 static void build_cave_vault(POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
223 int grd, roug, cutoff;
224 bool done, light, room;
225 POSITION xhsize, yhsize, xsize, ysize, x, y;
227 /* round to make sizes even */
233 msg_print_wizard(CHEAT_DUNGEON, _("洞穴ランダムVaultを生成しました。", "Cave Vault."));
235 light = done = FALSE;
240 /* testing values for these parameters feel free to adjust */
241 grd = 1 << randint0(4);
243 /* want average of about 16 */
244 roug = randint1(8) * randint1(4);
247 cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
248 randint1(xsize / 4) + randint1(ysize / 4);
251 generate_hmap(p_ptr->current_floor_ptr, y0, x0, xsize, ysize, grd, roug, cutoff);
253 /* Convert to normal format+ clean up */
254 done = generate_fracave(p_ptr->current_floor_ptr, y0, x0, xsize, ysize, cutoff, light, room);
257 /* Set icky flag because is a vault */
258 for (x = 0; x <= xsize; x++)
260 for (y = 0; y <= ysize; y++)
262 p_ptr->current_floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
266 /* Fill with monsters and treasure, low difficulty */
267 fill_treasure(p_ptr->current_floor_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
273 * @brief Vault地形を回転、上下左右反転するための座標変換を返す / coordinate translation code
274 * @param x 変換したい点のX座標参照ポインタ
275 * @param y 変換したい点のY座標参照ポインタ
276 * @param xoffset Vault生成時の基準X座標
277 * @param yoffset Vault生成時の基準Y座標
278 * @param transno 処理ID
281 static void coord_trans(POSITION *x, POSITION *y, POSITION xoffset, POSITION yoffset, int transno)
287 * transno specifies what transformation is required. (0-7)
288 * The lower two bits indicate by how much the vault is rotated,
289 * and the upper bit indicates a reflection.
290 * This is done by using rotation matrices... however since
291 * these are mostly zeros for rotations by 90 degrees this can
292 * be expressed simply in terms of swapping and inverting the
293 * x and y coordinates.
295 for (i = 0; i < transno % 4; i++)
297 /* rotate by 90 degrees */
305 /* Reflect depending on status of 3rd bit. */
309 /* Add offsets so vault stays in the first quadrant */
316 * @brief Vaultをフロアに配置する / Hack -- fill in "vault" rooms
317 * @param yval 生成基準Y座標
318 * @param xval 生成基準X座標
319 * @param ymax VaultのYサイズ
320 * @param xmax VaultのXサイズ
321 * @param data Vaultのデータ文字列
322 * @param xoffset 変換基準X座標
323 * @param yoffset 変換基準Y座標
324 * @param transno 変換ID
327 static void build_vault(floor_type *floor_ptr, POSITION yval, POSITION xval, POSITION ymax, POSITION xmax, concptr data,
328 POSITION xoffset, POSITION yoffset, int transno)
330 POSITION dx, dy, x, y, i, j;
334 /* Place dungeon features and objects */
335 for (t = data, dy = 0; dy < ymax; dy++)
337 for (dx = 0; dx < xmax; dx++, t++)
339 /* prevent loop counter from being overwritten */
344 coord_trans(&i, &j, xoffset, yoffset, transno);
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 = &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(floor_ptr, y, x, DOOR_DEFAULT);
429 /* Secret glass doors */
431 place_secret_door(floor_ptr, y, x, DOOR_GLASS_DOOR);
432 if (is_closed_door(g_ptr->feat)) g_ptr->mimic = feat_glass_wall;
437 place_secret_door(floor_ptr, y, x, DOOR_CURTAIN);
445 /* Black market in a dungeon */
447 set_cave_feat(floor_ptr, y, x, feat_black_market);
448 store_init(NO_TOWN, STORE_BLACK);
453 set_cave_feat(floor_ptr, y, x, feat_pattern_start);
457 set_cave_feat(floor_ptr, y, x, feat_pattern_1);
461 set_cave_feat(floor_ptr, y, x, feat_pattern_2);
465 set_cave_feat(floor_ptr, y, x, feat_pattern_3);
469 set_cave_feat(floor_ptr, y, x, feat_pattern_4);
473 set_cave_feat(floor_ptr, y, x, feat_pattern_end);
477 set_cave_feat(floor_ptr, y, x, feat_pattern_exit);
481 /* Reward for Pattern walk */
482 floor_ptr->object_level = floor_ptr->base_level + 12;
483 place_object(y, x, AM_GOOD | AM_GREAT);
484 floor_ptr->object_level = floor_ptr->base_level;
488 set_cave_feat(floor_ptr, y, x, feat_shallow_water);
492 set_cave_feat(floor_ptr, y, x, feat_deep_water);
496 set_cave_feat(floor_ptr, y, x, feat_shallow_lava);
500 set_cave_feat(floor_ptr, y, x, feat_deep_lava);
504 set_cave_feat(floor_ptr, y, x, feat_shallow_acid_puddle);
508 set_cave_feat(floor_ptr, y, x, feat_deep_acid_puddle);
512 set_cave_feat(floor_ptr, y, x, feat_shallow_poisonous_puddle);
516 set_cave_feat(floor_ptr, y, x, feat_deep_poisonous_puddle);
520 set_cave_feat(floor_ptr, y, x, feat_cold_zone);
524 set_cave_feat(floor_ptr, y, x, feat_heavy_cold_zone);
528 set_cave_feat(floor_ptr, y, x, feat_electrical_zone);
532 set_cave_feat(floor_ptr, 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 if (transno % 2 == 0)
555 x = xval - (xmax / 2) + i;
556 y = yval - (ymax / 2) + j;
561 x = xval - (ymax / 2) + i;
562 y = yval - (xmax / 2) + j;
565 /* Hack -- skip "non-grids" */
566 if (*t == ' ') continue;
568 /* Analyze the symbol */
573 floor_ptr->monster_level = floor_ptr->base_level + 5;
574 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
575 floor_ptr->monster_level = floor_ptr->base_level;
582 floor_ptr->monster_level = floor_ptr->base_level + 11;
583 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
584 floor_ptr->monster_level = floor_ptr->base_level;
588 /* Meaner monster, plus treasure */
591 floor_ptr->monster_level = floor_ptr->base_level + 9;
592 place_monster(y, x, PM_ALLOW_SLEEP);
593 floor_ptr->monster_level = floor_ptr->base_level;
594 floor_ptr->object_level = floor_ptr->base_level + 7;
595 place_object(y, x, AM_GOOD);
596 floor_ptr->object_level = floor_ptr->base_level;
600 /* Nasty monster and treasure */
603 floor_ptr->monster_level = floor_ptr->base_level + 40;
604 place_monster(y, x, PM_ALLOW_SLEEP);
605 floor_ptr->monster_level = floor_ptr->base_level;
606 floor_ptr->object_level = floor_ptr->base_level + 20;
607 place_object(y, x, AM_GOOD | AM_GREAT);
608 floor_ptr->object_level = floor_ptr->base_level;
612 /* Monster and/or object */
615 if (randint0(100) < 50)
617 floor_ptr->monster_level = floor_ptr->base_level + 3;
618 place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
619 floor_ptr->monster_level = floor_ptr->base_level;
621 if (randint0(100) < 50)
623 floor_ptr->object_level = floor_ptr->base_level + 7;
624 place_object(y, x, 0L);
625 floor_ptr->object_level = floor_ptr->base_level;
638 * @brief タイプ7の部屋…v_info.txtより小型vaultを生成する / Type 7 -- simple vaults (see "v_info.txt")
641 bool build_type7(floor_type *floor_ptr)
643 vault_type *v_ptr = NULL;
647 POSITION xoffset, yoffset;
650 /* Pick a lesser vault */
651 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
653 /* Access a random vault record */
654 v_ptr = &v_info[randint0(max_v_idx)];
656 /* Accept the first lesser vault */
657 if (v_ptr->typ == 7) break;
660 /* No lesser vault found */
661 if (dummy >= SAFE_MAX_ATTEMPTS)
663 msg_print_wizard(CHEAT_DUNGEON, _("小型固定Vaultを配置できませんでした。", "Could not place lesser vault."));
667 /* pick type of transformation (0-7) */
668 transno = randint0(8);
670 /* calculate offsets */
674 /* Some huge vault cannot be ratated to fit in the dungeon */
675 if (x + 2 > floor_ptr->height - 2)
677 /* Forbid 90 or 270 degree ratation */
681 coord_trans(&x, &y, 0, 0, transno);
701 /* Find and reserve some space in the dungeon. Get center of room. */
702 if (!find_space(&yval, &xval, abs(y), abs(x))) return FALSE;
708 msg_format_wizard(CHEAT_DUNGEON, _("小型Vault(%s)を生成しました。", "Lesser vault (%s)."), v_name + v_ptr->name);
710 /* Hack -- Build the vault */
711 build_vault(floor_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
712 v_text + v_ptr->text, xoffset, yoffset, transno);
718 * @brief タイプ8の部屋…v_info.txtより大型vaultを生成する / Type 8 -- greater vaults (see "v_info.txt")
721 bool build_type8(floor_type *floor_ptr)
728 POSITION xoffset, yoffset;
730 /* Pick a greater vault */
731 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
733 /* Access a random vault record */
734 v_ptr = &v_info[randint0(max_v_idx)];
736 /* Accept the first greater vault */
737 if (v_ptr->typ == 8) break;
740 /* No greater vault found */
741 if (dummy >= SAFE_MAX_ATTEMPTS)
743 msg_print_wizard(CHEAT_DUNGEON, _("大型固定Vaultを配置できませんでした。", "Could not place greater vault."));
747 /* pick type of transformation (0-7) */
748 transno = randint0(8);
750 /* calculate offsets */
754 /* Some huge vault cannot be ratated to fit in the dungeon */
755 if (x + 2 > floor_ptr->height - 2)
757 /* Forbid 90 or 270 degree ratation */
761 coord_trans(&x, &y, 0, 0, transno);
782 * Try to allocate space for room. If fails, exit
784 * Hack -- Prepare a bit larger space (+2, +2) to
785 * prevent generation of vaults with no-entrance.
787 /* Find and reserve some space in the dungeon. Get center of room. */
788 if (!find_space(&yval, &xval, (POSITION)(abs(y) + 2), (POSITION)(abs(x) + 2))) return FALSE;
791 v_ptr = &v_info[76 + randint1(3)];
794 msg_format_wizard(CHEAT_DUNGEON, _("大型固定Vault(%s)を生成しました。", "Greater vault (%s)."), v_name + v_ptr->name);
796 /* Hack -- Build the vault */
797 build_vault(floor_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
798 v_text + v_ptr->text, xoffset, yoffset, transno);
805 * Build target vault.
806 * This is made by two concentric "crypts" with perpendicular
807 * walls creating the cross-hairs.
809 static void build_target_vault(floor_type *floor_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
813 /* Make a random metric */
814 POSITION h1, h2, h3, h4;
815 h1 = randint1(32) - 16;
818 h4 = randint1(32) - 16;
820 msg_print_wizard(CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Elemental Vault"));
822 /* work out outer radius */
833 for (x = x0 - rad; x <= x0 + rad; x++)
835 for (y = y0 - rad; y <= y0 + rad; y++)
837 /* clear room flag */
838 floor_ptr->grid_array[y][x].info &= ~(CAVE_ROOM);
840 /* Vault - so is "icky" */
841 floor_ptr->grid_array[y][x].info |= CAVE_ICKY;
843 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1)
845 /* inside- so is floor */
846 place_floor_bold(y, x);
850 /* make granite outside so arena works */
851 place_extra_bold(y, x);
854 /* proper boundary for arena */
855 if (((y + rad) == y0) || ((y - rad) == y0) ||
856 ((x + rad) == x0) || ((x - rad) == x0))
858 place_extra_bold(y, x);
863 /* Find visible outer walls and set to be FEAT_OUTER */
864 add_outer_wall(x0, y0, FALSE, x0 - rad - 1, y0 - rad - 1,
865 x0 + rad + 1, y0 + rad + 1);
868 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++)
870 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++)
872 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2)
874 /* Make an internal wall */
875 place_inner_bold(y, x);
880 /* Add perpendicular walls */
881 for (x = x0 - rad; x <= x0 + rad; x++)
883 place_inner_bold(y0, x);
886 for (y = y0 - rad; y <= y0 + rad; y++)
888 place_inner_bold(y, x0);
891 /* Make inner vault */
892 for (y = y0 - 1; y <= y0 + 1; y++)
894 place_inner_bold(y, x0 - 1);
895 place_inner_bold(y, x0 + 1);
897 for (x = x0 - 1; x <= x0 + 1; x++)
899 place_inner_bold(y0 - 1, x);
900 place_inner_bold(y0 + 1, x);
903 place_floor_bold(y0, x0);
906 /* Add doors to vault */
907 /* get two distances so can place doors relative to centre */
908 x = (rad - 2) / 4 + 1;
911 add_door(x0 + x, y0);
912 add_door(x0 + y, y0);
913 add_door(x0 - x, y0);
914 add_door(x0 - y, y0);
915 add_door(x0, y0 + x);
916 add_door(x0, y0 + y);
917 add_door(x0, y0 - x);
918 add_door(x0, y0 - y);
920 /* Fill with stuff - medium difficulty */
921 fill_treasure(floor_ptr, x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
925 #ifdef ALLOW_CAVERNS_AND_LAKES
927 * This routine uses a modified version of the lake code to make a
928 * distribution of some terrain type over the vault. This type
929 * depends on the dungeon depth.
931 * Miniture rooms are then scattered across the vault.
933 static void build_elemental_vault(floor_type *floor_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
938 POSITION xsize, ysize, xhsize, yhsize, x, y;
942 msg_print_wizard(CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
944 /* round to make sizes even */
950 if (floor_ptr->dun_level < 25)
952 /* Earth vault (Rubble) */
953 type = LAKE_T_EARTH_VAULT;
955 else if (floor_ptr->dun_level < 50)
957 /* Air vault (Trees) */
958 type = LAKE_T_AIR_VAULT;
960 else if (floor_ptr->dun_level < 75)
962 /* Water vault (shallow water) */
963 type = LAKE_T_WATER_VAULT;
967 /* Fire vault (shallow lava) */
968 type = LAKE_T_FIRE_VAULT;
973 /* testing values for these parameters: feel free to adjust */
974 grd = 1 << (randint0(3));
976 /* want average of about 16 */
977 roug = randint1(8) * randint1(4);
979 /* Make up size of various componants */
983 /* Deep water/lava */
984 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
986 /* Shallow boundary */
990 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, c3);
992 /* Convert to normal format+ clean up */
993 done = generate_lake(floor_ptr, y0, x0, xsize, ysize, c1, c2, c3, type);
996 /* Set icky flag because is a vault */
997 for (x = 0; x <= xsize; x++)
999 for (y = 0; y <= ysize; y++)
1001 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
1005 /* make a few rooms in the vault */
1006 for (i = 1; i <= (xsize * ysize) / 50; i++)
1008 build_small_room(floor_ptr, x0 + randint0(xsize - 4) - xsize / 2 + 2,
1009 y0 + randint0(ysize - 4) - ysize / 2 + 2);
1012 /* Fill with monsters and treasure, low difficulty */
1013 fill_treasure(floor_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1,
1014 y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
1016 #endif /* ALLOW_CAVERNS_AND_LAKES */
1019 /* Build a "mini" checkerboard vault
1021 * This is done by making a permanent wall maze and setting
1022 * the diagonal sqaures of the checker board to be granite.
1023 * The vault has two entrances on opposite sides to guarantee
1024 * a way to get in even if the vault abuts a side of the dungeon.
1026 static void build_mini_c_vault(floor_type *floor_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1029 POSITION y1, x1, y2, x2, y, x, total;
1030 int m, n, num_vertices;
1033 msg_print_wizard(CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
1035 /* Pick a random room size */
1045 /* generate the room */
1046 for (x = x1 - 2; x <= x2 + 2; x++)
1048 if (!in_bounds(floor_ptr, y1 - 2, x)) break;
1050 floor_ptr->grid_array[y1 - 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1052 place_outer_noperm_bold(y1 - 2, x);
1055 for (x = x1 - 2; x <= x2 + 2; x++)
1057 if (!in_bounds(floor_ptr, y2 + 2, x)) break;
1059 floor_ptr->grid_array[y2 + 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1061 place_outer_noperm_bold(y2 + 2, x);
1064 for (y = y1 - 2; y <= y2 + 2; y++)
1066 if (!in_bounds(floor_ptr, y, x1 - 2)) break;
1068 floor_ptr->grid_array[y][x1 - 2].info |= (CAVE_ROOM | CAVE_ICKY);
1070 place_outer_noperm_bold(y, x1 - 2);
1073 for (y = y1 - 2; y <= y2 + 2; y++)
1075 if (!in_bounds(floor_ptr, y, x2 + 2)) break;
1077 floor_ptr->grid_array[y][x2 + 2].info |= (CAVE_ROOM | CAVE_ICKY);
1079 place_outer_noperm_bold(y, x2 + 2);
1082 for (y = y1 - 1; y <= y2 + 1; y++)
1084 for (x = x1 - 1; x <= x2 + 1; x++)
1086 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1088 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
1090 /* Permanent walls */
1091 place_inner_perm_grid(g_ptr);
1096 /* dimensions of vertex array */
1099 num_vertices = m * n;
1101 /* initialize array of visited vertices */
1102 C_MAKE(visited, num_vertices, int);
1104 /* traverse the graph to create a spannng tree, pick a random root */
1105 r_visit(y1, x1, y2, x2, randint0(num_vertices), 0, visited);
1107 /* Make it look like a checker board vault */
1108 for (x = x1; x <= x2; x++)
1110 for (y = y1; y <= y2; y++)
1112 total = x - x1 + y - y1;
1113 /* If total is odd- and is a floor then make a wall */
1114 if ((total % 2 == 1) && is_floor_bold(floor_ptr, y, x))
1116 place_inner_bold(y, x);
1121 /* Make a couple of entrances */
1124 /* left and right */
1125 y = randint1(dy) + dy / 2;
1126 place_inner_bold(y1 + y, x1 - 1);
1127 place_inner_bold(y1 + y, x2 + 1);
1131 /* top and bottom */
1132 x = randint1(dx) + dx / 2;
1133 place_inner_bold(y1 - 1, x1 + x);
1134 place_inner_bold(y2 + 1, x1 + x);
1137 /* Fill with monsters and treasure, highest difficulty */
1138 fill_treasure(floor_ptr, x1, x2, y1, y2, 10);
1140 C_KILL(visited, num_vertices, int);
1143 /* Build a castle */
1144 /* Driver routine: clear the region and call the recursive
1147 *This makes a vault that looks like a castle/ city in the dungeon.
1149 static void build_castle_vault(floor_type *floor_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1152 POSITION y1, x1, y2, x2;
1155 /* Pick a random room size */
1164 msg_print_wizard(CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
1166 /* generate the room */
1167 for (y = y1 - 1; y <= y2 + 1; y++)
1169 for (x = x1 - 1; x <= x2 + 1; x++)
1171 floor_ptr->grid_array[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
1172 /* Make everything a floor */
1173 place_floor_bold(y, x);
1177 /* Make the castle */
1178 build_recursive_room(floor_ptr, x1, y1, x2, y2, randint1(5));
1180 /* Fill with monsters and treasure, low difficulty */
1181 fill_treasure(floor_ptr, x1, x2, y1, y2, randint1(3));
1187 * @brief タイプ10の部屋…ランダム生成vault / Type 10 -- Random vaults
1190 bool build_type10(floor_type *floor_ptr)
1192 POSITION y0, x0, xsize, ysize, vtype;
1194 /* big enough to look good, small enough to be fairly common. */
1195 xsize = randint1(22) + 22;
1196 ysize = randint1(11) + 11;
1198 /* Find and reserve some space in the dungeon. Get center of room. */
1199 if (!find_space(&y0, &x0, ysize + 1, xsize + 1)) return FALSE;
1201 /* Select type of vault */
1202 #ifdef ALLOW_CAVERNS_AND_LAKES
1205 vtype = randint1(15);
1206 } while ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) &&
1207 ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
1208 #else /* ALLOW_CAVERNS_AND_LAKES */
1211 vtype = randint1(7);
1212 } while ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) &&
1213 ((vtype == 1) || (vtype == 3)));
1214 #endif /* ALLOW_CAVERNS_AND_LAKES */
1218 /* Build an appropriate room */
1219 case 1: case 9: build_bubble_vault(floor_ptr, x0, y0, xsize, ysize); break;
1220 case 2: case 10: build_room_vault(floor_ptr, x0, y0, xsize, ysize); break;
1221 case 3: case 11: build_cave_vault(x0, y0, xsize, ysize); break;
1222 case 4: case 12: build_maze_vault(x0, y0, xsize, ysize, TRUE); break;
1223 case 5: case 13: build_mini_c_vault(floor_ptr, x0, y0, xsize, ysize); break;
1224 case 6: case 14: build_castle_vault(floor_ptr, x0, y0, xsize, ysize); break;
1225 case 7: case 15: build_target_vault(floor_ptr, x0, y0, xsize, ysize); break;
1226 #ifdef ALLOW_CAVERNS_AND_LAKES
1227 case 8: build_elemental_vault(floor_ptr, x0, y0, xsize, ysize); break;
1228 #endif /* ALLOW_CAVERNS_AND_LAKES */
1229 /* I know how to add a few more... give me some time. */
1230 default: return FALSE;
1238 * @brief タイプ17の部屋…v_info.txtより固定特殊部屋を生成する / Type 17 -- fixed special room (see "v_info.txt")
1241 bool build_type17(floor_type *floor_ptr)
1243 vault_type *v_ptr = NULL;
1246 POSITION xval, yval;
1247 POSITION xoffset, yoffset;
1250 /* Pick a lesser vault */
1251 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
1253 /* Access a random vault record */
1254 v_ptr = &v_info[randint0(max_v_idx)];
1256 /* Accept the special fix room. */
1257 if (v_ptr->typ == 17) break;
1260 /* No lesser vault found */
1261 if (dummy >= SAFE_MAX_ATTEMPTS)
1263 msg_print_wizard(CHEAT_DUNGEON, _("固定特殊部屋を配置できませんでした。", "Could not place fixed special room."));
1267 /* pick type of transformation (0-7) */
1268 transno = randint0(8);
1270 /* calculate offsets */
1274 /* Some huge vault cannot be ratated to fit in the dungeon */
1275 if (x + 2 > floor_ptr->height - 2)
1277 /* Forbid 90 or 270 degree ratation */
1281 coord_trans(&x, &y, 0, 0, transno);
1301 /* Find and reserve some space in the dungeon. Get center of room. */
1302 if (!find_space(&yval, &xval, abs(y), abs(x))) return FALSE;
1308 msg_format_wizard(CHEAT_DUNGEON, _("特殊固定部屋(%s)を生成しました。", "Special Fix room (%s)."), v_name + v_ptr->name);
1310 /* Hack -- Build the vault */
1311 build_vault(floor_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
1312 v_text + v_ptr->text, xoffset, yoffset, transno);