OSDN Git Service

[Refactor] #38862 Moved object*.c/h to object/
[hengband/hengband.git] / src / rooms-trap.c
1 #include "angband.h"
2 #include "util.h"
3
4 #include "grid.h"
5 #include "floor/floor-generate.h"
6 #include "rooms.h"
7 #include "floor/floor.h"
8 #include "feature.h"
9 #include "dungeon/dungeon.h"
10
11 /*!
12 * @brief タイプ14の部屋…特殊トラップ部屋の生成 / Type 14 -- trapped rooms
13 * @param player_ptr プレーヤーへの参照ポインタ
14 * @return なし
15 * @details
16 * A special trap is placed at center of the room
17 */
18 bool build_type14(player_type *player_ptr)
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(player_ptr, &yval, &xval, ysize + 2, xsize + 2)) return FALSE;
39
40         /* Choose lite or dark */
41         floor_type *floor_ptr = player_ptr->current_floor_ptr;
42         light = ((floor_ptr->dun_level <= randint1(25)) && !(d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS));
43
44
45         /* Get corner values */
46         y1 = yval - ysize / 2;
47         x1 = xval - xsize / 2;
48         y2 = yval + (ysize - 1) / 2;
49         x2 = xval + (xsize - 1) / 2;
50
51
52         /* Place a full floor under the room */
53         for (y = y1 - 1; y <= y2 + 1; y++)
54         {
55                 for (x = x1 - 1; x <= x2 + 1; x++)
56                 {
57                         g_ptr = &floor_ptr->grid_array[y][x];
58                         place_grid(player_ptr, g_ptr, GB_FLOOR);
59                         g_ptr->info |= (CAVE_ROOM);
60                         if (light) g_ptr->info |= (CAVE_GLOW);
61                 }
62         }
63
64         /* Walls around the room */
65         for (y = y1 - 1; y <= y2 + 1; y++)
66         {
67                 g_ptr = &floor_ptr->grid_array[y][x1 - 1];
68                 place_grid(player_ptr, g_ptr, GB_OUTER);
69                 g_ptr = &floor_ptr->grid_array[y][x2 + 1];
70                 place_grid(player_ptr, g_ptr, GB_OUTER);
71         }
72         for (x = x1 - 1; x <= x2 + 1; x++)
73         {
74                 g_ptr = &floor_ptr->grid_array[y1 - 1][x];
75                 place_grid(player_ptr, g_ptr, GB_OUTER);
76                 g_ptr = &floor_ptr->grid_array[y2 + 1][x];
77                 place_grid(player_ptr, g_ptr, GB_OUTER);
78         }
79
80         if (floor_ptr->dun_level < 30 + randint1(30))
81                 trap = feat_trap_piranha;
82         else
83                 trap = feat_trap_armageddon;
84
85         /* Place a special trap */
86         g_ptr = &floor_ptr->grid_array[rand_spread(yval, ysize / 4)][rand_spread(xval, xsize / 4)];
87         g_ptr->mimic = g_ptr->feat;
88         g_ptr->feat = trap;
89
90         msg_format_wizard(CHEAT_DUNGEON, _("%sの部屋が生成されました。", "Room of %s was generated."), f_name + f_info[trap].name);
91
92         return TRUE;
93 }
94