OSDN Git Service

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