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 == '?'))
202 /* Display a list of spells */
203 print_spells(menu_line, spells, num, 1, 15, use_realm);
209 if (use_menu) continue;
222 ask = (isupper(choice));
225 if (ask) choice = (char)tolower(choice);
227 /* Extract request */
228 i = (islower(choice) ? A2I(choice) : -1);
231 /* Totally Illegal */
232 if ((i < 0) || (i >= num))
238 /* Save the spell index */
241 /* Require "okay" spells */
242 if (!spell_okay(spell, learned, FALSE, use_realm))
246 msg_format("その%sを%sことはできません。", p, prompt);
248 msg_format("You may not %s that %s.", prompt, p);
259 /* Access the spell */
260 if (!is_magic(use_realm))
262 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
266 s_ptr = &mp_ptr->info[use_realm - 1][spell];
269 /* Extract mana consumption rate */
270 if (use_realm == REALM_HISSATSU)
272 need_mana = s_ptr->smana;
276 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
281 jverb( prompt, jverb_buf, JVERB_AND );
283 (void) strnfmt(tmp_val, 78, "%s(MP%d, 失敗率%d%%)を%sますか? ",
284 do_spell(use_realm, spell, SPELL_NAME), need_mana,
285 spell_chance(spell, use_realm),jverb_buf);
287 (void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ",
288 prompt, do_spell(use_realm, spell, SPELL_NAME), need_mana,
289 spell_chance(spell, use_realm));
293 /* Belay that order */
294 if (!get_check(tmp_val)) continue;
301 if (redraw) screen_load();
303 p_ptr->window |= (PW_SPELL);
306 /* Abort if needed */
307 if (!flag) return FALSE;
309 /* Save the choice */
312 repeat_push((COMMAND_CODE)spell);
319 * @brief オブジェクトがプレイヤーが使用可能な魔道書かどうかを判定する
320 * @param o_ptr 判定したいオブ会ジェクトの構造体参照ポインタ
321 * @return 学習できる魔道書ならばTRUEを返す
323 static bool item_tester_learn_spell(object_type *o_ptr)
325 s32b choices = realm_choices2[p_ptr->pclass];
327 if (p_ptr->pclass == CLASS_PRIEST)
329 if (is_good_realm(p_ptr->realm1))
331 choices &= ~(CH_DEATH | CH_DAEMON);
335 choices &= ~(CH_LIFE | CH_CRUSADE);
339 if ((o_ptr->tval < TV_LIFE_BOOK) || (o_ptr->tval > (TV_LIFE_BOOK + MAX_REALM - 1))) return (FALSE);
340 if ((o_ptr->tval == TV_MUSIC_BOOK) && (p_ptr->pclass == CLASS_BARD)) return (TRUE);
341 else if (!is_magic(tval2realm(o_ptr->tval))) return FALSE;
342 if ((REALM1_BOOK == o_ptr->tval) || (REALM2_BOOK == o_ptr->tval)) return (TRUE);
343 if (choices & (0x0001 << (tval2realm(o_ptr->tval) - 1))) return (TRUE);
348 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
349 * @return 魔道書を一冊も持っていないならTRUEを返す
351 static bool player_has_no_spellbooks(void)
356 for (i = 0; i < INVEN_PACK; i++)
358 o_ptr = &inventory[i];
359 if (o_ptr->k_idx && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
362 for (i = cave[p_ptr->y][p_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
365 if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
372 * @brief プレイヤーの職業が練気術師の時、領域魔法と練気術を切り換える処理のインターフェイス
373 * @param browse_only 魔法と技能の閲覧を行うならばTRUE
374 * @return 魔道書を一冊も持っていないならTRUEを返す
376 static void confirm_use_force(bool browse_only)
381 /* Get the item index */
382 if (repeat_pull(&code) && (code == INVEN_FORCE))
384 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
388 /* Show the prompt */
389 prt(_("('w'練気術, ESC) 'w'かESCを押してください。 ", "(w for the Force, ESC) Hit 'w' or ESC. "), 0, 0);
396 if (which == ESCAPE) break;
397 else if (which == 'w')
400 repeat_push(INVEN_FORCE);
406 /* Clear the prompt line */
411 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
417 * @brief プレイヤーの魔法と技能を閲覧するコマンドのメインルーチン /
418 * Peruse the spells/prayers in a book
422 * Note that *all* spells in the book are listed
424 * Note that browsing is allowed while confused or blind,
425 * and in the dark, primarily to allow browsing in stores.
428 void do_cmd_browse(void)
431 OBJECT_SUBTYPE_VALUE sval;
432 REALM_IDX use_realm = 0;
434 SPELL_IDX spell = -1;
437 SPELL_IDX spells[64];
444 /* Warriors are illiterate */
445 if (!(p_ptr->realm1 || p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
447 msg_print(_("本を読むことができない!", "You cannot read books!"));
451 if (p_ptr->special_defense & KATA_MUSOU)
453 set_action(ACTION_NONE);
456 if (p_ptr->pclass == CLASS_FORCETRAINER)
458 if (player_has_no_spellbooks())
460 confirm_use_force(TRUE);
463 select_the_force = TRUE;
466 /* Restrict choices to "useful" books */
467 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
468 else item_tester_hook = item_tester_learn_spell;
470 q = _("どの本を読みますか? ", "Browse which book? ");
471 s = _("読める本がない。", "You have no books that you can read.");
473 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
475 select_the_force = FALSE;
478 select_the_force = FALSE;
480 if (item == INVEN_FORCE) /* the_force */
482 do_cmd_mind_browse();
486 /* Get the item (in the pack) */
489 o_ptr = &inventory[item];
492 /* Get the item (on the floor) */
495 o_ptr = &o_list[0 - item];
498 /* Access the item's sval */
501 use_realm = tval2realm(o_ptr->tval);
503 /* Track the object kind */
504 object_kind_track(o_ptr->k_idx);
509 for (spell = 0; spell < 32; spell++)
511 /* Check for this spell */
512 if ((fake_spell_flags[sval] & (1L << spell)))
514 /* Collect this spell */
515 spells[num++] = spell;
521 /* Clear the top line */
524 /* Keep browsing spells. Exit browsing on cancel. */
527 /* Ask for a spell, allow cancel */
528 if (!get_spell(&spell, _("読む", "browse"), o_ptr->sval, TRUE, use_realm))
530 /* If cancelled, leave immediately. */
531 if (spell == -1) break;
533 /* Display a list of spells */
534 print_spells(0, spells, num, 1, 15, use_realm);
536 /* Notify that there's nothing to see, and wait. */
537 if (use_realm == REALM_HISSATSU)
538 prt(_("読める技がない。", "No techniques to browse."), 0, 0);
540 prt(_("読める呪文がない。", "No spells to browse."), 0, 0);
548 /* Clear lines, position cursor (really should use strlen here) */
549 Term_erase(14, 14, 255);
550 Term_erase(14, 13, 255);
551 Term_erase(14, 12, 255);
552 Term_erase(14, 11, 255);
554 roff_to_buf(do_spell(use_realm, spell, SPELL_DESC), 62, temp, sizeof(temp));
556 for (j = 0, line = 11; temp[j]; j += 1 + strlen(&temp[j]))
558 prt(&temp[j], line, 15);
566 * @brief プレイヤーの第二魔法領域を変更する /
567 * @param next_realm 変更先の魔法領域ID
570 static void change_realm2(CHARACTER_IDX next_realm)
575 for (i = 0; i < 64; i++)
577 p_ptr->spell_order[j] = p_ptr->spell_order[i];
578 if (p_ptr->spell_order[i] < 32) j++;
581 p_ptr->spell_order[j] = 99;
583 for (i = 32; i < 64; i++)
585 p_ptr->spell_exp[i] = SPELL_EXP_UNSKILLED;
587 p_ptr->spell_learned2 = 0L;
588 p_ptr->spell_worked2 = 0L;
589 p_ptr->spell_forgotten2 = 0L;
591 sprintf(tmp,_("魔法の領域を%sから%sに変更した。", "change magic realm from %s to %s."), realm_names[p_ptr->realm2], realm_names[next_realm]);
592 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
593 p_ptr->old_realm |= 1 << (p_ptr->realm2-1);
594 p_ptr->realm2 = next_realm;
596 p_ptr->notice |= (PN_REORDER);
597 p_ptr->update |= (PU_SPELLS);
600 /* Load an autopick preference file */
601 autopick_load_pref(FALSE);
606 * @brief 魔法を学習するコマンドのメインルーチン /
607 * Study a book to gain a new spell/prayer
610 void do_cmd_study(void)
614 OBJECT_SUBTYPE_VALUE sval;
616 bool learned = FALSE;
618 /* Spells of realm2 will have an increment of +32 */
619 SPELL_IDX spell = -1;
621 cptr p = spell_category_name(mp_ptr->spell_book);
629 msg_print(_("本を読むことができない!", "You cannot read books!"));
633 if (p_ptr->blind || no_lite())
635 msg_print(_("目が見えない!", "You cannot see!"));
641 msg_print(_("混乱していて読めない!", "You are too confused!"));
645 if (!(p_ptr->new_spells))
647 msg_format(_("新しい%sを覚えることはできない!", "You cannot learn any new %ss!"), p);
651 if (p_ptr->special_defense & KATA_MUSOU)
653 set_action(ACTION_NONE);
657 if( p_ptr->new_spells < 10 ){
658 msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
660 msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
663 msg_format("You can learn %d new %s%s.", p_ptr->new_spells, p,
664 (p_ptr->new_spells == 1?"":"s"));
670 /* Restrict choices to "useful" books */
671 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
672 else item_tester_hook = item_tester_learn_spell;
674 q = _("どの本から学びますか? ", "Study which book? ");
675 s = _("読める本がない。", "You have no books that you can read.");
677 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
679 /* Get the item (in the pack) */
682 o_ptr = &inventory[item];
685 /* Get the item (on the floor) */
688 o_ptr = &o_list[0 - item];
691 /* Access the item's sval */
694 if (o_ptr->tval == REALM2_BOOK) increment = 32;
695 else if (o_ptr->tval != REALM1_BOOK)
697 if (!get_check(_("本当に魔法の領域を変更しますか?", "Really, change magic realm? "))) return;
698 change_realm2(tval2realm(o_ptr->tval));
702 /* Track the object kind */
703 object_kind_track(o_ptr->k_idx);
706 /* Mage -- Learn a selected spell */
707 if (mp_ptr->spell_book != TV_LIFE_BOOK)
709 /* Ask for a spell, allow cancel */
710 if (!get_spell(&spell, _("学ぶ", "study"), sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1) && (spell == -1)) return;
713 /* Priest -- Learn a random prayer */
720 for (spell = 0; spell < 32; spell++)
722 /* Check spells in the book */
723 if ((fake_spell_flags[sval] & (1L << spell)))
725 /* Skip non "okay" prayers */
726 if (!spell_okay(spell, FALSE, TRUE,
727 (increment ? p_ptr->realm2 : p_ptr->realm1))) continue;
729 /* Hack -- Prepare the randomizer */
732 /* Hack -- Apply the randomizer */
733 if (one_in_(k)) gift = spell;
741 /* Nothing to study */
744 msg_format(_("その本には学ぶべき%sがない。", "You cannot learn any %ss in that book."), p);
750 if (increment) spell += increment;
752 /* Learn the spell */
755 if (p_ptr->spell_learned1 & (1L << spell)) learned = TRUE;
756 else p_ptr->spell_learned1 |= (1L << spell);
760 if (p_ptr->spell_learned2 & (1L << (spell - 32))) learned = TRUE;
761 else p_ptr->spell_learned2 |= (1L << (spell - 32));
766 int max_exp = (spell < 32) ? SPELL_EXP_MASTER : SPELL_EXP_EXPERT;
767 int old_exp = p_ptr->spell_exp[spell];
768 int new_rank = EXP_LEVEL_UNSKILLED;
769 cptr name = do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell%32, SPELL_NAME);
771 if (old_exp >= max_exp)
773 msg_format(_("その%sは完全に使いこなせるので学ぶ必要はない。", "You don't need to study this %s anymore."), p);
777 if (!get_check(format("%sの%sをさらに学びます。よろしいですか?", name, p)))
779 if (!get_check(format("You will study a %s of %s again. Are you sure? ", p, name)))
784 else if (old_exp >= SPELL_EXP_EXPERT)
786 p_ptr->spell_exp[spell] = SPELL_EXP_MASTER;
787 new_rank = EXP_LEVEL_MASTER;
789 else if (old_exp >= SPELL_EXP_SKILLED)
791 if (spell >= 32) p_ptr->spell_exp[spell] = SPELL_EXP_EXPERT;
792 else p_ptr->spell_exp[spell] += SPELL_EXP_EXPERT - SPELL_EXP_SKILLED;
793 new_rank = EXP_LEVEL_EXPERT;
795 else if (old_exp >= SPELL_EXP_BEGINNER)
797 p_ptr->spell_exp[spell] = SPELL_EXP_SKILLED + (old_exp - SPELL_EXP_BEGINNER) * 2 / 3;
798 new_rank = EXP_LEVEL_SKILLED;
802 p_ptr->spell_exp[spell] = SPELL_EXP_BEGINNER + old_exp / 3;
803 new_rank = EXP_LEVEL_BEGINNER;
805 msg_format(_("%sの熟練度が%sに上がった。", "Your proficiency of %s is now %s rank."), name, exp_level_str[new_rank]);
809 /* Find the next open entry in "p_ptr->spell_order[]" */
810 for (i = 0; i < 64; i++)
812 /* Stop at the first empty space */
813 if (p_ptr->spell_order[i] == 99) break;
816 /* Add the spell to the known list */
817 p_ptr->spell_order[i++] = spell;
819 /* Mention the result */
822 if (mp_ptr->spell_book == TV_MUSIC_BOOK)
824 msg_format("%sを学んだ。",
825 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
829 msg_format("%sの%sを学んだ。",
830 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME) ,p);
833 msg_format("You have learned the %s of %s.",
834 p, do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
838 p_ptr->energy_use = 100;
840 switch (mp_ptr->spell_book)
843 chg_virtue(V_FAITH, 1);
846 chg_virtue(V_UNLIFE, 1);
849 chg_virtue(V_NATURE, 1);
852 chg_virtue(V_KNOWLEDGE, 1);
858 /* One less spell available */
859 p_ptr->learned_spells++;
862 p_ptr->update |= (PU_SPELLS);
865 /* Redraw object recall */
866 p_ptr->window |= (PW_OBJECT);
871 * @brief 魔法を詠唱するコマンドのメインルーチン /
875 void do_cmd_cast(void)
878 OBJECT_SUBTYPE_VALUE sval;
884 MANA_POINT need_mana;
888 const magic_type *s_ptr;
891 bool over_exerted = FALSE;
893 /* Require spell ability */
894 if (!p_ptr->realm1 && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
896 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
901 if (p_ptr->blind || no_lite())
903 if (p_ptr->pclass == CLASS_FORCETRAINER) confirm_use_force(FALSE);
906 msg_print(_("目が見えない!", "You cannot see!"));
912 /* Not when confused */
915 msg_print(_("混乱していて唱えられない!", "You are too confused!"));
921 if (p_ptr->realm1 == REALM_HEX)
923 if (hex_spell_fully())
926 msg_print(_("これ以上新しい呪文を詠唱することはできない。", "Can not spell new spells more."));
928 if (p_ptr->lev >= 35) flag = stop_hex_spell();
933 if (p_ptr->pclass == CLASS_FORCETRAINER)
935 if (player_has_no_spellbooks())
937 confirm_use_force(FALSE);
940 select_the_force = TRUE;
943 prayer = spell_category_name(mp_ptr->spell_book);
945 /* Restrict choices to spell books */
946 item_tester_tval = mp_ptr->spell_book;
948 q = _("どの呪文書を使いますか? ", "Use which book? ");
949 s = _("呪文書がない!", "You have no spell books!");
951 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
953 select_the_force = FALSE;
956 select_the_force = FALSE;
958 if (item == INVEN_FORCE) /* the_force */
964 /* Get the item (in the pack) */
967 o_ptr = &inventory[item];
970 /* Get the item (on the floor) */
973 o_ptr = &o_list[0 - item];
976 /* Access the item's sval */
979 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && (o_ptr->tval == REALM2_BOOK)) increment = 32;
982 /* Track the object kind */
983 object_kind_track(o_ptr->k_idx);
986 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
987 realm = o_ptr->tval - TV_LIFE_BOOK + 1;
988 else if (increment) realm = p_ptr->realm2;
989 else realm = p_ptr->realm1;
991 /* Ask for a spell */
993 if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_MUSIC_BOOK) ? "歌う" : "唱える"),
996 if (spell == -2) msg_format("その本には知っている%sがない。", prayer);
1000 if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1004 msg_format("You don't know any %ss in that book.", prayer);
1010 use_realm = tval2realm(o_ptr->tval);
1013 if (use_realm == REALM_HEX)
1015 if (hex_spelling(spell))
1017 msg_print(_("その呪文はすでに詠唱中だ。", "You are already casting it."));
1022 if (!is_magic(use_realm))
1024 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
1028 s_ptr = &mp_ptr->info[realm - 1][spell];
1031 /* Extract mana consumption rate */
1032 need_mana = mod_need_mana(s_ptr->smana, spell, realm);
1034 /* Verify "dangerous" spells */
1035 if (need_mana > p_ptr->csp)
1037 if (flush_failure) flush();
1041 msg_format("その%sを%sのに十分なマジックポイントがない。",prayer,
1042 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_LIFE_BOOK) ? "歌う" : "唱える"));
1044 msg_format("You do not have enough mana to %s this %s.",
1045 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1050 if (!over_exert) return;
1053 if (!get_check_strict(_("それでも挑戦しますか? ", "Attempt it anyway? "), CHECK_OKAY_CANCEL)) return;
1056 /* Spell failure chance */
1057 chance = spell_chance(spell, use_realm);
1059 /* Sufficient mana */
1060 if (need_mana <= p_ptr->csp)
1063 p_ptr->csp -= need_mana;
1065 else over_exerted = TRUE;
1066 p_ptr->redraw |= (PR_MANA);
1069 if (randint0(100) < chance)
1071 if (flush_failure) flush();
1073 msg_format(_("%sをうまく唱えられなかった!", "You failed to get the %s off!"), prayer);
1079 if (randint1(100) < chance) chg_virtue(V_VITALITY, -1);
1082 if (randint1(100) < chance) chg_virtue(V_UNLIFE, -1);
1085 if (randint1(100) < chance) chg_virtue(V_NATURE, -1);
1088 if (randint1(100) < chance) chg_virtue(V_JUSTICE, 1);
1091 if (randint1(100) < chance) chg_virtue(V_JUSTICE, -1);
1094 if (randint1(100) < chance) chg_virtue(V_COMPASSION, -1);
1097 if (randint1(100) < chance) chg_virtue(V_KNOWLEDGE, -1);
1101 /* Failure casting may activate some side effect */
1102 do_spell(realm, spell, SPELL_FAIL);
1105 if ((o_ptr->tval == TV_CHAOS_BOOK) && (randint1(100) < spell))
1107 msg_print(_("カオス的な効果を発生した!", "You produce a chaotic effect!"));
1110 else if ((o_ptr->tval == TV_DEATH_BOOK) && (randint1(100) < spell))
1112 if ((sval == 3) && one_in_(2))
1114 sanity_blast(0, TRUE);
1118 msg_print(_("痛い!", "It hurts!"));
1119 take_hit(DAMAGE_LOSELIFE, damroll(o_ptr->sval + 1, 6), _("暗黒魔法の逆流", "a miscast Death spell"), -1);
1121 if ((spell > 15) && one_in_(6) && !p_ptr->hold_exp)
1122 lose_exp(spell * 250);
1125 else if ((o_ptr->tval == TV_MUSIC_BOOK) && (randint1(200) < spell))
1127 msg_print(_("いやな音が響いた", "An infernal sound echoed."));
1128 aggravate_monsters(0);
1130 if (randint1(100) >= chance)
1131 chg_virtue(V_CHANCE,-1);
1137 /* Canceled spells cost neither a turn nor mana */
1138 if (!do_spell(realm, spell, SPELL_CAST)) return;
1140 if (randint1(100) < chance)
1141 chg_virtue(V_CHANCE,1);
1143 /* A spell was cast */
1145 (p_ptr->spell_worked2 & (1L << spell)) :
1146 (p_ptr->spell_worked1 & (1L << spell)))
1147 && (p_ptr->pclass != CLASS_SORCERER)
1148 && (p_ptr->pclass != CLASS_RED_MAGE))
1150 int e = s_ptr->sexp;
1152 /* The spell worked */
1153 if (realm == p_ptr->realm1)
1155 p_ptr->spell_worked1 |= (1L << spell);
1159 p_ptr->spell_worked2 |= (1L << spell);
1162 /* Gain experience */
1163 gain_exp(e * s_ptr->slevel);
1165 /* Redraw object recall */
1166 p_ptr->window |= (PW_OBJECT);
1171 chg_virtue(V_TEMPERANCE, 1);
1172 chg_virtue(V_COMPASSION, 1);
1173 chg_virtue(V_VITALITY, 1);
1174 chg_virtue(V_DILIGENCE, 1);
1177 chg_virtue(V_UNLIFE, 1);
1178 chg_virtue(V_JUSTICE, -1);
1179 chg_virtue(V_FAITH, -1);
1180 chg_virtue(V_VITALITY, -1);
1183 chg_virtue(V_JUSTICE, -1);
1184 chg_virtue(V_FAITH, -1);
1185 chg_virtue(V_HONOUR, -1);
1186 chg_virtue(V_TEMPERANCE, -1);
1189 chg_virtue(V_FAITH, 1);
1190 chg_virtue(V_JUSTICE, 1);
1191 chg_virtue(V_SACRIFICE, 1);
1192 chg_virtue(V_HONOUR, 1);
1195 chg_virtue(V_NATURE, 1);
1196 chg_virtue(V_HARMONY, 1);
1199 chg_virtue(V_JUSTICE, -1);
1200 chg_virtue(V_FAITH, -1);
1201 chg_virtue(V_HONOUR, -1);
1202 chg_virtue(V_COMPASSION, -1);
1205 chg_virtue(V_KNOWLEDGE, 1);
1212 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, 1);
1213 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, 1);
1214 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, 1);
1215 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_DILIGENCE, 1);
1218 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_UNLIFE, 1);
1219 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1220 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1221 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, -1);
1224 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1225 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1226 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1227 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, -1);
1230 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, 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_SACRIFICE, 1);
1233 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, 1);
1236 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_NATURE, 1);
1237 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HARMONY, 1);
1240 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1241 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1242 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1243 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, -1);
1246 if (mp_ptr->spell_xtra & MAGIC_GAIN_EXP)
1248 s16b cur_exp = p_ptr->spell_exp[(increment ? 32 : 0)+spell];
1251 if (cur_exp < SPELL_EXP_BEGINNER)
1253 else if (cur_exp < SPELL_EXP_SKILLED)
1255 if ((dun_level > 4) && ((dun_level + 10) > p_ptr->lev))
1258 else if (cur_exp < SPELL_EXP_EXPERT)
1260 if (((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel))
1263 else if ((cur_exp < SPELL_EXP_MASTER) && !increment)
1265 if (((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel))
1268 p_ptr->spell_exp[(increment ? 32 : 0) + spell] += exp_gain;
1272 p_ptr->energy_use = 100;
1275 /* Over-exert the player */
1278 int oops = need_mana;
1282 p_ptr->csp_frac = 0;
1284 msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
1286 /* Hack -- Bypass free action */
1287 (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
1292 chg_virtue(V_VITALITY, -10);
1295 chg_virtue(V_UNLIFE, -10);
1298 chg_virtue(V_JUSTICE, 10);
1301 chg_virtue(V_NATURE, -10);
1304 chg_virtue(V_JUSTICE, -10);
1307 chg_virtue(V_COMPASSION, 10);
1310 chg_virtue(V_KNOWLEDGE, -10);
1314 /* Damage CON (possibly permanently) */
1315 if (randint0(100) < 50)
1317 bool perm = (randint0(100) < 25);
1319 msg_print(_("体を悪くしてしまった!", "You have damaged your health!"));
1321 /* Reduce constitution */
1322 (void)dec_stat(A_CON, 15 + randint1(10), perm);
1326 p_ptr->window |= (PW_PLAYER);
1327 p_ptr->window |= (PW_SPELL);