OSDN Git Service

[Refactor] #37353 コメント整理。 / Refactor comments.
[hengbandforosx/hengbandosx.git] / src / cmd-spell.c
1 /*!
2     @file cmd-spell.c
3     @brief 魔法のインターフェイスと発動 / Purpose: Do everything for each spell
4     @date 2013/12/31
5     @author
6     2013 Deskull rearranged comment for Doxygen.
7  */
8
9 #include "angband.h"
10 #include "selfinfo.h"
11 #include "spells-summon.h"
12 #include "realm-arcane.h"
13 #include "realm-chaos.h"
14 #include "realm-craft.h"
15 #include "realm-crusade.h"
16 #include "realm-daemon.h"
17 #include "realm-death.h"
18 #include "realm-hex.h"
19 #include "realm-hissatsu.h"
20 #include "realm-life.h"
21 #include "realm-nature.h"
22 #include "realm-song.h"
23 #include "realm-sorcery.h"
24 #include "realm-trump.h"
25 #include "angband.h"
26 #include "avatar.h"
27 #include "player-status.h"
28 #include "object-hook.h"
29
30 /*!
31  * @brief
32  * 魔法の効果を「キャプション:ダイス+定数値」のフォーマットで出力する / Generate dice info string such as "foo 2d10"
33  * @param str キャプション
34  * @param dice ダイス数
35  * @param sides ダイス目
36  * @param base 固定値
37  * @return フォーマットに従い整形された文字列
38  */
39 concptr info_string_dice(concptr str, DICE_NUMBER dice, DICE_SID sides, int base)
40 {
41         /* Fix value */
42         if (!dice)
43                 return format("%s%d", str, base);
44
45         /* Dice only */
46         else if (!base)
47                 return format("%s%dd%d", str, dice, sides);
48
49         /* Dice plus base value */
50         else
51                 return format("%s%dd%d%+d", str, dice, sides, base);
52 }
53
54
55 /*!
56  * @brief 魔法によるダメージを出力する / Generate damage-dice info string such as "dam 2d10"
57  * @param dice ダイス数
58  * @param sides ダイス目
59  * @param base 固定値
60  * @return フォーマットに従い整形された文字列
61  */
62 concptr info_damage(DICE_NUMBER dice, DICE_SID sides, int base)
63 {
64         return info_string_dice(_("損傷:", "dam "), dice, sides, base);
65 }
66
67 /*!
68  * @brief 魔法の効果時間を出力する / Generate duration info string such as "dur 20+1d20"
69  * @param base 固定値
70  * @param sides ダイス目
71  * @return フォーマットに従い整形された文字列
72  */
73 concptr info_duration(int base, DICE_SID sides)
74 {
75         return format(_("期間:%d+1d%d", "dur %d+1d%d"), base, sides);
76 }
77
78 /*!
79  * @brief 魔法の効果範囲を出力する / Generate range info string such as "range 5"
80  * @param range 効果範囲
81  * @return フォーマットに従い整形された文字列
82  */
83 concptr info_range(POSITION range)
84 {
85         return format(_("範囲:%d", "range %d"), range);
86 }
87
88 /*!
89  * @brief 魔法による回復量を出力する / Generate heal info string such as "heal 2d8"
90  * @param dice ダイス数
91  * @param sides ダイス目
92  * @param base 固定値
93  * @return フォーマットに従い整形された文字列
94  */
95 concptr info_heal(DICE_NUMBER dice, DICE_SID sides, int base)
96 {
97         return info_string_dice(_("回復:", "heal "), dice, sides, base);
98 }
99
100 /*!
101  * @brief 魔法効果発動までの遅延ターンを出力する / Generate delay info string such as "delay 15+1d15"
102  * @param base 固定値
103  * @param sides ダイス目
104  * @return フォーマットに従い整形された文字列
105  */
106 concptr info_delay(int base, DICE_SID sides)
107 {
108         return format(_("遅延:%d+1d%d", "delay %d+1d%d"), base, sides);
109 }
110
111
112 /*!
113  * @brief 魔法によるダメージを出力する(固定値&複数回処理) / Generate multiple-damage info string such as "dam 25 each"
114  * @param dam 固定値
115  * @return フォーマットに従い整形された文字列
116  */
117 concptr info_multi_damage(HIT_POINT dam)
118 {
119         return format(_("損傷:各%d", "dam %d each"), dam);
120 }
121
122
123 /*!
124  * @brief 魔法によるダメージを出力する(ダイスのみ&複数回処理) / Generate multiple-damage-dice info string such as "dam 5d2 each"
125  * @param dice ダイス数
126  * @param sides ダイス目
127  * @return フォーマットに従い整形された文字列
128  */
129 concptr info_multi_damage_dice(DICE_NUMBER dice, DICE_SID sides)
130 {
131         return format(_("損傷:各%dd%d", "dam %dd%d each"), dice, sides);
132 }
133
134 /*!
135  * @brief 魔法による一般的な効力値を出力する(固定値) / Generate power info string such as "power 100"
136  * @param power 固定値
137  * @return フォーマットに従い整形された文字列
138  */
139 concptr info_power(int power)
140 {
141         return format(_("効力:%d", "power %d"), power);
142 }
143
144
145 /*!
146  * @brief 魔法による一般的な効力値を出力する(ダイス値) / Generate power info string such as "power 100"
147  * @param dice ダイス数
148  * @param sides ダイス目
149  * @return フォーマットに従い整形された文字列
150  */
151 /*
152  * Generate power info string such as "power 1d100"
153  */
154 concptr info_power_dice(DICE_NUMBER dice, DICE_SID sides)
155 {
156         return format(_("効力:%dd%d", "power %dd%d"), dice, sides);
157 }
158
159
160 /*!
161  * @brief 魔法の効果半径を出力する / Generate radius info string such as "rad 100"
162  * @param rad 効果半径
163  * @return フォーマットに従い整形された文字列
164  */
165 concptr info_radius(POSITION rad)
166 {
167         return format(_("半径:%d", "rad %d"), rad);
168 }
169
170
171 /*!
172  * @brief 魔法効果の限界重量を出力する / Generate weight info string such as "max wgt 15"
173  * @param weight 最大重量
174  * @return フォーマットに従い整形された文字列
175  */
176 concptr info_weight(WEIGHT weight)
177 {
178 #ifdef JP
179         return format("最大重量:%d.%dkg", lbtokg1(weight), lbtokg2(weight));
180 #else
181         return format("max wgt %d", weight/10);
182 #endif
183 }
184
185 /*!
186  * @brief 魔法処理のメインルーチン
187  * @param realm 魔法領域のID
188  * @param spell 各領域の魔法ID
189  * @param mode 求める処理
190  * @return 各領域魔法に各種テキストを求めた場合は文字列参照ポインタ、そうでない場合はNULLポインタを返す。
191  */
192 concptr do_spell(REALM_IDX realm, SPELL_IDX spell, BIT_FLAGS mode)
193 {
194         switch (realm)
195         {
196         case REALM_LIFE:     return do_life_spell(spell, mode);
197         case REALM_SORCERY:  return do_sorcery_spell(spell, mode);
198         case REALM_NATURE:   return do_nature_spell(spell, mode);
199         case REALM_CHAOS:    return do_chaos_spell(spell, mode);
200         case REALM_DEATH:    return do_death_spell(spell, mode);
201         case REALM_TRUMP:    return do_trump_spell(spell, mode);
202         case REALM_ARCANE:   return do_arcane_spell(spell, mode);
203         case REALM_CRAFT:    return do_craft_spell(spell, mode);
204         case REALM_DAEMON:   return do_daemon_spell(spell, mode);
205         case REALM_CRUSADE:  return do_crusade_spell(spell, mode);
206         case REALM_MUSIC:    return do_music_spell(spell, mode);
207         case REALM_HISSATSU: return do_hissatsu_spell(spell, mode);
208         case REALM_HEX:      return do_hex_spell(spell, mode);
209         }
210
211         return NULL;
212 }
213
214
215 /*!
216  * @brief 領域魔法の閲覧、学習、使用選択するインターフェイス処理
217  * Allow user to choose a spell/prayer from the given book.
218  * @param sn 選択した魔法IDを返す参照ポインタ
219  * @param prompt 魔法を利用する際の動詞表記
220  * @param sval 魔道書のsval
221  * @param learned 閲覧/使用選択ならばTRUE、学習処理ならFALSE
222  * @param use_realm 魔法領域ID
223  * @return
224  * <pre>
225  * If a valid spell is chosen, saves it in '*sn' and returns TRUE
226  * If the user hits escape, returns FALSE, and set '*sn' to -1
227  * If there are no legal choices, returns FALSE, and sets '*sn' to -2
228  * The "prompt" should be "cast", "recite", or "study"
229  * The "known" should be TRUE for cast/pray, FALSE for study
230  * </pre>
231  */
232 static int get_spell(SPELL_IDX *sn, concptr prompt, OBJECT_SUBTYPE_VALUE sval, bool learned, REALM_IDX use_realm)
233 {
234         int i;
235         SPELL_IDX spell = -1;
236         int num = 0;
237         int ask = TRUE;
238         MANA_POINT need_mana;
239         SPELL_IDX spells[64];
240         bool flag, redraw, okay;
241         char choice;
242         const magic_type  *s_ptr;
243         char out_val[160];
244         concptr p;
245         COMMAND_CODE code;
246 #ifdef JP
247         char jverb_buf[128];
248 #endif
249         int menu_line = (use_menu ? 1 : 0);
250
251         /* Get the spell, if available */
252         if (repeat_pull(&code))
253         {
254                 *sn = (SPELL_IDX)code;
255                 /* Verify the spell */
256                 if (spell_okay(*sn, learned, FALSE, use_realm))
257                 {
258                         /* Success */
259                         return (TRUE);
260                 }
261         }
262
263         p = spell_category_name(mp_ptr->spell_book);
264
265         /* Extract spells */
266         for (spell = 0; spell < 32; spell++)
267         {
268                 /* Check for this spell */
269                 if ((fake_spell_flags[sval] & (1L << spell)))
270                 {
271                         /* Collect this spell */
272                         spells[num++] = spell;
273                 }
274         }
275
276         /* Assume no usable spells */
277         okay = FALSE;
278
279         /* Assume no spells available */
280         (*sn) = -2;
281
282         /* Check for "okay" spells */
283         for (i = 0; i < num; i++)
284         {
285                 /* Look for "okay" spells */
286                 if (spell_okay(spells[i], learned, FALSE, use_realm)) okay = TRUE;
287         }
288
289         /* No "okay" spells */
290         if (!okay) return (FALSE);
291         if (((use_realm) != p_ptr->realm1) && ((use_realm) != p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return FALSE;
292         if (((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) && !is_magic(use_realm)) return FALSE;
293         if ((p_ptr->pclass == CLASS_RED_MAGE) && ((use_realm) != REALM_ARCANE) && (sval > 1)) return FALSE;
294
295         /* Assume cancelled */
296         *sn = (-1);
297
298         /* Nothing chosen yet */
299         flag = FALSE;
300
301         /* No redraw yet */
302         redraw = FALSE;
303
304         p_ptr->window |= (PW_SPELL);
305         handle_stuff();
306
307         /* Build a prompt (accept all spells) */
308 #ifdef JP
309         jverb(prompt, jverb_buf, JVERB_AND);
310         (void)strnfmt(out_val, 78, "(%^s:%c-%c, '*'で一覧, ESCで中断) どの%sを%^sますか? ",
311                 p, I2A(0), I2A(num - 1), p, jverb_buf);
312 #else
313         (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) %^s which %s? ",
314                 p, I2A(0), I2A(num - 1), prompt, p);
315 #endif
316
317         /* Get a spell from the user */
318
319         choice = (always_show_list || use_menu) ? ESCAPE : 1;
320         while (!flag)
321         {
322                 if (choice == ESCAPE) choice = ' ';
323                 else if (!get_com(out_val, &choice, TRUE))break;
324
325                 if (use_menu && choice != ' ')
326                 {
327                         switch (choice)
328                         {
329                         case '0':
330                         {
331                                 screen_load();
332                                 return FALSE;
333                         }
334
335                         case '8':
336                         case 'k':
337                         case 'K':
338                         {
339                                 menu_line += (num - 1);
340                                 break;
341                         }
342
343                         case '2':
344                         case 'j':
345                         case 'J':
346                         {
347                                 menu_line++;
348                                 break;
349                         }
350
351                         case 'x':
352                         case 'X':
353                         case '\r':
354                         case '\n':
355                         {
356                                 i = menu_line - 1;
357                                 ask = FALSE;
358                                 break;
359                         }
360                         }
361                         if (menu_line > num) menu_line -= num;
362                         /* Display a list of spells */
363                         print_spells(menu_line, spells, num, 1, 15, use_realm);
364                         if (ask) continue;
365                 }
366                 else
367                 {
368                         /* Request redraw */
369                         if ((choice == ' ') || (choice == '*') || (choice == '?'))
370                         {
371                                 /* Show the list */
372                                 if (!redraw)
373                                 {
374                                         redraw = TRUE;
375                                         screen_save();
376
377                                         /* Display a list of spells */
378                                         print_spells(menu_line, spells, num, 1, 15, use_realm);
379                                 }
380
381                                 /* Hide the list */
382                                 else
383                                 {
384                                         if (use_menu) continue;
385
386                                         /* Hide list */
387                                         redraw = FALSE;
388                                         screen_load();
389                                 }
390
391                                 /* Redo asking */
392                                 continue;
393                         }
394
395
396                         /* Note verify */
397                         ask = (isupper(choice));
398
399                         /* Lowercase */
400                         if (ask) choice = (char)tolower(choice);
401
402                         /* Extract request */
403                         i = (islower(choice) ? A2I(choice) : -1);
404                 }
405
406                 /* Totally Illegal */
407                 if ((i < 0) || (i >= num))
408                 {
409                         bell();
410                         continue;
411                 }
412
413                 /* Save the spell index */
414                 spell = spells[i];
415
416                 /* Require "okay" spells */
417                 if (!spell_okay(spell, learned, FALSE, use_realm))
418                 {
419                         bell();
420 #ifdef JP
421                         msg_format("その%sを%sことはできません。", p, prompt);
422 #else
423                         msg_format("You may not %s that %s.", prompt, p);
424 #endif
425
426                         continue;
427                 }
428
429                 /* Verify it */
430                 if (ask)
431                 {
432                         char tmp_val[160];
433
434                         /* Access the spell */
435                         if (!is_magic(use_realm))
436                         {
437                                 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
438                         }
439                         else
440                         {
441                                 s_ptr = &mp_ptr->info[use_realm - 1][spell];
442                         }
443
444                         /* Extract mana consumption rate */
445                         if (use_realm == REALM_HISSATSU)
446                         {
447                                 need_mana = s_ptr->smana;
448                         }
449                         else
450                         {
451                                 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
452                         }
453
454                         /* Prompt */
455 #ifdef JP
456                         jverb(prompt, jverb_buf, JVERB_AND);
457                         /* 英日切り替え機能に対応 */
458                         (void)strnfmt(tmp_val, 78, "%s(MP%d, 失敗率%d%%)を%sますか? ",
459                                 do_spell(use_realm, spell, SPELL_NAME), need_mana,
460                                 spell_chance(spell, use_realm), jverb_buf);
461 #else
462                         (void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ",
463                                 prompt, do_spell(use_realm, spell, SPELL_NAME), need_mana,
464                                 spell_chance(spell, use_realm));
465 #endif
466
467
468                         /* Belay that order */
469                         if (!get_check(tmp_val)) continue;
470                 }
471
472                 /* Stop the loop */
473                 flag = TRUE;
474         }
475
476         if (redraw) screen_load();
477
478         p_ptr->window |= (PW_SPELL);
479         handle_stuff();
480
481         /* Abort if needed */
482         if (!flag) return FALSE;
483
484         /* Save the choice */
485         (*sn) = spell;
486
487         repeat_push((COMMAND_CODE)spell);
488
489         /* Success */
490         return TRUE;
491 }
492
493 /*!
494  * @brief プレイヤーの職業が練気術師の時、領域魔法と練気術を切り換える処理のインターフェイス
495  * @param browse_only 魔法と技能の閲覧を行うならばTRUE
496  * @return 魔道書を一冊も持っていないならTRUEを返す
497  */
498 static void confirm_use_force(bool browse_only)
499 {
500         char which;
501         COMMAND_CODE code;
502
503         /* Get the item index */
504         if (repeat_pull(&code) && (code == INVEN_FORCE))
505         {
506                 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
507                 return;
508         }
509
510         /* Show the prompt */
511         prt(_("('w'練気術, ESC) 'w'かESCを押してください。 ", "(w for the Force, ESC) Hit 'w' or ESC. "), 0, 0);
512
513         while (1)
514         {
515                 /* Get a key */
516                 which = inkey();
517
518                 if (which == ESCAPE) break;
519                 else if (which == 'w')
520                 {
521                         repeat_push(INVEN_FORCE);
522                         break;
523                 }
524         }
525
526         /* Clear the prompt line */
527         prt("", 0, 0);
528
529         if (which == 'w')
530         {
531                 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
532         }
533 }
534
535
536 /*!
537  * @brief プレイヤーの魔法と技能を閲覧するコマンドのメインルーチン /
538  * Peruse the spells/prayers in a book
539  * @return なし
540  * @details
541  * <pre>
542  * Note that *all* spells in the book are listed
543  *
544  * Note that browsing is allowed while confused or blind,
545  * and in the dark, primarily to allow browsing in stores.
546  * </pre>
547  */
548 void do_cmd_browse(void)
549 {
550         OBJECT_IDX item;
551         OBJECT_SUBTYPE_VALUE sval;
552         REALM_IDX use_realm = 0;
553         int j, line;
554         SPELL_IDX spell = -1;
555         int num = 0;
556
557         SPELL_IDX spells[64];
558         char temp[62 * 4];
559
560         object_type *o_ptr;
561
562         concptr q, s;
563
564         /* Warriors are illiterate */
565         if (!(p_ptr->realm1 || p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
566         {
567                 msg_print(_("本を読むことができない!", "You cannot read books!"));
568                 return;
569         }
570
571         if (p_ptr->special_defense & KATA_MUSOU)
572         {
573                 set_action(ACTION_NONE);
574         }
575
576         if (p_ptr->pclass == CLASS_FORCETRAINER)
577         {
578                 if (player_has_no_spellbooks())
579                 {
580                         confirm_use_force(TRUE);
581                         return;
582                 }
583         }
584
585         /* Restrict choices to "useful" books */
586         if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
587         else item_tester_hook = item_tester_learn_spell;
588
589         q = _("どの本を読みますか? ", "Browse which book? ");
590         s = _("読める本がない。", "You have no books that you can read.");
591
592         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | (p_ptr->pclass == CLASS_FORCETRAINER ? USE_FORCE : 0)));
593         if (!o_ptr)
594         {
595                 if (item == INVEN_FORCE) /* the_force */
596                 {
597                         do_cmd_mind_browse();
598                         return;
599                 }
600                 return;
601         }
602
603         /* Access the item's sval */
604         sval = o_ptr->sval;
605
606         use_realm = tval2realm(o_ptr->tval);
607
608         /* Track the object kind */
609         object_kind_track(o_ptr->k_idx);
610         handle_stuff();
611
612         /* Extract spells */
613         for (spell = 0; spell < 32; spell++)
614         {
615                 /* Check for this spell */
616                 if ((fake_spell_flags[sval] & (1L << spell)))
617                 {
618                         /* Collect this spell */
619                         spells[num++] = spell;
620                 }
621         }
622
623         screen_save();
624         prt("", 0, 0);
625
626         /* Keep browsing spells.  Exit browsing on cancel. */
627         while (TRUE)
628         {
629                 /* Ask for a spell, allow cancel */
630                 if (!get_spell(&spell, _("読む", "browse"), o_ptr->sval, TRUE, use_realm))
631                 {
632                         /* If cancelled, leave immediately. */
633                         if (spell == -1) break;
634
635                         /* Display a list of spells */
636                         print_spells(0, spells, num, 1, 15, use_realm);
637
638                         /* Notify that there's nothing to see, and wait. */
639                         if (use_realm == REALM_HISSATSU)
640                                 prt(_("読める技がない。", "No techniques to browse."), 0, 0);
641                         else
642                                 prt(_("読める呪文がない。", "No spells to browse."), 0, 0);
643                         (void)inkey();
644
645                         screen_load();
646
647                         return;
648                 }
649
650                 /* Clear lines, position cursor  (really should use strlen here) */
651                 Term_erase(14, 14, 255);
652                 Term_erase(14, 13, 255);
653                 Term_erase(14, 12, 255);
654                 Term_erase(14, 11, 255);
655
656                 roff_to_buf(do_spell(use_realm, spell, SPELL_DESC), 62, temp, sizeof(temp));
657
658                 for (j = 0, line = 11; temp[j]; j += 1 + strlen(&temp[j]))
659                 {
660                         prt(&temp[j], line, 15);
661                         line++;
662                 }
663         }
664         screen_load();
665 }
666
667 /*!
668  * @brief プレイヤーの第二魔法領域を変更する /
669  * @param next_realm 変更先の魔法領域ID
670  * @return なし
671  */
672 static void change_realm2(CHARACTER_IDX next_realm)
673 {
674         int i, j = 0;
675         char tmp[80];
676
677         for (i = 0; i < 64; i++)
678         {
679                 p_ptr->spell_order[j] = p_ptr->spell_order[i];
680                 if (p_ptr->spell_order[i] < 32) j++;
681         }
682         for (; j < 64; j++)
683                 p_ptr->spell_order[j] = 99;
684
685         for (i = 32; i < 64; i++)
686         {
687                 p_ptr->spell_exp[i] = SPELL_EXP_UNSKILLED;
688         }
689         p_ptr->spell_learned2 = 0L;
690         p_ptr->spell_worked2 = 0L;
691         p_ptr->spell_forgotten2 = 0L;
692
693         sprintf(tmp, _("魔法の領域を%sから%sに変更した。", "change magic realm from %s to %s."), realm_names[p_ptr->realm2], realm_names[next_realm]);
694         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
695         p_ptr->old_realm |= 1 << (p_ptr->realm2 - 1);
696         p_ptr->realm2 = next_realm;
697
698         p_ptr->update |= (PU_REORDER);
699         p_ptr->update |= (PU_SPELLS);
700         handle_stuff();
701
702         /* Load an autopick preference file */
703         autopick_load_pref(FALSE);
704 }
705
706
707 /*!
708  * @brief 魔法を学習するコマンドのメインルーチン /
709  * Study a book to gain a new spell/prayer
710  * @return なし
711  */
712 void do_cmd_study(void)
713 {
714         int     i;
715         OBJECT_IDX item;
716         OBJECT_SUBTYPE_VALUE sval;
717         int     increment = 0;
718         bool    learned = FALSE;
719
720         /* Spells of realm2 will have an increment of +32 */
721         SPELL_IDX spell = -1;
722
723         concptr p = spell_category_name(mp_ptr->spell_book);
724
725         object_type *o_ptr;
726
727         concptr q, s;
728
729         if (!p_ptr->realm1)
730         {
731                 msg_print(_("本を読むことができない!", "You cannot read books!"));
732                 return;
733         }
734
735         if (p_ptr->blind || no_lite())
736         {
737                 msg_print(_("目が見えない!", "You cannot see!"));
738                 return;
739         }
740
741         if (cmd_limit_confused(p_ptr)) return;
742
743         if (!(p_ptr->new_spells))
744         {
745                 msg_format(_("新しい%sを覚えることはできない!", "You cannot learn any new %ss!"), p);
746                 return;
747         }
748
749         if (p_ptr->special_defense & KATA_MUSOU)
750         {
751                 set_action(ACTION_NONE);
752         }
753
754 #ifdef JP
755         if (p_ptr->new_spells < 10) {
756                 msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
757         }
758         else {
759                 msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
760         }
761 #else
762         msg_format("You can learn %d new %s%s.", p_ptr->new_spells, p,
763                 (p_ptr->new_spells == 1 ? "" : "s"));
764 #endif
765
766         msg_print(NULL);
767
768
769         /* Restrict choices to "useful" books */
770         if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
771         else item_tester_hook = item_tester_learn_spell;
772
773         q = _("どの本から学びますか? ", "Study which book? ");
774         s = _("読める本がない。", "You have no books that you can read.");
775
776         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
777         if (!o_ptr) return;
778
779         /* Access the item's sval */
780         sval = o_ptr->sval;
781
782         if (o_ptr->tval == REALM2_BOOK) increment = 32;
783         else if (o_ptr->tval != REALM1_BOOK)
784         {
785                 if (!get_check(_("本当に魔法の領域を変更しますか?", "Really, change magic realm? "))) return;
786                 change_realm2(tval2realm(o_ptr->tval));
787                 increment = 32;
788         }
789
790         /* Track the object kind */
791         object_kind_track(o_ptr->k_idx);
792         handle_stuff();
793
794         /* Mage -- Learn a selected spell */
795         if (mp_ptr->spell_book != TV_LIFE_BOOK)
796         {
797                 /* Ask for a spell, allow cancel */
798                 if (!get_spell(&spell, _("学ぶ", "study"), sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1) && (spell == -1)) return;
799         }
800
801         /* Priest -- Learn a random prayer */
802         else
803         {
804                 int k = 0;
805                 int gift = -1;
806
807                 /* Extract spells */
808                 for (spell = 0; spell < 32; spell++)
809                 {
810                         /* Check spells in the book */
811                         if ((fake_spell_flags[sval] & (1L << spell)))
812                         {
813                                 /* Skip non "okay" prayers */
814                                 if (!spell_okay(spell, FALSE, TRUE,
815                                         (increment ? p_ptr->realm2 : p_ptr->realm1))) continue;
816
817                                 /* Hack -- Prepare the randomizer */
818                                 k++;
819
820                                 /* Hack -- Apply the randomizer */
821                                 if (one_in_(k)) gift = spell;
822                         }
823                 }
824
825                 /* Accept gift */
826                 spell = gift;
827         }
828
829         /* Nothing to study */
830         if (spell < 0)
831         {
832                 msg_format(_("その本には学ぶべき%sがない。", "You cannot learn any %ss in that book."), p);
833
834                 /* Abort */
835                 return;
836         }
837
838         if (increment) spell += increment;
839
840         /* Learn the spell */
841         if (spell < 32)
842         {
843                 if (p_ptr->spell_learned1 & (1L << spell)) learned = TRUE;
844                 else p_ptr->spell_learned1 |= (1L << spell);
845         }
846         else
847         {
848                 if (p_ptr->spell_learned2 & (1L << (spell - 32))) learned = TRUE;
849                 else p_ptr->spell_learned2 |= (1L << (spell - 32));
850         }
851
852         if (learned)
853         {
854                 int max_exp = (spell < 32) ? SPELL_EXP_MASTER : SPELL_EXP_EXPERT;
855                 int old_exp = p_ptr->spell_exp[spell];
856                 int new_rank = EXP_LEVEL_UNSKILLED;
857                 concptr name = do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME);
858
859                 if (old_exp >= max_exp)
860                 {
861                         msg_format(_("その%sは完全に使いこなせるので学ぶ必要はない。", "You don't need to study this %s anymore."), p);
862                         return;
863                 }
864 #ifdef JP
865                 if (!get_check(format("%sの%sをさらに学びます。よろしいですか?", name, p)))
866 #else
867                 if (!get_check(format("You will study a %s of %s again. Are you sure? ", p, name)))
868 #endif
869                 {
870                         return;
871                 }
872                 else if (old_exp >= SPELL_EXP_EXPERT)
873                 {
874                         p_ptr->spell_exp[spell] = SPELL_EXP_MASTER;
875                         new_rank = EXP_LEVEL_MASTER;
876                 }
877                 else if (old_exp >= SPELL_EXP_SKILLED)
878                 {
879                         if (spell >= 32) p_ptr->spell_exp[spell] = SPELL_EXP_EXPERT;
880                         else p_ptr->spell_exp[spell] += SPELL_EXP_EXPERT - SPELL_EXP_SKILLED;
881                         new_rank = EXP_LEVEL_EXPERT;
882                 }
883                 else if (old_exp >= SPELL_EXP_BEGINNER)
884                 {
885                         p_ptr->spell_exp[spell] = SPELL_EXP_SKILLED + (old_exp - SPELL_EXP_BEGINNER) * 2 / 3;
886                         new_rank = EXP_LEVEL_SKILLED;
887                 }
888                 else
889                 {
890                         p_ptr->spell_exp[spell] = SPELL_EXP_BEGINNER + old_exp / 3;
891                         new_rank = EXP_LEVEL_BEGINNER;
892                 }
893                 msg_format(_("%sの熟練度が%sに上がった。", "Your proficiency of %s is now %s rank."), name, exp_level_str[new_rank]);
894         }
895         else
896         {
897                 /* Find the next open entry in "p_ptr->spell_order[]" */
898                 for (i = 0; i < 64; i++)
899                 {
900                         /* Stop at the first empty space */
901                         if (p_ptr->spell_order[i] == 99) break;
902                 }
903
904                 /* Add the spell to the known list */
905                 p_ptr->spell_order[i++] = spell;
906
907                 /* Mention the result */
908 #ifdef JP
909                 /* 英日切り替え機能に対応 */
910                 if (mp_ptr->spell_book == TV_MUSIC_BOOK)
911                 {
912                         msg_format("%sを学んだ。",
913                                 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
914                 }
915                 else
916                 {
917                         msg_format("%sの%sを学んだ。",
918                                 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME), p);
919                 }
920 #else
921                 msg_format("You have learned the %s of %s.",
922                         p, do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
923 #endif
924         }
925
926         take_turn(p_ptr, 100);
927
928         switch (mp_ptr->spell_book)
929         {
930         case TV_LIFE_BOOK:
931                 chg_virtue(V_FAITH, 1);
932                 break;
933         case TV_DEATH_BOOK:
934                 chg_virtue(V_UNLIFE, 1);
935                 break;
936         case TV_NATURE_BOOK:
937                 chg_virtue(V_NATURE, 1);
938                 break;
939         default:
940                 chg_virtue(V_KNOWLEDGE, 1);
941                 break;
942         }
943
944         sound(SOUND_STUDY);
945
946         /* One less spell available */
947         p_ptr->learned_spells++;
948
949         /* Update Study */
950         p_ptr->update |= (PU_SPELLS);
951         update_creature(p_ptr);
952
953         /* Redraw object recall */
954         p_ptr->window |= (PW_OBJECT);
955 }
956
957
958 /*!
959  * @brief 魔法を詠唱するコマンドのメインルーチン /
960  * Cast a spell
961  * @return なし
962  */
963 void do_cmd_cast(void)
964 {
965         OBJECT_IDX item;
966         OBJECT_SUBTYPE_VALUE sval;
967         SPELL_IDX spell;
968         REALM_IDX realm;
969         int     chance;
970         int     increment = 0;
971         REALM_IDX use_realm;
972         MANA_POINT need_mana;
973
974         concptr prayer;
975         object_type *o_ptr;
976         const magic_type *s_ptr;
977         concptr q, s;
978
979         bool over_exerted = FALSE;
980
981         /* Require spell ability */
982         if (!p_ptr->realm1 && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
983         {
984                 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
985                 return;
986         }
987
988         /* Require lite */
989         if (p_ptr->blind || no_lite())
990         {
991                 if (p_ptr->pclass == CLASS_FORCETRAINER) confirm_use_force(FALSE);
992                 else
993                 {
994                         msg_print(_("目が見えない!", "You cannot see!"));
995                         flush();
996                 }
997                 return;
998         }
999
1000         if (cmd_limit_confused(p_ptr)) return;
1001
1002         /* Hex */
1003         if (p_ptr->realm1 == REALM_HEX)
1004         {
1005                 if (hex_spell_fully())
1006                 {
1007                         bool flag = FALSE;
1008                         msg_print(_("これ以上新しい呪文を詠唱することはできない。", "Can not spell new spells more."));
1009                         flush();
1010                         if (p_ptr->lev >= 35) flag = stop_hex_spell();
1011                         if (!flag) return;
1012                 }
1013         }
1014
1015         if (p_ptr->pclass == CLASS_FORCETRAINER)
1016         {
1017                 if (player_has_no_spellbooks())
1018                 {
1019                         confirm_use_force(FALSE);
1020                         return;
1021                 }
1022         }
1023
1024         prayer = spell_category_name(mp_ptr->spell_book);
1025
1026         /* Restrict choices to spell books */
1027         item_tester_tval = mp_ptr->spell_book;
1028
1029         q = _("どの呪文書を使いますか? ", "Use which book? ");
1030         s = _("呪文書がない!", "You have no spell books!");
1031
1032         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | (p_ptr->pclass == CLASS_FORCETRAINER ? USE_FORCE : 0)));
1033         if (!o_ptr)
1034         {
1035                 if (item == INVEN_FORCE) /* the_force */
1036                 {
1037                         do_cmd_mind();
1038                         return;
1039                 }
1040                 return;
1041         }
1042
1043         /* Access the item's sval */
1044         sval = o_ptr->sval;
1045
1046         if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && (o_ptr->tval == REALM2_BOOK)) increment = 32;
1047
1048         /* Track the object kind */
1049         object_kind_track(o_ptr->k_idx);
1050         handle_stuff();
1051
1052         if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
1053                 realm = o_ptr->tval - TV_LIFE_BOOK + 1;
1054         else if (increment) realm = p_ptr->realm2;
1055         else realm = p_ptr->realm1;
1056
1057         /* Ask for a spell */
1058 #ifdef JP
1059         if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_MUSIC_BOOK) ? "歌う" : "唱える"),
1060                 sval, TRUE, realm))
1061         {
1062                 if (spell == -2) msg_format("その本には知っている%sがない。", prayer);
1063                 return;
1064         }
1065 #else
1066         if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1067                 sval, TRUE, realm))
1068         {
1069                 if (spell == -2)
1070                         msg_format("You don't know any %ss in that book.", prayer);
1071                 return;
1072         }
1073 #endif
1074
1075
1076         use_realm = tval2realm(o_ptr->tval);
1077
1078         /* Hex */
1079         if (use_realm == REALM_HEX)
1080         {
1081                 if (hex_spelling(spell))
1082                 {
1083                         msg_print(_("その呪文はすでに詠唱中だ。", "You are already casting it."));
1084                         return;
1085                 }
1086         }
1087
1088         if (!is_magic(use_realm))
1089         {
1090                 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
1091         }
1092         else
1093         {
1094                 s_ptr = &mp_ptr->info[realm - 1][spell];
1095         }
1096
1097         /* Extract mana consumption rate */
1098         need_mana = mod_need_mana(s_ptr->smana, spell, realm);
1099
1100         /* Verify "dangerous" spells */
1101         if (need_mana > p_ptr->csp)
1102         {
1103                 if (flush_failure) flush();
1104
1105                 /* Warning */
1106 #ifdef JP
1107                 msg_format("その%sを%sのに十分なマジックポイントがない。", prayer,
1108                         ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_LIFE_BOOK) ? "歌う" : "唱える"));
1109 #else
1110                 msg_format("You do not have enough mana to %s this %s.",
1111                         ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1112                         prayer);
1113 #endif
1114
1115
1116                 if (!over_exert) return;
1117
1118                 /* Verify */
1119                 if (!get_check_strict(_("それでも挑戦しますか? ", "Attempt it anyway? "), CHECK_OKAY_CANCEL)) return;
1120         }
1121
1122         /* Spell failure chance */
1123         chance = spell_chance(spell, use_realm);
1124
1125         /* Sufficient mana */
1126         if (need_mana <= p_ptr->csp)
1127         {
1128                 /* Use some mana */
1129                 p_ptr->csp -= need_mana;
1130         }
1131         else over_exerted = TRUE;
1132         p_ptr->redraw |= (PR_MANA);
1133
1134         /* Failed spell */
1135         if (randint0(100) < chance)
1136         {
1137                 if (flush_failure) flush();
1138
1139                 msg_format(_("%sをうまく唱えられなかった!", "You failed to get the %s off!"), prayer);
1140                 sound(SOUND_FAIL);
1141
1142                 switch (realm)
1143                 {
1144                 case REALM_LIFE:
1145                         if (randint1(100) < chance) chg_virtue(V_VITALITY, -1);
1146                         break;
1147                 case REALM_DEATH:
1148                         if (randint1(100) < chance) chg_virtue(V_UNLIFE, -1);
1149                         break;
1150                 case REALM_NATURE:
1151                         if (randint1(100) < chance) chg_virtue(V_NATURE, -1);
1152                         break;
1153                 case REALM_DAEMON:
1154                         if (randint1(100) < chance) chg_virtue(V_JUSTICE, 1);
1155                         break;
1156                 case REALM_CRUSADE:
1157                         if (randint1(100) < chance) chg_virtue(V_JUSTICE, -1);
1158                         break;
1159                 case REALM_HEX:
1160                         if (randint1(100) < chance) chg_virtue(V_COMPASSION, -1);
1161                         break;
1162                 default:
1163                         if (randint1(100) < chance) chg_virtue(V_KNOWLEDGE, -1);
1164                         break;
1165                 }
1166
1167                 /* Failure casting may activate some side effect */
1168                 do_spell(realm, spell, SPELL_FAIL);
1169
1170
1171                 if ((o_ptr->tval == TV_CHAOS_BOOK) && (randint1(100) < spell))
1172                 {
1173                         msg_print(_("カオス的な効果を発生した!", "You produce a chaotic effect!"));
1174                         wild_magic(spell);
1175                 }
1176                 else if ((o_ptr->tval == TV_DEATH_BOOK) && (randint1(100) < spell))
1177                 {
1178                         if ((sval == 3) && one_in_(2))
1179                         {
1180                                 sanity_blast(0, TRUE);
1181                         }
1182                         else
1183                         {
1184                                 msg_print(_("痛い!", "It hurts!"));
1185                                 take_hit(DAMAGE_LOSELIFE, damroll(o_ptr->sval + 1, 6), _("暗黒魔法の逆流", "a miscast Death spell"), -1);
1186
1187                                 if ((spell > 15) && one_in_(6) && !p_ptr->hold_exp)
1188                                         lose_exp(spell * 250);
1189                         }
1190                 }
1191                 else if ((o_ptr->tval == TV_MUSIC_BOOK) && (randint1(200) < spell))
1192                 {
1193                         msg_print(_("いやな音が響いた", "An infernal sound echoed."));
1194                         aggravate_monsters(0);
1195                 }
1196                 if (randint1(100) >= chance)
1197                         chg_virtue(V_CHANCE, -1);
1198         }
1199
1200         /* Process spell */
1201         else
1202         {
1203                 /* Canceled spells cost neither a current_world_ptr->game_turn nor mana */
1204                 if (!do_spell(realm, spell, SPELL_CAST)) return;
1205
1206                 if (randint1(100) < chance)
1207                         chg_virtue(V_CHANCE, 1);
1208
1209                 /* A spell was cast */
1210                 if (!(increment ?
1211                         (p_ptr->spell_worked2 & (1L << spell)) :
1212                         (p_ptr->spell_worked1 & (1L << spell)))
1213                         && (p_ptr->pclass != CLASS_SORCERER)
1214                         && (p_ptr->pclass != CLASS_RED_MAGE))
1215                 {
1216                         int e = s_ptr->sexp;
1217
1218                         /* The spell worked */
1219                         if (realm == p_ptr->realm1)
1220                         {
1221                                 p_ptr->spell_worked1 |= (1L << spell);
1222                         }
1223                         else
1224                         {
1225                                 p_ptr->spell_worked2 |= (1L << spell);
1226                         }
1227
1228                         /* Gain experience */
1229                         gain_exp(e * s_ptr->slevel);
1230
1231                         /* Redraw object recall */
1232                         p_ptr->window |= (PW_OBJECT);
1233
1234                         switch (realm)
1235                         {
1236                         case REALM_LIFE:
1237                                 chg_virtue(V_TEMPERANCE, 1);
1238                                 chg_virtue(V_COMPASSION, 1);
1239                                 chg_virtue(V_VITALITY, 1);
1240                                 chg_virtue(V_DILIGENCE, 1);
1241                                 break;
1242                         case REALM_DEATH:
1243                                 chg_virtue(V_UNLIFE, 1);
1244                                 chg_virtue(V_JUSTICE, -1);
1245                                 chg_virtue(V_FAITH, -1);
1246                                 chg_virtue(V_VITALITY, -1);
1247                                 break;
1248                         case REALM_DAEMON:
1249                                 chg_virtue(V_JUSTICE, -1);
1250                                 chg_virtue(V_FAITH, -1);
1251                                 chg_virtue(V_HONOUR, -1);
1252                                 chg_virtue(V_TEMPERANCE, -1);
1253                                 break;
1254                         case REALM_CRUSADE:
1255                                 chg_virtue(V_FAITH, 1);
1256                                 chg_virtue(V_JUSTICE, 1);
1257                                 chg_virtue(V_SACRIFICE, 1);
1258                                 chg_virtue(V_HONOUR, 1);
1259                                 break;
1260                         case REALM_NATURE:
1261                                 chg_virtue(V_NATURE, 1);
1262                                 chg_virtue(V_HARMONY, 1);
1263                                 break;
1264                         case REALM_HEX:
1265                                 chg_virtue(V_JUSTICE, -1);
1266                                 chg_virtue(V_FAITH, -1);
1267                                 chg_virtue(V_HONOUR, -1);
1268                                 chg_virtue(V_COMPASSION, -1);
1269                                 break;
1270                         default:
1271                                 chg_virtue(V_KNOWLEDGE, 1);
1272                                 break;
1273                         }
1274                 }
1275                 switch (realm)
1276                 {
1277                 case REALM_LIFE:
1278                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, 1);
1279                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, 1);
1280                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, 1);
1281                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_DILIGENCE, 1);
1282                         break;
1283                 case REALM_DEATH:
1284                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_UNLIFE, 1);
1285                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1286                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1287                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, -1);
1288                         break;
1289                 case REALM_DAEMON:
1290                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1291                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1292                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1293                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, -1);
1294                         break;
1295                 case REALM_CRUSADE:
1296                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, 1);
1297                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, 1);
1298                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_SACRIFICE, 1);
1299                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, 1);
1300                         break;
1301                 case REALM_NATURE:
1302                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_NATURE, 1);
1303                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HARMONY, 1);
1304                         break;
1305                 case REALM_HEX:
1306                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1307                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1308                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1309                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, -1);
1310                         break;
1311                 }
1312                 if (mp_ptr->spell_xtra & MAGIC_GAIN_EXP)
1313                 {
1314                         s16b cur_exp = p_ptr->spell_exp[(increment ? 32 : 0) + spell];
1315                         s16b exp_gain = 0;
1316
1317                         if (cur_exp < SPELL_EXP_BEGINNER)
1318                                 exp_gain += 60;
1319                         else if (cur_exp < SPELL_EXP_SKILLED)
1320                         {
1321                                 if ((current_floor_ptr->dun_level > 4) && ((current_floor_ptr->dun_level + 10) > p_ptr->lev))
1322                                         exp_gain = 8;
1323                         }
1324                         else if (cur_exp < SPELL_EXP_EXPERT)
1325                         {
1326                                 if (((current_floor_ptr->dun_level + 5) > p_ptr->lev) && ((current_floor_ptr->dun_level + 5) > s_ptr->slevel))
1327                                         exp_gain = 2;
1328                         }
1329                         else if ((cur_exp < SPELL_EXP_MASTER) && !increment)
1330                         {
1331                                 if (((current_floor_ptr->dun_level + 5) > p_ptr->lev) && (current_floor_ptr->dun_level > s_ptr->slevel))
1332                                         exp_gain = 1;
1333                         }
1334                         p_ptr->spell_exp[(increment ? 32 : 0) + spell] += exp_gain;
1335                 }
1336         }
1337
1338         take_turn(p_ptr, 100);
1339
1340
1341         /* Over-exert the player */
1342         if (over_exerted)
1343         {
1344                 int oops = need_mana;
1345
1346                 /* No mana left */
1347                 p_ptr->csp = 0;
1348                 p_ptr->csp_frac = 0;
1349
1350                 msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
1351
1352                 /* Hack -- Bypass free action */
1353                 (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
1354
1355                 switch (realm)
1356                 {
1357                 case REALM_LIFE:
1358                         chg_virtue(V_VITALITY, -10);
1359                         break;
1360                 case REALM_DEATH:
1361                         chg_virtue(V_UNLIFE, -10);
1362                         break;
1363                 case REALM_DAEMON:
1364                         chg_virtue(V_JUSTICE, 10);
1365                         break;
1366                 case REALM_NATURE:
1367                         chg_virtue(V_NATURE, -10);
1368                         break;
1369                 case REALM_CRUSADE:
1370                         chg_virtue(V_JUSTICE, -10);
1371                         break;
1372                 case REALM_HEX:
1373                         chg_virtue(V_COMPASSION, 10);
1374                         break;
1375                 default:
1376                         chg_virtue(V_KNOWLEDGE, -10);
1377                         break;
1378                 }
1379
1380                 /* Damage CON (possibly permanently) */
1381                 if (randint0(100) < 50)
1382                 {
1383                         bool perm = (randint0(100) < 25);
1384
1385                         msg_print(_("体を悪くしてしまった!", "You have damaged your health!"));
1386
1387                         /* Reduce constitution */
1388                         (void)dec_stat(A_CON, 15 + randint1(10), perm);
1389                 }
1390         }
1391
1392         p_ptr->window |= (PW_PLAYER);
1393         p_ptr->window |= (PW_SPELL);
1394 }