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-generate.h"
12 #include "floor/floor.h"
13 #include "floor/wild.h"
14 #include "game-option/cheat-types.h"
15 #include "grid/feature.h"
16 #include "grid/grid.h"
17 #include "grid/trap.h"
18 #include "monster-floor/monster-generator.h"
19 #include "monster-floor/place-monster-types.h"
20 #include "object-enchant/item-apply-magic.h"
21 #include "room/cave-filler.h"
22 #include "room/lake-types.h"
23 #include "room/rooms-maze-vault.h"
24 #include "room/rooms.h" // todo 相互依存.
25 #include "room/space-finder.h"
26 #include "room/treasure-deployment.h"
27 #include "store/store-util.h"
28 #include "store/store.h"
29 #include "system/dungeon-data-definition.h"
30 #include "system/floor-type-definition.h"
31 #include "wizard/wizard-messages.h"
34 * The vault generation arrays
41 * Maximum number of vaults in v_info.txt
46 * This function creates a random vault that looks like a collection of bubbles.
47 * It works by getting a set of coordinates that represent the center of each
48 * bubble. The entire room is made by seeing which bubble center is closest. If
49 * two centers are equidistant then the square is a wall, otherwise it is a floor.
50 * The only exception is for squares really near a center, these are always floor.
51 * (It looks better than without this check.)
53 * Note: If two centers are on the same point then this algorithm will create a
54 * blank bubble filled with walls. - This is prevented from happening.
56 static void build_bubble_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
58 #define BUBBLENUM 10 /* number of bubbles */
60 /* array of center points of bubbles */
61 coord center[BUBBLENUM];
64 POSITION x = 0, y = 0;
65 u16b min1, min2, temp;
68 /* Offset from center to top left hand corner */
69 POSITION xhsize = xsize / 2;
70 POSITION yhsize = ysize / 2;
72 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("泡型ランダムVaultを生成しました。", "Room Vault."));
74 /* Allocate center of bubbles */
75 center[0].x = (byte)randint1(xsize - 3) + 1;
76 center[0].y = (byte)randint1(ysize - 3) + 1;
78 for (i = 1; i < BUBBLENUM; i++)
82 /* 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++)
92 /* rough test to see if there is an overlap */
93 if ((x == center[j].x) && (y == center[j].y)) done = FALSE;
101 /* Top and bottom boundaries */
102 floor_type *floor_ptr = player_ptr->current_floor_ptr;
103 for (i = 0; i < xsize; i++)
105 int side_x = x0 - xhsize + i;
107 place_bold(player_ptr, y0 - yhsize + 0, side_x, GB_OUTER_NOPERM);
108 floor_ptr->grid_array[y0 - yhsize + 0][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
109 place_bold(player_ptr, y0 - yhsize + ysize - 1, side_x, GB_OUTER_NOPERM);
110 floor_ptr->grid_array[y0 - yhsize + ysize - 1][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
113 /* Left and right boundaries */
114 for (i = 1; i < ysize - 1; i++)
116 int side_y = y0 - yhsize + i;
118 place_bold(player_ptr, side_y, x0 - xhsize + 0, GB_OUTER_NOPERM);
119 floor_ptr->grid_array[side_y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
120 place_bold(player_ptr, side_y, x0 - xhsize + xsize - 1, GB_OUTER_NOPERM);
121 floor_ptr->grid_array[side_y][x0 - xhsize + xsize - 1].info |= (CAVE_ROOM | CAVE_ICKY);
124 /* Fill in middle with bubbles */
125 for (x = 1; x < xsize - 1; x++)
127 for (y = 1; y < ysize - 1; y++)
129 /* Get distances to two closest centers */
131 min1 = (u16b)distance(x, y, center[0].x, center[0].y);
132 min2 = (u16b)distance(x, y, center[1].x, center[1].y);
136 /* swap if in wrong order */
143 for (i = 2; i < BUBBLENUM; i++)
145 temp = (u16b)distance(x, y, center[i].x, center[i].y);
153 else if (temp < min2)
155 /* second smallest */
159 if (((min2 - min1) <= 2) && (!(min1 < 3)))
161 /* Boundary at midpoint+ not at inner region of bubble */
162 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_OUTER_NOPERM);
166 /* middle of a bubble */
167 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_FLOOR);
170 /* clean up rest of flags */
171 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= (CAVE_ROOM | CAVE_ICKY);
175 /* Try to add some random doors */
176 for (i = 0; i < 500; i++)
178 x = randint1(xsize - 3) - xhsize + x0 + 1;
179 y = randint1(ysize - 3) - yhsize + y0 + 1;
180 add_door(player_ptr, x, y);
183 /* Fill with monsters and treasure, low difficulty */
184 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5));
187 /* Create a random vault that looks like a collection of overlapping rooms */
188 static void build_room_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
190 POSITION x1, x2, y1, y2, xhsize, yhsize;
193 /* get offset from center */
197 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("部屋型ランダムVaultを生成しました。", "Room Vault."));
199 /* fill area so don't get problems with arena levels */
200 floor_type *floor_ptr = player_ptr->current_floor_ptr;
201 for (x1 = 0; x1 < xsize; x1++)
203 POSITION x = x0 - xhsize + x1;
205 for (y1 = 0; y1 < ysize; y1++)
207 POSITION y = y0 - yhsize + y1;
209 place_bold(player_ptr, y, x, GB_EXTRA);
210 floor_ptr->grid_array[y][x].info &= (~CAVE_ICKY);
214 /* add ten random rooms */
215 for (i = 0; i < 10; i++)
217 x1 = randint1(xhsize) * 2 + x0 - xhsize;
218 x2 = randint1(xhsize) * 2 + x0 - xhsize;
219 y1 = randint1(yhsize) * 2 + y0 - yhsize;
220 y2 = randint1(yhsize) * 2 + y0 - yhsize;
221 build_room(player_ptr, x1, x2, y1, y2);
224 /* Add some random doors */
225 for (i = 0; i < 500; i++)
227 x1 = randint1(xsize - 3) - xhsize + x0 + 1;
228 y1 = randint1(ysize - 3) - yhsize + y0 + 1;
229 add_door(player_ptr, x1, y1);
232 /* Fill with monsters and treasure, high difficulty */
233 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5);
237 /* Create a random vault out of a fractal grid */
238 static void build_cave_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
240 int grd, roug, cutoff;
241 bool done, light, room;
242 POSITION xhsize, yhsize, xsize, ysize, x, y;
244 /* round to make sizes even */
250 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("洞穴ランダムVaultを生成しました。", "Cave Vault."));
252 light = done = FALSE;
255 floor_type *floor_ptr = player_ptr->current_floor_ptr;
258 /* testing values for these parameters feel free to adjust */
259 grd = 1 << randint0(4);
261 /* want average of about 16 */
262 roug = randint1(8) * randint1(4);
265 cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
266 randint1(xsize / 4) + randint1(ysize / 4);
269 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, cutoff);
271 /* Convert to normal format+ clean up */
272 done = generate_fracave(player_ptr, y0, x0, xsize, ysize, cutoff, light, room);
275 /* Set icky flag because is a vault */
276 for (x = 0; x <= xsize; x++)
278 for (y = 0; y <= ysize; y++)
280 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
284 /* Fill with monsters and treasure, low difficulty */
285 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
290 * @brief Vault地形を回転、上下左右反転するための座標変換を返す / coordinate translation code
291 * @param x 変換したい点のX座標参照ポインタ
292 * @param y 変換したい点のY座標参照ポインタ
293 * @param xoffset Vault生成時の基準X座標
294 * @param yoffset Vault生成時の基準Y座標
295 * @param transno 処理ID
298 static void coord_trans(POSITION *x, POSITION *y, POSITION xoffset, POSITION yoffset, int transno)
304 * transno specifies what transformation is required. (0-7)
305 * The lower two bits indicate by how much the vault is rotated,
306 * and the upper bit indicates a reflection.
307 * This is done by using rotation matrices... however since
308 * these are mostly zeros for rotations by 90 degrees this can
309 * be expressed simply in terms of swapping and inverting the
310 * x and y coordinates.
312 for (i = 0; i < transno % 4; i++)
314 /* rotate by 90 degrees */
322 /* Reflect depending on status of 3rd bit. */
326 /* Add offsets so vault stays in the first quadrant */
333 * @brief Vaultをフロアに配置する / Hack -- fill in "vault" rooms
334 * @param player_ptr プレーヤーへの参照ポインタ
335 * @param yval 生成基準Y座標
336 * @param xval 生成基準X座標
337 * @param ymax VaultのYサイズ
338 * @param xmax VaultのXサイズ
339 * @param data Vaultのデータ文字列
340 * @param xoffset 変換基準X座標
341 * @param yoffset 変換基準Y座標
342 * @param transno 変換ID
345 static void build_vault(player_type *player_ptr, POSITION yval, POSITION xval, POSITION ymax, POSITION xmax, concptr data,
346 POSITION xoffset, POSITION yoffset, int transno)
348 POSITION dx, dy, x, y, i, j;
352 /* Place dungeon features and objects */
353 floor_type *floor_ptr = player_ptr->current_floor_ptr;
354 for (t = data, dy = 0; dy < ymax; dy++)
356 for (dx = 0; dx < xmax; dx++, t++)
358 /* prevent loop counter from being overwritten */
363 coord_trans(&i, &j, xoffset, yoffset, transno);
365 if (transno % 2 == 0)
368 x = xval - (xmax / 2) + i;
369 y = yval - (ymax / 2) + j;
374 x = xval - (ymax / 2) + i;
375 y = yval - (xmax / 2) + j;
378 /* Hack -- skip "non-grids" */
379 if (*t == ' ') continue;
380 g_ptr = &floor_ptr->grid_array[y][x];
382 /* Lay down a floor */
383 place_grid(player_ptr, g_ptr, GB_FLOOR);
385 /* Remove any mimic */
388 /* Part of a vault */
389 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
391 /* Analyze the grid */
394 /* Granite wall (outer) */
396 place_grid(player_ptr, g_ptr, GB_OUTER_NOPERM);
399 /* Granite wall (inner) */
401 place_grid(player_ptr, g_ptr, GB_INNER);
404 /* Glass wall (inner) */
406 place_grid(player_ptr, g_ptr, GB_INNER);
407 g_ptr->feat = feat_glass_wall;
410 /* Permanent wall (inner) */
412 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
415 /* Permanent glass wall (inner) */
417 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
418 g_ptr->feat = feat_permanent_glass_wall;
423 if (randint0(100) < 75)
425 place_object(player_ptr, y, x, 0L);
429 place_trap(player_ptr, y, x);
435 place_object(player_ptr, y, x, 0L);
440 g_ptr->feat = feat_tree;
445 place_secret_door(player_ptr, y, x, DOOR_DEFAULT);
448 /* Secret glass doors */
450 place_secret_door(player_ptr, y, x, DOOR_GLASS_DOOR);
451 if (is_closed_door(player_ptr, g_ptr->feat)) g_ptr->mimic = feat_glass_wall;
456 place_secret_door(player_ptr, y, x, DOOR_CURTAIN);
461 place_trap(player_ptr, y, x);
464 /* Black market in a dungeon */
466 set_cave_feat(floor_ptr, y, x, feat_black_market);
467 store_init(NO_TOWN, STORE_BLACK);
472 set_cave_feat(floor_ptr, y, x, feat_pattern_start);
476 set_cave_feat(floor_ptr, y, x, feat_pattern_1);
480 set_cave_feat(floor_ptr, y, x, feat_pattern_2);
484 set_cave_feat(floor_ptr, y, x, feat_pattern_3);
488 set_cave_feat(floor_ptr, y, x, feat_pattern_4);
492 set_cave_feat(floor_ptr, y, x, feat_pattern_end);
496 set_cave_feat(floor_ptr, y, x, feat_pattern_exit);
500 /* Reward for Pattern walk */
501 floor_ptr->object_level = floor_ptr->base_level + 12;
502 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
503 floor_ptr->object_level = floor_ptr->base_level;
507 set_cave_feat(floor_ptr, y, x, feat_shallow_water);
511 set_cave_feat(floor_ptr, y, x, feat_deep_water);
515 set_cave_feat(floor_ptr, y, x, feat_shallow_lava);
519 set_cave_feat(floor_ptr, y, x, feat_deep_lava);
523 set_cave_feat(floor_ptr, y, x, feat_shallow_acid_puddle);
527 set_cave_feat(floor_ptr, y, x, feat_deep_acid_puddle);
531 set_cave_feat(floor_ptr, y, x, feat_shallow_poisonous_puddle);
535 set_cave_feat(floor_ptr, y, x, feat_deep_poisonous_puddle);
539 set_cave_feat(floor_ptr, y, x, feat_cold_zone);
543 set_cave_feat(floor_ptr, y, x, feat_heavy_cold_zone);
547 set_cave_feat(floor_ptr, y, x, feat_electrical_zone);
551 set_cave_feat(floor_ptr, y, x, feat_heavy_electrical_zone);
559 /* Place dungeon monsters and objects */
560 for (t = data, dy = 0; dy < ymax; dy++)
562 for (dx = 0; dx < xmax; dx++, t++)
564 /* prevent loop counter from being overwritten */
569 coord_trans(&i, &j, xoffset, yoffset, transno);
571 if (transno % 2 == 0)
574 x = xval - (xmax / 2) + i;
575 y = yval - (ymax / 2) + j;
580 x = xval - (ymax / 2) + i;
581 y = yval - (xmax / 2) + j;
584 /* Hack -- skip "non-grids" */
585 if (*t == ' ') continue;
587 /* Analyze the symbol */
592 floor_ptr->monster_level = floor_ptr->base_level + 5;
593 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
594 floor_ptr->monster_level = floor_ptr->base_level;
601 floor_ptr->monster_level = floor_ptr->base_level + 11;
602 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
603 floor_ptr->monster_level = floor_ptr->base_level;
607 /* Meaner monster, plus treasure */
610 floor_ptr->monster_level = floor_ptr->base_level + 9;
611 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
612 floor_ptr->monster_level = floor_ptr->base_level;
613 floor_ptr->object_level = floor_ptr->base_level + 7;
614 place_object(player_ptr, y, x, AM_GOOD);
615 floor_ptr->object_level = floor_ptr->base_level;
619 /* Nasty monster and treasure */
622 floor_ptr->monster_level = floor_ptr->base_level + 40;
623 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
624 floor_ptr->monster_level = floor_ptr->base_level;
625 floor_ptr->object_level = floor_ptr->base_level + 20;
626 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
627 floor_ptr->object_level = floor_ptr->base_level;
631 /* Monster and/or object */
634 if (randint0(100) < 50)
636 floor_ptr->monster_level = floor_ptr->base_level + 3;
637 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
638 floor_ptr->monster_level = floor_ptr->base_level;
640 if (randint0(100) < 50)
642 floor_ptr->object_level = floor_ptr->base_level + 7;
643 place_object(player_ptr, y, x, 0L);
644 floor_ptr->object_level = floor_ptr->base_level;
655 * @brief タイプ7の部屋…v_info.txtより小型vaultを生成する / Type 7 -- simple vaults (see "v_info.txt")
658 bool build_type7(player_type *player_ptr)
660 vault_type *v_ptr = NULL;
664 POSITION xoffset, yoffset;
667 /* Pick a lesser vault */
668 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
670 /* Access a random vault record */
671 v_ptr = &v_info[randint0(max_v_idx)];
673 /* Accept the first lesser vault */
674 if (v_ptr->typ == 7) break;
677 /* No lesser vault found */
678 if (dummy >= SAFE_MAX_ATTEMPTS)
680 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("小型固定Vaultを配置できませんでした。", "Could not place lesser vault."));
684 /* pick type of transformation (0-7) */
685 transno = randint0(8);
687 /* calculate offsets */
691 /* Some huge vault cannot be ratated to fit in the dungeon */
692 floor_type *floor_ptr = player_ptr->current_floor_ptr;
693 if (x + 2 > floor_ptr->height - 2)
695 /* Forbid 90 or 270 degree ratation */
699 coord_trans(&x, &y, 0, 0, transno);
719 /* Find and reserve some space in the dungeon. Get center of room. */
720 if (!find_space(player_ptr, &yval, &xval, abs(y), abs(x))) return FALSE;
722 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("小型Vault(%s)を生成しました。", "Lesser vault (%s)."), v_name + v_ptr->name);
724 /* Hack -- Build the vault */
725 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
726 v_text + v_ptr->text, xoffset, yoffset, transno);
733 * @brief タイプ8の部屋…v_info.txtより大型vaultを生成する / Type 8 -- greater vaults (see "v_info.txt")
736 bool build_type8(player_type *player_ptr)
743 POSITION xoffset, yoffset;
745 /* Pick a greater vault */
746 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
748 /* Access a random vault record */
749 v_ptr = &v_info[randint0(max_v_idx)];
751 /* Accept the first greater vault */
752 if (v_ptr->typ == 8) break;
755 /* No greater vault found */
756 if (dummy >= SAFE_MAX_ATTEMPTS)
758 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("大型固定Vaultを配置できませんでした。", "Could not place greater vault."));
762 /* pick type of transformation (0-7) */
763 transno = randint0(8);
765 /* calculate offsets */
769 /* Some huge vault cannot be ratated to fit in the dungeon */
770 floor_type *floor_ptr = player_ptr->current_floor_ptr;
771 if (x + 2 > floor_ptr->height - 2)
773 /* Forbid 90 or 270 degree ratation */
777 coord_trans(&x, &y, 0, 0, transno);
798 * Try to allocate space for room. If fails, exit
800 * Hack -- Prepare a bit larger space (+2, +2) to
801 * prevent generation of vaults with no-entrance.
803 /* Find and reserve some space in the dungeon. Get center of room. */
804 if (!find_space(player_ptr, &yval, &xval, (POSITION)(abs(y) + 2), (POSITION)(abs(x) + 2))) return FALSE;
806 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("大型固定Vault(%s)を生成しました。", "Greater vault (%s)."), v_name + v_ptr->name);
808 /* Hack -- Build the vault */
809 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
810 v_text + v_ptr->text, xoffset, yoffset, transno);
817 * Build target vault.
818 * This is made by two concentric "crypts" with perpendicular
819 * walls creating the cross-hairs.
821 static void build_target_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
825 /* Make a random metric */
826 POSITION h1, h2, h3, h4;
827 h1 = randint1(32) - 16;
830 h4 = randint1(32) - 16;
832 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Elemental Vault"));
834 /* work out outer radius */
845 floor_type *floor_ptr = player_ptr->current_floor_ptr;
846 for (x = x0 - rad; x <= x0 + rad; x++)
848 for (y = y0 - rad; y <= y0 + rad; y++)
850 /* clear room flag */
851 floor_ptr->grid_array[y][x].info &= ~(CAVE_ROOM);
853 /* Vault - so is "icky" */
854 floor_ptr->grid_array[y][x].info |= CAVE_ICKY;
856 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1)
858 /* inside- so is floor */
859 place_bold(player_ptr, y, x, GB_FLOOR);
863 /* make granite outside so arena works */
864 place_bold(player_ptr, y, x, GB_EXTRA);
867 /* proper boundary for arena */
868 if (((y + rad) == y0) || ((y - rad) == y0) ||
869 ((x + rad) == x0) || ((x - rad) == x0))
871 place_bold(player_ptr, y, x, GB_EXTRA);
876 /* Find visible outer walls and set to be FEAT_OUTER */
877 add_outer_wall(player_ptr, x0, y0, FALSE, x0 - rad - 1, y0 - rad - 1, x0 + rad + 1, y0 + rad + 1);
880 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++)
882 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++)
884 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2)
886 /* Make an internal wall */
887 place_bold(player_ptr, y, x, GB_INNER);
892 /* Add perpendicular walls */
893 for (x = x0 - rad; x <= x0 + rad; x++)
895 place_bold(player_ptr, y0, x, GB_INNER);
898 for (y = y0 - rad; y <= y0 + rad; y++)
900 place_bold(player_ptr, y, x0, GB_INNER);
903 /* Make inner vault */
904 for (y = y0 - 1; y <= y0 + 1; y++)
906 place_bold(player_ptr, y, x0 - 1, GB_INNER);
907 place_bold(player_ptr, y, x0 + 1, GB_INNER);
909 for (x = x0 - 1; x <= x0 + 1; x++)
911 place_bold(player_ptr, y0 - 1, x, GB_INNER);
912 place_bold(player_ptr, y0 + 1, x, GB_INNER);
915 place_bold(player_ptr, y0, x0, GB_FLOOR);
918 /* Add doors to vault */
919 /* get two distances so can place doors relative to centre */
920 x = (rad - 2) / 4 + 1;
923 add_door(player_ptr, x0 + x, y0);
924 add_door(player_ptr, x0 + y, y0);
925 add_door(player_ptr, x0 - x, y0);
926 add_door(player_ptr, x0 - y, y0);
927 add_door(player_ptr, x0, y0 + x);
928 add_door(player_ptr, x0, y0 + y);
929 add_door(player_ptr, x0, y0 - x);
930 add_door(player_ptr, x0, y0 - y);
932 /* Fill with stuff - medium difficulty */
933 fill_treasure(player_ptr, x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
938 * This routine uses a modified version of the lake code to make a
939 * distribution of some terrain type over the vault. This type
940 * depends on the dungeon depth.
942 * Miniture rooms are then scattered across the vault.
944 static void build_elemental_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
949 POSITION xsize, ysize, xhsize, yhsize, x, y;
953 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
955 /* round to make sizes even */
961 floor_type *floor_ptr = player_ptr->current_floor_ptr;
962 if (floor_ptr->dun_level < 25)
964 /* Earth vault (Rubble) */
965 type = LAKE_T_EARTH_VAULT;
967 else if (floor_ptr->dun_level < 50)
969 /* Air vault (Trees) */
970 type = LAKE_T_AIR_VAULT;
972 else if (floor_ptr->dun_level < 75)
974 /* Water vault (shallow water) */
975 type = LAKE_T_WATER_VAULT;
979 /* Fire vault (shallow lava) */
980 type = LAKE_T_FIRE_VAULT;
985 /* testing values for these parameters: feel free to adjust */
986 grd = 1 << (randint0(3));
988 /* want average of about 16 */
989 roug = randint1(8) * randint1(4);
991 /* Make up size of various componants */
995 /* Deep water/lava */
996 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
998 /* Shallow boundary */
1002 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, c3);
1004 /* Convert to normal format+ clean up */
1005 done = generate_lake(player_ptr, y0, x0, xsize, ysize, c1, c2, c3, type);
1008 /* Set icky flag because is a vault */
1009 for (x = 0; x <= xsize; x++)
1011 for (y = 0; y <= ysize; y++)
1013 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
1017 /* make a few rooms in the vault */
1018 for (i = 1; i <= (xsize * ysize) / 50; i++)
1020 build_small_room(player_ptr, x0 + randint0(xsize - 4) - xsize / 2 + 2,
1021 y0 + randint0(ysize - 4) - ysize / 2 + 2);
1024 /* Fill with monsters and treasure, low difficulty */
1025 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1,
1026 y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
1030 /* Build a "mini" checkerboard vault
1032 * This is done by making a permanent wall maze and setting
1033 * the diagonal sqaures of the checker board to be granite.
1034 * The vault has two entrances on opposite sides to guarantee
1035 * a way to get in even if the vault abuts a side of the dungeon.
1037 static void build_mini_c_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1040 POSITION y1, x1, y2, x2, y, x, total;
1041 int m, n, num_vertices;
1044 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
1046 /* Pick a random room size */
1056 /* generate the room */
1057 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1058 for (x = x1 - 2; x <= x2 + 2; x++)
1060 if (!in_bounds(floor_ptr, y1 - 2, x)) break;
1062 floor_ptr->grid_array[y1 - 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1064 place_bold(player_ptr, y1 - 2, x, GB_OUTER_NOPERM);
1067 for (x = x1 - 2; x <= x2 + 2; x++)
1069 if (!in_bounds(floor_ptr, y2 + 2, x)) break;
1071 floor_ptr->grid_array[y2 + 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1073 place_bold(player_ptr, y2 + 2, x, GB_OUTER_NOPERM);
1076 for (y = y1 - 2; y <= y2 + 2; y++)
1078 if (!in_bounds(floor_ptr, y, x1 - 2)) break;
1080 floor_ptr->grid_array[y][x1 - 2].info |= (CAVE_ROOM | CAVE_ICKY);
1082 place_bold(player_ptr, y, x1 - 2, GB_OUTER_NOPERM);
1085 for (y = y1 - 2; y <= y2 + 2; y++)
1087 if (!in_bounds(floor_ptr, y, x2 + 2)) break;
1089 floor_ptr->grid_array[y][x2 + 2].info |= (CAVE_ROOM | CAVE_ICKY);
1091 place_bold(player_ptr, y, x2 + 2, GB_OUTER_NOPERM);
1094 for (y = y1 - 1; y <= y2 + 1; y++)
1096 for (x = x1 - 1; x <= x2 + 1; x++)
1098 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1100 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
1102 /* Permanent walls */
1103 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
1108 /* dimensions of vertex array */
1111 num_vertices = m * n;
1113 /* initialize array of visited vertices */
1114 C_MAKE(visited, num_vertices, int);
1116 /* traverse the graph to create a spannng tree, pick a random root */
1117 r_visit(player_ptr, y1, x1, y2, x2, randint0(num_vertices), 0, visited);
1119 /* Make it look like a checker board vault */
1120 for (x = x1; x <= x2; x++)
1122 for (y = y1; y <= y2; y++)
1124 total = x - x1 + y - y1;
1125 /* If total is odd- and is a floor then make a wall */
1126 if ((total % 2 == 1) && is_floor_bold(floor_ptr, y, x))
1128 place_bold(player_ptr, y, x, GB_INNER);
1133 /* Make a couple of entrances */
1136 /* left and right */
1137 y = randint1(dy) + dy / 2;
1138 place_bold(player_ptr, y1 + y, x1 - 1, GB_INNER);
1139 place_bold(player_ptr, y1 + y, x2 + 1, GB_INNER);
1143 /* top and bottom */
1144 x = randint1(dx) + dx / 2;
1145 place_bold(player_ptr, y1 - 1, x1 + x, GB_INNER);
1146 place_bold(player_ptr, y2 + 1, x1 + x, GB_INNER);
1149 /* Fill with monsters and treasure, highest difficulty */
1150 fill_treasure(player_ptr, x1, x2, y1, y2, 10);
1152 C_KILL(visited, num_vertices, int);
1155 /* Build a castle */
1156 /* Driver routine: clear the region and call the recursive
1159 *This makes a vault that looks like a castle/ city in the dungeon.
1161 static void build_castle_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1164 POSITION y1, x1, y2, x2;
1167 /* Pick a random room size */
1176 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
1178 /* generate the room */
1179 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1180 for (y = y1 - 1; y <= y2 + 1; y++)
1182 for (x = x1 - 1; x <= x2 + 1; x++)
1184 floor_ptr->grid_array[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
1185 /* Make everything a floor */
1186 place_bold(player_ptr, y, x, GB_FLOOR);
1190 /* Make the castle */
1191 build_recursive_room(player_ptr, x1, y1, x2, y2, randint1(5));
1193 /* Fill with monsters and treasure, low difficulty */
1194 fill_treasure(player_ptr, x1, x2, y1, y2, randint1(3));
1199 * @brief タイプ10の部屋…ランダム生成vault / Type 10 -- Random vaults
1200 * @param player_ptr プレーヤーへの参照ポインタ
1203 bool build_type10(player_type *player_ptr)
1205 POSITION y0, x0, xsize, ysize, vtype;
1207 /* big enough to look good, small enough to be fairly common. */
1208 xsize = randint1(22) + 22;
1209 ysize = randint1(11) + 11;
1211 /* Find and reserve some space in the dungeon. Get center of room. */
1212 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1213 if (!find_space(player_ptr, &y0, &x0, ysize + 1, xsize + 1)) return FALSE;
1215 /* Select type of vault */
1218 vtype = randint1(15);
1219 } while ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) &&
1220 ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
1224 /* Build an appropriate room */
1225 case 1: case 9: build_bubble_vault(player_ptr, x0, y0, xsize, ysize); break;
1226 case 2: case 10: build_room_vault(player_ptr, x0, y0, xsize, ysize); break;
1227 case 3: case 11: build_cave_vault(player_ptr, x0, y0, xsize, ysize); break;
1228 case 4: case 12: build_maze_vault(player_ptr, x0, y0, xsize, ysize, TRUE); break;
1229 case 5: case 13: build_mini_c_vault(player_ptr, x0, y0, xsize, ysize); break;
1230 case 6: case 14: build_castle_vault(player_ptr, x0, y0, xsize, ysize); break;
1231 case 7: case 15: build_target_vault(player_ptr, x0, y0, xsize, ysize); break;
1232 case 8: build_elemental_vault(player_ptr, x0, y0, xsize, ysize); break;
1233 /* I know how to add a few more... give me some time. */
1234 default: return FALSE;
1242 * @brief タイプ17の部屋…v_info.txtより固定特殊部屋を生成する / Type 17 -- fixed special room (see "v_info.txt")
1245 bool build_type17(player_type *player_ptr)
1247 vault_type *v_ptr = NULL;
1250 POSITION xval, yval;
1251 POSITION xoffset, yoffset;
1254 /* Pick a lesser vault */
1255 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
1257 /* Access a random vault record */
1258 v_ptr = &v_info[randint0(max_v_idx)];
1260 /* Accept the special fix room. */
1261 if (v_ptr->typ == 17) break;
1264 /* No lesser vault found */
1265 if (dummy >= SAFE_MAX_ATTEMPTS)
1267 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("固定特殊部屋を配置できませんでした。", "Could not place fixed special room."));
1271 /* pick type of transformation (0-7) */
1272 transno = randint0(8);
1274 /* calculate offsets */
1278 /* Some huge vault cannot be ratated to fit in the dungeon */
1279 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1280 if (x + 2 > floor_ptr->height - 2)
1282 /* Forbid 90 or 270 degree ratation */
1286 coord_trans(&x, &y, 0, 0, transno);
1306 /* Find and reserve some space in the dungeon. Get center of room. */
1307 if (!find_space(player_ptr, &yval, &xval, abs(y), abs(x))) return FALSE;
1309 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("特殊固定部屋(%s)を生成しました。", "Special Fix room (%s)."), v_name + v_ptr->name);
1311 /* Hack -- Build the vault */
1312 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
1313 v_text + v_ptr->text, xoffset, yoffset, transno);