OSDN Git Service

[Refactor] #2680 MAX_SIGHTとAAF_LIMITが分かりにくかったので分かりやすい定数名に変更した
[hengbandforosx/hengbandosx.git] / src / realm / realm-hex.cpp
1 /*!
2  * @brief 呪術の処理実装 / Hex code
3  * @date 2014/01/14
4  * @author
5  * 2014 Deskull rearranged comment for Doxygen.\n
6  */
7
8 #include "realm/realm-hex.h"
9 #include "cmd-action/cmd-spell.h"
10 #include "cmd-item/cmd-quaff.h"
11 #include "core/asking-player.h"
12 #include "core/player-redraw-types.h"
13 #include "core/player-update-types.h"
14 #include "effect/attribute-types.h"
15 #include "effect/effect-characteristics.h"
16 #include "effect/effect-processor.h"
17 #include "flavor/flavor-describer.h"
18 #include "flavor/object-flavor-types.h"
19 #include "floor/cave.h"
20 #include "floor/floor-object.h"
21 #include "floor/geometry.h"
22 #include "inventory/inventory-slot-types.h"
23 #include "io/input-key-requester.h"
24 #include "monster-race/monster-race.h"
25 #include "object-enchant/object-curse.h"
26 #include "object-enchant/tr-types.h"
27 #include "object-enchant/trc-types.h"
28 #include "object-hook/hook-armor.h"
29 #include "object/item-tester-hooker.h"
30 #include "object/item-use-flags.h"
31 #include "object/object-flags.h"
32 #include "player/attack-defense-types.h"
33 #include "player/player-skill.h"
34 #include "player/player-status.h"
35 #include "spell-kind/magic-item-recharger.h"
36 #include "spell-kind/spells-launcher.h"
37 #include "spell-kind/spells-neighbor.h"
38 #include "spell-kind/spells-sight.h"
39 #include "spell-kind/spells-teleport.h"
40 #include "spell-realm/spells-hex.h"
41 #include "spell/spells-execution.h"
42 #include "spell/spells-status.h"
43 #include "spell/technic-info-table.h"
44 #include "status/action-setter.h"
45 #include "system/floor-type-definition.h"
46 #include "system/grid-type-definition.h"
47 #include "system/object-type-definition.h"
48 #include "system/player-type-definition.h"
49 #include "target/grid-selector.h"
50 #include "target/target-getter.h"
51 #include "term/screen-processor.h"
52 #include "util/bit-flags-calculator.h"
53 #include "view/display-messages.h"
54 #include "world/world.h"
55
56 #ifdef JP
57 #else
58 #include "player-info/equipment-info.h"
59 #endif
60
61 /*!
62  * @brief 呪術領域の武器呪縛の対象にできる武器かどうかを返す。 / An "item_tester_hook" for offer
63  * @param o_ptr オブジェクト構造体の参照ポインタ
64  * @return 呪縛可能な武器ならばTRUEを返す
65  */
66 static bool item_tester_hook_weapon_except_bow(const ObjectType *o_ptr)
67 {
68     switch (o_ptr->tval) {
69     case ItemKindType::SWORD:
70     case ItemKindType::HAFTED:
71     case ItemKindType::POLEARM:
72     case ItemKindType::DIGGING:
73         return true;
74     default:
75         return false;
76     }
77 }
78
79 /*!
80  * @brief 呪術領域魔法の各処理を行う
81  * @param spell 魔法ID
82  * @param mode 処理内容 (SpellProcessType::NAME / SPELL_DESC / SpellProcessType::INFO / SpellProcessType::CAST / SPELL_CONT / SpellProcessType::STOP)
83  * @return SpellProcessType::NAME / SPELL_DESC / SpellProcessType::INFO 時には文字列ポインタを返す。SpellProcessType::CAST / SPELL_CONT / SpellProcessType::STOP 時はnullptr文字列を返す。
84  */
85 concptr do_hex_spell(PlayerType *player_ptr, spell_hex_type spell, SpellProcessType mode)
86 {
87     auto name = mode == SpellProcessType::NAME;
88     auto description = mode == SpellProcessType::DESCRIPTION;
89     auto info = mode == SpellProcessType::INFO;
90     auto cast = mode == SpellProcessType::CAST;
91     auto continuation = mode == SpellProcessType::CONTNUATION;
92     auto stop = mode == SpellProcessType::STOP;
93     auto should_continue = true;
94     int power;
95     switch (spell) {
96         /*** 1st book (0-7) ***/
97     case HEX_BLESS:
98         if (name) {
99             return _("邪なる祝福", "Evily blessing");
100         }
101         if (description) {
102             return _("祝福により攻撃精度と防御力が上がる。", "Attempts to increase +to_hit of a weapon and AC");
103         }
104         if (cast) {
105             if (!player_ptr->blessed) {
106                 msg_print(_("高潔な気分になった!", "You feel righteous!"));
107             }
108         }
109         if (stop) {
110             if (!player_ptr->blessed) {
111                 msg_print(_("高潔な気分が消え失せた。", "The prayer has expired."));
112             }
113         }
114         break;
115
116     case HEX_CURE_LIGHT:
117         if (name) {
118             return _("軽傷の治癒", "Cure light wounds");
119         }
120         if (description) {
121             return _("HPや傷を少し回復させる。", "Heals cuts and HP a little.");
122         }
123         if (info) {
124             return info_heal(1, 10, 0);
125         }
126         if (cast) {
127             msg_print(_("気分が良くなってくる。", "You feel a little better."));
128         }
129         if (cast || continuation) {
130             (void)cure_light_wounds(player_ptr, 1, 10);
131         }
132         break;
133
134     case HEX_DEMON_AURA:
135         if (name) {
136             return _("悪魔のオーラ", "Demonic aura");
137         }
138         if (description) {
139             return _("炎のオーラを身にまとい、回復速度が速くなる。", "Gives fire aura and regeneration.");
140         }
141         if (cast) {
142             msg_print(_("体が炎のオーラで覆われた。", "You are enveloped by a fiery aura!"));
143         }
144         if (stop) {
145             msg_print(_("炎のオーラが消え去った。", "The fiery aura disappeared."));
146         }
147         break;
148
149     case HEX_STINKING_MIST:
150         if (name) {
151             return _("悪臭霧", "Stinking mist");
152         }
153         if (description) {
154             return _("視界内のモンスターに微弱量の毒のダメージを与える。", "Deals a little poison damage to all monsters in your sight.");
155         }
156         power = player_ptr->lev / 2 + 5;
157         if (info) {
158             return info_damage(1, power, 0);
159         }
160         if (cast || continuation) {
161             project_all_los(player_ptr, AttributeType::POIS, randint1(power));
162         }
163         break;
164
165     case HEX_XTRA_MIGHT:
166         if (name) {
167             return _("腕力強化", "Extra might");
168         }
169         if (description) {
170             return _("術者の腕力を上昇させる。", "Attempts to increase your strength.");
171         }
172         if (cast) {
173             msg_print(_("何だか力が湧いて来る。", "You feel stronger."));
174         }
175         break;
176
177     case HEX_CURSE_WEAPON:
178         if (name) {
179             return _("武器呪縛", "Curse weapon");
180         }
181         if (description) {
182             return _("装備している武器を呪う。", "Curses your weapon.");
183         }
184         if (cast) {
185             OBJECT_IDX item;
186             concptr q, s;
187             GAME_TEXT o_name[MAX_NLEN];
188             ObjectType *o_ptr;
189
190             q = _("どれを呪いますか?", "Which weapon do you curse?");
191             s = _("武器を装備していない。", "You're not wielding a weapon.");
192
193             o_ptr = choose_object(player_ptr, &item, q, s, (USE_EQUIP), FuncItemTester(item_tester_hook_weapon_except_bow));
194             if (!o_ptr) {
195                 return "";
196             }
197
198             describe_flavor(player_ptr, o_name, o_ptr, OD_NAME_ONLY);
199             auto f = object_flags(o_ptr);
200
201             if (!get_check(format(_("本当に %s を呪いますか?", "Do you curse %s, really?"), o_name))) {
202                 return "";
203             }
204
205             if (!one_in_(3) && (o_ptr->is_artifact() || f.has(TR_BLESSED))) {
206                 msg_format(_("%s は呪いを跳ね返した。", "%s resists the effect."), o_name);
207                 if (one_in_(3)) {
208                     if (o_ptr->to_d > 0) {
209                         o_ptr->to_d -= randint1(3) % 2;
210                         if (o_ptr->to_d < 0) {
211                             o_ptr->to_d = 0;
212                         }
213                     }
214                     if (o_ptr->to_h > 0) {
215                         o_ptr->to_h -= randint1(3) % 2;
216                         if (o_ptr->to_h < 0) {
217                             o_ptr->to_h = 0;
218                         }
219                     }
220                     if (o_ptr->to_a > 0) {
221                         o_ptr->to_a -= randint1(3) % 2;
222                         if (o_ptr->to_a < 0) {
223                             o_ptr->to_a = 0;
224                         }
225                     }
226                     msg_format(_("%s は劣化してしまった。", "Your %s was disenchanted!"), o_name);
227                 }
228             } else {
229                 int curse_rank = 0;
230                 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
231                 o_ptr->curse_flags.set(CurseTraitType::CURSED);
232
233                 if (o_ptr->is_artifact() || o_ptr->is_ego()) {
234
235                     if (one_in_(3)) {
236                         o_ptr->curse_flags.set(CurseTraitType::HEAVY_CURSE);
237                     }
238                     if (one_in_(666)) {
239                         o_ptr->curse_flags.set(CurseTraitType::TY_CURSE);
240                         if (one_in_(666)) {
241                             o_ptr->curse_flags.set(CurseTraitType::PERMA_CURSE);
242                         }
243
244                         o_ptr->art_flags.set(TR_AGGRAVATE);
245                         o_ptr->art_flags.set(TR_VORPAL);
246                         o_ptr->art_flags.set(TR_VAMPIRIC);
247                         msg_print(_("血だ!血だ!血だ!", "Blood, Blood, Blood!"));
248                         curse_rank = 2;
249                     }
250                 }
251
252                 o_ptr->curse_flags.set(get_curse(curse_rank, o_ptr));
253             }
254
255             player_ptr->update |= (PU_BONUS);
256             should_continue = false;
257         }
258         break;
259
260     case HEX_DETECT_EVIL:
261         if (name) {
262             return _("邪悪感知", "Evil detection");
263         }
264         if (description) {
265             return _("周囲の邪悪なモンスターを感知する。", "Detects evil monsters.");
266         }
267         if (info) {
268             return info_range(MAX_PLAYER_SIGHT);
269         }
270         if (cast) {
271             msg_print(_("邪悪な生物の存在を感じ取ろうとした。", "You sense the presence of evil creatures."));
272         }
273         break;
274
275     case HEX_PATIENCE: {
276         if (name) {
277             return _("我慢", "Patience");
278         }
279
280         if (description) {
281             return _("数ターン攻撃を耐えた後、受けたダメージを地獄の業火として周囲に放出する。", "Bursts hell fire strongly after enduring damage for a few turns.");
282         }
283
284         SpellHex spell_hex(player_ptr);
285         power = std::min(200, spell_hex.get_revenge_power() * 2);
286         if (info) {
287             return info_damage(0, 0, power);
288         }
289
290         if (cast) {
291             int a = 3 - (player_ptr->pspeed - 100) / 10;
292             byte r = 3 + randint1(3) + std::max(0, std::min(3, a));
293
294             if (spell_hex.get_revenge_turn() > 0) {
295                 msg_print(_("すでに我慢をしている。", "You are already biding your time for vengeance."));
296                 return nullptr;
297             }
298
299             spell_hex.set_revenge_type(SpellHexRevengeType::PATIENCE);
300             spell_hex.set_revenge_turn(r, true);
301             spell_hex.set_revenge_power(0, true);
302             msg_print(_("じっと耐えることにした。", "You decide to endure damage for future retribution."));
303             should_continue = false;
304         }
305
306         if (continuation) {
307             POSITION rad = 2 + (power / 50);
308             spell_hex.set_revenge_turn(1, false);
309             if ((spell_hex.get_revenge_turn() == 0) || (power >= 200)) {
310                 msg_print(_("我慢が解かれた!", "My patience is at an end!"));
311                 if (power) {
312                     project(player_ptr, 0, rad, player_ptr->y, player_ptr->x, power, AttributeType::HELL_FIRE, (PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL));
313                 }
314
315                 if (w_ptr->wizard) {
316                     msg_format(_("%d点のダメージを返した。", "You return %d damage."), power);
317                 }
318
319                 spell_hex.set_revenge_type(SpellHexRevengeType::NONE);
320                 spell_hex.set_revenge_turn(0, true);
321                 spell_hex.set_revenge_power(0, true);
322             }
323         }
324         break;
325     }
326
327         /*** 2nd book (8-15) ***/
328     case HEX_ICE_ARMOR:
329         if (name) {
330             return _("氷の鎧", "Armor of ice");
331         }
332         if (description) {
333             return _("氷のオーラを身にまとい、防御力が上昇する。", "Surrounds you with an icy aura and gives a bonus to AC.");
334         }
335         if (cast) {
336             msg_print(_("体が氷の鎧で覆われた。", "You are enveloped by icy armor!"));
337         }
338         if (stop) {
339             msg_print(_("氷の鎧が消え去った。", "The icy armor disappeared."));
340         }
341         break;
342
343     case HEX_CURE_SERIOUS:
344         if (name) {
345             return _("重傷の治癒", "Cure serious wounds");
346         }
347         if (description) {
348             return _("体力や傷を多少回復させる。", "Heals cuts and HP.");
349         }
350         if (info) {
351             return info_heal(2, 10, 0);
352         }
353         if (cast) {
354             msg_print(_("気分が良くなってくる。", "You feel better."));
355         }
356         if (cast || continuation) {
357             (void)cure_serious_wounds(player_ptr, 2, 10);
358         }
359         break;
360
361     case HEX_INHALE: {
362         if (name) {
363             return _("薬品吸入", "Inhale potion");
364         }
365
366         if (description) {
367             return _("呪文詠唱を中止することなく、薬の効果を得ることができる。", "Quaffs a potion without canceling spell casting.");
368         }
369
370         SpellHex spell_hex(player_ptr);
371         if (cast) {
372             spell_hex.set_casting_flag(HEX_INHALE);
373             do_cmd_quaff_potion(player_ptr);
374             spell_hex.reset_casting_flag(HEX_INHALE);
375             should_continue = false;
376         }
377
378         break;
379     }
380     case HEX_VAMP_MIST:
381         if (name) {
382             return _("衰弱の霧", "Hypodynamic mist");
383         }
384         if (description) {
385             return _("視界内のモンスターに微弱量の衰弱属性のダメージを与える。", "Deals a little life-draining damage to all monsters in your sight.");
386         }
387         power = (player_ptr->lev / 2) + 5;
388         if (info) {
389             return info_damage(1, power, 0);
390         }
391         if (cast || continuation) {
392             project_all_los(player_ptr, AttributeType::HYPODYNAMIA, randint1(power));
393         }
394         break;
395
396     case HEX_RUNESWORD:
397         if (name) {
398             return _("魔剣化", "Swords to runeswords");
399         }
400         if (description) {
401             return _("武器の攻撃力を上げる。切れ味を得、呪いに応じて与えるダメージが上昇し、善良なモンスターに対するダメージが2倍になる。",
402                 "Gives vorpal ability to your weapon. Increases damage from your weapon acccording to curse of your weapon.");
403         }
404         if (cast) {
405 #ifdef JP
406             msg_print("あなたの武器が黒く輝いた。");
407 #else
408             if (!empty_hands(player_ptr, false)) {
409                 msg_print("Your weapons glow bright black.");
410             } else {
411                 msg_print("Your weapon glows bright black.");
412             }
413 #endif
414         }
415         if (stop) {
416 #ifdef JP
417             msg_print("武器の輝きが消え去った。");
418 #else
419             msg_format("Your weapon%s.", (empty_hands(player_ptr, false)) ? " no longer glows" : "s no longer glow");
420 #endif
421         }
422         break;
423
424     case HEX_CONFUSION:
425         if (name) {
426             return _("混乱の手", "Touch of confusion");
427         }
428         if (description) {
429             return _("攻撃した際モンスターを混乱させる。", "Confuses a monster when you attack.");
430         }
431         if (cast) {
432             msg_print(_("あなたの手が赤く輝き始めた。", "Your hands glow bright red."));
433         }
434         if (stop) {
435             msg_print(_("手の輝きがなくなった。", "Your hands no longer glow."));
436         }
437         break;
438
439     case HEX_BUILDING:
440         if (name) {
441             return _("肉体強化", "Building up");
442         }
443         if (description) {
444             return _(
445                 "術者の腕力、器用さ、耐久力を上昇させる。攻撃回数の上限を 1 増加させる。", "Attempts to increases your strength, dexterity and constitusion.");
446         }
447         if (cast) {
448             msg_print(_("身体が強くなった気がした。", "You feel your body is more developed now."));
449         }
450         break;
451
452     case HEX_ANTI_TELE:
453         if (name) {
454             return _("反テレポート結界", "Anti teleport barrier");
455         }
456         if (description) {
457             return _("視界内のモンスターのテレポートを阻害するバリアを張る。", "Obstructs all teleportations by monsters in your sight.");
458         }
459         power = player_ptr->lev * 3 / 2;
460         if (info) {
461             return info_power(power);
462         }
463         if (cast) {
464             msg_print(_("テレポートを防ぐ呪いをかけた。", "You feel anyone can not teleport except you."));
465         }
466         break;
467
468         /*** 3rd book (16-23) ***/
469     case HEX_SHOCK_CLOAK:
470         if (name) {
471             return _("衝撃のクローク", "Cloak of shock");
472         }
473         if (description) {
474             return _("電気のオーラを身にまとい、動きが速くなる。", "Gives lightning aura and a bonus to speed.");
475         }
476         if (cast) {
477             msg_print(_("体が稲妻のオーラで覆われた。", "You are enveloped by an electrical aura!"));
478         }
479         if (stop) {
480             msg_print(_("稲妻のオーラが消え去った。", "The electrical aura disappeared."));
481         }
482         break;
483
484     case HEX_CURE_CRITICAL:
485         if (name) {
486             return _("致命傷の治癒", "Cure critical wounds");
487         }
488         if (description) {
489             return _("体力や傷を回復させる。", "Heals cuts and HP greatly.");
490         }
491         if (info) {
492             return info_heal(4, 10, 0);
493         }
494         if (cast) {
495             msg_print(_("気分が良くなってくる。", "You feel much better."));
496         }
497         if (cast || continuation) {
498             (void)cure_critical_wounds(player_ptr, damroll(4, 10));
499         }
500         break;
501
502     case HEX_RECHARGE:
503         if (name) {
504             return _("呪力封入", "Recharging");
505         }
506         if (description) {
507             return _("魔法の道具に魔力を再充填する。", "Recharges a magic device.");
508         }
509         power = player_ptr->lev * 2;
510         if (info) {
511             return info_power(power);
512         }
513         if (cast) {
514             if (!recharge(player_ptr, power)) {
515                 return nullptr;
516             }
517             should_continue = false;
518         }
519         break;
520
521     case HEX_RAISE_DEAD:
522         if (name) {
523             return _("死者復活", "Animate Dead");
524         }
525         if (description) {
526             return _("死体を蘇らせてペットにする。", "Raises corpses and skeletons from dead.");
527         }
528         if (cast) {
529             msg_print(_("死者への呼びかけを始めた。", "You start to call the dead.!"));
530         }
531         if (cast || continuation) {
532             animate_dead(player_ptr, 0, player_ptr->y, player_ptr->x);
533         }
534         break;
535
536     case HEX_CURSE_ARMOUR:
537         if (name) {
538             return _("防具呪縛", "Curse armor");
539         }
540         if (description) {
541             return _("装備している防具に呪いをかける。", "Curse a piece of armour that you are wielding.");
542         }
543         if (cast) {
544             OBJECT_IDX item;
545             concptr q, s;
546             GAME_TEXT o_name[MAX_NLEN];
547             ObjectType *o_ptr;
548
549             q = _("どれを呪いますか?", "Which piece of armour do you curse?");
550             s = _("防具を装備していない。", "You're not wearing any armor.");
551
552             o_ptr = choose_object(player_ptr, &item, q, s, (USE_EQUIP), FuncItemTester(&ObjectType::is_armour));
553             if (!o_ptr) {
554                 return "";
555             }
556
557             o_ptr = &player_ptr->inventory_list[item];
558             describe_flavor(player_ptr, o_name, o_ptr, OD_NAME_ONLY);
559             auto f = object_flags(o_ptr);
560
561             if (!get_check(format(_("本当に %s を呪いますか?", "Do you curse %s, really?"), o_name))) {
562                 return "";
563             }
564
565             if (!one_in_(3) && (o_ptr->is_artifact() || f.has(TR_BLESSED))) {
566                 msg_format(_("%s は呪いを跳ね返した。", "%s resists the effect."), o_name);
567                 if (one_in_(3)) {
568                     if (o_ptr->to_d > 0) {
569                         o_ptr->to_d -= randint1(3) % 2;
570                         if (o_ptr->to_d < 0) {
571                             o_ptr->to_d = 0;
572                         }
573                     }
574                     if (o_ptr->to_h > 0) {
575                         o_ptr->to_h -= randint1(3) % 2;
576                         if (o_ptr->to_h < 0) {
577                             o_ptr->to_h = 0;
578                         }
579                     }
580                     if (o_ptr->to_a > 0) {
581                         o_ptr->to_a -= randint1(3) % 2;
582                         if (o_ptr->to_a < 0) {
583                             o_ptr->to_a = 0;
584                         }
585                     }
586                     msg_format(_("%s は劣化してしまった。", "Your %s was disenchanted!"), o_name);
587                 }
588             } else {
589                 int curse_rank = 0;
590                 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
591                 o_ptr->curse_flags.set(CurseTraitType::CURSED);
592
593                 if (o_ptr->is_artifact() || o_ptr->is_ego()) {
594
595                     if (one_in_(3)) {
596                         o_ptr->curse_flags.set(CurseTraitType::HEAVY_CURSE);
597                     }
598                     if (one_in_(666)) {
599                         o_ptr->curse_flags.set(CurseTraitType::TY_CURSE);
600                         if (one_in_(666)) {
601                             o_ptr->curse_flags.set(CurseTraitType::PERMA_CURSE);
602                         }
603
604                         o_ptr->art_flags.set(TR_AGGRAVATE);
605                         o_ptr->art_flags.set(TR_RES_POIS);
606                         o_ptr->art_flags.set(TR_RES_DARK);
607                         o_ptr->art_flags.set(TR_RES_NETHER);
608                         msg_print(_("血だ!血だ!血だ!", "Blood, Blood, Blood!"));
609                         curse_rank = 2;
610                     }
611                 }
612
613                 o_ptr->curse_flags.set(get_curse(curse_rank, o_ptr));
614             }
615
616             player_ptr->update |= (PU_BONUS);
617             should_continue = false;
618         }
619         break;
620
621     case HEX_SHADOW_CLOAK:
622         if (name) {
623             return _("影のクローク", "Cloak of shadow");
624         }
625         if (description) {
626             return _("影のオーラを身にまとい、敵に影のダメージを与える。", "Gives aura of shadow.");
627         }
628         if (cast) {
629             auto *o_ptr = &player_ptr->inventory_list[INVEN_OUTER];
630
631             if (!o_ptr->k_idx) {
632                 msg_print(_("クロークを身につけていない!", "You are not wearing a cloak."));
633                 return nullptr;
634             } else if (!o_ptr->is_cursed()) {
635                 msg_print(_("クロークは呪われていない!", "Your cloak is not cursed."));
636                 return nullptr;
637             } else {
638                 msg_print(_("影のオーラを身にまとった。", "You are enveloped by a shadowy aura!"));
639             }
640         }
641         if (continuation) {
642             auto *o_ptr = &player_ptr->inventory_list[INVEN_OUTER];
643
644             if ((!o_ptr->k_idx) || (!o_ptr->is_cursed())) {
645                 exe_spell(player_ptr, REALM_HEX, spell, SpellProcessType::STOP);
646                 SpellHex spell_hex(player_ptr);
647                 spell_hex.reset_casting_flag(spell);
648                 if (!spell_hex.is_spelling_any()) {
649                     set_action(player_ptr, ACTION_NONE);
650                 }
651             }
652         }
653         if (stop) {
654             msg_print(_("影のオーラが消え去った。", "The shadowy aura disappeared."));
655         }
656         break;
657
658     case HEX_PAIN_TO_MANA:
659         if (name) {
660             return _("苦痛を魔力に", "Pain to mana");
661         }
662         if (description) {
663             return _("視界内のモンスターに精神ダメージ与え、魔力を吸い取る。", "Deals psychic damage to all monsters in sight and drains some mana.");
664         }
665         power = player_ptr->lev * 3 / 2;
666         if (info) {
667             return info_damage(1, power, 0);
668         }
669         if (cast || continuation) {
670             project_all_los(player_ptr, AttributeType::PSI_DRAIN, randint1(power));
671         }
672         break;
673
674     case HEX_EYE_FOR_EYE:
675         if (name) {
676             return _("目には目を", "Eye for an eye");
677         }
678         if (description) {
679             return _("打撃や魔法で受けたダメージを、攻撃元のモンスターにも与える。", "Returns same damage which you got to the monster which damaged you.");
680         }
681         if (cast) {
682             msg_print(_("復讐したい欲望にかられた。", "You feel very vengeful."));
683         }
684         break;
685
686         /*** 4th book (24-31) ***/
687     case HEX_ANTI_MULTI:
688         if (name) {
689             return _("反増殖結界", "Anti multiply barrier");
690         }
691         if (description) {
692             return _("その階の増殖するモンスターの増殖を阻止する。", "Obstructs all multiplying by monsters on entire floor.");
693         }
694         if (cast) {
695             msg_print(_("増殖を阻止する呪いをかけた。", "You feel anyone can not multiply."));
696         }
697         break;
698
699     case HEX_RESTORE:
700         if (name) {
701             return _("全復活", "Restoration");
702         }
703         if (description) {
704             return _("経験値を徐々に復活し、減少した能力値を回復させる。", "Restores experience and status.");
705         }
706         if (cast) {
707             msg_print(_("体が元の活力を取り戻し始めた。", "You feel your lost status starting to return."));
708         }
709         if (cast || continuation) {
710             bool flag = false;
711             int d = (player_ptr->max_exp - player_ptr->exp);
712             int r = (player_ptr->exp / 20);
713             int i;
714
715             if (d > 0) {
716                 if (d < r) {
717                     player_ptr->exp = player_ptr->max_exp;
718                 } else {
719                     player_ptr->exp += r;
720                 }
721
722                 /* Check the experience */
723                 check_experience(player_ptr);
724
725                 flag = true;
726             }
727             for (i = A_STR; i < A_MAX; i++) {
728                 if (player_ptr->stat_cur[i] < player_ptr->stat_max[i]) {
729                     if (player_ptr->stat_cur[i] < 18) {
730                         player_ptr->stat_cur[i]++;
731                     } else {
732                         player_ptr->stat_cur[i] += 10;
733                     }
734
735                     if (player_ptr->stat_cur[i] > player_ptr->stat_max[i]) {
736                         player_ptr->stat_cur[i] = player_ptr->stat_max[i];
737                     }
738                     player_ptr->update |= (PU_BONUS);
739
740                     flag = true;
741                 }
742             }
743
744             if (!flag) {
745                 msg_format(_("%sの呪文の詠唱をやめた。", "Finish casting '%^s'."), exe_spell(player_ptr, REALM_HEX, HEX_RESTORE, SpellProcessType::NAME));
746                 SpellHex spell_hex(player_ptr);
747                 spell_hex.reset_casting_flag(HEX_RESTORE);
748                 if (!spell_hex.is_spelling_any()) {
749                     set_action(player_ptr, ACTION_NONE);
750                 }
751
752                 player_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
753                 player_ptr->redraw |= (PR_EXTRA);
754
755                 return "";
756             }
757         }
758         break;
759
760     case HEX_DRAIN_CURSE:
761         if (name) {
762             return _("呪力吸収", "Drain curse power");
763         }
764         if (description) {
765             return _("呪われた装備品の呪いを吸収して魔力を回復する。", "Drains curse on your equipment and heals SP a little.");
766         }
767         if (cast) {
768             OBJECT_IDX item;
769             concptr s, q;
770             ObjectType *o_ptr;
771
772             q = _("どの装備品から吸収しますか?", "Which cursed equipment do you drain mana from?");
773             s = _("呪われたアイテムを装備していない。", "You have no cursed equipment.");
774
775             o_ptr = choose_object(player_ptr, &item, q, s, (USE_EQUIP), FuncItemTester(&ObjectType::is_cursed));
776             if (!o_ptr) {
777                 return "";
778             }
779
780             auto f = object_flags(o_ptr);
781
782             player_ptr->csp += (player_ptr->lev / 5) + randint1(player_ptr->lev / 5);
783             if (f.has(TR_TY_CURSE) || o_ptr->curse_flags.has(CurseTraitType::TY_CURSE)) {
784                 player_ptr->csp += randint1(5);
785             }
786             if (player_ptr->csp > player_ptr->msp) {
787                 player_ptr->csp = player_ptr->msp;
788             }
789
790             if (o_ptr->curse_flags.has(CurseTraitType::PERMA_CURSE)) {
791                 /* Nothing */
792             } else if (o_ptr->curse_flags.has(CurseTraitType::HEAVY_CURSE)) {
793                 if (one_in_(7)) {
794                     msg_print(_("呪いを全て吸い取った。", "A heavy curse vanished."));
795                     o_ptr->curse_flags.clear();
796                 }
797             } else if (o_ptr->curse_flags.has(CurseTraitType::CURSED) && one_in_(3)) {
798                 msg_print(_("呪いを全て吸い取った。", "A curse vanished."));
799                 o_ptr->curse_flags.clear();
800             }
801
802             should_continue = false;
803         }
804         break;
805
806     case HEX_VAMP_BLADE:
807         if (name) {
808             return _("吸血の刃", "Swords to vampires");
809         }
810         if (description) {
811             return _("吸血属性で攻撃する。", "Gives vampiric ability to your weapon.");
812         }
813         if (cast) {
814 #ifdef JP
815             msg_print("あなたの武器が血を欲している。");
816 #else
817             if (!empty_hands(player_ptr, false)) {
818                 msg_print("Your weapons want more blood now.");
819             } else {
820                 msg_print("Your weapon wants more blood now.");
821             }
822 #endif
823         }
824         if (stop) {
825 #ifdef JP
826             msg_print("武器の渇望が消え去った。");
827 #else
828             msg_format("Your weapon%s less thirsty now.", (empty_hands(player_ptr, false)) ? " is" : "s are");
829 #endif
830         }
831         break;
832
833     case HEX_STUN_MONSTERS:
834         if (name) {
835             return _("朦朧の言葉", "Word of stun");
836         }
837         if (description) {
838             return _("視界内のモンスターを朦朧とさせる。", "Stuns all monsters in your sight.");
839         }
840         power = player_ptr->lev * 4;
841         if (info) {
842             return info_power(power);
843         }
844         if (cast || continuation) {
845             stun_monsters(player_ptr, power);
846         }
847         break;
848
849     case HEX_SHADOW_MOVE:
850         if (name) {
851             return _("影移動", "Moving into shadow");
852         }
853         if (description) {
854             return _("モンスターの隣のマスに瞬間移動する。", "Teleports you close to a monster.");
855         }
856         if (cast) {
857             int i, dir;
858             POSITION y, x;
859             bool flag;
860
861             for (i = 0; i < 3; i++) {
862                 if (!tgt_pt(player_ptr, &x, &y)) {
863                     return "";
864                 }
865
866                 flag = false;
867
868                 for (dir = 0; dir < 8; dir++) {
869                     int dy = y + ddy_ddd[dir];
870                     int dx = x + ddx_ddd[dir];
871                     if (dir == 5) {
872                         continue;
873                     }
874                     if (player_ptr->current_floor_ptr->grid_array[dy][dx].m_idx) {
875                         flag = true;
876                     }
877                 }
878
879                 if (!is_cave_empty_bold(player_ptr, y, x) || player_ptr->current_floor_ptr->grid_array[y][x].is_icky() || (distance(y, x, player_ptr->y, player_ptr->x) > player_ptr->lev + 2)) {
880                     msg_print(_("そこには移動できない。", "Can not teleport to there."));
881                     continue;
882                 }
883                 break;
884             }
885
886             if (flag && randint0(player_ptr->lev * player_ptr->lev / 2)) {
887                 teleport_player_to(player_ptr, y, x, TELEPORT_SPONTANEOUS);
888             } else {
889                 msg_print(_("おっと!", "Oops!"));
890                 teleport_player(player_ptr, 30, TELEPORT_SPONTANEOUS);
891             }
892
893             should_continue = false;
894         }
895         break;
896
897     case HEX_ANTI_MAGIC:
898         if (name) {
899             return _("反魔法結界", "Anti magic barrier");
900         }
901         if (description) {
902             return _("視界内のモンスターの魔法を阻害するバリアを張る。", "Obstructs all magic spells of monsters in your sight.");
903         }
904         power = player_ptr->lev * 3 / 2;
905         if (info) {
906             return info_power(power);
907         }
908         if (cast) {
909             msg_print(_("魔法を防ぐ呪いをかけた。", "You feel anyone can not cast spells except you."));
910         }
911         break;
912
913     case HEX_REVENGE: {
914         if (name) {
915             return _("復讐の宣告", "Revenge sentence");
916         }
917
918         if (description) {
919             return _("数ターン後にそれまで受けたダメージに応じた威力の地獄の劫火の弾を放つ。", "Fires a ball of hell fire to try avenging damage from a few turns.");
920         }
921
922         SpellHex spell_hex(player_ptr);
923         power = spell_hex.get_revenge_power();
924         if (info) {
925             return info_damage(0, 0, power);
926         }
927
928         if (cast) {
929             byte r;
930             int a = 3 - (player_ptr->pspeed - 100) / 10;
931             r = 1 + randint1(2) + std::max(0, std::min(3, a));
932
933             if (spell_hex.get_revenge_turn() > 0) {
934                 msg_print(_("すでに復讐は宣告済みだ。", "You've already declared your revenge."));
935                 return nullptr;
936             }
937
938             spell_hex.set_revenge_type(SpellHexRevengeType::REVENGE);
939             spell_hex.set_revenge_turn(r, true);
940             msg_format(_("あなたは復讐を宣告した。あと %d ターン。", "You declare your revenge. %d turns left."), r);
941             should_continue = false;
942         }
943
944         if (continuation) {
945             spell_hex.set_revenge_turn(1, false);
946             if (spell_hex.get_revenge_turn() == 0) {
947                 DIRECTION dir;
948
949                 if (power) {
950                     command_dir = 0;
951
952                     do {
953                         msg_print(_("復讐の時だ!", "Time for revenge!"));
954                     } while (!get_aim_dir(player_ptr, &dir));
955
956                     fire_ball(player_ptr, AttributeType::HELL_FIRE, dir, power, 1);
957
958                     if (w_ptr->wizard) {
959                         msg_format(_("%d点のダメージを返した。", "You return %d damage."), power);
960                     }
961                 } else {
962                     msg_print(_("復讐する気が失せた。", "You are not in the mood for revenge."));
963                 }
964
965                 spell_hex.set_revenge_power(0, true);
966             }
967         }
968
969         break;
970     }
971     case HEX_MAX:
972         break;
973     }
974
975     if (cast && should_continue) {
976         SpellHex spell_hex(player_ptr);
977         spell_hex.set_casting_flag(spell);
978         if (player_ptr->action != ACTION_SPELL) {
979             set_action(player_ptr, ACTION_SPELL);
980         }
981     }
982
983     if (!info) {
984         player_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
985         player_ptr->redraw |= (PR_EXTRA | PR_HP | PR_MANA);
986     }
987
988     return "";
989 }