OSDN Git Service

v3.0.0 Alpha5 OSDN最終版
[hengband/hengband.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                                         /* Show list */
375                                         redraw = TRUE;
376                                         screen_save();
377
378                                         /* Display a list of spells */
379                                         print_spells(menu_line, spells, num, 1, 15, use_realm);
380                                 }
381
382                                 /* Hide the list */
383                                 else
384                                 {
385                                         if (use_menu) continue;
386
387                                         /* Hide list */
388                                         redraw = FALSE;
389                                         screen_load();
390                                 }
391
392                                 /* Redo asking */
393                                 continue;
394                         }
395
396
397                         /* Note verify */
398                         ask = (isupper(choice));
399
400                         /* Lowercase */
401                         if (ask) choice = (char)tolower(choice);
402
403                         /* Extract request */
404                         i = (islower(choice) ? A2I(choice) : -1);
405                 }
406
407                 /* Totally Illegal */
408                 if ((i < 0) || (i >= num))
409                 {
410                         bell();
411                         continue;
412                 }
413
414                 /* Save the spell index */
415                 spell = spells[i];
416
417                 /* Require "okay" spells */
418                 if (!spell_okay(spell, learned, FALSE, use_realm))
419                 {
420                         bell();
421 #ifdef JP
422                         msg_format("その%sを%sことはできません。", p, prompt);
423 #else
424                         msg_format("You may not %s that %s.", prompt, p);
425 #endif
426
427                         continue;
428                 }
429
430                 /* Verify it */
431                 if (ask)
432                 {
433                         char tmp_val[160];
434
435                         /* Access the spell */
436                         if (!is_magic(use_realm))
437                         {
438                                 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
439                         }
440                         else
441                         {
442                                 s_ptr = &mp_ptr->info[use_realm - 1][spell];
443                         }
444
445                         /* Extract mana consumption rate */
446                         if (use_realm == REALM_HISSATSU)
447                         {
448                                 need_mana = s_ptr->smana;
449                         }
450                         else
451                         {
452                                 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
453                         }
454
455                         /* Prompt */
456 #ifdef JP
457                         jverb(prompt, jverb_buf, JVERB_AND);
458                         /* 英日切り替え機能に対応 */
459                         (void)strnfmt(tmp_val, 78, "%s(MP%d, 失敗率%d%%)を%sますか? ",
460                                 do_spell(use_realm, spell, SPELL_NAME), need_mana,
461                                 spell_chance(spell, use_realm), jverb_buf);
462 #else
463                         (void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ",
464                                 prompt, do_spell(use_realm, spell, SPELL_NAME), need_mana,
465                                 spell_chance(spell, use_realm));
466 #endif
467
468
469                         /* Belay that order */
470                         if (!get_check(tmp_val)) continue;
471                 }
472
473                 /* Stop the loop */
474                 flag = TRUE;
475         }
476
477         if (redraw) screen_load();
478
479         p_ptr->window |= (PW_SPELL);
480         handle_stuff();
481
482         /* Abort if needed */
483         if (!flag) return FALSE;
484
485         /* Save the choice */
486         (*sn) = spell;
487
488         repeat_push((COMMAND_CODE)spell);
489
490         /* Success */
491         return TRUE;
492 }
493
494 /*!
495  * @brief プレイヤーの職業が練気術師の時、領域魔法と練気術を切り換える処理のインターフェイス
496  * @param browse_only 魔法と技能の閲覧を行うならばTRUE
497  * @return 魔道書を一冊も持っていないならTRUEを返す
498  */
499 static void confirm_use_force(bool browse_only)
500 {
501         char which;
502         COMMAND_CODE code;
503
504         /* Get the item index */
505         if (repeat_pull(&code) && (code == INVEN_FORCE))
506         {
507                 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
508                 return;
509         }
510
511         /* Show the prompt */
512         prt(_("('w'練気術, ESC) 'w'かESCを押してください。 ", "(w for the Force, ESC) Hit 'w' or ESC. "), 0, 0);
513
514         while (1)
515         {
516                 /* Get a key */
517                 which = inkey();
518
519                 if (which == ESCAPE) break;
520                 else if (which == 'w')
521                 {
522                         repeat_push(INVEN_FORCE);
523                         break;
524                 }
525         }
526
527         /* Clear the prompt line */
528         prt("", 0, 0);
529
530         if (which == 'w')
531         {
532                 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
533         }
534 }
535
536
537 /*!
538  * @brief プレイヤーの魔法と技能を閲覧するコマンドのメインルーチン /
539  * Peruse the spells/prayers in a book
540  * @return なし
541  * @details
542  * <pre>
543  * Note that *all* spells in the book are listed
544  *
545  * Note that browsing is allowed while confused or blind,
546  * and in the dark, primarily to allow browsing in stores.
547  * </pre>
548  */
549 void do_cmd_browse(void)
550 {
551         OBJECT_IDX item;
552         OBJECT_SUBTYPE_VALUE sval;
553         REALM_IDX use_realm = 0;
554         int j, line;
555         SPELL_IDX spell = -1;
556         int num = 0;
557
558         SPELL_IDX spells[64];
559         char temp[62 * 4];
560
561         object_type *o_ptr;
562
563         concptr q, s;
564
565         /* Warriors are illiterate */
566         if (!(p_ptr->realm1 || p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
567         {
568                 msg_print(_("本を読むことができない!", "You cannot read books!"));
569                 return;
570         }
571
572         if (p_ptr->special_defense & KATA_MUSOU)
573         {
574                 set_action(ACTION_NONE);
575         }
576
577         if (p_ptr->pclass == CLASS_FORCETRAINER)
578         {
579                 if (player_has_no_spellbooks())
580                 {
581                         confirm_use_force(TRUE);
582                         return;
583                 }
584         }
585
586         /* Restrict choices to "useful" books */
587         if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
588         else item_tester_hook = item_tester_learn_spell;
589
590         q = _("どの本を読みますか? ", "Browse which book? ");
591         s = _("読める本がない。", "You have no books that you can read.");
592
593         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | (p_ptr->pclass == CLASS_FORCETRAINER ? USE_FORCE : 0)));
594         if (!o_ptr)
595         {
596                 if (item == INVEN_FORCE) /* the_force */
597                 {
598                         do_cmd_mind_browse();
599                         return;
600                 }
601                 return;
602         }
603
604         /* Access the item's sval */
605         sval = o_ptr->sval;
606
607         use_realm = tval2realm(o_ptr->tval);
608
609         /* Track the object kind */
610         object_kind_track(o_ptr->k_idx);
611         handle_stuff();
612
613         /* Extract spells */
614         for (spell = 0; spell < 32; spell++)
615         {
616                 /* Check for this spell */
617                 if ((fake_spell_flags[sval] & (1L << spell)))
618                 {
619                         /* Collect this spell */
620                         spells[num++] = spell;
621                 }
622         }
623
624         screen_save();
625         prt("", 0, 0);
626
627         /* Keep browsing spells.  Exit browsing on cancel. */
628         while (TRUE)
629         {
630                 /* Ask for a spell, allow cancel */
631                 if (!get_spell(&spell, _("読む", "browse"), o_ptr->sval, TRUE, use_realm))
632                 {
633                         /* If cancelled, leave immediately. */
634                         if (spell == -1) break;
635
636                         /* Display a list of spells */
637                         print_spells(0, spells, num, 1, 15, use_realm);
638
639                         /* Notify that there's nothing to see, and wait. */
640                         if (use_realm == REALM_HISSATSU)
641                                 prt(_("読める技がない。", "No techniques to browse."), 0, 0);
642                         else
643                                 prt(_("読める呪文がない。", "No spells to browse."), 0, 0);
644                         (void)inkey();
645
646                         screen_load();
647
648                         return;
649                 }
650
651                 /* Clear lines, position cursor  (really should use strlen here) */
652                 Term_erase(14, 14, 255);
653                 Term_erase(14, 13, 255);
654                 Term_erase(14, 12, 255);
655                 Term_erase(14, 11, 255);
656
657                 roff_to_buf(do_spell(use_realm, spell, SPELL_DESC), 62, temp, sizeof(temp));
658
659                 for (j = 0, line = 11; temp[j]; j += 1 + strlen(&temp[j]))
660                 {
661                         prt(&temp[j], line, 15);
662                         line++;
663                 }
664         }
665         screen_load();
666 }
667
668 /*!
669  * @brief プレイヤーの第二魔法領域を変更する /
670  * @param next_realm 変更先の魔法領域ID
671  * @return なし
672  */
673 static void change_realm2(CHARACTER_IDX next_realm)
674 {
675         int i, j = 0;
676         char tmp[80];
677
678         for (i = 0; i < 64; i++)
679         {
680                 p_ptr->spell_order[j] = p_ptr->spell_order[i];
681                 if (p_ptr->spell_order[i] < 32) j++;
682         }
683         for (; j < 64; j++)
684                 p_ptr->spell_order[j] = 99;
685
686         for (i = 32; i < 64; i++)
687         {
688                 p_ptr->spell_exp[i] = SPELL_EXP_UNSKILLED;
689         }
690         p_ptr->spell_learned2 = 0L;
691         p_ptr->spell_worked2 = 0L;
692         p_ptr->spell_forgotten2 = 0L;
693
694         sprintf(tmp, _("魔法の領域を%sから%sに変更した。", "change magic realm from %s to %s."), realm_names[p_ptr->realm2], realm_names[next_realm]);
695         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
696         p_ptr->old_realm |= 1 << (p_ptr->realm2 - 1);
697         p_ptr->realm2 = next_realm;
698
699         p_ptr->update |= (PU_REORDER);
700         p_ptr->update |= (PU_SPELLS);
701         handle_stuff();
702
703         /* Load an autopick preference file */
704         autopick_load_pref(FALSE);
705 }
706
707
708 /*!
709  * @brief 魔法を学習するコマンドのメインルーチン /
710  * Study a book to gain a new spell/prayer
711  * @return なし
712  */
713 void do_cmd_study(void)
714 {
715         int     i;
716         OBJECT_IDX item;
717         OBJECT_SUBTYPE_VALUE sval;
718         int     increment = 0;
719         bool    learned = FALSE;
720
721         /* Spells of realm2 will have an increment of +32 */
722         SPELL_IDX spell = -1;
723
724         concptr p = spell_category_name(mp_ptr->spell_book);
725
726         object_type *o_ptr;
727
728         concptr q, s;
729
730         if (!p_ptr->realm1)
731         {
732                 msg_print(_("本を読むことができない!", "You cannot read books!"));
733                 return;
734         }
735
736         if (p_ptr->blind || no_lite())
737         {
738                 msg_print(_("目が見えない!", "You cannot see!"));
739                 return;
740         }
741
742         if (cmd_limit_confused(p_ptr)) return;
743
744         if (!(p_ptr->new_spells))
745         {
746                 msg_format(_("新しい%sを覚えることはできない!", "You cannot learn any new %ss!"), p);
747                 return;
748         }
749
750         if (p_ptr->special_defense & KATA_MUSOU)
751         {
752                 set_action(ACTION_NONE);
753         }
754
755 #ifdef JP
756         if (p_ptr->new_spells < 10) {
757                 msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
758         }
759         else {
760                 msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
761         }
762 #else
763         msg_format("You can learn %d new %s%s.", p_ptr->new_spells, p,
764                 (p_ptr->new_spells == 1 ? "" : "s"));
765 #endif
766
767         msg_print(NULL);
768
769
770         /* Restrict choices to "useful" books */
771         if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
772         else item_tester_hook = item_tester_learn_spell;
773
774         q = _("どの本から学びますか? ", "Study which book? ");
775         s = _("読める本がない。", "You have no books that you can read.");
776
777         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
778         if (!o_ptr) return;
779
780         /* Access the item's sval */
781         sval = o_ptr->sval;
782
783         if (o_ptr->tval == REALM2_BOOK) increment = 32;
784         else if (o_ptr->tval != REALM1_BOOK)
785         {
786                 if (!get_check(_("本当に魔法の領域を変更しますか?", "Really, change magic realm? "))) return;
787                 change_realm2(tval2realm(o_ptr->tval));
788                 increment = 32;
789         }
790
791         /* Track the object kind */
792         object_kind_track(o_ptr->k_idx);
793         handle_stuff();
794
795         /* Mage -- Learn a selected spell */
796         if (mp_ptr->spell_book != TV_LIFE_BOOK)
797         {
798                 /* Ask for a spell, allow cancel */
799                 if (!get_spell(&spell, _("学ぶ", "study"), sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1) && (spell == -1)) return;
800         }
801
802         /* Priest -- Learn a random prayer */
803         else
804         {
805                 int k = 0;
806                 int gift = -1;
807
808                 /* Extract spells */
809                 for (spell = 0; spell < 32; spell++)
810                 {
811                         /* Check spells in the book */
812                         if ((fake_spell_flags[sval] & (1L << spell)))
813                         {
814                                 /* Skip non "okay" prayers */
815                                 if (!spell_okay(spell, FALSE, TRUE,
816                                         (increment ? p_ptr->realm2 : p_ptr->realm1))) continue;
817
818                                 /* Hack -- Prepare the randomizer */
819                                 k++;
820
821                                 /* Hack -- Apply the randomizer */
822                                 if (one_in_(k)) gift = spell;
823                         }
824                 }
825
826                 /* Accept gift */
827                 spell = gift;
828         }
829
830         /* Nothing to study */
831         if (spell < 0)
832         {
833                 msg_format(_("その本には学ぶべき%sがない。", "You cannot learn any %ss in that book."), p);
834
835                 /* Abort */
836                 return;
837         }
838
839         if (increment) spell += increment;
840
841         /* Learn the spell */
842         if (spell < 32)
843         {
844                 if (p_ptr->spell_learned1 & (1L << spell)) learned = TRUE;
845                 else p_ptr->spell_learned1 |= (1L << spell);
846         }
847         else
848         {
849                 if (p_ptr->spell_learned2 & (1L << (spell - 32))) learned = TRUE;
850                 else p_ptr->spell_learned2 |= (1L << (spell - 32));
851         }
852
853         if (learned)
854         {
855                 int max_exp = (spell < 32) ? SPELL_EXP_MASTER : SPELL_EXP_EXPERT;
856                 int old_exp = p_ptr->spell_exp[spell];
857                 int new_rank = EXP_LEVEL_UNSKILLED;
858                 concptr name = do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME);
859
860                 if (old_exp >= max_exp)
861                 {
862                         msg_format(_("その%sは完全に使いこなせるので学ぶ必要はない。", "You don't need to study this %s anymore."), p);
863                         return;
864                 }
865 #ifdef JP
866                 if (!get_check(format("%sの%sをさらに学びます。よろしいですか?", name, p)))
867 #else
868                 if (!get_check(format("You will study a %s of %s again. Are you sure? ", p, name)))
869 #endif
870                 {
871                         return;
872                 }
873                 else if (old_exp >= SPELL_EXP_EXPERT)
874                 {
875                         p_ptr->spell_exp[spell] = SPELL_EXP_MASTER;
876                         new_rank = EXP_LEVEL_MASTER;
877                 }
878                 else if (old_exp >= SPELL_EXP_SKILLED)
879                 {
880                         if (spell >= 32) p_ptr->spell_exp[spell] = SPELL_EXP_EXPERT;
881                         else p_ptr->spell_exp[spell] += SPELL_EXP_EXPERT - SPELL_EXP_SKILLED;
882                         new_rank = EXP_LEVEL_EXPERT;
883                 }
884                 else if (old_exp >= SPELL_EXP_BEGINNER)
885                 {
886                         p_ptr->spell_exp[spell] = SPELL_EXP_SKILLED + (old_exp - SPELL_EXP_BEGINNER) * 2 / 3;
887                         new_rank = EXP_LEVEL_SKILLED;
888                 }
889                 else
890                 {
891                         p_ptr->spell_exp[spell] = SPELL_EXP_BEGINNER + old_exp / 3;
892                         new_rank = EXP_LEVEL_BEGINNER;
893                 }
894                 msg_format(_("%sの熟練度が%sに上がった。", "Your proficiency of %s is now %s rank."), name, exp_level_str[new_rank]);
895         }
896         else
897         {
898                 /* Find the next open entry in "p_ptr->spell_order[]" */
899                 for (i = 0; i < 64; i++)
900                 {
901                         /* Stop at the first empty space */
902                         if (p_ptr->spell_order[i] == 99) break;
903                 }
904
905                 /* Add the spell to the known list */
906                 p_ptr->spell_order[i++] = spell;
907
908                 /* Mention the result */
909 #ifdef JP
910                 /* 英日切り替え機能に対応 */
911                 if (mp_ptr->spell_book == TV_MUSIC_BOOK)
912                 {
913                         msg_format("%sを学んだ。",
914                                 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
915                 }
916                 else
917                 {
918                         msg_format("%sの%sを学んだ。",
919                                 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME), p);
920                 }
921 #else
922                 msg_format("You have learned the %s of %s.",
923                         p, do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
924 #endif
925         }
926
927         take_turn(p_ptr, 100);;
928
929         switch (mp_ptr->spell_book)
930         {
931         case TV_LIFE_BOOK:
932                 chg_virtue(V_FAITH, 1);
933                 break;
934         case TV_DEATH_BOOK:
935                 chg_virtue(V_UNLIFE, 1);
936                 break;
937         case TV_NATURE_BOOK:
938                 chg_virtue(V_NATURE, 1);
939                 break;
940         default:
941                 chg_virtue(V_KNOWLEDGE, 1);
942                 break;
943         }
944
945         sound(SOUND_STUDY);
946
947         /* One less spell available */
948         p_ptr->learned_spells++;
949
950         /* Update Study */
951         p_ptr->update |= (PU_SPELLS);
952         update_creature(p_ptr);
953
954         /* Redraw object recall */
955         p_ptr->window |= (PW_OBJECT);
956 }
957
958
959 /*!
960  * @brief 魔法を詠唱するコマンドのメインルーチン /
961  * Cast a spell
962  * @return なし
963  */
964 void do_cmd_cast(void)
965 {
966         OBJECT_IDX item;
967         OBJECT_SUBTYPE_VALUE sval;
968         SPELL_IDX spell;
969         REALM_IDX realm;
970         int     chance;
971         int     increment = 0;
972         REALM_IDX use_realm;
973         MANA_POINT need_mana;
974
975         concptr prayer;
976         object_type *o_ptr;
977         const magic_type *s_ptr;
978         concptr q, s;
979
980         bool over_exerted = FALSE;
981
982         /* Require spell ability */
983         if (!p_ptr->realm1 && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
984         {
985                 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
986                 return;
987         }
988
989         /* Require lite */
990         if (p_ptr->blind || no_lite())
991         {
992                 if (p_ptr->pclass == CLASS_FORCETRAINER) confirm_use_force(FALSE);
993                 else
994                 {
995                         msg_print(_("目が見えない!", "You cannot see!"));
996                         flush();
997                 }
998                 return;
999         }
1000
1001         if (cmd_limit_confused(p_ptr)) return;
1002
1003         /* Hex */
1004         if (p_ptr->realm1 == REALM_HEX)
1005         {
1006                 if (hex_spell_fully())
1007                 {
1008                         bool flag = FALSE;
1009                         msg_print(_("これ以上新しい呪文を詠唱することはできない。", "Can not spell new spells more."));
1010                         flush();
1011                         if (p_ptr->lev >= 35) flag = stop_hex_spell();
1012                         if (!flag) return;
1013                 }
1014         }
1015
1016         if (p_ptr->pclass == CLASS_FORCETRAINER)
1017         {
1018                 if (player_has_no_spellbooks())
1019                 {
1020                         confirm_use_force(FALSE);
1021                         return;
1022                 }
1023         }
1024
1025         prayer = spell_category_name(mp_ptr->spell_book);
1026
1027         /* Restrict choices to spell books */
1028         item_tester_tval = mp_ptr->spell_book;
1029
1030         q = _("どの呪文書を使いますか? ", "Use which book? ");
1031         s = _("呪文書がない!", "You have no spell books!");
1032
1033         o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | (p_ptr->pclass == CLASS_FORCETRAINER ? USE_FORCE : 0)));
1034         if (!o_ptr)
1035         {
1036                 if (item == INVEN_FORCE) /* the_force */
1037                 {
1038                         do_cmd_mind();
1039                         return;
1040                 }
1041                 return;
1042         }
1043
1044         /* Access the item's sval */
1045         sval = o_ptr->sval;
1046
1047         if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && (o_ptr->tval == REALM2_BOOK)) increment = 32;
1048
1049         /* Track the object kind */
1050         object_kind_track(o_ptr->k_idx);
1051         handle_stuff();
1052
1053         if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
1054                 realm = o_ptr->tval - TV_LIFE_BOOK + 1;
1055         else if (increment) realm = p_ptr->realm2;
1056         else realm = p_ptr->realm1;
1057
1058         /* Ask for a spell */
1059 #ifdef JP
1060         if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_MUSIC_BOOK) ? "歌う" : "唱える"),
1061                 sval, TRUE, realm))
1062         {
1063                 if (spell == -2) msg_format("その本には知っている%sがない。", prayer);
1064                 return;
1065         }
1066 #else
1067         if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1068                 sval, TRUE, realm))
1069         {
1070                 if (spell == -2)
1071                         msg_format("You don't know any %ss in that book.", prayer);
1072                 return;
1073         }
1074 #endif
1075
1076
1077         use_realm = tval2realm(o_ptr->tval);
1078
1079         /* Hex */
1080         if (use_realm == REALM_HEX)
1081         {
1082                 if (hex_spelling(spell))
1083                 {
1084                         msg_print(_("その呪文はすでに詠唱中だ。", "You are already casting it."));
1085                         return;
1086                 }
1087         }
1088
1089         if (!is_magic(use_realm))
1090         {
1091                 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
1092         }
1093         else
1094         {
1095                 s_ptr = &mp_ptr->info[realm - 1][spell];
1096         }
1097
1098         /* Extract mana consumption rate */
1099         need_mana = mod_need_mana(s_ptr->smana, spell, realm);
1100
1101         /* Verify "dangerous" spells */
1102         if (need_mana > p_ptr->csp)
1103         {
1104                 if (flush_failure) flush();
1105
1106                 /* Warning */
1107 #ifdef JP
1108                 msg_format("その%sを%sのに十分なマジックポイントがない。", prayer,
1109                         ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_LIFE_BOOK) ? "歌う" : "唱える"));
1110 #else
1111                 msg_format("You do not have enough mana to %s this %s.",
1112                         ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1113                         prayer);
1114 #endif
1115
1116
1117                 if (!over_exert) return;
1118
1119                 /* Verify */
1120                 if (!get_check_strict(_("それでも挑戦しますか? ", "Attempt it anyway? "), CHECK_OKAY_CANCEL)) return;
1121         }
1122
1123         /* Spell failure chance */
1124         chance = spell_chance(spell, use_realm);
1125
1126         /* Sufficient mana */
1127         if (need_mana <= p_ptr->csp)
1128         {
1129                 /* Use some mana */
1130                 p_ptr->csp -= need_mana;
1131         }
1132         else over_exerted = TRUE;
1133         p_ptr->redraw |= (PR_MANA);
1134
1135         /* Failed spell */
1136         if (randint0(100) < chance)
1137         {
1138                 if (flush_failure) flush();
1139
1140                 msg_format(_("%sをうまく唱えられなかった!", "You failed to get the %s off!"), prayer);
1141                 sound(SOUND_FAIL);
1142
1143                 switch (realm)
1144                 {
1145                 case REALM_LIFE:
1146                         if (randint1(100) < chance) chg_virtue(V_VITALITY, -1);
1147                         break;
1148                 case REALM_DEATH:
1149                         if (randint1(100) < chance) chg_virtue(V_UNLIFE, -1);
1150                         break;
1151                 case REALM_NATURE:
1152                         if (randint1(100) < chance) chg_virtue(V_NATURE, -1);
1153                         break;
1154                 case REALM_DAEMON:
1155                         if (randint1(100) < chance) chg_virtue(V_JUSTICE, 1);
1156                         break;
1157                 case REALM_CRUSADE:
1158                         if (randint1(100) < chance) chg_virtue(V_JUSTICE, -1);
1159                         break;
1160                 case REALM_HEX:
1161                         if (randint1(100) < chance) chg_virtue(V_COMPASSION, -1);
1162                         break;
1163                 default:
1164                         if (randint1(100) < chance) chg_virtue(V_KNOWLEDGE, -1);
1165                         break;
1166                 }
1167
1168                 /* Failure casting may activate some side effect */
1169                 do_spell(realm, spell, SPELL_FAIL);
1170
1171
1172                 if ((o_ptr->tval == TV_CHAOS_BOOK) && (randint1(100) < spell))
1173                 {
1174                         msg_print(_("カオス的な効果を発生した!", "You produce a chaotic effect!"));
1175                         wild_magic(spell);
1176                 }
1177                 else if ((o_ptr->tval == TV_DEATH_BOOK) && (randint1(100) < spell))
1178                 {
1179                         if ((sval == 3) && one_in_(2))
1180                         {
1181                                 sanity_blast(0, TRUE);
1182                         }
1183                         else
1184                         {
1185                                 msg_print(_("痛い!", "It hurts!"));
1186                                 take_hit(DAMAGE_LOSELIFE, damroll(o_ptr->sval + 1, 6), _("暗黒魔法の逆流", "a miscast Death spell"), -1);
1187
1188                                 if ((spell > 15) && one_in_(6) && !p_ptr->hold_exp)
1189                                         lose_exp(spell * 250);
1190                         }
1191                 }
1192                 else if ((o_ptr->tval == TV_MUSIC_BOOK) && (randint1(200) < spell))
1193                 {
1194                         msg_print(_("いやな音が響いた", "An infernal sound echoed."));
1195                         aggravate_monsters(0);
1196                 }
1197                 if (randint1(100) >= chance)
1198                         chg_virtue(V_CHANCE, -1);
1199         }
1200
1201         /* Process spell */
1202         else
1203         {
1204                 /* Canceled spells cost neither a turn nor mana */
1205                 if (!do_spell(realm, spell, SPELL_CAST)) return;
1206
1207                 if (randint1(100) < chance)
1208                         chg_virtue(V_CHANCE, 1);
1209
1210                 /* A spell was cast */
1211                 if (!(increment ?
1212                         (p_ptr->spell_worked2 & (1L << spell)) :
1213                         (p_ptr->spell_worked1 & (1L << spell)))
1214                         && (p_ptr->pclass != CLASS_SORCERER)
1215                         && (p_ptr->pclass != CLASS_RED_MAGE))
1216                 {
1217                         int e = s_ptr->sexp;
1218
1219                         /* The spell worked */
1220                         if (realm == p_ptr->realm1)
1221                         {
1222                                 p_ptr->spell_worked1 |= (1L << spell);
1223                         }
1224                         else
1225                         {
1226                                 p_ptr->spell_worked2 |= (1L << spell);
1227                         }
1228
1229                         /* Gain experience */
1230                         gain_exp(e * s_ptr->slevel);
1231
1232                         /* Redraw object recall */
1233                         p_ptr->window |= (PW_OBJECT);
1234
1235                         switch (realm)
1236                         {
1237                         case REALM_LIFE:
1238                                 chg_virtue(V_TEMPERANCE, 1);
1239                                 chg_virtue(V_COMPASSION, 1);
1240                                 chg_virtue(V_VITALITY, 1);
1241                                 chg_virtue(V_DILIGENCE, 1);
1242                                 break;
1243                         case REALM_DEATH:
1244                                 chg_virtue(V_UNLIFE, 1);
1245                                 chg_virtue(V_JUSTICE, -1);
1246                                 chg_virtue(V_FAITH, -1);
1247                                 chg_virtue(V_VITALITY, -1);
1248                                 break;
1249                         case REALM_DAEMON:
1250                                 chg_virtue(V_JUSTICE, -1);
1251                                 chg_virtue(V_FAITH, -1);
1252                                 chg_virtue(V_HONOUR, -1);
1253                                 chg_virtue(V_TEMPERANCE, -1);
1254                                 break;
1255                         case REALM_CRUSADE:
1256                                 chg_virtue(V_FAITH, 1);
1257                                 chg_virtue(V_JUSTICE, 1);
1258                                 chg_virtue(V_SACRIFICE, 1);
1259                                 chg_virtue(V_HONOUR, 1);
1260                                 break;
1261                         case REALM_NATURE:
1262                                 chg_virtue(V_NATURE, 1);
1263                                 chg_virtue(V_HARMONY, 1);
1264                                 break;
1265                         case REALM_HEX:
1266                                 chg_virtue(V_JUSTICE, -1);
1267                                 chg_virtue(V_FAITH, -1);
1268                                 chg_virtue(V_HONOUR, -1);
1269                                 chg_virtue(V_COMPASSION, -1);
1270                                 break;
1271                         default:
1272                                 chg_virtue(V_KNOWLEDGE, 1);
1273                                 break;
1274                         }
1275                 }
1276                 switch (realm)
1277                 {
1278                 case REALM_LIFE:
1279                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, 1);
1280                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, 1);
1281                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, 1);
1282                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_DILIGENCE, 1);
1283                         break;
1284                 case REALM_DEATH:
1285                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_UNLIFE, 1);
1286                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1287                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1288                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, -1);
1289                         break;
1290                 case REALM_DAEMON:
1291                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1292                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1293                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1294                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, -1);
1295                         break;
1296                 case REALM_CRUSADE:
1297                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, 1);
1298                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, 1);
1299                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_SACRIFICE, 1);
1300                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, 1);
1301                         break;
1302                 case REALM_NATURE:
1303                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_NATURE, 1);
1304                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HARMONY, 1);
1305                         break;
1306                 case REALM_HEX:
1307                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1308                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1309                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1310                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, -1);
1311                         break;
1312                 }
1313                 if (mp_ptr->spell_xtra & MAGIC_GAIN_EXP)
1314                 {
1315                         s16b cur_exp = p_ptr->spell_exp[(increment ? 32 : 0) + spell];
1316                         s16b exp_gain = 0;
1317
1318                         if (cur_exp < SPELL_EXP_BEGINNER)
1319                                 exp_gain += 60;
1320                         else if (cur_exp < SPELL_EXP_SKILLED)
1321                         {
1322                                 if ((dun_level > 4) && ((dun_level + 10) > p_ptr->lev))
1323                                         exp_gain = 8;
1324                         }
1325                         else if (cur_exp < SPELL_EXP_EXPERT)
1326                         {
1327                                 if (((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel))
1328                                         exp_gain = 2;
1329                         }
1330                         else if ((cur_exp < SPELL_EXP_MASTER) && !increment)
1331                         {
1332                                 if (((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel))
1333                                         exp_gain = 1;
1334                         }
1335                         p_ptr->spell_exp[(increment ? 32 : 0) + spell] += exp_gain;
1336                 }
1337         }
1338
1339         take_turn(p_ptr, 100);;
1340
1341
1342         /* Over-exert the player */
1343         if (over_exerted)
1344         {
1345                 int oops = need_mana;
1346
1347                 /* No mana left */
1348                 p_ptr->csp = 0;
1349                 p_ptr->csp_frac = 0;
1350
1351                 msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
1352
1353                 /* Hack -- Bypass free action */
1354                 (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
1355
1356                 switch (realm)
1357                 {
1358                 case REALM_LIFE:
1359                         chg_virtue(V_VITALITY, -10);
1360                         break;
1361                 case REALM_DEATH:
1362                         chg_virtue(V_UNLIFE, -10);
1363                         break;
1364                 case REALM_DAEMON:
1365                         chg_virtue(V_JUSTICE, 10);
1366                         break;
1367                 case REALM_NATURE:
1368                         chg_virtue(V_NATURE, -10);
1369                         break;
1370                 case REALM_CRUSADE:
1371                         chg_virtue(V_JUSTICE, -10);
1372                         break;
1373                 case REALM_HEX:
1374                         chg_virtue(V_COMPASSION, 10);
1375                         break;
1376                 default:
1377                         chg_virtue(V_KNOWLEDGE, -10);
1378                         break;
1379                 }
1380
1381                 /* Damage CON (possibly permanently) */
1382                 if (randint0(100) < 50)
1383                 {
1384                         bool perm = (randint0(100) < 25);
1385
1386                         msg_print(_("体を悪くしてしまった!", "You have damaged your health!"));
1387
1388                         /* Reduce constitution */
1389                         (void)dec_stat(A_CON, 15 + randint1(10), perm);
1390                 }
1391         }
1392
1393         p_ptr->window |= (PW_PLAYER);
1394         p_ptr->window |= (PW_SPELL);
1395 }