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/floor.h"
14 #include "floor/wild.h"
15 #include "game-option/cheat-types.h"
16 #include "grid/feature.h"
17 #include "grid/grid.h"
18 #include "grid/trap.h"
19 #include "monster-floor/monster-generator.h"
20 #include "monster-floor/place-monster-types.h"
21 #include "object-enchant/item-apply-magic.h"
22 #include "room/cave-filler.h"
23 #include "room/lake-types.h"
24 #include "room/rooms-builder.h"
25 #include "room/rooms-maze-vault.h"
26 #include "room/space-finder.h"
27 #include "room/treasure-deployment.h"
28 #include "store/store-util.h"
29 #include "store/store.h"
30 #include "system/dungeon-data-definition.h"
31 #include "system/floor-type-definition.h"
32 #include "wizard/wizard-messages.h"
35 * The vault generation arrays
42 * Maximum number of vaults in v_info.txt
47 * This function creates a random vault that looks like a collection of bubbles.
48 * It works by getting a set of coordinates that represent the center of each
49 * bubble. The entire room is made by seeing which bubble center is closest. If
50 * two centers are equidistant then the square is a wall, otherwise it is a floor.
51 * The only exception is for squares really near a center, these are always floor.
52 * (It looks better than without this check.)
54 * Note: If two centers are on the same point then this algorithm will create a
55 * blank bubble filled with walls. - This is prevented from happening.
57 static void build_bubble_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
59 #define BUBBLENUM 10 /* number of bubbles */
61 /* array of center points of bubbles */
62 coord center[BUBBLENUM];
65 POSITION x = 0, y = 0;
66 u16b min1, min2, temp;
69 /* Offset from center to top left hand corner */
70 POSITION xhsize = xsize / 2;
71 POSITION yhsize = ysize / 2;
73 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("泡型ランダムVaultを生成しました。", "Room Vault."));
75 /* Allocate center of bubbles */
76 center[0].x = (byte)randint1(xsize - 3) + 1;
77 center[0].y = (byte)randint1(ysize - 3) + 1;
79 for (i = 1; i < BUBBLENUM; i++) {
82 /* get center and check to see if it is unique */
86 x = randint1(xsize - 3) + 1;
87 y = randint1(ysize - 3) + 1;
89 for (j = 0; j < i; j++) {
90 /* rough test to see if there is an overlap */
91 if ((x == center[j].x) && (y == center[j].y))
100 /* Top and bottom boundaries */
101 floor_type *floor_ptr = player_ptr->current_floor_ptr;
102 for (i = 0; i < xsize; i++) {
103 int side_x = x0 - xhsize + i;
105 place_bold(player_ptr, y0 - yhsize + 0, side_x, GB_OUTER_NOPERM);
106 floor_ptr->grid_array[y0 - yhsize + 0][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
107 place_bold(player_ptr, y0 - yhsize + ysize - 1, side_x, GB_OUTER_NOPERM);
108 floor_ptr->grid_array[y0 - yhsize + ysize - 1][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
111 /* Left and right boundaries */
112 for (i = 1; i < ysize - 1; i++) {
113 int side_y = y0 - yhsize + i;
115 place_bold(player_ptr, side_y, x0 - xhsize + 0, GB_OUTER_NOPERM);
116 floor_ptr->grid_array[side_y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
117 place_bold(player_ptr, side_y, x0 - xhsize + xsize - 1, GB_OUTER_NOPERM);
118 floor_ptr->grid_array[side_y][x0 - xhsize + xsize - 1].info |= (CAVE_ROOM | CAVE_ICKY);
121 /* Fill in middle with bubbles */
122 for (x = 1; x < xsize - 1; x++) {
123 for (y = 1; y < ysize - 1; y++) {
124 /* Get distances to two closest centers */
126 min1 = (u16b)distance(x, y, center[0].x, center[0].y);
127 min2 = (u16b)distance(x, y, center[1].x, center[1].y);
130 /* swap if in wrong order */
137 for (i = 2; i < BUBBLENUM; i++) {
138 temp = (u16b)distance(x, y, center[i].x, center[i].y);
144 } else if (temp < min2) {
145 /* second smallest */
149 if (((min2 - min1) <= 2) && (!(min1 < 3))) {
150 /* Boundary at midpoint+ not at inner region of bubble */
151 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_OUTER_NOPERM);
153 /* middle of a bubble */
154 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_FLOOR);
157 /* clean up rest of flags */
158 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= (CAVE_ROOM | CAVE_ICKY);
162 /* Try to add some random doors */
163 for (i = 0; i < 500; i++) {
164 x = randint1(xsize - 3) - xhsize + x0 + 1;
165 y = randint1(ysize - 3) - yhsize + y0 + 1;
166 add_door(player_ptr, x, y);
169 /* Fill with monsters and treasure, low difficulty */
170 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5));
173 /* Create a random vault that looks like a collection of overlapping rooms */
174 static void build_room_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
176 POSITION x1, x2, y1, y2, xhsize, yhsize;
179 /* get offset from center */
183 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("部屋型ランダムVaultを生成しました。", "Room Vault."));
185 /* fill area so don't get problems with arena levels */
186 floor_type *floor_ptr = player_ptr->current_floor_ptr;
187 for (x1 = 0; x1 < xsize; x1++) {
188 POSITION x = x0 - xhsize + x1;
190 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++) {
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(player_ptr, x1, x2, y1, y2);
207 /* Add some random doors */
208 for (i = 0; i < 500; i++) {
209 x1 = randint1(xsize - 3) - xhsize + x0 + 1;
210 y1 = randint1(ysize - 3) - yhsize + y0 + 1;
211 add_door(player_ptr, x1, y1);
214 /* Fill with monsters and treasure, high difficulty */
215 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5);
218 /* Create a random vault out of a fractal grid */
219 static void build_cave_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
221 int grd, roug, cutoff;
222 bool done, light, room;
223 POSITION xhsize, yhsize, xsize, ysize, x, y;
225 /* round to make sizes even */
231 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("洞穴ランダムVaultを生成しました。", "Cave Vault."));
233 light = done = FALSE;
236 floor_type *floor_ptr = player_ptr->current_floor_ptr;
238 /* testing values for these parameters feel free to adjust */
239 grd = 1 << randint0(4);
241 /* want average of about 16 */
242 roug = randint1(8) * randint1(4);
245 cutoff = randint1(xsize / 4) + randint1(ysize / 4) + randint1(xsize / 4) + randint1(ysize / 4);
248 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, cutoff);
250 /* Convert to normal format+ clean up */
251 done = generate_fracave(player_ptr, y0, x0, xsize, ysize, cutoff, light, room);
254 /* Set icky flag because is a vault */
255 for (x = 0; x <= xsize; x++) {
256 for (y = 0; y <= ysize; y++) {
257 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
261 /* Fill with monsters and treasure, low difficulty */
262 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
266 * @brief Vault地形を回転、上下左右反転するための座標変換を返す / coordinate translation code
267 * @param x 変換したい点のX座標参照ポインタ
268 * @param y 変換したい点のY座標参照ポインタ
269 * @param xoffset Vault生成時の基準X座標
270 * @param yoffset Vault生成時の基準Y座標
271 * @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
318 static void build_vault(
319 player_type *player_ptr, POSITION yval, POSITION xval, POSITION ymax, POSITION xmax, concptr data, POSITION xoffset, POSITION yoffset, int transno)
321 POSITION dx, dy, x, y, i, j;
325 /* Place dungeon features and objects */
326 floor_type *floor_ptr = player_ptr->current_floor_ptr;
327 for (t = data, dy = 0; dy < ymax; dy++) {
328 for (dx = 0; dx < xmax; dx++, t++) {
329 /* prevent loop counter from being overwritten */
334 coord_trans(&i, &j, xoffset, yoffset, transno);
336 if (transno % 2 == 0) {
338 x = xval - (xmax / 2) + i;
339 y = yval - (ymax / 2) + j;
342 x = xval - (ymax / 2) + i;
343 y = yval - (xmax / 2) + j;
346 /* Hack -- skip "non-grids" */
349 g_ptr = &floor_ptr->grid_array[y][x];
351 /* Lay down a floor */
352 place_grid(player_ptr, g_ptr, GB_FLOOR);
354 /* Remove any mimic */
357 /* Part of a vault */
358 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
360 /* Analyze the grid */
362 /* Granite wall (outer) */
364 place_grid(player_ptr, g_ptr, GB_OUTER_NOPERM);
367 /* Granite wall (inner) */
369 place_grid(player_ptr, g_ptr, GB_INNER);
372 /* Glass wall (inner) */
374 place_grid(player_ptr, g_ptr, GB_INNER);
375 g_ptr->feat = feat_glass_wall;
378 /* Permanent wall (inner) */
380 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
383 /* Permanent glass wall (inner) */
385 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
386 g_ptr->feat = feat_permanent_glass_wall;
391 if (randint0(100) < 75) {
392 place_object(player_ptr, y, x, 0L);
394 place_trap(player_ptr, y, x);
400 place_object(player_ptr, y, x, 0L);
405 g_ptr->feat = feat_tree;
410 place_secret_door(player_ptr, y, x, DOOR_DEFAULT);
413 /* Secret glass doors */
415 place_secret_door(player_ptr, y, x, DOOR_GLASS_DOOR);
416 if (is_closed_door(player_ptr, g_ptr->feat))
417 g_ptr->mimic = feat_glass_wall;
422 place_secret_door(player_ptr, y, x, DOOR_CURTAIN);
427 place_trap(player_ptr, y, x);
430 /* Black market in a dungeon */
432 set_cave_feat(floor_ptr, y, x, feat_black_market);
433 store_init(NO_TOWN, STORE_BLACK);
438 set_cave_feat(floor_ptr, y, x, feat_pattern_start);
442 set_cave_feat(floor_ptr, y, x, feat_pattern_1);
446 set_cave_feat(floor_ptr, y, x, feat_pattern_2);
450 set_cave_feat(floor_ptr, y, x, feat_pattern_3);
454 set_cave_feat(floor_ptr, y, x, feat_pattern_4);
458 set_cave_feat(floor_ptr, y, x, feat_pattern_end);
462 set_cave_feat(floor_ptr, y, x, feat_pattern_exit);
466 /* Reward for Pattern walk */
467 floor_ptr->object_level = floor_ptr->base_level + 12;
468 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
469 floor_ptr->object_level = floor_ptr->base_level;
473 set_cave_feat(floor_ptr, y, x, feat_shallow_water);
477 set_cave_feat(floor_ptr, y, x, feat_deep_water);
481 set_cave_feat(floor_ptr, y, x, feat_shallow_lava);
485 set_cave_feat(floor_ptr, y, x, feat_deep_lava);
489 set_cave_feat(floor_ptr, y, x, feat_shallow_acid_puddle);
493 set_cave_feat(floor_ptr, y, x, feat_deep_acid_puddle);
497 set_cave_feat(floor_ptr, y, x, feat_shallow_poisonous_puddle);
501 set_cave_feat(floor_ptr, y, x, feat_deep_poisonous_puddle);
505 set_cave_feat(floor_ptr, y, x, feat_cold_zone);
509 set_cave_feat(floor_ptr, y, x, feat_heavy_cold_zone);
513 set_cave_feat(floor_ptr, y, x, feat_electrical_zone);
517 set_cave_feat(floor_ptr, y, x, feat_heavy_electrical_zone);
523 /* Place dungeon monsters and objects */
524 for (t = data, dy = 0; dy < ymax; dy++) {
525 for (dx = 0; dx < xmax; dx++, t++) {
526 /* prevent loop counter from being overwritten */
531 coord_trans(&i, &j, xoffset, yoffset, transno);
533 if (transno % 2 == 0) {
535 x = xval - (xmax / 2) + i;
536 y = yval - (ymax / 2) + j;
539 x = xval - (ymax / 2) + i;
540 y = yval - (xmax / 2) + j;
543 /* Hack -- skip "non-grids" */
547 /* Analyze the symbol */
550 floor_ptr->monster_level = floor_ptr->base_level + 5;
551 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
552 floor_ptr->monster_level = floor_ptr->base_level;
558 floor_ptr->monster_level = floor_ptr->base_level + 11;
559 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
560 floor_ptr->monster_level = floor_ptr->base_level;
564 /* Meaner monster, plus treasure */
566 floor_ptr->monster_level = floor_ptr->base_level + 9;
567 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
568 floor_ptr->monster_level = floor_ptr->base_level;
569 floor_ptr->object_level = floor_ptr->base_level + 7;
570 place_object(player_ptr, y, x, AM_GOOD);
571 floor_ptr->object_level = floor_ptr->base_level;
575 /* Nasty monster and treasure */
577 floor_ptr->monster_level = floor_ptr->base_level + 40;
578 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
579 floor_ptr->monster_level = floor_ptr->base_level;
580 floor_ptr->object_level = floor_ptr->base_level + 20;
581 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
582 floor_ptr->object_level = floor_ptr->base_level;
586 /* Monster and/or object */
588 if (randint0(100) < 50) {
589 floor_ptr->monster_level = floor_ptr->base_level + 3;
590 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
591 floor_ptr->monster_level = floor_ptr->base_level;
593 if (randint0(100) < 50) {
594 floor_ptr->object_level = floor_ptr->base_level + 7;
595 place_object(player_ptr, y, x, 0L);
596 floor_ptr->object_level = floor_ptr->base_level;
606 * @brief タイプ7の部屋…v_info.txtより小型vaultを生成する / Type 7 -- simple vaults (see "v_info.txt")
609 bool build_type7(player_type *player_ptr, dun_data_type *dd_ptr)
611 vault_type *v_ptr = NULL;
615 POSITION xoffset, yoffset;
618 /* Pick a lesser vault */
619 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++) {
620 /* Access a random vault record */
621 v_ptr = &v_info[randint0(max_v_idx)];
623 /* Accept the first lesser vault */
628 /* No lesser vault found */
629 if (dummy >= SAFE_MAX_ATTEMPTS) {
630 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("小型固定Vaultを配置できませんでした。", "Could not place lesser vault."));
634 /* pick type of transformation (0-7) */
635 transno = randint0(8);
637 /* calculate offsets */
641 /* Some huge vault cannot be ratated to fit in the dungeon */
642 floor_type *floor_ptr = player_ptr->current_floor_ptr;
643 if (x + 2 > floor_ptr->height - 2) {
644 /* Forbid 90 or 270 degree ratation */
648 coord_trans(&x, &y, 0, 0, transno);
662 /* Find and reserve some space in the dungeon. Get center of room. */
663 if (!find_space(player_ptr, dd_ptr, &yval, &xval, abs(y), abs(x)))
666 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("小型Vault(%s)を生成しました。", "Lesser vault (%s)."), v_name + v_ptr->name);
668 /* Hack -- Build the vault */
669 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid, v_text + v_ptr->text, xoffset, yoffset, transno);
675 * @brief タイプ8の部屋…v_info.txtより大型vaultを生成する / Type 8 -- greater vaults (see "v_info.txt")
678 bool build_type8(player_type *player_ptr, dun_data_type *dd_ptr)
685 POSITION xoffset, yoffset;
687 /* Pick a greater vault */
688 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++) {
689 /* Access a random vault record */
690 v_ptr = &v_info[randint0(max_v_idx)];
692 /* Accept the first greater vault */
697 /* No greater vault found */
698 if (dummy >= SAFE_MAX_ATTEMPTS) {
699 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("大型固定Vaultを配置できませんでした。", "Could not place greater vault."));
703 /* pick type of transformation (0-7) */
704 transno = randint0(8);
706 /* calculate offsets */
710 /* Some huge vault cannot be ratated to fit in the dungeon */
711 floor_type *floor_ptr = player_ptr->current_floor_ptr;
712 if (x + 2 > floor_ptr->height - 2) {
713 /* Forbid 90 or 270 degree ratation */
717 coord_trans(&x, &y, 0, 0, transno);
732 * Try to allocate space for room. If fails, exit
734 * Hack -- Prepare a bit larger space (+2, +2) to
735 * prevent generation of vaults with no-entrance.
737 /* Find and reserve some space in the dungeon. Get center of room. */
738 if (!find_space(player_ptr, dd_ptr, &yval, &xval, (POSITION)(abs(y) + 2), (POSITION)(abs(x) + 2)))
741 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("大型固定Vault(%s)を生成しました。", "Greater vault (%s)."), v_name + v_ptr->name);
743 /* Hack -- Build the vault */
744 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid, v_text + v_ptr->text, xoffset, yoffset, transno);
750 * Build target vault.
751 * This is made by two concentric "crypts" with perpendicular
752 * walls creating the cross-hairs.
754 static void build_target_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
758 /* Make a random metric */
759 POSITION h1, h2, h3, h4;
760 h1 = randint1(32) - 16;
763 h4 = randint1(32) - 16;
765 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Elemental Vault"));
767 /* work out outer radius */
775 floor_type *floor_ptr = player_ptr->current_floor_ptr;
776 for (x = x0 - rad; x <= x0 + rad; x++) {
777 for (y = y0 - rad; y <= y0 + rad; y++) {
778 /* clear room flag */
779 floor_ptr->grid_array[y][x].info &= ~(CAVE_ROOM);
781 /* Vault - so is "icky" */
782 floor_ptr->grid_array[y][x].info |= CAVE_ICKY;
784 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1) {
785 /* inside- so is floor */
786 place_bold(player_ptr, y, x, GB_FLOOR);
788 /* make granite outside so arena works */
789 place_bold(player_ptr, y, x, GB_EXTRA);
792 /* proper boundary for arena */
793 if (((y + rad) == y0) || ((y - rad) == y0) || ((x + rad) == x0) || ((x - rad) == x0)) {
794 place_bold(player_ptr, y, x, GB_EXTRA);
799 /* Find visible outer walls and set to be FEAT_OUTER */
800 add_outer_wall(player_ptr, x0, y0, FALSE, x0 - rad - 1, y0 - rad - 1, x0 + rad + 1, y0 + rad + 1);
803 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++) {
804 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++) {
805 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2) {
806 /* Make an internal wall */
807 place_bold(player_ptr, y, x, GB_INNER);
812 /* Add perpendicular walls */
813 for (x = x0 - rad; x <= x0 + rad; x++) {
814 place_bold(player_ptr, y0, x, GB_INNER);
817 for (y = y0 - rad; y <= y0 + rad; y++) {
818 place_bold(player_ptr, y, x0, GB_INNER);
821 /* Make inner vault */
822 for (y = y0 - 1; y <= y0 + 1; y++) {
823 place_bold(player_ptr, y, x0 - 1, GB_INNER);
824 place_bold(player_ptr, y, x0 + 1, GB_INNER);
826 for (x = x0 - 1; x <= x0 + 1; x++) {
827 place_bold(player_ptr, y0 - 1, x, GB_INNER);
828 place_bold(player_ptr, y0 + 1, x, GB_INNER);
831 place_bold(player_ptr, y0, x0, GB_FLOOR);
833 /* Add doors to vault */
834 /* get two distances so can place doors relative to centre */
835 x = (rad - 2) / 4 + 1;
838 add_door(player_ptr, x0 + x, y0);
839 add_door(player_ptr, x0 + y, y0);
840 add_door(player_ptr, x0 - x, y0);
841 add_door(player_ptr, x0 - y, y0);
842 add_door(player_ptr, x0, y0 + x);
843 add_door(player_ptr, x0, y0 + y);
844 add_door(player_ptr, x0, y0 - x);
845 add_door(player_ptr, x0, y0 - y);
847 /* Fill with stuff - medium difficulty */
848 fill_treasure(player_ptr, x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
852 * This routine uses a modified version of the lake code to make a
853 * distribution of some terrain type over the vault. This type
854 * depends on the dungeon depth.
856 * Miniture rooms are then scattered across the vault.
858 static void build_elemental_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
863 POSITION xsize, ysize, xhsize, yhsize, x, y;
867 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
869 /* round to make sizes even */
875 floor_type *floor_ptr = player_ptr->current_floor_ptr;
876 if (floor_ptr->dun_level < 25) {
877 /* Earth vault (Rubble) */
878 type = LAKE_T_EARTH_VAULT;
879 } else if (floor_ptr->dun_level < 50) {
880 /* Air vault (Trees) */
881 type = LAKE_T_AIR_VAULT;
882 } else if (floor_ptr->dun_level < 75) {
883 /* Water vault (shallow water) */
884 type = LAKE_T_WATER_VAULT;
886 /* Fire vault (shallow lava) */
887 type = LAKE_T_FIRE_VAULT;
891 /* testing values for these parameters: feel free to adjust */
892 grd = 1 << (randint0(3));
894 /* want average of about 16 */
895 roug = randint1(8) * randint1(4);
897 /* Make up size of various componants */
901 /* Deep water/lava */
902 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
904 /* Shallow boundary */
908 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, c3);
910 /* Convert to normal format+ clean up */
911 done = generate_lake(player_ptr, y0, x0, xsize, ysize, c1, c2, c3, type);
914 /* Set icky flag because is a vault */
915 for (x = 0; x <= xsize; x++) {
916 for (y = 0; y <= ysize; y++) {
917 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
921 /* make a few rooms in the vault */
922 for (i = 1; i <= (xsize * ysize) / 50; i++) {
923 build_small_room(player_ptr, x0 + randint0(xsize - 4) - xsize / 2 + 2, y0 + randint0(ysize - 4) - ysize / 2 + 2);
926 /* Fill with monsters and treasure, low difficulty */
927 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
930 /* Build a "mini" checkerboard vault
932 * This is done by making a permanent wall maze and setting
933 * the diagonal sqaures of the checker board to be granite.
934 * The vault has two entrances on opposite sides to guarantee
935 * a way to get in even if the vault abuts a side of the dungeon.
937 static void build_mini_c_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
940 POSITION y1, x1, y2, x2, y, x, total;
941 int m, n, num_vertices;
944 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
946 /* Pick a random room size */
955 /* generate the room */
956 floor_type *floor_ptr = player_ptr->current_floor_ptr;
957 for (x = x1 - 2; x <= x2 + 2; x++) {
958 if (!in_bounds(floor_ptr, y1 - 2, x))
961 floor_ptr->grid_array[y1 - 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
963 place_bold(player_ptr, y1 - 2, x, GB_OUTER_NOPERM);
966 for (x = x1 - 2; x <= x2 + 2; x++) {
967 if (!in_bounds(floor_ptr, y2 + 2, x))
970 floor_ptr->grid_array[y2 + 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
972 place_bold(player_ptr, y2 + 2, x, GB_OUTER_NOPERM);
975 for (y = y1 - 2; y <= y2 + 2; y++) {
976 if (!in_bounds(floor_ptr, y, x1 - 2))
979 floor_ptr->grid_array[y][x1 - 2].info |= (CAVE_ROOM | CAVE_ICKY);
981 place_bold(player_ptr, y, x1 - 2, GB_OUTER_NOPERM);
984 for (y = y1 - 2; y <= y2 + 2; y++) {
985 if (!in_bounds(floor_ptr, y, x2 + 2))
988 floor_ptr->grid_array[y][x2 + 2].info |= (CAVE_ROOM | CAVE_ICKY);
990 place_bold(player_ptr, y, x2 + 2, GB_OUTER_NOPERM);
993 for (y = y1 - 1; y <= y2 + 1; y++) {
994 for (x = x1 - 1; x <= x2 + 1; x++) {
995 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
997 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
999 /* Permanent walls */
1000 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
1004 /* dimensions of vertex array */
1007 num_vertices = m * n;
1009 /* initialize array of visited vertices */
1010 C_MAKE(visited, num_vertices, int);
1012 /* traverse the graph to create a spannng tree, pick a random root */
1013 r_visit(player_ptr, y1, x1, y2, x2, randint0(num_vertices), 0, visited);
1015 /* Make it look like a checker board vault */
1016 for (x = x1; x <= x2; x++) {
1017 for (y = y1; y <= y2; y++) {
1018 total = x - x1 + y - y1;
1019 /* If total is odd- and is a floor then make a wall */
1020 if ((total % 2 == 1) && is_floor_bold(floor_ptr, y, x)) {
1021 place_bold(player_ptr, y, x, GB_INNER);
1026 /* Make a couple of entrances */
1028 /* left and right */
1029 y = randint1(dy) + dy / 2;
1030 place_bold(player_ptr, y1 + y, x1 - 1, GB_INNER);
1031 place_bold(player_ptr, y1 + y, x2 + 1, GB_INNER);
1033 /* top and bottom */
1034 x = randint1(dx) + dx / 2;
1035 place_bold(player_ptr, y1 - 1, x1 + x, GB_INNER);
1036 place_bold(player_ptr, y2 + 1, x1 + x, GB_INNER);
1039 /* Fill with monsters and treasure, highest difficulty */
1040 fill_treasure(player_ptr, x1, x2, y1, y2, 10);
1042 C_KILL(visited, num_vertices, int);
1045 /* Build a castle */
1046 /* Driver routine: clear the region and call the recursive
1049 *This makes a vault that looks like a castle/ city in the dungeon.
1051 static void build_castle_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1054 POSITION y1, x1, y2, x2;
1057 /* Pick a random room size */
1066 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
1068 /* generate the room */
1069 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1070 for (y = y1 - 1; y <= y2 + 1; y++) {
1071 for (x = x1 - 1; x <= x2 + 1; x++) {
1072 floor_ptr->grid_array[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
1073 /* Make everything a floor */
1074 place_bold(player_ptr, y, x, GB_FLOOR);
1078 /* Make the castle */
1079 build_recursive_room(player_ptr, x1, y1, x2, y2, randint1(5));
1081 /* Fill with monsters and treasure, low difficulty */
1082 fill_treasure(player_ptr, x1, x2, y1, y2, randint1(3));
1086 * @brief タイプ10の部屋…ランダム生成vault / Type 10 -- Random vaults
1087 * @param player_ptr プレーヤーへの参照ポインタ
1090 bool build_type10(player_type *player_ptr, dun_data_type *dd_ptr)
1092 POSITION y0, x0, xsize, ysize, vtype;
1094 /* big enough to look good, small enough to be fairly common. */
1095 xsize = randint1(22) + 22;
1096 ysize = randint1(11) + 11;
1098 /* Find and reserve some space in the dungeon. Get center of room. */
1099 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1100 if (!find_space(player_ptr, dd_ptr, &y0, &x0, ysize + 1, xsize + 1))
1103 /* Select type of vault */
1105 vtype = randint1(15);
1106 } while ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) && ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
1109 /* Build an appropriate room */
1112 build_bubble_vault(player_ptr, x0, y0, xsize, ysize);
1116 build_room_vault(player_ptr, x0, y0, xsize, ysize);
1120 build_cave_vault(player_ptr, x0, y0, xsize, ysize);
1124 build_maze_vault(player_ptr, x0, y0, xsize, ysize, TRUE);
1128 build_mini_c_vault(player_ptr, x0, y0, xsize, ysize);
1132 build_castle_vault(player_ptr, x0, y0, xsize, ysize);
1136 build_target_vault(player_ptr, x0, y0, xsize, ysize);
1139 build_elemental_vault(player_ptr, x0, y0, xsize, ysize);
1141 /* I know how to add a few more... give me some time. */
1150 * @brief タイプ17の部屋…v_info.txtより固定特殊部屋を生成する / Type 17 -- fixed special room (see "v_info.txt")
1153 bool build_type17(player_type *player_ptr, dun_data_type *dd_ptr)
1155 vault_type *v_ptr = NULL;
1158 POSITION xval, yval;
1159 POSITION xoffset, yoffset;
1162 /* Pick a lesser vault */
1163 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++) {
1164 /* Access a random vault record */
1165 v_ptr = &v_info[randint0(max_v_idx)];
1167 /* Accept the special fix room. */
1168 if (v_ptr->typ == 17)
1172 /* No lesser vault found */
1173 if (dummy >= SAFE_MAX_ATTEMPTS) {
1174 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("固定特殊部屋を配置できませんでした。", "Could not place fixed special room."));
1178 /* pick type of transformation (0-7) */
1179 transno = randint0(8);
1181 /* calculate offsets */
1185 /* Some huge vault cannot be ratated to fit in the dungeon */
1186 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1187 if (x + 2 > floor_ptr->height - 2) {
1188 /* Forbid 90 or 270 degree ratation */
1192 coord_trans(&x, &y, 0, 0, transno);
1206 /* Find and reserve some space in the dungeon. Get center of room. */
1207 if (!find_space(player_ptr, dd_ptr, &yval, &xval, abs(y), abs(x)))
1210 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("特殊固定部屋(%s)を生成しました。", "Special Fix room (%s)."), v_name + v_ptr->name);
1212 /* Hack -- Build the vault */
1213 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid, v_text + v_ptr->text, xoffset, yoffset, transno);