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.
16 #include "player-status.h"
19 * @brief 領域魔法に応じて技能の名称を返す。
20 * @param tval 魔法書のtval
21 * @return 領域魔法の技能名称を保管した文字列ポインタ
23 concptr spell_category_name(OBJECT_TYPE_VALUE tval)
27 case TV_HISSATSU_BOOK:
28 return _("必殺技", "art");
30 return _("祈り", "prayer");
32 return _("歌", "song");
34 return _("呪文", "spell");
39 * @brief 領域魔法の閲覧、学習、使用選択するインターフェイス処理
40 * Allow user to choose a spell/prayer from the given book.
41 * @param sn 選択した魔法IDを返す参照ポインタ
42 * @param prompt 魔法を利用する際の動詞表記
43 * @param sval 魔道書のsval
44 * @param learned 閲覧/使用選択ならばTRUE、学習処理ならFALSE
45 * @param use_realm 魔法領域ID
48 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
49 * If the user hits escape, returns FALSE, and set '*sn' to -1
50 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
51 * The "prompt" should be "cast", "recite", or "study"
52 * The "known" should be TRUE for cast/pray, FALSE for study
55 static int get_spell(SPELL_IDX *sn, concptr prompt, OBJECT_SUBTYPE_VALUE sval, bool learned, REALM_IDX use_realm)
63 bool flag, redraw, okay;
65 const magic_type *s_ptr;
72 int menu_line = (use_menu ? 1 : 0);
74 /* Get the spell, if available */
75 if (repeat_pull(&code))
77 *sn = (SPELL_IDX)code;
78 /* Verify the spell */
79 if (spell_okay(*sn, learned, FALSE, use_realm))
86 p = spell_category_name(mp_ptr->spell_book);
89 for (spell = 0; spell < 32; spell++)
91 /* Check for this spell */
92 if ((fake_spell_flags[sval] & (1L << spell)))
94 /* Collect this spell */
95 spells[num++] = spell;
99 /* Assume no usable spells */
102 /* Assume no spells available */
105 /* Check for "okay" spells */
106 for (i = 0; i < num; i++)
108 /* Look for "okay" spells */
109 if (spell_okay(spells[i], learned, FALSE, use_realm)) okay = TRUE;
112 /* No "okay" spells */
113 if (!okay) return (FALSE);
114 if (((use_realm) != p_ptr->realm1) && ((use_realm) != p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return FALSE;
115 if (((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) && !is_magic(use_realm)) return FALSE;
116 if ((p_ptr->pclass == CLASS_RED_MAGE) && ((use_realm) != REALM_ARCANE) && (sval > 1)) return FALSE;
118 /* Assume cancelled */
121 /* Nothing chosen yet */
127 p_ptr->window |= (PW_SPELL);
130 /* Build a prompt (accept all spells) */
132 jverb( prompt, jverb_buf, JVERB_AND );
133 (void) strnfmt(out_val, 78, "(%^s:%c-%c, '*'で一覧, ESCで中断) どの%sを%^sますか? ",
134 p, I2A(0), I2A(num - 1), p, jverb_buf );
136 (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) %^s which %s? ",
137 p, I2A(0), I2A(num - 1), prompt, p);
140 /* Get a spell from the user */
142 choice = (always_show_list || use_menu) ? ESCAPE : 1;
145 if (choice == ESCAPE) choice = ' ';
146 else if (!get_com(out_val, &choice, TRUE))break;
148 if (use_menu && choice != ' ')
162 menu_line += (num - 1);
184 if (menu_line > num) menu_line -= num;
185 /* Display a list of spells */
186 print_spells(menu_line, spells, num, 1, 15, use_realm);
192 if ((choice == ' ') || (choice == '*') || (choice == '?'))
201 /* Display a list of spells */
202 print_spells(menu_line, spells, num, 1, 15, use_realm);
208 if (use_menu) continue;
221 ask = (isupper(choice));
224 if (ask) choice = (char)tolower(choice);
226 /* Extract request */
227 i = (islower(choice) ? A2I(choice) : -1);
230 /* Totally Illegal */
231 if ((i < 0) || (i >= num))
237 /* Save the spell index */
240 /* Require "okay" spells */
241 if (!spell_okay(spell, learned, FALSE, use_realm))
245 msg_format("その%sを%sことはできません。", p, prompt);
247 msg_format("You may not %s that %s.", prompt, p);
258 /* Access the spell */
259 if (!is_magic(use_realm))
261 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
265 s_ptr = &mp_ptr->info[use_realm - 1][spell];
268 /* Extract mana consumption rate */
269 if (use_realm == REALM_HISSATSU)
271 need_mana = s_ptr->smana;
275 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
280 jverb( prompt, jverb_buf, JVERB_AND );
282 (void) strnfmt(tmp_val, 78, "%s(MP%d, 失敗率%d%%)を%sますか? ",
283 do_spell(use_realm, spell, SPELL_NAME), need_mana,
284 spell_chance(spell, use_realm),jverb_buf);
286 (void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ",
287 prompt, do_spell(use_realm, spell, SPELL_NAME), need_mana,
288 spell_chance(spell, use_realm));
292 /* Belay that order */
293 if (!get_check(tmp_val)) continue;
300 if (redraw) screen_load();
302 p_ptr->window |= (PW_SPELL);
305 /* Abort if needed */
306 if (!flag) return FALSE;
308 /* Save the choice */
311 repeat_push((COMMAND_CODE)spell);
318 * @brief オブジェクトがプレイヤーが使用可能な魔道書かどうかを判定する
319 * @param o_ptr 判定したいオブ会ジェクトの構造体参照ポインタ
320 * @return 学習できる魔道書ならばTRUEを返す
322 static bool item_tester_learn_spell(object_type *o_ptr)
324 s32b choices = realm_choices2[p_ptr->pclass];
326 if (p_ptr->pclass == CLASS_PRIEST)
328 if (is_good_realm(p_ptr->realm1))
330 choices &= ~(CH_DEATH | CH_DAEMON);
334 choices &= ~(CH_LIFE | CH_CRUSADE);
338 if ((o_ptr->tval < TV_LIFE_BOOK) || (o_ptr->tval > (TV_LIFE_BOOK + MAX_REALM - 1))) return (FALSE);
339 if ((o_ptr->tval == TV_MUSIC_BOOK) && (p_ptr->pclass == CLASS_BARD)) return (TRUE);
340 else if (!is_magic(tval2realm(o_ptr->tval))) return FALSE;
341 if ((REALM1_BOOK == o_ptr->tval) || (REALM2_BOOK == o_ptr->tval)) return (TRUE);
342 if (choices & (0x0001 << (tval2realm(o_ptr->tval) - 1))) return (TRUE);
347 * @brief プレイヤーの職業が練気術師の時、領域魔法と練気術を切り換える処理のインターフェイス
348 * @param browse_only 魔法と技能の閲覧を行うならばTRUE
349 * @return 魔道書を一冊も持っていないならTRUEを返す
351 static void confirm_use_force(bool browse_only)
356 /* Get the item index */
357 if (repeat_pull(&code) && (code == INVEN_FORCE))
359 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
363 /* Show the prompt */
364 prt(_("('w'練気術, ESC) 'w'かESCを押してください。 ", "(w for the Force, ESC) Hit 'w' or ESC. "), 0, 0);
371 if (which == ESCAPE) break;
372 else if (which == 'w')
374 repeat_push(INVEN_FORCE);
379 /* Clear the prompt line */
384 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
390 * @brief プレイヤーの魔法と技能を閲覧するコマンドのメインルーチン /
391 * Peruse the spells/prayers in a book
395 * Note that *all* spells in the book are listed
397 * Note that browsing is allowed while confused or blind,
398 * and in the dark, primarily to allow browsing in stores.
401 void do_cmd_browse(void)
404 OBJECT_SUBTYPE_VALUE sval;
405 REALM_IDX use_realm = 0;
407 SPELL_IDX spell = -1;
410 SPELL_IDX spells[64];
417 /* Warriors are illiterate */
418 if (!(p_ptr->realm1 || p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
420 msg_print(_("本を読むことができない!", "You cannot read books!"));
424 if (p_ptr->special_defense & KATA_MUSOU)
426 set_action(ACTION_NONE);
429 if (p_ptr->pclass == CLASS_FORCETRAINER)
431 if (player_has_no_spellbooks())
433 confirm_use_force(TRUE);
438 /* Restrict choices to "useful" books */
439 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
440 else item_tester_hook = item_tester_learn_spell;
442 q = _("どの本を読みますか? ", "Browse which book? ");
443 s = _("読める本がない。", "You have no books that you can read.");
445 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | (p_ptr->pclass == CLASS_FORCETRAINER ? USE_FORCE : 0)));
448 if (item == INVEN_FORCE) /* the_force */
450 do_cmd_mind_browse();
456 /* Access the item's sval */
459 use_realm = tval2realm(o_ptr->tval);
461 /* Track the object kind */
462 object_kind_track(o_ptr->k_idx);
466 for (spell = 0; spell < 32; spell++)
468 /* Check for this spell */
469 if ((fake_spell_flags[sval] & (1L << spell)))
471 /* Collect this spell */
472 spells[num++] = spell;
479 /* Keep browsing spells. Exit browsing on cancel. */
482 /* Ask for a spell, allow cancel */
483 if (!get_spell(&spell, _("読む", "browse"), o_ptr->sval, TRUE, use_realm))
485 /* If cancelled, leave immediately. */
486 if (spell == -1) break;
488 /* Display a list of spells */
489 print_spells(0, spells, num, 1, 15, use_realm);
491 /* Notify that there's nothing to see, and wait. */
492 if (use_realm == REALM_HISSATSU)
493 prt(_("読める技がない。", "No techniques to browse."), 0, 0);
495 prt(_("読める呪文がない。", "No spells to browse."), 0, 0);
503 /* Clear lines, position cursor (really should use strlen here) */
504 Term_erase(14, 14, 255);
505 Term_erase(14, 13, 255);
506 Term_erase(14, 12, 255);
507 Term_erase(14, 11, 255);
509 roff_to_buf(do_spell(use_realm, spell, SPELL_DESC), 62, temp, sizeof(temp));
511 for (j = 0, line = 11; temp[j]; j += 1 + strlen(&temp[j]))
513 prt(&temp[j], line, 15);
521 * @brief プレイヤーの第二魔法領域を変更する /
522 * @param next_realm 変更先の魔法領域ID
525 static void change_realm2(CHARACTER_IDX next_realm)
530 for (i = 0; i < 64; i++)
532 p_ptr->spell_order[j] = p_ptr->spell_order[i];
533 if (p_ptr->spell_order[i] < 32) j++;
536 p_ptr->spell_order[j] = 99;
538 for (i = 32; i < 64; i++)
540 p_ptr->spell_exp[i] = SPELL_EXP_UNSKILLED;
542 p_ptr->spell_learned2 = 0L;
543 p_ptr->spell_worked2 = 0L;
544 p_ptr->spell_forgotten2 = 0L;
546 sprintf(tmp,_("魔法の領域を%sから%sに変更した。", "change magic realm from %s to %s."), realm_names[p_ptr->realm2], realm_names[next_realm]);
547 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
548 p_ptr->old_realm |= 1 << (p_ptr->realm2-1);
549 p_ptr->realm2 = next_realm;
551 p_ptr->update |= (PU_REORDER);
552 p_ptr->update |= (PU_SPELLS);
555 /* Load an autopick preference file */
556 autopick_load_pref(FALSE);
561 * @brief 魔法を学習するコマンドのメインルーチン /
562 * Study a book to gain a new spell/prayer
565 void do_cmd_study(void)
569 OBJECT_SUBTYPE_VALUE sval;
571 bool learned = FALSE;
573 /* Spells of realm2 will have an increment of +32 */
574 SPELL_IDX spell = -1;
576 concptr p = spell_category_name(mp_ptr->spell_book);
584 msg_print(_("本を読むことができない!", "You cannot read books!"));
588 if (p_ptr->blind || no_lite())
590 msg_print(_("目が見えない!", "You cannot see!"));
596 msg_print(_("混乱していて読めない!", "You are too confused!"));
600 if (!(p_ptr->new_spells))
602 msg_format(_("新しい%sを覚えることはできない!", "You cannot learn any new %ss!"), p);
606 if (p_ptr->special_defense & KATA_MUSOU)
608 set_action(ACTION_NONE);
612 if( p_ptr->new_spells < 10 ){
613 msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
615 msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
618 msg_format("You can learn %d new %s%s.", p_ptr->new_spells, p,
619 (p_ptr->new_spells == 1?"":"s"));
625 /* Restrict choices to "useful" books */
626 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
627 else item_tester_hook = item_tester_learn_spell;
629 q = _("どの本から学びますか? ", "Study which book? ");
630 s = _("読める本がない。", "You have no books that you can read.");
632 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
635 /* Access the item's sval */
638 if (o_ptr->tval == REALM2_BOOK) increment = 32;
639 else if (o_ptr->tval != REALM1_BOOK)
641 if (!get_check(_("本当に魔法の領域を変更しますか?", "Really, change magic realm? "))) return;
642 change_realm2(tval2realm(o_ptr->tval));
646 /* Track the object kind */
647 object_kind_track(o_ptr->k_idx);
650 /* Mage -- Learn a selected spell */
651 if (mp_ptr->spell_book != TV_LIFE_BOOK)
653 /* Ask for a spell, allow cancel */
654 if (!get_spell(&spell, _("学ぶ", "study"), sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1) && (spell == -1)) return;
657 /* Priest -- Learn a random prayer */
664 for (spell = 0; spell < 32; spell++)
666 /* Check spells in the book */
667 if ((fake_spell_flags[sval] & (1L << spell)))
669 /* Skip non "okay" prayers */
670 if (!spell_okay(spell, FALSE, TRUE,
671 (increment ? p_ptr->realm2 : p_ptr->realm1))) continue;
673 /* Hack -- Prepare the randomizer */
676 /* Hack -- Apply the randomizer */
677 if (one_in_(k)) gift = spell;
685 /* Nothing to study */
688 msg_format(_("その本には学ぶべき%sがない。", "You cannot learn any %ss in that book."), p);
694 if (increment) spell += increment;
696 /* Learn the spell */
699 if (p_ptr->spell_learned1 & (1L << spell)) learned = TRUE;
700 else p_ptr->spell_learned1 |= (1L << spell);
704 if (p_ptr->spell_learned2 & (1L << (spell - 32))) learned = TRUE;
705 else p_ptr->spell_learned2 |= (1L << (spell - 32));
710 int max_exp = (spell < 32) ? SPELL_EXP_MASTER : SPELL_EXP_EXPERT;
711 int old_exp = p_ptr->spell_exp[spell];
712 int new_rank = EXP_LEVEL_UNSKILLED;
713 concptr name = do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell%32, SPELL_NAME);
715 if (old_exp >= max_exp)
717 msg_format(_("その%sは完全に使いこなせるので学ぶ必要はない。", "You don't need to study this %s anymore."), p);
721 if (!get_check(format("%sの%sをさらに学びます。よろしいですか?", name, p)))
723 if (!get_check(format("You will study a %s of %s again. Are you sure? ", p, name)))
728 else if (old_exp >= SPELL_EXP_EXPERT)
730 p_ptr->spell_exp[spell] = SPELL_EXP_MASTER;
731 new_rank = EXP_LEVEL_MASTER;
733 else if (old_exp >= SPELL_EXP_SKILLED)
735 if (spell >= 32) p_ptr->spell_exp[spell] = SPELL_EXP_EXPERT;
736 else p_ptr->spell_exp[spell] += SPELL_EXP_EXPERT - SPELL_EXP_SKILLED;
737 new_rank = EXP_LEVEL_EXPERT;
739 else if (old_exp >= SPELL_EXP_BEGINNER)
741 p_ptr->spell_exp[spell] = SPELL_EXP_SKILLED + (old_exp - SPELL_EXP_BEGINNER) * 2 / 3;
742 new_rank = EXP_LEVEL_SKILLED;
746 p_ptr->spell_exp[spell] = SPELL_EXP_BEGINNER + old_exp / 3;
747 new_rank = EXP_LEVEL_BEGINNER;
749 msg_format(_("%sの熟練度が%sに上がった。", "Your proficiency of %s is now %s rank."), name, exp_level_str[new_rank]);
753 /* Find the next open entry in "p_ptr->spell_order[]" */
754 for (i = 0; i < 64; i++)
756 /* Stop at the first empty space */
757 if (p_ptr->spell_order[i] == 99) break;
760 /* Add the spell to the known list */
761 p_ptr->spell_order[i++] = spell;
763 /* Mention the result */
766 if (mp_ptr->spell_book == TV_MUSIC_BOOK)
768 msg_format("%sを学んだ。",
769 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
773 msg_format("%sの%sを学んだ。",
774 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME) ,p);
777 msg_format("You have learned the %s of %s.",
778 p, do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
782 p_ptr->energy_use = 100;
784 switch (mp_ptr->spell_book)
787 chg_virtue(V_FAITH, 1);
790 chg_virtue(V_UNLIFE, 1);
793 chg_virtue(V_NATURE, 1);
796 chg_virtue(V_KNOWLEDGE, 1);
802 /* One less spell available */
803 p_ptr->learned_spells++;
806 p_ptr->update |= (PU_SPELLS);
807 update_creature(p_ptr);
809 /* Redraw object recall */
810 p_ptr->window |= (PW_OBJECT);
815 * @brief 魔法を詠唱するコマンドのメインルーチン /
819 void do_cmd_cast(void)
822 OBJECT_SUBTYPE_VALUE sval;
828 MANA_POINT need_mana;
832 const magic_type *s_ptr;
835 bool over_exerted = FALSE;
837 /* Require spell ability */
838 if (!p_ptr->realm1 && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
840 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
845 if (p_ptr->blind || no_lite())
847 if (p_ptr->pclass == CLASS_FORCETRAINER) confirm_use_force(FALSE);
850 msg_print(_("目が見えない!", "You cannot see!"));
856 /* Not when confused */
859 msg_print(_("混乱していて唱えられない!", "You are too confused!"));
865 if (p_ptr->realm1 == REALM_HEX)
867 if (hex_spell_fully())
870 msg_print(_("これ以上新しい呪文を詠唱することはできない。", "Can not spell new spells more."));
872 if (p_ptr->lev >= 35) flag = stop_hex_spell();
877 if (p_ptr->pclass == CLASS_FORCETRAINER)
879 if (player_has_no_spellbooks())
881 confirm_use_force(FALSE);
886 prayer = spell_category_name(mp_ptr->spell_book);
888 /* Restrict choices to spell books */
889 item_tester_tval = mp_ptr->spell_book;
891 q = _("どの呪文書を使いますか? ", "Use which book? ");
892 s = _("呪文書がない!", "You have no spell books!");
894 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | (p_ptr->pclass == CLASS_FORCETRAINER ? USE_FORCE : 0)));
897 if (item == INVEN_FORCE) /* the_force */
905 /* Access the item's sval */
908 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && (o_ptr->tval == REALM2_BOOK)) increment = 32;
910 /* Track the object kind */
911 object_kind_track(o_ptr->k_idx);
914 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
915 realm = o_ptr->tval - TV_LIFE_BOOK + 1;
916 else if (increment) realm = p_ptr->realm2;
917 else realm = p_ptr->realm1;
919 /* Ask for a spell */
921 if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_MUSIC_BOOK) ? "歌う" : "唱える"),
924 if (spell == -2) msg_format("その本には知っている%sがない。", prayer);
928 if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
932 msg_format("You don't know any %ss in that book.", prayer);
938 use_realm = tval2realm(o_ptr->tval);
941 if (use_realm == REALM_HEX)
943 if (hex_spelling(spell))
945 msg_print(_("その呪文はすでに詠唱中だ。", "You are already casting it."));
950 if (!is_magic(use_realm))
952 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
956 s_ptr = &mp_ptr->info[realm - 1][spell];
959 /* Extract mana consumption rate */
960 need_mana = mod_need_mana(s_ptr->smana, spell, realm);
962 /* Verify "dangerous" spells */
963 if (need_mana > p_ptr->csp)
965 if (flush_failure) flush();
969 msg_format("その%sを%sのに十分なマジックポイントがない。",prayer,
970 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_LIFE_BOOK) ? "歌う" : "唱える"));
972 msg_format("You do not have enough mana to %s this %s.",
973 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
978 if (!over_exert) return;
981 if (!get_check_strict(_("それでも挑戦しますか? ", "Attempt it anyway? "), CHECK_OKAY_CANCEL)) return;
984 /* Spell failure chance */
985 chance = spell_chance(spell, use_realm);
987 /* Sufficient mana */
988 if (need_mana <= p_ptr->csp)
991 p_ptr->csp -= need_mana;
993 else over_exerted = TRUE;
994 p_ptr->redraw |= (PR_MANA);
997 if (randint0(100) < chance)
999 if (flush_failure) flush();
1001 msg_format(_("%sをうまく唱えられなかった!", "You failed to get the %s off!"), prayer);
1007 if (randint1(100) < chance) chg_virtue(V_VITALITY, -1);
1010 if (randint1(100) < chance) chg_virtue(V_UNLIFE, -1);
1013 if (randint1(100) < chance) chg_virtue(V_NATURE, -1);
1016 if (randint1(100) < chance) chg_virtue(V_JUSTICE, 1);
1019 if (randint1(100) < chance) chg_virtue(V_JUSTICE, -1);
1022 if (randint1(100) < chance) chg_virtue(V_COMPASSION, -1);
1025 if (randint1(100) < chance) chg_virtue(V_KNOWLEDGE, -1);
1029 /* Failure casting may activate some side effect */
1030 do_spell(realm, spell, SPELL_FAIL);
1033 if ((o_ptr->tval == TV_CHAOS_BOOK) && (randint1(100) < spell))
1035 msg_print(_("カオス的な効果を発生した!", "You produce a chaotic effect!"));
1038 else if ((o_ptr->tval == TV_DEATH_BOOK) && (randint1(100) < spell))
1040 if ((sval == 3) && one_in_(2))
1042 sanity_blast(0, TRUE);
1046 msg_print(_("痛い!", "It hurts!"));
1047 take_hit(DAMAGE_LOSELIFE, damroll(o_ptr->sval + 1, 6), _("暗黒魔法の逆流", "a miscast Death spell"), -1);
1049 if ((spell > 15) && one_in_(6) && !p_ptr->hold_exp)
1050 lose_exp(spell * 250);
1053 else if ((o_ptr->tval == TV_MUSIC_BOOK) && (randint1(200) < spell))
1055 msg_print(_("いやな音が響いた", "An infernal sound echoed."));
1056 aggravate_monsters(0);
1058 if (randint1(100) >= chance)
1059 chg_virtue(V_CHANCE,-1);
1065 /* Canceled spells cost neither a turn nor mana */
1066 if (!do_spell(realm, spell, SPELL_CAST)) return;
1068 if (randint1(100) < chance)
1069 chg_virtue(V_CHANCE,1);
1071 /* A spell was cast */
1073 (p_ptr->spell_worked2 & (1L << spell)) :
1074 (p_ptr->spell_worked1 & (1L << spell)))
1075 && (p_ptr->pclass != CLASS_SORCERER)
1076 && (p_ptr->pclass != CLASS_RED_MAGE))
1078 int e = s_ptr->sexp;
1080 /* The spell worked */
1081 if (realm == p_ptr->realm1)
1083 p_ptr->spell_worked1 |= (1L << spell);
1087 p_ptr->spell_worked2 |= (1L << spell);
1090 /* Gain experience */
1091 gain_exp(e * s_ptr->slevel);
1093 /* Redraw object recall */
1094 p_ptr->window |= (PW_OBJECT);
1099 chg_virtue(V_TEMPERANCE, 1);
1100 chg_virtue(V_COMPASSION, 1);
1101 chg_virtue(V_VITALITY, 1);
1102 chg_virtue(V_DILIGENCE, 1);
1105 chg_virtue(V_UNLIFE, 1);
1106 chg_virtue(V_JUSTICE, -1);
1107 chg_virtue(V_FAITH, -1);
1108 chg_virtue(V_VITALITY, -1);
1111 chg_virtue(V_JUSTICE, -1);
1112 chg_virtue(V_FAITH, -1);
1113 chg_virtue(V_HONOUR, -1);
1114 chg_virtue(V_TEMPERANCE, -1);
1117 chg_virtue(V_FAITH, 1);
1118 chg_virtue(V_JUSTICE, 1);
1119 chg_virtue(V_SACRIFICE, 1);
1120 chg_virtue(V_HONOUR, 1);
1123 chg_virtue(V_NATURE, 1);
1124 chg_virtue(V_HARMONY, 1);
1127 chg_virtue(V_JUSTICE, -1);
1128 chg_virtue(V_FAITH, -1);
1129 chg_virtue(V_HONOUR, -1);
1130 chg_virtue(V_COMPASSION, -1);
1133 chg_virtue(V_KNOWLEDGE, 1);
1140 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, 1);
1141 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, 1);
1142 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, 1);
1143 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_DILIGENCE, 1);
1146 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_UNLIFE, 1);
1147 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1148 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1149 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, -1);
1152 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1153 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1154 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1155 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, -1);
1158 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, 1);
1159 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, 1);
1160 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_SACRIFICE, 1);
1161 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, 1);
1164 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_NATURE, 1);
1165 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HARMONY, 1);
1168 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1169 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1170 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1171 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, -1);
1174 if (mp_ptr->spell_xtra & MAGIC_GAIN_EXP)
1176 s16b cur_exp = p_ptr->spell_exp[(increment ? 32 : 0)+spell];
1179 if (cur_exp < SPELL_EXP_BEGINNER)
1181 else if (cur_exp < SPELL_EXP_SKILLED)
1183 if ((dun_level > 4) && ((dun_level + 10) > p_ptr->lev))
1186 else if (cur_exp < SPELL_EXP_EXPERT)
1188 if (((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel))
1191 else if ((cur_exp < SPELL_EXP_MASTER) && !increment)
1193 if (((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel))
1196 p_ptr->spell_exp[(increment ? 32 : 0) + spell] += exp_gain;
1200 p_ptr->energy_use = 100;
1203 /* Over-exert the player */
1206 int oops = need_mana;
1210 p_ptr->csp_frac = 0;
1212 msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
1214 /* Hack -- Bypass free action */
1215 (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
1220 chg_virtue(V_VITALITY, -10);
1223 chg_virtue(V_UNLIFE, -10);
1226 chg_virtue(V_JUSTICE, 10);
1229 chg_virtue(V_NATURE, -10);
1232 chg_virtue(V_JUSTICE, -10);
1235 chg_virtue(V_COMPASSION, 10);
1238 chg_virtue(V_KNOWLEDGE, -10);
1242 /* Damage CON (possibly permanently) */
1243 if (randint0(100) < 50)
1245 bool perm = (randint0(100) < 25);
1247 msg_print(_("体を悪くしてしまった!", "You have damaged your health!"));
1249 /* Reduce constitution */
1250 (void)dec_stat(A_CON, 15 + randint1(10), perm);
1254 p_ptr->window |= (PW_PLAYER);
1255 p_ptr->window |= (PW_SPELL);