3 * @brief プレイヤーの魔法に関するコマンドの実装 / Spell/Prayer commands
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
17 * @brief 領域魔法に応じて技能の名称を返す。
18 * @param tval 魔法書のtval
19 * @return 領域魔法の技能名称を保管した文字列ポインタ
21 cptr spell_category_name(OBJECT_TYPE_VALUE tval)
25 case TV_HISSATSU_BOOK:
26 return _("必殺技", "art");
28 return _("祈り", "prayer");
30 return _("歌", "song");
32 return _("呪文", "spell");
37 bool select_the_force = FALSE;
40 * @brief 領域魔法の閲覧、学習、使用選択するインターフェイス処理
41 * Allow user to choose a spell/prayer from the given book.
42 * @param sn 選択した魔法IDを返す参照ポインタ
43 * @param prompt 魔法を利用する際の動詞表記
44 * @param sval 魔道書のsval
45 * @param learned 閲覧/使用選択ならばTRUE、学習処理ならFALSE
46 * @param use_realm 魔法領域ID
49 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
50 * If the user hits escape, returns FALSE, and set '*sn' to -1
51 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
52 * The "prompt" should be "cast", "recite", or "study"
53 * The "known" should be TRUE for cast/pray, FALSE for study
56 static int get_spell(SPELL_IDX *sn, cptr prompt, OBJECT_SUBTYPE_VALUE sval, bool learned, REALM_IDX use_realm)
64 bool flag, redraw, okay;
66 const magic_type *s_ptr;
73 int menu_line = (use_menu ? 1 : 0);
75 /* Get the spell, if available */
76 if (repeat_pull(&code))
78 *sn = (SPELL_IDX)code;
79 /* Verify the spell */
80 if (spell_okay(*sn, learned, FALSE, use_realm))
87 p = spell_category_name(mp_ptr->spell_book);
90 for (spell = 0; spell < 32; spell++)
92 /* Check for this spell */
93 if ((fake_spell_flags[sval] & (1L << spell)))
95 /* Collect this spell */
96 spells[num++] = spell;
100 /* Assume no usable spells */
103 /* Assume no spells available */
106 /* Check for "okay" spells */
107 for (i = 0; i < num; i++)
109 /* Look for "okay" spells */
110 if (spell_okay(spells[i], learned, FALSE, use_realm)) okay = TRUE;
113 /* No "okay" spells */
114 if (!okay) return (FALSE);
115 if (((use_realm) != p_ptr->realm1) && ((use_realm) != p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return FALSE;
116 if (((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) && !is_magic(use_realm)) return FALSE;
117 if ((p_ptr->pclass == CLASS_RED_MAGE) && ((use_realm) != REALM_ARCANE) && (sval > 1)) return FALSE;
119 /* Assume cancelled */
122 /* Nothing chosen yet */
129 p_ptr->window |= (PW_SPELL);
133 /* Build a prompt (accept all spells) */
135 jverb( prompt, jverb_buf, JVERB_AND );
136 (void) strnfmt(out_val, 78, "(%^s:%c-%c, '*'で一覧, ESCで中断) どの%sを%^sますか? ",
137 p, I2A(0), I2A(num - 1), p, jverb_buf );
139 (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) %^s which %s? ",
140 p, I2A(0), I2A(num - 1), prompt, p);
143 /* Get a spell from the user */
145 choice = (always_show_list || use_menu) ? ESCAPE : 1;
148 if (choice == ESCAPE) choice = ' ';
149 else if (!get_com(out_val, &choice, TRUE))break;
151 if (use_menu && choice != ' ')
165 menu_line += (num - 1);
187 if (menu_line > num) menu_line -= num;
188 /* Display a list of spells */
189 print_spells(menu_line, spells, num, 1, 15, use_realm);
195 if ((choice == ' ') || (choice == '*') || (choice == '?'))
203 /* Save the screen */
206 /* Display a list of spells */
207 print_spells(menu_line, spells, num, 1, 15, use_realm);
213 if (use_menu) continue;
218 /* Restore the screen */
228 ask = (isupper(choice));
231 if (ask) choice = (char)tolower(choice);
233 /* Extract request */
234 i = (islower(choice) ? A2I(choice) : -1);
237 /* Totally Illegal */
238 if ((i < 0) || (i >= num))
244 /* Save the spell index */
247 /* Require "okay" spells */
248 if (!spell_okay(spell, learned, FALSE, use_realm))
252 msg_format("その%sを%sことはできません。", p, prompt);
254 msg_format("You may not %s that %s.", prompt, p);
265 /* Access the spell */
266 if (!is_magic(use_realm))
268 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
272 s_ptr = &mp_ptr->info[use_realm - 1][spell];
275 /* Extract mana consumption rate */
276 if (use_realm == REALM_HISSATSU)
278 need_mana = s_ptr->smana;
282 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
287 jverb( prompt, jverb_buf, JVERB_AND );
289 (void) strnfmt(tmp_val, 78, "%s(MP%d, 失敗率%d%%)を%sますか? ",
290 do_spell(use_realm, spell, SPELL_NAME), need_mana,
291 spell_chance(spell, use_realm),jverb_buf);
293 (void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ",
294 prompt, do_spell(use_realm, spell, SPELL_NAME), need_mana,
295 spell_chance(spell, use_realm));
299 /* Belay that order */
300 if (!get_check(tmp_val)) continue;
308 /* Restore the screen */
309 if (redraw) screen_load();
313 p_ptr->window |= (PW_SPELL);
318 /* Abort if needed */
319 if (!flag) return FALSE;
321 /* Save the choice */
324 repeat_push((COMMAND_CODE)spell);
331 * @brief オブジェクトがプレイヤーが使用可能な魔道書かどうかを判定する
332 * @param o_ptr 判定したいオブ会ジェクトの構造体参照ポインタ
333 * @return 学習できる魔道書ならばTRUEを返す
335 static bool item_tester_learn_spell(object_type *o_ptr)
337 s32b choices = realm_choices2[p_ptr->pclass];
339 if (p_ptr->pclass == CLASS_PRIEST)
341 if (is_good_realm(p_ptr->realm1))
343 choices &= ~(CH_DEATH | CH_DAEMON);
347 choices &= ~(CH_LIFE | CH_CRUSADE);
351 if ((o_ptr->tval < TV_LIFE_BOOK) || (o_ptr->tval > (TV_LIFE_BOOK + MAX_REALM - 1))) return (FALSE);
352 if ((o_ptr->tval == TV_MUSIC_BOOK) && (p_ptr->pclass == CLASS_BARD)) return (TRUE);
353 else if (!is_magic(tval2realm(o_ptr->tval))) return FALSE;
354 if ((REALM1_BOOK == o_ptr->tval) || (REALM2_BOOK == o_ptr->tval)) return (TRUE);
355 if (choices & (0x0001 << (tval2realm(o_ptr->tval) - 1))) return (TRUE);
360 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
361 * @return 魔道書を一冊も持っていないならTRUEを返す
363 static bool player_has_no_spellbooks(void)
368 for (i = 0; i < INVEN_PACK; i++)
370 o_ptr = &inventory[i];
371 if (o_ptr->k_idx && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
374 for (i = cave[p_ptr->y][p_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
377 if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
384 * @brief プレイヤーの職業が練気術師の時、領域魔法と練気術を切り換える処理のインターフェイス
385 * @param browse_only 魔法と技能の閲覧を行うならばTRUE
386 * @return 魔道書を一冊も持っていないならTRUEを返す
388 static void confirm_use_force(bool browse_only)
393 /* Get the item index */
394 if (repeat_pull(&code) && (code == INVEN_FORCE))
396 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
400 /* Show the prompt */
401 prt(_("('w'練気術, ESC) 'w'かESCを押してください。 ", "(w for the Force, ESC) Hit 'w' or ESC. "), 0, 0);
408 if (which == ESCAPE) break;
409 else if (which == 'w')
412 repeat_push(INVEN_FORCE);
418 /* Clear the prompt line */
423 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
429 * @brief プレイヤーの魔法と技能を閲覧するコマンドのメインルーチン /
430 * Peruse the spells/prayers in a book
434 * Note that *all* spells in the book are listed
436 * Note that browsing is allowed while confused or blind,
437 * and in the dark, primarily to allow browsing in stores.
440 void do_cmd_browse(void)
443 OBJECT_SUBTYPE_VALUE sval;
444 REALM_IDX use_realm = 0;
446 SPELL_IDX spell = -1;
449 SPELL_IDX spells[64];
456 /* Warriors are illiterate */
457 if (!(p_ptr->realm1 || p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
459 msg_print(_("本を読むことができない!", "You cannot read books!"));
463 if (p_ptr->special_defense & KATA_MUSOU)
465 set_action(ACTION_NONE);
468 if (p_ptr->pclass == CLASS_FORCETRAINER)
470 if (player_has_no_spellbooks())
472 confirm_use_force(TRUE);
475 select_the_force = TRUE;
478 /* Restrict choices to "useful" books */
479 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
480 else item_tester_hook = item_tester_learn_spell;
482 q = _("どの本を読みますか? ", "Browse which book? ");
483 s = _("読める本がない。", "You have no books that you can read.");
485 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
487 select_the_force = FALSE;
490 select_the_force = FALSE;
492 if (item == INVEN_FORCE) /* the_force */
494 do_cmd_mind_browse();
498 /* Get the item (in the pack) */
501 o_ptr = &inventory[item];
504 /* Get the item (on the floor) */
507 o_ptr = &o_list[0 - item];
510 /* Access the item's sval */
513 use_realm = tval2realm(o_ptr->tval);
515 /* Track the object kind */
516 object_kind_track(o_ptr->k_idx);
521 for (spell = 0; spell < 32; spell++)
523 /* Check for this spell */
524 if ((fake_spell_flags[sval] & (1L << spell)))
526 /* Collect this spell */
527 spells[num++] = spell;
532 /* Save the screen */
535 /* Clear the top line */
538 /* Keep browsing spells. Exit browsing on cancel. */
541 /* Ask for a spell, allow cancel */
542 if (!get_spell(&spell, _("読む", "browse"), o_ptr->sval, TRUE, use_realm))
544 /* If cancelled, leave immediately. */
545 if (spell == -1) break;
547 /* Display a list of spells */
548 print_spells(0, spells, num, 1, 15, use_realm);
550 /* Notify that there's nothing to see, and wait. */
551 if (use_realm == REALM_HISSATSU)
552 prt(_("読める技がない。", "No techniques to browse."), 0, 0);
554 prt(_("読める呪文がない。", "No spells to browse."), 0, 0);
558 /* Restore the screen */
564 /* Clear lines, position cursor (really should use strlen here) */
565 Term_erase(14, 14, 255);
566 Term_erase(14, 13, 255);
567 Term_erase(14, 12, 255);
568 Term_erase(14, 11, 255);
570 roff_to_buf(do_spell(use_realm, spell, SPELL_DESC), 62, temp, sizeof(temp));
572 for (j = 0, line = 11; temp[j]; j += 1 + strlen(&temp[j]))
574 prt(&temp[j], line, 15);
579 /* Restore the screen */
584 * @brief プレイヤーの第二魔法領域を変更する /
585 * @param next_realm 変更先の魔法領域ID
588 static void change_realm2(CHARACTER_IDX next_realm)
593 for (i = 0; i < 64; i++)
595 p_ptr->spell_order[j] = p_ptr->spell_order[i];
596 if (p_ptr->spell_order[i] < 32) j++;
599 p_ptr->spell_order[j] = 99;
601 for (i = 32; i < 64; i++)
603 p_ptr->spell_exp[i] = SPELL_EXP_UNSKILLED;
605 p_ptr->spell_learned2 = 0L;
606 p_ptr->spell_worked2 = 0L;
607 p_ptr->spell_forgotten2 = 0L;
609 sprintf(tmp,_("魔法の領域を%sから%sに変更した。", "change magic realm from %s to %s."), realm_names[p_ptr->realm2], realm_names[next_realm]);
610 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
611 p_ptr->old_realm |= 1 << (p_ptr->realm2-1);
612 p_ptr->realm2 = next_realm;
614 p_ptr->notice |= (PN_REORDER);
615 p_ptr->update |= (PU_SPELLS);
618 /* Load an autopick preference file */
619 autopick_load_pref(FALSE);
624 * @brief 魔法を学習するコマンドのメインルーチン /
625 * Study a book to gain a new spell/prayer
628 void do_cmd_study(void)
632 OBJECT_SUBTYPE_VALUE sval;
634 bool learned = FALSE;
636 /* Spells of realm2 will have an increment of +32 */
637 SPELL_IDX spell = -1;
639 cptr p = spell_category_name(mp_ptr->spell_book);
647 msg_print(_("本を読むことができない!", "You cannot read books!"));
651 if (p_ptr->blind || no_lite())
653 msg_print(_("目が見えない!", "You cannot see!"));
659 msg_print(_("混乱していて読めない!", "You are too confused!"));
663 if (!(p_ptr->new_spells))
665 msg_format(_("新しい%sを覚えることはできない!", "You cannot learn any new %ss!"), p);
669 if (p_ptr->special_defense & KATA_MUSOU)
671 set_action(ACTION_NONE);
675 if( p_ptr->new_spells < 10 ){
676 msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
678 msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
681 msg_format("You can learn %d new %s%s.", p_ptr->new_spells, p,
682 (p_ptr->new_spells == 1?"":"s"));
688 /* Restrict choices to "useful" books */
689 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
690 else item_tester_hook = item_tester_learn_spell;
692 q = _("どの本から学びますか? ", "Study which book? ");
693 s = _("読める本がない。", "You have no books that you can read.");
695 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
697 /* Get the item (in the pack) */
700 o_ptr = &inventory[item];
703 /* Get the item (on the floor) */
706 o_ptr = &o_list[0 - item];
709 /* Access the item's sval */
712 if (o_ptr->tval == REALM2_BOOK) increment = 32;
713 else if (o_ptr->tval != REALM1_BOOK)
715 if (!get_check(_("本当に魔法の領域を変更しますか?", "Really, change magic realm? "))) return;
716 change_realm2(tval2realm(o_ptr->tval));
720 /* Track the object kind */
721 object_kind_track(o_ptr->k_idx);
724 /* Mage -- Learn a selected spell */
725 if (mp_ptr->spell_book != TV_LIFE_BOOK)
727 /* Ask for a spell, allow cancel */
728 if (!get_spell(&spell, _("学ぶ", "study"), sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1) && (spell == -1)) return;
731 /* Priest -- Learn a random prayer */
738 for (spell = 0; spell < 32; spell++)
740 /* Check spells in the book */
741 if ((fake_spell_flags[sval] & (1L << spell)))
743 /* Skip non "okay" prayers */
744 if (!spell_okay(spell, FALSE, TRUE,
745 (increment ? p_ptr->realm2 : p_ptr->realm1))) continue;
747 /* Hack -- Prepare the randomizer */
750 /* Hack -- Apply the randomizer */
751 if (one_in_(k)) gift = spell;
759 /* Nothing to study */
762 msg_format(_("その本には学ぶべき%sがない。", "You cannot learn any %ss in that book."), p);
768 if (increment) spell += increment;
770 /* Learn the spell */
773 if (p_ptr->spell_learned1 & (1L << spell)) learned = TRUE;
774 else p_ptr->spell_learned1 |= (1L << spell);
778 if (p_ptr->spell_learned2 & (1L << (spell - 32))) learned = TRUE;
779 else p_ptr->spell_learned2 |= (1L << (spell - 32));
784 int max_exp = (spell < 32) ? SPELL_EXP_MASTER : SPELL_EXP_EXPERT;
785 int old_exp = p_ptr->spell_exp[spell];
786 int new_rank = EXP_LEVEL_UNSKILLED;
787 cptr name = do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell%32, SPELL_NAME);
789 if (old_exp >= max_exp)
791 msg_format(_("その%sは完全に使いこなせるので学ぶ必要はない。", "You don't need to study this %s anymore."), p);
795 if (!get_check(format("%sの%sをさらに学びます。よろしいですか?", name, p)))
797 if (!get_check(format("You will study a %s of %s again. Are you sure? ", p, name)))
802 else if (old_exp >= SPELL_EXP_EXPERT)
804 p_ptr->spell_exp[spell] = SPELL_EXP_MASTER;
805 new_rank = EXP_LEVEL_MASTER;
807 else if (old_exp >= SPELL_EXP_SKILLED)
809 if (spell >= 32) p_ptr->spell_exp[spell] = SPELL_EXP_EXPERT;
810 else p_ptr->spell_exp[spell] += SPELL_EXP_EXPERT - SPELL_EXP_SKILLED;
811 new_rank = EXP_LEVEL_EXPERT;
813 else if (old_exp >= SPELL_EXP_BEGINNER)
815 p_ptr->spell_exp[spell] = SPELL_EXP_SKILLED + (old_exp - SPELL_EXP_BEGINNER) * 2 / 3;
816 new_rank = EXP_LEVEL_SKILLED;
820 p_ptr->spell_exp[spell] = SPELL_EXP_BEGINNER + old_exp / 3;
821 new_rank = EXP_LEVEL_BEGINNER;
823 msg_format(_("%sの熟練度が%sに上がった。", "Your proficiency of %s is now %s rank."), name, exp_level_str[new_rank]);
827 /* Find the next open entry in "p_ptr->spell_order[]" */
828 for (i = 0; i < 64; i++)
830 /* Stop at the first empty space */
831 if (p_ptr->spell_order[i] == 99) break;
834 /* Add the spell to the known list */
835 p_ptr->spell_order[i++] = spell;
837 /* Mention the result */
840 if (mp_ptr->spell_book == TV_MUSIC_BOOK)
842 msg_format("%sを学んだ。",
843 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
847 msg_format("%sの%sを学んだ。",
848 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME) ,p);
851 msg_format("You have learned the %s of %s.",
852 p, do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
856 p_ptr->energy_use = 100;
858 switch (mp_ptr->spell_book)
861 chg_virtue(V_FAITH, 1);
864 chg_virtue(V_UNLIFE, 1);
867 chg_virtue(V_NATURE, 1);
870 chg_virtue(V_KNOWLEDGE, 1);
876 /* One less spell available */
877 p_ptr->learned_spells++;
880 p_ptr->update |= (PU_SPELLS);
883 /* Redraw object recall */
884 p_ptr->window |= (PW_OBJECT);
889 * @brief 魔法を詠唱するコマンドのメインルーチン /
893 void do_cmd_cast(void)
896 OBJECT_SUBTYPE_VALUE sval;
902 MANA_POINT need_mana;
906 const magic_type *s_ptr;
909 bool over_exerted = FALSE;
911 /* Require spell ability */
912 if (!p_ptr->realm1 && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
914 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
919 if (p_ptr->blind || no_lite())
921 if (p_ptr->pclass == CLASS_FORCETRAINER) confirm_use_force(FALSE);
924 msg_print(_("目が見えない!", "You cannot see!"));
930 /* Not when confused */
933 msg_print(_("混乱していて唱えられない!", "You are too confused!"));
939 if (p_ptr->realm1 == REALM_HEX)
941 if (hex_spell_fully())
944 msg_print(_("これ以上新しい呪文を詠唱することはできない。", "Can not spell new spells more."));
946 if (p_ptr->lev >= 35) flag = stop_hex_spell();
951 if (p_ptr->pclass == CLASS_FORCETRAINER)
953 if (player_has_no_spellbooks())
955 confirm_use_force(FALSE);
958 select_the_force = TRUE;
961 prayer = spell_category_name(mp_ptr->spell_book);
963 /* Restrict choices to spell books */
964 item_tester_tval = mp_ptr->spell_book;
966 q = _("どの呪文書を使いますか? ", "Use which book? ");
967 s = _("呪文書がない!", "You have no spell books!");
969 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
971 select_the_force = FALSE;
974 select_the_force = FALSE;
976 if (item == INVEN_FORCE) /* the_force */
982 /* Get the item (in the pack) */
985 o_ptr = &inventory[item];
988 /* Get the item (on the floor) */
991 o_ptr = &o_list[0 - item];
994 /* Access the item's sval */
997 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && (o_ptr->tval == REALM2_BOOK)) increment = 32;
1000 /* Track the object kind */
1001 object_kind_track(o_ptr->k_idx);
1004 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
1005 realm = o_ptr->tval - TV_LIFE_BOOK + 1;
1006 else if (increment) realm = p_ptr->realm2;
1007 else realm = p_ptr->realm1;
1009 /* Ask for a spell */
1011 if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_MUSIC_BOOK) ? "歌う" : "唱える"),
1014 if (spell == -2) msg_format("その本には知っている%sがない。", prayer);
1018 if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1022 msg_format("You don't know any %ss in that book.", prayer);
1028 use_realm = tval2realm(o_ptr->tval);
1031 if (use_realm == REALM_HEX)
1033 if (hex_spelling(spell))
1035 msg_print(_("その呪文はすでに詠唱中だ。", "You are already casting it."));
1040 if (!is_magic(use_realm))
1042 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
1046 s_ptr = &mp_ptr->info[realm - 1][spell];
1049 /* Extract mana consumption rate */
1050 need_mana = mod_need_mana(s_ptr->smana, spell, realm);
1052 /* Verify "dangerous" spells */
1053 if (need_mana > p_ptr->csp)
1055 if (flush_failure) flush();
1059 msg_format("その%sを%sのに十分なマジックポイントがない。",prayer,
1060 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_LIFE_BOOK) ? "歌う" : "唱える"));
1062 msg_format("You do not have enough mana to %s this %s.",
1063 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1068 if (!over_exert) return;
1071 if (!get_check_strict(_("それでも挑戦しますか? ", "Attempt it anyway? "), CHECK_OKAY_CANCEL)) return;
1074 /* Spell failure chance */
1075 chance = spell_chance(spell, use_realm);
1077 /* Sufficient mana */
1078 if (need_mana <= p_ptr->csp)
1081 p_ptr->csp -= need_mana;
1083 else over_exerted = TRUE;
1086 p_ptr->redraw |= (PR_MANA);
1089 if (randint0(100) < chance)
1091 if (flush_failure) flush();
1093 msg_format(_("%sをうまく唱えられなかった!", "You failed to get the %s off!"), prayer);
1099 if (randint1(100) < chance) chg_virtue(V_VITALITY, -1);
1102 if (randint1(100) < chance) chg_virtue(V_UNLIFE, -1);
1105 if (randint1(100) < chance) chg_virtue(V_NATURE, -1);
1108 if (randint1(100) < chance) chg_virtue(V_JUSTICE, 1);
1111 if (randint1(100) < chance) chg_virtue(V_JUSTICE, -1);
1114 if (randint1(100) < chance) chg_virtue(V_COMPASSION, -1);
1117 if (randint1(100) < chance) chg_virtue(V_KNOWLEDGE, -1);
1121 /* Failure casting may activate some side effect */
1122 do_spell(realm, spell, SPELL_FAIL);
1125 if ((o_ptr->tval == TV_CHAOS_BOOK) && (randint1(100) < spell))
1127 msg_print(_("カオス的な効果を発生した!", "You produce a chaotic effect!"));
1130 else if ((o_ptr->tval == TV_DEATH_BOOK) && (randint1(100) < spell))
1132 if ((sval == 3) && one_in_(2))
1134 sanity_blast(0, TRUE);
1138 msg_print(_("痛い!", "It hurts!"));
1139 take_hit(DAMAGE_LOSELIFE, damroll(o_ptr->sval + 1, 6), _("暗黒魔法の逆流", "a miscast Death spell"), -1);
1141 if ((spell > 15) && one_in_(6) && !p_ptr->hold_exp)
1142 lose_exp(spell * 250);
1145 else if ((o_ptr->tval == TV_MUSIC_BOOK) && (randint1(200) < spell))
1147 msg_print(_("いやな音が響いた", "An infernal sound echoed."));
1148 aggravate_monsters(0);
1150 if (randint1(100) >= chance)
1151 chg_virtue(V_CHANCE,-1);
1157 /* Canceled spells cost neither a turn nor mana */
1158 if (!do_spell(realm, spell, SPELL_CAST)) return;
1160 if (randint1(100) < chance)
1161 chg_virtue(V_CHANCE,1);
1163 /* A spell was cast */
1165 (p_ptr->spell_worked2 & (1L << spell)) :
1166 (p_ptr->spell_worked1 & (1L << spell)))
1167 && (p_ptr->pclass != CLASS_SORCERER)
1168 && (p_ptr->pclass != CLASS_RED_MAGE))
1170 int e = s_ptr->sexp;
1172 /* The spell worked */
1173 if (realm == p_ptr->realm1)
1175 p_ptr->spell_worked1 |= (1L << spell);
1179 p_ptr->spell_worked2 |= (1L << spell);
1182 /* Gain experience */
1183 gain_exp(e * s_ptr->slevel);
1185 /* Redraw object recall */
1186 p_ptr->window |= (PW_OBJECT);
1191 chg_virtue(V_TEMPERANCE, 1);
1192 chg_virtue(V_COMPASSION, 1);
1193 chg_virtue(V_VITALITY, 1);
1194 chg_virtue(V_DILIGENCE, 1);
1197 chg_virtue(V_UNLIFE, 1);
1198 chg_virtue(V_JUSTICE, -1);
1199 chg_virtue(V_FAITH, -1);
1200 chg_virtue(V_VITALITY, -1);
1203 chg_virtue(V_JUSTICE, -1);
1204 chg_virtue(V_FAITH, -1);
1205 chg_virtue(V_HONOUR, -1);
1206 chg_virtue(V_TEMPERANCE, -1);
1209 chg_virtue(V_FAITH, 1);
1210 chg_virtue(V_JUSTICE, 1);
1211 chg_virtue(V_SACRIFICE, 1);
1212 chg_virtue(V_HONOUR, 1);
1215 chg_virtue(V_NATURE, 1);
1216 chg_virtue(V_HARMONY, 1);
1219 chg_virtue(V_JUSTICE, -1);
1220 chg_virtue(V_FAITH, -1);
1221 chg_virtue(V_HONOUR, -1);
1222 chg_virtue(V_COMPASSION, -1);
1225 chg_virtue(V_KNOWLEDGE, 1);
1232 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, 1);
1233 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, 1);
1234 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, 1);
1235 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_DILIGENCE, 1);
1238 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_UNLIFE, 1);
1239 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1240 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1241 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, -1);
1244 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1245 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1246 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1247 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, -1);
1250 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, 1);
1251 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, 1);
1252 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_SACRIFICE, 1);
1253 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, 1);
1256 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_NATURE, 1);
1257 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HARMONY, 1);
1260 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1261 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1262 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1263 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, -1);
1266 if (mp_ptr->spell_xtra & MAGIC_GAIN_EXP)
1268 s16b cur_exp = p_ptr->spell_exp[(increment ? 32 : 0)+spell];
1271 if (cur_exp < SPELL_EXP_BEGINNER)
1273 else if (cur_exp < SPELL_EXP_SKILLED)
1275 if ((dun_level > 4) && ((dun_level + 10) > p_ptr->lev))
1278 else if (cur_exp < SPELL_EXP_EXPERT)
1280 if (((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel))
1283 else if ((cur_exp < SPELL_EXP_MASTER) && !increment)
1285 if (((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel))
1288 p_ptr->spell_exp[(increment ? 32 : 0) + spell] += exp_gain;
1292 p_ptr->energy_use = 100;
1295 /* Over-exert the player */
1298 int oops = need_mana;
1302 p_ptr->csp_frac = 0;
1304 msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
1306 /* Hack -- Bypass free action */
1307 (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
1312 chg_virtue(V_VITALITY, -10);
1315 chg_virtue(V_UNLIFE, -10);
1318 chg_virtue(V_JUSTICE, 10);
1321 chg_virtue(V_NATURE, -10);
1324 chg_virtue(V_JUSTICE, -10);
1327 chg_virtue(V_COMPASSION, 10);
1330 chg_virtue(V_KNOWLEDGE, -10);
1334 /* Damage CON (possibly permanently) */
1335 if (randint0(100) < 50)
1337 bool perm = (randint0(100) < 25);
1339 msg_print(_("体を悪くしてしまった!", "You have damaged your health!"));
1341 /* Reduce constitution */
1342 (void)dec_stat(A_CON, 15 + randint1(10), perm);
1346 p_ptr->window |= (PW_PLAYER);
1347 p_ptr->window |= (PW_SPELL);