1 #include "room/vault-builder.h"
2 #include "floor/cave.h"
3 #include "floor/floor-generator-util.h"
4 #include "floor/floor-util.h"
5 #include "game-option/cheat-options.h"
6 #include "grid/feature-flag-types.h"
8 #include "grid/object-placer.h"
10 #include "monster-floor/monster-generator.h"
11 #include "monster-floor/place-monster-types.h"
12 #include "system/floor-type-definition.h"
13 #include "view/display-messages.h"
16 * Grid based version of "creature_bold()"
18 static bool player_grid(player_type *player_ptr, grid_type *g_ptr) { return g_ptr == &player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x]; }
21 * Grid based version of "cave_empty_bold()"
23 static bool is_cave_empty_grid(player_type *player_ptr, grid_type *g_ptr)
25 bool is_empty_grid = cave_has_flag_grid(g_ptr, FF_PLACE);
26 is_empty_grid &= g_ptr->m_idx == 0;
27 is_empty_grid &= !player_grid(player_ptr, g_ptr);
32 * @brief 特殊な部屋地形向けにモンスターを配置する / Place some sleeping monsters near the given location
33 * @param player_ptr プレーヤーへの参照ポインタ
34 * @param y1 モンスターを配置したいマスの中心Y座標
35 * @param x1 モンスターを配置したいマスの中心X座標
36 * @param num 配置したいモンスターの数
39 * Only really called by some of the "vault" routines.
41 void vault_monsters(player_type *player_ptr, POSITION y1, POSITION x1, int num)
43 floor_type *floor_ptr = player_ptr->current_floor_ptr;
44 for (int k = 0; k < num; k++) {
45 for (int i = 0; i < 9; i++) {
48 scatter(player_ptr, &y, &x, y1, x1, d, 0);
50 g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
51 if (!is_cave_empty_grid(player_ptr, g_ptr))
54 floor_ptr->monster_level = floor_ptr->base_level + 2;
55 (void)place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
56 floor_ptr->monster_level = floor_ptr->base_level;
62 * @brief 特殊な部屋向けに各種アイテムを配置する / Create up to "num" objects near the given coordinates
63 * @param player_ptr プレーヤーへの参照ポインタ
64 * @param y 配置したい中心マスのY座標
65 * @param x 配置したい中心マスのX座標
69 * Only really called by some of the "vault" routines.
71 void vault_objects(player_type *player_ptr, POSITION y, POSITION x, int num)
73 floor_type *floor_ptr = player_ptr->current_floor_ptr;
74 for (; num > 0; --num) {
77 for (int i = 0; i < 11; ++i) {
78 while (dummy < SAFE_MAX_ATTEMPTS) {
79 j = rand_spread(y, 2);
80 k = rand_spread(x, 3);
82 if (!in_bounds(floor_ptr, j, k))
87 if (dummy >= SAFE_MAX_ATTEMPTS && cheat_room) {
88 msg_print(_("警告!地下室のアイテムを配置できません!", "Warning! Could not place vault object!"));
92 g_ptr = &floor_ptr->grid_array[j][k];
93 if (!is_floor_grid(g_ptr) || g_ptr->o_idx)
96 if (randint0(100) < 75) {
97 place_object(player_ptr, j, k, 0L);
99 place_gold(player_ptr, j, k);
108 * @brief 特殊な部屋向けに各種アイテムを配置する(vault_trapのサブセット) / Place a trap with a given displacement of point
109 * @param y トラップを配置したいマスの中心Y座標
110 * @param x トラップを配置したいマスの中心X座標
111 * @param yd Y方向の配置分散マス数
112 * @param xd X方向の配置分散マス数
115 * Only really called by some of the "vault" routines.
117 static void vault_trap_aux(player_type *player_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd)
120 floor_type *floor_ptr = player_ptr->current_floor_ptr;
123 for (int count = 0; count <= 5; count++) {
124 while (dummy < SAFE_MAX_ATTEMPTS) {
125 y1 = rand_spread(y, yd);
126 x1 = rand_spread(x, xd);
128 if (!in_bounds(floor_ptr, y1, x1))
133 if (dummy >= SAFE_MAX_ATTEMPTS && cheat_room) {
134 msg_print(_("警告!地下室のトラップを配置できません!", "Warning! Could not place vault trap!"));
137 g_ptr = &floor_ptr->grid_array[y1][x1];
138 if (!is_floor_grid(g_ptr) || g_ptr->o_idx || g_ptr->m_idx)
141 place_trap(player_ptr, y1, x1);
147 * @brief 特殊な部屋向けに各種アイテムを配置する(メインルーチン) / Place some traps with a given displacement of given location
148 * @param player_ptr プレーヤーへの参照ポインタ
149 * @param y トラップを配置したいマスの中心Y座標
150 * @param x トラップを配置したいマスの中心X座標
151 * @param yd Y方向の配置分散マス数
152 * @param xd X方向の配置分散マス数
153 * @param num 配置したいトラップの数
156 * Only really called by some of the "vault" routines.
157 * @todo rooms-normal からしか呼ばれていない、要調整
159 void vault_traps(player_type *player_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd, int num)
161 for (int i = 0; i < num; i++)
162 vault_trap_aux(player_ptr, y, x, yd, xd);