7 #include "room/rooms-vault.h"
8 #include "dungeon/dungeon-flag-types.h"
9 #include "dungeon/dungeon.h"
10 #include "floor/cave.h"
11 #include "floor/floor-generator-util.h"
12 #include "floor/floor-generator.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/lake-types.h"
26 #include "room/rooms-builder.h"
27 #include "room/rooms-maze-vault.h"
28 #include "room/space-finder.h"
29 #include "room/treasure-deployment.h"
30 #include "store/store-util.h"
31 #include "store/store.h"
32 #include "system/dungeon-data-definition.h"
33 #include "system/floor-type-definition.h"
34 #include "system/player-type-definition.h"
35 #include "wizard/wizard-messages.h"
38 * The vault generation arrays
40 std::vector<vault_type> v_info;
43 * Maximum number of vaults in v_info.txt
48 * This function creates a random vault that looks like a collection of bubbles.
49 * It works by getting a set of coordinates that represent the center of each
50 * bubble. The entire room is made by seeing which bubble center is closest. If
51 * two centers are equidistant then the square is a wall, otherwise it is a floor.
52 * The only exception is for squares really near a center, these are always floor.
53 * (It looks better than without this check.)
55 * Note: If two centers are on the same point then this algorithm will create a
56 * blank bubble filled with walls. - This is prevented from happening.
58 static void build_bubble_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
60 #define BUBBLENUM 10 /* number of bubbles */
62 /* array of center points of bubbles */
63 coord center[BUBBLENUM];
66 POSITION x = 0, y = 0;
67 u16b min1, min2, temp;
70 /* Offset from center to top left hand corner */
71 POSITION xhsize = xsize / 2;
72 POSITION yhsize = ysize / 2;
74 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("泡型ランダムVaultを生成しました。", "Bubble-shaped Vault."));
76 /* Allocate center of bubbles */
77 center[0].x = (byte)randint1(xsize - 3) + 1;
78 center[0].y = (byte)randint1(ysize - 3) + 1;
80 for (i = 1; i < BUBBLENUM; i++) {
83 /* get center and check to see if it is unique */
87 x = randint1(xsize - 3) + 1;
88 y = randint1(ysize - 3) + 1;
90 for (j = 0; j < i; j++) {
91 /* rough test to see if there is an overlap */
92 if ((x == center[j].x) && (y == center[j].y))
101 /* Top and bottom boundaries */
102 floor_type *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 = (u16b)distance(x, y, center[0].x, center[0].y);
128 min2 = (u16b)distance(x, y, center[1].x, center[1].y);
131 /* swap if in wrong order */
138 for (i = 2; i < BUBBLENUM; i++) {
139 temp = (u16b)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(player_type *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 floor_type *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(player_type *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 floor_type *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 player_type *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 floor_type *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" */
348 g_ptr = &floor_ptr->grid_array[y][x];
350 /* Lay down a floor */
351 place_grid(player_ptr, g_ptr, GB_FLOOR);
353 /* Remove any mimic */
356 /* Part of a vault */
357 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
359 /* Analyze the grid */
361 /* Granite wall (outer) */
363 place_grid(player_ptr, g_ptr, GB_OUTER_NOPERM);
366 /* Granite wall (inner) */
368 place_grid(player_ptr, g_ptr, GB_INNER);
371 /* Glass wall (inner) */
373 place_grid(player_ptr, g_ptr, GB_INNER);
374 g_ptr->feat = feat_glass_wall;
377 /* Permanent wall (inner) */
379 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
382 /* Permanent glass wall (inner) */
384 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
385 g_ptr->feat = feat_permanent_glass_wall;
390 if (randint0(100) < 75) {
391 place_object(player_ptr, y, x, 0L);
393 place_trap(player_ptr, y, x);
399 place_object(player_ptr, y, x, 0L);
404 g_ptr->feat = feat_tree;
409 place_secret_door(player_ptr, y, x, DOOR_DEFAULT);
412 /* Secret glass doors */
414 place_secret_door(player_ptr, y, x, DOOR_GLASS_DOOR);
415 if (is_closed_door(player_ptr, g_ptr->feat))
416 g_ptr->mimic = feat_glass_wall;
421 place_secret_door(player_ptr, y, x, DOOR_CURTAIN);
426 place_trap(player_ptr, y, x);
429 /* Black market in a dungeon */
431 set_cave_feat(floor_ptr, y, x, feat_black_market);
432 store_init(NO_TOWN, STORE_BLACK);
437 set_cave_feat(floor_ptr, y, x, feat_pattern_start);
441 set_cave_feat(floor_ptr, y, x, feat_pattern_1);
445 set_cave_feat(floor_ptr, y, x, feat_pattern_2);
449 set_cave_feat(floor_ptr, y, x, feat_pattern_3);
453 set_cave_feat(floor_ptr, y, x, feat_pattern_4);
457 set_cave_feat(floor_ptr, y, x, feat_pattern_end);
461 set_cave_feat(floor_ptr, y, x, feat_pattern_exit);
465 /* Reward for Pattern walk */
466 floor_ptr->object_level = floor_ptr->base_level + 12;
467 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
468 floor_ptr->object_level = floor_ptr->base_level;
472 set_cave_feat(floor_ptr, y, x, feat_shallow_water);
476 set_cave_feat(floor_ptr, y, x, feat_deep_water);
480 set_cave_feat(floor_ptr, y, x, feat_shallow_lava);
484 set_cave_feat(floor_ptr, y, x, feat_deep_lava);
488 set_cave_feat(floor_ptr, y, x, feat_shallow_acid_puddle);
492 set_cave_feat(floor_ptr, y, x, feat_deep_acid_puddle);
496 set_cave_feat(floor_ptr, y, x, feat_shallow_poisonous_puddle);
500 set_cave_feat(floor_ptr, y, x, feat_deep_poisonous_puddle);
504 set_cave_feat(floor_ptr, y, x, feat_cold_zone);
508 set_cave_feat(floor_ptr, y, x, feat_heavy_cold_zone);
512 set_cave_feat(floor_ptr, y, x, feat_electrical_zone);
516 set_cave_feat(floor_ptr, y, x, feat_heavy_electrical_zone);
522 /* Place dungeon monsters and objects */
523 for (t = data, dy = 0; dy < ymax; dy++) {
524 for (dx = 0; dx < xmax; dx++, t++) {
525 /* prevent loop counter from being overwritten */
530 coord_trans(&i, &j, xoffset, yoffset, transno);
532 if (transno % 2 == 0) {
534 x = xval - (xmax / 2) + i;
535 y = yval - (ymax / 2) + j;
538 x = xval - (ymax / 2) + i;
539 y = yval - (xmax / 2) + j;
542 /* Hack -- skip "non-grids" */
546 /* Analyze the symbol */
549 floor_ptr->monster_level = floor_ptr->base_level + 5;
550 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
551 floor_ptr->monster_level = floor_ptr->base_level;
557 floor_ptr->monster_level = floor_ptr->base_level + 11;
558 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
559 floor_ptr->monster_level = floor_ptr->base_level;
563 /* Meaner monster, plus treasure */
565 floor_ptr->monster_level = floor_ptr->base_level + 9;
566 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
567 floor_ptr->monster_level = floor_ptr->base_level;
568 floor_ptr->object_level = floor_ptr->base_level + 7;
569 place_object(player_ptr, y, x, AM_GOOD);
570 floor_ptr->object_level = floor_ptr->base_level;
574 /* Nasty monster and treasure */
576 floor_ptr->monster_level = floor_ptr->base_level + 40;
577 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
578 floor_ptr->monster_level = floor_ptr->base_level;
579 floor_ptr->object_level = floor_ptr->base_level + 20;
580 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
581 floor_ptr->object_level = floor_ptr->base_level;
585 /* Monster and/or object */
587 if (randint0(100) < 50) {
588 floor_ptr->monster_level = floor_ptr->base_level + 3;
589 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
590 floor_ptr->monster_level = floor_ptr->base_level;
592 if (randint0(100) < 50) {
593 floor_ptr->object_level = floor_ptr->base_level + 7;
594 place_object(player_ptr, y, x, 0L);
595 floor_ptr->object_level = floor_ptr->base_level;
605 * @brief タイプ7の部屋…v_info.txtより小型vaultを生成する / Type 7 -- simple vaults (see "v_info.txt")
607 bool build_type7(player_type *player_ptr, dun_data_type *dd_ptr)
609 vault_type *v_ptr = NULL;
613 POSITION xoffset, yoffset;
616 /* Pick a lesser vault */
617 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++) {
618 /* Access a random vault record */
619 v_ptr = &v_info[randint0(max_v_idx)];
621 /* Accept the first lesser vault */
626 /* No lesser vault found */
627 if (dummy >= SAFE_MAX_ATTEMPTS) {
628 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("小型固定Vaultを配置できませんでした。", "Could not place lesser vault."));
632 /* pick type of transformation (0-7) */
633 transno = randint0(8);
635 /* calculate offsets */
639 /* Some huge vault cannot be ratated to fit in the dungeon */
640 floor_type *floor_ptr = player_ptr->current_floor_ptr;
641 if (x + 2 > floor_ptr->height - 2) {
642 /* Forbid 90 or 270 degree ratation */
646 coord_trans(&x, &y, 0, 0, transno);
660 /* Find and reserve some space in the dungeon. Get center of room. */
661 if (!find_space(player_ptr, dd_ptr, &yval, &xval, abs(y), abs(x)))
664 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("小型Vault(%s)を生成しました。", "Lesser vault (%s)."), v_ptr->name.c_str());
666 /* Hack -- Build the vault */
667 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid, v_ptr->text.c_str(), xoffset, yoffset, transno);
673 * @brief タイプ8の部屋…v_info.txtより大型vaultを生成する / Type 8 -- greater vaults (see "v_info.txt")
675 bool build_type8(player_type *player_ptr, dun_data_type *dd_ptr)
682 POSITION xoffset, yoffset;
684 /* Pick a greater vault */
685 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++) {
686 /* Access a random vault record */
687 v_ptr = &v_info[randint0(max_v_idx)];
689 /* Accept the first greater vault */
694 /* No greater vault found */
695 if (dummy >= SAFE_MAX_ATTEMPTS) {
696 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("大型固定Vaultを配置できませんでした。", "Could not place greater vault."));
700 /* pick type of transformation (0-7) */
701 transno = randint0(8);
703 /* calculate offsets */
707 /* Some huge vault cannot be ratated to fit in the dungeon */
708 floor_type *floor_ptr = player_ptr->current_floor_ptr;
709 if (x + 2 > floor_ptr->height - 2) {
710 /* Forbid 90 or 270 degree ratation */
714 coord_trans(&x, &y, 0, 0, transno);
729 * Try to allocate space for room. If fails, exit
731 * Hack -- Prepare a bit larger space (+2, +2) to
732 * prevent generation of vaults with no-entrance.
734 /* Find and reserve some space in the dungeon. Get center of room. */
735 if (!find_space(player_ptr, dd_ptr, &yval, &xval, (POSITION)(abs(y) + 2), (POSITION)(abs(x) + 2)))
738 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("大型固定Vault(%s)を生成しました。", "Greater vault (%s)."), v_ptr->name.c_str());
740 /* Hack -- Build the vault */
741 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid, v_ptr->text.c_str(), xoffset, yoffset, transno);
747 * Build target vault.
748 * This is made by two concentric "crypts" with perpendicular
749 * walls creating the cross-hairs.
751 static void build_target_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
755 /* Make a random metric */
756 POSITION h1, h2, h3, h4;
757 h1 = randint1(32) - 16;
760 h4 = randint1(32) - 16;
762 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Target Vault"));
764 /* work out outer radius */
772 floor_type *floor_ptr = player_ptr->current_floor_ptr;
773 for (x = x0 - rad; x <= x0 + rad; x++) {
774 for (y = y0 - rad; y <= y0 + rad; y++) {
775 /* clear room flag */
776 floor_ptr->grid_array[y][x].info &= ~(CAVE_ROOM);
778 /* Vault - so is "icky" */
779 floor_ptr->grid_array[y][x].info |= CAVE_ICKY;
781 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1) {
782 /* inside- so is floor */
783 place_bold(player_ptr, y, x, GB_FLOOR);
785 /* make granite outside so on_defeat_arena_monster works */
786 place_bold(player_ptr, y, x, GB_EXTRA);
789 /* proper boundary for on_defeat_arena_monster */
790 if (((y + rad) == y0) || ((y - rad) == y0) || ((x + rad) == x0) || ((x - rad) == x0)) {
791 place_bold(player_ptr, y, x, GB_EXTRA);
796 /* Find visible outer walls and set to be FEAT_OUTER */
797 add_outer_wall(player_ptr, x0, y0, FALSE, x0 - rad - 1, y0 - rad - 1, x0 + rad + 1, y0 + rad + 1);
800 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++) {
801 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++) {
802 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2) {
803 /* Make an internal wall */
804 place_bold(player_ptr, y, x, GB_INNER);
809 /* Add perpendicular walls */
810 for (x = x0 - rad; x <= x0 + rad; x++) {
811 place_bold(player_ptr, y0, x, GB_INNER);
814 for (y = y0 - rad; y <= y0 + rad; y++) {
815 place_bold(player_ptr, y, x0, GB_INNER);
818 /* Make inner vault */
819 for (y = y0 - 1; y <= y0 + 1; y++) {
820 place_bold(player_ptr, y, x0 - 1, GB_INNER);
821 place_bold(player_ptr, y, x0 + 1, GB_INNER);
823 for (x = x0 - 1; x <= x0 + 1; x++) {
824 place_bold(player_ptr, y0 - 1, x, GB_INNER);
825 place_bold(player_ptr, y0 + 1, x, GB_INNER);
828 place_bold(player_ptr, y0, x0, GB_FLOOR);
830 /* Add doors to vault */
831 /* get two distances so can place doors relative to centre */
832 x = (rad - 2) / 4 + 1;
835 add_door(player_ptr, x0 + x, y0);
836 add_door(player_ptr, x0 + y, y0);
837 add_door(player_ptr, x0 - x, y0);
838 add_door(player_ptr, x0 - y, y0);
839 add_door(player_ptr, x0, y0 + x);
840 add_door(player_ptr, x0, y0 + y);
841 add_door(player_ptr, x0, y0 - x);
842 add_door(player_ptr, x0, y0 - y);
844 /* Fill with stuff - medium difficulty */
845 fill_treasure(player_ptr, x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
849 * This routine uses a modified version of the lake code to make a
850 * distribution of some terrain type over the vault. This type
851 * depends on the dungeon depth.
853 * Miniture rooms are then scattered across the vault.
855 static void build_elemental_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
860 POSITION xsize, ysize, xhsize, yhsize, x, y;
864 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
866 /* round to make sizes even */
872 floor_type *floor_ptr = player_ptr->current_floor_ptr;
873 if (floor_ptr->dun_level < 25) {
874 /* Earth vault (Rubble) */
875 type = LAKE_T_EARTH_VAULT;
876 } else if (floor_ptr->dun_level < 50) {
877 /* Air vault (Trees) */
878 type = LAKE_T_AIR_VAULT;
879 } else if (floor_ptr->dun_level < 75) {
880 /* Water vault (shallow water) */
881 type = LAKE_T_WATER_VAULT;
883 /* Fire vault (shallow lava) */
884 type = LAKE_T_FIRE_VAULT;
888 /* testing values for these parameters: feel free to adjust */
889 grd = 1 << (randint0(3));
891 /* want average of about 16 */
892 roug = randint1(8) * randint1(4);
894 /* Make up size of various componants */
898 /* Deep water/lava */
899 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
901 /* Shallow boundary */
905 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, c3);
907 /* Convert to normal format+ clean up */
908 done = generate_lake(player_ptr, y0, x0, xsize, ysize, c1, c2, c3, type);
911 /* Set icky flag because is a vault */
912 for (x = 0; x <= xsize; x++) {
913 for (y = 0; y <= ysize; y++) {
914 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
918 /* make a few rooms in the vault */
919 for (i = 1; i <= (xsize * ysize) / 50; i++) {
920 build_small_room(player_ptr, x0 + randint0(xsize - 4) - xsize / 2 + 2, y0 + randint0(ysize - 4) - ysize / 2 + 2);
923 /* Fill with monsters and treasure, low difficulty */
924 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
927 /* Build a "mini" checkerboard vault
929 * This is done by making a permanent wall maze and setting
930 * the diagonal sqaures of the checker board to be granite.
931 * The vault has two entrances on opposite sides to guarantee
932 * a way to get in even if the vault abuts a side of the dungeon.
934 static void build_mini_c_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
937 POSITION y1, x1, y2, x2, y, x, total;
938 int m, n, num_vertices;
941 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
943 /* Pick a random room size */
952 /* generate the room */
953 floor_type *floor_ptr = player_ptr->current_floor_ptr;
954 for (x = x1 - 2; x <= x2 + 2; x++) {
955 if (!in_bounds(floor_ptr, y1 - 2, x))
958 floor_ptr->grid_array[y1 - 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
960 place_bold(player_ptr, y1 - 2, x, GB_OUTER_NOPERM);
963 for (x = x1 - 2; x <= x2 + 2; x++) {
964 if (!in_bounds(floor_ptr, y2 + 2, x))
967 floor_ptr->grid_array[y2 + 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
969 place_bold(player_ptr, y2 + 2, x, GB_OUTER_NOPERM);
972 for (y = y1 - 2; y <= y2 + 2; y++) {
973 if (!in_bounds(floor_ptr, y, x1 - 2))
976 floor_ptr->grid_array[y][x1 - 2].info |= (CAVE_ROOM | CAVE_ICKY);
978 place_bold(player_ptr, y, x1 - 2, GB_OUTER_NOPERM);
981 for (y = y1 - 2; y <= y2 + 2; y++) {
982 if (!in_bounds(floor_ptr, y, x2 + 2))
985 floor_ptr->grid_array[y][x2 + 2].info |= (CAVE_ROOM | CAVE_ICKY);
987 place_bold(player_ptr, y, x2 + 2, GB_OUTER_NOPERM);
990 for (y = y1 - 1; y <= y2 + 1; y++) {
991 for (x = x1 - 1; x <= x2 + 1; x++) {
992 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
994 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
996 /* Permanent walls */
997 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
1001 /* dimensions of vertex array */
1004 num_vertices = m * n;
1006 /* initialize array of visited vertices */
1007 C_MAKE(visited, num_vertices, int);
1009 /* traverse the graph to create a spannng tree, pick a random root */
1010 r_visit(player_ptr, y1, x1, y2, x2, randint0(num_vertices), 0, visited);
1012 /* Make it look like a checker board vault */
1013 for (x = x1; x <= x2; x++) {
1014 for (y = y1; y <= y2; y++) {
1015 total = x - x1 + y - y1;
1016 /* If total is odd- and is a floor then make a wall */
1017 if ((total % 2 == 1) && is_floor_bold(floor_ptr, y, x)) {
1018 place_bold(player_ptr, y, x, GB_INNER);
1023 /* Make a couple of entrances */
1025 /* left and right */
1026 y = randint1(dy) + dy / 2;
1027 place_bold(player_ptr, y1 + y, x1 - 1, GB_INNER);
1028 place_bold(player_ptr, y1 + y, x2 + 1, GB_INNER);
1030 /* top and bottom */
1031 x = randint1(dx) + dx / 2;
1032 place_bold(player_ptr, y1 - 1, x1 + x, GB_INNER);
1033 place_bold(player_ptr, y2 + 1, x1 + x, GB_INNER);
1036 /* Fill with monsters and treasure, highest difficulty */
1037 fill_treasure(player_ptr, x1, x2, y1, y2, 10);
1039 C_KILL(visited, num_vertices, int);
1042 /* Build a castle */
1043 /* Driver routine: clear the region and call the recursive
1046 *This makes a vault that looks like a castle/ city in the dungeon.
1048 static void build_castle_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1051 POSITION y1, x1, y2, x2;
1054 /* Pick a random room size */
1063 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
1065 /* generate the room */
1066 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1067 for (y = y1 - 1; y <= y2 + 1; y++) {
1068 for (x = x1 - 1; x <= x2 + 1; x++) {
1069 floor_ptr->grid_array[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
1070 /* Make everything a floor */
1071 place_bold(player_ptr, y, x, GB_FLOOR);
1075 /* Make the castle */
1076 build_recursive_room(player_ptr, x1, y1, x2, y2, randint1(5));
1078 /* Fill with monsters and treasure, low difficulty */
1079 fill_treasure(player_ptr, x1, x2, y1, y2, randint1(3));
1083 * @brief タイプ10の部屋…ランダム生成vault / Type 10 -- Random vaults
1084 * @param player_ptr プレーヤーへの参照ポインタ
1086 bool build_type10(player_type *player_ptr, dun_data_type *dd_ptr)
1088 POSITION y0, x0, xsize, ysize, vtype;
1090 /* big enough to look good, small enough to be fairly common. */
1091 xsize = randint1(22) + 22;
1092 ysize = randint1(11) + 11;
1094 /* Find and reserve some space in the dungeon. Get center of room. */
1095 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1096 if (!find_space(player_ptr, dd_ptr, &y0, &x0, ysize + 1, xsize + 1))
1099 /* Select type of vault */
1101 vtype = randint1(15);
1102 } while ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) && ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
1105 /* Build an appropriate room */
1108 build_bubble_vault(player_ptr, x0, y0, xsize, ysize);
1112 build_room_vault(player_ptr, x0, y0, xsize, ysize);
1116 build_cave_vault(player_ptr, x0, y0, xsize, ysize);
1120 build_maze_vault(player_ptr, x0, y0, xsize, ysize, TRUE);
1124 build_mini_c_vault(player_ptr, x0, y0, xsize, ysize);
1128 build_castle_vault(player_ptr, x0, y0, xsize, ysize);
1132 build_target_vault(player_ptr, x0, y0, xsize, ysize);
1135 build_elemental_vault(player_ptr, x0, y0, xsize, ysize);
1137 /* I know how to add a few more... give me some time. */
1146 * @brief タイプ17の部屋…v_info.txtより固定特殊部屋を生成する / Type 17 -- fixed special room (see "v_info.txt")
1148 bool build_type17(player_type *player_ptr, dun_data_type *dd_ptr)
1150 vault_type *v_ptr = NULL;
1153 POSITION xval, yval;
1154 POSITION xoffset, yoffset;
1157 /* Pick a lesser vault */
1158 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++) {
1159 /* Access a random vault record */
1160 v_ptr = &v_info[randint0(max_v_idx)];
1162 /* Accept the special fix room. */
1163 if (v_ptr->typ == 17)
1167 /* No lesser vault found */
1168 if (dummy >= SAFE_MAX_ATTEMPTS) {
1169 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("固定特殊部屋を配置できませんでした。", "Could not place fixed special room."));
1173 /* pick type of transformation (0-7) */
1174 transno = randint0(8);
1176 /* calculate offsets */
1180 /* Some huge vault cannot be ratated to fit in the dungeon */
1181 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1182 if (x + 2 > floor_ptr->height - 2) {
1183 /* Forbid 90 or 270 degree ratation */
1187 coord_trans(&x, &y, 0, 0, transno);
1201 /* Find and reserve some space in the dungeon. Get center of room. */
1202 if (!find_space(player_ptr, dd_ptr, &yval, &xval, abs(y), abs(x)))
1205 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("特殊固定部屋(%s)を生成しました。", "Special Fixed Room (%s)."), v_ptr->name.c_str());
1207 /* Hack -- Build the vault */
1208 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid, v_ptr->text.c_str(), xoffset, yoffset, transno);