OSDN Git Service

v3.0.0 Alpha5 OSDN最終版
[hengband/hengband.git] / src / rooms-trap.c
1 #include "angband.h"
2 #include "grid.h"
3 #include "generate.h"
4 #include "rooms.h"
5
6
7 /*!
8 * @brief タイプ14の部屋…特殊トラップ部屋の生成 / Type 14 -- trapped rooms
9 * @return なし
10 * @details
11 * A special trap is placed at center of the room
12 */
13 bool build_type14(void)
14 {
15         POSITION y, x, y2, x2, yval, xval;
16         POSITION y1, x1, xsize, ysize;
17
18         bool light;
19
20         cave_type *c_ptr;
21         s16b trap;
22
23         /* Pick a room size */
24         y1 = randint1(4);
25         x1 = randint1(11);
26         y2 = randint1(3);
27         x2 = randint1(11);
28
29         xsize = x1 + x2 + 1;
30         ysize = y1 + y2 + 1;
31
32         /* Find and reserve some space in the dungeon.  Get center of room. */
33         if (!find_space(&yval, &xval, ysize + 2, xsize + 2)) return FALSE;
34
35         /* Choose lite or dark */
36         light = ((dun_level <= randint1(25)) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS));
37
38
39         /* Get corner values */
40         y1 = yval - ysize / 2;
41         x1 = xval - xsize / 2;
42         y2 = yval + (ysize - 1) / 2;
43         x2 = xval + (xsize - 1) / 2;
44
45
46         /* Place a full floor under the room */
47         for (y = y1 - 1; y <= y2 + 1; y++)
48         {
49                 for (x = x1 - 1; x <= x2 + 1; x++)
50                 {
51                         c_ptr = &cave[y][x];
52                         place_floor_grid(c_ptr);
53                         c_ptr->info |= (CAVE_ROOM);
54                         if (light) c_ptr->info |= (CAVE_GLOW);
55                 }
56         }
57
58         /* Walls around the room */
59         for (y = y1 - 1; y <= y2 + 1; y++)
60         {
61                 c_ptr = &cave[y][x1 - 1];
62                 place_outer_grid(c_ptr);
63                 c_ptr = &cave[y][x2 + 1];
64                 place_outer_grid(c_ptr);
65         }
66         for (x = x1 - 1; x <= x2 + 1; x++)
67         {
68                 c_ptr = &cave[y1 - 1][x];
69                 place_outer_grid(c_ptr);
70                 c_ptr = &cave[y2 + 1][x];
71                 place_outer_grid(c_ptr);
72         }
73
74         if (dun_level < 30 + randint1(30))
75                 trap = feat_trap_piranha;
76         else
77                 trap = feat_trap_armageddon;
78
79         /* Place a special trap */
80         c_ptr = &cave[rand_spread(yval, ysize / 4)][rand_spread(xval, xsize / 4)];
81         c_ptr->mimic = c_ptr->feat;
82         c_ptr->feat = trap;
83
84         msg_format_wizard(CHEAT_DUNGEON, _("%sの部屋が生成されました。", "Room of %s was generated."), f_name + f_info[trap].name);
85
86         return TRUE;
87 }
88