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-builder.h"
24 #include "room/rooms-maze-vault.h"
25 #include "room/space-finder.h"
26 #include "room/treasure-deployment.h"
27 #include "store/store-util.h"
28 #include "store/store.h"
29 #include "system/dungeon-data-definition.h"
30 #include "system/floor-type-definition.h"
31 #include "wizard/wizard-messages.h"
34 * The vault generation arrays
41 * Maximum number of vaults in v_info.txt
46 * This function creates a random vault that looks like a collection of bubbles.
47 * It works by getting a set of coordinates that represent the center of each
48 * bubble. The entire room is made by seeing which bubble center is closest. If
49 * two centers are equidistant then the square is a wall, otherwise it is a floor.
50 * The only exception is for squares really near a center, these are always floor.
51 * (It looks better than without this check.)
53 * Note: If two centers are on the same point then this algorithm will create a
54 * blank bubble filled with walls. - This is prevented from happening.
56 static void build_bubble_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
58 #define BUBBLENUM 10 /* number of bubbles */
60 /* array of center points of bubbles */
61 coord center[BUBBLENUM];
64 POSITION x = 0, y = 0;
65 u16b min1, min2, temp;
68 /* Offset from center to top left hand corner */
69 POSITION xhsize = xsize / 2;
70 POSITION yhsize = ysize / 2;
72 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("泡型ランダムVaultを生成しました。", "Room Vault."));
74 /* Allocate center of bubbles */
75 center[0].x = (byte)randint1(xsize - 3) + 1;
76 center[0].y = (byte)randint1(ysize - 3) + 1;
78 for (i = 1; i < BUBBLENUM; i++) {
81 /* get center and check to see if it is unique */
85 x = randint1(xsize - 3) + 1;
86 y = randint1(ysize - 3) + 1;
88 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))
99 /* Top and bottom boundaries */
100 floor_type *floor_ptr = player_ptr->current_floor_ptr;
101 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++) {
112 int side_y = y0 - yhsize + i;
114 place_bold(player_ptr, side_y, x0 - xhsize + 0, GB_OUTER_NOPERM);
115 floor_ptr->grid_array[side_y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
116 place_bold(player_ptr, side_y, x0 - xhsize + xsize - 1, GB_OUTER_NOPERM);
117 floor_ptr->grid_array[side_y][x0 - xhsize + xsize - 1].info |= (CAVE_ROOM | CAVE_ICKY);
120 /* Fill in middle with bubbles */
121 for (x = 1; x < xsize - 1; x++) {
122 for (y = 1; y < ysize - 1; y++) {
123 /* Get distances to two closest centers */
125 min1 = (u16b)distance(x, y, center[0].x, center[0].y);
126 min2 = (u16b)distance(x, y, center[1].x, center[1].y);
129 /* swap if in wrong order */
136 for (i = 2; i < BUBBLENUM; i++) {
137 temp = (u16b)distance(x, y, center[i].x, center[i].y);
143 } else if (temp < min2) {
144 /* second smallest */
148 if (((min2 - min1) <= 2) && (!(min1 < 3))) {
149 /* Boundary at midpoint+ not at inner region of bubble */
150 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_OUTER_NOPERM);
152 /* middle of a bubble */
153 place_bold(player_ptr, y0 - yhsize + y, x0 - xhsize + x, GB_FLOOR);
156 /* clean up rest of flags */
157 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= (CAVE_ROOM | CAVE_ICKY);
161 /* Try to add some random doors */
162 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(player_ptr, 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++) {
187 POSITION x = x0 - xhsize + x1;
189 for (y1 = 0; y1 < ysize; y1++) {
190 POSITION y = y0 - yhsize + y1;
192 place_bold(player_ptr, y, x, GB_EXTRA);
193 floor_ptr->grid_array[y][x].info &= (~CAVE_ICKY);
197 /* add ten random rooms */
198 for (i = 0; i < 10; i++) {
199 x1 = randint1(xhsize) * 2 + x0 - xhsize;
200 x2 = randint1(xhsize) * 2 + x0 - xhsize;
201 y1 = randint1(yhsize) * 2 + y0 - yhsize;
202 y2 = randint1(yhsize) * 2 + y0 - yhsize;
203 build_room(player_ptr, x1, x2, y1, y2);
206 /* Add some random doors */
207 for (i = 0; i < 500; i++) {
208 x1 = randint1(xsize - 3) - xhsize + x0 + 1;
209 y1 = randint1(ysize - 3) - yhsize + y0 + 1;
210 add_door(player_ptr, x1, y1);
213 /* Fill with monsters and treasure, high difficulty */
214 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 2, y0 - yhsize + 1, y0 - yhsize + ysize - 2, randint1(5) + 5);
217 /* Create a random vault out of a fractal grid */
218 static void build_cave_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
220 int grd, roug, cutoff;
221 bool done, light, room;
222 POSITION xhsize, yhsize, xsize, ysize, x, y;
224 /* round to make sizes even */
230 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("洞穴ランダムVaultを生成しました。", "Cave Vault."));
232 light = done = FALSE;
235 floor_type *floor_ptr = player_ptr->current_floor_ptr;
237 /* testing values for these parameters feel free to adjust */
238 grd = 1 << randint0(4);
240 /* want average of about 16 */
241 roug = randint1(8) * randint1(4);
244 cutoff = randint1(xsize / 4) + randint1(ysize / 4) + randint1(xsize / 4) + randint1(ysize / 4);
247 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, cutoff);
249 /* Convert to normal format+ clean up */
250 done = generate_fracave(player_ptr, y0, x0, xsize, ysize, cutoff, light, room);
253 /* Set icky flag because is a vault */
254 for (x = 0; x <= xsize; x++) {
255 for (y = 0; y <= ysize; y++) {
256 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
260 /* Fill with monsters and treasure, low difficulty */
261 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
265 * @brief Vault地形を回転、上下左右反転するための座標変換を返す / coordinate translation code
266 * @param x 変換したい点のX座標参照ポインタ
267 * @param y 変換したい点のY座標参照ポインタ
268 * @param xoffset Vault生成時の基準X座標
269 * @param yoffset Vault生成時の基準Y座標
270 * @param transno 処理ID
273 static void coord_trans(POSITION *x, POSITION *y, POSITION xoffset, POSITION yoffset, int transno)
279 * transno specifies what transformation is required. (0-7)
280 * The lower two bits indicate by how much the vault is rotated,
281 * and the upper bit indicates a reflection.
282 * This is done by using rotation matrices... however since
283 * these are mostly zeros for rotations by 90 degrees this can
284 * be expressed simply in terms of swapping and inverting the
285 * x and y coordinates.
287 for (i = 0; i < transno % 4; i++) {
288 /* rotate by 90 degrees */
295 /* Reflect depending on status of 3rd bit. */
299 /* Add offsets so vault stays in the first quadrant */
305 * @brief Vaultをフロアに配置する / Hack -- fill in "vault" rooms
306 * @param player_ptr プレーヤーへの参照ポインタ
307 * @param yval 生成基準Y座標
308 * @param xval 生成基準X座標
309 * @param ymax VaultのYサイズ
310 * @param xmax VaultのXサイズ
311 * @param data Vaultのデータ文字列
312 * @param xoffset 変換基準X座標
313 * @param yoffset 変換基準Y座標
314 * @param transno 変換ID
317 static void build_vault(
318 player_type *player_ptr, POSITION yval, POSITION xval, POSITION ymax, POSITION xmax, concptr data, POSITION xoffset, POSITION yoffset, int transno)
320 POSITION dx, dy, x, y, i, j;
324 /* Place dungeon features and objects */
325 floor_type *floor_ptr = player_ptr->current_floor_ptr;
326 for (t = data, dy = 0; dy < ymax; dy++) {
327 for (dx = 0; dx < xmax; dx++, t++) {
328 /* prevent loop counter from being overwritten */
333 coord_trans(&i, &j, xoffset, yoffset, transno);
335 if (transno % 2 == 0) {
337 x = xval - (xmax / 2) + i;
338 y = yval - (ymax / 2) + j;
341 x = xval - (ymax / 2) + i;
342 y = yval - (xmax / 2) + j;
345 /* Hack -- skip "non-grids" */
348 g_ptr = &floor_ptr->grid_array[y][x];
350 /* Lay down a floor */
351 place_grid(player_ptr, g_ptr, GB_FLOOR);
353 /* Remove any mimic */
356 /* Part of a vault */
357 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
359 /* Analyze the grid */
361 /* Granite wall (outer) */
363 place_grid(player_ptr, g_ptr, GB_OUTER_NOPERM);
366 /* Granite wall (inner) */
368 place_grid(player_ptr, g_ptr, GB_INNER);
371 /* Glass wall (inner) */
373 place_grid(player_ptr, g_ptr, GB_INNER);
374 g_ptr->feat = feat_glass_wall;
377 /* Permanent wall (inner) */
379 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
382 /* Permanent glass wall (inner) */
384 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
385 g_ptr->feat = feat_permanent_glass_wall;
390 if (randint0(100) < 75) {
391 place_object(player_ptr, y, x, 0L);
393 place_trap(player_ptr, y, x);
399 place_object(player_ptr, y, x, 0L);
404 g_ptr->feat = feat_tree;
409 place_secret_door(player_ptr, y, x, DOOR_DEFAULT);
412 /* Secret glass doors */
414 place_secret_door(player_ptr, y, x, DOOR_GLASS_DOOR);
415 if (is_closed_door(player_ptr, g_ptr->feat))
416 g_ptr->mimic = feat_glass_wall;
421 place_secret_door(player_ptr, y, x, DOOR_CURTAIN);
426 place_trap(player_ptr, y, x);
429 /* Black market in a dungeon */
431 set_cave_feat(floor_ptr, y, x, feat_black_market);
432 store_init(NO_TOWN, STORE_BLACK);
437 set_cave_feat(floor_ptr, y, x, feat_pattern_start);
441 set_cave_feat(floor_ptr, y, x, feat_pattern_1);
445 set_cave_feat(floor_ptr, y, x, feat_pattern_2);
449 set_cave_feat(floor_ptr, y, x, feat_pattern_3);
453 set_cave_feat(floor_ptr, y, x, feat_pattern_4);
457 set_cave_feat(floor_ptr, y, x, feat_pattern_end);
461 set_cave_feat(floor_ptr, y, x, feat_pattern_exit);
465 /* Reward for Pattern walk */
466 floor_ptr->object_level = floor_ptr->base_level + 12;
467 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
468 floor_ptr->object_level = floor_ptr->base_level;
472 set_cave_feat(floor_ptr, y, x, feat_shallow_water);
476 set_cave_feat(floor_ptr, y, x, feat_deep_water);
480 set_cave_feat(floor_ptr, y, x, feat_shallow_lava);
484 set_cave_feat(floor_ptr, y, x, feat_deep_lava);
488 set_cave_feat(floor_ptr, y, x, feat_shallow_acid_puddle);
492 set_cave_feat(floor_ptr, y, x, feat_deep_acid_puddle);
496 set_cave_feat(floor_ptr, y, x, feat_shallow_poisonous_puddle);
500 set_cave_feat(floor_ptr, y, x, feat_deep_poisonous_puddle);
504 set_cave_feat(floor_ptr, y, x, feat_cold_zone);
508 set_cave_feat(floor_ptr, y, x, feat_heavy_cold_zone);
512 set_cave_feat(floor_ptr, y, x, feat_electrical_zone);
516 set_cave_feat(floor_ptr, y, x, feat_heavy_electrical_zone);
522 /* Place dungeon monsters and objects */
523 for (t = data, dy = 0; dy < ymax; dy++) {
524 for (dx = 0; dx < xmax; dx++, t++) {
525 /* prevent loop counter from being overwritten */
530 coord_trans(&i, &j, xoffset, yoffset, transno);
532 if (transno % 2 == 0) {
534 x = xval - (xmax / 2) + i;
535 y = yval - (ymax / 2) + j;
538 x = xval - (ymax / 2) + i;
539 y = yval - (xmax / 2) + j;
542 /* Hack -- skip "non-grids" */
546 /* Analyze the symbol */
549 floor_ptr->monster_level = floor_ptr->base_level + 5;
550 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
551 floor_ptr->monster_level = floor_ptr->base_level;
557 floor_ptr->monster_level = floor_ptr->base_level + 11;
558 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
559 floor_ptr->monster_level = floor_ptr->base_level;
563 /* Meaner monster, plus treasure */
565 floor_ptr->monster_level = floor_ptr->base_level + 9;
566 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
567 floor_ptr->monster_level = floor_ptr->base_level;
568 floor_ptr->object_level = floor_ptr->base_level + 7;
569 place_object(player_ptr, y, x, AM_GOOD);
570 floor_ptr->object_level = floor_ptr->base_level;
574 /* Nasty monster and treasure */
576 floor_ptr->monster_level = floor_ptr->base_level + 40;
577 place_monster(player_ptr, y, x, PM_ALLOW_SLEEP);
578 floor_ptr->monster_level = floor_ptr->base_level;
579 floor_ptr->object_level = floor_ptr->base_level + 20;
580 place_object(player_ptr, y, x, AM_GOOD | AM_GREAT);
581 floor_ptr->object_level = floor_ptr->base_level;
585 /* Monster and/or object */
587 if (randint0(100) < 50) {
588 floor_ptr->monster_level = floor_ptr->base_level + 3;
589 place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
590 floor_ptr->monster_level = floor_ptr->base_level;
592 if (randint0(100) < 50) {
593 floor_ptr->object_level = floor_ptr->base_level + 7;
594 place_object(player_ptr, y, x, 0L);
595 floor_ptr->object_level = floor_ptr->base_level;
605 * @brief タイプ7の部屋…v_info.txtより小型vaultを生成する / Type 7 -- simple vaults (see "v_info.txt")
608 bool build_type7(player_type *player_ptr)
610 vault_type *v_ptr = NULL;
614 POSITION xoffset, yoffset;
617 /* Pick a lesser vault */
618 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++) {
619 /* Access a random vault record */
620 v_ptr = &v_info[randint0(max_v_idx)];
622 /* Accept the first lesser vault */
627 /* No lesser vault found */
628 if (dummy >= SAFE_MAX_ATTEMPTS) {
629 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("小型固定Vaultを配置できませんでした。", "Could not place lesser vault."));
633 /* pick type of transformation (0-7) */
634 transno = randint0(8);
636 /* calculate offsets */
640 /* Some huge vault cannot be ratated to fit in the dungeon */
641 floor_type *floor_ptr = player_ptr->current_floor_ptr;
642 if (x + 2 > floor_ptr->height - 2) {
643 /* Forbid 90 or 270 degree ratation */
647 coord_trans(&x, &y, 0, 0, transno);
661 /* Find and reserve some space in the dungeon. Get center of room. */
662 if (!find_space(player_ptr, &yval, &xval, abs(y), abs(x)))
665 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("小型Vault(%s)を生成しました。", "Lesser vault (%s)."), v_name + v_ptr->name);
667 /* Hack -- Build the vault */
668 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid, v_text + v_ptr->text, xoffset, yoffset, transno);
674 * @brief タイプ8の部屋…v_info.txtより大型vaultを生成する / Type 8 -- greater vaults (see "v_info.txt")
677 bool build_type8(player_type *player_ptr)
684 POSITION xoffset, yoffset;
686 /* Pick a greater vault */
687 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++) {
688 /* Access a random vault record */
689 v_ptr = &v_info[randint0(max_v_idx)];
691 /* Accept the first greater vault */
696 /* No greater vault found */
697 if (dummy >= SAFE_MAX_ATTEMPTS) {
698 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("大型固定Vaultを配置できませんでした。", "Could not place greater vault."));
702 /* pick type of transformation (0-7) */
703 transno = randint0(8);
705 /* calculate offsets */
709 /* Some huge vault cannot be ratated to fit in the dungeon */
710 floor_type *floor_ptr = player_ptr->current_floor_ptr;
711 if (x + 2 > floor_ptr->height - 2) {
712 /* Forbid 90 or 270 degree ratation */
716 coord_trans(&x, &y, 0, 0, transno);
731 * Try to allocate space for room. If fails, exit
733 * Hack -- Prepare a bit larger space (+2, +2) to
734 * prevent generation of vaults with no-entrance.
736 /* Find and reserve some space in the dungeon. Get center of room. */
737 if (!find_space(player_ptr, &yval, &xval, (POSITION)(abs(y) + 2), (POSITION)(abs(x) + 2)))
740 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("大型固定Vault(%s)を生成しました。", "Greater vault (%s)."), v_name + v_ptr->name);
742 /* Hack -- Build the vault */
743 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid, v_text + v_ptr->text, xoffset, yoffset, transno);
749 * Build target vault.
750 * This is made by two concentric "crypts" with perpendicular
751 * walls creating the cross-hairs.
753 static void build_target_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
757 /* Make a random metric */
758 POSITION h1, h2, h3, h4;
759 h1 = randint1(32) - 16;
762 h4 = randint1(32) - 16;
764 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Elemental Vault"));
766 /* work out outer radius */
774 floor_type *floor_ptr = player_ptr->current_floor_ptr;
775 for (x = x0 - rad; x <= x0 + rad; x++) {
776 for (y = y0 - rad; y <= y0 + rad; y++) {
777 /* clear room flag */
778 floor_ptr->grid_array[y][x].info &= ~(CAVE_ROOM);
780 /* Vault - so is "icky" */
781 floor_ptr->grid_array[y][x].info |= CAVE_ICKY;
783 if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1) {
784 /* inside- so is floor */
785 place_bold(player_ptr, y, x, GB_FLOOR);
787 /* make granite outside so arena works */
788 place_bold(player_ptr, y, x, GB_EXTRA);
791 /* proper boundary for arena */
792 if (((y + rad) == y0) || ((y - rad) == y0) || ((x + rad) == x0) || ((x - rad) == x0)) {
793 place_bold(player_ptr, y, x, GB_EXTRA);
798 /* Find visible outer walls and set to be FEAT_OUTER */
799 add_outer_wall(player_ptr, x0, y0, FALSE, x0 - rad - 1, y0 - rad - 1, x0 + rad + 1, y0 + rad + 1);
802 for (x = x0 - rad / 2; x <= x0 + rad / 2; x++) {
803 for (y = y0 - rad / 2; y <= y0 + rad / 2; y++) {
804 if (dist2(y0, x0, y, x, h1, h2, h3, h4) == rad / 2) {
805 /* Make an internal wall */
806 place_bold(player_ptr, y, x, GB_INNER);
811 /* Add perpendicular walls */
812 for (x = x0 - rad; x <= x0 + rad; x++) {
813 place_bold(player_ptr, y0, x, GB_INNER);
816 for (y = y0 - rad; y <= y0 + rad; y++) {
817 place_bold(player_ptr, y, x0, GB_INNER);
820 /* Make inner vault */
821 for (y = y0 - 1; y <= y0 + 1; y++) {
822 place_bold(player_ptr, y, x0 - 1, GB_INNER);
823 place_bold(player_ptr, y, x0 + 1, GB_INNER);
825 for (x = x0 - 1; x <= x0 + 1; x++) {
826 place_bold(player_ptr, y0 - 1, x, GB_INNER);
827 place_bold(player_ptr, y0 + 1, x, GB_INNER);
830 place_bold(player_ptr, y0, x0, GB_FLOOR);
832 /* Add doors to vault */
833 /* get two distances so can place doors relative to centre */
834 x = (rad - 2) / 4 + 1;
837 add_door(player_ptr, x0 + x, y0);
838 add_door(player_ptr, x0 + y, y0);
839 add_door(player_ptr, x0 - x, y0);
840 add_door(player_ptr, x0 - y, y0);
841 add_door(player_ptr, x0, y0 + x);
842 add_door(player_ptr, x0, y0 + y);
843 add_door(player_ptr, x0, y0 - x);
844 add_door(player_ptr, x0, y0 - y);
846 /* Fill with stuff - medium difficulty */
847 fill_treasure(player_ptr, x0 - rad, x0 + rad, y0 - rad, y0 + rad, randint1(3) + 3);
851 * This routine uses a modified version of the lake code to make a
852 * distribution of some terrain type over the vault. This type
853 * depends on the dungeon depth.
855 * Miniture rooms are then scattered across the vault.
857 static void build_elemental_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsiz, POSITION ysiz)
862 POSITION xsize, ysize, xhsize, yhsize, x, y;
866 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
868 /* round to make sizes even */
874 floor_type *floor_ptr = player_ptr->current_floor_ptr;
875 if (floor_ptr->dun_level < 25) {
876 /* Earth vault (Rubble) */
877 type = LAKE_T_EARTH_VAULT;
878 } else if (floor_ptr->dun_level < 50) {
879 /* Air vault (Trees) */
880 type = LAKE_T_AIR_VAULT;
881 } else if (floor_ptr->dun_level < 75) {
882 /* Water vault (shallow water) */
883 type = LAKE_T_WATER_VAULT;
885 /* Fire vault (shallow lava) */
886 type = LAKE_T_FIRE_VAULT;
890 /* testing values for these parameters: feel free to adjust */
891 grd = 1 << (randint0(3));
893 /* want average of about 16 */
894 roug = randint1(8) * randint1(4);
896 /* Make up size of various componants */
900 /* Deep water/lava */
901 c1 = randint0(c3 / 2) + randint0(c3 / 2) - 5;
903 /* Shallow boundary */
907 generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, c3);
909 /* Convert to normal format+ clean up */
910 done = generate_lake(player_ptr, y0, x0, xsize, ysize, c1, c2, c3, type);
913 /* Set icky flag because is a vault */
914 for (x = 0; x <= xsize; x++) {
915 for (y = 0; y <= ysize; y++) {
916 floor_ptr->grid_array[y0 - yhsize + y][x0 - xhsize + x].info |= CAVE_ICKY;
920 /* make a few rooms in the vault */
921 for (i = 1; i <= (xsize * ysize) / 50; i++) {
922 build_small_room(player_ptr, x0 + randint0(xsize - 4) - xsize / 2 + 2, y0 + randint0(ysize - 4) - ysize / 2 + 2);
925 /* Fill with monsters and treasure, low difficulty */
926 fill_treasure(player_ptr, x0 - xhsize + 1, x0 - xhsize + xsize - 1, y0 - yhsize + 1, y0 - yhsize + ysize - 1, randint1(5));
929 /* Build a "mini" checkerboard vault
931 * This is done by making a permanent wall maze and setting
932 * the diagonal sqaures of the checker board to be granite.
933 * The vault has two entrances on opposite sides to guarantee
934 * a way to get in even if the vault abuts a side of the dungeon.
936 static void build_mini_c_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
939 POSITION y1, x1, y2, x2, y, x, total;
940 int m, n, num_vertices;
943 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
945 /* Pick a random room size */
954 /* generate the room */
955 floor_type *floor_ptr = player_ptr->current_floor_ptr;
956 for (x = x1 - 2; x <= x2 + 2; x++) {
957 if (!in_bounds(floor_ptr, y1 - 2, x))
960 floor_ptr->grid_array[y1 - 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
962 place_bold(player_ptr, y1 - 2, x, GB_OUTER_NOPERM);
965 for (x = x1 - 2; x <= x2 + 2; x++) {
966 if (!in_bounds(floor_ptr, y2 + 2, x))
969 floor_ptr->grid_array[y2 + 2][x].info |= (CAVE_ROOM | CAVE_ICKY);
971 place_bold(player_ptr, y2 + 2, x, GB_OUTER_NOPERM);
974 for (y = y1 - 2; y <= y2 + 2; y++) {
975 if (!in_bounds(floor_ptr, y, x1 - 2))
978 floor_ptr->grid_array[y][x1 - 2].info |= (CAVE_ROOM | CAVE_ICKY);
980 place_bold(player_ptr, y, x1 - 2, GB_OUTER_NOPERM);
983 for (y = y1 - 2; y <= y2 + 2; y++) {
984 if (!in_bounds(floor_ptr, y, x2 + 2))
987 floor_ptr->grid_array[y][x2 + 2].info |= (CAVE_ROOM | CAVE_ICKY);
989 place_bold(player_ptr, y, x2 + 2, GB_OUTER_NOPERM);
992 for (y = y1 - 1; y <= y2 + 1; y++) {
993 for (x = x1 - 1; x <= x2 + 1; x++) {
994 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
996 g_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
998 /* Permanent walls */
999 place_grid(player_ptr, g_ptr, GB_INNER_PERM);
1003 /* dimensions of vertex array */
1006 num_vertices = m * n;
1008 /* initialize array of visited vertices */
1009 C_MAKE(visited, num_vertices, int);
1011 /* traverse the graph to create a spannng tree, pick a random root */
1012 r_visit(player_ptr, y1, x1, y2, x2, randint0(num_vertices), 0, visited);
1014 /* Make it look like a checker board vault */
1015 for (x = x1; x <= x2; x++) {
1016 for (y = y1; y <= y2; y++) {
1017 total = x - x1 + y - y1;
1018 /* If total is odd- and is a floor then make a wall */
1019 if ((total % 2 == 1) && is_floor_bold(floor_ptr, y, x)) {
1020 place_bold(player_ptr, y, x, GB_INNER);
1025 /* Make a couple of entrances */
1027 /* left and right */
1028 y = randint1(dy) + dy / 2;
1029 place_bold(player_ptr, y1 + y, x1 - 1, GB_INNER);
1030 place_bold(player_ptr, y1 + y, x2 + 1, GB_INNER);
1032 /* top and bottom */
1033 x = randint1(dx) + dx / 2;
1034 place_bold(player_ptr, y1 - 1, x1 + x, GB_INNER);
1035 place_bold(player_ptr, y2 + 1, x1 + x, GB_INNER);
1038 /* Fill with monsters and treasure, highest difficulty */
1039 fill_treasure(player_ptr, x1, x2, y1, y2, 10);
1041 C_KILL(visited, num_vertices, int);
1044 /* Build a castle */
1045 /* Driver routine: clear the region and call the recursive
1048 *This makes a vault that looks like a castle/ city in the dungeon.
1050 static void build_castle_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize)
1053 POSITION y1, x1, y2, x2;
1056 /* Pick a random room size */
1065 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
1067 /* generate the room */
1068 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1069 for (y = y1 - 1; y <= y2 + 1; y++) {
1070 for (x = x1 - 1; x <= x2 + 1; x++) {
1071 floor_ptr->grid_array[y][x].info |= (CAVE_ROOM | CAVE_ICKY);
1072 /* Make everything a floor */
1073 place_bold(player_ptr, y, x, GB_FLOOR);
1077 /* Make the castle */
1078 build_recursive_room(player_ptr, x1, y1, x2, y2, randint1(5));
1080 /* Fill with monsters and treasure, low difficulty */
1081 fill_treasure(player_ptr, x1, x2, y1, y2, randint1(3));
1085 * @brief タイプ10の部屋…ランダム生成vault / Type 10 -- Random vaults
1086 * @param player_ptr プレーヤーへの参照ポインタ
1089 bool build_type10(player_type *player_ptr)
1091 POSITION y0, x0, xsize, ysize, vtype;
1093 /* big enough to look good, small enough to be fairly common. */
1094 xsize = randint1(22) + 22;
1095 ysize = randint1(11) + 11;
1097 /* Find and reserve some space in the dungeon. Get center of room. */
1098 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1099 if (!find_space(player_ptr, &y0, &x0, ysize + 1, xsize + 1))
1102 /* Select type of vault */
1104 vtype = randint1(15);
1105 } while ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) && ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
1108 /* Build an appropriate room */
1111 build_bubble_vault(player_ptr, x0, y0, xsize, ysize);
1115 build_room_vault(player_ptr, x0, y0, xsize, ysize);
1119 build_cave_vault(player_ptr, x0, y0, xsize, ysize);
1123 build_maze_vault(player_ptr, x0, y0, xsize, ysize, TRUE);
1127 build_mini_c_vault(player_ptr, x0, y0, xsize, ysize);
1131 build_castle_vault(player_ptr, x0, y0, xsize, ysize);
1135 build_target_vault(player_ptr, x0, y0, xsize, ysize);
1138 build_elemental_vault(player_ptr, x0, y0, xsize, ysize);
1140 /* I know how to add a few more... give me some time. */
1149 * @brief タイプ17の部屋…v_info.txtより固定特殊部屋を生成する / Type 17 -- fixed special room (see "v_info.txt")
1152 bool build_type17(player_type *player_ptr)
1154 vault_type *v_ptr = NULL;
1157 POSITION xval, yval;
1158 POSITION xoffset, yoffset;
1161 /* Pick a lesser vault */
1162 for (dummy = 0; dummy < SAFE_MAX_ATTEMPTS; dummy++) {
1163 /* Access a random vault record */
1164 v_ptr = &v_info[randint0(max_v_idx)];
1166 /* Accept the special fix room. */
1167 if (v_ptr->typ == 17)
1171 /* No lesser vault found */
1172 if (dummy >= SAFE_MAX_ATTEMPTS) {
1173 msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("固定特殊部屋を配置できませんでした。", "Could not place fixed special room."));
1177 /* pick type of transformation (0-7) */
1178 transno = randint0(8);
1180 /* calculate offsets */
1184 /* Some huge vault cannot be ratated to fit in the dungeon */
1185 floor_type *floor_ptr = player_ptr->current_floor_ptr;
1186 if (x + 2 > floor_ptr->height - 2) {
1187 /* Forbid 90 or 270 degree ratation */
1191 coord_trans(&x, &y, 0, 0, transno);
1205 /* Find and reserve some space in the dungeon. Get center of room. */
1206 if (!find_space(player_ptr, &yval, &xval, abs(y), abs(x)))
1209 msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("特殊固定部屋(%s)を生成しました。", "Special Fix room (%s)."), v_name + v_ptr->name);
1211 /* Hack -- Build the vault */
1212 build_vault(player_ptr, yval, xval, v_ptr->hgt, v_ptr->wid, v_text + v_ptr->text, xoffset, yoffset, transno);