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.h"
24 #include "store/store-util.h"
25 #include "store/store.h"
26 #include "system/dungeon-data-definition.h"
27 #include "system/floor-type-definition.h"
28 #include "wizard/wizard-messages.h"
31 * The vault generation arrays
38 * Maximum number of vaults in v_info.txt
43 * This function creates a random vault that looks like a collection of bubbles.
44 * It works by getting a set of coordinates that represent the center of each
45 * bubble. The entire room is made by seeing which bubble center is closest. If
46 * two centers are equidistant then the square is a wall, otherwise it is a floor.
47 * The only exception is for squares really near a center, these are always floor.
48 * (It looks better than without this check.)
50 * Note: If two centers are on the same point then this algorithm will create a
51 * blank bubble filled with walls. - This is prevented from happening.
53 static void build_bubble_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
55 #define BUBBLENUM 10 /* number of bubbles */
57 /* array of center points of bubbles */
58 coord center[BUBBLENUM];
61 POSITION x = 0, y = 0;
62 u16b min1, min2, temp;
65 /* Offset from center to top left hand corner */
66 POSITION xhsize = xsize / 2;
67 POSITION yhsize = ysize / 2;
69 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("泡型ランダムVaultを生成しました。", "Room Vault."));
71 /* Allocate center of bubbles */
72 center[0].x = (byte)randint1(xsize - 3) + 1;
73 center[0].y = (byte)randint1(ysize - 3) + 1;
75 for (i = 1; i < BUBBLENUM; i++)
79 /* get center and check to see if it is unique */
84 x = randint1(xsize - 3) + 1;
85 y = randint1(ysize - 3) + 1;
87 for (j = 0; j < i; j++)
89 /* rough test to see if there is an overlap */
90 if ((x == center[j].x) && (y == center[j].y)) done = FALSE;
98 /* Top and bottom boundaries */
99 floor_type *floor_ptr = player_ptr->current_floor_ptr;
100 for (i = 0; i < xsize; i++)
102 int side_x = x0 - xhsize + i;
104 place_bold(player_ptr, y0 - yhsize + 0, side_x, GB_OUTER_NOPERM);
105 floor_ptr->grid_array[y0 - yhsize + 0][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
106 place_bold(player_ptr, y0 - yhsize + ysize - 1, side_x, GB_OUTER_NOPERM);
107 floor_ptr->grid_array[y0 - yhsize + ysize - 1][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
110 /* Left and right boundaries */
111 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++)
124 for (y = 1; y < ysize - 1; y++)
126 /* Get distances to two closest centers */
128 min1 = (u16b)distance(x, y, center[0].x, center[0].y);
129 min2 = (u16b)distance(x, y, center[1].x, center[1].y);
133 /* swap if in wrong order */
140 for (i = 2; i < BUBBLENUM; i++)
142 temp = (u16b)distance(x, y, center[i].x, center[i].y);
150 else if (temp < min2)
152 /* second smallest */
156 if (((min2 - min1) <= 2) && (!(min1 < 3)))
158 /* Boundary at midpoint+ not at inner region of bubble */
159 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_OUTER_NOPERM);
163 /* middle of a bubble */
164 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_FLOOR);
167 /* clean up rest of flags */
168 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= (CAVE_ROOM | CAVE_ICKY);
172 /* Try to add some random doors */
173 for (i = 0; i < 500; i++)
175 x = randint1(xsize - 3) - xhsize + x0 + 1;
176 y = randint1(ysize - 3) - yhsize + y0 + 1;
177 add_door(player_ptr, x, y);
180 /* Fill with monsters and treasure, low difficulty */
181 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5));
184 /* Create a random vault that looks like a collection of overlapping rooms */
185 static void build_room_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
187 POSITION x1, x2, y1, y2, xhsize, yhsize;
190 /* get offset from center */
194 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("部屋型ランダムVaultを生成しました。", "Room Vault."));
196 /* fill area so don't get problems with arena levels */
197 floor_type *floor_ptr = player_ptr->current_floor_ptr;
198 for (x1 = 0; x1 < xsize; x1++)
200 POSITION x = x0 - xhsize + x1;
202 for (y1 = 0; y1 < ysize; y1++)
204 POSITION y = y0 - yhsize + y1;
206 place_bold(player_ptr, y, x, GB_EXTRA);
207 floor_ptr->grid_array[y][x].info &= (~CAVE_ICKY);
211 /* add ten random rooms */
212 for (i = 0; i < 10; i++)
214 x1 = randint1(xhsize) * 2 + x0 - xhsize;
215 x2 = randint1(xhsize) * 2 + x0 - xhsize;
216 y1 = randint1(yhsize) * 2 + y0 - yhsize;
217 y2 = randint1(yhsize) * 2 + y0 - yhsize;
218 build_room(player_ptr, x1, x2, y1, y2);
221 /* Add some random doors */
222 for (i = 0; i < 500; i++)
224 x1 = randint1(xsize - 3) - xhsize + x0 + 1;
225 y1 = randint1(ysize - 3) - yhsize + y0 + 1;
226 add_door(player_ptr, x1, y1);
229 /* Fill with monsters and treasure, high difficulty */
230 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5);
234 /* Create a random vault out of a fractal grid */
235 static void build_cave_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
237 int grd, roug, cutoff;
238 bool done, light, room;
239 POSITION xhsize, yhsize, xsize, ysize, x, y;
241 /* round to make sizes even */
247 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("洞穴ランダムVaultを生成しました。", "Cave Vault."));
249 light = done = FALSE;
252 floor_type *floor_ptr = player_ptr->current_floor_ptr;
255 /* testing values for these parameters feel free to adjust */
256 grd = 1 << randint0(4);
258 /* want average of about 16 */
259 roug = randint1(8) * randint1(4);
262 cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
263 randint1(xsize / 4) + randint1(ysize / 4);
266 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, cutoff);
268 /* Convert to normal format+ clean up */
269 done = generate_fracave(player_ptr, y0, x0, xsize, ysize, cutoff, light, room);
272 /* Set icky flag because is a vault */
273 for (x = 0; x <= xsize; x++)
275 for (y = 0; y <= ysize; y++)
277 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
281 /* Fill with monsters and treasure, low difficulty */
282 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
287 * @brief Vault地形を回転、上下左右反転するための座標変換を返す / coordinate translation code
288 * @param x 変換したい点のX座標参照ポインタ
289 * @param y 変換したい点のY座標参照ポインタ
290 * @param xoffset Vault生成時の基準X座標
291 * @param yoffset Vault生成時の基準Y座標
292 * @param transno 処理ID
295 static void coord_trans(POSITION *x, POSITION *y, POSITION xoffset, POSITION yoffset, int transno)
301 * transno specifies what transformation is required. (0-7)
302 * The lower two bits indicate by how much the vault is rotated,
303 * and the upper bit indicates a reflection.
304 * This is done by using rotation matrices... however since
305 * these are mostly zeros for rotations by 90 degrees this can
306 * be expressed simply in terms of swapping and inverting the
307 * x and y coordinates.
309 for (i = 0; i < transno % 4; i++)
311 /* rotate by 90 degrees */
319 /* Reflect depending on status of 3rd bit. */
323 /* Add offsets so vault stays in the first quadrant */
330 * @brief Vaultをフロアに配置する / Hack -- fill in "vault" rooms
331 * @param player_ptr プレーヤーへの参照ポインタ
332 * @param yval 生成基準Y座標
333 * @param xval 生成基準X座標
334 * @param ymax VaultのYサイズ
335 * @param xmax VaultのXサイズ
336 * @param data Vaultのデータ文字列
337 * @param xoffset 変換基準X座標
338 * @param yoffset 変換基準Y座標
339 * @param transno 変換ID
342 static void build_vault(player_type *player_ptr, POSITION yval, POSITION xval, POSITION ymax, POSITION xmax, concptr data,
343 POSITION xoffset, POSITION yoffset, int transno)
345 POSITION dx, dy, x, y, i, j;
349 /* Place dungeon features and objects */
350 floor_type *floor_ptr = player_ptr->current_floor_ptr;
351 for (t = data, dy = 0; dy < ymax; dy++)
353 for (dx = 0; dx < xmax; dx++, t++)
355 /* prevent loop counter from being overwritten */
360 coord_trans(&i, &j, xoffset, yoffset, transno);
362 if (transno % 2 == 0)
365 x = xval - (xmax / 2) + i;
366 y = yval - (ymax / 2) + j;
371 x = xval - (ymax / 2) + i;
372 y = yval - (xmax / 2) + j;
375 /* Hack -- skip "non-grids" */
376 if (*t == ' ') continue;
377 g_ptr = &floor_ptr->grid_array[y][x];
379 /* Lay down a floor */
380 place_grid(player_ptr, g_ptr, GB_FLOOR);
382 /* Remove any mimic */
385 /* Part of a vault */
386 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
388 /* Analyze the grid */
391 /* Granite wall (outer) */
393 place_grid(player_ptr, g_ptr, GB_OUTER_NOPERM);
396 /* Granite wall (inner) */
398 place_grid(player_ptr, g_ptr, GB_INNER);
401 /* Glass wall (inner) */
403 place_grid(player_ptr, g_ptr, GB_INNER);
404 g_ptr->feat = feat_glass_wall;
407 /* Permanent wall (inner) */
409 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
412 /* Permanent glass wall (inner) */
414 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
415 g_ptr->feat = feat_permanent_glass_wall;
420 if (randint0(100) < 75)
422 place_object(player_ptr, y, x, 0L);
426 place_trap(player_ptr, y, x);
432 place_object(player_ptr, y, x, 0L);
437 g_ptr->feat = feat_tree;
442 place_secret_door(player_ptr, y, x, DOOR_DEFAULT);
445 /* Secret glass doors */
447 place_secret_door(player_ptr, y, x, DOOR_GLASS_DOOR);
448 if (is_closed_door(player_ptr, g_ptr->feat)) g_ptr->mimic = feat_glass_wall;
453 place_secret_door(player_ptr, y, x, DOOR_CURTAIN);
458 place_trap(player_ptr, y, x);
461 /* Black market in a dungeon */
463 set_cave_feat(floor_ptr, y, x, feat_black_market);
464 store_init(NO_TOWN, STORE_BLACK);
469 set_cave_feat(floor_ptr, y, x, feat_pattern_start);
473 set_cave_feat(floor_ptr, y, x, feat_pattern_1);
477 set_cave_feat(floor_ptr, y, x, feat_pattern_2);
481 set_cave_feat(floor_ptr, y, x, feat_pattern_3);
485 set_cave_feat(floor_ptr, y, x, feat_pattern_4);
489 set_cave_feat(floor_ptr, y, x, feat_pattern_end);
493 set_cave_feat(floor_ptr, y, x, feat_pattern_exit);
497 /* Reward for Pattern walk */
498 floor_ptr->object_level = floor_ptr->base_level + 12;
499 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
500 floor_ptr->object_level = floor_ptr->base_level;
504 set_cave_feat(floor_ptr, y, x, feat_shallow_water);
508 set_cave_feat(floor_ptr, y, x, feat_deep_water);
512 set_cave_feat(floor_ptr, y, x, feat_shallow_lava);
516 set_cave_feat(floor_ptr, y, x, feat_deep_lava);
520 set_cave_feat(floor_ptr, y, x, feat_shallow_acid_puddle);
524 set_cave_feat(floor_ptr, y, x, feat_deep_acid_puddle);
528 set_cave_feat(floor_ptr, y, x, feat_shallow_poisonous_puddle);
532 set_cave_feat(floor_ptr, y, x, feat_deep_poisonous_puddle);
536 set_cave_feat(floor_ptr, y, x, feat_cold_zone);
540 set_cave_feat(floor_ptr, y, x, feat_heavy_cold_zone);
544 set_cave_feat(floor_ptr, y, x, feat_electrical_zone);
548 set_cave_feat(floor_ptr, y, x, feat_heavy_electrical_zone);
556 /* Place dungeon monsters and objects */
557 for (t = data, dy = 0; dy < ymax; dy++)
559 for (dx = 0; dx < xmax; dx++, t++)
561 /* prevent loop counter from being overwritten */
566 coord_trans(&i, &j, xoffset, yoffset, transno);
568 if (transno % 2 == 0)
571 x = xval - (xmax / 2) + i;
572 y = yval - (ymax / 2) + j;
577 x = xval - (ymax / 2) + i;
578 y = yval - (xmax / 2) + j;
581 /* Hack -- skip "non-grids" */
582 if (*t == ' ') continue;
584 /* Analyze the symbol */
589 floor_ptr->monster_level = floor_ptr->base_level + 5;
590 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
591 floor_ptr->monster_level = floor_ptr->base_level;
598 floor_ptr->monster_level = floor_ptr->base_level + 11;
599 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
600 floor_ptr->monster_level = floor_ptr->base_level;
604 /* Meaner monster, plus treasure */
607 floor_ptr->monster_level = floor_ptr->base_level + 9;
608 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
609 floor_ptr->monster_level = floor_ptr->base_level;
610 floor_ptr->object_level = floor_ptr->base_level + 7;
611 place_object(player_ptr, y, x, AM_GOOD);
612 floor_ptr->object_level = floor_ptr->base_level;
616 /* Nasty monster and treasure */
619 floor_ptr->monster_level = floor_ptr->base_level + 40;
620 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
621 floor_ptr->monster_level = floor_ptr->base_level;
622 floor_ptr->object_level = floor_ptr->base_level + 20;
623 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
624 floor_ptr->object_level = floor_ptr->base_level;
628 /* Monster and/or object */
631 if (randint0(100) < 50)
633 floor_ptr->monster_level = floor_ptr->base_level + 3;
634 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
635 floor_ptr->monster_level = floor_ptr->base_level;
637 if (randint0(100) < 50)
639 floor_ptr->object_level = floor_ptr->base_level + 7;
640 place_object(player_ptr, y, x, 0L);
641 floor_ptr->object_level = floor_ptr->base_level;
652 * @brief タイプ7の部屋…v_info.txtより小型vaultを生成する / Type 7 -- simple vaults (see "v_info.txt")
655 bool build_type7(player_type *player_ptr)
657 vault_type *v_ptr = NULL;
661 POSITION xoffset, yoffset;
664 /* Pick a lesser vault */
665 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
667 /* Access a random vault record */
668 v_ptr = &v_info[randint0(max_v_idx)];
670 /* Accept the first lesser vault */
671 if (v_ptr->typ == 7) break;
674 /* No lesser vault found */
675 if (dummy >= SAFE_MAX_ATTEMPTS)
677 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("小型固定Vaultを配置できませんでした。", "Could not place lesser vault."));
681 /* pick type of transformation (0-7) */
682 transno = randint0(8);
684 /* calculate offsets */
688 /* Some huge vault cannot be ratated to fit in the dungeon */
689 floor_type *floor_ptr = player_ptr->current_floor_ptr;
690 if (x + 2 > floor_ptr->height - 2)
692 /* Forbid 90 or 270 degree ratation */
696 coord_trans(&x, &y, 0, 0, transno);
716 /* Find and reserve some space in the dungeon. Get center of room. */
717 if (!find_space(player_ptr, &yval, &xval, abs(y), abs(x))) return FALSE;
719 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("小型Vault(%s)を生成しました。", "Lesser vault (%s)."), v_name + v_ptr->name);
721 /* Hack -- Build the vault */
722 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
723 v_text + v_ptr->text, xoffset, yoffset, transno);
730 * @brief タイプ8の部屋…v_info.txtより大型vaultを生成する / Type 8 -- greater vaults (see "v_info.txt")
733 bool build_type8(player_type *player_ptr)
740 POSITION xoffset, yoffset;
742 /* Pick a greater vault */
743 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
745 /* Access a random vault record */
746 v_ptr = &v_info[randint0(max_v_idx)];
748 /* Accept the first greater vault */
749 if (v_ptr->typ == 8) break;
752 /* No greater vault found */
753 if (dummy >= SAFE_MAX_ATTEMPTS)
755 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("大型固定Vaultを配置できませんでした。", "Could not place greater vault."));
759 /* pick type of transformation (0-7) */
760 transno = randint0(8);
762 /* calculate offsets */
766 /* Some huge vault cannot be ratated to fit in the dungeon */
767 floor_type *floor_ptr = player_ptr->current_floor_ptr;
768 if (x + 2 > floor_ptr->height - 2)
770 /* Forbid 90 or 270 degree ratation */
774 coord_trans(&x, &y, 0, 0, transno);
795 * Try to allocate space for room. If fails, exit
797 * Hack -- Prepare a bit larger space (+2, +2) to
798 * prevent generation of vaults with no-entrance.
800 /* Find and reserve some space in the dungeon. Get center of room. */
801 if (!find_space(player_ptr, &yval, &xval, (POSITION)(abs(y) + 2), (POSITION)(abs(x) + 2))) return FALSE;
803 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("大型固定Vault(%s)を生成しました。", "Greater vault (%s)."), v_name + v_ptr->name);
805 /* Hack -- Build the vault */
806 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
807 v_text + v_ptr->text, xoffset, yoffset, transno);
814 * Build target vault.
815 * This is made by two concentric "crypts" with perpendicular
816 * walls creating the cross-hairs.
818 static void build_target_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
822 /* Make a random metric */
823 POSITION h1, h2, h3, h4;
824 h1 = randint1(32) - 16;
827 h4 = randint1(32) - 16;
829 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Elemental Vault"));
831 /* work out outer radius */
842 floor_type *floor_ptr = player_ptr->current_floor_ptr;
843 for (x = x0 - rad; x <= x0 + rad; x++)
845 for (y = y0 - rad; y <= y0 + rad; y++)
847 /* clear room flag */
848 floor_ptr->grid_array[y][x].info &= ~(CAVE_ROOM);
850 /* Vault - so is "icky" */
851 floor_ptr->grid_array[y][x].info |= CAVE_ICKY;
853 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1)
855 /* inside- so is floor */
856 place_bold(player_ptr, y, x, GB_FLOOR);
860 /* make granite outside so arena works */
861 place_bold(player_ptr, y, x, GB_EXTRA);
864 /* proper boundary for arena */
865 if (((y + rad) == y0) || ((y - rad) == y0) ||
866 ((x + rad) == x0) || ((x - rad) == x0))
868 place_bold(player_ptr, y, x, GB_EXTRA);
873 /* Find visible outer walls and set to be FEAT_OUTER */
874 add_outer_wall(player_ptr, x0, y0, FALSE, x0 - rad - 1, y0 - rad - 1, x0 + rad + 1, y0 + rad + 1);
877 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++)
879 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++)
881 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2)
883 /* Make an internal wall */
884 place_bold(player_ptr, y, x, GB_INNER);
889 /* Add perpendicular walls */
890 for (x = x0 - rad; x <= x0 + rad; x++)
892 place_bold(player_ptr, y0, x, GB_INNER);
895 for (y = y0 - rad; y <= y0 + rad; y++)
897 place_bold(player_ptr, y, x0, GB_INNER);
900 /* Make inner vault */
901 for (y = y0 - 1; y <= y0 + 1; y++)
903 place_bold(player_ptr, y, x0 - 1, GB_INNER);
904 place_bold(player_ptr, y, x0 + 1, GB_INNER);
906 for (x = x0 - 1; x <= x0 + 1; x++)
908 place_bold(player_ptr, y0 - 1, x, GB_INNER);
909 place_bold(player_ptr, y0 + 1, x, GB_INNER);
912 place_bold(player_ptr, y0, x0, GB_FLOOR);
915 /* Add doors to vault */
916 /* get two distances so can place doors relative to centre */
917 x = (rad - 2) / 4 + 1;
920 add_door(player_ptr, x0 + x, y0);
921 add_door(player_ptr, x0 + y, y0);
922 add_door(player_ptr, x0 - x, y0);
923 add_door(player_ptr, x0 - y, y0);
924 add_door(player_ptr, x0, y0 + x);
925 add_door(player_ptr, x0, y0 + y);
926 add_door(player_ptr, x0, y0 - x);
927 add_door(player_ptr, x0, y0 - y);
929 /* Fill with stuff - medium difficulty */
930 fill_treasure(player_ptr, x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
935 * This routine uses a modified version of the lake code to make a
936 * distribution of some terrain type over the vault. This type
937 * depends on the dungeon depth.
939 * Miniture rooms are then scattered across the vault.
941 static void build_elemental_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
946 POSITION xsize, ysize, xhsize, yhsize, x, y;
950 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
952 /* round to make sizes even */
958 floor_type *floor_ptr = player_ptr->current_floor_ptr;
959 if (floor_ptr->dun_level < 25)
961 /* Earth vault (Rubble) */
962 type = LAKE_T_EARTH_VAULT;
964 else if (floor_ptr->dun_level < 50)
966 /* Air vault (Trees) */
967 type = LAKE_T_AIR_VAULT;
969 else if (floor_ptr->dun_level < 75)
971 /* Water vault (shallow water) */
972 type = LAKE_T_WATER_VAULT;
976 /* Fire vault (shallow lava) */
977 type = LAKE_T_FIRE_VAULT;
982 /* testing values for these parameters: feel free to adjust */
983 grd = 1 << (randint0(3));
985 /* want average of about 16 */
986 roug = randint1(8) * randint1(4);
988 /* Make up size of various componants */
992 /* Deep water/lava */
993 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
995 /* Shallow boundary */
999 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, c3);
1001 /* Convert to normal format+ clean up */
1002 done = generate_lake(player_ptr, y0, x0, xsize, ysize, c1, c2, c3, type);
1005 /* Set icky flag because is a vault */
1006 for (x = 0; x <= xsize; x++)
1008 for (y = 0; y <= ysize; y++)
1010 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
1014 /* make a few rooms in the vault */
1015 for (i = 1; i <= (xsize * ysize) / 50; i++)
1017 build_small_room(player_ptr, x0 + randint0(xsize - 4) - xsize / 2 + 2,
1018 y0 + randint0(ysize - 4) - ysize / 2 + 2);
1021 /* Fill with monsters and treasure, low difficulty */
1022 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1,
1023 y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
1027 /* Build a "mini" checkerboard vault
1029 * This is done by making a permanent wall maze and setting
1030 * the diagonal sqaures of the checker board to be granite.
1031 * The vault has two entrances on opposite sides to guarantee
1032 * a way to get in even if the vault abuts a side of the dungeon.
1034 static void build_mini_c_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1037 POSITION y1, x1, y2, x2, y, x, total;
1038 int m, n, num_vertices;
1041 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
1043 /* Pick a random room size */
1053 /* generate the room */
1054 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1055 for (x = x1 - 2; x <= x2 + 2; x++)
1057 if (!in_bounds(floor_ptr, y1 - 2, x)) break;
1059 floor_ptr->grid_array[y1 - 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1061 place_bold(player_ptr, y1 - 2, x, GB_OUTER_NOPERM);
1064 for (x = x1 - 2; x <= x2 + 2; x++)
1066 if (!in_bounds(floor_ptr, y2 + 2, x)) break;
1068 floor_ptr->grid_array[y2 + 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1070 place_bold(player_ptr, y2 + 2, x, GB_OUTER_NOPERM);
1073 for (y = y1 - 2; y <= y2 + 2; y++)
1075 if (!in_bounds(floor_ptr, y, x1 - 2)) break;
1077 floor_ptr->grid_array[y][x1 - 2].info |= (CAVE_ROOM | CAVE_ICKY);
1079 place_bold(player_ptr, y, x1 - 2, GB_OUTER_NOPERM);
1082 for (y = y1 - 2; y <= y2 + 2; y++)
1084 if (!in_bounds(floor_ptr, y, x2 + 2)) break;
1086 floor_ptr->grid_array[y][x2 + 2].info |= (CAVE_ROOM | CAVE_ICKY);
1088 place_bold(player_ptr, y, x2 + 2, GB_OUTER_NOPERM);
1091 for (y = y1 - 1; y <= y2 + 1; y++)
1093 for (x = x1 - 1; x <= x2 + 1; x++)
1095 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1097 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
1099 /* Permanent walls */
1100 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
1105 /* dimensions of vertex array */
1108 num_vertices = m * n;
1110 /* initialize array of visited vertices */
1111 C_MAKE(visited, num_vertices, int);
1113 /* traverse the graph to create a spannng tree, pick a random root */
1114 r_visit(player_ptr, y1, x1, y2, x2, randint0(num_vertices), 0, visited);
1116 /* Make it look like a checker board vault */
1117 for (x = x1; x <= x2; x++)
1119 for (y = y1; y <= y2; y++)
1121 total = x - x1 + y - y1;
1122 /* If total is odd- and is a floor then make a wall */
1123 if ((total % 2 == 1) && is_floor_bold(floor_ptr, y, x))
1125 place_bold(player_ptr, y, x, GB_INNER);
1130 /* Make a couple of entrances */
1133 /* left and right */
1134 y = randint1(dy) + dy / 2;
1135 place_bold(player_ptr, y1 + y, x1 - 1, GB_INNER);
1136 place_bold(player_ptr, y1 + y, x2 + 1, GB_INNER);
1140 /* top and bottom */
1141 x = randint1(dx) + dx / 2;
1142 place_bold(player_ptr, y1 - 1, x1 + x, GB_INNER);
1143 place_bold(player_ptr, y2 + 1, x1 + x, GB_INNER);
1146 /* Fill with monsters and treasure, highest difficulty */
1147 fill_treasure(player_ptr, x1, x2, y1, y2, 10);
1149 C_KILL(visited, num_vertices, int);
1152 /* Build a castle */
1153 /* Driver routine: clear the region and call the recursive
1156 *This makes a vault that looks like a castle/ city in the dungeon.
1158 static void build_castle_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1161 POSITION y1, x1, y2, x2;
1164 /* Pick a random room size */
1173 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
1175 /* generate the room */
1176 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1177 for (y = y1 - 1; y <= y2 + 1; y++)
1179 for (x = x1 - 1; x <= x2 + 1; x++)
1181 floor_ptr->grid_array[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
1182 /* Make everything a floor */
1183 place_bold(player_ptr, y, x, GB_FLOOR);
1187 /* Make the castle */
1188 build_recursive_room(player_ptr, x1, y1, x2, y2, randint1(5));
1190 /* Fill with monsters and treasure, low difficulty */
1191 fill_treasure(player_ptr, x1, x2, y1, y2, randint1(3));
1196 * @brief タイプ10の部屋…ランダム生成vault / Type 10 -- Random vaults
1197 * @param player_ptr プレーヤーへの参照ポインタ
1200 bool build_type10(player_type *player_ptr)
1202 POSITION y0, x0, xsize, ysize, vtype;
1204 /* big enough to look good, small enough to be fairly common. */
1205 xsize = randint1(22) + 22;
1206 ysize = randint1(11) + 11;
1208 /* Find and reserve some space in the dungeon. Get center of room. */
1209 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1210 if (!find_space(player_ptr, &y0, &x0, ysize + 1, xsize + 1)) return FALSE;
1212 /* Select type of vault */
1215 vtype = randint1(15);
1216 } while ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) &&
1217 ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
1221 /* Build an appropriate room */
1222 case 1: case 9: build_bubble_vault(player_ptr, x0, y0, xsize, ysize); break;
1223 case 2: case 10: build_room_vault(player_ptr, x0, y0, xsize, ysize); break;
1224 case 3: case 11: build_cave_vault(player_ptr, x0, y0, xsize, ysize); break;
1225 case 4: case 12: build_maze_vault(player_ptr, x0, y0, xsize, ysize, TRUE); break;
1226 case 5: case 13: build_mini_c_vault(player_ptr, x0, y0, xsize, ysize); break;
1227 case 6: case 14: build_castle_vault(player_ptr, x0, y0, xsize, ysize); break;
1228 case 7: case 15: build_target_vault(player_ptr, x0, y0, xsize, ysize); break;
1229 case 8: build_elemental_vault(player_ptr, x0, y0, xsize, ysize); break;
1230 /* I know how to add a few more... give me some time. */
1231 default: return FALSE;
1239 * @brief タイプ17の部屋…v_info.txtより固定特殊部屋を生成する / Type 17 -- fixed special room (see "v_info.txt")
1242 bool build_type17(player_type *player_ptr)
1244 vault_type *v_ptr = NULL;
1247 POSITION xval, yval;
1248 POSITION xoffset, yoffset;
1251 /* Pick a lesser vault */
1252 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
1254 /* Access a random vault record */
1255 v_ptr = &v_info[randint0(max_v_idx)];
1257 /* Accept the special fix room. */
1258 if (v_ptr->typ == 17) break;
1261 /* No lesser vault found */
1262 if (dummy >= SAFE_MAX_ATTEMPTS)
1264 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("固定特殊部屋を配置できませんでした。", "Could not place fixed special room."));
1268 /* pick type of transformation (0-7) */
1269 transno = randint0(8);
1271 /* calculate offsets */
1275 /* Some huge vault cannot be ratated to fit in the dungeon */
1276 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1277 if (x + 2 > floor_ptr->height - 2)
1279 /* Forbid 90 or 270 degree ratation */
1283 coord_trans(&x, &y, 0, 0, transno);
1303 /* Find and reserve some space in the dungeon. Get center of room. */
1304 if (!find_space(player_ptr, &yval, &xval, abs(y), abs(x))) return FALSE;
1306 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("特殊固定部屋(%s)を生成しました。", "Special Fix room (%s)."), v_name + v_ptr->name);
1308 /* Hack -- Build the vault */
1309 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
1310 v_text + v_ptr->text, xoffset, yoffset, transno);