OSDN Git Service

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