OSDN Git Service

70336a5c9cd2ee00d73b7c1931df3a51c3b3b2ec
[hengbandforosx/hengbandosx.git] / src / realm / realm-hissatsu.cpp
1 #include "realm/realm-hissatsu.h"
2 #include "artifact/fixed-art-types.h"
3 #include "cmd-action/cmd-attack.h"
4 #include "cmd-action/cmd-spell.h"
5 #include "cmd-item/cmd-throw.h"
6 #include "combat/combat-options-type.h"
7 #include "core/asking-player.h"
8 #include "core/stuff-handler.h"
9 #include "dungeon/dungeon-flag-types.h"
10 #include "effect/attribute-types.h"
11 #include "effect/effect-characteristics.h"
12 #include "effect/effect-processor.h"
13 #include "effect/spells-effect-util.h"
14 #include "floor/cave.h"
15 #include "floor/geometry.h"
16 #include "grid/feature-flag-types.h"
17 #include "grid/feature.h"
18 #include "grid/grid.h"
19 #include "inventory/inventory-slot-types.h"
20 #include "io/input-key-acceptor.h"
21 #include "io/input-key-requester.h"
22 #include "mind/mind-ninja.h"
23 #include "monster-race/monster-race-hook.h"
24 #include "monster-race/monster-race.h"
25 #include "monster-race/race-brightness-mask.h"
26 #include "monster-race/race-flags7.h"
27 #include "monster/monster-describer.h"
28 #include "monster/monster-info.h"
29 #include "monster/monster-update.h"
30 #include "object-enchant/tr-types.h"
31 #include "object/object-flags.h"
32 #include "player-info/equipment-info.h"
33 #include "player/player-damage.h"
34 #include "player/player-move.h"
35 #include "spell-kind/earthquake.h"
36 #include "spell-kind/spells-detection.h"
37 #include "spell-kind/spells-launcher.h"
38 #include "spell-kind/spells-perception.h"
39 #include "spell-kind/spells-sight.h"
40 #include "spell-kind/spells-teleport.h"
41 #include "spell/technic-info-table.h"
42 #include "status/bad-status-setter.h"
43 #include "system/dungeon-info.h"
44 #include "system/floor-type-definition.h"
45 #include "system/grid-type-definition.h"
46 #include "system/item-entity.h"
47 #include "system/monster-entity.h"
48 #include "system/monster-race-info.h"
49 #include "system/player-type-definition.h"
50 #include "system/redrawing-flags-updater.h"
51 #include "target/grid-selector.h"
52 #include "target/projection-path-calculator.h"
53 #include "target/target-getter.h"
54 #include "term/screen-processor.h"
55 #include "timed-effect/player-cut.h"
56 #include "timed-effect/timed-effects.h"
57 #include "util/bit-flags-calculator.h"
58 #include "view/display-messages.h"
59 #include "world/world.h"
60
61 /*!
62  * @brief 剣術の各処理を行う
63  * @param player_ptr プレイヤーへの参照ポインタ
64  * @param spell 剣術ID
65  * @param mode 処理内容 (SpellProcessType::NAME / SPELL_DESC / SpellProcessType::CAST)
66  * @return SpellProcessType::NAME / SPELL_DESC 時には文字列を返す。SpellProcessType::CAST時は std::nullopt を返す。
67  */
68 std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX spell, SpellProcessType mode)
69 {
70     bool name = mode == SpellProcessType::NAME;
71     bool desc = mode == SpellProcessType::DESCRIPTION;
72     bool cast = mode == SpellProcessType::CAST;
73
74     DIRECTION dir;
75     PLAYER_LEVEL plev = player_ptr->lev;
76
77     switch (spell) {
78     case 0:
79         if (name) {
80             return _("飛飯綱", "Tobi-Izuna");
81         }
82         if (desc) {
83             return _("2マス離れたところにいるモンスターを攻撃する。", "Attacks a monster two squares away.");
84         }
85
86         if (cast) {
87             project_length = 2;
88             if (!get_aim_dir(player_ptr, &dir)) {
89                 return std::nullopt;
90             }
91
92             project_hook(player_ptr, AttributeType::ATTACK, dir, HISSATSU_2, PROJECT_STOP | PROJECT_KILL);
93         }
94         break;
95
96     case 1:
97         if (name) {
98             return _("五月雨斬り", "3-Way Attack");
99         }
100         if (desc) {
101             return _("3方向に対して攻撃する。", "Attacks in 3 directions at one time.");
102         }
103
104         if (cast) {
105             DIRECTION cdir;
106             POSITION y, x;
107
108             if (!get_direction(player_ptr, &dir, false, false)) {
109                 return std::nullopt;
110             }
111             if (dir == 5) {
112                 return std::nullopt;
113             }
114
115             for (cdir = 0; cdir < 8; cdir++) {
116                 if (cdd[cdir] == dir) {
117                     break;
118                 }
119             }
120
121             if (cdir == 8) {
122                 return std::nullopt;
123             }
124
125             y = player_ptr->y + ddy_cdd[cdir];
126             x = player_ptr->x + ddx_cdd[cdir];
127             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
128                 do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
129             } else {
130                 msg_print(_("攻撃は空を切った。", "You attack the empty air."));
131             }
132
133             y = player_ptr->y + ddy_cdd[(cdir + 7) % 8];
134             x = player_ptr->x + ddx_cdd[(cdir + 7) % 8];
135             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
136                 do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
137             } else {
138                 msg_print(_("攻撃は空を切った。", "You attack the empty air."));
139             }
140
141             y = player_ptr->y + ddy_cdd[(cdir + 1) % 8];
142             x = player_ptr->x + ddx_cdd[(cdir + 1) % 8];
143             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
144                 do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
145             } else {
146                 msg_print(_("攻撃は空を切った。", "You attack the empty air."));
147             }
148         }
149         break;
150
151     case 2:
152         if (name) {
153             return _("ブーメラン", "Boomerang");
154         }
155         if (desc) {
156             return _(
157                 "武器を手元に戻ってくるように投げる。戻ってこないこともある。", "Throws current weapon. It'll return to your hand unless the action failed.");
158         }
159
160         if (cast) {
161             if (!ThrowCommand(player_ptr).do_cmd_throw(1, true, -1)) {
162                 return std::nullopt;
163             }
164         }
165         break;
166
167     case 3:
168         if (name) {
169             return _("焔霊", "Burning Strike");
170         }
171         if (desc) {
172             return _("火炎耐性のないモンスターに大ダメージを与える。", "Attacks a monster with more damage unless it has resistance to fire.");
173         }
174
175         if (cast) {
176             POSITION y, x;
177
178             if (!get_direction(player_ptr, &dir, false, false)) {
179                 return std::nullopt;
180             }
181             if (dir == 5) {
182                 return std::nullopt;
183             }
184
185             y = player_ptr->y + ddy[dir];
186             x = player_ptr->x + ddx[dir];
187
188             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
189                 do_cmd_attack(player_ptr, y, x, HISSATSU_FIRE);
190             } else {
191                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
192                 return std::nullopt;
193             }
194         }
195         break;
196
197     case 4:
198         if (name) {
199             return _("殺気感知", "Detect Ferocity");
200         }
201         if (desc) {
202             return _("近くの思考することができるモンスターを感知する。", "Detects all monsters except the mindless in your vicinity.");
203         }
204
205         if (cast) {
206             detect_monsters_mind(player_ptr, DETECT_RAD_DEFAULT);
207         }
208         break;
209
210     case 5:
211         if (name) {
212             return _("みね打ち", "Strike to Stun");
213         }
214         if (desc) {
215             return _("相手にダメージを与えないが、朦朧とさせる。", "Attempts to stun a monster next to you.");
216         }
217
218         if (cast) {
219             POSITION y, x;
220
221             if (!get_direction(player_ptr, &dir, false, false)) {
222                 return std::nullopt;
223             }
224             if (dir == 5) {
225                 return std::nullopt;
226             }
227
228             y = player_ptr->y + ddy[dir];
229             x = player_ptr->x + ddx[dir];
230
231             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
232                 do_cmd_attack(player_ptr, y, x, HISSATSU_MINEUCHI);
233             } else {
234                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
235                 return std::nullopt;
236             }
237         }
238         break;
239
240     case 6:
241         if (name) {
242             return _("カウンター", "Counter");
243         }
244         if (desc) {
245             return _("相手に攻撃されたときに反撃する。反撃するたびにMPを消費。",
246                 "Prepares to counterattack. When attacked by a monster, strikes back using SP each time.");
247         }
248
249         if (cast) {
250             if (player_ptr->riding) {
251                 msg_print(_("乗馬中には無理だ。", "You cannot do it when riding."));
252                 return std::nullopt;
253             }
254             msg_print(_("相手の攻撃に対して身構えた。", "You prepare to counterattack."));
255             player_ptr->counter = true;
256         }
257         break;
258
259     case 7:
260         if (name) {
261             return _("払い抜け", "Harainuke");
262         }
263         if (desc) {
264             return _("攻撃した後、反対側に抜ける。",
265                 "In one action, attacks a monster with your weapons normally and then moves to the space beyond the monster if that space is not blocked.");
266         }
267
268         if (cast) {
269             POSITION y, x;
270
271             if (player_ptr->riding) {
272                 msg_print(_("乗馬中には無理だ。", "You cannot do it when riding."));
273                 return std::nullopt;
274             }
275
276             if (!get_direction(player_ptr, &dir, false, false)) {
277                 return std::nullopt;
278             }
279
280             if (dir == 5) {
281                 return std::nullopt;
282             }
283             y = player_ptr->y + ddy[dir];
284             x = player_ptr->x + ddx[dir];
285
286             const auto *floor_ptr = player_ptr->current_floor_ptr;
287             const auto &grid = floor_ptr->grid_array[y][x];
288             if (!grid.m_idx) {
289                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
290                 return std::nullopt;
291             }
292
293             do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
294             if (!player_can_enter(player_ptr, grid.feat, 0) || is_trap(player_ptr, grid.feat)) {
295                 break;
296             }
297
298             y += ddy[dir];
299             x += ddx[dir];
300
301             if (player_can_enter(player_ptr, grid.feat, 0) && !is_trap(player_ptr, grid.feat) && !grid.m_idx) {
302                 msg_print(nullptr);
303                 (void)move_player_effect(player_ptr, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
304             }
305         }
306         break;
307
308     case 8:
309         if (name) {
310             return _("サーペンツタン", "Serpent's Tongue");
311         }
312         if (desc) {
313             return _("毒耐性のないモンスターに大ダメージを与える。", "Attacks a monster with more damage unless it has resistance to poison.");
314         }
315
316         if (cast) {
317             POSITION y, x;
318
319             if (!get_direction(player_ptr, &dir, false, false)) {
320                 return std::nullopt;
321             }
322             if (dir == 5) {
323                 return std::nullopt;
324             }
325
326             y = player_ptr->y + ddy[dir];
327             x = player_ptr->x + ddx[dir];
328
329             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
330                 do_cmd_attack(player_ptr, y, x, HISSATSU_POISON);
331             } else {
332                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
333                 return std::nullopt;
334             }
335         }
336         break;
337
338     case 9:
339         if (name) {
340             return _("斬魔剣弐の太刀", "Zammaken");
341         }
342         if (desc) {
343             return _("生命のない邪悪なモンスターに大ダメージを与えるが、他のモンスターには全く効果がない。",
344                 "Attacks an evil unliving monster with great damage. Has no effect on other monsters.");
345         }
346
347         if (cast) {
348             POSITION y, x;
349
350             if (!get_direction(player_ptr, &dir, false, false)) {
351                 return std::nullopt;
352             }
353             if (dir == 5) {
354                 return std::nullopt;
355             }
356
357             y = player_ptr->y + ddy[dir];
358             x = player_ptr->x + ddx[dir];
359
360             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
361                 do_cmd_attack(player_ptr, y, x, HISSATSU_ZANMA);
362             } else {
363                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
364                 return std::nullopt;
365             }
366         }
367         break;
368
369     case 10:
370         if (name) {
371             return _("裂風剣", "Wind Blast");
372         }
373         if (desc) {
374             return _("攻撃した相手を後方へ吹き飛ばす。", "Attacks an adjacent monster and blows it away.");
375         }
376
377         if (cast) {
378             POSITION y, x;
379
380             if (!get_direction(player_ptr, &dir, false, false)) {
381                 return std::nullopt;
382             }
383             if (dir == 5) {
384                 return std::nullopt;
385             }
386
387             y = player_ptr->y + ddy[dir];
388             x = player_ptr->x + ddx[dir];
389
390             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
391                 do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
392             } else {
393                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
394                 return std::nullopt;
395             }
396             if (dungeons_info[player_ptr->dungeon_idx].flags.has(DungeonFeatureType::NO_MELEE)) {
397                 return "";
398             }
399             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
400                 int i;
401                 POSITION ty = y, tx = x;
402                 POSITION oy = y, ox = x;
403                 MONSTER_IDX m_idx = player_ptr->current_floor_ptr->grid_array[y][x].m_idx;
404                 auto *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
405                 const auto m_name = monster_desc(player_ptr, m_ptr, 0);
406
407                 for (i = 0; i < 5; i++) {
408                     y += ddy[dir];
409                     x += ddx[dir];
410                     if (is_cave_empty_bold(player_ptr, y, x)) {
411                         ty = y;
412                         tx = x;
413                     } else {
414                         break;
415                     }
416                 }
417                 if ((ty != oy) || (tx != ox)) {
418                     msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name.data());
419                     player_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
420                     player_ptr->current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
421                     m_ptr->fy = ty;
422                     m_ptr->fx = tx;
423
424                     update_monster(player_ptr, m_idx, true);
425                     lite_spot(player_ptr, oy, ox);
426                     lite_spot(player_ptr, ty, tx);
427
428                     if (monraces_info[m_ptr->r_idx].brightness_flags.has_any_of(ld_mask)) {
429                         RedrawingFlagsUpdater::get_instance().set_flag(StatusRedrawingFlag::MONSTER_LITE);
430                     }
431                 }
432             }
433         }
434         break;
435
436     case 11:
437         if (name) {
438             return _("刀匠の目利き", "Judge");
439         }
440         if (desc) {
441             return _("武器・防具を1つ識別する。レベル45以上で武器・防具の能力を完全に知ることができる。",
442                 "Identifies a weapon or armor. *Identifies* the item at level 45.");
443         }
444
445         if (cast) {
446             if (plev > 44) {
447                 if (!identify_fully(player_ptr, true)) {
448                     return std::nullopt;
449                 }
450             } else {
451                 if (!ident_spell(player_ptr, true)) {
452                     return std::nullopt;
453                 }
454             }
455         }
456         break;
457
458     case 12:
459         if (name) {
460             return _("破岩斬", "Rock Smash");
461         }
462         if (desc) {
463             return _("岩を壊し、岩石系のモンスターに大ダメージを与える。", "Breaks rock or greatly damages a monster made of rocks.");
464         }
465
466         if (cast) {
467             POSITION y, x;
468
469             if (!get_direction(player_ptr, &dir, false, false)) {
470                 return std::nullopt;
471             }
472             if (dir == 5) {
473                 return std::nullopt;
474             }
475
476             y = player_ptr->y + ddy[dir];
477             x = player_ptr->x + ddx[dir];
478
479             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
480                 do_cmd_attack(player_ptr, y, x, HISSATSU_HAGAN);
481             }
482
483             if (!cave_has_flag_bold(player_ptr->current_floor_ptr, y, x, TerrainCharacteristics::HURT_ROCK)) {
484                 break;
485             }
486
487             /* Destroy the feature */
488             cave_alter_feat(player_ptr, y, x, TerrainCharacteristics::HURT_ROCK);
489             RedrawingFlagsUpdater::get_instance().set_flag(StatusRedrawingFlag::FLOW);
490         }
491         break;
492
493     case 13:
494         if (name) {
495             return _("乱れ雪月花", "Midare-Setsugekka");
496         }
497         if (desc) {
498             return _("攻撃回数が増え、冷気耐性のないモンスターに大ダメージを与える。",
499                 "Attacks a monster with an increased number of attacks and more damage unless it has resistance to cold.");
500         }
501
502         if (cast) {
503             POSITION y, x;
504
505             if (!get_direction(player_ptr, &dir, false, false)) {
506                 return std::nullopt;
507             }
508             if (dir == 5) {
509                 return std::nullopt;
510             }
511
512             y = player_ptr->y + ddy[dir];
513             x = player_ptr->x + ddx[dir];
514
515             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
516                 do_cmd_attack(player_ptr, y, x, HISSATSU_COLD);
517             } else {
518                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
519                 return std::nullopt;
520             }
521         }
522         break;
523
524     case 14:
525         if (name) {
526             return _("急所突き", "Spot Aiming");
527         }
528         if (desc) {
529             return _("モンスターを一撃で倒す攻撃を繰り出す。失敗すると1点しかダメージを与えられない。",
530                 "Attempts to kill a monster instantly. If that fails, causes only 1HP of damage.");
531         }
532
533         if (cast) {
534             POSITION y, x;
535
536             if (!get_direction(player_ptr, &dir, false, false)) {
537                 return std::nullopt;
538             }
539             if (dir == 5) {
540                 return std::nullopt;
541             }
542
543             y = player_ptr->y + ddy[dir];
544             x = player_ptr->x + ddx[dir];
545
546             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
547                 do_cmd_attack(player_ptr, y, x, HISSATSU_KYUSHO);
548             } else {
549                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
550                 return std::nullopt;
551             }
552         }
553         break;
554
555     case 15:
556         if (name) {
557             return _("魔神斬り", "Majingiri");
558         }
559         if (desc) {
560             return _("会心の一撃で攻撃する。攻撃がかわされやすい。", "Attempts to attack with a critical hit, but this attack is easy to evade for a monster.");
561         }
562
563         if (cast) {
564             POSITION y, x;
565
566             if (!get_direction(player_ptr, &dir, false, false)) {
567                 return std::nullopt;
568             }
569             if (dir == 5) {
570                 return std::nullopt;
571             }
572
573             y = player_ptr->y + ddy[dir];
574             x = player_ptr->x + ddx[dir];
575
576             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
577                 do_cmd_attack(player_ptr, y, x, HISSATSU_MAJIN);
578             } else {
579                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
580                 return std::nullopt;
581             }
582         }
583         break;
584
585     case 16:
586         if (name) {
587             return _("捨て身", "Desperate Attack");
588         }
589         if (desc) {
590             return _("強力な攻撃を繰り出す。次のターンまでの間、食らうダメージが増える。",
591                 "Attacks with all of your power, but all damage you take will be doubled for one turn.");
592         }
593
594         if (cast) {
595             POSITION y, x;
596
597             if (!get_direction(player_ptr, &dir, false, false)) {
598                 return std::nullopt;
599             }
600             if (dir == 5) {
601                 return std::nullopt;
602             }
603
604             y = player_ptr->y + ddy[dir];
605             x = player_ptr->x + ddx[dir];
606
607             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
608                 do_cmd_attack(player_ptr, y, x, HISSATSU_SUTEMI);
609             } else {
610                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
611                 return std::nullopt;
612             }
613             player_ptr->sutemi = true;
614         }
615         break;
616
617     case 17:
618         if (name) {
619             return _("雷撃鷲爪斬", "Lightning Eagle");
620         }
621         if (desc) {
622             return _("電撃耐性のないモンスターに非常に大きいダメージを与える。", "Attacks a monster with more damage unless it has resistance to electricity.");
623         }
624
625         if (cast) {
626             POSITION y, x;
627
628             if (!get_direction(player_ptr, &dir, false, false)) {
629                 return std::nullopt;
630             }
631             if (dir == 5) {
632                 return std::nullopt;
633             }
634
635             y = player_ptr->y + ddy[dir];
636             x = player_ptr->x + ddx[dir];
637
638             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
639                 do_cmd_attack(player_ptr, y, x, HISSATSU_ELEC);
640             } else {
641                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
642                 return std::nullopt;
643             }
644         }
645         break;
646
647     case 18:
648         if (name) {
649             return _("入身", "Rush Attack");
650         }
651         if (desc) {
652             return _("素早く相手に近寄り攻撃する。", "Steps close to a monster and attacks at the same time.");
653         }
654
655         if (cast) {
656             if (!rush_attack(player_ptr, nullptr)) {
657                 return std::nullopt;
658             }
659         }
660         break;
661
662     case 19:
663         if (name) {
664             return _("赤流渦", "Bloody Maelstrom");
665         }
666
667         if (desc) {
668             return _("自分自身も傷を作りつつ、その傷が深いほど大きい威力で全方向の敵を攻撃できる。生きていないモンスターには効果がない。",
669                 "Attacks all adjacent monsters with power corresponding to your cuts. Then increases your cuts. Has no effect on unliving monsters.");
670         }
671
672         if (cast) {
673             POSITION y = 0, x = 0;
674             auto current_cut = player_ptr->effects()->cut()->current();
675             short new_cut = current_cut < 300 ? current_cut + 300 : current_cut * 2;
676             (void)BadStatusSetter(player_ptr).set_cut(new_cut);
677             for (dir = 0; dir < 8; dir++) {
678                 y = player_ptr->y + ddy_ddd[dir];
679                 x = player_ptr->x + ddx_ddd[dir];
680                 auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
681                 auto *m_ptr = &player_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
682                 if ((g_ptr->m_idx == 0) || (!m_ptr->ml && !cave_has_flag_bold(player_ptr->current_floor_ptr, y, x, TerrainCharacteristics::PROJECT))) {
683                     continue;
684                 }
685
686                 if (monster_living(m_ptr->r_idx)) {
687                     do_cmd_attack(player_ptr, y, x, HISSATSU_SEKIRYUKA);
688                     continue;
689                 }
690
691                 const auto m_name = monster_desc(player_ptr, m_ptr, 0);
692                 msg_format(_("%sには効果がない!", "%s is unharmed!"), m_name.data());
693             }
694         }
695
696         break;
697     case 20:
698         if (name) {
699             return _("激震撃", "Earthquake Blow");
700         }
701         if (desc) {
702             return _("地震を起こす。", "Shakes dungeon structure, and results in random swapping of floors and walls.");
703         }
704
705         if (cast) {
706             POSITION y, x;
707
708             if (!get_direction(player_ptr, &dir, false, false)) {
709                 return std::nullopt;
710             }
711             if (dir == 5) {
712                 return std::nullopt;
713             }
714
715             y = player_ptr->y + ddy[dir];
716             x = player_ptr->x + ddx[dir];
717
718             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
719                 do_cmd_attack(player_ptr, y, x, HISSATSU_QUAKE);
720             } else {
721                 earthquake(player_ptr, player_ptr->y, player_ptr->x, 10, 0);
722             }
723         }
724         break;
725
726     case 21:
727         if (name) {
728             return _("地走り", "Crack");
729         }
730         if (desc) {
731             return _("衝撃波のビームを放つ。", "Fires a shock wave as a beam.");
732         }
733
734         if (cast) {
735             int total_damage = 0, basedam, i;
736             ItemEntity *o_ptr;
737             if (!get_aim_dir(player_ptr, &dir)) {
738                 return std::nullopt;
739             }
740             msg_print(_("武器を大きく振り下ろした。", "You swing your weapon downward."));
741             for (i = 0; i < 2; i++) {
742                 int damage;
743
744                 if (!has_melee_weapon(player_ptr, INVEN_MAIN_HAND + i)) {
745                     break;
746                 }
747                 o_ptr = &player_ptr->inventory_list[INVEN_MAIN_HAND + i];
748                 basedam = (o_ptr->dd * (o_ptr->ds + 1)) * 50;
749                 damage = o_ptr->to_d * 100;
750                 auto flags = object_flags(o_ptr);
751
752                 // @todo ヴォーパルの多重定義.
753                 if (o_ptr->is_specific_artifact(FixedArtifactId::VORPAL_BLADE) || o_ptr->is_specific_artifact(FixedArtifactId::CHAINSWORD)) {
754                     /* vorpal blade */
755                     basedam *= 5;
756                     basedam /= 3;
757                 } else if (flags.has(TR_VORPAL)) {
758                     /* vorpal flag only */
759                     basedam *= 11;
760                     basedam /= 9;
761                 }
762                 damage += basedam;
763                 damage *= player_ptr->num_blow[i];
764                 total_damage += damage / 200;
765                 if (i) {
766                     total_damage = total_damage * 7 / 10;
767                 }
768             }
769             fire_beam(player_ptr, AttributeType::FORCE, dir, total_damage);
770         }
771         break;
772
773     case 22:
774         if (name) {
775             return _("気迫の雄叫び", "War Cry");
776         }
777         if (desc) {
778             return _("視界内の全モンスターに対して轟音の攻撃を行う。さらに、近くにいるモンスターを怒らせる。",
779                 "Damages all monsters in sight with sound. Aggravates nearby monsters.");
780         }
781
782         if (cast) {
783             msg_print(_("雄叫びをあげた!", "You roar!"));
784             project_all_los(player_ptr, AttributeType::SOUND, randint1(plev * 3));
785             aggravate_monsters(player_ptr, 0);
786         }
787         break;
788
789     case 23:
790         if (name) {
791             return _("無双三段", "Musou-Sandan");
792         }
793         if (desc) {
794             return _("強力な3段攻撃を繰り出す。", "Attacks with three powerful strikes.");
795         }
796
797         if (cast) {
798             int i;
799
800             if (!get_direction(player_ptr, &dir, false, false)) {
801                 return std::nullopt;
802             }
803             if (dir == 5) {
804                 return std::nullopt;
805             }
806
807             for (i = 0; i < 3; i++) {
808                 POSITION y, x;
809                 POSITION ny, nx;
810                 MONSTER_IDX m_idx;
811                 grid_type *g_ptr;
812                 MonsterEntity *m_ptr;
813
814                 y = player_ptr->y + ddy[dir];
815                 x = player_ptr->x + ddx[dir];
816                 g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
817
818                 if (g_ptr->m_idx) {
819                     do_cmd_attack(player_ptr, y, x, HISSATSU_3DAN);
820                 } else {
821                     msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
822                     return std::nullopt;
823                 }
824
825                 if (dungeons_info[player_ptr->dungeon_idx].flags.has(DungeonFeatureType::NO_MELEE)) {
826                     return "";
827                 }
828
829                 /* Monster is dead? */
830                 if (!g_ptr->m_idx) {
831                     break;
832                 }
833
834                 ny = y + ddy[dir];
835                 nx = x + ddx[dir];
836                 m_idx = g_ptr->m_idx;
837                 m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
838
839                 /* Monster cannot move back? */
840                 if (!monster_can_enter(player_ptr, ny, nx, &monraces_info[m_ptr->r_idx], 0)) {
841                     /* -more- */
842                     if (i < 2) {
843                         msg_print(nullptr);
844                     }
845                     continue;
846                 }
847
848                 g_ptr->m_idx = 0;
849                 player_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
850                 m_ptr->fy = ny;
851                 m_ptr->fx = nx;
852
853                 update_monster(player_ptr, m_idx, true);
854
855                 /* Redraw the old spot */
856                 lite_spot(player_ptr, y, x);
857
858                 /* Redraw the new spot */
859                 lite_spot(player_ptr, ny, nx);
860
861                 /* Player can move forward? */
862                 if (player_can_enter(player_ptr, g_ptr->feat, 0)) {
863                     if (!move_player_effect(player_ptr, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP)) {
864                         break;
865                     }
866                 } else {
867                     break;
868                 }
869
870                 /* -more- */
871                 if (i < 2) {
872                     msg_print(nullptr);
873                 }
874             }
875         }
876         break;
877
878     case 24:
879         if (name) {
880             return _("吸血鬼の牙", "Vampire's Fang");
881         }
882         if (desc) {
883             return _("攻撃した相手の体力を吸いとり、自分の体力を回復させる。生命を持たないモンスターには通じない。",
884                 "Attacks with vampiric strikes which absorb HP from a monster and heal you. Has no effect on unliving monsters.");
885         }
886
887         if (cast) {
888             POSITION y, x;
889
890             if (!get_direction(player_ptr, &dir, false, false)) {
891                 return std::nullopt;
892             }
893             if (dir == 5) {
894                 return std::nullopt;
895             }
896
897             y = player_ptr->y + ddy[dir];
898             x = player_ptr->x + ddx[dir];
899
900             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
901                 do_cmd_attack(player_ptr, y, x, HISSATSU_DRAIN);
902             } else {
903                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
904                 return std::nullopt;
905             }
906         }
907         break;
908
909     case 25:
910         if (name) {
911             return _("幻惑", "Moon Dazzling");
912         }
913         if (desc) {
914             return _("視界内の起きている全モンスターに朦朧、混乱、眠りを与えようとする。", "Attempts to stun, confuse and put to sleep all waking monsters.");
915         }
916
917         if (cast) {
918             msg_print(_("武器を不規則に揺らした...", "You irregularly wave your weapon..."));
919             project_all_los(player_ptr, AttributeType::ENGETSU, plev * 4);
920         }
921         break;
922
923     case 26:
924         if (name) {
925             return _("百人斬り", "Hundred Slaughter");
926         }
927         if (desc) {
928             return _("連続して入身でモンスターを攻撃する。攻撃するたびにMPを消費。MPがなくなるか、モンスターを倒せなかったら百人斬りは終了する。",
929                 "Performs a series of rush attacks. The series continues as long as the attacked monster dies and you have sufficient SP.");
930         }
931
932         if (cast) {
933             const int mana_cost_per_monster = 8;
934             bool is_new = true;
935             bool mdeath;
936
937             do {
938                 if (!rush_attack(player_ptr, &mdeath)) {
939                     break;
940                 }
941                 if (is_new) {
942                     /* Reserve needed mana point */
943                     player_ptr->csp -= technic_info[REALM_HISSATSU - MIN_TECHNIC][26].smana;
944                     is_new = false;
945                 } else {
946                     player_ptr->csp -= mana_cost_per_monster;
947                 }
948
949                 if (!mdeath) {
950                     break;
951                 }
952                 command_dir = 0;
953
954                 RedrawingFlagsUpdater::get_instance().set_flag(MainWindowRedrawingFlag::MP);
955                 handle_stuff(player_ptr);
956             } while (player_ptr->csp > mana_cost_per_monster);
957
958             if (is_new) {
959                 return std::nullopt;
960             }
961
962             /* Restore reserved mana */
963             player_ptr->csp += technic_info[REALM_HISSATSU - MIN_TECHNIC][26].smana;
964         }
965         break;
966
967     case 27:
968         if (name) {
969             return _("天翔龍閃", "Dragonic Flash");
970         }
971         if (desc) {
972             return _("視界内の場所を指定して、その場所と自分の間にいる全モンスターを攻撃し、その場所に移動する。",
973                 "Runs toward given location while attacking all monsters on the path.");
974         }
975
976         if (cast) {
977             POSITION y, x;
978
979             if (!tgt_pt(player_ptr, &x, &y)) {
980                 return std::nullopt;
981             }
982
983             const auto is_teleportable = cave_player_teleportable_bold(player_ptr, y, x, TELEPORT_SPONTANEOUS);
984             const auto dist = distance(y, x, player_ptr->y, player_ptr->x);
985             if (!is_teleportable || (dist > MAX_PLAYER_SIGHT / 2) || !projectable(player_ptr, player_ptr->y, player_ptr->x, y, x)) {
986                 msg_print(_("失敗!", "You cannot move to that place!"));
987                 break;
988             }
989             if (player_ptr->anti_tele) {
990                 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
991                 break;
992             }
993             project(player_ptr, 0, 0, y, x, HISSATSU_ISSEN, AttributeType::ATTACK, PROJECT_BEAM | PROJECT_KILL);
994             teleport_player_to(player_ptr, y, x, TELEPORT_SPONTANEOUS);
995         }
996         break;
997
998     case 28:
999         if (name) {
1000             return _("二重の剣撃", "Twin Slash");
1001         }
1002         if (desc) {
1003             return _("1ターンで2度攻撃を行う。", "Attack twice in one turn.");
1004         }
1005
1006         if (cast) {
1007             POSITION x, y;
1008
1009             if (!get_rep_dir(player_ptr, &dir, false)) {
1010                 return std::nullopt;
1011             }
1012
1013             y = player_ptr->y + ddy[dir];
1014             x = player_ptr->x + ddx[dir];
1015
1016             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
1017                 do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
1018                 if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
1019                     handle_stuff(player_ptr);
1020                     do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
1021                 }
1022             } else {
1023                 msg_print(_("その方向にはモンスターはいません。", "You don't see any monster in this direction"));
1024                 return std::nullopt;
1025             }
1026         }
1027         break;
1028
1029     case 29:
1030         if (name) {
1031             return _("虎伏絶刀勢", "Kofuku-Zettousei");
1032         }
1033         if (desc) {
1034             return _("強力な攻撃を行い、近くの場所にも効果が及ぶ。", "Performs a powerful attack which even affects nearby monsters.");
1035         }
1036
1037         if (cast) {
1038             int total_damage = 0, basedam, i;
1039             POSITION y, x;
1040             ItemEntity *o_ptr;
1041
1042             if (!get_direction(player_ptr, &dir, false, false)) {
1043                 return std::nullopt;
1044             }
1045             if (dir == 5) {
1046                 return std::nullopt;
1047             }
1048
1049             y = player_ptr->y + ddy[dir];
1050             x = player_ptr->x + ddx[dir];
1051
1052             if (dungeons_info[player_ptr->dungeon_idx].flags.has(DungeonFeatureType::NO_MELEE)) {
1053                 msg_print(_("なぜか攻撃することができない。", "Something prevents you from attacking."));
1054                 return "";
1055             }
1056             msg_print(_("武器を大きく振り下ろした。", "You swing your weapon downward."));
1057             for (i = 0; i < 2; i++) {
1058                 int damage;
1059                 if (!has_melee_weapon(player_ptr, INVEN_MAIN_HAND + i)) {
1060                     break;
1061                 }
1062                 o_ptr = &player_ptr->inventory_list[INVEN_MAIN_HAND + i];
1063                 basedam = (o_ptr->dd * (o_ptr->ds + 1)) * 50;
1064                 damage = o_ptr->to_d * 100;
1065                 auto flags = object_flags(o_ptr);
1066
1067                 // @todo ヴォーパルの多重定義.
1068                 if (o_ptr->is_specific_artifact(FixedArtifactId::VORPAL_BLADE) || o_ptr->is_specific_artifact(FixedArtifactId::CHAINSWORD)) {
1069                     /* vorpal blade */
1070                     basedam *= 5;
1071                     basedam /= 3;
1072                 } else if (flags.has(TR_VORPAL)) {
1073                     /* vorpal flag only */
1074                     basedam *= 11;
1075                     basedam /= 9;
1076                 }
1077                 damage += basedam;
1078                 damage += player_ptr->to_d[i] * 100;
1079                 damage *= player_ptr->num_blow[i];
1080                 total_damage += (damage / 100);
1081             }
1082
1083             auto *floor_ptr = player_ptr->current_floor_ptr;
1084             const auto is_bold = cave_has_flag_bold(floor_ptr, y, x, TerrainCharacteristics::PROJECT);
1085             constexpr auto flags = PROJECT_KILL | PROJECT_JUMP | PROJECT_ITEM;
1086             project(player_ptr, 0, (is_bold ? 5 : 0), y, x, total_damage * 3 / 2, AttributeType::METEOR, flags);
1087         }
1088         break;
1089
1090     case 30:
1091         if (name) {
1092             return _("慶雲鬼忍剣", "Keiun-Kininken");
1093         }
1094         if (desc) {
1095             return _("自分もダメージをくらうが、相手に非常に大きなダメージを与える。アンデッドには特に効果がある。",
1096                 "Attacks a monster with extremely powerful damage, but you also take some damage. Hurts an undead monster greatly.");
1097         }
1098
1099         if (cast) {
1100             POSITION y, x;
1101
1102             if (!get_direction(player_ptr, &dir, false, false)) {
1103                 return std::nullopt;
1104             }
1105             if (dir == 5) {
1106                 return std::nullopt;
1107             }
1108
1109             y = player_ptr->y + ddy[dir];
1110             x = player_ptr->x + ddx[dir];
1111
1112             if (player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
1113                 do_cmd_attack(player_ptr, y, x, HISSATSU_UNDEAD);
1114             } else {
1115                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
1116                 return std::nullopt;
1117             }
1118             take_hit(player_ptr, DAMAGE_NOESCAPE, 100 + randint1(100), _("慶雲鬼忍剣を使った衝撃", "exhaustion on using Keiun-Kininken"));
1119         }
1120         break;
1121
1122     case 31:
1123         if (name) {
1124             return _("切腹", "Harakiri");
1125         }
1126         if (desc) {
1127             return _("「武士道とは、死ぬことと見つけたり。」", "'Bushido, the way of warriors, is found in death'");
1128         }
1129
1130         if (cast) {
1131             int i;
1132             if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) {
1133                 return std::nullopt;
1134             }
1135             /* Special Verification for suicide */
1136             prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
1137
1138             flush();
1139             i = inkey();
1140             prt("", 0, 0);
1141             if (i != '@') {
1142                 return std::nullopt;
1143             }
1144             if (w_ptr->total_winner) {
1145                 take_hit(player_ptr, DAMAGE_FORCE, 9999, "Seppuku");
1146                 w_ptr->total_winner = true;
1147             } else {
1148                 msg_print(_("武士道とは、死ぬことと見つけたり。", "The meaning of bushido is found in death."));
1149                 take_hit(player_ptr, DAMAGE_FORCE, 9999, "Seppuku");
1150             }
1151         }
1152         break;
1153     }
1154
1155     return "";
1156 }