OSDN Git Service

English: use "power" rather than "magic" for elementalist power menu
[hengbandforosx/hengbandosx.git] / src / spell-realm / spells-chaos.cpp
1 #include "spell-realm/spells-chaos.h"
2 #include "core/player-redraw-types.h"
3 #include "core/player-update-types.h"
4 #include "core/window-redrawer.h"
5 #include "dungeon/quest.h"
6 #include "effect/attribute-types.h"
7 #include "effect/effect-characteristics.h"
8 #include "effect/effect-processor.h"
9 #include "floor/cave.h"
10 #include "floor/geometry.h"
11 #include "grid/feature.h"
12 #include "grid/grid.h"
13 #include "monster/monster-describer.h"
14 #include "monster/monster-status-setter.h"
15 #include "monster/monster-status.h"
16 #include "player-info/class-info.h"
17 #include "player/player-damage.h"
18 #include "spell-kind/spells-floor.h"
19 #include "spell-kind/spells-launcher.h"
20 #include "system/floor-type-definition.h"
21 #include "system/grid-type-definition.h"
22 #include "system/monster-type-definition.h"
23 #include "system/player-type-definition.h"
24 #include "target/projection-path-calculator.h"
25 #include "util/bit-flags-calculator.h"
26 #include "view/display-messages.h"
27
28 /*!
29  * @brief 虚無招来処理 /
30  * @param player_ptr プレイヤーへの参照ポインタ
31  * @details
32  * Sorry, it becomes not (void)...
33  */
34 void call_the_void(PlayerType *player_ptr)
35 {
36     bool do_call = true;
37     auto *floor_ptr = player_ptr->current_floor_ptr;
38     for (int i = 0; i < 9; i++) {
39         auto *g_ptr = &floor_ptr->grid_array[player_ptr->y + ddy_ddd[i]][player_ptr->x + ddx_ddd[i]];
40
41         if (!g_ptr->cave_has_flag(FloorFeatureType::PROJECT)) {
42             if (!g_ptr->mimic || f_info[g_ptr->mimic].flags.has_not(FloorFeatureType::PROJECT) || !permanent_wall(&f_info[g_ptr->feat])) {
43                 do_call = false;
44                 break;
45             }
46         }
47     }
48
49     if (do_call) {
50         for (int i = 1; i < 10; i++) {
51             if (i - 5) {
52                 fire_ball(player_ptr, AttributeType::ROCKET, i, 175, 2);
53             }
54         }
55
56         for (int i = 1; i < 10; i++) {
57             if (i - 5) {
58                 fire_ball(player_ptr, AttributeType::MANA, i, 175, 3);
59             }
60         }
61
62         for (int i = 1; i < 10; i++) {
63             if (i - 5) {
64                 fire_ball(player_ptr, AttributeType::NUKE, i, 175, 4);
65             }
66         }
67
68         return;
69     }
70
71     bool is_special_fllor = inside_quest(floor_ptr->quest_number) && quest_type::is_fixed(floor_ptr->quest_number);
72     is_special_fllor |= floor_ptr->dun_level > 0;
73     if (is_special_fllor) {
74         msg_print(_("地面が揺れた。", "The ground trembles."));
75         return;
76     }
77
78 #ifdef JP
79     msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!", ((mp_ptr->spell_book == ItemKindType::LIFE_BOOK) ? "祈り" : "呪文"));
80 #else
81     msg_format("You %s the %s too close to a wall!", ((mp_ptr->spell_book == ItemKindType::LIFE_BOOK) ? "recite" : "cast"),
82         ((mp_ptr->spell_book == ItemKindType::LIFE_BOOK) ? "prayer" : "spell"));
83 #endif
84     msg_print(_("大きな爆発音があった!", "There is a loud explosion!"));
85
86     if (one_in_(666)) {
87         if (!vanish_dungeon(player_ptr)) {
88             msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon becomes quiet for a moment."));
89         }
90         take_hit(player_ptr, DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"));
91         return;
92     }
93
94     if (destroy_area(player_ptr, player_ptr->y, player_ptr->x, 15 + player_ptr->lev + randint0(11), false)) {
95         msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
96     } else {
97         msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
98     }
99     take_hit(player_ptr, DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"));
100 }
101
102 /*!
103  * @brief 虚無招来によるフロア中の全壁除去処理 /
104  * Vanish all walls in this floor
105  * @param player_ptr プレイヤーへの参照ポインタ
106  * @param player_ptr 術者の参照ポインタ
107  * @return 実際に処理が反映された場合TRUE
108  */
109 bool vanish_dungeon(PlayerType *player_ptr)
110 {
111     auto *floor_ptr = player_ptr->current_floor_ptr;
112     bool is_special_floor = inside_quest(floor_ptr->quest_number) && quest_type::is_fixed(floor_ptr->quest_number);
113     is_special_floor |= (floor_ptr->dun_level == 0);
114     if (is_special_floor) {
115         return false;
116     }
117
118     GAME_TEXT m_name[MAX_NLEN];
119     for (POSITION y = 1; y < floor_ptr->height - 1; y++) {
120         for (POSITION x = 1; x < floor_ptr->width - 1; x++) {
121             auto *g_ptr = &floor_ptr->grid_array[y][x];
122
123             auto *f_ptr = &f_info[g_ptr->feat];
124             g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
125             auto *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
126             if (g_ptr->m_idx && monster_csleep_remaining(m_ptr)) {
127                 (void)set_monster_csleep(player_ptr, g_ptr->m_idx, 0);
128                 if (m_ptr->ml) {
129                     monster_desc(player_ptr, m_name, m_ptr, 0);
130                     msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
131                 }
132             }
133
134             if (f_ptr->flags.has(FloorFeatureType::HURT_DISI)) {
135                 cave_alter_feat(player_ptr, y, x, FloorFeatureType::HURT_DISI);
136             }
137         }
138     }
139
140     for (POSITION x = 0; x < floor_ptr->width; x++) {
141         auto *g_ptr = &floor_ptr->grid_array[0][x];
142         auto *f_ptr = &f_info[g_ptr->mimic];
143         g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
144
145         if (g_ptr->mimic && f_ptr->flags.has(FloorFeatureType::HURT_DISI)) {
146             g_ptr->mimic = feat_state(floor_ptr, g_ptr->mimic, FloorFeatureType::HURT_DISI);
147             if (f_info[g_ptr->mimic].flags.has_not(FloorFeatureType::REMEMBER)) {
148                 g_ptr->info &= ~(CAVE_MARK);
149             }
150         }
151
152         g_ptr = &floor_ptr->grid_array[floor_ptr->height - 1][x];
153         f_ptr = &f_info[g_ptr->mimic];
154         g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
155
156         if (g_ptr->mimic && f_ptr->flags.has(FloorFeatureType::HURT_DISI)) {
157             g_ptr->mimic = feat_state(floor_ptr, g_ptr->mimic, FloorFeatureType::HURT_DISI);
158             if (f_info[g_ptr->mimic].flags.has_not(FloorFeatureType::REMEMBER)) {
159                 g_ptr->info &= ~(CAVE_MARK);
160             }
161         }
162     }
163
164     /* Special boundary walls -- Left and right */
165     for (POSITION y = 1; y < (floor_ptr->height - 1); y++) {
166         auto *g_ptr = &floor_ptr->grid_array[y][0];
167         auto *f_ptr = &f_info[g_ptr->mimic];
168         g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
169
170         if (g_ptr->mimic && f_ptr->flags.has(FloorFeatureType::HURT_DISI)) {
171             g_ptr->mimic = feat_state(floor_ptr, g_ptr->mimic, FloorFeatureType::HURT_DISI);
172             if (f_info[g_ptr->mimic].flags.has_not(FloorFeatureType::REMEMBER)) {
173                 g_ptr->info &= ~(CAVE_MARK);
174             }
175         }
176
177         g_ptr = &floor_ptr->grid_array[y][floor_ptr->width - 1];
178         f_ptr = &f_info[g_ptr->mimic];
179         g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
180
181         if (g_ptr->mimic && f_ptr->flags.has(FloorFeatureType::HURT_DISI)) {
182             g_ptr->mimic = feat_state(floor_ptr, g_ptr->mimic, FloorFeatureType::HURT_DISI);
183             if (f_info[g_ptr->mimic].flags.has_not(FloorFeatureType::REMEMBER)) {
184                 g_ptr->info &= ~(CAVE_MARK);
185             }
186         }
187     }
188
189     player_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
190     player_ptr->redraw |= (PR_MAP);
191     player_ptr->window_flags |= (PW_OVERHEAD | PW_DUNGEON);
192     return true;
193 }
194
195 /*!
196  * @brief カオス魔法「流星群」/トランプ魔法「隕石のカード」の処理としてプレイヤーを中心に隕石落下処理を10+1d10回繰り返す。
197  * / Drop 10+1d10 meteor ball at random places near the player
198  * @param player_ptr プレイヤーへの参照ポインタ
199  * @param dam ダメージ
200  * @param rad 効力の半径
201  * @details このファイルにいるのは、spells-trump.c と比べて行数が少なかったため。それ以上の意図はない
202  */
203 void cast_meteor(PlayerType *player_ptr, int dam, POSITION rad)
204 {
205     int b = 10 + randint1(10);
206     for (int i = 0; i < b; i++) {
207         POSITION y = 0, x = 0;
208         int count;
209
210         for (count = 0; count <= 20; count++) {
211             int dy, dx, d;
212
213             x = player_ptr->x - 8 + randint0(17);
214             y = player_ptr->y - 8 + randint0(17);
215             dx = (player_ptr->x > x) ? (player_ptr->x - x) : (x - player_ptr->x);
216             dy = (player_ptr->y > y) ? (player_ptr->y - y) : (y - player_ptr->y);
217             d = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
218
219             if (d >= 9) {
220                 continue;
221             }
222
223             auto *floor_ptr = player_ptr->current_floor_ptr;
224             if (!in_bounds(floor_ptr, y, x) || !projectable(player_ptr, player_ptr->y, player_ptr->x, y, x) || !cave_has_flag_bold(floor_ptr, y, x, FloorFeatureType::PROJECT)) {
225                 continue;
226             }
227
228             break;
229         }
230
231         if (count > 20) {
232             continue;
233         }
234
235         project(player_ptr, 0, rad, y, x, dam, AttributeType::METEOR, PROJECT_KILL | PROJECT_JUMP | PROJECT_ITEM);
236     }
237 }