1 #include "system/angband.h"
3 #include "room/rooms-vault.h"
5 #include "floor/floor-generate.h"
7 #include "room/rooms.h"
8 #include "market/store.h"
10 #include "monster/monster.h"
11 #include "grid/feature.h"
12 #include "floor/floor.h"
13 #include "dungeon/dungeon.h"
16 #include "market/store-util.h"
19 * The vault generation arrays
26 * Maximum number of vaults in v_info.txt
31 * This function creates a random vault that looks like a collection of bubbles.
32 * It works by getting a set of coordinates that represent the center of each
33 * bubble. The entire room is made by seeing which bubble center is closest. If
34 * two centers are equidistant then the square is a wall, otherwise it is a floor.
35 * The only exception is for squares really near a center, these are always floor.
36 * (It looks better than without this check.)
38 * Note: If two centers are on the same point then this algorithm will create a
39 * blank bubble filled with walls. - This is prevented from happening.
41 static void build_bubble_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
43 #define BUBBLENUM 10 /* number of bubbles */
45 /* array of center points of bubbles */
46 coord center[BUBBLENUM];
49 POSITION x = 0, y = 0;
50 u16b min1, min2, temp;
53 /* Offset from center to top left hand corner */
54 POSITION xhsize = xsize / 2;
55 POSITION yhsize = ysize / 2;
57 msg_print_wizard(CHEAT_DUNGEON, _("泡型ランダムVaultを生成しました。", "Room Vault."));
59 /* Allocate center of bubbles */
60 center[0].x = (byte)randint1(xsize - 3) + 1;
61 center[0].y = (byte)randint1(ysize - 3) + 1;
63 for (i = 1; i < BUBBLENUM; i++)
67 /* get center and check to see if it is unique */
72 x = randint1(xsize - 3) + 1;
73 y = randint1(ysize - 3) + 1;
75 for (j = 0; j < i; j++)
77 /* rough test to see if there is an overlap */
78 if ((x == center[j].x) && (y == center[j].y)) done = FALSE;
86 /* Top and bottom boundaries */
87 floor_type *floor_ptr = player_ptr->current_floor_ptr;
88 for (i = 0; i < xsize; i++)
90 int side_x = x0 - xhsize + i;
92 place_bold(player_ptr, y0 - yhsize + 0, side_x, GB_OUTER_NOPERM);
93 floor_ptr->grid_array[y0 - yhsize + 0][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
94 place_bold(player_ptr, y0 - yhsize + ysize - 1, side_x, GB_OUTER_NOPERM);
95 floor_ptr->grid_array[y0 - yhsize + ysize - 1][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
98 /* Left and right boundaries */
99 for (i = 1; i < ysize - 1; i++)
101 int side_y = y0 - yhsize + i;
103 place_bold(player_ptr, side_y, x0 - xhsize + 0, GB_OUTER_NOPERM);
104 floor_ptr->grid_array[side_y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
105 place_bold(player_ptr, side_y, x0 - xhsize + xsize - 1, GB_OUTER_NOPERM);
106 floor_ptr->grid_array[side_y][x0 - xhsize + xsize - 1].info |= (CAVE_ROOM | CAVE_ICKY);
109 /* Fill in middle with bubbles */
110 for (x = 1; x < xsize - 1; x++)
112 for (y = 1; y < ysize - 1; y++)
114 /* Get distances to two closest centers */
116 min1 = (u16b)distance(x, y, center[0].x, center[0].y);
117 min2 = (u16b)distance(x, y, center[1].x, center[1].y);
121 /* swap if in wrong order */
128 for (i = 2; i < BUBBLENUM; i++)
130 temp = (u16b)distance(x, y, center[i].x, center[i].y);
138 else if (temp < min2)
140 /* second smallest */
144 if (((min2 - min1) <= 2) && (!(min1 < 3)))
146 /* Boundary at midpoint+ not at inner region of bubble */
147 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_OUTER_NOPERM);
151 /* middle of a bubble */
152 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_FLOOR);
155 /* clean up rest of flags */
156 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= (CAVE_ROOM | CAVE_ICKY);
160 /* Try to add some random doors */
161 for (i = 0; i < 500; i++)
163 x = randint1(xsize - 3) - xhsize + x0 + 1;
164 y = randint1(ysize - 3) - yhsize + y0 + 1;
165 add_door(player_ptr, x, y);
168 /* Fill with monsters and treasure, low difficulty */
169 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5));
172 /* Create a random vault that looks like a collection of overlapping rooms */
173 static void build_room_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
175 POSITION x1, x2, y1, y2, xhsize, yhsize;
178 /* get offset from center */
182 msg_print_wizard(CHEAT_DUNGEON, _("部屋型ランダムVaultを生成しました。", "Room Vault."));
184 /* fill area so don't get problems with arena levels */
185 floor_type *floor_ptr = player_ptr->current_floor_ptr;
186 for (x1 = 0; x1 < xsize; x1++)
188 POSITION x = x0 - xhsize + x1;
190 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++)
202 x1 = randint1(xhsize) * 2 + x0 - xhsize;
203 x2 = randint1(xhsize) * 2 + x0 - xhsize;
204 y1 = randint1(yhsize) * 2 + y0 - yhsize;
205 y2 = randint1(yhsize) * 2 + y0 - yhsize;
206 build_room(player_ptr, x1, x2, y1, y2);
209 /* Add some random doors */
210 for (i = 0; i < 500; i++)
212 x1 = randint1(xsize - 3) - xhsize + x0 + 1;
213 y1 = randint1(ysize - 3) - yhsize + y0 + 1;
214 add_door(player_ptr, x1, y1);
217 /* Fill with monsters and treasure, high difficulty */
218 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5);
222 /* Create a random vault out of a fractal grid */
223 static void build_cave_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
225 int grd, roug, cutoff;
226 bool done, light, room;
227 POSITION xhsize, yhsize, xsize, ysize, x, y;
229 /* round to make sizes even */
235 msg_print_wizard(CHEAT_DUNGEON, _("洞穴ランダムVaultを生成しました。", "Cave Vault."));
237 light = done = FALSE;
240 floor_type *floor_ptr = player_ptr->current_floor_ptr;
243 /* testing values for these parameters feel free to adjust */
244 grd = 1 << randint0(4);
246 /* want average of about 16 */
247 roug = randint1(8) * randint1(4);
250 cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
251 randint1(xsize / 4) + randint1(ysize / 4);
254 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, cutoff);
256 /* Convert to normal format+ clean up */
257 done = generate_fracave(player_ptr, y0, x0, xsize, ysize, cutoff, light, room);
260 /* Set icky flag because is a vault */
261 for (x = 0; x <= xsize; x++)
263 for (y = 0; y <= ysize; y++)
265 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
269 /* Fill with monsters and treasure, low difficulty */
270 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
275 * @brief Vault地形を回転、上下左右反転するための座標変換を返す / coordinate translation code
276 * @param x 変換したい点のX座標参照ポインタ
277 * @param y 変換したい点のY座標参照ポインタ
278 * @param xoffset Vault生成時の基準X座標
279 * @param yoffset Vault生成時の基準Y座標
280 * @param transno 処理ID
283 static void coord_trans(POSITION *x, POSITION *y, POSITION xoffset, POSITION yoffset, int transno)
289 * transno specifies what transformation is required. (0-7)
290 * The lower two bits indicate by how much the vault is rotated,
291 * and the upper bit indicates a reflection.
292 * This is done by using rotation matrices... however since
293 * these are mostly zeros for rotations by 90 degrees this can
294 * be expressed simply in terms of swapping and inverting the
295 * x and y coordinates.
297 for (i = 0; i < transno % 4; i++)
299 /* rotate by 90 degrees */
307 /* Reflect depending on status of 3rd bit. */
311 /* Add offsets so vault stays in the first quadrant */
318 * @brief Vaultをフロアに配置する / Hack -- fill in "vault" rooms
319 * @param player_ptr プレーヤーへの参照ポインタ
320 * @param yval 生成基準Y座標
321 * @param xval 生成基準X座標
322 * @param ymax VaultのYサイズ
323 * @param xmax VaultのXサイズ
324 * @param data Vaultのデータ文字列
325 * @param xoffset 変換基準X座標
326 * @param yoffset 変換基準Y座標
327 * @param transno 変換ID
330 static void build_vault(player_type *player_ptr, POSITION yval, POSITION xval, POSITION ymax, POSITION xmax, concptr data,
331 POSITION xoffset, POSITION yoffset, int transno)
333 POSITION dx, dy, x, y, i, j;
337 /* Place dungeon features and objects */
338 floor_type *floor_ptr = player_ptr->current_floor_ptr;
339 for (t = data, dy = 0; dy < ymax; dy++)
341 for (dx = 0; dx < xmax; dx++, t++)
343 /* prevent loop counter from being overwritten */
348 coord_trans(&i, &j, xoffset, yoffset, transno);
350 if (transno % 2 == 0)
353 x = xval - (xmax / 2) + i;
354 y = yval - (ymax / 2) + j;
359 x = xval - (ymax / 2) + i;
360 y = yval - (xmax / 2) + j;
363 /* Hack -- skip "non-grids" */
364 if (*t == ' ') continue;
365 g_ptr = &floor_ptr->grid_array[y][x];
367 /* Lay down a floor */
368 place_grid(player_ptr, g_ptr, GB_FLOOR);
370 /* Remove any mimic */
373 /* Part of a vault */
374 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
376 /* Analyze the grid */
379 /* Granite wall (outer) */
381 place_grid(player_ptr, g_ptr, GB_OUTER_NOPERM);
384 /* Granite wall (inner) */
386 place_grid(player_ptr, g_ptr, GB_INNER);
389 /* Glass wall (inner) */
391 place_grid(player_ptr, g_ptr, GB_INNER);
392 g_ptr->feat = feat_glass_wall;
395 /* Permanent wall (inner) */
397 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
400 /* Permanent glass wall (inner) */
402 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
403 g_ptr->feat = feat_permanent_glass_wall;
408 if (randint0(100) < 75)
410 place_object(player_ptr, y, x, 0L);
414 place_trap(player_ptr, y, x);
420 place_object(player_ptr, y, x, 0L);
425 g_ptr->feat = feat_tree;
430 place_secret_door(player_ptr, y, x, DOOR_DEFAULT);
433 /* Secret glass doors */
435 place_secret_door(player_ptr, y, x, DOOR_GLASS_DOOR);
436 if (is_closed_door(player_ptr, g_ptr->feat)) g_ptr->mimic = feat_glass_wall;
441 place_secret_door(player_ptr, y, x, DOOR_CURTAIN);
446 place_trap(player_ptr, y, x);
449 /* Black market in a dungeon */
451 set_cave_feat(floor_ptr, y, x, feat_black_market);
452 store_init(NO_TOWN, STORE_BLACK);
457 set_cave_feat(floor_ptr, y, x, feat_pattern_start);
461 set_cave_feat(floor_ptr, y, x, feat_pattern_1);
465 set_cave_feat(floor_ptr, y, x, feat_pattern_2);
469 set_cave_feat(floor_ptr, y, x, feat_pattern_3);
473 set_cave_feat(floor_ptr, y, x, feat_pattern_4);
477 set_cave_feat(floor_ptr, y, x, feat_pattern_end);
481 set_cave_feat(floor_ptr, y, x, feat_pattern_exit);
485 /* Reward for Pattern walk */
486 floor_ptr->object_level = floor_ptr->base_level + 12;
487 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
488 floor_ptr->object_level = floor_ptr->base_level;
492 set_cave_feat(floor_ptr, y, x, feat_shallow_water);
496 set_cave_feat(floor_ptr, y, x, feat_deep_water);
500 set_cave_feat(floor_ptr, y, x, feat_shallow_lava);
504 set_cave_feat(floor_ptr, y, x, feat_deep_lava);
508 set_cave_feat(floor_ptr, y, x, feat_shallow_acid_puddle);
512 set_cave_feat(floor_ptr, y, x, feat_deep_acid_puddle);
516 set_cave_feat(floor_ptr, y, x, feat_shallow_poisonous_puddle);
520 set_cave_feat(floor_ptr, y, x, feat_deep_poisonous_puddle);
524 set_cave_feat(floor_ptr, y, x, feat_cold_zone);
528 set_cave_feat(floor_ptr, y, x, feat_heavy_cold_zone);
532 set_cave_feat(floor_ptr, y, x, feat_electrical_zone);
536 set_cave_feat(floor_ptr, y, x, feat_heavy_electrical_zone);
544 /* Place dungeon monsters and objects */
545 for (t = data, dy = 0; dy < ymax; dy++)
547 for (dx = 0; dx < xmax; dx++, t++)
549 /* prevent loop counter from being overwritten */
554 coord_trans(&i, &j, xoffset, yoffset, transno);
556 if (transno % 2 == 0)
559 x = xval - (xmax / 2) + i;
560 y = yval - (ymax / 2) + j;
565 x = xval - (ymax / 2) + i;
566 y = yval - (xmax / 2) + j;
569 /* Hack -- skip "non-grids" */
570 if (*t == ' ') continue;
572 /* Analyze the symbol */
577 floor_ptr->monster_level = floor_ptr->base_level + 5;
578 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
579 floor_ptr->monster_level = floor_ptr->base_level;
586 floor_ptr->monster_level = floor_ptr->base_level + 11;
587 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
588 floor_ptr->monster_level = floor_ptr->base_level;
592 /* Meaner monster, plus treasure */
595 floor_ptr->monster_level = floor_ptr->base_level + 9;
596 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
597 floor_ptr->monster_level = floor_ptr->base_level;
598 floor_ptr->object_level = floor_ptr->base_level + 7;
599 place_object(player_ptr, y, x, AM_GOOD);
600 floor_ptr->object_level = floor_ptr->base_level;
604 /* Nasty monster and treasure */
607 floor_ptr->monster_level = floor_ptr->base_level + 40;
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 + 20;
611 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
612 floor_ptr->object_level = floor_ptr->base_level;
616 /* Monster and/or object */
619 if (randint0(100) < 50)
621 floor_ptr->monster_level = floor_ptr->base_level + 3;
622 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
623 floor_ptr->monster_level = floor_ptr->base_level;
625 if (randint0(100) < 50)
627 floor_ptr->object_level = floor_ptr->base_level + 7;
628 place_object(player_ptr, y, x, 0L);
629 floor_ptr->object_level = floor_ptr->base_level;
640 * @brief タイプ7の部屋…v_info.txtより小型vaultを生成する / Type 7 -- simple vaults (see "v_info.txt")
643 bool build_type7(player_type *player_ptr)
645 vault_type *v_ptr = NULL;
649 POSITION xoffset, yoffset;
652 /* Pick a lesser vault */
653 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
655 /* Access a random vault record */
656 v_ptr = &v_info[randint0(max_v_idx)];
658 /* Accept the first lesser vault */
659 if (v_ptr->typ == 7) break;
662 /* No lesser vault found */
663 if (dummy >= SAFE_MAX_ATTEMPTS)
665 msg_print_wizard(CHEAT_DUNGEON, _("小型固定Vaultを配置できませんでした。", "Could not place lesser vault."));
669 /* pick type of transformation (0-7) */
670 transno = randint0(8);
672 /* calculate offsets */
676 /* Some huge vault cannot be ratated to fit in the dungeon */
677 floor_type *floor_ptr = player_ptr->current_floor_ptr;
678 if (x + 2 > floor_ptr->height - 2)
680 /* Forbid 90 or 270 degree ratation */
684 coord_trans(&x, &y, 0, 0, transno);
704 /* Find and reserve some space in the dungeon. Get center of room. */
705 if (!find_space(player_ptr, &yval, &xval, abs(y), abs(x))) return FALSE;
707 msg_format_wizard(CHEAT_DUNGEON, _("小型Vault(%s)を生成しました。", "Lesser vault (%s)."), v_name + v_ptr->name);
709 /* Hack -- Build the vault */
710 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
711 v_text + v_ptr->text, xoffset, yoffset, transno);
718 * @brief タイプ8の部屋…v_info.txtより大型vaultを生成する / Type 8 -- greater vaults (see "v_info.txt")
721 bool build_type8(player_type *player_ptr)
728 POSITION xoffset, yoffset;
730 /* Pick a greater vault */
731 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
733 /* Access a random vault record */
734 v_ptr = &v_info[randint0(max_v_idx)];
736 /* Accept the first greater vault */
737 if (v_ptr->typ == 8) break;
740 /* No greater vault found */
741 if (dummy >= SAFE_MAX_ATTEMPTS)
743 msg_print_wizard(CHEAT_DUNGEON, _("大型固定Vaultを配置できませんでした。", "Could not place greater vault."));
747 /* pick type of transformation (0-7) */
748 transno = randint0(8);
750 /* calculate offsets */
754 /* Some huge vault cannot be ratated to fit in the dungeon */
755 floor_type *floor_ptr = player_ptr->current_floor_ptr;
756 if (x + 2 > floor_ptr->height - 2)
758 /* Forbid 90 or 270 degree ratation */
762 coord_trans(&x, &y, 0, 0, transno);
783 * Try to allocate space for room. If fails, exit
785 * Hack -- Prepare a bit larger space (+2, +2) to
786 * prevent generation of vaults with no-entrance.
788 /* Find and reserve some space in the dungeon. Get center of room. */
789 if (!find_space(player_ptr, &yval, &xval, (POSITION)(abs(y) + 2), (POSITION)(abs(x) + 2))) return FALSE;
791 msg_format_wizard(CHEAT_DUNGEON, _("大型固定Vault(%s)を生成しました。", "Greater vault (%s)."), v_name + v_ptr->name);
793 /* Hack -- Build the vault */
794 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
795 v_text + v_ptr->text, xoffset, yoffset, transno);
802 * Build target vault.
803 * This is made by two concentric "crypts" with perpendicular
804 * walls creating the cross-hairs.
806 static void build_target_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
810 /* Make a random metric */
811 POSITION h1, h2, h3, h4;
812 h1 = randint1(32) - 16;
815 h4 = randint1(32) - 16;
817 msg_print_wizard(CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Elemental Vault"));
819 /* work out outer radius */
830 floor_type *floor_ptr = player_ptr->current_floor_ptr;
831 for (x = x0 - rad; x <= x0 + rad; x++)
833 for (y = y0 - rad; y <= y0 + rad; y++)
835 /* clear room flag */
836 floor_ptr->grid_array[y][x].info &= ~(CAVE_ROOM);
838 /* Vault - so is "icky" */
839 floor_ptr->grid_array[y][x].info |= CAVE_ICKY;
841 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1)
843 /* inside- so is floor */
844 place_bold(player_ptr, y, x, GB_FLOOR);
848 /* make granite outside so arena works */
849 place_bold(player_ptr, y, x, GB_EXTRA);
852 /* proper boundary for arena */
853 if (((y + rad) == y0) || ((y - rad) == y0) ||
854 ((x + rad) == x0) || ((x - rad) == x0))
856 place_bold(player_ptr, y, x, GB_EXTRA);
861 /* Find visible outer walls and set to be FEAT_OUTER */
862 add_outer_wall(player_ptr, x0, y0, FALSE, x0 - rad - 1, y0 - rad - 1, x0 + rad + 1, y0 + rad + 1);
865 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++)
867 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++)
869 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2)
871 /* Make an internal wall */
872 place_bold(player_ptr, y, x, GB_INNER);
877 /* Add perpendicular walls */
878 for (x = x0 - rad; x <= x0 + rad; x++)
880 place_bold(player_ptr, y0, x, GB_INNER);
883 for (y = y0 - rad; y <= y0 + rad; y++)
885 place_bold(player_ptr, y, x0, GB_INNER);
888 /* Make inner vault */
889 for (y = y0 - 1; y <= y0 + 1; y++)
891 place_bold(player_ptr, y, x0 - 1, GB_INNER);
892 place_bold(player_ptr, y, x0 + 1, GB_INNER);
894 for (x = x0 - 1; x <= x0 + 1; x++)
896 place_bold(player_ptr, y0 - 1, x, GB_INNER);
897 place_bold(player_ptr, y0 + 1, x, GB_INNER);
900 place_bold(player_ptr, y0, x0, GB_FLOOR);
903 /* Add doors to vault */
904 /* get two distances so can place doors relative to centre */
905 x = (rad - 2) / 4 + 1;
908 add_door(player_ptr, x0 + x, y0);
909 add_door(player_ptr, x0 + y, y0);
910 add_door(player_ptr, x0 - x, y0);
911 add_door(player_ptr, x0 - y, y0);
912 add_door(player_ptr, x0, y0 + x);
913 add_door(player_ptr, x0, y0 + y);
914 add_door(player_ptr, x0, y0 - x);
915 add_door(player_ptr, x0, y0 - y);
917 /* Fill with stuff - medium difficulty */
918 fill_treasure(player_ptr, x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
923 * This routine uses a modified version of the lake code to make a
924 * distribution of some terrain type over the vault. This type
925 * depends on the dungeon depth.
927 * Miniture rooms are then scattered across the vault.
929 static void build_elemental_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
934 POSITION xsize, ysize, xhsize, yhsize, x, y;
938 msg_print_wizard(CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
940 /* round to make sizes even */
946 floor_type *floor_ptr = player_ptr->current_floor_ptr;
947 if (floor_ptr->dun_level < 25)
949 /* Earth vault (Rubble) */
950 type = LAKE_T_EARTH_VAULT;
952 else if (floor_ptr->dun_level < 50)
954 /* Air vault (Trees) */
955 type = LAKE_T_AIR_VAULT;
957 else if (floor_ptr->dun_level < 75)
959 /* Water vault (shallow water) */
960 type = LAKE_T_WATER_VAULT;
964 /* Fire vault (shallow lava) */
965 type = LAKE_T_FIRE_VAULT;
970 /* testing values for these parameters: feel free to adjust */
971 grd = 1 << (randint0(3));
973 /* want average of about 16 */
974 roug = randint1(8) * randint1(4);
976 /* Make up size of various componants */
980 /* Deep water/lava */
981 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
983 /* Shallow boundary */
987 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, c3);
989 /* Convert to normal format+ clean up */
990 done = generate_lake(player_ptr, y0, x0, xsize, ysize, c1, c2, c3, type);
993 /* Set icky flag because is a vault */
994 for (x = 0; x <= xsize; x++)
996 for (y = 0; y <= ysize; y++)
998 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
1002 /* make a few rooms in the vault */
1003 for (i = 1; i <= (xsize * ysize) / 50; i++)
1005 build_small_room(player_ptr, x0 + randint0(xsize - 4) - xsize / 2 + 2,
1006 y0 + randint0(ysize - 4) - ysize / 2 + 2);
1009 /* Fill with monsters and treasure, low difficulty */
1010 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1,
1011 y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
1015 /* Build a "mini" checkerboard vault
1017 * This is done by making a permanent wall maze and setting
1018 * the diagonal sqaures of the checker board to be granite.
1019 * The vault has two entrances on opposite sides to guarantee
1020 * a way to get in even if the vault abuts a side of the dungeon.
1022 static void build_mini_c_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1025 POSITION y1, x1, y2, x2, y, x, total;
1026 int m, n, num_vertices;
1029 msg_print_wizard(CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
1031 /* Pick a random room size */
1041 /* generate the room */
1042 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1043 for (x = x1 - 2; x <= x2 + 2; x++)
1045 if (!in_bounds(floor_ptr, y1 - 2, x)) break;
1047 floor_ptr->grid_array[y1 - 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1049 place_bold(player_ptr, y1 - 2, x, GB_OUTER_NOPERM);
1052 for (x = x1 - 2; x <= x2 + 2; x++)
1054 if (!in_bounds(floor_ptr, y2 + 2, x)) break;
1056 floor_ptr->grid_array[y2 + 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
1058 place_bold(player_ptr, y2 + 2, x, GB_OUTER_NOPERM);
1061 for (y = y1 - 2; y <= y2 + 2; y++)
1063 if (!in_bounds(floor_ptr, y, x1 - 2)) break;
1065 floor_ptr->grid_array[y][x1 - 2].info |= (CAVE_ROOM | CAVE_ICKY);
1067 place_bold(player_ptr, y, x1 - 2, GB_OUTER_NOPERM);
1070 for (y = y1 - 2; y <= y2 + 2; y++)
1072 if (!in_bounds(floor_ptr, y, x2 + 2)) break;
1074 floor_ptr->grid_array[y][x2 + 2].info |= (CAVE_ROOM | CAVE_ICKY);
1076 place_bold(player_ptr, y, x2 + 2, GB_OUTER_NOPERM);
1079 for (y = y1 - 1; y <= y2 + 1; y++)
1081 for (x = x1 - 1; x <= x2 + 1; x++)
1083 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1085 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
1087 /* Permanent walls */
1088 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
1093 /* dimensions of vertex array */
1096 num_vertices = m * n;
1098 /* initialize array of visited vertices */
1099 C_MAKE(visited, num_vertices, int);
1101 /* traverse the graph to create a spannng tree, pick a random root */
1102 r_visit(player_ptr, y1, x1, y2, x2, randint0(num_vertices), 0, visited);
1104 /* Make it look like a checker board vault */
1105 for (x = x1; x <= x2; x++)
1107 for (y = y1; y <= y2; y++)
1109 total = x - x1 + y - y1;
1110 /* If total is odd- and is a floor then make a wall */
1111 if ((total % 2 == 1) && is_floor_bold(floor_ptr, y, x))
1113 place_bold(player_ptr, y, x, GB_INNER);
1118 /* Make a couple of entrances */
1121 /* left and right */
1122 y = randint1(dy) + dy / 2;
1123 place_bold(player_ptr, y1 + y, x1 - 1, GB_INNER);
1124 place_bold(player_ptr, y1 + y, x2 + 1, GB_INNER);
1128 /* top and bottom */
1129 x = randint1(dx) + dx / 2;
1130 place_bold(player_ptr, y1 - 1, x1 + x, GB_INNER);
1131 place_bold(player_ptr, y2 + 1, x1 + x, GB_INNER);
1134 /* Fill with monsters and treasure, highest difficulty */
1135 fill_treasure(player_ptr, x1, x2, y1, y2, 10);
1137 C_KILL(visited, num_vertices, int);
1140 /* Build a castle */
1141 /* Driver routine: clear the region and call the recursive
1144 *This makes a vault that looks like a castle/ city in the dungeon.
1146 static void build_castle_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1149 POSITION y1, x1, y2, x2;
1152 /* Pick a random room size */
1161 msg_print_wizard(CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
1163 /* generate the room */
1164 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1165 for (y = y1 - 1; y <= y2 + 1; y++)
1167 for (x = x1 - 1; x <= x2 + 1; x++)
1169 floor_ptr->grid_array[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
1170 /* Make everything a floor */
1171 place_bold(player_ptr, y, x, GB_FLOOR);
1175 /* Make the castle */
1176 build_recursive_room(player_ptr, x1, y1, x2, y2, randint1(5));
1178 /* Fill with monsters and treasure, low difficulty */
1179 fill_treasure(player_ptr, x1, x2, y1, y2, randint1(3));
1184 * @brief タイプ10の部屋…ランダム生成vault / Type 10 -- Random vaults
1185 * @param player_ptr プレーヤーへの参照ポインタ
1188 bool build_type10(player_type *player_ptr)
1190 POSITION y0, x0, xsize, ysize, vtype;
1192 /* big enough to look good, small enough to be fairly common. */
1193 xsize = randint1(22) + 22;
1194 ysize = randint1(11) + 11;
1196 /* Find and reserve some space in the dungeon. Get center of room. */
1197 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1198 if (!find_space(player_ptr, &y0, &x0, ysize + 1, xsize + 1)) return FALSE;
1200 /* Select type of vault */
1203 vtype = randint1(15);
1204 } while ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) &&
1205 ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
1209 /* Build an appropriate room */
1210 case 1: case 9: build_bubble_vault(player_ptr, x0, y0, xsize, ysize); break;
1211 case 2: case 10: build_room_vault(player_ptr, x0, y0, xsize, ysize); break;
1212 case 3: case 11: build_cave_vault(player_ptr, x0, y0, xsize, ysize); break;
1213 case 4: case 12: build_maze_vault(player_ptr, x0, y0, xsize, ysize, TRUE); break;
1214 case 5: case 13: build_mini_c_vault(player_ptr, x0, y0, xsize, ysize); break;
1215 case 6: case 14: build_castle_vault(player_ptr, x0, y0, xsize, ysize); break;
1216 case 7: case 15: build_target_vault(player_ptr, x0, y0, xsize, ysize); break;
1217 case 8: build_elemental_vault(player_ptr, x0, y0, xsize, ysize); break;
1218 /* I know how to add a few more... give me some time. */
1219 default: return FALSE;
1227 * @brief タイプ17の部屋…v_info.txtより固定特殊部屋を生成する / Type 17 -- fixed special room (see "v_info.txt")
1230 bool build_type17(player_type *player_ptr)
1232 vault_type *v_ptr = NULL;
1235 POSITION xval, yval;
1236 POSITION xoffset, yoffset;
1239 /* Pick a lesser vault */
1240 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++)
1242 /* Access a random vault record */
1243 v_ptr = &v_info[randint0(max_v_idx)];
1245 /* Accept the special fix room. */
1246 if (v_ptr->typ == 17) break;
1249 /* No lesser vault found */
1250 if (dummy >= SAFE_MAX_ATTEMPTS)
1252 msg_print_wizard(CHEAT_DUNGEON, _("固定特殊部屋を配置できませんでした。", "Could not place fixed special room."));
1256 /* pick type of transformation (0-7) */
1257 transno = randint0(8);
1259 /* calculate offsets */
1263 /* Some huge vault cannot be ratated to fit in the dungeon */
1264 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1265 if (x + 2 > floor_ptr->height - 2)
1267 /* Forbid 90 or 270 degree ratation */
1271 coord_trans(&x, &y, 0, 0, transno);
1291 /* Find and reserve some space in the dungeon. Get center of room. */
1292 if (!find_space(player_ptr, &yval, &xval, abs(y), abs(x))) return FALSE;
1294 msg_format_wizard(CHEAT_DUNGEON, _("特殊固定部屋(%s)を生成しました。", "Special Fix room (%s)."), v_name + v_ptr->name);
1296 /* Hack -- Build the vault */
1297 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid,
1298 v_text + v_ptr->text, xoffset, yoffset, transno);