OSDN Git Service

3c807ead47b0a9a7fce2843bd854f3228ed3f0ed
[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
9
10 /*!
11 * @brief タイプ14の部屋…特殊トラップ部屋の生成 / Type 14 -- trapped rooms
12 * @return なし
13 * @details
14 * A special trap is placed at center of the room
15 */
16 bool build_type14(void)
17 {
18         POSITION y, x, y2, x2, yval, xval;
19         POSITION y1, x1, xsize, ysize;
20
21         bool light;
22
23         grid_type *g_ptr;
24         s16b trap;
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(&yval, &xval, ysize + 2, xsize + 2)) return FALSE;
37
38         /* Choose lite or dark */
39         light = ((current_floor_ptr->dun_level <= randint1(25)) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS));
40
41
42         /* Get corner values */
43         y1 = yval - ysize / 2;
44         x1 = xval - xsize / 2;
45         y2 = yval + (ysize - 1) / 2;
46         x2 = xval + (xsize - 1) / 2;
47
48
49         /* Place a full floor under the room */
50         for (y = y1 - 1; y <= y2 + 1; y++)
51         {
52                 for (x = x1 - 1; x <= x2 + 1; x++)
53                 {
54                         g_ptr = &current_floor_ptr->grid_array[y][x];
55                         place_floor_grid(g_ptr);
56                         g_ptr->info |= (CAVE_ROOM);
57                         if (light) g_ptr->info |= (CAVE_GLOW);
58                 }
59         }
60
61         /* Walls around the room */
62         for (y = y1 - 1; y <= y2 + 1; y++)
63         {
64                 g_ptr = &current_floor_ptr->grid_array[y][x1 - 1];
65                 place_outer_grid(g_ptr);
66                 g_ptr = &current_floor_ptr->grid_array[y][x2 + 1];
67                 place_outer_grid(g_ptr);
68         }
69         for (x = x1 - 1; x <= x2 + 1; x++)
70         {
71                 g_ptr = &current_floor_ptr->grid_array[y1 - 1][x];
72                 place_outer_grid(g_ptr);
73                 g_ptr = &current_floor_ptr->grid_array[y2 + 1][x];
74                 place_outer_grid(g_ptr);
75         }
76
77         if (current_floor_ptr->dun_level < 30 + randint1(30))
78                 trap = feat_trap_piranha;
79         else
80                 trap = feat_trap_armageddon;
81
82         /* Place a special trap */
83         g_ptr = &current_floor_ptr->grid_array[rand_spread(yval, ysize / 4)][rand_spread(xval, xsize / 4)];
84         g_ptr->mimic = g_ptr->feat;
85         g_ptr->feat = trap;
86
87         msg_format_wizard(CHEAT_DUNGEON, _("%sの部屋が生成されました。", "Room of %s was generated."), f_name + f_info[trap].name);
88
89         return TRUE;
90 }
91