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 #ifdef ALLOW_REPEAT /* TNB */
77 /* Get the spell, if available */
78 if (repeat_pull(&code))
80 *sn = (SPELL_IDX)code;
81 /* Verify the spell */
82 if (spell_okay(*sn, learned, FALSE, use_realm))
89 #endif /* ALLOW_REPEAT -- TNB */
91 p = spell_category_name(mp_ptr->spell_book);
94 for (spell = 0; spell < 32; spell++)
96 /* Check for this spell */
97 if ((fake_spell_flags[sval] & (1L << spell)))
99 /* Collect this spell */
100 spells[num++] = spell;
104 /* Assume no usable spells */
107 /* Assume no spells available */
110 /* Check for "okay" spells */
111 for (i = 0; i < num; i++)
113 /* Look for "okay" spells */
114 if (spell_okay(spells[i], learned, FALSE, use_realm)) okay = TRUE;
117 /* No "okay" spells */
118 if (!okay) return (FALSE);
119 if (((use_realm) != p_ptr->realm1) && ((use_realm) != p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return FALSE;
120 if (((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) && !is_magic(use_realm)) return FALSE;
121 if ((p_ptr->pclass == CLASS_RED_MAGE) && ((use_realm) != REALM_ARCANE) && (sval > 1)) return FALSE;
123 /* Assume cancelled */
126 /* Nothing chosen yet */
133 p_ptr->window |= (PW_SPELL);
137 /* Build a prompt (accept all spells) */
139 jverb( prompt, jverb_buf, JVERB_AND );
140 (void) strnfmt(out_val, 78, "(%^s:%c-%c, '*'で一覧, ESCで中断) どの%sを%^sますか? ",
141 p, I2A(0), I2A(num - 1), p, jverb_buf );
143 (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) %^s which %s? ",
144 p, I2A(0), I2A(num - 1), prompt, p);
147 /* Get a spell from the user */
149 choice = (always_show_list || use_menu) ? ESCAPE : 1;
152 if (choice == ESCAPE) choice = ' ';
153 else if (!get_com(out_val, &choice, TRUE))break;
155 if (use_menu && choice != ' ')
169 menu_line += (num - 1);
191 if (menu_line > num) menu_line -= num;
192 /* Display a list of spells */
193 print_spells(menu_line, spells, num, 1, 15, use_realm);
199 if ((choice == ' ') || (choice == '*') || (choice == '?'))
207 /* Save the screen */
210 /* Display a list of spells */
211 print_spells(menu_line, spells, num, 1, 15, use_realm);
217 if (use_menu) continue;
222 /* Restore the screen */
232 ask = (isupper(choice));
235 if (ask) choice = (char)tolower(choice);
237 /* Extract request */
238 i = (islower(choice) ? A2I(choice) : -1);
241 /* Totally Illegal */
242 if ((i < 0) || (i >= num))
248 /* Save the spell index */
251 /* Require "okay" spells */
252 if (!spell_okay(spell, learned, FALSE, use_realm))
256 msg_format("その%sを%sことはできません。", p, prompt);
258 msg_format("You may not %s that %s.", prompt, p);
269 /* Access the spell */
270 if (!is_magic(use_realm))
272 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
276 s_ptr = &mp_ptr->info[use_realm - 1][spell];
279 /* Extract mana consumption rate */
280 if (use_realm == REALM_HISSATSU)
282 need_mana = s_ptr->smana;
286 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
291 jverb( prompt, jverb_buf, JVERB_AND );
293 (void) strnfmt(tmp_val, 78, "%s(MP%d, 失敗率%d%%)を%sますか? ",
294 do_spell(use_realm, spell, SPELL_NAME), need_mana,
295 spell_chance(spell, use_realm),jverb_buf);
297 (void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ",
298 prompt, do_spell(use_realm, spell, SPELL_NAME), need_mana,
299 spell_chance(spell, use_realm));
303 /* Belay that order */
304 if (!get_check(tmp_val)) continue;
312 /* Restore the screen */
313 if (redraw) screen_load();
317 p_ptr->window |= (PW_SPELL);
322 /* Abort if needed */
323 if (!flag) return FALSE;
325 /* Save the choice */
328 #ifdef ALLOW_REPEAT /* TNB */
330 repeat_push((COMMAND_CODE)spell);
332 #endif /* ALLOW_REPEAT -- TNB */
339 * @brief オブジェクトがプレイヤーが使用可能な魔道書かどうかを判定する
340 * @param o_ptr 判定したいオブ会ジェクトの構造体参照ポインタ
341 * @return 学習できる魔道書ならばTRUEを返す
343 static bool item_tester_learn_spell(object_type *o_ptr)
345 s32b choices = realm_choices2[p_ptr->pclass];
347 if (p_ptr->pclass == CLASS_PRIEST)
349 if (is_good_realm(p_ptr->realm1))
351 choices &= ~(CH_DEATH | CH_DAEMON);
355 choices &= ~(CH_LIFE | CH_CRUSADE);
359 if ((o_ptr->tval < TV_LIFE_BOOK) || (o_ptr->tval > (TV_LIFE_BOOK + MAX_REALM - 1))) return (FALSE);
360 if ((o_ptr->tval == TV_MUSIC_BOOK) && (p_ptr->pclass == CLASS_BARD)) return (TRUE);
361 else if (!is_magic(tval2realm(o_ptr->tval))) return FALSE;
362 if ((REALM1_BOOK == o_ptr->tval) || (REALM2_BOOK == o_ptr->tval)) return (TRUE);
363 if (choices & (0x0001 << (tval2realm(o_ptr->tval) - 1))) return (TRUE);
368 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
369 * @return 魔道書を一冊も持っていないならTRUEを返す
371 static bool player_has_no_spellbooks(void)
376 for (i = 0; i < INVEN_PACK; i++)
378 o_ptr = &inventory[i];
379 if (o_ptr->k_idx && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
382 for (i = cave[p_ptr->y][p_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
385 if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
392 * @brief プレイヤーの職業が練気術師の時、領域魔法と練気術を切り換える処理のインターフェイス
393 * @param browse_only 魔法と技能の閲覧を行うならばTRUE
394 * @return 魔道書を一冊も持っていないならTRUEを返す
396 static void confirm_use_force(bool browse_only)
403 /* Get the item index */
404 if (repeat_pull(&code) && (code == INVEN_FORCE))
406 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
410 #endif /* ALLOW_REPEAT */
412 /* Show the prompt */
413 prt(_("('w'練気術, ESC) 'w'かESCを押してください。 ", "(w for the Force, ESC) Hit 'w' or ESC. "), 0, 0);
420 if (which == ESCAPE) break;
421 else if (which == 'w')
426 repeat_push(INVEN_FORCE);
428 #endif /* ALLOW_REPEAT */
434 /* Clear the prompt line */
439 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
445 * @brief プレイヤーの魔法と技能を閲覧するコマンドのメインルーチン /
446 * Peruse the spells/prayers in a book
450 * Note that *all* spells in the book are listed
452 * Note that browsing is allowed while confused or blind,
453 * and in the dark, primarily to allow browsing in stores.
456 void do_cmd_browse(void)
459 OBJECT_SUBTYPE_VALUE sval;
460 REALM_IDX use_realm = 0;
462 SPELL_IDX spell = -1;
465 SPELL_IDX spells[64];
472 /* Warriors are illiterate */
473 if (!(p_ptr->realm1 || p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
475 msg_print(_("本を読むことができない!", "You cannot read books!"));
479 if (p_ptr->special_defense & KATA_MUSOU)
481 set_action(ACTION_NONE);
484 if (p_ptr->pclass == CLASS_FORCETRAINER)
486 if (player_has_no_spellbooks())
488 confirm_use_force(TRUE);
491 select_the_force = TRUE;
494 /* Restrict choices to "useful" books */
495 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
496 else item_tester_hook = item_tester_learn_spell;
499 q = _("どの本を読みますか? ", "Browse which book? ");
500 s = _("読める本がない。", "You have no books that you can read.");
502 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
504 select_the_force = FALSE;
507 select_the_force = FALSE;
509 if (item == INVEN_FORCE) /* the_force */
511 do_cmd_mind_browse();
515 /* Get the item (in the pack) */
518 o_ptr = &inventory[item];
521 /* Get the item (on the floor) */
524 o_ptr = &o_list[0 - item];
527 /* Access the item's sval */
530 use_realm = tval2realm(o_ptr->tval);
532 /* Track the object kind */
533 object_kind_track(o_ptr->k_idx);
535 /* Hack -- Handle stuff */
540 for (spell = 0; spell < 32; spell++)
542 /* Check for this spell */
543 if ((fake_spell_flags[sval] & (1L << spell)))
545 /* Collect this spell */
546 spells[num++] = spell;
551 /* Save the screen */
554 /* Clear the top line */
557 /* Keep browsing spells. Exit browsing on cancel. */
560 /* Ask for a spell, allow cancel */
561 if (!get_spell(&spell, _("読む", "browse"), o_ptr->sval, TRUE, use_realm))
563 /* If cancelled, leave immediately. */
564 if (spell == -1) break;
566 /* Display a list of spells */
567 print_spells(0, spells, num, 1, 15, use_realm);
569 /* Notify that there's nothing to see, and wait. */
570 if (use_realm == REALM_HISSATSU)
571 prt(_("読める技がない。", "No techniques to browse."), 0, 0);
573 prt(_("読める呪文がない。", "No spells to browse."), 0, 0);
577 /* Restore the screen */
583 /* Clear lines, position cursor (really should use strlen here) */
584 Term_erase(14, 14, 255);
585 Term_erase(14, 13, 255);
586 Term_erase(14, 12, 255);
587 Term_erase(14, 11, 255);
589 roff_to_buf(do_spell(use_realm, spell, SPELL_DESC), 62, temp, sizeof(temp));
591 for (j = 0, line = 11; temp[j]; j += 1 + strlen(&temp[j]))
593 prt(&temp[j], line, 15);
598 /* Restore the screen */
603 * @brief プレイヤーの第二魔法領域を変更する /
604 * @param next_realm 変更先の魔法領域ID
607 static void change_realm2(CHARACTER_IDX next_realm)
612 for (i = 0; i < 64; i++)
614 p_ptr->spell_order[j] = p_ptr->spell_order[i];
615 if (p_ptr->spell_order[i] < 32) j++;
618 p_ptr->spell_order[j] = 99;
620 for (i = 32; i < 64; i++)
622 p_ptr->spell_exp[i] = SPELL_EXP_UNSKILLED;
624 p_ptr->spell_learned2 = 0L;
625 p_ptr->spell_worked2 = 0L;
626 p_ptr->spell_forgotten2 = 0L;
628 sprintf(tmp,_("魔法の領域を%sから%sに変更した。", "change magic realm from %s to %s."), realm_names[p_ptr->realm2], realm_names[next_realm]);
629 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
630 p_ptr->old_realm |= 1 << (p_ptr->realm2-1);
631 p_ptr->realm2 = next_realm;
633 p_ptr->notice |= (PN_REORDER);
634 p_ptr->update |= (PU_SPELLS);
637 /* Load an autopick preference file */
638 autopick_load_pref(FALSE);
643 * @brief 魔法を学習するコマンドのメインルーチン /
644 * Study a book to gain a new spell/prayer
647 void do_cmd_study(void)
651 OBJECT_SUBTYPE_VALUE sval;
653 bool learned = FALSE;
655 /* Spells of realm2 will have an increment of +32 */
656 SPELL_IDX spell = -1;
658 cptr p = spell_category_name(mp_ptr->spell_book);
666 msg_print(_("本を読むことができない!", "You cannot read books!"));
670 if (p_ptr->blind || no_lite())
672 msg_print(_("目が見えない!", "You cannot see!"));
678 msg_print(_("混乱していて読めない!", "You are too confused!"));
682 if (!(p_ptr->new_spells))
684 msg_format(_("新しい%sを覚えることはできない!", "You cannot learn any new %ss!"), p);
688 if (p_ptr->special_defense & KATA_MUSOU)
690 set_action(ACTION_NONE);
694 if( p_ptr->new_spells < 10 ){
695 msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
697 msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
700 msg_format("You can learn %d new %s%s.", p_ptr->new_spells, p,
701 (p_ptr->new_spells == 1?"":"s"));
707 /* Restrict choices to "useful" books */
708 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
709 else item_tester_hook = item_tester_learn_spell;
712 q = _("どの本から学びますか? ", "Study which book? ");
713 s = _("読める本がない。", "You have no books that you can read.");
715 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
717 /* Get the item (in the pack) */
720 o_ptr = &inventory[item];
723 /* Get the item (on the floor) */
726 o_ptr = &o_list[0 - item];
729 /* Access the item's sval */
732 if (o_ptr->tval == REALM2_BOOK) increment = 32;
733 else if (o_ptr->tval != REALM1_BOOK)
735 if (!get_check(_("本当に魔法の領域を変更しますか?", "Really, change magic realm? "))) return;
736 change_realm2(tval2realm(o_ptr->tval));
740 /* Track the object kind */
741 object_kind_track(o_ptr->k_idx);
743 /* Hack -- Handle stuff */
746 /* Mage -- Learn a selected spell */
747 if (mp_ptr->spell_book != TV_LIFE_BOOK)
749 /* Ask for a spell, allow cancel */
750 if (!get_spell(&spell, _("学ぶ", "study"), sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1) && (spell == -1)) return;
753 /* Priest -- Learn a random prayer */
760 for (spell = 0; spell < 32; spell++)
762 /* Check spells in the book */
763 if ((fake_spell_flags[sval] & (1L << spell)))
765 /* Skip non "okay" prayers */
766 if (!spell_okay(spell, FALSE, TRUE,
767 (increment ? p_ptr->realm2 : p_ptr->realm1))) continue;
769 /* Hack -- Prepare the randomizer */
772 /* Hack -- Apply the randomizer */
773 if (one_in_(k)) gift = spell;
781 /* Nothing to study */
784 msg_format(_("その本には学ぶべき%sがない。", "You cannot learn any %ss in that book."), p);
790 if (increment) spell += increment;
792 /* Learn the spell */
795 if (p_ptr->spell_learned1 & (1L << spell)) learned = TRUE;
796 else p_ptr->spell_learned1 |= (1L << spell);
800 if (p_ptr->spell_learned2 & (1L << (spell - 32))) learned = TRUE;
801 else p_ptr->spell_learned2 |= (1L << (spell - 32));
806 int max_exp = (spell < 32) ? SPELL_EXP_MASTER : SPELL_EXP_EXPERT;
807 int old_exp = p_ptr->spell_exp[spell];
808 int new_rank = EXP_LEVEL_UNSKILLED;
809 cptr name = do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell%32, SPELL_NAME);
811 if (old_exp >= max_exp)
813 msg_format(_("その%sは完全に使いこなせるので学ぶ必要はない。", "You don't need to study this %s anymore."), p);
817 if (!get_check(format("%sの%sをさらに学びます。よろしいですか?", name, p)))
819 if (!get_check(format("You will study a %s of %s again. Are you sure? ", p, name)))
824 else if (old_exp >= SPELL_EXP_EXPERT)
826 p_ptr->spell_exp[spell] = SPELL_EXP_MASTER;
827 new_rank = EXP_LEVEL_MASTER;
829 else if (old_exp >= SPELL_EXP_SKILLED)
831 if (spell >= 32) p_ptr->spell_exp[spell] = SPELL_EXP_EXPERT;
832 else p_ptr->spell_exp[spell] += SPELL_EXP_EXPERT - SPELL_EXP_SKILLED;
833 new_rank = EXP_LEVEL_EXPERT;
835 else if (old_exp >= SPELL_EXP_BEGINNER)
837 p_ptr->spell_exp[spell] = SPELL_EXP_SKILLED + (old_exp - SPELL_EXP_BEGINNER) * 2 / 3;
838 new_rank = EXP_LEVEL_SKILLED;
842 p_ptr->spell_exp[spell] = SPELL_EXP_BEGINNER + old_exp / 3;
843 new_rank = EXP_LEVEL_BEGINNER;
845 msg_format(_("%sの熟練度が%sに上がった。", "Your proficiency of %s is now %s rank."), name, exp_level_str[new_rank]);
849 /* Find the next open entry in "p_ptr->spell_order[]" */
850 for (i = 0; i < 64; i++)
852 /* Stop at the first empty space */
853 if (p_ptr->spell_order[i] == 99) break;
856 /* Add the spell to the known list */
857 p_ptr->spell_order[i++] = spell;
859 /* Mention the result */
862 if (mp_ptr->spell_book == TV_MUSIC_BOOK)
864 msg_format("%sを学んだ。",
865 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
869 msg_format("%sの%sを学んだ。",
870 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME) ,p);
873 msg_format("You have learned the %s of %s.",
874 p, do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
878 p_ptr->energy_use = 100;
880 switch (mp_ptr->spell_book)
883 chg_virtue(V_FAITH, 1);
886 chg_virtue(V_UNLIFE, 1);
889 chg_virtue(V_NATURE, 1);
892 chg_virtue(V_KNOWLEDGE, 1);
898 /* One less spell available */
899 p_ptr->learned_spells++;
902 p_ptr->update |= (PU_SPELLS);
905 /* Redraw object recall */
906 p_ptr->window |= (PW_OBJECT);
911 * @brief 魔法を詠唱するコマンドのメインルーチン /
915 void do_cmd_cast(void)
918 OBJECT_SUBTYPE_VALUE sval;
924 MANA_POINT need_mana;
928 const magic_type *s_ptr;
931 bool over_exerted = FALSE;
933 /* Require spell ability */
934 if (!p_ptr->realm1 && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
936 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
941 if (p_ptr->blind || no_lite())
943 if (p_ptr->pclass == CLASS_FORCETRAINER) confirm_use_force(FALSE);
946 msg_print(_("目が見えない!", "You cannot see!"));
952 /* Not when confused */
955 msg_print(_("混乱していて唱えられない!", "You are too confused!"));
961 if (p_ptr->realm1 == REALM_HEX)
963 if (hex_spell_fully())
966 msg_print(_("これ以上新しい呪文を詠唱することはできない。", "Can not spell new spells more."));
968 if (p_ptr->lev >= 35) flag = stop_hex_spell();
973 if (p_ptr->pclass == CLASS_FORCETRAINER)
975 if (player_has_no_spellbooks())
977 confirm_use_force(FALSE);
980 select_the_force = TRUE;
983 prayer = spell_category_name(mp_ptr->spell_book);
985 /* Restrict choices to spell books */
986 item_tester_tval = mp_ptr->spell_book;
989 q = _("どの呪文書を使いますか? ", "Use which book? ");
990 s = _("呪文書がない!", "You have no spell books!");
992 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
994 select_the_force = FALSE;
997 select_the_force = FALSE;
999 if (item == INVEN_FORCE) /* the_force */
1005 /* Get the item (in the pack) */
1008 o_ptr = &inventory[item];
1011 /* Get the item (on the floor) */
1014 o_ptr = &o_list[0 - item];
1017 /* Access the item's sval */
1020 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && (o_ptr->tval == REALM2_BOOK)) increment = 32;
1023 /* Track the object kind */
1024 object_kind_track(o_ptr->k_idx);
1026 /* Hack -- Handle stuff */
1029 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
1030 realm = o_ptr->tval - TV_LIFE_BOOK + 1;
1031 else if (increment) realm = p_ptr->realm2;
1032 else realm = p_ptr->realm1;
1034 /* Ask for a spell */
1036 if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_MUSIC_BOOK) ? "歌う" : "唱える"),
1039 if (spell == -2) msg_format("その本には知っている%sがない。", prayer);
1043 if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1047 msg_format("You don't know any %ss in that book.", prayer);
1053 use_realm = tval2realm(o_ptr->tval);
1056 if (use_realm == REALM_HEX)
1058 if (hex_spelling(spell))
1060 msg_print(_("その呪文はすでに詠唱中だ。", "You are already casting it."));
1065 if (!is_magic(use_realm))
1067 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
1071 s_ptr = &mp_ptr->info[realm - 1][spell];
1074 /* Extract mana consumption rate */
1075 need_mana = mod_need_mana(s_ptr->smana, spell, realm);
1077 /* Verify "dangerous" spells */
1078 if (need_mana > p_ptr->csp)
1080 if (flush_failure) flush();
1084 msg_format("その%sを%sのに十分なマジックポイントがない。",prayer,
1085 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_LIFE_BOOK) ? "歌う" : "唱える"));
1087 msg_format("You do not have enough mana to %s this %s.",
1088 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1093 if (!over_exert) return;
1096 if (!get_check_strict(_("それでも挑戦しますか? ", "Attempt it anyway? "), CHECK_OKAY_CANCEL)) return;
1099 /* Spell failure chance */
1100 chance = spell_chance(spell, use_realm);
1102 /* Sufficient mana */
1103 if (need_mana <= p_ptr->csp)
1106 p_ptr->csp -= need_mana;
1108 else over_exerted = TRUE;
1111 p_ptr->redraw |= (PR_MANA);
1114 if (randint0(100) < chance)
1116 if (flush_failure) flush();
1118 msg_format(_("%sをうまく唱えられなかった!", "You failed to get the %s off!"), prayer);
1124 if (randint1(100) < chance) chg_virtue(V_VITALITY, -1);
1127 if (randint1(100) < chance) chg_virtue(V_UNLIFE, -1);
1130 if (randint1(100) < chance) chg_virtue(V_NATURE, -1);
1133 if (randint1(100) < chance) chg_virtue(V_JUSTICE, 1);
1136 if (randint1(100) < chance) chg_virtue(V_JUSTICE, -1);
1139 if (randint1(100) < chance) chg_virtue(V_COMPASSION, -1);
1142 if (randint1(100) < chance) chg_virtue(V_KNOWLEDGE, -1);
1146 /* Failure casting may activate some side effect */
1147 do_spell(realm, spell, SPELL_FAIL);
1150 if ((o_ptr->tval == TV_CHAOS_BOOK) && (randint1(100) < spell))
1152 msg_print(_("カオス的な効果を発生した!", "You produce a chaotic effect!"));
1155 else if ((o_ptr->tval == TV_DEATH_BOOK) && (randint1(100) < spell))
1157 if ((sval == 3) && one_in_(2))
1159 sanity_blast(0, TRUE);
1163 msg_print(_("痛い!", "It hurts!"));
1164 take_hit(DAMAGE_LOSELIFE, damroll(o_ptr->sval + 1, 6), _("暗黒魔法の逆流", "a miscast Death spell"), -1);
1166 if ((spell > 15) && one_in_(6) && !p_ptr->hold_exp)
1167 lose_exp(spell * 250);
1170 else if ((o_ptr->tval == TV_MUSIC_BOOK) && (randint1(200) < spell))
1172 msg_print(_("いやな音が響いた", "An infernal sound echoed."));
1173 aggravate_monsters(0);
1175 if (randint1(100) >= chance)
1176 chg_virtue(V_CHANCE,-1);
1182 /* Canceled spells cost neither a turn nor mana */
1183 if (!do_spell(realm, spell, SPELL_CAST)) return;
1185 if (randint1(100) < chance)
1186 chg_virtue(V_CHANCE,1);
1188 /* A spell was cast */
1190 (p_ptr->spell_worked2 & (1L << spell)) :
1191 (p_ptr->spell_worked1 & (1L << spell)))
1192 && (p_ptr->pclass != CLASS_SORCERER)
1193 && (p_ptr->pclass != CLASS_RED_MAGE))
1195 int e = s_ptr->sexp;
1197 /* The spell worked */
1198 if (realm == p_ptr->realm1)
1200 p_ptr->spell_worked1 |= (1L << spell);
1204 p_ptr->spell_worked2 |= (1L << spell);
1207 /* Gain experience */
1208 gain_exp(e * s_ptr->slevel);
1210 /* Redraw object recall */
1211 p_ptr->window |= (PW_OBJECT);
1216 chg_virtue(V_TEMPERANCE, 1);
1217 chg_virtue(V_COMPASSION, 1);
1218 chg_virtue(V_VITALITY, 1);
1219 chg_virtue(V_DILIGENCE, 1);
1222 chg_virtue(V_UNLIFE, 1);
1223 chg_virtue(V_JUSTICE, -1);
1224 chg_virtue(V_FAITH, -1);
1225 chg_virtue(V_VITALITY, -1);
1228 chg_virtue(V_JUSTICE, -1);
1229 chg_virtue(V_FAITH, -1);
1230 chg_virtue(V_HONOUR, -1);
1231 chg_virtue(V_TEMPERANCE, -1);
1234 chg_virtue(V_FAITH, 1);
1235 chg_virtue(V_JUSTICE, 1);
1236 chg_virtue(V_SACRIFICE, 1);
1237 chg_virtue(V_HONOUR, 1);
1240 chg_virtue(V_NATURE, 1);
1241 chg_virtue(V_HARMONY, 1);
1244 chg_virtue(V_JUSTICE, -1);
1245 chg_virtue(V_FAITH, -1);
1246 chg_virtue(V_HONOUR, -1);
1247 chg_virtue(V_COMPASSION, -1);
1250 chg_virtue(V_KNOWLEDGE, 1);
1257 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, 1);
1258 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, 1);
1259 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, 1);
1260 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_DILIGENCE, 1);
1263 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_UNLIFE, 1);
1264 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1265 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1266 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, -1);
1269 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1270 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1271 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1272 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, -1);
1275 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, 1);
1276 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, 1);
1277 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_SACRIFICE, 1);
1278 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, 1);
1281 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_NATURE, 1);
1282 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HARMONY, 1);
1285 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1286 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1287 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1288 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, -1);
1291 if (mp_ptr->spell_xtra & MAGIC_GAIN_EXP)
1293 s16b cur_exp = p_ptr->spell_exp[(increment ? 32 : 0)+spell];
1296 if (cur_exp < SPELL_EXP_BEGINNER)
1298 else if (cur_exp < SPELL_EXP_SKILLED)
1300 if ((dun_level > 4) && ((dun_level + 10) > p_ptr->lev))
1303 else if (cur_exp < SPELL_EXP_EXPERT)
1305 if (((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel))
1308 else if ((cur_exp < SPELL_EXP_MASTER) && !increment)
1310 if (((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel))
1313 p_ptr->spell_exp[(increment ? 32 : 0) + spell] += exp_gain;
1317 p_ptr->energy_use = 100;
1320 /* Over-exert the player */
1323 int oops = need_mana;
1327 p_ptr->csp_frac = 0;
1329 msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
1331 /* Hack -- Bypass free action */
1332 (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
1337 chg_virtue(V_VITALITY, -10);
1340 chg_virtue(V_UNLIFE, -10);
1343 chg_virtue(V_JUSTICE, 10);
1346 chg_virtue(V_NATURE, -10);
1349 chg_virtue(V_JUSTICE, -10);
1352 chg_virtue(V_COMPASSION, 10);
1355 chg_virtue(V_KNOWLEDGE, -10);
1359 /* Damage CON (possibly permanently) */
1360 if (randint0(100) < 50)
1362 bool perm = (randint0(100) < 25);
1364 msg_print(_("体を悪くしてしまった!", "You have damaged your health!"));
1366 /* Reduce constitution */
1367 (void)dec_stat(A_CON, 15 + randint1(10), perm);
1371 p_ptr->window |= (PW_PLAYER);
1372 p_ptr->window |= (PW_SPELL);