OSDN Git Service

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