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/wild.h"
14 #include "game-option/cheat-types.h"
15 #include "grid/door.h"
16 #include "grid/feature.h"
17 #include "grid/grid.h"
18 #include "grid/object-placer.h"
19 #include "grid/trap.h"
20 #include "monster-floor/monster-generator.h"
21 #include "monster-floor/place-monster-types.h"
22 #include "object-enchant/item-apply-magic.h"
23 #include "room/cave-filler.h"
24 #include "room/lake-types.h"
25 #include "room/rooms-builder.h"
26 #include "room/rooms-maze-vault.h"
27 #include "room/space-finder.h"
28 #include "room/treasure-deployment.h"
29 #include "store/store-util.h"
30 #include "store/store.h"
31 #include "system/dungeon-data-definition.h"
32 #include "system/floor-type-definition.h"
33 #include "wizard/wizard-messages.h"
36 * The vault generation arrays
43 * Maximum number of vaults in v_info.txt
48 * This function creates a random vault that looks like a collection of bubbles.
49 * It works by getting a set of coordinates that represent the center of each
50 * bubble. The entire room is made by seeing which bubble center is closest. If
51 * two centers are equidistant then the square is a wall, otherwise it is a floor.
52 * The only exception is for squares really near a center, these are always floor.
53 * (It looks better than without this check.)
55 * Note: If two centers are on the same point then this algorithm will create a
56 * blank bubble filled with walls. - This is prevented from happening.
58 static void build_bubble_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
60 #define BUBBLENUM 10 /* number of bubbles */
62 /* array of center points of bubbles */
63 coord center[BUBBLENUM];
66 POSITION x = 0, y = 0;
67 u16b min1, min2, temp;
70 /* Offset from center to top left hand corner */
71 POSITION xhsize = xsize / 2;
72 POSITION yhsize = ysize / 2;
74 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("泡型ランダムVaultを生成しました。", "Room Vault."));
76 /* Allocate center of bubbles */
77 center[0].x = (byte)randint1(xsize - 3) + 1;
78 center[0].y = (byte)randint1(ysize - 3) + 1;
80 for (i = 1; i < BUBBLENUM; i++) {
83 /* get center and check to see if it is unique */
87 x = randint1(xsize - 3) + 1;
88 y = randint1(ysize - 3) + 1;
90 for (j = 0; j < i; j++) {
91 /* rough test to see if there is an overlap */
92 if ((x == center[j].x) && (y == center[j].y))
101 /* Top and bottom boundaries */
102 floor_type *floor_ptr = player_ptr->current_floor_ptr;
103 for (i = 0; i < xsize; i++) {
104 int side_x = x0 - xhsize + i;
106 place_bold(player_ptr, y0 - yhsize + 0, side_x, GB_OUTER_NOPERM);
107 floor_ptr->grid_array[y0 - yhsize + 0][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
108 place_bold(player_ptr, y0 - yhsize + ysize - 1, side_x, GB_OUTER_NOPERM);
109 floor_ptr->grid_array[y0 - yhsize + ysize - 1][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
112 /* Left and right boundaries */
113 for (i = 1; i < ysize - 1; i++) {
114 int side_y = y0 - yhsize + i;
116 place_bold(player_ptr, side_y, x0 - xhsize + 0, GB_OUTER_NOPERM);
117 floor_ptr->grid_array[side_y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
118 place_bold(player_ptr, side_y, x0 - xhsize + xsize - 1, GB_OUTER_NOPERM);
119 floor_ptr->grid_array[side_y][x0 - xhsize + xsize - 1].info |= (CAVE_ROOM | CAVE_ICKY);
122 /* Fill in middle with bubbles */
123 for (x = 1; x < xsize - 1; x++) {
124 for (y = 1; y < ysize - 1; y++) {
125 /* Get distances to two closest centers */
127 min1 = (u16b)distance(x, y, center[0].x, center[0].y);
128 min2 = (u16b)distance(x, y, center[1].x, center[1].y);
131 /* swap if in wrong order */
138 for (i = 2; i < BUBBLENUM; i++) {
139 temp = (u16b)distance(x, y, center[i].x, center[i].y);
145 } else if (temp < min2) {
146 /* second smallest */
150 if (((min2 - min1) <= 2) && (!(min1 < 3))) {
151 /* Boundary at midpoint+ not at inner region of bubble */
152 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_OUTER_NOPERM);
154 /* middle of a bubble */
155 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_FLOOR);
158 /* clean up rest of flags */
159 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= (CAVE_ROOM | CAVE_ICKY);
163 /* Try to add some random doors */
164 for (i = 0; i < 500; i++) {
165 x = randint1(xsize - 3) - xhsize + x0 + 1;
166 y = randint1(ysize - 3) - yhsize + y0 + 1;
167 add_door(player_ptr, x, y);
170 /* Fill with monsters and treasure, low difficulty */
171 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5));
174 /* Create a random vault that looks like a collection of overlapping rooms */
175 static void build_room_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
177 POSITION x1, x2, y1, y2, xhsize, yhsize;
180 /* get offset from center */
184 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("部屋型ランダムVaultを生成しました。", "Room Vault."));
186 /* fill area so don't get problems with on_defeat_arena_monster levels */
187 floor_type *floor_ptr = player_ptr->current_floor_ptr;
188 for (x1 = 0; x1 < xsize; x1++) {
189 POSITION x = x0 - xhsize + x1;
191 for (y1 = 0; y1 < ysize; y1++) {
192 POSITION y = y0 - yhsize + y1;
194 place_bold(player_ptr, y, x, GB_EXTRA);
195 floor_ptr->grid_array[y][x].info &= (~CAVE_ICKY);
199 /* add ten random rooms */
200 for (i = 0; i < 10; i++) {
201 x1 = randint1(xhsize) * 2 + x0 - xhsize;
202 x2 = randint1(xhsize) * 2 + x0 - xhsize;
203 y1 = randint1(yhsize) * 2 + y0 - yhsize;
204 y2 = randint1(yhsize) * 2 + y0 - yhsize;
205 build_room(player_ptr, x1, x2, y1, y2);
208 /* Add some random doors */
209 for (i = 0; i < 500; i++) {
210 x1 = randint1(xsize - 3) - xhsize + x0 + 1;
211 y1 = randint1(ysize - 3) - yhsize + y0 + 1;
212 add_door(player_ptr, x1, y1);
215 /* Fill with monsters and treasure, high difficulty */
216 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5);
219 /* Create a random vault out of a fractal grid */
220 static void build_cave_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
222 int grd, roug, cutoff;
223 bool done, light, room;
224 POSITION xhsize, yhsize, xsize, ysize, x, y;
226 /* round to make sizes even */
232 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("洞穴ランダムVaultを生成しました。", "Cave Vault."));
234 light = done = FALSE;
237 floor_type *floor_ptr = player_ptr->current_floor_ptr;
239 /* testing values for these parameters feel free to adjust */
240 grd = 1 << randint0(4);
242 /* want average of about 16 */
243 roug = randint1(8) * randint1(4);
246 cutoff = randint1(xsize / 4) + randint1(ysize / 4) + randint1(xsize / 4) + randint1(ysize / 4);
249 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, cutoff);
251 /* Convert to normal format+ clean up */
252 done = generate_fracave(player_ptr, y0, x0, xsize, ysize, cutoff, light, room);
255 /* Set icky flag because is a vault */
256 for (x = 0; x <= xsize; x++) {
257 for (y = 0; y <= ysize; y++) {
258 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
262 /* Fill with monsters and treasure, low difficulty */
263 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
267 * @brief Vault地形を回転、上下左右反転するための座標変換を返す / coordinate translation code
268 * @param x 変換したい点のX座標参照ポインタ
269 * @param y 変換したい点のY座標参照ポインタ
270 * @param xoffset Vault生成時の基準X座標
271 * @param yoffset Vault生成時の基準Y座標
272 * @param transno 処理ID
275 static void coord_trans(POSITION *x, POSITION *y, POSITION xoffset, POSITION yoffset, int transno)
281 * transno specifies what transformation is required. (0-7)
282 * The lower two bits indicate by how much the vault is rotated,
283 * and the upper bit indicates a reflection.
284 * This is done by using rotation matrices... however since
285 * these are mostly zeros for rotations by 90 degrees this can
286 * be expressed simply in terms of swapping and inverting the
287 * x and y coordinates.
289 for (i = 0; i < transno % 4; i++) {
290 /* rotate by 90 degrees */
297 /* Reflect depending on status of 3rd bit. */
301 /* Add offsets so vault stays in the first quadrant */
307 * @brief Vaultをフロアに配置する / Hack -- fill in "vault" rooms
308 * @param player_ptr プレーヤーへの参照ポインタ
309 * @param yval 生成基準Y座標
310 * @param xval 生成基準X座標
311 * @param ymax VaultのYサイズ
312 * @param xmax VaultのXサイズ
313 * @param data Vaultのデータ文字列
314 * @param xoffset 変換基準X座標
315 * @param yoffset 変換基準Y座標
316 * @param transno 変換ID
319 static void build_vault(
320 player_type *player_ptr, POSITION yval, POSITION xval, POSITION ymax, POSITION xmax, concptr data, POSITION xoffset, POSITION yoffset, int transno)
322 POSITION dx, dy, x, y, i, j;
326 /* Place dungeon features and objects */
327 floor_type *floor_ptr = player_ptr->current_floor_ptr;
328 for (t = data, dy = 0; dy < ymax; dy++) {
329 for (dx = 0; dx < xmax; dx++, t++) {
330 /* prevent loop counter from being overwritten */
335 coord_trans(&i, &j, xoffset, yoffset, transno);
337 if (transno % 2 == 0) {
339 x = xval - (xmax / 2) + i;
340 y = yval - (ymax / 2) + j;
343 x = xval - (ymax / 2) + i;
344 y = yval - (xmax / 2) + j;
347 /* Hack -- skip "non-grids" */
350 g_ptr = &floor_ptr->grid_array[y][x];
352 /* Lay down a floor */
353 place_grid(player_ptr, g_ptr, GB_FLOOR);
355 /* Remove any mimic */
358 /* Part of a vault */
359 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
361 /* Analyze the grid */
363 /* Granite wall (outer) */
365 place_grid(player_ptr, g_ptr, GB_OUTER_NOPERM);
368 /* Granite wall (inner) */
370 place_grid(player_ptr, g_ptr, GB_INNER);
373 /* Glass wall (inner) */
375 place_grid(player_ptr, g_ptr, GB_INNER);
376 g_ptr->feat = feat_glass_wall;
379 /* Permanent wall (inner) */
381 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
384 /* Permanent glass wall (inner) */
386 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
387 g_ptr->feat = feat_permanent_glass_wall;
392 if (randint0(100) < 75) {
393 place_object(player_ptr, y, x, 0L);
395 place_trap(player_ptr, y, x);
401 place_object(player_ptr, y, x, 0L);
406 g_ptr->feat = feat_tree;
411 place_secret_door(player_ptr, y, x, DOOR_DEFAULT);
414 /* Secret glass doors */
416 place_secret_door(player_ptr, y, x, DOOR_GLASS_DOOR);
417 if (is_closed_door(player_ptr, g_ptr->feat))
418 g_ptr->mimic = feat_glass_wall;
423 place_secret_door(player_ptr, y, x, DOOR_CURTAIN);
428 place_trap(player_ptr, y, x);
431 /* Black market in a dungeon */
433 set_cave_feat(floor_ptr, y, x, feat_black_market);
434 store_init(NO_TOWN, STORE_BLACK);
439 set_cave_feat(floor_ptr, y, x, feat_pattern_start);
443 set_cave_feat(floor_ptr, y, x, feat_pattern_1);
447 set_cave_feat(floor_ptr, y, x, feat_pattern_2);
451 set_cave_feat(floor_ptr, y, x, feat_pattern_3);
455 set_cave_feat(floor_ptr, y, x, feat_pattern_4);
459 set_cave_feat(floor_ptr, y, x, feat_pattern_end);
463 set_cave_feat(floor_ptr, y, x, feat_pattern_exit);
467 /* Reward for Pattern walk */
468 floor_ptr->object_level = floor_ptr->base_level + 12;
469 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
470 floor_ptr->object_level = floor_ptr->base_level;
474 set_cave_feat(floor_ptr, y, x, feat_shallow_water);
478 set_cave_feat(floor_ptr, y, x, feat_deep_water);
482 set_cave_feat(floor_ptr, y, x, feat_shallow_lava);
486 set_cave_feat(floor_ptr, y, x, feat_deep_lava);
490 set_cave_feat(floor_ptr, y, x, feat_shallow_acid_puddle);
494 set_cave_feat(floor_ptr, y, x, feat_deep_acid_puddle);
498 set_cave_feat(floor_ptr, y, x, feat_shallow_poisonous_puddle);
502 set_cave_feat(floor_ptr, y, x, feat_deep_poisonous_puddle);
506 set_cave_feat(floor_ptr, y, x, feat_cold_zone);
510 set_cave_feat(floor_ptr, y, x, feat_heavy_cold_zone);
514 set_cave_feat(floor_ptr, y, x, feat_electrical_zone);
518 set_cave_feat(floor_ptr, y, x, feat_heavy_electrical_zone);
524 /* Place dungeon monsters and objects */
525 for (t = data, dy = 0; dy < ymax; dy++) {
526 for (dx = 0; dx < xmax; dx++, t++) {
527 /* prevent loop counter from being overwritten */
532 coord_trans(&i, &j, xoffset, yoffset, transno);
534 if (transno % 2 == 0) {
536 x = xval - (xmax / 2) + i;
537 y = yval - (ymax / 2) + j;
540 x = xval - (ymax / 2) + i;
541 y = yval - (xmax / 2) + j;
544 /* Hack -- skip "non-grids" */
548 /* Analyze the symbol */
551 floor_ptr->monster_level = floor_ptr->base_level + 5;
552 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
553 floor_ptr->monster_level = floor_ptr->base_level;
559 floor_ptr->monster_level = floor_ptr->base_level + 11;
560 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
561 floor_ptr->monster_level = floor_ptr->base_level;
565 /* Meaner monster, plus treasure */
567 floor_ptr->monster_level = floor_ptr->base_level + 9;
568 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
569 floor_ptr->monster_level = floor_ptr->base_level;
570 floor_ptr->object_level = floor_ptr->base_level + 7;
571 place_object(player_ptr, y, x, AM_GOOD);
572 floor_ptr->object_level = floor_ptr->base_level;
576 /* Nasty monster and treasure */
578 floor_ptr->monster_level = floor_ptr->base_level + 40;
579 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
580 floor_ptr->monster_level = floor_ptr->base_level;
581 floor_ptr->object_level = floor_ptr->base_level + 20;
582 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
583 floor_ptr->object_level = floor_ptr->base_level;
587 /* Monster and/or object */
589 if (randint0(100) < 50) {
590 floor_ptr->monster_level = floor_ptr->base_level + 3;
591 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
592 floor_ptr->monster_level = floor_ptr->base_level;
594 if (randint0(100) < 50) {
595 floor_ptr->object_level = floor_ptr->base_level + 7;
596 place_object(player_ptr, y, x, 0L);
597 floor_ptr->object_level = floor_ptr->base_level;
607 * @brief タイプ7の部屋…v_info.txtより小型vaultを生成する / Type 7 -- simple vaults (see "v_info.txt")
610 bool build_type7(player_type *player_ptr, dun_data_type *dd_ptr)
612 vault_type *v_ptr = NULL;
616 POSITION xoffset, yoffset;
619 /* Pick a lesser vault */
620 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++) {
621 /* Access a random vault record */
622 v_ptr = &v_info[randint0(max_v_idx)];
624 /* Accept the first lesser vault */
629 /* No lesser vault found */
630 if (dummy >= SAFE_MAX_ATTEMPTS) {
631 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("小型固定Vaultを配置できませんでした。", "Could not place lesser vault."));
635 /* pick type of transformation (0-7) */
636 transno = randint0(8);
638 /* calculate offsets */
642 /* Some huge vault cannot be ratated to fit in the dungeon */
643 floor_type *floor_ptr = player_ptr->current_floor_ptr;
644 if (x + 2 > floor_ptr->height - 2) {
645 /* Forbid 90 or 270 degree ratation */
649 coord_trans(&x, &y, 0, 0, transno);
663 /* Find and reserve some space in the dungeon. Get center of room. */
664 if (!find_space(player_ptr, dd_ptr, &yval, &xval, abs(y), abs(x)))
667 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("小型Vault(%s)を生成しました。", "Lesser vault (%s)."), v_name + v_ptr->name);
669 /* Hack -- Build the vault */
670 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid, v_text + v_ptr->text, xoffset, yoffset, transno);
676 * @brief タイプ8の部屋…v_info.txtより大型vaultを生成する / Type 8 -- greater vaults (see "v_info.txt")
679 bool build_type8(player_type *player_ptr, dun_data_type *dd_ptr)
686 POSITION xoffset, yoffset;
688 /* Pick a greater vault */
689 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++) {
690 /* Access a random vault record */
691 v_ptr = &v_info[randint0(max_v_idx)];
693 /* Accept the first greater vault */
698 /* No greater vault found */
699 if (dummy >= SAFE_MAX_ATTEMPTS) {
700 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("大型固定Vaultを配置できませんでした。", "Could not place greater vault."));
704 /* pick type of transformation (0-7) */
705 transno = randint0(8);
707 /* calculate offsets */
711 /* Some huge vault cannot be ratated to fit in the dungeon */
712 floor_type *floor_ptr = player_ptr->current_floor_ptr;
713 if (x + 2 > floor_ptr->height - 2) {
714 /* Forbid 90 or 270 degree ratation */
718 coord_trans(&x, &y, 0, 0, transno);
733 * Try to allocate space for room. If fails, exit
735 * Hack -- Prepare a bit larger space (+2, +2) to
736 * prevent generation of vaults with no-entrance.
738 /* Find and reserve some space in the dungeon. Get center of room. */
739 if (!find_space(player_ptr, dd_ptr, &yval, &xval, (POSITION)(abs(y) + 2), (POSITION)(abs(x) + 2)))
742 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("大型固定Vault(%s)を生成しました。", "Greater vault (%s)."), v_name + v_ptr->name);
744 /* Hack -- Build the vault */
745 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid, v_text + v_ptr->text, xoffset, yoffset, transno);
751 * Build target vault.
752 * This is made by two concentric "crypts" with perpendicular
753 * walls creating the cross-hairs.
755 static void build_target_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
759 /* Make a random metric */
760 POSITION h1, h2, h3, h4;
761 h1 = randint1(32) - 16;
764 h4 = randint1(32) - 16;
766 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Elemental Vault"));
768 /* work out outer radius */
776 floor_type *floor_ptr = player_ptr->current_floor_ptr;
777 for (x = x0 - rad; x <= x0 + rad; x++) {
778 for (y = y0 - rad; y <= y0 + rad; y++) {
779 /* clear room flag */
780 floor_ptr->grid_array[y][x].info &= ~(CAVE_ROOM);
782 /* Vault - so is "icky" */
783 floor_ptr->grid_array[y][x].info |= CAVE_ICKY;
785 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1) {
786 /* inside- so is floor */
787 place_bold(player_ptr, y, x, GB_FLOOR);
789 /* make granite outside so on_defeat_arena_monster works */
790 place_bold(player_ptr, y, x, GB_EXTRA);
793 /* proper boundary for on_defeat_arena_monster */
794 if (((y + rad) == y0) || ((y - rad) == y0) || ((x + rad) == x0) || ((x - rad) == x0)) {
795 place_bold(player_ptr, y, x, GB_EXTRA);
800 /* Find visible outer walls and set to be FEAT_OUTER */
801 add_outer_wall(player_ptr, x0, y0, FALSE, x0 - rad - 1, y0 - rad - 1, x0 + rad + 1, y0 + rad + 1);
804 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++) {
805 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++) {
806 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2) {
807 /* Make an internal wall */
808 place_bold(player_ptr, y, x, GB_INNER);
813 /* Add perpendicular walls */
814 for (x = x0 - rad; x <= x0 + rad; x++) {
815 place_bold(player_ptr, y0, x, GB_INNER);
818 for (y = y0 - rad; y <= y0 + rad; y++) {
819 place_bold(player_ptr, y, x0, GB_INNER);
822 /* Make inner vault */
823 for (y = y0 - 1; y <= y0 + 1; y++) {
824 place_bold(player_ptr, y, x0 - 1, GB_INNER);
825 place_bold(player_ptr, y, x0 + 1, GB_INNER);
827 for (x = x0 - 1; x <= x0 + 1; x++) {
828 place_bold(player_ptr, y0 - 1, x, GB_INNER);
829 place_bold(player_ptr, y0 + 1, x, GB_INNER);
832 place_bold(player_ptr, y0, x0, GB_FLOOR);
834 /* Add doors to vault */
835 /* get two distances so can place doors relative to centre */
836 x = (rad - 2) / 4 + 1;
839 add_door(player_ptr, x0 + x, y0);
840 add_door(player_ptr, x0 + y, y0);
841 add_door(player_ptr, x0 - x, y0);
842 add_door(player_ptr, x0 - y, y0);
843 add_door(player_ptr, x0, y0 + x);
844 add_door(player_ptr, x0, y0 + y);
845 add_door(player_ptr, x0, y0 - x);
846 add_door(player_ptr, x0, y0 - y);
848 /* Fill with stuff - medium difficulty */
849 fill_treasure(player_ptr, x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
853 * This routine uses a modified version of the lake code to make a
854 * distribution of some terrain type over the vault. This type
855 * depends on the dungeon depth.
857 * Miniture rooms are then scattered across the vault.
859 static void build_elemental_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
864 POSITION xsize, ysize, xhsize, yhsize, x, y;
868 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
870 /* round to make sizes even */
876 floor_type *floor_ptr = player_ptr->current_floor_ptr;
877 if (floor_ptr->dun_level < 25) {
878 /* Earth vault (Rubble) */
879 type = LAKE_T_EARTH_VAULT;
880 } else if (floor_ptr->dun_level < 50) {
881 /* Air vault (Trees) */
882 type = LAKE_T_AIR_VAULT;
883 } else if (floor_ptr->dun_level < 75) {
884 /* Water vault (shallow water) */
885 type = LAKE_T_WATER_VAULT;
887 /* Fire vault (shallow lava) */
888 type = LAKE_T_FIRE_VAULT;
892 /* testing values for these parameters: feel free to adjust */
893 grd = 1 << (randint0(3));
895 /* want average of about 16 */
896 roug = randint1(8) * randint1(4);
898 /* Make up size of various componants */
902 /* Deep water/lava */
903 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
905 /* Shallow boundary */
909 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, c3);
911 /* Convert to normal format+ clean up */
912 done = generate_lake(player_ptr, y0, x0, xsize, ysize, c1, c2, c3, type);
915 /* Set icky flag because is a vault */
916 for (x = 0; x <= xsize; x++) {
917 for (y = 0; y <= ysize; y++) {
918 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
922 /* make a few rooms in the vault */
923 for (i = 1; i <= (xsize * ysize) / 50; i++) {
924 build_small_room(player_ptr, x0 + randint0(xsize - 4) - xsize / 2 + 2, y0 + randint0(ysize - 4) - ysize / 2 + 2);
927 /* Fill with monsters and treasure, low difficulty */
928 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
931 /* Build a "mini" checkerboard vault
933 * This is done by making a permanent wall maze and setting
934 * the diagonal sqaures of the checker board to be granite.
935 * The vault has two entrances on opposite sides to guarantee
936 * a way to get in even if the vault abuts a side of the dungeon.
938 static void build_mini_c_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
941 POSITION y1, x1, y2, x2, y, x, total;
942 int m, n, num_vertices;
945 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
947 /* Pick a random room size */
956 /* generate the room */
957 floor_type *floor_ptr = player_ptr->current_floor_ptr;
958 for (x = x1 - 2; x <= x2 + 2; x++) {
959 if (!in_bounds(floor_ptr, y1 - 2, x))
962 floor_ptr->grid_array[y1 - 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
964 place_bold(player_ptr, y1 - 2, x, GB_OUTER_NOPERM);
967 for (x = x1 - 2; x <= x2 + 2; x++) {
968 if (!in_bounds(floor_ptr, y2 + 2, x))
971 floor_ptr->grid_array[y2 + 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
973 place_bold(player_ptr, y2 + 2, x, GB_OUTER_NOPERM);
976 for (y = y1 - 2; y <= y2 + 2; y++) {
977 if (!in_bounds(floor_ptr, y, x1 - 2))
980 floor_ptr->grid_array[y][x1 - 2].info |= (CAVE_ROOM | CAVE_ICKY);
982 place_bold(player_ptr, y, x1 - 2, GB_OUTER_NOPERM);
985 for (y = y1 - 2; y <= y2 + 2; y++) {
986 if (!in_bounds(floor_ptr, y, x2 + 2))
989 floor_ptr->grid_array[y][x2 + 2].info |= (CAVE_ROOM | CAVE_ICKY);
991 place_bold(player_ptr, y, x2 + 2, GB_OUTER_NOPERM);
994 for (y = y1 - 1; y <= y2 + 1; y++) {
995 for (x = x1 - 1; x <= x2 + 1; x++) {
996 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
998 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
1000 /* Permanent walls */
1001 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
1005 /* dimensions of vertex array */
1008 num_vertices = m * n;
1010 /* initialize array of visited vertices */
1011 C_MAKE(visited, num_vertices, int);
1013 /* traverse the graph to create a spannng tree, pick a random root */
1014 r_visit(player_ptr, y1, x1, y2, x2, randint0(num_vertices), 0, visited);
1016 /* Make it look like a checker board vault */
1017 for (x = x1; x <= x2; x++) {
1018 for (y = y1; y <= y2; y++) {
1019 total = x - x1 + y - y1;
1020 /* If total is odd- and is a floor then make a wall */
1021 if ((total % 2 == 1) && is_floor_bold(floor_ptr, y, x)) {
1022 place_bold(player_ptr, y, x, GB_INNER);
1027 /* Make a couple of entrances */
1029 /* left and right */
1030 y = randint1(dy) + dy / 2;
1031 place_bold(player_ptr, y1 + y, x1 - 1, GB_INNER);
1032 place_bold(player_ptr, y1 + y, x2 + 1, GB_INNER);
1034 /* top and bottom */
1035 x = randint1(dx) + dx / 2;
1036 place_bold(player_ptr, y1 - 1, x1 + x, GB_INNER);
1037 place_bold(player_ptr, y2 + 1, x1 + x, GB_INNER);
1040 /* Fill with monsters and treasure, highest difficulty */
1041 fill_treasure(player_ptr, x1, x2, y1, y2, 10);
1043 C_KILL(visited, num_vertices, int);
1046 /* Build a castle */
1047 /* Driver routine: clear the region and call the recursive
1050 *This makes a vault that looks like a castle/ city in the dungeon.
1052 static void build_castle_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1055 POSITION y1, x1, y2, x2;
1058 /* Pick a random room size */
1067 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
1069 /* generate the room */
1070 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1071 for (y = y1 - 1; y <= y2 + 1; y++) {
1072 for (x = x1 - 1; x <= x2 + 1; x++) {
1073 floor_ptr->grid_array[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
1074 /* Make everything a floor */
1075 place_bold(player_ptr, y, x, GB_FLOOR);
1079 /* Make the castle */
1080 build_recursive_room(player_ptr, x1, y1, x2, y2, randint1(5));
1082 /* Fill with monsters and treasure, low difficulty */
1083 fill_treasure(player_ptr, x1, x2, y1, y2, randint1(3));
1087 * @brief タイプ10の部屋…ランダム生成vault / Type 10 -- Random vaults
1088 * @param player_ptr プレーヤーへの参照ポインタ
1091 bool build_type10(player_type *player_ptr, dun_data_type *dd_ptr)
1093 POSITION y0, x0, xsize, ysize, vtype;
1095 /* big enough to look good, small enough to be fairly common. */
1096 xsize = randint1(22) + 22;
1097 ysize = randint1(11) + 11;
1099 /* Find and reserve some space in the dungeon. Get center of room. */
1100 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1101 if (!find_space(player_ptr, dd_ptr, &y0, &x0, ysize + 1, xsize + 1))
1104 /* Select type of vault */
1106 vtype = randint1(15);
1107 } while ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) && ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
1110 /* Build an appropriate room */
1113 build_bubble_vault(player_ptr, x0, y0, xsize, ysize);
1117 build_room_vault(player_ptr, x0, y0, xsize, ysize);
1121 build_cave_vault(player_ptr, x0, y0, xsize, ysize);
1125 build_maze_vault(player_ptr, x0, y0, xsize, ysize, TRUE);
1129 build_mini_c_vault(player_ptr, x0, y0, xsize, ysize);
1133 build_castle_vault(player_ptr, x0, y0, xsize, ysize);
1137 build_target_vault(player_ptr, x0, y0, xsize, ysize);
1140 build_elemental_vault(player_ptr, x0, y0, xsize, ysize);
1142 /* I know how to add a few more... give me some time. */
1151 * @brief タイプ17の部屋…v_info.txtより固定特殊部屋を生成する / Type 17 -- fixed special room (see "v_info.txt")
1154 bool build_type17(player_type *player_ptr, dun_data_type *dd_ptr)
1156 vault_type *v_ptr = NULL;
1159 POSITION xval, yval;
1160 POSITION xoffset, yoffset;
1163 /* Pick a lesser vault */
1164 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++) {
1165 /* Access a random vault record */
1166 v_ptr = &v_info[randint0(max_v_idx)];
1168 /* Accept the special fix room. */
1169 if (v_ptr->typ == 17)
1173 /* No lesser vault found */
1174 if (dummy >= SAFE_MAX_ATTEMPTS) {
1175 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("固定特殊部屋を配置できませんでした。", "Could not place fixed special room."));
1179 /* pick type of transformation (0-7) */
1180 transno = randint0(8);
1182 /* calculate offsets */
1186 /* Some huge vault cannot be ratated to fit in the dungeon */
1187 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1188 if (x + 2 > floor_ptr->height - 2) {
1189 /* Forbid 90 or 270 degree ratation */
1193 coord_trans(&x, &y, 0, 0, transno);
1207 /* Find and reserve some space in the dungeon. Get center of room. */
1208 if (!find_space(player_ptr, dd_ptr, &yval, &xval, abs(y), abs(x)))
1211 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("特殊固定部屋(%s)を生成しました。", "Special Fix room (%s)."), v_name + v_ptr->name);
1213 /* Hack -- Build the vault */
1214 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid, v_text + v_ptr->text, xoffset, yoffset, transno);