1 #include "grid/feature-generator.h"
2 #include "dungeon/dungeon-flag-types.h"
3 #include "dungeon/dungeon.h"
4 #include "dungeon/quest.h"
5 #include "floor/cave.h"
6 #include "floor/dungeon-tunnel-util.h"
7 #include "game-option/cheat-types.h"
8 #include "game-option/game-play-options.h"
10 #include "grid/grid.h"
11 #include "room/lake-types.h"
12 #include "room/rooms-builder.h"
13 #include "system/dungeon-data-definition.h"
14 #include "system/floor-type-definition.h"
15 #include "wizard/wizard-messages.h"
18 * @brief フロアに洞窟や湖を配置する / Generate various caverns and lakes
19 * @details There were moved from cave_gen().
22 void gen_caverns_and_lakes(player_type *owner_ptr, dungeon_type *dungeon_ptr, dun_data_type *dd_ptr)
24 floor_type *floor_ptr = owner_ptr->current_floor_ptr;
25 if ((floor_ptr->dun_level > 30) && one_in_(DUN_DEST * 2) && small_levels && (dungeon_ptr->flags1 & DF1_DESTROY)) {
26 dd_ptr->destroyed = TRUE;
27 build_lake(owner_ptr, one_in_(2) ? LAKE_T_CAVE : LAKE_T_EARTH_VAULT);
30 if (one_in_(LAKE_LEVEL) && !dd_ptr->empty_level && !dd_ptr->destroyed && (dungeon_ptr->flags1 & DF1_LAKE_MASK)) {
32 if (dungeon_ptr->flags1 & DF1_LAKE_WATER)
35 if (dungeon_ptr->flags1 & DF1_LAKE_LAVA)
38 if (dungeon_ptr->flags1 & DF1_LAKE_RUBBLE)
41 if (dungeon_ptr->flags1 & DF1_LAKE_TREE)
44 if (dungeon_ptr->flags1 & DF1_LAKE_LAVA) {
45 if ((floor_ptr->dun_level > 80) && (randint0(count) < 2))
46 dd_ptr->laketype = LAKE_T_LAVA;
49 if (!dd_ptr->laketype && (floor_ptr->dun_level > 80) && one_in_(count))
50 dd_ptr->laketype = LAKE_T_FIRE_VAULT;
55 if ((dungeon_ptr->flags1 & DF1_LAKE_WATER) && !dd_ptr->laketype) {
56 if ((floor_ptr->dun_level > 50) && randint0(count) < 2)
57 dd_ptr->laketype = LAKE_T_WATER;
60 if (!dd_ptr->laketype && (floor_ptr->dun_level > 50) && one_in_(count))
61 dd_ptr->laketype = LAKE_T_WATER_VAULT;
66 if ((dungeon_ptr->flags1 & DF1_LAKE_RUBBLE) && !dd_ptr->laketype) {
67 if ((floor_ptr->dun_level > 35) && (randint0(count) < 2))
68 dd_ptr->laketype = LAKE_T_CAVE;
71 if (!dd_ptr->laketype && (floor_ptr->dun_level > 35) && one_in_(count))
72 dd_ptr->laketype = LAKE_T_EARTH_VAULT;
77 if ((floor_ptr->dun_level > 5) && (dungeon_ptr->flags1 & DF1_LAKE_TREE) && !dd_ptr->laketype)
78 dd_ptr->laketype = LAKE_T_AIR_VAULT;
80 if (dd_ptr->laketype) {
81 msg_print_wizard(owner_ptr, CHEAT_DUNGEON, _("湖を生成します。", "Lake on the level."));
82 build_lake(owner_ptr, dd_ptr->laketype);
86 if ((floor_ptr->dun_level > DUN_CAVERN) && !dd_ptr->empty_level && (dungeon_ptr->flags1 & DF1_CAVERN) && !dd_ptr->laketype && !dd_ptr->destroyed
87 && (randint1(1000) < floor_ptr->dun_level)) {
88 dd_ptr->cavern = TRUE;
89 msg_print_wizard(owner_ptr, CHEAT_DUNGEON, _("洞窟を生成。", "Cavern on level."));
90 build_cavern(owner_ptr);
93 if (quest_number(owner_ptr, floor_ptr->dun_level))
94 dd_ptr->destroyed = FALSE;
97 bool has_river_flag(dungeon_type *dungeon_ptr)
99 return (dungeon_ptr->flags1 & (DF1_WATER_RIVER | DF1_LAVA_RIVER | DF1_ACID_RIVER | DF1_POISONOUS_RIVER)) != 0;
103 * @brief 隣接4マスに存在する通路の数を返す / Count the number of "corridor" grids adjacent to the given grid.
104 * @param y1 基準となるマスのY座標
105 * @param x1 基準となるマスのX座標
107 * @note Assumes "in_bounds(y1, x1)"
109 * XXX XXX This routine currently only counts actual "empty floor"\n
110 * grids which are not in rooms. We might want to also count stairs,\n
111 * open doors, closed doors, etc.
113 static int next_to_corr(floor_type *floor_ptr, POSITION y1, POSITION x1)
116 for (int i = 0; i < 4; i++) {
117 POSITION y = y1 + ddy_ddd[i];
118 POSITION x = x1 + ddx_ddd[i];
120 g_ptr = &floor_ptr->grid_array[y][x];
121 if (cave_has_flag_grid(g_ptr, FF_WALL) || !is_floor_grid(g_ptr) || ((g_ptr->info & CAVE_ROOM) != 0))
131 * @brief ドアを設置可能な地形かを返す / Determine if the given location is "between" two walls, and "next to" two corridor spaces.
132 * @param y 判定を行いたいマスのY座標
133 * @param x 判定を行いたいマスのX座標
134 * @return ドアを設置可能ならばTRUEを返す
135 * @details まず垂直方向に、次に水平方向に調べる
137 static bool possible_doorway(floor_type *floor_ptr, POSITION y, POSITION x)
139 if (next_to_corr(floor_ptr, y, x) < 2)
142 if (cave_has_flag_bold(floor_ptr, y - 1, x, FF_WALL) && cave_has_flag_bold(floor_ptr, y + 1, x, FF_WALL))
145 if (cave_has_flag_bold(floor_ptr, y, x - 1, FF_WALL) && cave_has_flag_bold(floor_ptr, y, x + 1, FF_WALL))
152 * @brief ドアの設置を試みる / Places door at y, x position if at least 2 walls found
153 * @param player_ptr プレーヤーへの参照ポインタ
154 * @param y 設置を行いたいマスのY座標
155 * @param x 設置を行いたいマスのX座標
158 void try_door(player_type *player_ptr, dt_type *dt_ptr, POSITION y, POSITION x)
160 floor_type *floor_ptr = player_ptr->current_floor_ptr;
161 if (!in_bounds(floor_ptr, y, x) || cave_has_flag_bold(floor_ptr, y, x, FF_WALL) || ((floor_ptr->grid_array[y][x].info & CAVE_ROOM) != 0))
164 bool can_place_door = randint0(100) < dt_ptr->dun_tun_jct;
165 can_place_door &= possible_doorway(floor_ptr, y, x);
166 can_place_door &= (d_info[player_ptr->dungeon_idx].flags1 & DF1_NO_DOORS) == 0;
168 place_random_door(player_ptr, y, x, FALSE);