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 */
128 p_ptr->window |= (PW_SPELL);
131 /* Build a prompt (accept all spells) */
133 jverb( prompt, jverb_buf, JVERB_AND );
134 (void) strnfmt(out_val, 78, "(%^s:%c-%c, '*'で一覧, ESCで中断) どの%sを%^sますか? ",
135 p, I2A(0), I2A(num - 1), p, jverb_buf );
137 (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) %^s which %s? ",
138 p, I2A(0), I2A(num - 1), prompt, p);
141 /* Get a spell from the user */
143 choice = (always_show_list || use_menu) ? ESCAPE : 1;
146 if (choice == ESCAPE) choice = ' ';
147 else if (!get_com(out_val, &choice, TRUE))break;
149 if (use_menu && choice != ' ')
163 menu_line += (num - 1);
185 if (menu_line > num) menu_line -= num;
186 /* Display a list of spells */
187 print_spells(menu_line, spells, num, 1, 15, use_realm);
193 if ((choice == ' ') || (choice == '*') || (choice == '?'))
201 /* Save the screen */
204 /* Display a list of spells */
205 print_spells(menu_line, spells, num, 1, 15, use_realm);
211 if (use_menu) continue;
216 /* Restore the screen */
226 ask = (isupper(choice));
229 if (ask) choice = (char)tolower(choice);
231 /* Extract request */
232 i = (islower(choice) ? A2I(choice) : -1);
235 /* Totally Illegal */
236 if ((i < 0) || (i >= num))
242 /* Save the spell index */
245 /* Require "okay" spells */
246 if (!spell_okay(spell, learned, FALSE, use_realm))
250 msg_format("その%sを%sことはできません。", p, prompt);
252 msg_format("You may not %s that %s.", prompt, p);
263 /* Access the spell */
264 if (!is_magic(use_realm))
266 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
270 s_ptr = &mp_ptr->info[use_realm - 1][spell];
273 /* Extract mana consumption rate */
274 if (use_realm == REALM_HISSATSU)
276 need_mana = s_ptr->smana;
280 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
285 jverb( prompt, jverb_buf, JVERB_AND );
287 (void) strnfmt(tmp_val, 78, "%s(MP%d, 失敗率%d%%)を%sますか? ",
288 do_spell(use_realm, spell, SPELL_NAME), need_mana,
289 spell_chance(spell, use_realm),jverb_buf);
291 (void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ",
292 prompt, do_spell(use_realm, spell, SPELL_NAME), need_mana,
293 spell_chance(spell, use_realm));
297 /* Belay that order */
298 if (!get_check(tmp_val)) continue;
306 /* Restore the screen */
307 if (redraw) screen_load();
309 p_ptr->window |= (PW_SPELL);
312 /* Abort if needed */
313 if (!flag) return FALSE;
315 /* Save the choice */
318 repeat_push((COMMAND_CODE)spell);
325 * @brief オブジェクトがプレイヤーが使用可能な魔道書かどうかを判定する
326 * @param o_ptr 判定したいオブ会ジェクトの構造体参照ポインタ
327 * @return 学習できる魔道書ならばTRUEを返す
329 static bool item_tester_learn_spell(object_type *o_ptr)
331 s32b choices = realm_choices2[p_ptr->pclass];
333 if (p_ptr->pclass == CLASS_PRIEST)
335 if (is_good_realm(p_ptr->realm1))
337 choices &= ~(CH_DEATH | CH_DAEMON);
341 choices &= ~(CH_LIFE | CH_CRUSADE);
345 if ((o_ptr->tval < TV_LIFE_BOOK) || (o_ptr->tval > (TV_LIFE_BOOK + MAX_REALM - 1))) return (FALSE);
346 if ((o_ptr->tval == TV_MUSIC_BOOK) && (p_ptr->pclass == CLASS_BARD)) return (TRUE);
347 else if (!is_magic(tval2realm(o_ptr->tval))) return FALSE;
348 if ((REALM1_BOOK == o_ptr->tval) || (REALM2_BOOK == o_ptr->tval)) return (TRUE);
349 if (choices & (0x0001 << (tval2realm(o_ptr->tval) - 1))) return (TRUE);
354 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
355 * @return 魔道書を一冊も持っていないならTRUEを返す
357 static bool player_has_no_spellbooks(void)
362 for (i = 0; i < INVEN_PACK; i++)
364 o_ptr = &inventory[i];
365 if (o_ptr->k_idx && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
368 for (i = cave[p_ptr->y][p_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
371 if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
378 * @brief プレイヤーの職業が練気術師の時、領域魔法と練気術を切り換える処理のインターフェイス
379 * @param browse_only 魔法と技能の閲覧を行うならばTRUE
380 * @return 魔道書を一冊も持っていないならTRUEを返す
382 static void confirm_use_force(bool browse_only)
387 /* Get the item index */
388 if (repeat_pull(&code) && (code == INVEN_FORCE))
390 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
394 /* Show the prompt */
395 prt(_("('w'練気術, ESC) 'w'かESCを押してください。 ", "(w for the Force, ESC) Hit 'w' or ESC. "), 0, 0);
402 if (which == ESCAPE) break;
403 else if (which == 'w')
406 repeat_push(INVEN_FORCE);
412 /* Clear the prompt line */
417 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
423 * @brief プレイヤーの魔法と技能を閲覧するコマンドのメインルーチン /
424 * Peruse the spells/prayers in a book
428 * Note that *all* spells in the book are listed
430 * Note that browsing is allowed while confused or blind,
431 * and in the dark, primarily to allow browsing in stores.
434 void do_cmd_browse(void)
437 OBJECT_SUBTYPE_VALUE sval;
438 REALM_IDX use_realm = 0;
440 SPELL_IDX spell = -1;
443 SPELL_IDX spells[64];
450 /* Warriors are illiterate */
451 if (!(p_ptr->realm1 || p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
453 msg_print(_("本を読むことができない!", "You cannot read books!"));
457 if (p_ptr->special_defense & KATA_MUSOU)
459 set_action(ACTION_NONE);
462 if (p_ptr->pclass == CLASS_FORCETRAINER)
464 if (player_has_no_spellbooks())
466 confirm_use_force(TRUE);
469 select_the_force = TRUE;
472 /* Restrict choices to "useful" books */
473 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
474 else item_tester_hook = item_tester_learn_spell;
476 q = _("どの本を読みますか? ", "Browse which book? ");
477 s = _("読める本がない。", "You have no books that you can read.");
479 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
481 select_the_force = FALSE;
484 select_the_force = FALSE;
486 if (item == INVEN_FORCE) /* the_force */
488 do_cmd_mind_browse();
492 /* Get the item (in the pack) */
495 o_ptr = &inventory[item];
498 /* Get the item (on the floor) */
501 o_ptr = &o_list[0 - item];
504 /* Access the item's sval */
507 use_realm = tval2realm(o_ptr->tval);
509 /* Track the object kind */
510 object_kind_track(o_ptr->k_idx);
515 for (spell = 0; spell < 32; spell++)
517 /* Check for this spell */
518 if ((fake_spell_flags[sval] & (1L << spell)))
520 /* Collect this spell */
521 spells[num++] = spell;
526 /* Save the screen */
529 /* Clear the top line */
532 /* Keep browsing spells. Exit browsing on cancel. */
535 /* Ask for a spell, allow cancel */
536 if (!get_spell(&spell, _("読む", "browse"), o_ptr->sval, TRUE, use_realm))
538 /* If cancelled, leave immediately. */
539 if (spell == -1) break;
541 /* Display a list of spells */
542 print_spells(0, spells, num, 1, 15, use_realm);
544 /* Notify that there's nothing to see, and wait. */
545 if (use_realm == REALM_HISSATSU)
546 prt(_("読める技がない。", "No techniques to browse."), 0, 0);
548 prt(_("読める呪文がない。", "No spells to browse."), 0, 0);
552 /* Restore the screen */
558 /* Clear lines, position cursor (really should use strlen here) */
559 Term_erase(14, 14, 255);
560 Term_erase(14, 13, 255);
561 Term_erase(14, 12, 255);
562 Term_erase(14, 11, 255);
564 roff_to_buf(do_spell(use_realm, spell, SPELL_DESC), 62, temp, sizeof(temp));
566 for (j = 0, line = 11; temp[j]; j += 1 + strlen(&temp[j]))
568 prt(&temp[j], line, 15);
573 /* Restore the screen */
578 * @brief プレイヤーの第二魔法領域を変更する /
579 * @param next_realm 変更先の魔法領域ID
582 static void change_realm2(CHARACTER_IDX next_realm)
587 for (i = 0; i < 64; i++)
589 p_ptr->spell_order[j] = p_ptr->spell_order[i];
590 if (p_ptr->spell_order[i] < 32) j++;
593 p_ptr->spell_order[j] = 99;
595 for (i = 32; i < 64; i++)
597 p_ptr->spell_exp[i] = SPELL_EXP_UNSKILLED;
599 p_ptr->spell_learned2 = 0L;
600 p_ptr->spell_worked2 = 0L;
601 p_ptr->spell_forgotten2 = 0L;
603 sprintf(tmp,_("魔法の領域を%sから%sに変更した。", "change magic realm from %s to %s."), realm_names[p_ptr->realm2], realm_names[next_realm]);
604 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
605 p_ptr->old_realm |= 1 << (p_ptr->realm2-1);
606 p_ptr->realm2 = next_realm;
608 p_ptr->notice |= (PN_REORDER);
609 p_ptr->update |= (PU_SPELLS);
612 /* Load an autopick preference file */
613 autopick_load_pref(FALSE);
618 * @brief 魔法を学習するコマンドのメインルーチン /
619 * Study a book to gain a new spell/prayer
622 void do_cmd_study(void)
626 OBJECT_SUBTYPE_VALUE sval;
628 bool learned = FALSE;
630 /* Spells of realm2 will have an increment of +32 */
631 SPELL_IDX spell = -1;
633 cptr p = spell_category_name(mp_ptr->spell_book);
641 msg_print(_("本を読むことができない!", "You cannot read books!"));
645 if (p_ptr->blind || no_lite())
647 msg_print(_("目が見えない!", "You cannot see!"));
653 msg_print(_("混乱していて読めない!", "You are too confused!"));
657 if (!(p_ptr->new_spells))
659 msg_format(_("新しい%sを覚えることはできない!", "You cannot learn any new %ss!"), p);
663 if (p_ptr->special_defense & KATA_MUSOU)
665 set_action(ACTION_NONE);
669 if( p_ptr->new_spells < 10 ){
670 msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
672 msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
675 msg_format("You can learn %d new %s%s.", p_ptr->new_spells, p,
676 (p_ptr->new_spells == 1?"":"s"));
682 /* Restrict choices to "useful" books */
683 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
684 else item_tester_hook = item_tester_learn_spell;
686 q = _("どの本から学びますか? ", "Study which book? ");
687 s = _("読める本がない。", "You have no books that you can read.");
689 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
691 /* Get the item (in the pack) */
694 o_ptr = &inventory[item];
697 /* Get the item (on the floor) */
700 o_ptr = &o_list[0 - item];
703 /* Access the item's sval */
706 if (o_ptr->tval == REALM2_BOOK) increment = 32;
707 else if (o_ptr->tval != REALM1_BOOK)
709 if (!get_check(_("本当に魔法の領域を変更しますか?", "Really, change magic realm? "))) return;
710 change_realm2(tval2realm(o_ptr->tval));
714 /* Track the object kind */
715 object_kind_track(o_ptr->k_idx);
718 /* Mage -- Learn a selected spell */
719 if (mp_ptr->spell_book != TV_LIFE_BOOK)
721 /* Ask for a spell, allow cancel */
722 if (!get_spell(&spell, _("学ぶ", "study"), sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1) && (spell == -1)) return;
725 /* Priest -- Learn a random prayer */
732 for (spell = 0; spell < 32; spell++)
734 /* Check spells in the book */
735 if ((fake_spell_flags[sval] & (1L << spell)))
737 /* Skip non "okay" prayers */
738 if (!spell_okay(spell, FALSE, TRUE,
739 (increment ? p_ptr->realm2 : p_ptr->realm1))) continue;
741 /* Hack -- Prepare the randomizer */
744 /* Hack -- Apply the randomizer */
745 if (one_in_(k)) gift = spell;
753 /* Nothing to study */
756 msg_format(_("その本には学ぶべき%sがない。", "You cannot learn any %ss in that book."), p);
762 if (increment) spell += increment;
764 /* Learn the spell */
767 if (p_ptr->spell_learned1 & (1L << spell)) learned = TRUE;
768 else p_ptr->spell_learned1 |= (1L << spell);
772 if (p_ptr->spell_learned2 & (1L << (spell - 32))) learned = TRUE;
773 else p_ptr->spell_learned2 |= (1L << (spell - 32));
778 int max_exp = (spell < 32) ? SPELL_EXP_MASTER : SPELL_EXP_EXPERT;
779 int old_exp = p_ptr->spell_exp[spell];
780 int new_rank = EXP_LEVEL_UNSKILLED;
781 cptr name = do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell%32, SPELL_NAME);
783 if (old_exp >= max_exp)
785 msg_format(_("その%sは完全に使いこなせるので学ぶ必要はない。", "You don't need to study this %s anymore."), p);
789 if (!get_check(format("%sの%sをさらに学びます。よろしいですか?", name, p)))
791 if (!get_check(format("You will study a %s of %s again. Are you sure? ", p, name)))
796 else if (old_exp >= SPELL_EXP_EXPERT)
798 p_ptr->spell_exp[spell] = SPELL_EXP_MASTER;
799 new_rank = EXP_LEVEL_MASTER;
801 else if (old_exp >= SPELL_EXP_SKILLED)
803 if (spell >= 32) p_ptr->spell_exp[spell] = SPELL_EXP_EXPERT;
804 else p_ptr->spell_exp[spell] += SPELL_EXP_EXPERT - SPELL_EXP_SKILLED;
805 new_rank = EXP_LEVEL_EXPERT;
807 else if (old_exp >= SPELL_EXP_BEGINNER)
809 p_ptr->spell_exp[spell] = SPELL_EXP_SKILLED + (old_exp - SPELL_EXP_BEGINNER) * 2 / 3;
810 new_rank = EXP_LEVEL_SKILLED;
814 p_ptr->spell_exp[spell] = SPELL_EXP_BEGINNER + old_exp / 3;
815 new_rank = EXP_LEVEL_BEGINNER;
817 msg_format(_("%sの熟練度が%sに上がった。", "Your proficiency of %s is now %s rank."), name, exp_level_str[new_rank]);
821 /* Find the next open entry in "p_ptr->spell_order[]" */
822 for (i = 0; i < 64; i++)
824 /* Stop at the first empty space */
825 if (p_ptr->spell_order[i] == 99) break;
828 /* Add the spell to the known list */
829 p_ptr->spell_order[i++] = spell;
831 /* Mention the result */
834 if (mp_ptr->spell_book == TV_MUSIC_BOOK)
836 msg_format("%sを学んだ。",
837 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
841 msg_format("%sの%sを学んだ。",
842 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME) ,p);
845 msg_format("You have learned the %s of %s.",
846 p, do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
850 p_ptr->energy_use = 100;
852 switch (mp_ptr->spell_book)
855 chg_virtue(V_FAITH, 1);
858 chg_virtue(V_UNLIFE, 1);
861 chg_virtue(V_NATURE, 1);
864 chg_virtue(V_KNOWLEDGE, 1);
870 /* One less spell available */
871 p_ptr->learned_spells++;
874 p_ptr->update |= (PU_SPELLS);
877 /* Redraw object recall */
878 p_ptr->window |= (PW_OBJECT);
883 * @brief 魔法を詠唱するコマンドのメインルーチン /
887 void do_cmd_cast(void)
890 OBJECT_SUBTYPE_VALUE sval;
896 MANA_POINT need_mana;
900 const magic_type *s_ptr;
903 bool over_exerted = FALSE;
905 /* Require spell ability */
906 if (!p_ptr->realm1 && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
908 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
913 if (p_ptr->blind || no_lite())
915 if (p_ptr->pclass == CLASS_FORCETRAINER) confirm_use_force(FALSE);
918 msg_print(_("目が見えない!", "You cannot see!"));
924 /* Not when confused */
927 msg_print(_("混乱していて唱えられない!", "You are too confused!"));
933 if (p_ptr->realm1 == REALM_HEX)
935 if (hex_spell_fully())
938 msg_print(_("これ以上新しい呪文を詠唱することはできない。", "Can not spell new spells more."));
940 if (p_ptr->lev >= 35) flag = stop_hex_spell();
945 if (p_ptr->pclass == CLASS_FORCETRAINER)
947 if (player_has_no_spellbooks())
949 confirm_use_force(FALSE);
952 select_the_force = TRUE;
955 prayer = spell_category_name(mp_ptr->spell_book);
957 /* Restrict choices to spell books */
958 item_tester_tval = mp_ptr->spell_book;
960 q = _("どの呪文書を使いますか? ", "Use which book? ");
961 s = _("呪文書がない!", "You have no spell books!");
963 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
965 select_the_force = FALSE;
968 select_the_force = FALSE;
970 if (item == INVEN_FORCE) /* the_force */
976 /* Get the item (in the pack) */
979 o_ptr = &inventory[item];
982 /* Get the item (on the floor) */
985 o_ptr = &o_list[0 - item];
988 /* Access the item's sval */
991 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && (o_ptr->tval == REALM2_BOOK)) increment = 32;
994 /* Track the object kind */
995 object_kind_track(o_ptr->k_idx);
998 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
999 realm = o_ptr->tval - TV_LIFE_BOOK + 1;
1000 else if (increment) realm = p_ptr->realm2;
1001 else realm = p_ptr->realm1;
1003 /* Ask for a spell */
1005 if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_MUSIC_BOOK) ? "歌う" : "唱える"),
1008 if (spell == -2) msg_format("その本には知っている%sがない。", prayer);
1012 if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1016 msg_format("You don't know any %ss in that book.", prayer);
1022 use_realm = tval2realm(o_ptr->tval);
1025 if (use_realm == REALM_HEX)
1027 if (hex_spelling(spell))
1029 msg_print(_("その呪文はすでに詠唱中だ。", "You are already casting it."));
1034 if (!is_magic(use_realm))
1036 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
1040 s_ptr = &mp_ptr->info[realm - 1][spell];
1043 /* Extract mana consumption rate */
1044 need_mana = mod_need_mana(s_ptr->smana, spell, realm);
1046 /* Verify "dangerous" spells */
1047 if (need_mana > p_ptr->csp)
1049 if (flush_failure) flush();
1053 msg_format("その%sを%sのに十分なマジックポイントがない。",prayer,
1054 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_LIFE_BOOK) ? "歌う" : "唱える"));
1056 msg_format("You do not have enough mana to %s this %s.",
1057 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1062 if (!over_exert) return;
1065 if (!get_check_strict(_("それでも挑戦しますか? ", "Attempt it anyway? "), CHECK_OKAY_CANCEL)) return;
1068 /* Spell failure chance */
1069 chance = spell_chance(spell, use_realm);
1071 /* Sufficient mana */
1072 if (need_mana <= p_ptr->csp)
1075 p_ptr->csp -= need_mana;
1077 else over_exerted = TRUE;
1078 p_ptr->redraw |= (PR_MANA);
1081 if (randint0(100) < chance)
1083 if (flush_failure) flush();
1085 msg_format(_("%sをうまく唱えられなかった!", "You failed to get the %s off!"), prayer);
1091 if (randint1(100) < chance) chg_virtue(V_VITALITY, -1);
1094 if (randint1(100) < chance) chg_virtue(V_UNLIFE, -1);
1097 if (randint1(100) < chance) chg_virtue(V_NATURE, -1);
1100 if (randint1(100) < chance) chg_virtue(V_JUSTICE, 1);
1103 if (randint1(100) < chance) chg_virtue(V_JUSTICE, -1);
1106 if (randint1(100) < chance) chg_virtue(V_COMPASSION, -1);
1109 if (randint1(100) < chance) chg_virtue(V_KNOWLEDGE, -1);
1113 /* Failure casting may activate some side effect */
1114 do_spell(realm, spell, SPELL_FAIL);
1117 if ((o_ptr->tval == TV_CHAOS_BOOK) && (randint1(100) < spell))
1119 msg_print(_("カオス的な効果を発生した!", "You produce a chaotic effect!"));
1122 else if ((o_ptr->tval == TV_DEATH_BOOK) && (randint1(100) < spell))
1124 if ((sval == 3) && one_in_(2))
1126 sanity_blast(0, TRUE);
1130 msg_print(_("痛い!", "It hurts!"));
1131 take_hit(DAMAGE_LOSELIFE, damroll(o_ptr->sval + 1, 6), _("暗黒魔法の逆流", "a miscast Death spell"), -1);
1133 if ((spell > 15) && one_in_(6) && !p_ptr->hold_exp)
1134 lose_exp(spell * 250);
1137 else if ((o_ptr->tval == TV_MUSIC_BOOK) && (randint1(200) < spell))
1139 msg_print(_("いやな音が響いた", "An infernal sound echoed."));
1140 aggravate_monsters(0);
1142 if (randint1(100) >= chance)
1143 chg_virtue(V_CHANCE,-1);
1149 /* Canceled spells cost neither a turn nor mana */
1150 if (!do_spell(realm, spell, SPELL_CAST)) return;
1152 if (randint1(100) < chance)
1153 chg_virtue(V_CHANCE,1);
1155 /* A spell was cast */
1157 (p_ptr->spell_worked2 & (1L << spell)) :
1158 (p_ptr->spell_worked1 & (1L << spell)))
1159 && (p_ptr->pclass != CLASS_SORCERER)
1160 && (p_ptr->pclass != CLASS_RED_MAGE))
1162 int e = s_ptr->sexp;
1164 /* The spell worked */
1165 if (realm == p_ptr->realm1)
1167 p_ptr->spell_worked1 |= (1L << spell);
1171 p_ptr->spell_worked2 |= (1L << spell);
1174 /* Gain experience */
1175 gain_exp(e * s_ptr->slevel);
1177 /* Redraw object recall */
1178 p_ptr->window |= (PW_OBJECT);
1183 chg_virtue(V_TEMPERANCE, 1);
1184 chg_virtue(V_COMPASSION, 1);
1185 chg_virtue(V_VITALITY, 1);
1186 chg_virtue(V_DILIGENCE, 1);
1189 chg_virtue(V_UNLIFE, 1);
1190 chg_virtue(V_JUSTICE, -1);
1191 chg_virtue(V_FAITH, -1);
1192 chg_virtue(V_VITALITY, -1);
1195 chg_virtue(V_JUSTICE, -1);
1196 chg_virtue(V_FAITH, -1);
1197 chg_virtue(V_HONOUR, -1);
1198 chg_virtue(V_TEMPERANCE, -1);
1201 chg_virtue(V_FAITH, 1);
1202 chg_virtue(V_JUSTICE, 1);
1203 chg_virtue(V_SACRIFICE, 1);
1204 chg_virtue(V_HONOUR, 1);
1207 chg_virtue(V_NATURE, 1);
1208 chg_virtue(V_HARMONY, 1);
1211 chg_virtue(V_JUSTICE, -1);
1212 chg_virtue(V_FAITH, -1);
1213 chg_virtue(V_HONOUR, -1);
1214 chg_virtue(V_COMPASSION, -1);
1217 chg_virtue(V_KNOWLEDGE, 1);
1224 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, 1);
1225 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, 1);
1226 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, 1);
1227 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_DILIGENCE, 1);
1230 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_UNLIFE, 1);
1231 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1232 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1233 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, -1);
1236 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1237 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1238 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1239 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, -1);
1242 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, 1);
1243 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, 1);
1244 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_SACRIFICE, 1);
1245 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, 1);
1248 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_NATURE, 1);
1249 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HARMONY, 1);
1252 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1253 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1254 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1255 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, -1);
1258 if (mp_ptr->spell_xtra & MAGIC_GAIN_EXP)
1260 s16b cur_exp = p_ptr->spell_exp[(increment ? 32 : 0)+spell];
1263 if (cur_exp < SPELL_EXP_BEGINNER)
1265 else if (cur_exp < SPELL_EXP_SKILLED)
1267 if ((dun_level > 4) && ((dun_level + 10) > p_ptr->lev))
1270 else if (cur_exp < SPELL_EXP_EXPERT)
1272 if (((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel))
1275 else if ((cur_exp < SPELL_EXP_MASTER) && !increment)
1277 if (((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel))
1280 p_ptr->spell_exp[(increment ? 32 : 0) + spell] += exp_gain;
1284 p_ptr->energy_use = 100;
1287 /* Over-exert the player */
1290 int oops = need_mana;
1294 p_ptr->csp_frac = 0;
1296 msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
1298 /* Hack -- Bypass free action */
1299 (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
1304 chg_virtue(V_VITALITY, -10);
1307 chg_virtue(V_UNLIFE, -10);
1310 chg_virtue(V_JUSTICE, 10);
1313 chg_virtue(V_NATURE, -10);
1316 chg_virtue(V_JUSTICE, -10);
1319 chg_virtue(V_COMPASSION, 10);
1322 chg_virtue(V_KNOWLEDGE, -10);
1326 /* Damage CON (possibly permanently) */
1327 if (randint0(100) < 50)
1329 bool perm = (randint0(100) < 25);
1331 msg_print(_("体を悪くしてしまった!", "You have damaged your health!"));
1333 /* Reduce constitution */
1334 (void)dec_stat(A_CON, 15 + randint1(10), perm);
1338 p_ptr->window |= (PW_PLAYER);
1339 p_ptr->window |= (PW_SPELL);