7 #include "room/rooms-vault.h"
8 #include "dungeon/dungeon.h"
9 #include "floor/floor-generate.h"
10 #include "floor/floor.h"
11 #include "floor/geometry.h"
12 #include "floor/wild.h"
13 #include "grid/feature.h"
14 #include "grid/grid.h"
15 #include "grid/trap.h"
16 #include "monster/monster.h"
17 #include "monster/place-monster-types.h"
18 #include "object-enchant/item-apply-magic.h"
19 #include "room/rooms.h"
20 #include "store/store-util.h"
21 #include "store/store.h"
22 #include "util/util.h"
25 * The vault generation arrays
32 * Maximum number of vaults in v_info.txt
37 * This function creates a random vault that looks like a collection of bubbles.
38 * It works by getting a set of coordinates that represent the center of each
39 * bubble. The entire room is made by seeing which bubble center is closest. If
40 * two centers are equidistant then the square is a wall, otherwise it is a floor.
41 * The only exception is for squares really near a center, these are always floor.
42 * (It looks better than without this check.)
44 * Note: If two centers are on the same point then this algorithm will create a
45 * blank bubble filled with walls. - This is prevented from happening.
47 static void build_bubble_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
49 #define BUBBLENUM 10 /* number of bubbles */
51 /* array of center points of bubbles */
52 coord center[BUBBLENUM];
55 POSITION x = 0, y = 0;
56 u16b min1, min2, temp;
59 /* Offset from center to top left hand corner */
60 POSITION xhsize = xsize / 2;
61 POSITION yhsize = ysize / 2;
63 msg_print_wizard(CHEAT_DUNGEON, _("泡型ランダムVaultを生成しました。", "Room Vault."));
65 /* Allocate center of bubbles */
66 center[0].x = (byte)randint1(xsize - 3) + 1;
67 center[0].y = (byte)randint1(ysize - 3) + 1;
69 for (i = 1; i < BUBBLENUM; i++)
73 /* get center and check to see if it is unique */
78 x = randint1(xsize - 3) + 1;
79 y = randint1(ysize - 3) + 1;
81 for (j = 0; j < i; j++)
83 /* rough test to see if there is an overlap */
84 if ((x == center[j].x) && (y == center[j].y)) done = FALSE;
92 /* Top and bottom boundaries */
93 floor_type *floor_ptr = player_ptr->current_floor_ptr;
94 for (i = 0; i < xsize; i++)
96 int side_x = x0 - xhsize + i;
98 place_bold(player_ptr, y0 - yhsize + 0, side_x, GB_OUTER_NOPERM);
99 floor_ptr->grid_array[y0 - yhsize + 0][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
100 place_bold(player_ptr, y0 - yhsize + ysize - 1, side_x, GB_OUTER_NOPERM);
101 floor_ptr->grid_array[y0 - yhsize + ysize - 1][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
104 /* Left and right boundaries */
105 for (i = 1; i < ysize - 1; i++)
107 int side_y = y0 - yhsize + i;
109 place_bold(player_ptr, side_y, x0 - xhsize + 0, GB_OUTER_NOPERM);
110 floor_ptr->grid_array[side_y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
111 place_bold(player_ptr, side_y, x0 - xhsize + xsize - 1, GB_OUTER_NOPERM);
112 floor_ptr->grid_array[side_y][x0 - xhsize + xsize - 1].info |= (CAVE_ROOM | CAVE_ICKY);
115 /* Fill in middle with bubbles */
116 for (x = 1; x < xsize - 1; x++)
118 for (y = 1; y < ysize - 1; y++)
120 /* Get distances to two closest centers */
122 min1 = (u16b)distance(x, y, center[0].x, center[0].y);
123 min2 = (u16b)distance(x, y, center[1].x, center[1].y);
127 /* swap if in wrong order */
134 for (i = 2; i < BUBBLENUM; i++)
136 temp = (u16b)distance(x, y, center[i].x, center[i].y);
144 else if (temp < min2)
146 /* second smallest */
150 if (((min2 - min1) <= 2) && (!(min1 < 3)))
152 /* Boundary at midpoint+ not at inner region of bubble */
153 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_OUTER_NOPERM);
157 /* middle of a bubble */
158 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_FLOOR);
161 /* clean up rest of flags */
162 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= (CAVE_ROOM | CAVE_ICKY);
166 /* Try to add some random doors */
167 for (i = 0; i < 500; i++)
169 x = randint1(xsize - 3) - xhsize + x0 + 1;
170 y = randint1(ysize - 3) - yhsize + y0 + 1;
171 add_door(player_ptr, x, y);
174 /* Fill with monsters and treasure, low difficulty */
175 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5));
178 /* Create a random vault that looks like a collection of overlapping rooms */
179 static void build_room_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
181 POSITION x1, x2, y1, y2, xhsize, yhsize;
184 /* get offset from center */
188 msg_print_wizard(CHEAT_DUNGEON, _("部屋型ランダムVaultを生成しました。", "Room Vault."));
190 /* fill area so don't get problems with arena levels */
191 floor_type *floor_ptr = player_ptr->current_floor_ptr;
192 for (x1 = 0; x1 < xsize; x1++)
194 POSITION x = x0 - xhsize + x1;
196 for (y1 = 0; y1 < ysize; y1++)
198 POSITION y = y0 - yhsize + y1;
200 place_bold(player_ptr, y, x, GB_EXTRA);
201 floor_ptr->grid_array[y][x].info &= (~CAVE_ICKY);
205 /* add ten random rooms */
206 for (i = 0; i < 10; i++)
208 x1 = randint1(xhsize) * 2 + x0 - xhsize;
209 x2 = randint1(xhsize) * 2 + x0 - xhsize;
210 y1 = randint1(yhsize) * 2 + y0 - yhsize;
211 y2 = randint1(yhsize) * 2 + y0 - yhsize;
212 build_room(player_ptr, x1, x2, y1, y2);
215 /* Add some random doors */
216 for (i = 0; i < 500; i++)
218 x1 = randint1(xsize - 3) - xhsize + x0 + 1;
219 y1 = randint1(ysize - 3) - yhsize + y0 + 1;
220 add_door(player_ptr, x1, y1);
223 /* Fill with monsters and treasure, high difficulty */
224 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5);
228 /* Create a random vault out of a fractal grid */
229 static void build_cave_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
231 int grd, roug, cutoff;
232 bool done, light, room;
233 POSITION xhsize, yhsize, xsize, ysize, x, y;
235 /* round to make sizes even */
241 msg_print_wizard(CHEAT_DUNGEON, _("洞穴ランダムVaultを生成しました。", "Cave Vault."));
243 light = done = FALSE;
246 floor_type *floor_ptr = player_ptr->current_floor_ptr;
249 /* testing values for these parameters feel free to adjust */
250 grd = 1 << randint0(4);
252 /* want average of about 16 */
253 roug = randint1(8) * randint1(4);
256 cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
257 randint1(xsize / 4) + randint1(ysize / 4);
260 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, cutoff);
262 /* Convert to normal format+ clean up */
263 done = generate_fracave(player_ptr, y0, x0, xsize, ysize, cutoff, light, room);
266 /* Set icky flag because is a vault */
267 for (x = 0; x <= xsize; x++)
269 for (y = 0; y <= ysize; y++)
271 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
275 /* Fill with monsters and treasure, low difficulty */
276 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
281 * @brief Vault地形を回転、上下左右反転するための座標変換を返す / coordinate translation code
282 * @param x 変換したい点のX座標参照ポインタ
283 * @param y 変換したい点のY座標参照ポインタ
284 * @param xoffset Vault生成時の基準X座標
285 * @param yoffset Vault生成時の基準Y座標
286 * @param transno 処理ID
289 static void coord_trans(POSITION *x, POSITION *y, POSITION xoffset, POSITION yoffset, int transno)
295 * transno specifies what transformation is required. (0-7)
296 * The lower two bits indicate by how much the vault is rotated,
297 * and the upper bit indicates a reflection.
298 * This is done by using rotation matrices... however since
299 * these are mostly zeros for rotations by 90 degrees this can
300 * be expressed simply in terms of swapping and inverting the
301 * x and y coordinates.
303 for (i = 0; i < transno % 4; i++)
305 /* rotate by 90 degrees */
313 /* Reflect depending on status of 3rd bit. */
317 /* Add offsets so vault stays in the first quadrant */
324 * @brief Vaultをフロアに配置する / Hack -- fill in "vault" rooms
325 * @param player_ptr プレーヤーへの参照ポインタ
326 * @param yval 生成基準Y座標
327 * @param xval 生成基準X座標
328 * @param ymax VaultのYサイズ
329 * @param xmax VaultのXサイズ
330 * @param data Vaultのデータ文字列
331 * @param xoffset 変換基準X座標
332 * @param yoffset 変換基準Y座標
333 * @param transno 変換ID
336 static void build_vault(player_type *player_ptr, POSITION yval, POSITION xval, POSITION ymax, POSITION xmax, concptr data,
337 POSITION xoffset, POSITION yoffset, int transno)
339 POSITION dx, dy, x, y, i, j;
343 /* Place dungeon features and objects */
344 floor_type *floor_ptr = player_ptr->current_floor_ptr;
345 for (t = data, dy = 0; dy < ymax; dy++)
347 for (dx = 0; dx < xmax; dx++, t++)
349 /* prevent loop counter from being overwritten */
354 coord_trans(&i, &j, xoffset, yoffset, transno);
356 if (transno % 2 == 0)
359 x = xval - (xmax / 2) + i;
360 y = yval - (ymax / 2) + j;
365 x = xval - (ymax / 2) + i;
366 y = yval - (xmax / 2) + j;
369 /* Hack -- skip "non-grids" */
370 if (*t == ' ') continue;
371 g_ptr = &floor_ptr->grid_array[y][x];
373 /* Lay down a floor */
374 place_grid(player_ptr, g_ptr, GB_FLOOR);
376 /* Remove any mimic */
379 /* Part of a vault */
380 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
382 /* Analyze the grid */
385 /* Granite wall (outer) */
387 place_grid(player_ptr, g_ptr, GB_OUTER_NOPERM);
390 /* Granite wall (inner) */
392 place_grid(player_ptr, g_ptr, GB_INNER);
395 /* Glass wall (inner) */
397 place_grid(player_ptr, g_ptr, GB_INNER);
398 g_ptr->feat = feat_glass_wall;
401 /* Permanent wall (inner) */
403 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
406 /* Permanent glass wall (inner) */
408 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
409 g_ptr->feat = feat_permanent_glass_wall;
414 if (randint0(100) < 75)
416 place_object(player_ptr, y, x, 0L);
420 place_trap(player_ptr, y, x);
426 place_object(player_ptr, y, x, 0L);
431 g_ptr->feat = feat_tree;
436 place_secret_door(player_ptr, y, x, DOOR_DEFAULT);
439 /* Secret glass doors */
441 place_secret_door(player_ptr, y, x, DOOR_GLASS_DOOR);
442 if (is_closed_door(player_ptr, g_ptr->feat)) g_ptr->mimic = feat_glass_wall;
447 place_secret_door(player_ptr, y, x, DOOR_CURTAIN);
452 place_trap(player_ptr, y, x);
455 /* Black market in a dungeon */
457 set_cave_feat(floor_ptr, y, x, feat_black_market);
458 store_init(NO_TOWN, STORE_BLACK);
463 set_cave_feat(floor_ptr, y, x, feat_pattern_start);
467 set_cave_feat(floor_ptr, y, x, feat_pattern_1);
471 set_cave_feat(floor_ptr, y, x, feat_pattern_2);
475 set_cave_feat(floor_ptr, y, x, feat_pattern_3);
479 set_cave_feat(floor_ptr, y, x, feat_pattern_4);
483 set_cave_feat(floor_ptr, y, x, feat_pattern_end);
487 set_cave_feat(floor_ptr, y, x, feat_pattern_exit);
491 /* Reward for Pattern walk */
492 floor_ptr->object_level = floor_ptr->base_level + 12;
493 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
494 floor_ptr->object_level = floor_ptr->base_level;
498 set_cave_feat(floor_ptr, y, x, feat_shallow_water);
502 set_cave_feat(floor_ptr, y, x, feat_deep_water);
506 set_cave_feat(floor_ptr, y, x, feat_shallow_lava);
510 set_cave_feat(floor_ptr, y, x, feat_deep_lava);
514 set_cave_feat(floor_ptr, y, x, feat_shallow_acid_puddle);
518 set_cave_feat(floor_ptr, y, x, feat_deep_acid_puddle);
522 set_cave_feat(floor_ptr, y, x, feat_shallow_poisonous_puddle);
526 set_cave_feat(floor_ptr, y, x, feat_deep_poisonous_puddle);
530 set_cave_feat(floor_ptr, y, x, feat_cold_zone);
534 set_cave_feat(floor_ptr, y, x, feat_heavy_cold_zone);
538 set_cave_feat(floor_ptr, y, x, feat_electrical_zone);
542 set_cave_feat(floor_ptr, y, x, feat_heavy_electrical_zone);
550 /* Place dungeon monsters and objects */
551 for (t = data, dy = 0; dy < ymax; dy++)
553 for (dx = 0; dx < xmax; dx++, t++)
555 /* prevent loop counter from being overwritten */
560 coord_trans(&i, &j, xoffset, yoffset, transno);
562 if (transno % 2 == 0)
565 x = xval - (xmax / 2) + i;
566 y = yval - (ymax / 2) + j;
571 x = xval - (ymax / 2) + i;
572 y = yval - (xmax / 2) + j;
575 /* Hack -- skip "non-grids" */
576 if (*t == ' ') continue;
578 /* Analyze the symbol */
583 floor_ptr->monster_level = floor_ptr->base_level + 5;
584 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
585 floor_ptr->monster_level = floor_ptr->base_level;
592 floor_ptr->monster_level = floor_ptr->base_level + 11;
593 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
594 floor_ptr->monster_level = floor_ptr->base_level;
598 /* Meaner monster, plus treasure */
601 floor_ptr->monster_level = floor_ptr->base_level + 9;
602 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
603 floor_ptr->monster_level = floor_ptr->base_level;
604 floor_ptr->object_level = floor_ptr->base_level + 7;
605 place_object(player_ptr, y, x, AM_GOOD);
606 floor_ptr->object_level = floor_ptr->base_level;
610 /* Nasty monster and treasure */
613 floor_ptr->monster_level = floor_ptr->base_level + 40;
614 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
615 floor_ptr->monster_level = floor_ptr->base_level;
616 floor_ptr->object_level = floor_ptr->base_level + 20;
617 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
618 floor_ptr->object_level = floor_ptr->base_level;
622 /* Monster and/or object */
625 if (randint0(100) < 50)
627 floor_ptr->monster_level = floor_ptr->base_level + 3;
628 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
629 floor_ptr->monster_level = floor_ptr->base_level;
631 if (randint0(100) < 50)
633 floor_ptr->object_level = floor_ptr->base_level + 7;
634 place_object(player_ptr, y, x, 0L);
635 floor_ptr->object_level = floor_ptr->base_level;
646 * @brief タイプ7の部屋…v_info.txtより小型vaultを生成する / Type 7 -- simple vaults (see "v_info.txt")
649 bool build_type7(player_type *player_ptr)
651 vault_type *v_ptr = NULL;
655 POSITION xoffset, yoffset;
658 /* Pick a lesser vault */
659 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
661 /* Access a random vault record */
662 v_ptr = &v_info[randint0(max_v_idx)];
664 /* Accept the first lesser vault */
665 if (v_ptr->typ == 7) break;
668 /* No lesser vault found */
669 if (dummy >= SAFE_MAX_ATTEMPTS)
671 msg_print_wizard(CHEAT_DUNGEON, _("小型固定Vaultを配置できませんでした。", "Could not place lesser vault."));
675 /* pick type of transformation (0-7) */
676 transno = randint0(8);
678 /* calculate offsets */
682 /* Some huge vault cannot be ratated to fit in the dungeon */
683 floor_type *floor_ptr = player_ptr->current_floor_ptr;
684 if (x + 2 > floor_ptr->height - 2)
686 /* Forbid 90 or 270 degree ratation */
690 coord_trans(&x, &y, 0, 0, transno);
710 /* Find and reserve some space in the dungeon. Get center of room. */
711 if (!find_space(player_ptr, &yval, &xval, abs(y), abs(x))) return FALSE;
713 msg_format_wizard(CHEAT_DUNGEON, _("小型Vault(%s)を生成しました。", "Lesser vault (%s)."), v_name + v_ptr->name);
715 /* Hack -- Build the vault */
716 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
717 v_text + v_ptr->text, xoffset, yoffset, transno);
724 * @brief タイプ8の部屋…v_info.txtより大型vaultを生成する / Type 8 -- greater vaults (see "v_info.txt")
727 bool build_type8(player_type *player_ptr)
734 POSITION xoffset, yoffset;
736 /* Pick a greater vault */
737 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
739 /* Access a random vault record */
740 v_ptr = &v_info[randint0(max_v_idx)];
742 /* Accept the first greater vault */
743 if (v_ptr->typ == 8) break;
746 /* No greater vault found */
747 if (dummy >= SAFE_MAX_ATTEMPTS)
749 msg_print_wizard(CHEAT_DUNGEON, _("大型固定Vaultを配置できませんでした。", "Could not place greater vault."));
753 /* pick type of transformation (0-7) */
754 transno = randint0(8);
756 /* calculate offsets */
760 /* Some huge vault cannot be ratated to fit in the dungeon */
761 floor_type *floor_ptr = player_ptr->current_floor_ptr;
762 if (x + 2 > floor_ptr->height - 2)
764 /* Forbid 90 or 270 degree ratation */
768 coord_trans(&x, &y, 0, 0, transno);
789 * Try to allocate space for room. If fails, exit
791 * Hack -- Prepare a bit larger space (+2, +2) to
792 * prevent generation of vaults with no-entrance.
794 /* Find and reserve some space in the dungeon. Get center of room. */
795 if (!find_space(player_ptr, &yval, &xval, (POSITION)(abs(y) + 2), (POSITION)(abs(x) + 2))) return FALSE;
797 msg_format_wizard(CHEAT_DUNGEON, _("大型固定Vault(%s)を生成しました。", "Greater vault (%s)."), v_name + v_ptr->name);
799 /* Hack -- Build the vault */
800 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
801 v_text + v_ptr->text, xoffset, yoffset, transno);
808 * Build target vault.
809 * This is made by two concentric "crypts" with perpendicular
810 * walls creating the cross-hairs.
812 static void build_target_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
816 /* Make a random metric */
817 POSITION h1, h2, h3, h4;
818 h1 = randint1(32) - 16;
821 h4 = randint1(32) - 16;
823 msg_print_wizard(CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Elemental Vault"));
825 /* work out outer radius */
836 floor_type *floor_ptr = player_ptr->current_floor_ptr;
837 for (x = x0 - rad; x <= x0 + rad; x++)
839 for (y = y0 - rad; y <= y0 + rad; y++)
841 /* clear room flag */
842 floor_ptr->grid_array[y][x].info &= ~(CAVE_ROOM);
844 /* Vault - so is "icky" */
845 floor_ptr->grid_array[y][x].info |= CAVE_ICKY;
847 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1)
849 /* inside- so is floor */
850 place_bold(player_ptr, y, x, GB_FLOOR);
854 /* make granite outside so arena works */
855 place_bold(player_ptr, y, x, GB_EXTRA);
858 /* proper boundary for arena */
859 if (((y + rad) == y0) || ((y - rad) == y0) ||
860 ((x + rad) == x0) || ((x - rad) == x0))
862 place_bold(player_ptr, y, x, GB_EXTRA);
867 /* Find visible outer walls and set to be FEAT_OUTER */
868 add_outer_wall(player_ptr, x0, y0, FALSE, x0 - rad - 1, y0 - rad - 1, x0 + rad + 1, y0 + rad + 1);
871 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++)
873 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++)
875 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2)
877 /* Make an internal wall */
878 place_bold(player_ptr, y, x, GB_INNER);
883 /* Add perpendicular walls */
884 for (x = x0 - rad; x <= x0 + rad; x++)
886 place_bold(player_ptr, y0, x, GB_INNER);
889 for (y = y0 - rad; y <= y0 + rad; y++)
891 place_bold(player_ptr, y, x0, GB_INNER);
894 /* Make inner vault */
895 for (y = y0 - 1; y <= y0 + 1; y++)
897 place_bold(player_ptr, y, x0 - 1, GB_INNER);
898 place_bold(player_ptr, y, x0 + 1, GB_INNER);
900 for (x = x0 - 1; x <= x0 + 1; x++)
902 place_bold(player_ptr, y0 - 1, x, GB_INNER);
903 place_bold(player_ptr, y0 + 1, x, GB_INNER);
906 place_bold(player_ptr, y0, x0, GB_FLOOR);
909 /* Add doors to vault */
910 /* get two distances so can place doors relative to centre */
911 x = (rad - 2) / 4 + 1;
914 add_door(player_ptr, x0 + x, y0);
915 add_door(player_ptr, x0 + y, y0);
916 add_door(player_ptr, x0 - x, y0);
917 add_door(player_ptr, x0 - y, y0);
918 add_door(player_ptr, x0, y0 + x);
919 add_door(player_ptr, x0, y0 + y);
920 add_door(player_ptr, x0, y0 - x);
921 add_door(player_ptr, x0, y0 - y);
923 /* Fill with stuff - medium difficulty */
924 fill_treasure(player_ptr, x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
929 * This routine uses a modified version of the lake code to make a
930 * distribution of some terrain type over the vault. This type
931 * depends on the dungeon depth.
933 * Miniture rooms are then scattered across the vault.
935 static void build_elemental_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
940 POSITION xsize, ysize, xhsize, yhsize, x, y;
944 msg_print_wizard(CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
946 /* round to make sizes even */
952 floor_type *floor_ptr = player_ptr->current_floor_ptr;
953 if (floor_ptr->dun_level < 25)
955 /* Earth vault (Rubble) */
956 type = LAKE_T_EARTH_VAULT;
958 else if (floor_ptr->dun_level < 50)
960 /* Air vault (Trees) */
961 type = LAKE_T_AIR_VAULT;
963 else if (floor_ptr->dun_level < 75)
965 /* Water vault (shallow water) */
966 type = LAKE_T_WATER_VAULT;
970 /* Fire vault (shallow lava) */
971 type = LAKE_T_FIRE_VAULT;
976 /* testing values for these parameters: feel free to adjust */
977 grd = 1 << (randint0(3));
979 /* want average of about 16 */
980 roug = randint1(8) * randint1(4);
982 /* Make up size of various componants */
986 /* Deep water/lava */
987 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
989 /* Shallow boundary */
993 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, c3);
995 /* Convert to normal format+ clean up */
996 done = generate_lake(player_ptr, y0, x0, xsize, ysize, c1, c2, c3, type);
999 /* Set icky flag because is a vault */
1000 for (x = 0; x <= xsize; x++)
1002 for (y = 0; y <= ysize; y++)
1004 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
1008 /* make a few rooms in the vault */
1009 for (i = 1; i <= (xsize * ysize) / 50; i++)
1011 build_small_room(player_ptr, x0 + randint0(xsize - 4) - xsize / 2 + 2,
1012 y0 + randint0(ysize - 4) - ysize / 2 + 2);
1015 /* Fill with monsters and treasure, low difficulty */
1016 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1,
1017 y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
1021 /* Build a "mini" checkerboard vault
1023 * This is done by making a permanent wall maze and setting
1024 * the diagonal sqaures of the checker board to be granite.
1025 * The vault has two entrances on opposite sides to guarantee
1026 * a way to get in even if the vault abuts a side of the dungeon.
1028 static void build_mini_c_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1031 POSITION y1, x1, y2, x2, y, x, total;
1032 int m, n, num_vertices;
1035 msg_print_wizard(CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
1037 /* Pick a random room size */
1047 /* generate the room */
1048 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1049 for (x = x1 - 2; x <= x2 + 2; x++)
1051 if (!in_bounds(floor_ptr, y1 - 2, x)) break;
1053 floor_ptr->grid_array[y1 - 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1055 place_bold(player_ptr, y1 - 2, x, GB_OUTER_NOPERM);
1058 for (x = x1 - 2; x <= x2 + 2; x++)
1060 if (!in_bounds(floor_ptr, y2 + 2, x)) break;
1062 floor_ptr->grid_array[y2 + 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1064 place_bold(player_ptr, y2 + 2, x, GB_OUTER_NOPERM);
1067 for (y = y1 - 2; y <= y2 + 2; y++)
1069 if (!in_bounds(floor_ptr, y, x1 - 2)) break;
1071 floor_ptr->grid_array[y][x1 - 2].info |= (CAVE_ROOM | CAVE_ICKY);
1073 place_bold(player_ptr, y, x1 - 2, GB_OUTER_NOPERM);
1076 for (y = y1 - 2; y <= y2 + 2; y++)
1078 if (!in_bounds(floor_ptr, y, x2 + 2)) break;
1080 floor_ptr->grid_array[y][x2 + 2].info |= (CAVE_ROOM | CAVE_ICKY);
1082 place_bold(player_ptr, y, x2 + 2, GB_OUTER_NOPERM);
1085 for (y = y1 - 1; y <= y2 + 1; y++)
1087 for (x = x1 - 1; x <= x2 + 1; x++)
1089 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1091 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
1093 /* Permanent walls */
1094 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
1099 /* dimensions of vertex array */
1102 num_vertices = m * n;
1104 /* initialize array of visited vertices */
1105 C_MAKE(visited, num_vertices, int);
1107 /* traverse the graph to create a spannng tree, pick a random root */
1108 r_visit(player_ptr, y1, x1, y2, x2, randint0(num_vertices), 0, visited);
1110 /* Make it look like a checker board vault */
1111 for (x = x1; x <= x2; x++)
1113 for (y = y1; y <= y2; y++)
1115 total = x - x1 + y - y1;
1116 /* If total is odd- and is a floor then make a wall */
1117 if ((total % 2 == 1) && is_floor_bold(floor_ptr, y, x))
1119 place_bold(player_ptr, y, x, GB_INNER);
1124 /* Make a couple of entrances */
1127 /* left and right */
1128 y = randint1(dy) + dy / 2;
1129 place_bold(player_ptr, y1 + y, x1 - 1, GB_INNER);
1130 place_bold(player_ptr, y1 + y, x2 + 1, GB_INNER);
1134 /* top and bottom */
1135 x = randint1(dx) + dx / 2;
1136 place_bold(player_ptr, y1 - 1, x1 + x, GB_INNER);
1137 place_bold(player_ptr, y2 + 1, x1 + x, GB_INNER);
1140 /* Fill with monsters and treasure, highest difficulty */
1141 fill_treasure(player_ptr, x1, x2, y1, y2, 10);
1143 C_KILL(visited, num_vertices, int);
1146 /* Build a castle */
1147 /* Driver routine: clear the region and call the recursive
1150 *This makes a vault that looks like a castle/ city in the dungeon.
1152 static void build_castle_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1155 POSITION y1, x1, y2, x2;
1158 /* Pick a random room size */
1167 msg_print_wizard(CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
1169 /* generate the room */
1170 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1171 for (y = y1 - 1; y <= y2 + 1; y++)
1173 for (x = x1 - 1; x <= x2 + 1; x++)
1175 floor_ptr->grid_array[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
1176 /* Make everything a floor */
1177 place_bold(player_ptr, y, x, GB_FLOOR);
1181 /* Make the castle */
1182 build_recursive_room(player_ptr, x1, y1, x2, y2, randint1(5));
1184 /* Fill with monsters and treasure, low difficulty */
1185 fill_treasure(player_ptr, x1, x2, y1, y2, randint1(3));
1190 * @brief タイプ10の部屋…ランダム生成vault / Type 10 -- Random vaults
1191 * @param player_ptr プレーヤーへの参照ポインタ
1194 bool build_type10(player_type *player_ptr)
1196 POSITION y0, x0, xsize, ysize, vtype;
1198 /* big enough to look good, small enough to be fairly common. */
1199 xsize = randint1(22) + 22;
1200 ysize = randint1(11) + 11;
1202 /* Find and reserve some space in the dungeon. Get center of room. */
1203 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1204 if (!find_space(player_ptr, &y0, &x0, ysize + 1, xsize + 1)) return FALSE;
1206 /* Select type of vault */
1209 vtype = randint1(15);
1210 } while ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) &&
1211 ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
1215 /* Build an appropriate room */
1216 case 1: case 9: build_bubble_vault(player_ptr, x0, y0, xsize, ysize); break;
1217 case 2: case 10: build_room_vault(player_ptr, x0, y0, xsize, ysize); break;
1218 case 3: case 11: build_cave_vault(player_ptr, x0, y0, xsize, ysize); break;
1219 case 4: case 12: build_maze_vault(player_ptr, x0, y0, xsize, ysize, TRUE); break;
1220 case 5: case 13: build_mini_c_vault(player_ptr, x0, y0, xsize, ysize); break;
1221 case 6: case 14: build_castle_vault(player_ptr, x0, y0, xsize, ysize); break;
1222 case 7: case 15: build_target_vault(player_ptr, x0, y0, xsize, ysize); break;
1223 case 8: build_elemental_vault(player_ptr, x0, y0, xsize, ysize); break;
1224 /* I know how to add a few more... give me some time. */
1225 default: return FALSE;
1233 * @brief タイプ17の部屋…v_info.txtより固定特殊部屋を生成する / Type 17 -- fixed special room (see "v_info.txt")
1236 bool build_type17(player_type *player_ptr)
1238 vault_type *v_ptr = NULL;
1241 POSITION xval, yval;
1242 POSITION xoffset, yoffset;
1245 /* Pick a lesser vault */
1246 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
1248 /* Access a random vault record */
1249 v_ptr = &v_info[randint0(max_v_idx)];
1251 /* Accept the special fix room. */
1252 if (v_ptr->typ == 17) break;
1255 /* No lesser vault found */
1256 if (dummy >= SAFE_MAX_ATTEMPTS)
1258 msg_print_wizard(CHEAT_DUNGEON, _("固定特殊部屋を配置できませんでした。", "Could not place fixed special room."));
1262 /* pick type of transformation (0-7) */
1263 transno = randint0(8);
1265 /* calculate offsets */
1269 /* Some huge vault cannot be ratated to fit in the dungeon */
1270 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1271 if (x + 2 > floor_ptr->height - 2)
1273 /* Forbid 90 or 270 degree ratation */
1277 coord_trans(&x, &y, 0, 0, transno);
1297 /* Find and reserve some space in the dungeon. Get center of room. */
1298 if (!find_space(player_ptr, &yval, &xval, abs(y), abs(x))) return FALSE;
1300 msg_format_wizard(CHEAT_DUNGEON, _("特殊固定部屋(%s)を生成しました。", "Special Fix room (%s)."), v_name + v_ptr->name);
1302 /* Hack -- Build the vault */
1303 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
1304 v_text + v_ptr->text, xoffset, yoffset, transno);