OSDN Git Service

Merge pull request #934 from sikabane-works/feature/add-doxygen-artifact
[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 "system/player-type-definition.h"
10 #include "wizard/wizard-messages.h"
11
12 /*!
13  * @brief タイプ14の部屋…特殊トラップ部屋の生成 / Type 14 -- trapped rooms
14  * @param player_ptr プレーヤーへの参照ポインタ
15  * @return なし
16  * @details
17  * A special trap is placed at center of the room
18  */
19 bool build_type14(player_type *player_ptr, dun_data_type *dd_ptr)
20 {
21     POSITION y, x, y2, x2, yval, xval;
22     POSITION y1, x1, xsize, ysize;
23
24     bool light;
25
26     grid_type *g_ptr;
27     s16b trap;
28
29     /* Pick a room size */
30     y1 = randint1(4);
31     x1 = randint1(11);
32     y2 = randint1(3);
33     x2 = randint1(11);
34
35     xsize = x1 + x2 + 1;
36     ysize = y1 + y2 + 1;
37
38     /* Find and reserve some space in the dungeon.  Get center of room. */
39     if (!find_space(player_ptr, dd_ptr, &yval, &xval, ysize + 2, xsize + 2))
40         return FALSE;
41
42     /* Choose lite or dark */
43     floor_type *floor_ptr = player_ptr->current_floor_ptr;
44     light = ((floor_ptr->dun_level <= randint1(25)) && !(d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS));
45
46     /* Get corner values */
47     y1 = yval - ysize / 2;
48     x1 = xval - xsize / 2;
49     y2 = yval + (ysize - 1) / 2;
50     x2 = xval + (xsize - 1) / 2;
51
52     /* Place a full floor under the room */
53     for (y = y1 - 1; y <= y2 + 1; y++) {
54         for (x = x1 - 1; x <= x2 + 1; x++) {
55             g_ptr = &floor_ptr->grid_array[y][x];
56             place_grid(player_ptr, g_ptr, GB_FLOOR);
57             g_ptr->info |= (CAVE_ROOM);
58             if (light)
59                 g_ptr->info |= (CAVE_GLOW);
60         }
61     }
62
63     /* Walls around the room */
64     for (y = y1 - 1; y <= y2 + 1; y++) {
65         g_ptr = &floor_ptr->grid_array[y][x1 - 1];
66         place_grid(player_ptr, g_ptr, GB_OUTER);
67         g_ptr = &floor_ptr->grid_array[y][x2 + 1];
68         place_grid(player_ptr, g_ptr, GB_OUTER);
69     }
70     for (x = x1 - 1; x <= x2 + 1; x++) {
71         g_ptr = &floor_ptr->grid_array[y1 - 1][x];
72         place_grid(player_ptr, g_ptr, GB_OUTER);
73         g_ptr = &floor_ptr->grid_array[y2 + 1][x];
74         place_grid(player_ptr, g_ptr, GB_OUTER);
75     }
76
77     if (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 = &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(player_ptr, CHEAT_DUNGEON, _("%sの部屋が生成されました。", "Room of %s was generated."), f_info[trap].name.c_str());
88     return TRUE;
89 }