OSDN Git Service

Merge pull request #2302 from Hourier/Make-Hallucination-Class
[hengbandforosx/hengbandosx.git] / src / spell-kind / spells-neighbor.cpp
1 #include "spell-kind/spells-neighbor.h"
2 #include "core/player-redraw-types.h"
3 #include "core/player-update-types.h"
4 #include "effect/attribute-types.h"
5 #include "effect/effect-characteristics.h"
6 #include "effect/effect-processor.h"
7 #include "floor/cave.h"
8 #include "floor/floor-util.h"
9 #include "grid/feature-flag-types.h"
10 #include "grid/grid.h"
11 #include "spell-kind/earthquake.h"
12 #include "system/player-type-definition.h"
13 #include "util/bit-flags-calculator.h"
14
15 /*!
16  * @brief ドア生成処理(プレイヤー中心に周囲1マス) / Hooks -- affect adjacent grids (radius 1 ball attack)
17  * @param player_ptr プレイヤーへの参照ポインタ
18  * @return 作用が実際にあった場合TRUEを返す
19  */
20 bool door_creation(PlayerType *player_ptr, POSITION y, POSITION x)
21 {
22     BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
23     return project(player_ptr, 0, 1, y, x, 0, AttributeType::MAKE_DOOR, flg).notice;
24 }
25
26 /*!
27  * @brief トラップ生成処理(起点から周囲1マス)
28  * @param player_ptr プレイヤーへの参照ポインタ
29  * @param y 起点Y座標
30  * @param x 起点X座標
31  * @return 作用が実際にあった場合TRUEを返す
32  */
33 bool trap_creation(PlayerType *player_ptr, POSITION y, POSITION x)
34 {
35     BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
36     return project(player_ptr, 0, 1, y, x, 0, AttributeType::MAKE_TRAP, flg).notice;
37 }
38
39 /*!
40  * @brief 森林生成処理(プレイヤー中心に周囲1マス)
41  * @param player_ptr プレイヤーへの参照ポインタ
42  * @return 作用が実際にあった場合TRUEを返す
43  */
44 bool tree_creation(PlayerType *player_ptr, POSITION y, POSITION x)
45 {
46     BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
47     return project(player_ptr, 0, 1, y, x, 0, AttributeType::MAKE_TREE, flg).notice;
48 }
49
50 /*!
51  * @brief 魔法のルーン生成処理(プレイヤー中心に周囲1マス)
52  * @param player_ptr プレイヤーへの参照ポインタ
53  * @return 作用が実際にあった場合TRUEを返す
54  */
55 bool create_rune_protection_area(PlayerType *player_ptr, POSITION y, POSITION x)
56 {
57     BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM;
58     return project(player_ptr, 0, 1, y, x, 0, AttributeType::MAKE_RUNE_PROTECTION, flg).notice;
59 }
60
61 /*!
62  * @brief 壁生成処理(プレイヤー中心に周囲1マス)
63  * @param player_ptr プレイヤーへの参照ポインタ
64  * @return 作用が実際にあった場合TRUEを返す
65  */
66 bool wall_stone(PlayerType *player_ptr)
67 {
68     BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
69     bool dummy = project(player_ptr, 0, 1, player_ptr->y, player_ptr->x, 0, AttributeType::STONE_WALL, flg).notice;
70     player_ptr->update |= (PU_FLOW);
71     player_ptr->redraw |= (PR_MAP);
72     return dummy;
73 }
74
75 /*!
76  * @brief ドア破壊処理(プレイヤー中心に周囲1マス)
77  * @param player_ptr プレイヤーへの参照ポインタ
78  * @return 作用が実際にあった場合TRUEを返す
79  */
80 bool destroy_doors_touch(PlayerType *player_ptr)
81 {
82     BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
83     return project(player_ptr, 0, 1, player_ptr->y, player_ptr->x, 0, AttributeType::KILL_DOOR, flg).notice;
84 }
85
86 /*!
87  * @brief トラップ解除処理(プレイヤー中心に周囲1マス)
88  * @param player_ptr プレイヤーへの参照ポインタ
89  * @return 作用が実際にあった場合TRUEを返す
90  */
91 bool disarm_traps_touch(PlayerType *player_ptr)
92 {
93     BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_HIDE;
94     return project(player_ptr, 0, 1, player_ptr->y, player_ptr->x, 0, AttributeType::KILL_TRAP, flg).notice;
95 }
96
97 /*!
98  * @brief スリープモンスター処理(プレイヤー中心に周囲1マス)
99  * @param player_ptr プレイヤーへの参照ポインタ
100  * @return 作用が実際にあった場合TRUEを返す
101  */
102 bool sleep_monsters_touch(PlayerType *player_ptr)
103 {
104     BIT_FLAGS flg = PROJECT_KILL | PROJECT_HIDE;
105     return project(player_ptr, 0, 1, player_ptr->y, player_ptr->x, player_ptr->lev, AttributeType::OLD_SLEEP, flg).notice;
106 }
107
108 /*!
109  * @brief 死者復活処理(起点より周囲5マス)
110  * @param player_ptr プレイヤーへの参照ポインタ
111  * @param who 術者モンスターID(0ならばプレイヤー)
112  * @param y 起点Y座標
113  * @param x 起点X座標
114  * @return 作用が実際にあった場合TRUEを返す
115  */
116 bool animate_dead(PlayerType *player_ptr, MONSTER_IDX who, POSITION y, POSITION x)
117 {
118     BIT_FLAGS flg = PROJECT_ITEM | PROJECT_HIDE;
119     return project(player_ptr, who, 5, y, x, 0, AttributeType::ANIM_DEAD, flg).notice;
120 }
121
122 /*!
123  * @brief 周辺破壊効果(プレイヤー中心)
124  * @param player_ptr プレイヤーへの参照ポインタ
125  */
126 void wall_breaker(PlayerType *player_ptr)
127 {
128     POSITION y = 0, x = 0;
129     int attempts = 1000;
130     if (randint1(80 + player_ptr->lev) < 70) {
131         while (attempts--) {
132             scatter(player_ptr, &y, &x, player_ptr->y, player_ptr->x, 4, PROJECT_NONE);
133
134             if (!cave_has_flag_bold(player_ptr->current_floor_ptr, y, x, FloorFeatureType::PROJECT)) {
135                 continue;
136             }
137
138             if (!player_bold(player_ptr, y, x)) {
139                 break;
140             }
141         }
142
143         project(player_ptr, 0, 0, y, x, 20 + randint1(30), AttributeType::KILL_WALL, (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL));
144         return;
145     }
146
147     if (randint1(100) > 30) {
148         earthquake(player_ptr, player_ptr->y, player_ptr->x, 1, 0);
149         return;
150     }
151
152     int num = damroll(5, 3);
153     for (int i = 0; i < num; i++) {
154         while (true) {
155             scatter(player_ptr, &y, &x, player_ptr->y, player_ptr->x, 10, PROJECT_NONE);
156
157             if (!player_bold(player_ptr, y, x)) {
158                 break;
159             }
160         }
161
162         project(player_ptr, 0, 0, y, x, 20 + randint1(30), AttributeType::KILL_WALL, (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL));
163     }
164 }