OSDN Git Service

d97a0567a5b004880a5b8f53b092bfd8999d57aa
[hengband/hengband.git] / src / rooms-normal.c
1 #include "angband.h"
2 #include "grid.h"
3 #include "trap.h"
4
5 #include "floor.h"
6 #include "dungeon.h"
7 #include "rooms.h"
8
9
10 /*!
11 * @brief タイプ1の部屋…通常可変長方形の部屋を生成する / Type 1 -- normal rectangular rooms
12 * @return なし
13 */
14 bool build_type1(floor_type *floor_ptr)
15 {
16         POSITION y, x, y2, x2, yval, xval;
17         POSITION y1, x1, xsize, ysize;
18
19         bool light;
20
21         grid_type *g_ptr;
22
23         bool curtain = (d_info[floor_ptr->dungeon_idx].flags1 & DF1_CURTAIN) &&
24                 one_in_((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) ? 48 : 512);
25
26         /* Pick a room size */
27         y1 = randint1(4);
28         x1 = randint1(11);
29         y2 = randint1(3);
30         x2 = randint1(11);
31
32         xsize = x1 + x2 + 1;
33         ysize = y1 + y2 + 1;
34
35         /* Find and reserve some space in the dungeon.  Get center of room. */
36         if (!find_space(floor_ptr, &yval, &xval, ysize + 2, xsize + 2))
37         {
38                 /* Limit to the minimum room size, and retry */
39                 y1 = 1;
40                 x1 = 1;
41                 y2 = 1;
42                 x2 = 1;
43
44                 xsize = x1 + x2 + 1;
45                 ysize = y1 + y2 + 1;
46
47                 /* Find and reserve some space in the dungeon.  Get center of room. */
48                 if (!find_space(floor_ptr, &yval, &xval, ysize + 2, xsize + 2)) return FALSE;
49         }
50
51         /* Choose lite or dark */
52         light = ((floor_ptr->dun_level <= randint1(25)) && !(d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS));
53
54
55         /* Get corner values */
56         y1 = yval - ysize / 2;
57         x1 = xval - xsize / 2;
58         y2 = yval + (ysize - 1) / 2;
59         x2 = xval + (xsize - 1) / 2;
60
61
62         /* Place a full floor under the room */
63         for (y = y1 - 1; y <= y2 + 1; y++)
64         {
65                 for (x = x1 - 1; x <= x2 + 1; x++)
66                 {
67                         g_ptr = &floor_ptr->grid_array[y][x];
68                         place_floor_grid(g_ptr);
69                         g_ptr->info |= (CAVE_ROOM);
70                         if (light) g_ptr->info |= (CAVE_GLOW);
71                 }
72         }
73
74         /* Walls around the room */
75         for (y = y1 - 1; y <= y2 + 1; y++)
76         {
77                 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
78                 place_outer_grid(g_ptr);
79                 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
80                 place_outer_grid(g_ptr);
81         }
82         for (x = x1 - 1; x <= x2 + 1; x++)
83         {
84                 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
85                 place_outer_grid(g_ptr);
86                 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
87                 place_outer_grid(g_ptr);
88         }
89
90
91         /* Hack -- Occasional curtained room */
92         if (curtain && (y2 - y1 > 2) && (x2 - x1 > 2))
93         {
94                 for (y = y1; y <= y2; y++)
95                 {
96                         g_ptr = &floor_ptr->grid_array[y][x1];
97                         g_ptr->feat = feat_door[DOOR_CURTAIN].closed;
98                         g_ptr->info &= ~(CAVE_MASK);
99                         g_ptr = &floor_ptr->grid_array[y][x2];
100                         g_ptr->feat = feat_door[DOOR_CURTAIN].closed;
101                         g_ptr->info &= ~(CAVE_MASK);
102                 }
103                 for (x = x1; x <= x2; x++)
104                 {
105                         g_ptr = &floor_ptr->grid_array[y1][x];
106                         g_ptr->feat = feat_door[DOOR_CURTAIN].closed;
107                         g_ptr->info &= ~(CAVE_MASK);
108                         g_ptr = &floor_ptr->grid_array[y2][x];
109                         g_ptr->feat = feat_door[DOOR_CURTAIN].closed;
110                         g_ptr->info &= ~(CAVE_MASK);
111                 }
112         }
113
114
115         /* Hack -- Occasional pillar room */
116         if (one_in_(20))
117         {
118                 for (y = y1; y <= y2; y += 2)
119                 {
120                         for (x = x1; x <= x2; x += 2)
121                         {
122                                 g_ptr = &floor_ptr->grid_array[y][x];
123                                 place_inner_grid(g_ptr);
124                         }
125                 }
126         }
127
128         /* Hack -- Occasional room with four pillars */
129         else if (one_in_(20))
130         {
131                 if ((y1 + 4 < y2) && (x1 + 4 < x2))
132                 {
133                         g_ptr = &floor_ptr->grid_array[y1 + 1][x1 + 1];
134                         place_inner_grid(g_ptr);
135
136                         g_ptr = &floor_ptr->grid_array[y1 + 1][x2 - 1];
137                         place_inner_grid(g_ptr);
138
139                         g_ptr = &floor_ptr->grid_array[y2 - 1][x1 + 1];
140                         place_inner_grid(g_ptr);
141
142                         g_ptr = &floor_ptr->grid_array[y2 - 1][x2 - 1];
143                         place_inner_grid(g_ptr);
144                 }
145         }
146
147         /* Hack -- Occasional ragged-edge room */
148         else if (one_in_(50))
149         {
150                 for (y = y1 + 2; y <= y2 - 2; y += 2)
151                 {
152                         g_ptr = &floor_ptr->grid_array[y][x1];
153                         place_inner_grid(g_ptr);
154                         g_ptr = &floor_ptr->grid_array[y][x2];
155                         place_inner_grid(g_ptr);
156                 }
157                 for (x = x1 + 2; x <= x2 - 2; x += 2)
158                 {
159                         g_ptr = &floor_ptr->grid_array[y1][x];
160                         place_inner_grid(g_ptr);
161                         g_ptr = &floor_ptr->grid_array[y2][x];
162                         place_inner_grid(g_ptr);
163                 }
164         }
165         /* Hack -- Occasional divided room */
166         else if (one_in_(50))
167         {
168                 bool curtain2 = (d_info[floor_ptr->dungeon_idx].flags1 & DF1_CURTAIN) &&
169                         one_in_((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) ? 2 : 128);
170
171                 if (randint1(100) < 50)
172                 {
173                         /* Horizontal wall */
174                         for (x = x1; x <= x2; x++)
175                         {
176                                 place_inner_bold(floor_ptr, yval, x);
177                                 if (curtain2) floor_ptr->grid_array[yval][x].feat = feat_door[DOOR_CURTAIN].closed;
178                         }
179
180                         /* Prevent edge of wall from being tunneled */
181                         place_solid_bold(floor_ptr, yval, x1 - 1);
182                         place_solid_bold(floor_ptr, yval, x2 + 1);
183                 }
184                 else
185                 {
186                         /* Vertical wall */
187                         for (y = y1; y <= y2; y++)
188                         {
189                                 place_inner_bold(floor_ptr, y, xval);
190                                 if (curtain2) floor_ptr->grid_array[y][xval].feat = feat_door[DOOR_CURTAIN].closed;
191                         }
192
193                         /* Prevent edge of wall from being tunneled */
194                         place_solid_bold(floor_ptr, y1 - 1, xval);
195                         place_solid_bold(floor_ptr, y2 + 1, xval);
196                 }
197
198                 place_random_door(floor_ptr, yval, xval, TRUE);
199                 if (curtain2) floor_ptr->grid_array[yval][xval].feat = feat_door[DOOR_CURTAIN].closed;
200         }
201
202         return TRUE;
203 }
204
205 /*!
206 * @brief タイプ2の部屋…二重長方形の部屋を生成する / Type 2 -- Overlapping rectangular rooms
207 * @return なし
208 */
209 bool build_type2(floor_type *floor_ptr)
210 {
211         POSITION        y, x, xval, yval;
212         POSITION        y1a, x1a, y2a, x2a;
213         POSITION        y1b, x1b, y2b, x2b;
214         bool            light;
215         grid_type   *g_ptr;
216
217         /* Find and reserve some space in the dungeon.  Get center of room. */
218         if (!find_space(floor_ptr, &yval, &xval, 11, 25)) return FALSE;
219
220         /* Choose lite or dark */
221         light = ((floor_ptr->dun_level <= randint1(25)) && !(d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS));
222
223         /* Determine extents of the first room */
224         y1a = yval - randint1(4);
225         y2a = yval + randint1(3);
226         x1a = xval - randint1(11);
227         x2a = xval + randint1(10);
228
229         /* Determine extents of the second room */
230         y1b = yval - randint1(3);
231         y2b = yval + randint1(4);
232         x1b = xval - randint1(10);
233         x2b = xval + randint1(11);
234
235
236         /* Place a full floor for room "a" */
237         for (y = y1a - 1; y <= y2a + 1; y++)
238         {
239                 for (x = x1a - 1; x <= x2a + 1; x++)
240                 {
241                         g_ptr = &floor_ptr->grid_array[y][x];
242                         place_floor_grid(g_ptr);
243                         g_ptr->info |= (CAVE_ROOM);
244                         if (light) g_ptr->info |= (CAVE_GLOW);
245                 }
246         }
247
248         /* Place a full floor for room "b" */
249         for (y = y1b - 1; y <= y2b + 1; y++)
250         {
251                 for (x = x1b - 1; x <= x2b + 1; x++)
252                 {
253                         g_ptr = &floor_ptr->grid_array[y][x];
254                         place_floor_grid(g_ptr);
255                         g_ptr->info |= (CAVE_ROOM);
256                         if (light) g_ptr->info |= (CAVE_GLOW);
257                 }
258         }
259
260
261         /* Place the walls around room "a" */
262         for (y = y1a - 1; y <= y2a + 1; y++)
263         {
264                 g_ptr = &floor_ptr->grid_array[y][x1a - 1];
265                 place_outer_grid(g_ptr);
266                 g_ptr = &floor_ptr->grid_array[y][x2a + 1];
267                 place_outer_grid(g_ptr);
268         }
269         for (x = x1a - 1; x <= x2a + 1; x++)
270         {
271                 g_ptr = &floor_ptr->grid_array[y1a - 1][x];
272                 place_outer_grid(g_ptr);
273                 g_ptr = &floor_ptr->grid_array[y2a + 1][x];
274                 place_outer_grid(g_ptr);
275         }
276
277         /* Place the walls around room "b" */
278         for (y = y1b - 1; y <= y2b + 1; y++)
279         {
280                 g_ptr = &floor_ptr->grid_array[y][x1b - 1];
281                 place_outer_grid(g_ptr);
282                 g_ptr = &floor_ptr->grid_array[y][x2b + 1];
283                 place_outer_grid(g_ptr);
284         }
285         for (x = x1b - 1; x <= x2b + 1; x++)
286         {
287                 g_ptr = &floor_ptr->grid_array[y1b - 1][x];
288                 place_outer_grid(g_ptr);
289                 g_ptr = &floor_ptr->grid_array[y2b + 1][x];
290                 place_outer_grid(g_ptr);
291         }
292
293
294
295         /* Replace the floor for room "a" */
296         for (y = y1a; y <= y2a; y++)
297         {
298                 for (x = x1a; x <= x2a; x++)
299                 {
300                         g_ptr = &floor_ptr->grid_array[y][x];
301                         place_floor_grid(g_ptr);
302                 }
303         }
304
305         /* Replace the floor for room "b" */
306         for (y = y1b; y <= y2b; y++)
307         {
308                 for (x = x1b; x <= x2b; x++)
309                 {
310                         g_ptr = &floor_ptr->grid_array[y][x];
311                         place_floor_grid(g_ptr);
312                 }
313         }
314
315         return TRUE;
316 }
317
318 /*!
319 * @brief タイプ3の部屋…十字型の部屋を生成する / Type 3 -- Cross shaped rooms
320 * @param player_ptr プレーヤーへの参照ポインタ
321 * @return なし
322 * @details
323 * Builds a room at a row, column coordinate\n
324 *\n
325 * Room "a" runs north/south, and Room "b" runs east/east\n
326 * So the "central pillar" runs from x1a, y1b to x2a, y2b.\n
327 *\n
328 * Note that currently, the "center" is always 3x3, but I think that\n
329 * the code below will work (with "bounds checking") for 5x5, or even\n
330 * for unsymetric values like 4x3 or 5x3 or 3x4 or 3x5, or even larger.\n
331 */
332 bool build_type3(player_type *player_ptr)
333 {
334         POSITION y, x, dy, dx, wy, wx;
335         POSITION y1a, x1a, y2a, x2a;
336         POSITION y1b, x1b, y2b, x2b;
337         POSITION yval, xval;
338         bool light;
339         grid_type *g_ptr;
340
341         /* Find and reserve some space in the dungeon.  Get center of room. */
342         floor_type *floor_ptr = player_ptr->current_floor_ptr;
343         if (!find_space(floor_ptr, &yval, &xval, 11, 25)) return FALSE;
344
345
346         /* Choose lite or dark */
347         light = ((floor_ptr->dun_level <= randint1(25)) && !(d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS));
348
349         /* For now, always 3x3 */
350         wx = wy = 1;
351
352         /* Pick max vertical size (at most 4) */
353         dy = rand_range(3, 4);
354
355         /* Pick max horizontal size (at most 15) */
356         dx = rand_range(3, 11);
357
358
359         /* Determine extents of the north/south room */
360         y1a = yval - dy;
361         y2a = yval + dy;
362         x1a = xval - wx;
363         x2a = xval + wx;
364
365         /* Determine extents of the east/west room */
366         y1b = yval - wy;
367         y2b = yval + wy;
368         x1b = xval - dx;
369         x2b = xval + dx;
370
371
372         /* Place a full floor for room "a" */
373         for (y = y1a - 1; y <= y2a + 1; y++)
374         {
375                 for (x = x1a - 1; x <= x2a + 1; x++)
376                 {
377                         g_ptr = &floor_ptr->grid_array[y][x];
378                         place_floor_grid(g_ptr);
379                         g_ptr->info |= (CAVE_ROOM);
380                         if (light) g_ptr->info |= (CAVE_GLOW);
381                 }
382         }
383
384         /* Place a full floor for room "b" */
385         for (y = y1b - 1; y <= y2b + 1; y++)
386         {
387                 for (x = x1b - 1; x <= x2b + 1; x++)
388                 {
389                         g_ptr = &floor_ptr->grid_array[y][x];
390                         place_floor_grid(g_ptr);
391                         g_ptr->info |= (CAVE_ROOM);
392                         if (light) g_ptr->info |= (CAVE_GLOW);
393                 }
394         }
395
396
397         /* Place the walls around room "a" */
398         for (y = y1a - 1; y <= y2a + 1; y++)
399         {
400                 g_ptr = &floor_ptr->grid_array[y][x1a - 1];
401                 place_outer_grid(g_ptr);
402                 g_ptr = &floor_ptr->grid_array[y][x2a + 1];
403                 place_outer_grid(g_ptr);
404         }
405         for (x = x1a - 1; x <= x2a + 1; x++)
406         {
407                 g_ptr = &floor_ptr->grid_array[y1a - 1][x];
408                 place_outer_grid(g_ptr);
409                 g_ptr = &floor_ptr->grid_array[y2a + 1][x];
410                 place_outer_grid(g_ptr);
411         }
412
413         /* Place the walls around room "b" */
414         for (y = y1b - 1; y <= y2b + 1; y++)
415         {
416                 g_ptr = &floor_ptr->grid_array[y][x1b - 1];
417                 place_outer_grid(g_ptr);
418                 g_ptr = &floor_ptr->grid_array[y][x2b + 1];
419                 place_outer_grid(g_ptr);
420         }
421         for (x = x1b - 1; x <= x2b + 1; x++)
422         {
423                 g_ptr = &floor_ptr->grid_array[y1b - 1][x];
424                 place_outer_grid(g_ptr);
425                 g_ptr = &floor_ptr->grid_array[y2b + 1][x];
426                 place_outer_grid(g_ptr);
427         }
428
429
430         /* Replace the floor for room "a" */
431         for (y = y1a; y <= y2a; y++)
432         {
433                 for (x = x1a; x <= x2a; x++)
434                 {
435                         g_ptr = &floor_ptr->grid_array[y][x];
436                         place_floor_grid(g_ptr);
437                 }
438         }
439
440         /* Replace the floor for room "b" */
441         for (y = y1b; y <= y2b; y++)
442         {
443                 for (x = x1b; x <= x2b; x++)
444                 {
445                         g_ptr = &floor_ptr->grid_array[y][x];
446                         place_floor_grid(g_ptr);
447                 }
448         }
449
450
451
452         /* Special features (3/4) */
453         switch (randint0(4))
454         {
455                 /* Large solid middle pillar */
456         case 1:
457         {
458                 for (y = y1b; y <= y2b; y++)
459                 {
460                         for (x = x1a; x <= x2a; x++)
461                         {
462                                 g_ptr = &floor_ptr->grid_array[y][x];
463                                 place_inner_grid(g_ptr);
464                         }
465                 }
466                 break;
467         }
468
469         /* Inner treasure vault */
470         case 2:
471         {
472                 /* Build the vault */
473                 for (y = y1b; y <= y2b; y++)
474                 {
475                         g_ptr = &floor_ptr->grid_array[y][x1a];
476                         place_inner_grid(g_ptr);
477                         g_ptr = &floor_ptr->grid_array[y][x2a];
478                         place_inner_grid(g_ptr);
479                 }
480                 for (x = x1a; x <= x2a; x++)
481                 {
482                         g_ptr = &floor_ptr->grid_array[y1b][x];
483                         place_inner_grid(g_ptr);
484                         g_ptr = &floor_ptr->grid_array[y2b][x];
485                         place_inner_grid(g_ptr);
486                 }
487
488                 /* Place a secret door on the inner room */
489                 switch (randint0(4))
490                 {
491                 case 0: place_secret_door(floor_ptr, y1b, xval, DOOR_DEFAULT); break;
492                 case 1: place_secret_door(floor_ptr, y2b, xval, DOOR_DEFAULT); break;
493                 case 2: place_secret_door(floor_ptr, yval, x1a, DOOR_DEFAULT); break;
494                 case 3: place_secret_door(floor_ptr, yval, x2a, DOOR_DEFAULT); break;
495                 }
496
497                 /* Place a treasure in the vault */
498                 place_object(player_ptr, yval, xval, 0L);
499
500                 /* Let's guard the treasure well */
501                 vault_monsters(floor_ptr, yval, xval, randint0(2) + 3);
502
503                 /* Traps naturally */
504                 vault_traps(player_ptr, yval, xval, 4, 4, randint0(3) + 2);
505
506                 break;
507         }
508
509         /* Something else */
510         case 3:
511         {
512                 /* Occasionally pinch the center shut */
513                 if (one_in_(3))
514                 {
515                         /* Pinch the east/west sides */
516                         for (y = y1b; y <= y2b; y++)
517                         {
518                                 if (y == yval) continue;
519                                 g_ptr = &floor_ptr->grid_array[y][x1a - 1];
520                                 place_inner_grid(g_ptr);
521                                 g_ptr = &floor_ptr->grid_array[y][x2a + 1];
522                                 place_inner_grid(g_ptr);
523                         }
524
525                         /* Pinch the north/south sides */
526                         for (x = x1a; x <= x2a; x++)
527                         {
528                                 if (x == xval) continue;
529                                 g_ptr = &floor_ptr->grid_array[y1b - 1][x];
530                                 place_inner_grid(g_ptr);
531                                 g_ptr = &floor_ptr->grid_array[y2b + 1][x];
532                                 place_inner_grid(g_ptr);
533                         }
534
535                         /* Sometimes shut using secret doors */
536                         if (one_in_(3))
537                         {
538                                 int door_type = ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_CURTAIN) &&
539                                         one_in_((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
540                                         ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
541
542                                 place_secret_door(floor_ptr, yval, x1a - 1, door_type);
543                                 place_secret_door(floor_ptr, yval, x2a + 1, door_type);
544                                 place_secret_door(floor_ptr, y1b - 1, xval, door_type);
545                                 place_secret_door(floor_ptr, y2b + 1, xval, door_type);
546                         }
547                 }
548
549                 /* Occasionally put a "plus" in the center */
550                 else if (one_in_(3))
551                 {
552                         g_ptr = &floor_ptr->grid_array[yval][xval];
553                         place_inner_grid(g_ptr);
554                         g_ptr = &floor_ptr->grid_array[y1b][xval];
555                         place_inner_grid(g_ptr);
556                         g_ptr = &floor_ptr->grid_array[y2b][xval];
557                         place_inner_grid(g_ptr);
558                         g_ptr = &floor_ptr->grid_array[yval][x1a];
559                         place_inner_grid(g_ptr);
560                         g_ptr = &floor_ptr->grid_array[yval][x2a];
561                         place_inner_grid(g_ptr);
562                 }
563
564                 /* Occasionally put a pillar in the center */
565                 else if (one_in_(3))
566                 {
567                         g_ptr = &floor_ptr->grid_array[yval][xval];
568                         place_inner_grid(g_ptr);
569                 }
570
571                 break;
572         }
573         }
574
575         return TRUE;
576 }
577
578 /*!
579 * @brief タイプ4の部屋…固定サイズの二重構造部屋を生成する / Type 4 -- Large room with inner features
580 * @param player_ptr プレーヤーへの参照ポインタ
581 * @return なし
582 * @details
583 * Possible sub-types:\n
584 *       1 - Just an inner room with one door\n
585 *       2 - An inner room within an inner room\n
586 *       3 - An inner room with pillar(s)\n
587 *       4 - Inner room has a maze\n
588 *       5 - A set of four inner rooms\n
589 */
590 bool build_type4(player_type *player_ptr)
591 {
592         POSITION y, x, y1, x1;
593         POSITION y2, x2, tmp, yval, xval;
594         bool light;
595         grid_type *g_ptr;
596
597         /* Find and reserve some space in the dungeon.  Get center of room. */
598         floor_type *floor_ptr = player_ptr->current_floor_ptr;
599         if (!find_space(floor_ptr, &yval, &xval, 11, 25)) return FALSE;
600
601         /* Choose lite or dark */
602         light = ((floor_ptr->dun_level <= randint1(25)) && !(d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS));
603
604         /* Large room */
605         y1 = yval - 4;
606         y2 = yval + 4;
607         x1 = xval - 11;
608         x2 = xval + 11;
609
610         /* Place a full floor under the room */
611         for (y = y1 - 1; y <= y2 + 1; y++)
612         {
613                 for (x = x1 - 1; x <= x2 + 1; x++)
614                 {
615                         g_ptr = &floor_ptr->grid_array[y][x];
616                         place_floor_grid(g_ptr);
617                         g_ptr->info |= (CAVE_ROOM);
618                         if (light) g_ptr->info |= (CAVE_GLOW);
619                 }
620         }
621
622         /* Outer Walls */
623         for (y = y1 - 1; y <= y2 + 1; y++)
624         {
625                 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
626                 place_outer_grid(g_ptr);
627                 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
628                 place_outer_grid(g_ptr);
629         }
630         for (x = x1 - 1; x <= x2 + 1; x++)
631         {
632                 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
633                 place_outer_grid(g_ptr);
634                 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
635                 place_outer_grid(g_ptr);
636         }
637
638
639         /* The inner room */
640         y1 = y1 + 2;
641         y2 = y2 - 2;
642         x1 = x1 + 2;
643         x2 = x2 - 2;
644
645         /* The inner walls */
646         for (y = y1 - 1; y <= y2 + 1; y++)
647         {
648                 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
649                 place_inner_grid(g_ptr);
650                 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
651                 place_inner_grid(g_ptr);
652         }
653         for (x = x1 - 1; x <= x2 + 1; x++)
654         {
655                 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
656                 place_inner_grid(g_ptr);
657                 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
658                 place_inner_grid(g_ptr);
659         }
660
661
662         /* Inner room variations */
663         switch (randint1(5))
664         {
665                         /* Just an inner room with a monster */
666                 case 1:
667                 {
668                         /* Place a secret door */
669                         switch (randint1(4))
670                         {
671                         case 1: place_secret_door(floor_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
672                         case 2: place_secret_door(floor_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
673                         case 3: place_secret_door(floor_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
674                         case 4: place_secret_door(floor_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
675                         }
676
677                         /* Place a monster in the room */
678                         vault_monsters(floor_ptr, yval, xval, 1);
679
680                         break;
681                 }
682
683                 /* Treasure Vault (with a door) */
684                 case 2:
685                 {
686                         /* Place a secret door */
687                         switch (randint1(4))
688                         {
689                         case 1: place_secret_door(floor_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
690                         case 2: place_secret_door(floor_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
691                         case 3: place_secret_door(floor_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
692                         case 4: place_secret_door(floor_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
693                         }
694
695                         /* Place another inner room */
696                         for (y = yval - 1; y <= yval + 1; y++)
697                         {
698                                 for (x = xval - 1; x <= xval + 1; x++)
699                                 {
700                                         if ((x == xval) && (y == yval)) continue;
701                                         g_ptr = &floor_ptr->grid_array[y][x];
702                                         place_inner_grid(g_ptr);
703                                 }
704                         }
705
706                         /* Place a locked door on the inner room */
707                         switch (randint1(4))
708                         {
709                         case 1: place_locked_door(floor_ptr, yval - 1, xval); break;
710                         case 2: place_locked_door(floor_ptr, yval + 1, xval); break;
711                         case 3: place_locked_door(floor_ptr, yval, xval - 1); break;
712                         case 4: place_locked_door(floor_ptr, yval, xval + 1); break;
713                         }
714
715                         /* Monsters to guard the "treasure" */
716                         vault_monsters(floor_ptr, yval, xval, randint1(3) + 2);
717
718                         /* Object (80%) */
719                         if (randint0(100) < 80)
720                         {
721                                 place_object(player_ptr, yval, xval, 0L);
722                         }
723
724                         /* Stairs (20%) */
725                         else
726                         {
727                                 place_random_stairs(player_ptr, yval, xval);
728                         }
729
730                         /* Traps to protect the treasure */
731                         vault_traps(player_ptr, yval, xval, 4, 10, 2 + randint1(3));
732
733                         break;
734                 }
735
736                 /* Inner pillar(s). */
737                 case 3:
738                 {
739                         /* Place a secret door */
740                         switch (randint1(4))
741                         {
742                         case 1: place_secret_door(floor_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
743                         case 2: place_secret_door(floor_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
744                         case 3: place_secret_door(floor_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
745                         case 4: place_secret_door(floor_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
746                         }
747
748                         /* Large Inner Pillar */
749                         for (y = yval - 1; y <= yval + 1; y++)
750                         {
751                                 for (x = xval - 1; x <= xval + 1; x++)
752                                 {
753                                         g_ptr = &floor_ptr->grid_array[y][x];
754                                         place_inner_grid(g_ptr);
755                                 }
756                         }
757
758                         /* Occasionally, two more Large Inner Pillars */
759                         if (one_in_(2))
760                         {
761                                 tmp = randint1(2);
762                                 for (y = yval - 1; y <= yval + 1; y++)
763                                 {
764                                         for (x = xval - 5 - tmp; x <= xval - 3 - tmp; x++)
765                                         {
766                                                 g_ptr = &floor_ptr->grid_array[y][x];
767                                                 place_inner_grid(g_ptr);
768                                         }
769                                         for (x = xval + 3 + tmp; x <= xval + 5 + tmp; x++)
770                                         {
771                                                 g_ptr = &floor_ptr->grid_array[y][x];
772                                                 place_inner_grid(g_ptr);
773                                         }
774                                 }
775                         }
776
777                         /* Occasionally, some Inner rooms */
778                         if (one_in_(3))
779                         {
780                                 int door_type = ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_CURTAIN) &&
781                                         one_in_((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
782                                         ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
783
784                                 /* Long horizontal walls */
785                                 for (x = xval - 5; x <= xval + 5; x++)
786                                 {
787                                         g_ptr = &floor_ptr->grid_array[yval - 1][x];
788                                         place_inner_grid(g_ptr);
789                                         g_ptr = &floor_ptr->grid_array[yval + 1][x];
790                                         place_inner_grid(g_ptr);
791                                 }
792
793                                 /* Close off the left/right edges */
794                                 g_ptr = &floor_ptr->grid_array[yval][xval - 5];
795                                 place_inner_grid(g_ptr);
796                                 g_ptr = &floor_ptr->grid_array[yval][xval + 5];
797                                 place_inner_grid(g_ptr);
798
799                                 /* Secret doors (random top/bottom) */
800                                 place_secret_door(floor_ptr, yval - 3 + (randint1(2) * 2), xval - 3, door_type);
801                                 place_secret_door(floor_ptr, yval - 3 + (randint1(2) * 2), xval + 3, door_type);
802
803                                 /* Monsters */
804                                 vault_monsters(floor_ptr, yval, xval - 2, randint1(2));
805                                 vault_monsters(floor_ptr, yval, xval + 2, randint1(2));
806
807                                 /* Objects */
808                                 if (one_in_(3)) place_object(player_ptr, yval, xval - 2, 0L);
809                                 if (one_in_(3)) place_object(player_ptr, yval, xval + 2, 0L);
810                         }
811
812                         break;
813                 }
814
815                 /* Maze inside. */
816                 case 4:
817                 {
818                         /* Place a secret door */
819                         switch (randint1(4))
820                         {
821                         case 1: place_secret_door(floor_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
822                         case 2: place_secret_door(floor_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
823                         case 3: place_secret_door(floor_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
824                         case 4: place_secret_door(floor_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
825                         }
826
827                         /* Maze (really a checkerboard) */
828                         for (y = y1; y <= y2; y++)
829                         {
830                                 for (x = x1; x <= x2; x++)
831                                 {
832                                         if (0x1 & (x + y))
833                                         {
834                                                 g_ptr = &floor_ptr->grid_array[y][x];
835                                                 place_inner_grid(g_ptr);
836                                         }
837                                 }
838                         }
839
840                         /* Monsters just love mazes. */
841                         vault_monsters(floor_ptr, yval, xval - 5, randint1(3));
842                         vault_monsters(floor_ptr, yval, xval + 5, randint1(3));
843
844                         /* Traps make them entertaining. */
845                         vault_traps(player_ptr, yval, xval - 3, 2, 8, randint1(3));
846                         vault_traps(player_ptr, yval, xval + 3, 2, 8, randint1(3));
847
848                         /* Mazes should have some treasure too. */
849                         vault_objects(player_ptr, yval, xval, 3);
850
851                         break;
852                 }
853
854                 /* Four small rooms. */
855                 case 5:
856                 {
857                         int door_type = ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_CURTAIN) &&
858                                 one_in_((d_info[floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
859                                 ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
860
861                         /* Inner "cross" */
862                         for (y = y1; y <= y2; y++)
863                         {
864                                 g_ptr = &floor_ptr->grid_array[y][xval];
865                                 place_inner_grid(g_ptr);
866                         }
867                         for (x = x1; x <= x2; x++)
868                         {
869                                 g_ptr = &floor_ptr->grid_array[yval][x];
870                                 place_inner_grid(g_ptr);
871                         }
872
873                         /* Doors into the rooms */
874                         if (randint0(100) < 50)
875                         {
876                                 int i = randint1(10);
877                                 place_secret_door(floor_ptr, y1 - 1, xval - i, door_type);
878                                 place_secret_door(floor_ptr, y1 - 1, xval + i, door_type);
879                                 place_secret_door(floor_ptr, y2 + 1, xval - i, door_type);
880                                 place_secret_door(floor_ptr, y2 + 1, xval + i, door_type);
881                         }
882                         else
883                         {
884                                 int i = randint1(3);
885                                 place_secret_door(floor_ptr, yval + i, x1 - 1, door_type);
886                                 place_secret_door(floor_ptr, yval - i, x1 - 1, door_type);
887                                 place_secret_door(floor_ptr, yval + i, x2 + 1, door_type);
888                                 place_secret_door(floor_ptr, yval - i, x2 + 1, door_type);
889                         }
890
891                         /* Treasure, centered at the center of the cross */
892                         vault_objects(player_ptr, yval, xval, 2 + randint1(2));
893
894                         /* Gotta have some monsters. */
895                         vault_monsters(floor_ptr, yval + 1, xval - 4, randint1(4));
896                         vault_monsters(floor_ptr, yval + 1, xval + 4, randint1(4));
897                         vault_monsters(floor_ptr, yval - 1, xval - 4, randint1(4));
898                         vault_monsters(floor_ptr, yval - 1, xval + 4, randint1(4));
899
900                         break;
901                 }
902         }
903
904         return TRUE;
905 }
906
907
908 /*!
909 * @brief タイプ11の部屋…円形部屋の生成 / Type 11 -- Build an vertical oval room.
910 * @return なし
911 * @details
912 * For every grid in the possible square, check the distance.\n
913 * If it's less than the radius, make it a room square.\n
914 *\n
915 * When done fill from the inside to find the walls,\n
916 */
917 bool build_type11(floor_type *floor_ptr)
918 {
919         POSITION rad, x, y, x0, y0;
920         int light = FALSE;
921
922         /* Occasional light */
923         if ((randint1(floor_ptr->dun_level) <= 15) && !(d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) light = TRUE;
924
925         rad = randint0(9);
926
927         /* Find and reserve some space in the dungeon.  Get center of room. */
928         if (!find_space(floor_ptr, &y0, &x0, rad * 2 + 1, rad * 2 + 1)) return FALSE;
929
930         /* Make circular floor */
931         for (x = x0 - rad; x <= x0 + rad; x++)
932         {
933                 for (y = y0 - rad; y <= y0 + rad; y++)
934                 {
935                         if (distance(y0, x0, y, x) <= rad - 1)
936                         {
937                                 /* inside- so is floor */
938                                 place_floor_bold(floor_ptr, y, x);
939                         }
940                         else if (distance(y0, x0, y, x) <= rad + 1)
941                         {
942                                 /* make granite outside so arena works */
943                                 place_extra_bold(floor_ptr, y, x);
944                         }
945                 }
946         }
947
948         /* Find visible outer walls and set to be FEAT_OUTER */
949         add_outer_wall(floor_ptr, x0, y0, light, x0 - rad, y0 - rad, x0 + rad, y0 + rad);
950
951         return TRUE;
952 }
953
954
955 /*!
956 * @brief タイプ12の部屋…ドーム型部屋の生成 / Type 12 -- Build crypt room.
957 * @param player_ptr プレーヤーへの参照ポインタ
958 * @return なし
959 * @details
960 * For every grid in the possible square, check the (fake) distance.\n
961 * If it's less than the radius, make it a room square.\n
962 *\n
963 * When done fill from the inside to find the walls,\n
964 */
965 bool build_type12(player_type *player_ptr)
966 {
967         POSITION rad, x, y, x0, y0;
968         int light = FALSE;
969         bool emptyflag = TRUE;
970
971         /* Make a random metric */
972         POSITION h1, h2, h3, h4;
973         h1 = randint1(32) - 16;
974         h2 = randint1(16);
975         h3 = randint1(32);
976         h4 = randint1(32) - 16;
977
978         /* Occasional light */
979         floor_type *floor_ptr = player_ptr->current_floor_ptr;
980         if ((randint1(floor_ptr->dun_level) <= 5) && !(d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) light = TRUE;
981
982         rad = randint1(9);
983
984         /* Find and reserve some space in the dungeon.  Get center of room. */
985         if (!find_space(floor_ptr, &y0, &x0, rad * 2 + 3, rad * 2 + 3)) return FALSE;
986
987         /* Make floor */
988         for (x = x0 - rad; x <= x0 + rad; x++)
989         {
990                 for (y = y0 - rad; y <= y0 + rad; y++)
991                 {
992                         /* clear room flag */
993                         floor_ptr->grid_array[y][x].info &= ~(CAVE_ROOM);
994
995                         if (dist2(y0, x0, y, x, h1, h2, h3, h4) <= rad - 1)
996                         {
997                                 /* inside - so is floor */
998                                 place_floor_bold(floor_ptr, y, x);
999                         }
1000                         else if (distance(y0, x0, y, x) < 3)
1001                         {
1002                                 place_floor_bold(floor_ptr, y, x);
1003                         }
1004                         else
1005                         {
1006                                 /* make granite outside so arena works */
1007                                 place_extra_bold(floor_ptr, y, x);
1008                         }
1009
1010                         /* proper boundary for arena */
1011                         if (((y + rad) == y0) || ((y - rad) == y0) ||
1012                                 ((x + rad) == x0) || ((x - rad) == x0))
1013                         {
1014                                 place_extra_bold(floor_ptr, y, x);
1015                         }
1016                 }
1017         }
1018
1019         /* Find visible outer walls and set to be FEAT_OUTER */
1020         add_outer_wall(floor_ptr, x0, y0, light, x0 - rad - 1, y0 - rad - 1, x0 + rad + 1, y0 + rad + 1);
1021
1022         /* Check to see if there is room for an inner vault */
1023         for (x = x0 - 2; x <= x0 + 2; x++)
1024         {
1025                 for (y = y0 - 2; y <= y0 + 2; y++)
1026                 {
1027                         if (!is_floor_bold(floor_ptr, y, x))
1028                         {
1029                                 /* Wall in the way */
1030                                 emptyflag = FALSE;
1031                         }
1032                 }
1033         }
1034
1035         if (emptyflag && one_in_(2))
1036         {
1037                 /* Build the vault */
1038                 build_small_room(floor_ptr, x0, y0);
1039
1040                 /* Place a treasure in the vault */
1041                 place_object(player_ptr, y0, x0, 0L);
1042
1043                 /* Let's guard the treasure well */
1044                 vault_monsters(floor_ptr, y0, x0, randint0(2) + 3);
1045
1046                 /* Traps naturally */
1047                 vault_traps(player_ptr, y0, x0, 4, 4, randint0(3) + 2);
1048         }
1049
1050         return TRUE;
1051 }