OSDN Git Service

[Refactor] #1172 Changed '(TRUE)', 'TRUE;' and 'FALSE;' to '(true)', 'true;' and...
[hengbandforosx/hengbandosx.git] / src / room / rooms-special.cpp
1 #include "room/rooms-special.h"
2 #include "dungeon/dungeon-flag-types.h"
3 #include "dungeon/dungeon.h"
4 #include "floor/floor-generator.h"
5 #include "floor//geometry.h"
6 #include "game-option/cheat-types.h"
7 #include "grid/door.h"
8 #include "grid/feature.h"
9 #include "grid/grid.h"
10 #include "grid/object-placer.h"
11 #include "monster-floor/monster-generator.h"
12 #include "monster-floor/place-monster-types.h"
13 #include "monster-race/monster-race-hook.h"
14 #include "monster/monster-list.h"
15 #include "monster/monster-util.h"
16 #include "object-enchant/item-apply-magic.h"
17 #include "object/object-kind-hook.h"
18 #include "room/space-finder.h"
19 #include "system/floor-type-definition.h"
20 #include "system/player-type-definition.h"
21 #include "system/system-variables.h"
22 #include "wizard/wizard-messages.h"
23
24 /*!
25  * @brief タイプ15の部屋…ガラス部屋の生成 / Type 15 -- glass rooms
26  * @param player_ptr プレーヤーへの参照ポインタ
27  */
28 bool build_type15(player_type *player_ptr, dun_data_type *dd_ptr)
29 {
30     POSITION y, x, y2, x2, yval, xval;
31     POSITION y1, x1, xsize, ysize;
32     bool light;
33
34     grid_type *g_ptr;
35
36     /* Pick a room size */
37     xsize = rand_range(9, 13);
38     ysize = rand_range(9, 13);
39
40     /* Find and reserve some space in the dungeon.  Get center of room. */
41     floor_type *floor_ptr = player_ptr->current_floor_ptr;
42     if (!find_space(player_ptr, dd_ptr, &yval, &xval, ysize + 2, xsize + 2))
43         return false;
44
45     /* Choose lite or dark */
46     light = ((floor_ptr->dun_level <= randint1(25)) && d_info[floor_ptr->dungeon_idx].flags.has_not(DF::DARKNESS));
47
48     /* Get corner values */
49     y1 = yval - ysize / 2;
50     x1 = xval - xsize / 2;
51     y2 = yval + (ysize - 1) / 2;
52     x2 = xval + (xsize - 1) / 2;
53
54     /* Place a full floor under the room */
55     for (y = y1 - 1; y <= y2 + 1; y++) {
56         for (x = x1 - 1; x <= x2 + 1; x++) {
57             g_ptr = &floor_ptr->grid_array[y][x];
58             place_grid(player_ptr, g_ptr, GB_FLOOR);
59             g_ptr->feat = feat_glass_floor;
60             g_ptr->info |= (CAVE_ROOM);
61             if (light)
62                 g_ptr->info |= (CAVE_GLOW);
63         }
64     }
65
66     /* Walls around the room */
67     for (y = y1 - 1; y <= y2 + 1; y++) {
68         g_ptr = &floor_ptr->grid_array[y][x1 - 1];
69         place_grid(player_ptr, g_ptr, GB_OUTER);
70         g_ptr->feat = feat_glass_wall;
71         g_ptr = &floor_ptr->grid_array[y][x2 + 1];
72         place_grid(player_ptr, g_ptr, GB_OUTER);
73         g_ptr->feat = feat_glass_wall;
74     }
75
76     for (x = x1 - 1; x <= x2 + 1; x++) {
77         g_ptr = &floor_ptr->grid_array[y1 - 1][x];
78         place_grid(player_ptr, g_ptr, GB_OUTER);
79         g_ptr->feat = feat_glass_wall;
80         g_ptr = &floor_ptr->grid_array[y2 + 1][x];
81         place_grid(player_ptr, g_ptr, GB_OUTER);
82         g_ptr->feat = feat_glass_wall;
83     }
84
85     switch (randint1(3)) {
86     case 1: /* 4 lite breathers + potion */
87     {
88         DIRECTION dir1, dir2;
89         get_mon_num_prep(player_ptr, vault_aux_lite, NULL);
90
91         /* Place fixed lite berathers */
92         for (dir1 = 4; dir1 < 8; dir1++) {
93             MONRACE_IDX r_idx = get_mon_num(player_ptr, 0, floor_ptr->dun_level, 0);
94
95             y = yval + 2 * ddy_ddd[dir1];
96             x = xval + 2 * ddx_ddd[dir1];
97             if (r_idx)
98                 place_monster_aux(player_ptr, 0, y, x, r_idx, PM_ALLOW_SLEEP);
99
100             /* Walls around the breather */
101             for (dir2 = 0; dir2 < 8; dir2++) {
102                 g_ptr = &floor_ptr->grid_array[y + ddy_ddd[dir2]][x + ddx_ddd[dir2]];
103                 place_grid(player_ptr, g_ptr, GB_INNER);
104                 g_ptr->feat = feat_glass_wall;
105             }
106         }
107
108         /* Walls around the potion */
109         for (dir1 = 0; dir1 < 4; dir1++) {
110             y = yval + 2 * ddy_ddd[dir1];
111             x = xval + 2 * ddx_ddd[dir1];
112             g_ptr = &floor_ptr->grid_array[y][x];
113             place_grid(player_ptr, g_ptr, GB_INNER_PERM);
114             g_ptr->feat = feat_permanent_glass_wall;
115             floor_ptr->grid_array[yval + ddy_ddd[dir1]][xval + ddx_ddd[dir1]].info |= (CAVE_ICKY);
116         }
117
118         /* Glass door */
119         dir1 = randint0(4);
120         y = yval + 2 * ddy_ddd[dir1];
121         x = xval + 2 * ddx_ddd[dir1];
122         place_secret_door(player_ptr, y, x, DOOR_GLASS_DOOR);
123         g_ptr = &floor_ptr->grid_array[y][x];
124         if (is_closed_door(player_ptr, g_ptr->feat))
125             g_ptr->mimic = feat_glass_wall;
126
127         /* Place a potion */
128         get_obj_num_hook = kind_is_potion;
129         place_object(player_ptr, yval, xval, AM_NO_FIXED_ART);
130         floor_ptr->grid_array[yval][xval].info |= (CAVE_ICKY);
131     } break;
132
133     case 2: /* 1 lite breather + random object */
134     {
135         MONRACE_IDX r_idx;
136         DIRECTION dir1;
137
138         /* Pillars */
139         g_ptr = &floor_ptr->grid_array[y1 + 1][x1 + 1];
140         place_grid(player_ptr, g_ptr, GB_INNER);
141         g_ptr->feat = feat_glass_wall;
142
143         g_ptr = &floor_ptr->grid_array[y1 + 1][x2 - 1];
144         place_grid(player_ptr, g_ptr, GB_INNER);
145         g_ptr->feat = feat_glass_wall;
146
147         g_ptr = &floor_ptr->grid_array[y2 - 1][x1 + 1];
148         place_grid(player_ptr, g_ptr, GB_INNER);
149         g_ptr->feat = feat_glass_wall;
150
151         g_ptr = &floor_ptr->grid_array[y2 - 1][x2 - 1];
152         place_grid(player_ptr, g_ptr, GB_INNER);
153         g_ptr->feat = feat_glass_wall;
154         get_mon_num_prep(player_ptr, vault_aux_lite, NULL);
155
156         r_idx = get_mon_num(player_ptr, 0, floor_ptr->dun_level, 0);
157         if (r_idx)
158             place_monster_aux(player_ptr, 0, yval, xval, r_idx, 0L);
159
160         /* Walls around the breather */
161         for (dir1 = 0; dir1 < 8; dir1++) {
162             g_ptr = &floor_ptr->grid_array[yval + ddy_ddd[dir1]][xval + ddx_ddd[dir1]];
163             place_grid(player_ptr, g_ptr, GB_INNER);
164             g_ptr->feat = feat_glass_wall;
165         }
166
167         /* Curtains around the breather */
168         for (y = yval - 1; y <= yval + 1; y++) {
169             place_secret_door(player_ptr, y, xval - 2, DOOR_CURTAIN);
170             place_secret_door(player_ptr, y, xval + 2, DOOR_CURTAIN);
171         }
172
173         for (x = xval - 1; x <= xval + 1; x++) {
174             place_secret_door(player_ptr, yval - 2, x, DOOR_CURTAIN);
175             place_secret_door(player_ptr, yval + 2, x, DOOR_CURTAIN);
176         }
177
178         /* Place an object */
179         place_object(player_ptr, yval, xval, AM_NO_FIXED_ART);
180         floor_ptr->grid_array[yval][xval].info |= (CAVE_ICKY);
181     } break;
182
183     case 3: /* 4 shards breathers + 2 potions */
184     {
185         DIRECTION dir1;
186
187         /* Walls around the potion */
188         for (y = yval - 2; y <= yval + 2; y++) {
189             g_ptr = &floor_ptr->grid_array[y][xval - 3];
190             place_grid(player_ptr, g_ptr, GB_INNER);
191             g_ptr->feat = feat_glass_wall;
192             g_ptr = &floor_ptr->grid_array[y][xval + 3];
193             place_grid(player_ptr, g_ptr, GB_INNER);
194             g_ptr->feat = feat_glass_wall;
195         }
196
197         for (x = xval - 2; x <= xval + 2; x++) {
198             g_ptr = &floor_ptr->grid_array[yval - 3][x];
199             place_grid(player_ptr, g_ptr, GB_INNER);
200             g_ptr->feat = feat_glass_wall;
201             g_ptr = &floor_ptr->grid_array[yval + 3][x];
202             place_grid(player_ptr, g_ptr, GB_INNER);
203             g_ptr->feat = feat_glass_wall;
204         }
205
206         for (dir1 = 4; dir1 < 8; dir1++) {
207             g_ptr = &floor_ptr->grid_array[yval + 2 * ddy_ddd[dir1]][xval + 2 * ddx_ddd[dir1]];
208             place_grid(player_ptr, g_ptr, GB_INNER);
209             g_ptr->feat = feat_glass_wall;
210         }
211
212         get_mon_num_prep(player_ptr, vault_aux_shards, NULL);
213
214         /* Place shard berathers */
215         for (dir1 = 4; dir1 < 8; dir1++) {
216             MONRACE_IDX r_idx = get_mon_num(player_ptr, 0, floor_ptr->dun_level, 0);
217
218             y = yval + ddy_ddd[dir1];
219             x = xval + ddx_ddd[dir1];
220             if (r_idx)
221                 place_monster_aux(player_ptr, 0, y, x, r_idx, 0L);
222         }
223
224         /* Place two potions */
225         if (one_in_(2)) {
226             get_obj_num_hook = kind_is_potion;
227             place_object(player_ptr, yval, xval - 1, AM_NO_FIXED_ART);
228             get_obj_num_hook = kind_is_potion;
229             place_object(player_ptr, yval, xval + 1, AM_NO_FIXED_ART);
230         } else {
231             get_obj_num_hook = kind_is_potion;
232             place_object(player_ptr, yval - 1, xval, AM_NO_FIXED_ART);
233             get_obj_num_hook = kind_is_potion;
234             place_object(player_ptr, yval + 1, xval, AM_NO_FIXED_ART);
235         }
236
237         for (y = yval - 2; y <= yval + 2; y++)
238             for (x = xval - 2; x <= xval + 2; x++)
239                 floor_ptr->grid_array[y][x].info |= (CAVE_ICKY);
240     } break;
241     }
242
243     msg_print_wizard(player_ptr, CHEAT_DUNGEON, _("ガラスの部屋が生成されました。", "Glass room was generated."));
244     return true;
245 }