OSDN Git Service

[Refactor] enum spells-typeをenum class AttributeTypeに置換
[hengbandforosx/hengbandosx.git] / src / object-activation / activation-others.cpp
1 /*!
2  * @brief 発動処理その他 (肥大化しがちなので適宜まとまりを別ファイルへ分割すること)
3  * @date 2020/08/19
4  * @author Hourier
5  */
6
7 #include "object-activation/activation-others.h"
8 #include "artifact/fixed-art-types.h"
9 #include "avatar/avatar.h"
10 #include "cmd-io/cmd-save.h"
11 #include "core/asking-player.h"
12 #include "core/player-redraw-types.h"
13 #include "effect/effect-characteristics.h"
14 #include "effect/effect-processor.h"
15 #include "game-option/special-options.h"
16 #include "hpmp/hp-mp-processor.h"
17 #include "monster-race/monster-race.h"
18 #include "monster-race/race-flags1.h"
19 #include "monster-race/race-indice-types.h"
20 #include "monster/monster-status.h"
21 #include "player-attack/player-attack.h"
22 #include "player/player-damage.h"
23 #include "player/player-status.h"
24 #include "spell-kind/earthquake.h"
25 #include "spell-kind/magic-item-recharger.h"
26 #include "spell-kind/spells-beam.h"
27 #include "spell-kind/spells-curse-removal.h"
28 #include "spell-kind/spells-detection.h"
29 #include "spell-kind/spells-fetcher.h"
30 #include "spell-kind/spells-floor.h"
31 #include "spell-kind/spells-grid.h"
32 #include "spell-kind/spells-launcher.h"
33 #include "spell-kind/spells-lite.h"
34 #include "spell-kind/spells-neighbor.h"
35 #include "spell-kind/spells-perception.h"
36 #include "spell-kind/spells-random.h"
37 #include "spell-kind/spells-sight.h"
38 #include "spell-kind/spells-teleport.h"
39 #include "spell-kind/spells-world.h"
40 #include "spell-realm/spells-hex.h"
41 #include "spell-realm/spells-song.h"
42 #include "effect/attribute-types.h"
43 #include "spell/spells-status.h"
44 #include "status/bad-status-setter.h"
45 #include "status/body-improvement.h"
46 #include "status/buff-setter.h"
47 #include "system/floor-type-definition.h"
48 #include "system/monster-race-definition.h"
49 #include "system/monster-type-definition.h"
50 #include "system/object-type-definition.h"
51 #include "system/player-type-definition.h"
52 #include "target/target-getter.h"
53 #include "util/bit-flags-calculator.h"
54 #include "util/quarks.h"
55 #include "view/display-messages.h"
56
57 bool activate_sunlight(player_type *player_ptr)
58 {
59     DIRECTION dir;
60     if (!get_aim_dir(player_ptr, &dir))
61         return false;
62
63     msg_print(_("太陽光線が放たれた。", "A line of sunlight appears."));
64     (void)lite_line(player_ptr, dir, damroll(6, 8));
65     return true;
66 }
67
68 bool activate_confusion(player_type *player_ptr)
69 {
70     DIRECTION dir;
71     msg_print(_("様々な色の火花を発している...", "It glows in scintillating colours..."));
72     if (!get_aim_dir(player_ptr, &dir))
73         return false;
74
75     confuse_monster(player_ptr, dir, 20);
76     return true;
77 }
78
79 bool activate_banish_evil(player_type *player_ptr)
80 {
81     if (banish_evil(player_ptr, 100))
82         msg_print(_("アーティファクトの力が邪悪を打ち払った!", "The power of the artifact banishes evil!"));
83
84     return true;
85 }
86
87 bool activate_scare(player_type *player_ptr)
88 {
89     if (music_singing_any(player_ptr))
90         stop_singing(player_ptr);
91
92     if (SpellHex(player_ptr).is_spelling_any()) {
93         (void)SpellHex(player_ptr).stop_all_spells();
94     }
95
96     msg_print(_("あなたは力強い突風を吹き鳴らした。周囲の敵が震え上っている!", "You wind a mighty blast; your enemies tremble!"));
97     (void)turn_monsters(player_ptr, (3 * player_ptr->lev / 2) + 10);
98     return true;
99 }
100
101 bool activate_aggravation(player_type *player_ptr, object_type *o_ptr, concptr name)
102 {
103     if (o_ptr->name1 == ART_HYOUSIGI)
104         msg_print(_("拍子木を打った。", "You beat your wooden clappers."));
105     else
106         msg_format(_("%sは不快な物音を立てた。", "The %s sounds an unpleasant noise."), name);
107
108     aggravate_monsters(player_ptr, 0);
109     return true;
110 }
111
112 bool activate_stone_mud(player_type *player_ptr)
113 {
114     DIRECTION dir;
115     msg_print(_("鼓動している...", "It pulsates..."));
116     if (!get_aim_dir(player_ptr, &dir))
117         return false;
118
119     wall_to_mud(player_ptr, dir, 20 + randint1(30));
120     return true;
121 }
122
123 bool activate_judgement(player_type *player_ptr, concptr name)
124 {
125     msg_format(_("%sは赤く明るく光った!", "The %s flashes bright red!"), name);
126     chg_virtue(player_ptr, V_KNOWLEDGE, 1);
127     chg_virtue(player_ptr, V_ENLIGHTEN, 1);
128     wiz_lite(player_ptr, false);
129
130     msg_format(_("%sはあなたの体力を奪った...", "The %s drains your vitality..."), name);
131     take_hit(player_ptr, DAMAGE_LOSELIFE, damroll(3, 8), _("審判の宝石", "the Jewel of Judgement"));
132
133     (void)detect_traps(player_ptr, DETECT_RAD_DEFAULT, true);
134     (void)detect_doors(player_ptr, DETECT_RAD_DEFAULT);
135     (void)detect_stairs(player_ptr, DETECT_RAD_DEFAULT);
136
137     if (get_check(_("帰還の力を使いますか?", "Activate recall? ")))
138         (void)recall_player(player_ptr, randint0(21) + 15);
139
140     return true;
141 }
142
143 bool activate_telekinesis(player_type *player_ptr, concptr name)
144 {
145     DIRECTION dir;
146     if (!get_aim_dir(player_ptr, &dir))
147         return false;
148
149     msg_format(_("%sを伸ばした。", "You stretched your %s."), name);
150     fetch_item(player_ptr, dir, 500, true);
151     return true;
152 }
153
154 bool activate_unique_detection(player_type *player_ptr)
155 {
156     monster_type *m_ptr;
157     monster_race *r_ptr;
158     msg_print(_("奇妙な場所が頭の中に浮かんだ...", "Some strange places show up in your mind. And you see ..."));
159     for (int i = player_ptr->current_floor_ptr->m_max - 1; i >= 1; i--) {
160         m_ptr = &player_ptr->current_floor_ptr->m_list[i];
161         if (!monster_is_valid(m_ptr))
162             continue;
163
164         r_ptr = &r_info[m_ptr->r_idx];
165         if (r_ptr->flags1 & RF1_UNIQUE)
166             msg_format(_("%s. ", "%s. "), r_ptr->name.c_str());
167
168         if (m_ptr->r_idx == MON_DIO)
169             msg_print(_("きさま! 見ているなッ!", "You bastard! You're watching me, well watch this!"));
170     }
171
172     return true;
173 }
174
175 bool activate_dispel_curse(player_type *player_ptr, concptr name)
176 {
177     msg_format(_("%sが真実を照らし出す...", "The %s exhibits the truth..."), name);
178     (void)remove_all_curse(player_ptr);
179     (void)probing(player_ptr);
180     return true;
181 }
182
183 bool activate_cure_lw(player_type *player_ptr)
184 {
185     (void)BadStatusSetter(player_ptr).afraidness(0);
186     (void)hp_player(player_ptr, 30);
187     return true;
188 }
189
190 bool activate_grand_cross(player_type *player_ptr)
191 {
192     msg_print(_("「闇に還れ!」", "You say, 'Return to darkness!'"));
193     (void)project(player_ptr, 0, 8, player_ptr->y, player_ptr->x, (randint1(100) + 200) * 2, AttributeType::HOLY_FIRE, PROJECT_KILL | PROJECT_ITEM | PROJECT_GRID);
194     return true;
195 }
196
197 bool activate_call_chaos(player_type *player_ptr)
198 {
199     msg_print(_("様々な色の火花を発している...", "It glows in scintillating colours..."));
200     call_chaos(player_ptr);
201     return true;
202 }
203
204 bool activate_dispel_evil(player_type *player_ptr)
205 {
206     msg_print(_("神聖な雰囲気が充満した...", "It floods the area with goodness..."));
207     dispel_evil(player_ptr, player_ptr->lev * 5);
208     return true;
209 }
210
211 bool activate_dispel_good(player_type *player_ptr)
212 {
213     msg_print(_("邪悪な雰囲気が充満した...", "It floods the area with evil..."));
214     dispel_good(player_ptr, player_ptr->lev * 5);
215     return true;
216 }
217
218 bool activate_all_monsters_detection(player_type *player_ptr)
219 {
220     (void)detect_monsters_invis(player_ptr, 255);
221     (void)detect_monsters_normal(player_ptr, 255);
222     return true;
223 }
224
225 bool activate_all_detection(player_type *player_ptr)
226 {
227     msg_print(_("白く明るく輝いている...", "It glows bright white..."));
228     msg_print(_("心にイメージが浮かんできた...", "An image forms in your mind..."));
229     detect_all(player_ptr, DETECT_RAD_DEFAULT);
230     return true;
231 }
232
233 bool activate_extra_detection(player_type *player_ptr)
234 {
235     msg_print(_("明るく輝いている...", "It glows brightly..."));
236     detect_all(player_ptr, DETECT_RAD_DEFAULT);
237     probing(player_ptr);
238     identify_fully(player_ptr, false);
239     return true;
240 }
241
242 bool activate_fully_identification(player_type *player_ptr)
243 {
244     msg_print(_("黄色く輝いている...", "It glows yellow..."));
245     identify_fully(player_ptr, false);
246     return true;
247 }
248
249 /*!
250  * @brief switch_activation() から個々のスペルへの依存性をなくすためのシンタックスシュガー
251  * @param player_ptr プレイヤーへの参照ポインタ
252  * @return 発動に成功したらTRUE
253  */
254 bool activate_identification(player_type *player_ptr)
255 {
256     return ident_spell(player_ptr, false);
257 }
258
259 bool activate_pesticide(player_type *player_ptr)
260 {
261     msg_print(_("あなたは害虫を一掃した。", "You exterminate some pests."));
262     (void)dispel_monsters(player_ptr, 4);
263     return true;
264 }
265
266 /*!
267  * @brief switch_activation() から個々のスペルへの依存性をなくすためのシンタックスシュガー
268  * @param player_ptr プレイヤーへの参照ポインタ
269  * @return 発動に成功したらTRUE
270  */
271 bool activate_whirlwind(player_type *player_ptr)
272 {
273     massacre(player_ptr);
274     return true;
275 }
276
277 bool activate_blinding_light(player_type *player_ptr, concptr name)
278 {
279     msg_format(_("%sが眩しい光で輝いた...", "The %s gleams with blinding light..."), name);
280     (void)fire_ball(player_ptr, AttributeType::LITE, 0, 300, 6);
281     confuse_monsters(player_ptr, 3 * player_ptr->lev / 2);
282     return true;
283 }
284
285 bool activate_sleep(player_type *player_ptr)
286 {
287     msg_print(_("深青色に輝いている...", "It glows deep blue..."));
288     sleep_monsters_touch(player_ptr);
289     return true;
290 }
291
292 bool activate_door_destroy(player_type *player_ptr)
293 {
294     msg_print(_("明るい赤色に輝いている...", "It glows bright red..."));
295     destroy_doors_touch(player_ptr);
296     return true;
297 }
298
299 bool activate_earthquake(player_type *player_ptr)
300 {
301     earthquake(player_ptr, player_ptr->y, player_ptr->x, 5, 0);
302     return true;
303 }
304
305 bool activate_recharge(player_type *player_ptr)
306 {
307     recharge(player_ptr, 130);
308     return true;
309 }
310
311 bool activate_recharge_extra(player_type *player_ptr, concptr name)
312 {
313     msg_format(_("%sが白く輝いた...", "The %s gleams with blinding light..."), name);
314     return recharge(player_ptr, 1000);
315 }
316
317 bool activate_shikofumi(player_type *player_ptr)
318 {
319     msg_print(_("力強く四股を踏んだ。", "You stamp. (as if you are in a ring.)"));
320     (void)BadStatusSetter(player_ptr).afraidness(0);
321     (void)set_hero(player_ptr, randint1(20) + 20, false);
322     (void)dispel_evil(player_ptr, player_ptr->lev * 3);
323     return true;
324 }
325
326 bool activate_terror(player_type *player_ptr)
327 {
328     turn_monsters(player_ptr, 40 + player_ptr->lev);
329     return true;
330 }
331
332 bool activate_map_light(player_type *player_ptr)
333 {
334     msg_print(_("眩しく輝いた...", "It shines brightly..."));
335     map_area(player_ptr, DETECT_RAD_MAP);
336     lite_area(player_ptr, damroll(2, 15), 3);
337     return true;
338 }
339
340 bool activate_exploding_rune(player_type *player_ptr)
341 {
342     msg_print(_("明るい赤色に輝いている...", "It glows bright red..."));
343     create_rune_explosion(player_ptr, player_ptr->y, player_ptr->x);
344     return true;
345 }
346
347 bool activate_protection_rune(player_type *player_ptr)
348 {
349     msg_print(_("ブルーに明るく輝いている...", "It glows light blue..."));
350     create_rune_protection_one(player_ptr);
351     return true;
352 }
353
354 bool activate_protection_elbereth(player_type *player_ptr)
355 {
356     BadStatusSetter bss(player_ptr);
357     msg_print(_("エルベレスよ、我を護り給え!", "A Elbereth gilthoniel!"));
358     create_rune_protection_one(player_ptr);
359     (void)bss.afraidness(0);
360     (void)bss.blindness(0);
361     (void)bss.hallucination(0);
362     set_blessed(player_ptr, randint0(25) + 25, true);
363     set_bits(player_ptr->redraw, PR_STATS);
364     return true;
365 }
366
367 bool activate_light(player_type *player_ptr, concptr name)
368 {
369     msg_format(_("%sから澄んだ光があふれ出た...", "The %s wells with clear light..."), name);
370     (void)lite_area(player_ptr, damroll(2, 15), 3);
371     return true;
372 }
373
374 bool activate_recall(player_type *player_ptr)
375 {
376     msg_print(_("やわらかな白色に輝いている...", "It glows soft white..."));
377     return recall_player(player_ptr, randint0(21) + 15);
378 }
379
380 bool activate_tree_creation(player_type *player_ptr, object_type *o_ptr, concptr name)
381 {
382     msg_format(_("%s%sから明るい緑の光があふれ出た...", "The %s%s wells with clear light..."), name, quark_str(o_ptr->art_name));
383     return tree_creation(player_ptr, player_ptr->y, player_ptr->x);
384 }
385
386 bool activate_animate_dead(player_type *player_ptr, object_type *o_ptr)
387 {
388     msg_print(_("黄金色の光が溢れ出た...", "It emitted a golden light..."));
389     if (o_ptr->name1 > 0)
390         msg_print(_("ぴぴるぴるぴるぴぴるぴ~♪", "Pipiru piru piru pipiru pii"));
391
392     return animate_dead(player_ptr, 0, player_ptr->y, player_ptr->x);
393 }
394
395 bool activate_detect_treasure(player_type *player_ptr)
396 {
397     msg_print(_("金と銀に彩られている...", "It shines with gold and silver..."));
398     return detect_treasure(player_ptr, DETECT_RAD_DEFAULT);
399 }