OSDN Git Service

Merge pull request #857 from sikabane-works/feature/fix-doxygen-syntax
[hengbandforosx/hengbandosx.git] / src / room / rooms-trap.cpp
1 #include "dungeon/dungeon-flag-types.h"
2 #include "dungeon/dungeon.h"
3 #include "floor/floor-generator.h"
4 #include "game-option/cheat-types.h"
5 #include "grid/feature.h"
6 #include "grid/grid.h"
7 #include "room/space-finder.h"
8 #include "system/floor-type-definition.h"
9 #include "wizard/wizard-messages.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, dun_data_type *dd_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, dd_ptr, &yval, &xval, ysize + 2, xsize + 2))
39         return FALSE;
40
41     /* Choose lite or dark */
42     floor_type *floor_ptr = player_ptr->current_floor_ptr;
43     light = ((floor_ptr->dun_level <= randint1(25)) && !(d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS));
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     /* Place a full floor under the room */
52     for (y = y1 - 1; y <= y2 + 1; y++) {
53         for (x = x1 - 1; x <= x2 + 1; x++) {
54             g_ptr = &floor_ptr->grid_array[y][x];
55             place_grid(player_ptr, g_ptr, GB_FLOOR);
56             g_ptr->info |= (CAVE_ROOM);
57             if (light)
58                 g_ptr->info |= (CAVE_GLOW);
59         }
60     }
61
62     /* Walls around the room */
63     for (y = y1 - 1; y <= y2 + 1; y++) {
64         g_ptr = &floor_ptr->grid_array[y][x1 - 1];
65         place_grid(player_ptr, g_ptr, GB_OUTER);
66         g_ptr = &floor_ptr->grid_array[y][x2 + 1];
67         place_grid(player_ptr, g_ptr, GB_OUTER);
68     }
69     for (x = x1 - 1; x <= x2 + 1; x++) {
70         g_ptr = &floor_ptr->grid_array[y1 - 1][x];
71         place_grid(player_ptr, g_ptr, GB_OUTER);
72         g_ptr = &floor_ptr->grid_array[y2 + 1][x];
73         place_grid(player_ptr, g_ptr, GB_OUTER);
74     }
75
76     if (floor_ptr->dun_level < 30 + randint1(30))
77         trap = feat_trap_piranha;
78     else
79         trap = feat_trap_armageddon;
80
81     /* Place a special trap */
82     g_ptr = &floor_ptr->grid_array[rand_spread(yval, ysize / 4)][rand_spread(xval, xsize / 4)];
83     g_ptr->mimic = g_ptr->feat;
84     g_ptr->feat = trap;
85
86     msg_format_wizard(player_ptr, CHEAT_DUNGEON, _("%sの部屋が生成されました。", "Room of %s was generated."), f_info[trap].name.c_str());
87     return TRUE;
88 }