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(player_type *player_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;
85 /* Top and bottom boundaries */
86 floor_type *floor_ptr = player_ptr->current_floor_ptr;
87 for (i = 0; i < xsize; i++)
89 int side_x = x0 - xhsize + i;
91 place_bold(player_ptr, y0 - yhsize + 0, side_x, gb_outer_noperm);
92 floor_ptr->grid_array[y0 - yhsize + 0][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
93 place_bold(player_ptr, y0 - yhsize + ysize - 1, side_x, gb_outer_noperm);
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_bold(player_ptr, side_y, x0 - xhsize + 0, gb_outer_noperm);
103 floor_ptr->grid_array[side_y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
104 place_bold(player_ptr, side_y, x0 - xhsize + xsize - 1, gb_outer_noperm);
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_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, gb_outer_noperm);
150 /* middle of a bubble */
151 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, gb_floor);
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;
164 add_door(player_ptr, x, y);
167 /* Fill with monsters and treasure, low difficulty */
168 fill_treasure(player_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(player_type *player_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 floor_type *floor_ptr = player_ptr->current_floor_ptr;
185 for (x1 = 0; x1 < xsize; x1++)
187 POSITION x = x0 - xhsize + x1;
189 for (y1 = 0; y1 < ysize; y1++)
191 POSITION y = y0 - yhsize + y1;
193 place_bold(player_ptr, y, x, gb_extra);
194 floor_ptr->grid_array[y][x].info &= (~CAVE_ICKY);
198 /* add ten random rooms */
199 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++)
211 x1 = randint1(xsize - 3) - xhsize + x0 + 1;
212 y1 = randint1(ysize - 3) - yhsize + y0 + 1;
213 add_door(player_ptr, x1, y1);
216 /* Fill with monsters and treasure, high difficulty */
217 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5);
221 /* Create a random vault out of a fractal grid */
222 static void build_cave_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
224 int grd, roug, cutoff;
225 bool done, light, room;
226 POSITION xhsize, yhsize, xsize, ysize, x, y;
228 /* round to make sizes even */
234 msg_print_wizard(CHEAT_DUNGEON, _("洞穴ランダムVaultを生成しました。", "Cave Vault."));
236 light = done = FALSE;
239 floor_type *floor_ptr = player_ptr->current_floor_ptr;
242 /* testing values for these parameters feel free to adjust */
243 grd = 1 << randint0(4);
245 /* want average of about 16 */
246 roug = randint1(8) * randint1(4);
249 cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
250 randint1(xsize / 4) + randint1(ysize / 4);
253 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, cutoff);
255 /* Convert to normal format+ clean up */
256 done = generate_fracave(player_ptr, y0, x0, xsize, ysize, cutoff, light, room);
259 /* Set icky flag because is a vault */
260 for (x = 0; x <= xsize; x++)
262 for (y = 0; y <= ysize; y++)
264 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
268 /* Fill with monsters and treasure, low difficulty */
269 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
274 * @brief Vault地形を回転、上下左右反転するための座標変換を返す / coordinate translation code
275 * @param x 変換したい点のX座標参照ポインタ
276 * @param y 変換したい点のY座標参照ポインタ
277 * @param xoffset Vault生成時の基準X座標
278 * @param yoffset Vault生成時の基準Y座標
279 * @param transno 処理ID
282 static void coord_trans(POSITION *x, POSITION *y, POSITION xoffset, POSITION yoffset, int transno)
288 * transno specifies what transformation is required. (0-7)
289 * The lower two bits indicate by how much the vault is rotated,
290 * and the upper bit indicates a reflection.
291 * This is done by using rotation matrices... however since
292 * these are mostly zeros for rotations by 90 degrees this can
293 * be expressed simply in terms of swapping and inverting the
294 * x and y coordinates.
296 for (i = 0; i < transno % 4; i++)
298 /* rotate by 90 degrees */
306 /* Reflect depending on status of 3rd bit. */
310 /* Add offsets so vault stays in the first quadrant */
317 * @brief Vaultをフロアに配置する / Hack -- fill in "vault" rooms
318 * @param player_ptr プレーヤーへの参照ポインタ
319 * @param yval 生成基準Y座標
320 * @param xval 生成基準X座標
321 * @param ymax VaultのYサイズ
322 * @param xmax VaultのXサイズ
323 * @param data Vaultのデータ文字列
324 * @param xoffset 変換基準X座標
325 * @param yoffset 変換基準Y座標
326 * @param transno 変換ID
329 static void build_vault(player_type *player_ptr, POSITION yval, POSITION xval, POSITION ymax, POSITION xmax, concptr data,
330 POSITION xoffset, POSITION yoffset, int transno)
332 POSITION dx, dy, x, y, i, j;
336 /* Place dungeon features and objects */
337 floor_type *floor_ptr = player_ptr->current_floor_ptr;
338 for (t = data, dy = 0; dy < ymax; dy++)
340 for (dx = 0; dx < xmax; dx++, t++)
342 /* prevent loop counter from being overwritten */
347 coord_trans(&i, &j, xoffset, yoffset, transno);
349 if (transno % 2 == 0)
352 x = xval - (xmax / 2) + i;
353 y = yval - (ymax / 2) + j;
358 x = xval - (ymax / 2) + i;
359 y = yval - (xmax / 2) + j;
362 /* Hack -- skip "non-grids" */
363 if (*t == ' ') continue;
364 g_ptr = &floor_ptr->grid_array[y][x];
366 /* Lay down a floor */
367 place_grid(player_ptr, g_ptr, gb_floor);
369 /* Remove any mimic */
372 /* Part of a vault */
373 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
375 /* Analyze the grid */
378 /* Granite wall (outer) */
380 place_grid(player_ptr, g_ptr, gb_outer_noperm);
383 /* Granite wall (inner) */
385 place_grid(player_ptr, g_ptr, gb_inner);
388 /* Glass wall (inner) */
390 place_grid(player_ptr, g_ptr, gb_inner);
391 g_ptr->feat = feat_glass_wall;
394 /* Permanent wall (inner) */
396 place_grid(player_ptr, g_ptr, gb_inner_perm);
399 /* Permanent glass wall (inner) */
401 place_grid(player_ptr, g_ptr, gb_inner_perm);
402 g_ptr->feat = feat_permanent_glass_wall;
407 if (randint0(100) < 75)
409 place_object(player_ptr, y, x, 0L);
413 place_trap(player_ptr, y, x);
419 place_object(player_ptr, y, x, 0L);
424 g_ptr->feat = feat_tree;
429 place_secret_door(player_ptr, y, x, DOOR_DEFAULT);
432 /* Secret glass doors */
434 place_secret_door(player_ptr, y, x, DOOR_GLASS_DOOR);
435 if (is_closed_door(player_ptr, g_ptr->feat)) g_ptr->mimic = feat_glass_wall;
440 place_secret_door(player_ptr, y, x, DOOR_CURTAIN);
445 place_trap(player_ptr, y, x);
448 /* Black market in a dungeon */
450 set_cave_feat(floor_ptr, y, x, feat_black_market);
451 store_init(NO_TOWN, STORE_BLACK);
456 set_cave_feat(floor_ptr, y, x, feat_pattern_start);
460 set_cave_feat(floor_ptr, y, x, feat_pattern_1);
464 set_cave_feat(floor_ptr, y, x, feat_pattern_2);
468 set_cave_feat(floor_ptr, y, x, feat_pattern_3);
472 set_cave_feat(floor_ptr, y, x, feat_pattern_4);
476 set_cave_feat(floor_ptr, y, x, feat_pattern_end);
480 set_cave_feat(floor_ptr, y, x, feat_pattern_exit);
484 /* Reward for Pattern walk */
485 floor_ptr->object_level = floor_ptr->base_level + 12;
486 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
487 floor_ptr->object_level = floor_ptr->base_level;
491 set_cave_feat(floor_ptr, y, x, feat_shallow_water);
495 set_cave_feat(floor_ptr, y, x, feat_deep_water);
499 set_cave_feat(floor_ptr, y, x, feat_shallow_lava);
503 set_cave_feat(floor_ptr, y, x, feat_deep_lava);
507 set_cave_feat(floor_ptr, y, x, feat_shallow_acid_puddle);
511 set_cave_feat(floor_ptr, y, x, feat_deep_acid_puddle);
515 set_cave_feat(floor_ptr, y, x, feat_shallow_poisonous_puddle);
519 set_cave_feat(floor_ptr, y, x, feat_deep_poisonous_puddle);
523 set_cave_feat(floor_ptr, y, x, feat_cold_zone);
527 set_cave_feat(floor_ptr, y, x, feat_heavy_cold_zone);
531 set_cave_feat(floor_ptr, y, x, feat_electrical_zone);
535 set_cave_feat(floor_ptr, y, x, feat_heavy_electrical_zone);
543 /* Place dungeon monsters and objects */
544 for (t = data, dy = 0; dy < ymax; dy++)
546 for (dx = 0; dx < xmax; dx++, t++)
548 /* prevent loop counter from being overwritten */
553 coord_trans(&i, &j, xoffset, yoffset, transno);
555 if (transno % 2 == 0)
558 x = xval - (xmax / 2) + i;
559 y = yval - (ymax / 2) + j;
564 x = xval - (ymax / 2) + i;
565 y = yval - (xmax / 2) + j;
568 /* Hack -- skip "non-grids" */
569 if (*t == ' ') continue;
571 /* Analyze the symbol */
576 floor_ptr->monster_level = floor_ptr->base_level + 5;
577 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
578 floor_ptr->monster_level = floor_ptr->base_level;
585 floor_ptr->monster_level = floor_ptr->base_level + 11;
586 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
587 floor_ptr->monster_level = floor_ptr->base_level;
591 /* Meaner monster, plus treasure */
594 floor_ptr->monster_level = floor_ptr->base_level + 9;
595 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
596 floor_ptr->monster_level = floor_ptr->base_level;
597 floor_ptr->object_level = floor_ptr->base_level + 7;
598 place_object(player_ptr, y, x, AM_GOOD);
599 floor_ptr->object_level = floor_ptr->base_level;
603 /* Nasty monster and treasure */
606 floor_ptr->monster_level = floor_ptr->base_level + 40;
607 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
608 floor_ptr->monster_level = floor_ptr->base_level;
609 floor_ptr->object_level = floor_ptr->base_level + 20;
610 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
611 floor_ptr->object_level = floor_ptr->base_level;
615 /* Monster and/or object */
618 if (randint0(100) < 50)
620 floor_ptr->monster_level = floor_ptr->base_level + 3;
621 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
622 floor_ptr->monster_level = floor_ptr->base_level;
624 if (randint0(100) < 50)
626 floor_ptr->object_level = floor_ptr->base_level + 7;
627 place_object(player_ptr, y, x, 0L);
628 floor_ptr->object_level = floor_ptr->base_level;
639 * @brief タイプ7の部屋…v_info.txtより小型vaultを生成する / Type 7 -- simple vaults (see "v_info.txt")
642 bool build_type7(player_type *player_ptr)
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 floor_type *floor_ptr = player_ptr->current_floor_ptr;
677 if (x + 2 > floor_ptr->height - 2)
679 /* Forbid 90 or 270 degree ratation */
683 coord_trans(&x, &y, 0, 0, transno);
703 /* Find and reserve some space in the dungeon. Get center of room. */
704 if (!find_space(player_ptr, &yval, &xval, abs(y), abs(x))) return FALSE;
710 msg_format_wizard(CHEAT_DUNGEON, _("小型Vault(%s)を生成しました。", "Lesser vault (%s)."), v_name + v_ptr->name);
712 /* Hack -- Build the vault */
713 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
714 v_text + v_ptr->text, xoffset, yoffset, transno);
721 * @brief タイプ8の部屋…v_info.txtより大型vaultを生成する / Type 8 -- greater vaults (see "v_info.txt")
724 bool build_type8(player_type *player_ptr)
731 POSITION xoffset, yoffset;
733 /* Pick a greater vault */
734 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
736 /* Access a random vault record */
737 v_ptr = &v_info[randint0(max_v_idx)];
739 /* Accept the first greater vault */
740 if (v_ptr->typ == 8) break;
743 /* No greater vault found */
744 if (dummy >= SAFE_MAX_ATTEMPTS)
746 msg_print_wizard(CHEAT_DUNGEON, _("大型固定Vaultを配置できませんでした。", "Could not place greater vault."));
750 /* pick type of transformation (0-7) */
751 transno = randint0(8);
753 /* calculate offsets */
757 /* Some huge vault cannot be ratated to fit in the dungeon */
758 floor_type *floor_ptr = player_ptr->current_floor_ptr;
759 if (x + 2 > floor_ptr->height - 2)
761 /* Forbid 90 or 270 degree ratation */
765 coord_trans(&x, &y, 0, 0, transno);
786 * Try to allocate space for room. If fails, exit
788 * Hack -- Prepare a bit larger space (+2, +2) to
789 * prevent generation of vaults with no-entrance.
791 /* Find and reserve some space in the dungeon. Get center of room. */
792 if (!find_space(player_ptr, &yval, &xval, (POSITION)(abs(y) + 2), (POSITION)(abs(x) + 2))) return FALSE;
795 v_ptr = &v_info[76 + randint1(3)];
798 msg_format_wizard(CHEAT_DUNGEON, _("大型固定Vault(%s)を生成しました。", "Greater vault (%s)."), v_name + v_ptr->name);
800 /* Hack -- Build the vault */
801 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
802 v_text + v_ptr->text, xoffset, yoffset, transno);
809 * Build target vault.
810 * This is made by two concentric "crypts" with perpendicular
811 * walls creating the cross-hairs.
813 static void build_target_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
817 /* Make a random metric */
818 POSITION h1, h2, h3, h4;
819 h1 = randint1(32) - 16;
822 h4 = randint1(32) - 16;
824 msg_print_wizard(CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Elemental Vault"));
826 /* work out outer radius */
837 floor_type *floor_ptr = player_ptr->current_floor_ptr;
838 for (x = x0 - rad; x <= x0 + rad; x++)
840 for (y = y0 - rad; y <= y0 + rad; y++)
842 /* clear room flag */
843 floor_ptr->grid_array[y][x].info &= ~(CAVE_ROOM);
845 /* Vault - so is "icky" */
846 floor_ptr->grid_array[y][x].info |= CAVE_ICKY;
848 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1)
850 /* inside- so is floor */
851 place_bold(player_ptr, y, x, gb_floor);
855 /* make granite outside so arena works */
856 place_bold(player_ptr, y, x, gb_extra);
859 /* proper boundary for arena */
860 if (((y + rad) == y0) || ((y - rad) == y0) ||
861 ((x + rad) == x0) || ((x - rad) == x0))
863 place_bold(player_ptr, y, x, gb_extra);
868 /* Find visible outer walls and set to be FEAT_OUTER */
869 add_outer_wall(player_ptr, x0, y0, FALSE, x0 - rad - 1, y0 - rad - 1, x0 + rad + 1, y0 + rad + 1);
872 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++)
874 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++)
876 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2)
878 /* Make an internal wall */
879 place_bold(player_ptr, y, x, gb_inner);
884 /* Add perpendicular walls */
885 for (x = x0 - rad; x <= x0 + rad; x++)
887 place_bold(player_ptr, y0, x, gb_inner);
890 for (y = y0 - rad; y <= y0 + rad; y++)
892 place_bold(player_ptr, y, x0, gb_inner);
895 /* Make inner vault */
896 for (y = y0 - 1; y <= y0 + 1; y++)
898 place_bold(player_ptr, y, x0 - 1, gb_inner);
899 place_bold(player_ptr, y, x0 + 1, gb_inner);
901 for (x = x0 - 1; x <= x0 + 1; x++)
903 place_bold(player_ptr, y0 - 1, x, gb_inner);
904 place_bold(player_ptr, y0 + 1, x, gb_inner);
907 place_bold(player_ptr, y0, x0, gb_floor);
910 /* Add doors to vault */
911 /* get two distances so can place doors relative to centre */
912 x = (rad - 2) / 4 + 1;
915 add_door(player_ptr, x0 + x, y0);
916 add_door(player_ptr, x0 + y, y0);
917 add_door(player_ptr, x0 - x, y0);
918 add_door(player_ptr, x0 - y, y0);
919 add_door(player_ptr, x0, y0 + x);
920 add_door(player_ptr, x0, y0 + y);
921 add_door(player_ptr, x0, y0 - x);
922 add_door(player_ptr, x0, y0 - y);
924 /* Fill with stuff - medium difficulty */
925 fill_treasure(player_ptr, x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
930 * This routine uses a modified version of the lake code to make a
931 * distribution of some terrain type over the vault. This type
932 * depends on the dungeon depth.
934 * Miniture rooms are then scattered across the vault.
936 static void build_elemental_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
941 POSITION xsize, ysize, xhsize, yhsize, x, y;
945 msg_print_wizard(CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
947 /* round to make sizes even */
953 floor_type *floor_ptr = player_ptr->current_floor_ptr;
954 if (floor_ptr->dun_level < 25)
956 /* Earth vault (Rubble) */
957 type = LAKE_T_EARTH_VAULT;
959 else if (floor_ptr->dun_level < 50)
961 /* Air vault (Trees) */
962 type = LAKE_T_AIR_VAULT;
964 else if (floor_ptr->dun_level < 75)
966 /* Water vault (shallow water) */
967 type = LAKE_T_WATER_VAULT;
971 /* Fire vault (shallow lava) */
972 type = LAKE_T_FIRE_VAULT;
977 /* testing values for these parameters: feel free to adjust */
978 grd = 1 << (randint0(3));
980 /* want average of about 16 */
981 roug = randint1(8) * randint1(4);
983 /* Make up size of various componants */
987 /* Deep water/lava */
988 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
990 /* Shallow boundary */
994 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, c3);
996 /* Convert to normal format+ clean up */
997 done = generate_lake(player_ptr, y0, x0, xsize, ysize, c1, c2, c3, type);
1000 /* Set icky flag because is a vault */
1001 for (x = 0; x <= xsize; x++)
1003 for (y = 0; y <= ysize; y++)
1005 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
1009 /* make a few rooms in the vault */
1010 for (i = 1; i <= (xsize * ysize) / 50; i++)
1012 build_small_room(player_ptr, x0 + randint0(xsize - 4) - xsize / 2 + 2,
1013 y0 + randint0(ysize - 4) - ysize / 2 + 2);
1016 /* Fill with monsters and treasure, low difficulty */
1017 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1,
1018 y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
1022 /* Build a "mini" checkerboard vault
1024 * This is done by making a permanent wall maze and setting
1025 * the diagonal sqaures of the checker board to be granite.
1026 * The vault has two entrances on opposite sides to guarantee
1027 * a way to get in even if the vault abuts a side of the dungeon.
1029 static void build_mini_c_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1032 POSITION y1, x1, y2, x2, y, x, total;
1033 int m, n, num_vertices;
1036 msg_print_wizard(CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
1038 /* Pick a random room size */
1048 /* generate the room */
1049 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1050 for (x = x1 - 2; x <= x2 + 2; x++)
1052 if (!in_bounds(floor_ptr, y1 - 2, x)) break;
1054 floor_ptr->grid_array[y1 - 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1056 place_bold(player_ptr, y1 - 2, x, gb_outer_noperm);
1059 for (x = x1 - 2; x <= x2 + 2; x++)
1061 if (!in_bounds(floor_ptr, y2 + 2, x)) break;
1063 floor_ptr->grid_array[y2 + 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1065 place_bold(player_ptr, y2 + 2, x, gb_outer_noperm);
1068 for (y = y1 - 2; y <= y2 + 2; y++)
1070 if (!in_bounds(floor_ptr, y, x1 - 2)) break;
1072 floor_ptr->grid_array[y][x1 - 2].info |= (CAVE_ROOM | CAVE_ICKY);
1074 place_bold(player_ptr, y, x1 - 2, gb_outer_noperm);
1077 for (y = y1 - 2; y <= y2 + 2; y++)
1079 if (!in_bounds(floor_ptr, y, x2 + 2)) break;
1081 floor_ptr->grid_array[y][x2 + 2].info |= (CAVE_ROOM | CAVE_ICKY);
1083 place_bold(player_ptr, y, x2 + 2, gb_outer_noperm);
1086 for (y = y1 - 1; y <= y2 + 1; y++)
1088 for (x = x1 - 1; x <= x2 + 1; x++)
1090 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1092 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
1094 /* Permanent walls */
1095 place_grid(player_ptr, g_ptr, gb_inner_perm);
1100 /* dimensions of vertex array */
1103 num_vertices = m * n;
1105 /* initialize array of visited vertices */
1106 C_MAKE(visited, num_vertices, int);
1108 /* traverse the graph to create a spannng tree, pick a random root */
1109 r_visit(player_ptr, y1, x1, y2, x2, randint0(num_vertices), 0, visited);
1111 /* Make it look like a checker board vault */
1112 for (x = x1; x <= x2; x++)
1114 for (y = y1; y <= y2; y++)
1116 total = x - x1 + y - y1;
1117 /* If total is odd- and is a floor then make a wall */
1118 if ((total % 2 == 1) && is_floor_bold(floor_ptr, y, x))
1120 place_bold(player_ptr, y, x, gb_inner);
1125 /* Make a couple of entrances */
1128 /* left and right */
1129 y = randint1(dy) + dy / 2;
1130 place_bold(player_ptr, y1 + y, x1 - 1, gb_inner);
1131 place_bold(player_ptr, y1 + y, x2 + 1, gb_inner);
1135 /* top and bottom */
1136 x = randint1(dx) + dx / 2;
1137 place_bold(player_ptr, y1 - 1, x1 + x, gb_inner);
1138 place_bold(player_ptr, y2 + 1, x1 + x, gb_inner);
1141 /* Fill with monsters and treasure, highest difficulty */
1142 fill_treasure(player_ptr, x1, x2, y1, y2, 10);
1144 C_KILL(visited, num_vertices, int);
1147 /* Build a castle */
1148 /* Driver routine: clear the region and call the recursive
1151 *This makes a vault that looks like a castle/ city in the dungeon.
1153 static void build_castle_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1156 POSITION y1, x1, y2, x2;
1159 /* Pick a random room size */
1168 msg_print_wizard(CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
1170 /* generate the room */
1171 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1172 for (y = y1 - 1; y <= y2 + 1; y++)
1174 for (x = x1 - 1; x <= x2 + 1; x++)
1176 floor_ptr->grid_array[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
1177 /* Make everything a floor */
1178 place_bold(player_ptr, y, x, gb_floor);
1182 /* Make the castle */
1183 build_recursive_room(player_ptr, x1, y1, x2, y2, randint1(5));
1185 /* Fill with monsters and treasure, low difficulty */
1186 fill_treasure(player_ptr, x1, x2, y1, y2, randint1(3));
1191 * @brief タイプ10の部屋…ランダム生成vault / Type 10 -- Random vaults
1192 * @param player_ptr プレーヤーへの参照ポインタ
1195 bool build_type10(player_type *player_ptr)
1197 POSITION y0, x0, xsize, ysize, vtype;
1199 /* big enough to look good, small enough to be fairly common. */
1200 xsize = randint1(22) + 22;
1201 ysize = randint1(11) + 11;
1203 /* Find and reserve some space in the dungeon. Get center of room. */
1204 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1205 if (!find_space(player_ptr, &y0, &x0, ysize + 1, xsize + 1)) return FALSE;
1207 /* Select type of vault */
1210 vtype = randint1(15);
1211 } while ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) &&
1212 ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
1216 /* Build an appropriate room */
1217 case 1: case 9: build_bubble_vault(player_ptr, x0, y0, xsize, ysize); break;
1218 case 2: case 10: build_room_vault(player_ptr, x0, y0, xsize, ysize); break;
1219 case 3: case 11: build_cave_vault(player_ptr, x0, y0, xsize, ysize); break;
1220 case 4: case 12: build_maze_vault(player_ptr, x0, y0, xsize, ysize, TRUE); break;
1221 case 5: case 13: build_mini_c_vault(player_ptr, x0, y0, xsize, ysize); break;
1222 case 6: case 14: build_castle_vault(player_ptr, x0, y0, xsize, ysize); break;
1223 case 7: case 15: build_target_vault(player_ptr, x0, y0, xsize, ysize); break;
1224 case 8: build_elemental_vault(player_ptr, x0, y0, xsize, ysize); break;
1225 /* I know how to add a few more... give me some time. */
1226 default: return FALSE;
1234 * @brief タイプ17の部屋…v_info.txtより固定特殊部屋を生成する / Type 17 -- fixed special room (see "v_info.txt")
1237 bool build_type17(player_type *player_ptr)
1239 vault_type *v_ptr = NULL;
1242 POSITION xval, yval;
1243 POSITION xoffset, yoffset;
1246 /* Pick a lesser vault */
1247 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
1249 /* Access a random vault record */
1250 v_ptr = &v_info[randint0(max_v_idx)];
1252 /* Accept the special fix room. */
1253 if (v_ptr->typ == 17) break;
1256 /* No lesser vault found */
1257 if (dummy >= SAFE_MAX_ATTEMPTS)
1259 msg_print_wizard(CHEAT_DUNGEON, _("固定特殊部屋を配置できませんでした。", "Could not place fixed special room."));
1263 /* pick type of transformation (0-7) */
1264 transno = randint0(8);
1266 /* calculate offsets */
1270 /* Some huge vault cannot be ratated to fit in the dungeon */
1271 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1272 if (x + 2 > floor_ptr->height - 2)
1274 /* Forbid 90 or 270 degree ratation */
1278 coord_trans(&x, &y, 0, 0, transno);
1298 /* Find and reserve some space in the dungeon. Get center of room. */
1299 if (!find_space(player_ptr, &yval, &xval, abs(y), abs(x))) return FALSE;
1305 msg_format_wizard(CHEAT_DUNGEON, _("特殊固定部屋(%s)を生成しました。", "Special Fix room (%s)."), v_name + v_ptr->name);
1307 /* Hack -- Build the vault */
1308 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
1309 v_text + v_ptr->text, xoffset, yoffset, transno);