OSDN Git Service

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