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)
26 case TV_HISSATSU_BOOK:
35 case TV_HISSATSU_BOOK:
48 bool select_the_force = FALSE;
51 * @brief 領域魔法の閲覧、学習、使用選択するインターフェイス処理
52 * Allow user to choose a spell/prayer from the given book.
53 * @param sn 選択した魔法IDを返す参照ポインタ
54 * @param prompt 魔法を利用する際の動詞表記
55 * @param sval 魔道書のsval
56 * @param learned 閲覧/使用選択ならばTRUE、学習処理ならFALSE
57 * @param use_realm 魔法領域ID
60 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
61 * If the user hits escape, returns FALSE, and set '*sn' to -1
62 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
63 * The "prompt" should be "cast", "recite", or "study"
64 * The "known" should be TRUE for cast/pray, FALSE for study
67 static int get_spell(int *sn, cptr prompt, OBJECT_SUBTYPE_VALUE sval, bool learned, int use_realm)
75 bool flag, redraw, okay;
77 const magic_type *s_ptr;
83 int menu_line = (use_menu ? 1 : 0);
85 #ifdef ALLOW_REPEAT /* TNB */
87 /* Get the spell, if available */
90 /* Verify the spell */
91 if (spell_okay(*sn, learned, FALSE, use_realm))
98 #endif /* ALLOW_REPEAT -- TNB */
100 p = spell_category_name(mp_ptr->spell_book);
103 for (spell = 0; spell < 32; spell++)
105 /* Check for this spell */
106 if ((fake_spell_flags[sval] & (1L << spell)))
108 /* Collect this spell */
109 spells[num++] = spell;
113 /* Assume no usable spells */
116 /* Assume no spells available */
119 /* Check for "okay" spells */
120 for (i = 0; i < num; i++)
122 /* Look for "okay" spells */
123 if (spell_okay(spells[i], learned, FALSE, use_realm)) okay = TRUE;
126 /* No "okay" spells */
127 if (!okay) return (FALSE);
128 if (((use_realm) != p_ptr->realm1) && ((use_realm) != p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return FALSE;
129 if (((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) && !is_magic(use_realm)) return FALSE;
130 if ((p_ptr->pclass == CLASS_RED_MAGE) && ((use_realm) != REALM_ARCANE) && (sval > 1)) return FALSE;
132 /* Assume cancelled */
135 /* Nothing chosen yet */
142 p_ptr->window |= (PW_SPELL);
147 /* Build a prompt (accept all spells) */
149 jverb( prompt, jverb_buf, JVERB_AND );
150 (void) strnfmt(out_val, 78, "(%^s:%c-%c, '*'で一覧, ESCで中断) どの%sを%^sますか? ",
151 p, I2A(0), I2A(num - 1), p, jverb_buf );
153 (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) %^s which %s? ",
154 p, I2A(0), I2A(num - 1), prompt, p);
157 /* Get a spell from the user */
159 choice = (always_show_list || use_menu) ? ESCAPE : 1;
162 if (choice == ESCAPE) choice = ' ';
163 else if (!get_com(out_val, &choice, TRUE))break;
165 if (use_menu && choice != ' ')
179 menu_line += (num - 1);
201 if (menu_line > num) menu_line -= num;
202 /* Display a list of spells */
203 print_spells(menu_line, spells, num, 1, 15, use_realm);
209 if ((choice == ' ') || (choice == '*') || (choice == '?'))
217 /* Save the screen */
220 /* Display a list of spells */
221 print_spells(menu_line, spells, num, 1, 15, use_realm);
227 if (use_menu) continue;
232 /* Restore the screen */
242 ask = (isupper(choice));
245 if (ask) choice = (char)tolower(choice);
247 /* Extract request */
248 i = (islower(choice) ? A2I(choice) : -1);
251 /* Totally Illegal */
252 if ((i < 0) || (i >= num))
258 /* Save the spell index */
261 /* Require "okay" spells */
262 if (!spell_okay(spell, learned, FALSE, use_realm))
266 msg_format("その%sを%sことはできません。", p, prompt);
268 msg_format("You may not %s that %s.", prompt, p);
279 /* Access the spell */
280 if (!is_magic(use_realm))
282 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
286 s_ptr = &mp_ptr->info[use_realm - 1][spell];
289 /* Extract mana consumption rate */
290 if (use_realm == REALM_HISSATSU)
292 need_mana = s_ptr->smana;
296 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
301 jverb( prompt, jverb_buf, JVERB_AND );
303 (void) strnfmt(tmp_val, 78, "%s(MP%d, 失敗率%d%%)を%sますか? ",
304 do_spell(use_realm, spell, SPELL_NAME), need_mana,
305 spell_chance(spell, use_realm),jverb_buf);
307 (void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ",
308 prompt, do_spell(use_realm, spell, SPELL_NAME), need_mana,
309 spell_chance(spell, use_realm));
313 /* Belay that order */
314 if (!get_check(tmp_val)) continue;
322 /* Restore the screen */
323 if (redraw) screen_load();
327 p_ptr->window |= (PW_SPELL);
333 /* Abort if needed */
334 if (!flag) return FALSE;
336 /* Save the choice */
339 #ifdef ALLOW_REPEAT /* TNB */
343 #endif /* ALLOW_REPEAT -- TNB */
350 * @brief オブジェクトがプレイヤーが使用可能な魔道書かどうかを判定する
351 * @param o_ptr 判定したいオブ会ジェクトの構造体参照ポインタ
352 * @return 学習できる魔道書ならばTRUEを返す
354 static bool item_tester_learn_spell(object_type *o_ptr)
356 s32b choices = realm_choices2[p_ptr->pclass];
358 if (p_ptr->pclass == CLASS_PRIEST)
360 if (is_good_realm(p_ptr->realm1))
362 choices &= ~(CH_DEATH | CH_DAEMON);
366 choices &= ~(CH_LIFE | CH_CRUSADE);
370 if ((o_ptr->tval < TV_LIFE_BOOK) || (o_ptr->tval > (TV_LIFE_BOOK + MAX_REALM - 1))) return (FALSE);
371 if ((o_ptr->tval == TV_MUSIC_BOOK) && (p_ptr->pclass == CLASS_BARD)) return (TRUE);
372 else if (!is_magic(tval2realm(o_ptr->tval))) return FALSE;
373 if ((REALM1_BOOK == o_ptr->tval) || (REALM2_BOOK == o_ptr->tval)) return (TRUE);
374 if (choices & (0x0001 << (tval2realm(o_ptr->tval) - 1))) return (TRUE);
379 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
380 * @return 魔道書を一冊も持っていないならTRUEを返す
382 static bool player_has_no_spellbooks(void)
387 for (i = 0; i < INVEN_PACK; i++)
389 o_ptr = &inventory[i];
390 if (o_ptr->k_idx && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
393 for (i = cave[p_ptr->y][p_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
396 if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
403 * @brief プレイヤーの職業が練気術師の時、領域魔法と練気術を切り換える処理のインターフェイス
404 * @param browse_only 魔法と技能の閲覧を行うならばTRUE
405 * @return 魔道書を一冊も持っていないならTRUEを返す
407 static void confirm_use_force(bool browse_only)
414 /* Get the item index */
415 if (repeat_pull(&item) && (item == INVEN_FORCE))
417 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
421 #endif /* ALLOW_REPEAT */
423 /* Show the prompt */
424 prt(_("('w'練気術, ESC) 'w'かESCを押してください。 ", "(w for the Force, ESC) Hit 'w' or ESC. "), 0, 0);
431 if (which == ESCAPE) break;
432 else if (which == 'w')
437 repeat_push(INVEN_FORCE);
439 #endif /* ALLOW_REPEAT */
445 /* Clear the prompt line */
450 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
456 * @brief プレイヤーの魔法と技能を閲覧するコマンドのメインルーチン /
457 * Peruse the spells/prayers in a book
461 * Note that *all* spells in the book are listed
463 * Note that browsing is allowed while confused or blind,
464 * and in the dark, primarily to allow browsing in stores.
467 void do_cmd_browse(void)
469 int item, sval, use_realm = 0, j, line;
480 /* Warriors are illiterate */
481 if (!(p_ptr->realm1 || p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
483 msg_print(_("本を読むことができない!", "You cannot read books!"));
487 if (p_ptr->special_defense & KATA_MUSOU)
489 set_action(ACTION_NONE);
492 if (p_ptr->pclass == CLASS_FORCETRAINER)
494 if (player_has_no_spellbooks())
496 confirm_use_force(TRUE);
499 select_the_force = TRUE;
502 /* Restrict choices to "useful" books */
503 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
504 else item_tester_hook = item_tester_learn_spell;
507 q = _("どの本を読みますか? ", "Browse which book? ");
508 s = _("読める本がない。", "You have no books that you can read.");
510 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
512 select_the_force = FALSE;
515 select_the_force = FALSE;
517 if (item == INVEN_FORCE) /* the_force */
519 do_cmd_mind_browse();
523 /* Get the item (in the pack) */
526 o_ptr = &inventory[item];
529 /* Get the item (on the floor) */
532 o_ptr = &o_list[0 - item];
535 /* Access the item's sval */
538 use_realm = tval2realm(o_ptr->tval);
540 /* Track the object kind */
541 object_kind_track(o_ptr->k_idx);
543 /* Hack -- Handle stuff */
548 for (spell = 0; spell < 32; spell++)
550 /* Check for this spell */
551 if ((fake_spell_flags[sval] & (1L << spell)))
553 /* Collect this spell */
554 spells[num++] = spell;
559 /* Save the screen */
562 /* Clear the top line */
565 /* Keep browsing spells. Exit browsing on cancel. */
568 /* Ask for a spell, allow cancel */
569 if (!get_spell(&spell, _("読む", "browse"), o_ptr->sval, TRUE, use_realm))
571 /* If cancelled, leave immediately. */
572 if (spell == -1) break;
574 /* Display a list of spells */
575 print_spells(0, spells, num, 1, 15, use_realm);
577 /* Notify that there's nothing to see, and wait. */
578 if (use_realm == REALM_HISSATSU)
579 prt(_("読める技がない。", "No techniques to browse."), 0, 0);
581 prt(_("読める呪文がない。", "No spells to browse."), 0, 0);
585 /* Restore the screen */
591 /* Clear lines, position cursor (really should use strlen here) */
592 Term_erase(14, 14, 255);
593 Term_erase(14, 13, 255);
594 Term_erase(14, 12, 255);
595 Term_erase(14, 11, 255);
597 roff_to_buf(do_spell(use_realm, spell, SPELL_DESC), 62, temp, sizeof(temp));
599 for (j = 0, line = 11; temp[j]; j += 1 + strlen(&temp[j]))
601 prt(&temp[j], line, 15);
606 /* Restore the screen */
611 * @brief プレイヤーの第二魔法領域を変更する /
612 * @param next_realm 変更先の魔法領域ID
615 static void change_realm2(CHARACTER_IDX next_realm)
620 for (i = 0; i < 64; i++)
622 p_ptr->spell_order[j] = p_ptr->spell_order[i];
623 if (p_ptr->spell_order[i] < 32) j++;
626 p_ptr->spell_order[j] = 99;
628 for (i = 32; i < 64; i++)
630 p_ptr->spell_exp[i] = SPELL_EXP_UNSKILLED;
632 p_ptr->spell_learned2 = 0L;
633 p_ptr->spell_worked2 = 0L;
634 p_ptr->spell_forgotten2 = 0L;
636 sprintf(tmp,_("魔法の領域を%sから%sに変更した。", "change magic realm from %s to %s."), realm_names[p_ptr->realm2], realm_names[next_realm]);
637 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
638 p_ptr->old_realm |= 1 << (p_ptr->realm2-1);
639 p_ptr->realm2 = next_realm;
641 p_ptr->notice |= (PN_REORDER);
642 p_ptr->update |= (PU_SPELLS);
645 /* Load an autopick preference file */
646 autopick_load_pref(FALSE);
651 * @brief 魔法を学習するコマンドのメインルーチン /
652 * Study a book to gain a new spell/prayer
655 void do_cmd_study(void)
659 bool learned = FALSE;
661 /* Spells of realm2 will have an increment of +32 */
664 cptr p = spell_category_name(mp_ptr->spell_book);
672 msg_print(_("本を読むことができない!", "You cannot read books!"));
676 if (p_ptr->blind || no_lite())
678 msg_print(_("目が見えない!", "You cannot see!"));
684 msg_print(_("混乱していて読めない!", "You are too confused!"));
688 if (!(p_ptr->new_spells))
690 msg_format(_("新しい%sを覚えることはできない!", "You cannot learn any new %ss!"), p);
694 if (p_ptr->special_defense & KATA_MUSOU)
696 set_action(ACTION_NONE);
700 if( p_ptr->new_spells < 10 ){
701 msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
703 msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
706 msg_format("You can learn %d new %s%s.", p_ptr->new_spells, p,
707 (p_ptr->new_spells == 1?"":"s"));
713 /* Restrict choices to "useful" books */
714 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
715 else item_tester_hook = item_tester_learn_spell;
718 q = _("どの本から学びますか? ", "Study which book? ");
719 s = _("読める本がない。", "You have no books that you can read.");
721 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
723 /* Get the item (in the pack) */
726 o_ptr = &inventory[item];
729 /* Get the item (on the floor) */
732 o_ptr = &o_list[0 - item];
735 /* Access the item's sval */
738 if (o_ptr->tval == REALM2_BOOK) increment = 32;
739 else if (o_ptr->tval != REALM1_BOOK)
741 if (!get_check(_("本当に魔法の領域を変更しますか?", "Really, change magic realm? "))) return;
742 change_realm2(tval2realm(o_ptr->tval));
746 /* Track the object kind */
747 object_kind_track(o_ptr->k_idx);
749 /* Hack -- Handle stuff */
752 /* Mage -- Learn a selected spell */
753 if (mp_ptr->spell_book != TV_LIFE_BOOK)
755 /* Ask for a spell, allow cancel */
757 if (!get_spell(&spell, "学ぶ", sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1)
758 && (spell == -1)) return;
760 if (!get_spell(&spell, "study", sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1)
761 && (spell == -1)) return;
766 /* Priest -- Learn a random prayer */
774 for (spell = 0; spell < 32; spell++)
776 /* Check spells in the book */
777 if ((fake_spell_flags[sval] & (1L << spell)))
779 /* Skip non "okay" prayers */
780 if (!spell_okay(spell, FALSE, TRUE,
781 (increment ? p_ptr->realm2 : p_ptr->realm1))) continue;
783 /* Hack -- Prepare the randomizer */
786 /* Hack -- Apply the randomizer */
787 if (one_in_(k)) gift = spell;
795 /* Nothing to study */
799 msg_format(_("その本には学ぶべき%sがない。", "You cannot learn any %ss in that book."), p);
806 if (increment) spell += increment;
808 /* Learn the spell */
811 if (p_ptr->spell_learned1 & (1L << spell)) learned = TRUE;
812 else p_ptr->spell_learned1 |= (1L << spell);
816 if (p_ptr->spell_learned2 & (1L << (spell - 32))) learned = TRUE;
817 else p_ptr->spell_learned2 |= (1L << (spell - 32));
822 int max_exp = (spell < 32) ? SPELL_EXP_MASTER : SPELL_EXP_EXPERT;
823 int old_exp = p_ptr->spell_exp[spell];
824 int new_rank = EXP_LEVEL_UNSKILLED;
825 cptr name = do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell%32, SPELL_NAME);
827 if (old_exp >= max_exp)
829 msg_format(_("その%sは完全に使いこなせるので学ぶ必要はない。", "You don't need to study this %s anymore."), p);
833 if (!get_check(format("%sの%sをさらに学びます。よろしいですか?", name, p)))
835 if (!get_check(format("You will study a %s of %s again. Are you sure? ", p, name)))
840 else if (old_exp >= SPELL_EXP_EXPERT)
842 p_ptr->spell_exp[spell] = SPELL_EXP_MASTER;
843 new_rank = EXP_LEVEL_MASTER;
845 else if (old_exp >= SPELL_EXP_SKILLED)
847 if (spell >= 32) p_ptr->spell_exp[spell] = SPELL_EXP_EXPERT;
848 else p_ptr->spell_exp[spell] += SPELL_EXP_EXPERT - SPELL_EXP_SKILLED;
849 new_rank = EXP_LEVEL_EXPERT;
851 else if (old_exp >= SPELL_EXP_BEGINNER)
853 p_ptr->spell_exp[spell] = SPELL_EXP_SKILLED + (old_exp - SPELL_EXP_BEGINNER) * 2 / 3;
854 new_rank = EXP_LEVEL_SKILLED;
858 p_ptr->spell_exp[spell] = SPELL_EXP_BEGINNER + old_exp / 3;
859 new_rank = EXP_LEVEL_BEGINNER;
861 msg_format(_("%sの熟練度が%sに上がった。", "Your proficiency of %s is now %s rank."), name, exp_level_str[new_rank]);
865 /* Find the next open entry in "p_ptr->spell_order[]" */
866 for (i = 0; i < 64; i++)
868 /* Stop at the first empty space */
869 if (p_ptr->spell_order[i] == 99) break;
872 /* Add the spell to the known list */
873 p_ptr->spell_order[i++] = spell;
875 /* Mention the result */
878 if (mp_ptr->spell_book == TV_MUSIC_BOOK)
880 msg_format("%sを学んだ。",
881 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
885 msg_format("%sの%sを学んだ。",
886 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME) ,p);
889 msg_format("You have learned the %s of %s.",
890 p, do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
895 p_ptr->energy_use = 100;
897 switch (mp_ptr->spell_book)
900 chg_virtue(V_FAITH, 1);
903 chg_virtue(V_UNLIFE, 1);
906 chg_virtue(V_NATURE, 1);
909 chg_virtue(V_KNOWLEDGE, 1);
916 /* One less spell available */
917 p_ptr->learned_spells++;
919 /* Message if needed */
920 if (p_ptr->new_spells)
924 if (p_ptr->new_spells < 10) msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
925 else msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
927 msg_format("You can learn %d more %s%s.", p_ptr->new_spells, p,
928 (p_ptr->new_spells != 1) ? "s" : "");
934 p_ptr->update |= (PU_SPELLS);
937 /* Redraw object recall */
938 p_ptr->window |= (PW_OBJECT);
942 * @brief 運命の輪、並びにカオス的な効果の発動
943 * @param spell ランダムな効果を選択するための基準ID
946 static void wild_magic(int spell)
949 int type = SUMMON_MOLD + randint0(6);
951 if (type < SUMMON_MOLD) type = SUMMON_MOLD;
952 else if (type > SUMMON_MIMIC) type = SUMMON_MIMIC;
954 switch (randint1(spell) + randint1(8) + 1)
959 teleport_player(10, TELEPORT_PASSIVE);
964 teleport_player(100, TELEPORT_PASSIVE);
968 teleport_player(200, TELEPORT_PASSIVE);
978 lite_area(damroll(2, 3), 2);
981 destroy_doors_touch();
986 sleep_monsters_touch();
990 trap_creation(p_ptr->y, p_ptr->x);
999 aggravate_monsters(0);
1002 earthquake(p_ptr->y, p_ptr->x, 5);
1006 (void)gain_random_mutation(0);
1010 apply_disenchant(1);
1016 fire_ball(GF_CHAOS, 0, spell + 5, 1 + (spell / 10));
1023 while (counter++ < 8)
1025 (void)summon_specific(0, p_ptr->y, p_ptr->x, (dun_level * 3) / 2, type, (PM_ALLOW_GROUP | PM_NO_PET));
1030 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
1033 (void)summon_cyber(-1, p_ptr->y, p_ptr->x);
1038 (void)activate_ty_curse(FALSE, &count);
1048 * @brief 魔法を詠唱するコマンドのメインルーチン /
1052 void do_cmd_cast(void)
1055 OBJECT_SUBTYPE_VALUE sval;
1066 const magic_type *s_ptr;
1070 bool over_exerted = FALSE;
1072 /* Require spell ability */
1073 if (!p_ptr->realm1 && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
1075 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
1080 if (p_ptr->blind || no_lite())
1082 if (p_ptr->pclass == CLASS_FORCETRAINER) confirm_use_force(FALSE);
1085 msg_print(_("目が見えない!", "You cannot see!"));
1091 /* Not when confused */
1092 if (p_ptr->confused)
1094 msg_print(_("混乱していて唱えられない!", "You are too confused!"));
1100 if (p_ptr->realm1 == REALM_HEX)
1102 if (hex_spell_fully())
1105 msg_print(_("これ以上新しい呪文を詠唱することはできない。", "Can not spell new spells more."));
1107 if (p_ptr->lev >= 35) flag = stop_hex_spell();
1112 if (p_ptr->pclass == CLASS_FORCETRAINER)
1114 if (player_has_no_spellbooks())
1116 confirm_use_force(FALSE);
1119 select_the_force = TRUE;
1122 prayer = spell_category_name(mp_ptr->spell_book);
1124 /* Restrict choices to spell books */
1125 item_tester_tval = mp_ptr->spell_book;
1128 q = _("どの呪文書を使いますか? ", "Use which book? ");
1129 s = _("呪文書がない!", "You have no spell books!");
1131 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
1133 select_the_force = FALSE;
1136 select_the_force = FALSE;
1138 if (item == INVEN_FORCE) /* the_force */
1144 /* Get the item (in the pack) */
1147 o_ptr = &inventory[item];
1150 /* Get the item (on the floor) */
1153 o_ptr = &o_list[0 - item];
1156 /* Access the item's sval */
1159 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && (o_ptr->tval == REALM2_BOOK)) increment = 32;
1162 /* Track the object kind */
1163 object_kind_track(o_ptr->k_idx);
1165 /* Hack -- Handle stuff */
1168 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
1169 realm = o_ptr->tval - TV_LIFE_BOOK + 1;
1170 else if (increment) realm = p_ptr->realm2;
1171 else realm = p_ptr->realm1;
1173 /* Ask for a spell */
1175 if (!get_spell(&spell,
1176 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_MUSIC_BOOK) ? "歌う" : "唱える"),
1179 if (spell == -2) msg_format("その本には知っている%sがない。", prayer);
1183 if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1187 msg_format("You don't know any %ss in that book.", prayer);
1193 use_realm = tval2realm(o_ptr->tval);
1196 if (use_realm == REALM_HEX)
1198 if (hex_spelling(spell))
1200 msg_print(_("その呪文はすでに詠唱中だ。", "You are already casting it."));
1205 if (!is_magic(use_realm))
1207 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
1211 s_ptr = &mp_ptr->info[realm - 1][spell];
1214 /* Extract mana consumption rate */
1215 need_mana = mod_need_mana(s_ptr->smana, spell, realm);
1217 /* Verify "dangerous" spells */
1218 if (need_mana > p_ptr->csp)
1220 if (flush_failure) flush();
1224 msg_format("その%sを%sのに十分なマジックポイントがない。",prayer,
1225 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_LIFE_BOOK) ? "歌う" : "唱える"));
1227 msg_format("You do not have enough mana to %s this %s.",
1228 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1233 if (!over_exert) return;
1236 if (!get_check_strict(_("それでも挑戦しますか? ", "Attempt it anyway? "), CHECK_OKAY_CANCEL)) return;
1239 /* Spell failure chance */
1240 chance = spell_chance(spell, use_realm);
1242 /* Sufficient mana */
1243 if (need_mana <= p_ptr->csp)
1246 p_ptr->csp -= need_mana;
1248 else over_exerted = TRUE;
1251 p_ptr->redraw |= (PR_MANA);
1254 if (randint0(100) < chance)
1256 if (flush_failure) flush();
1258 msg_format(_("%sをうまく唱えられなかった!", "You failed to get the %s off!"), prayer);
1264 if (randint1(100) < chance) chg_virtue(V_VITALITY, -1);
1267 if (randint1(100) < chance) chg_virtue(V_UNLIFE, -1);
1270 if (randint1(100) < chance) chg_virtue(V_NATURE, -1);
1273 if (randint1(100) < chance) chg_virtue(V_JUSTICE, 1);
1276 if (randint1(100) < chance) chg_virtue(V_JUSTICE, -1);
1279 if (randint1(100) < chance) chg_virtue(V_COMPASSION, -1);
1282 if (randint1(100) < chance) chg_virtue(V_KNOWLEDGE, -1);
1286 /* Failure casting may activate some side effect */
1287 do_spell(realm, spell, SPELL_FAIL);
1290 if ((o_ptr->tval == TV_CHAOS_BOOK) && (randint1(100) < spell))
1292 msg_print(_("カオス的な効果を発生した!", "You produce a chaotic effect!"));
1295 else if ((o_ptr->tval == TV_DEATH_BOOK) && (randint1(100) < spell))
1297 if ((sval == 3) && one_in_(2))
1299 sanity_blast(0, TRUE);
1303 msg_print(_("痛い!", "It hurts!"));
1304 take_hit(DAMAGE_LOSELIFE, damroll(o_ptr->sval + 1, 6), _("暗黒魔法の逆流", "a miscast Death spell"), -1);
1306 if ((spell > 15) && one_in_(6) && !p_ptr->hold_exp)
1307 lose_exp(spell * 250);
1310 else if ((o_ptr->tval == TV_MUSIC_BOOK) && (randint1(200) < spell))
1312 msg_print(_("いやな音が響いた", "An infernal sound echoed."));
1313 aggravate_monsters(0);
1315 if (randint1(100) >= chance)
1316 chg_virtue(V_CHANCE,-1);
1322 /* Canceled spells cost neither a turn nor mana */
1323 if (!do_spell(realm, spell, SPELL_CAST)) return;
1325 if (randint1(100) < chance)
1326 chg_virtue(V_CHANCE,1);
1328 /* A spell was cast */
1330 (p_ptr->spell_worked2 & (1L << spell)) :
1331 (p_ptr->spell_worked1 & (1L << spell)))
1332 && (p_ptr->pclass != CLASS_SORCERER)
1333 && (p_ptr->pclass != CLASS_RED_MAGE))
1335 int e = s_ptr->sexp;
1337 /* The spell worked */
1338 if (realm == p_ptr->realm1)
1340 p_ptr->spell_worked1 |= (1L << spell);
1344 p_ptr->spell_worked2 |= (1L << spell);
1347 /* Gain experience */
1348 gain_exp(e * s_ptr->slevel);
1350 /* Redraw object recall */
1351 p_ptr->window |= (PW_OBJECT);
1356 chg_virtue(V_TEMPERANCE, 1);
1357 chg_virtue(V_COMPASSION, 1);
1358 chg_virtue(V_VITALITY, 1);
1359 chg_virtue(V_DILIGENCE, 1);
1362 chg_virtue(V_UNLIFE, 1);
1363 chg_virtue(V_JUSTICE, -1);
1364 chg_virtue(V_FAITH, -1);
1365 chg_virtue(V_VITALITY, -1);
1368 chg_virtue(V_JUSTICE, -1);
1369 chg_virtue(V_FAITH, -1);
1370 chg_virtue(V_HONOUR, -1);
1371 chg_virtue(V_TEMPERANCE, -1);
1374 chg_virtue(V_FAITH, 1);
1375 chg_virtue(V_JUSTICE, 1);
1376 chg_virtue(V_SACRIFICE, 1);
1377 chg_virtue(V_HONOUR, 1);
1380 chg_virtue(V_NATURE, 1);
1381 chg_virtue(V_HARMONY, 1);
1384 chg_virtue(V_JUSTICE, -1);
1385 chg_virtue(V_FAITH, -1);
1386 chg_virtue(V_HONOUR, -1);
1387 chg_virtue(V_COMPASSION, -1);
1390 chg_virtue(V_KNOWLEDGE, 1);
1397 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, 1);
1398 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, 1);
1399 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, 1);
1400 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_DILIGENCE, 1);
1403 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_UNLIFE, 1);
1404 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1405 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1406 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, -1);
1409 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1410 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1411 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1412 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, -1);
1415 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, 1);
1416 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, 1);
1417 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_SACRIFICE, 1);
1418 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, 1);
1421 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_NATURE, 1);
1422 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HARMONY, 1);
1425 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1426 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1427 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1428 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, -1);
1431 if (mp_ptr->spell_xtra & MAGIC_GAIN_EXP)
1433 s16b cur_exp = p_ptr->spell_exp[(increment ? 32 : 0)+spell];
1436 if (cur_exp < SPELL_EXP_BEGINNER)
1438 else if (cur_exp < SPELL_EXP_SKILLED)
1440 if ((dun_level > 4) && ((dun_level + 10) > p_ptr->lev))
1443 else if (cur_exp < SPELL_EXP_EXPERT)
1445 if (((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel))
1448 else if ((cur_exp < SPELL_EXP_MASTER) && !increment)
1450 if (((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel))
1453 p_ptr->spell_exp[(increment ? 32 : 0) + spell] += exp_gain;
1458 p_ptr->energy_use = 100;
1461 /* Over-exert the player */
1464 int oops = need_mana;
1468 p_ptr->csp_frac = 0;
1471 msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
1473 /* Hack -- Bypass free action */
1474 (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
1479 chg_virtue(V_VITALITY, -10);
1482 chg_virtue(V_UNLIFE, -10);
1485 chg_virtue(V_JUSTICE, 10);
1488 chg_virtue(V_NATURE, -10);
1491 chg_virtue(V_JUSTICE, -10);
1494 chg_virtue(V_COMPASSION, 10);
1497 chg_virtue(V_KNOWLEDGE, -10);
1501 /* Damage CON (possibly permanently) */
1502 if (randint0(100) < 50)
1504 bool perm = (randint0(100) < 25);
1507 msg_print(_("体を悪くしてしまった!", "You have damaged your health!"));
1509 /* Reduce constitution */
1510 (void)dec_stat(A_CON, 15 + randint1(10), perm);
1515 p_ptr->window |= (PW_PLAYER);
1516 p_ptr->window |= (PW_SPELL);
1520 * @brief ペットになっているモンスターをソートするための比較処理
1521 * @param u モンスターの構造体配列
1523 * @param a 比較対象のモンスターID1
1524 * @param b 比較対象のモンスターID2
1525 * @return 2番目が大ならばTRUEを返す
1527 static bool ang_sort_comp_pet_dismiss(vptr u, vptr v, int a, int b)
1529 u16b *who = (u16b*)(u);
1534 monster_type *m_ptr1 = &m_list[w1];
1535 monster_type *m_ptr2 = &m_list[w2];
1536 monster_race *r_ptr1 = &r_info[m_ptr1->r_idx];
1537 monster_race *r_ptr2 = &r_info[m_ptr2->r_idx];
1542 if (w1 == p_ptr->riding) return TRUE;
1543 if (w2 == p_ptr->riding) return FALSE;
1545 if (m_ptr1->nickname && !m_ptr2->nickname) return TRUE;
1546 if (m_ptr2->nickname && !m_ptr1->nickname) return FALSE;
1548 if (!m_ptr1->parent_m_idx && m_ptr2->parent_m_idx) return TRUE;
1549 if (!m_ptr2->parent_m_idx && m_ptr1->parent_m_idx) return FALSE;
1551 if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return TRUE;
1552 if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return FALSE;
1554 if (r_ptr1->level > r_ptr2->level) return TRUE;
1555 if (r_ptr2->level > r_ptr1->level) return FALSE;
1557 if (m_ptr1->hp > m_ptr2->hp) return TRUE;
1558 if (m_ptr2->hp > m_ptr1->hp) return FALSE;
1564 * @brief ペットの善悪属性に応じた維持コストの途中計算処理
1565 * @param m_ptr 計算基準となるモンスターの構造体参照ポインタ
1566 * @param inc m_ptrで指定したモンスターを維持コスト計算に加えるならTRUE、外すならFALSEを指定
1569 void check_pets_num_and_align(monster_type *m_ptr, bool inc)
1571 s32b old_friend_align = friend_align;
1572 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1577 if (r_ptr->flags3 & RF3_GOOD) friend_align += r_ptr->level;
1578 if (r_ptr->flags3 & RF3_EVIL) friend_align -= r_ptr->level;
1583 if (r_ptr->flags3 & RF3_GOOD) friend_align -= r_ptr->level;
1584 if (r_ptr->flags3 & RF3_EVIL) friend_align += r_ptr->level;
1587 if (old_friend_align != friend_align) p_ptr->update |= (PU_BONUS);
1591 * @brief ペットの維持コスト計算
1594 int calculate_upkeep(void)
1596 s32b old_friend_align = friend_align;
1598 bool have_a_unique = FALSE;
1599 s32b total_friend_levels = 0;
1604 for (m_idx = m_max - 1; m_idx >=1; m_idx--)
1606 monster_type *m_ptr;
1607 monster_race *r_ptr;
1609 m_ptr = &m_list[m_idx];
1610 if (!m_ptr->r_idx) continue;
1611 r_ptr = &r_info[m_ptr->r_idx];
1616 if (r_ptr->flags1 & RF1_UNIQUE)
1618 if (p_ptr->pclass == CLASS_CAVALRY)
1620 if (p_ptr->riding == m_idx)
1621 total_friend_levels += (r_ptr->level+5)*2;
1622 else if (!have_a_unique && (r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
1623 total_friend_levels += (r_ptr->level+5)*7/2;
1625 total_friend_levels += (r_ptr->level+5)*10;
1626 have_a_unique = TRUE;
1629 total_friend_levels += (r_ptr->level+5)*10;
1632 total_friend_levels += r_ptr->level;
1634 /* Determine pet alignment */
1635 if (r_ptr->flags3 & RF3_GOOD) friend_align += r_ptr->level;
1636 if (r_ptr->flags3 & RF3_EVIL) friend_align -= r_ptr->level;
1639 if (old_friend_align != friend_align) p_ptr->update |= (PU_BONUS);
1643 upkeep_factor = (total_friend_levels - (p_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
1644 if (upkeep_factor < 0) upkeep_factor = 0;
1645 if (upkeep_factor > 1000) upkeep_factor = 1000;
1646 return upkeep_factor;
1653 * @brief ペットを開放するコマンドのメインルーチン
1656 void do_cmd_pet_dismiss(void)
1658 monster_type *m_ptr;
1659 bool all_pets = FALSE;
1674 /* Allocate the "who" array */
1675 C_MAKE(who, max_m_idx, u16b);
1677 /* Process the monsters (backwards) */
1678 for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
1680 if (is_pet(&m_list[pet_ctr]))
1681 who[max_pet++] = pet_ctr;
1684 /* Select the sort method */
1685 ang_sort_comp = ang_sort_comp_pet_dismiss;
1686 ang_sort_swap = ang_sort_swap_hook;
1688 ang_sort(who, &dummy_why, max_pet);
1690 /* Process the monsters (backwards) */
1691 for (i = 0; i < max_pet; i++)
1694 char friend_name[80];
1697 /* Access the monster */
1699 m_ptr = &m_list[pet_ctr];
1701 delete_this = FALSE;
1702 kakunin = ((pet_ctr == p_ptr->riding) || (m_ptr->nickname));
1703 monster_desc(friend_name, m_ptr, MD_ASSUME_VISIBLE);
1707 /* Hack -- health bar for this monster */
1708 health_track(pet_ctr);
1710 /* Hack -- handle stuff */
1713 msg_format(_("%sを放しますか? [Yes/No/Unnamed (%d体)]","Dismiss %s? [Yes/No/Unnamed (%d remain)]"), friend_name, max_pet - i);
1716 move_cursor_relative(m_ptr->fy, m_ptr->fx);
1722 if (ch == 'Y' || ch == 'y')
1728 msg_format(_("本当によろしいですか? (%s) ","Are you sure? (%s) "), friend_name);
1730 if (ch != 'Y' && ch != 'y')
1731 delete_this = FALSE;
1736 if (ch == 'U' || ch == 'u')
1742 if (ch == ESCAPE || ch == 'N' || ch == 'n')
1749 if ((all_pets && !kakunin) || (!all_pets && delete_this))
1751 if (record_named_pet && m_ptr->nickname)
1755 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1756 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_DISMISS, m_name);
1759 if (pet_ctr == p_ptr->riding)
1761 msg_format(_("%sから降りた。","You have got off %s. "), friend_name);
1765 /* Update the monsters */
1766 p_ptr->update |= (PU_BONUS | PU_MONSTERS);
1767 p_ptr->redraw |= (PR_EXTRA | PR_UHEALTH);
1770 /* HACK : Add the line to message buffer */
1771 msg_format(_("%s を放した。","Dismissed %s."), friend_name);
1772 p_ptr->window |= (PW_MESSAGE);
1775 delete_monster_idx(pet_ctr);
1784 C_KILL(who, max_m_idx, u16b);
1787 msg_format("%d 体のペットを放しました。", Dismissed);
1789 msg_format("You have dismissed %d pet%s.", Dismissed,
1790 (Dismissed == 1 ? "" : "s"));
1792 if (Dismissed == 0 && all_pets)
1793 msg_print(_("'U'nnamed は、乗馬以外の名前のないペットだけを全て解放します。", "'U'nnamed means all your pets except named pets and your mount."));
1797 * @brief プレイヤーの騎乗/下馬処理判定
1798 * @param c_ptr プレイヤーの移動先マスの構造体参照ポインタ
1799 * @param now_riding TRUEなら下馬処理、FALSEならば騎乗処理
1800 * @return 可能ならばTRUEを返す
1802 static bool player_can_ride_aux(cave_type *c_ptr, bool now_riding)
1805 bool old_character_xtra = character_xtra;
1806 int old_riding = p_ptr->riding;
1807 bool old_riding_ryoute = p_ptr->riding_ryoute;
1808 bool old_old_riding_ryoute = p_ptr->old_riding_ryoute;
1809 bool old_pf_ryoute = (p_ptr->pet_extra_flags & PF_RYOUTE) ? TRUE : FALSE;
1811 /* Hack -- prevent "icky" message */
1812 character_xtra = TRUE;
1814 if (now_riding) p_ptr->riding = c_ptr->m_idx;
1818 p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
1819 p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
1824 p_can_enter = player_can_enter(c_ptr->feat, CEM_P_CAN_ENTER_PATTERN);
1826 p_ptr->riding = old_riding;
1827 if (old_pf_ryoute) p_ptr->pet_extra_flags |= (PF_RYOUTE);
1828 else p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
1829 p_ptr->riding_ryoute = old_riding_ryoute;
1830 p_ptr->old_riding_ryoute = old_old_riding_ryoute;
1834 character_xtra = old_character_xtra;
1840 * @brief プレイヤーの落馬判定処理
1841 * @param dam 落馬判定を発した際に受けたダメージ量
1842 * @param force TRUEならば強制的に落馬する
1843 * @return 実際に落馬したらTRUEを返す
1845 bool rakuba(int dam, bool force)
1847 int i, y, x, oy, ox;
1848 int sn = 0, sy = 0, sx = 0;
1850 monster_type *m_ptr = &m_list[p_ptr->riding];
1851 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1852 bool fall_dam = FALSE;
1854 if (!p_ptr->riding) return FALSE;
1855 if (p_ptr->wild_mode) return FALSE;
1857 if (dam >= 0 || force)
1861 int cur = p_ptr->skill_exp[GINOU_RIDING];
1862 int max = s_info[p_ptr->pclass].s_max[GINOU_RIDING];
1863 int ridinglevel = r_ptr->level;
1866 int rakubalevel = r_ptr->level;
1867 if (p_ptr->riding_ryoute) rakubalevel += 20;
1869 if ((cur < max) && (max > 1000) &&
1870 (dam / 2 + ridinglevel) > (cur / 30 + 10))
1874 if (ridinglevel > (cur / 100 + 15))
1875 inc += 1 + (ridinglevel - cur / 100 - 15);
1879 p_ptr->skill_exp[GINOU_RIDING] = MIN(max, cur + inc);
1882 /* レベルの低い乗馬からは落馬しにくい */
1883 if (randint0(dam / 2 + rakubalevel * 2) < cur / 30 + 10)
1885 if ((((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY)) && !p_ptr->riding_ryoute) || !one_in_(p_ptr->lev*(p_ptr->riding_ryoute ? 2 : 3) + 30))
1892 /* Check around the player */
1893 for (i = 0; i < 8; i++)
1897 /* Access the location */
1898 y = p_ptr->y + ddy_ddd[i];
1899 x = p_ptr->x + ddx_ddd[i];
1901 c_ptr = &cave[y][x];
1903 if (c_ptr->m_idx) continue;
1905 /* Skip non-empty grids */
1906 if (!cave_have_flag_grid(c_ptr, FF_MOVE) && !cave_have_flag_grid(c_ptr, FF_CAN_FLY))
1908 if (!player_can_ride_aux(c_ptr, FALSE)) continue;
1911 if (cave_have_flag_grid(c_ptr, FF_PATTERN)) continue;
1913 /* Count "safe" grids */
1916 /* Randomize choice */
1917 if (randint0(sn) > 0) continue;
1919 /* Save the safe location */
1924 monster_desc(m_name, m_ptr, 0);
1926 msg_format("%sから振り落とされそうになって、壁にぶつかった。",m_name);
1927 take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, "壁への衝突", -1);
1929 msg_format("You have nearly fallen from %s, but bumped into wall.",m_name);
1930 take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, "bumping into wall", -1);
1941 /* Redraw the old spot */
1944 /* Redraw the new spot */
1945 lite_spot(p_ptr->y, p_ptr->x);
1947 /* Check for new panel */
1952 p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
1953 p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
1957 p_ptr->update |= (PU_BONUS);
1960 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1963 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1965 p_ptr->redraw |= (PR_EXTRA);
1967 /* Update health track of mount */
1968 p_ptr->redraw |= (PR_UHEALTH);
1970 if (p_ptr->levitation && !force)
1972 monster_desc(m_name, m_ptr, 0);
1973 msg_format(_("%sから落ちたが、空中でうまく体勢を立て直して着地した。", "You are thrown from %s, but make a good landing."),m_name);
1977 take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, _("落馬", "Falling from riding"), -1);
1981 /* Move the player */
1982 if (sy && !p_ptr->is_dead)
1983 (void)move_player_effect(p_ptr->y, p_ptr->x, MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
1989 * @brief ペットから騎乗/下馬するコマンドのメインルーチン /
1990 * @param force 強制的に騎乗/下馬するならばTRUE
1991 * @return 騎乗/下馬できたらTRUE
1993 bool do_riding(bool force)
1997 monster_type *m_ptr;
1999 if (!get_rep_dir2(&dir)) return FALSE;
2000 y = p_ptr->y + ddy[dir];
2001 x = p_ptr->x + ddx[dir];
2002 c_ptr = &cave[y][x];
2004 if (p_ptr->special_defense & KATA_MUSOU) set_action(ACTION_NONE);
2008 /* Skip non-empty grids */
2009 if (!player_can_ride_aux(c_ptr, FALSE))
2011 msg_print(_("そちらには降りられません。", "You cannot go to that direction."));
2015 if (!pattern_seq(p_ptr->y, p_ptr->x, y, x)) return FALSE;
2020 p_ptr->energy_use = 100;
2023 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2030 p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
2031 p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
2035 if (p_ptr->confused)
2037 msg_print(_("混乱していて乗れない!", "You are too confused!"));
2041 m_ptr = &m_list[c_ptr->m_idx];
2043 if (!c_ptr->m_idx || !m_ptr->ml)
2045 msg_print(_("その場所にはモンスターはいません。", "Here is no monster."));
2048 if (!is_pet(m_ptr) && !force)
2050 msg_print(_("そのモンスターはペットではありません。", "That monster is not a pet."));
2053 if (!(r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
2055 msg_print(_("そのモンスターには乗れなさそうだ。", "This monster doesn't seem suitable for riding."));
2059 if (!pattern_seq(p_ptr->y, p_ptr->x, y, x)) return FALSE;
2061 if (!player_can_ride_aux(c_ptr, TRUE))
2063 /* Feature code (applying "mimic" field) */
2064 feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
2066 msg_format("そのモンスターは%sの%sにいる。", f_name + f_ptr->name,
2067 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
2068 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE))) ?
2071 msg_format("This monster is %s the %s.",
2072 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
2073 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE))) ?
2074 "in" : "on", f_name + f_ptr->name);
2079 if (r_info[m_ptr->r_idx].level > randint1((p_ptr->skill_exp[GINOU_RIDING] / 50 + p_ptr->lev / 2 + 20)))
2081 msg_print(_("うまく乗れなかった。", "You failed to ride."));
2082 p_ptr->energy_use = 100;
2086 if (MON_CSLEEP(m_ptr))
2089 monster_desc(m_name, m_ptr, 0);
2090 (void)set_monster_csleep(c_ptr->m_idx, 0);
2091 msg_format(_("%sを起こした。", "You have waked %s up."), m_name);
2094 if (p_ptr->action == ACTION_KAMAE) set_action(ACTION_NONE);
2096 p_ptr->riding = c_ptr->m_idx;
2098 /* Hack -- remove tracked monster */
2099 if (p_ptr->riding == p_ptr->health_who) health_track(0);
2102 p_ptr->energy_use = 100;
2104 /* Mega-Hack -- Forget the view and lite */
2105 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2107 /* Update the monsters */
2108 p_ptr->update |= (PU_BONUS);
2111 p_ptr->redraw |= (PR_MAP | PR_EXTRA);
2113 p_ptr->redraw |= (PR_UHEALTH);
2115 /* Move the player */
2116 (void)move_player_effect(y, x, MPE_HANDLE_STUFF | MPE_ENERGY_USE | MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
2122 * @brief ペットに名前をつけるコマンドのメインルーチン
2125 static void do_name_pet(void)
2127 monster_type *m_ptr;
2130 bool old_name = FALSE;
2131 bool old_target_pet = target_pet;
2134 if (!target_set(TARGET_KILL))
2136 target_pet = old_target_pet;
2139 target_pet = old_target_pet;
2141 if (cave[target_row][target_col].m_idx)
2143 m_ptr = &m_list[cave[target_row][target_col].m_idx];
2148 msg_print(_("そのモンスターはペットではない。", "This monster is not a pet."));
2151 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2153 msg_print(_("そのモンスターの名前は変えられない!", "You cannot change name of this monster!"));
2156 monster_desc(m_name, m_ptr, 0);
2159 msg_format(_("%sに名前をつける。", "Name %s."), m_name);
2162 /* Start with nothing */
2163 strcpy(out_val, "");
2165 /* Use old inscription */
2166 if (m_ptr->nickname)
2168 /* Start with the old inscription */
2169 strcpy(out_val, quark_str(m_ptr->nickname));
2173 /* Get a new inscription (possibly empty) */
2174 if (get_string(_("名前: ", "Name: "), out_val, 15))
2178 /* Save the inscription */
2179 m_ptr->nickname = quark_add(out_val);
2180 if (record_named_pet)
2182 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2183 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_NAME, m_name);
2188 if (record_named_pet && old_name)
2190 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2191 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_UNNAME, m_name);
2193 m_ptr->nickname = 0;
2201 * @brief ペットに関するコマンドリストのメインルーチン /
2202 * Issue a pet command
2205 void do_cmd_pet(void)
2210 cptr power_desc[36];
2215 monster_type *m_ptr;
2220 char target_buf[160];
2222 int menu_line = use_menu ? 1 : 0;
2226 power_desc[num] = _("ペットを放す", "dismiss pets");
2227 powers[num++] = PET_DISMISS;
2230 sprintf(target_buf, "ペットのターゲットを指定 (現在:%s)",
2231 (pet_t_m_idx ? (p_ptr->image ? "何か奇妙な物" : (r_name + r_info[m_list[pet_t_m_idx].ap_r_idx].name)) : "指定なし"));
2233 sprintf(target_buf, "specify a target of pet (now:%s)",
2234 (pet_t_m_idx ? (p_ptr->image ? "something strange" : (r_name + r_info[m_list[pet_t_m_idx].ap_r_idx].name)) : "nothing"));
2236 power_desc[num] = target_buf;
2237 powers[num++] = PET_TARGET;
2238 power_desc[num] = _("近くにいろ", "stay close");
2240 if (p_ptr->pet_follow_distance == PET_CLOSE_DIST) mode = num;
2241 powers[num++] = PET_STAY_CLOSE;
2242 power_desc[num] = _("ついて来い", "follow me");
2244 if (p_ptr->pet_follow_distance == PET_FOLLOW_DIST) mode = num;
2245 powers[num++] = PET_FOLLOW_ME;
2246 power_desc[num] = _("敵を見つけて倒せ", "seek and destroy");
2248 if (p_ptr->pet_follow_distance == PET_DESTROY_DIST) mode = num;
2249 powers[num++] = PET_SEEK_AND_DESTROY;
2250 power_desc[num] = _("少し離れていろ", "give me space");
2252 if (p_ptr->pet_follow_distance == PET_SPACE_DIST) mode = num;
2253 powers[num++] = PET_ALLOW_SPACE;
2254 power_desc[num] = _("離れていろ", "stay away");
2256 if (p_ptr->pet_follow_distance == PET_AWAY_DIST) mode = num;
2257 powers[num++] = PET_STAY_AWAY;
2259 if (p_ptr->pet_extra_flags & PF_OPEN_DOORS)
2261 power_desc[num] = _("ドアを開ける (現在:ON)", "pets open doors (now On)");
2265 power_desc[num] = _("ドアを開ける (現在:OFF)", "pets open doors (now Off)");
2267 powers[num++] = PET_OPEN_DOORS;
2269 if (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS)
2271 power_desc[num] = _("アイテムを拾う (現在:ON)", "pets pick up items (now On)");
2275 power_desc[num] = _("アイテムを拾う (現在:OFF)", "pets pick up items (now Off)");
2277 powers[num++] = PET_TAKE_ITEMS;
2279 if (p_ptr->pet_extra_flags & PF_TELEPORT)
2281 power_desc[num] = _("テレポート系魔法を使う (現在:ON)", "allow teleport (now On)");
2285 power_desc[num] = _("テレポート系魔法を使う (現在:OFF)", "allow teleport (now Off)");
2287 powers[num++] = PET_TELEPORT;
2289 if (p_ptr->pet_extra_flags & PF_ATTACK_SPELL)
2291 power_desc[num] = _("攻撃魔法を使う (現在:ON)", "allow cast attack spell (now On)");
2295 power_desc[num] = _("攻撃魔法を使う (現在:OFF)", "allow cast attack spell (now Off)");
2297 powers[num++] = PET_ATTACK_SPELL;
2299 if (p_ptr->pet_extra_flags & PF_SUMMON_SPELL)
2301 power_desc[num] = _("召喚魔法を使う (現在:ON)", "allow cast summon spell (now On)");
2305 power_desc[num] = _("召喚魔法を使う (現在:OFF)", "allow cast summon spell (now Off)");
2307 powers[num++] = PET_SUMMON_SPELL;
2309 if (p_ptr->pet_extra_flags & PF_BALL_SPELL)
2311 power_desc[num] = _("プレイヤーを巻き込む範囲魔法を使う (現在:ON)", "allow involve player in area spell (now On)");
2315 power_desc[num] = _("プレイヤーを巻き込む範囲魔法を使う (現在:OFF)", "allow involve player in area spell (now Off)");
2317 powers[num++] = PET_BALL_SPELL;
2321 power_desc[num] = _("ペットから降りる", "get off a pet");
2325 power_desc[num] = _("ペットに乗る", "ride a pet");
2327 powers[num++] = PET_RIDING;
2328 power_desc[num] = _("ペットに名前をつける", "name pets");
2329 powers[num++] = PET_NAME;
2333 if ((p_ptr->migite && (empty_hands(FALSE) == EMPTY_HAND_LARM) &&
2334 object_allow_two_hands_wielding(&inventory[INVEN_RARM])) ||
2335 (p_ptr->hidarite && (empty_hands(FALSE) == EMPTY_HAND_RARM) &&
2336 object_allow_two_hands_wielding(&inventory[INVEN_LARM])))
2338 if (p_ptr->pet_extra_flags & PF_RYOUTE)
2340 power_desc[num] = _("武器を片手で持つ", "use one hand to control a riding pet");
2344 power_desc[num] = _("武器を両手で持つ", "use both hands for a weapon");
2347 powers[num++] = PET_RYOUTE;
2351 switch (p_ptr->pclass)
2354 case CLASS_FORCETRAINER:
2355 case CLASS_BERSERKER:
2356 if (empty_hands(FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
2358 if (p_ptr->pet_extra_flags & PF_RYOUTE)
2360 power_desc[num] = _("片手で格闘する", "use one hand to control a riding pet");
2364 power_desc[num] = _("両手で格闘する", "use both hands for melee");
2367 powers[num++] = PET_RYOUTE;
2369 else if ((empty_hands(FALSE) != EMPTY_HAND_NONE) && !buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
2371 if (p_ptr->pet_extra_flags & PF_RYOUTE)
2373 power_desc[num] = _("格闘を行わない", "use one hand to control a riding pet");
2377 power_desc[num] = _("格闘を行う", "use one hand for melee");
2380 powers[num++] = PET_RYOUTE;
2388 if (!(repeat_pull(&i) && (i >= 0) && (i < num)))
2390 #endif /* ALLOW_REPEAT */
2392 /* Nothing chosen yet */
2400 /* Save the screen */
2403 /* Build a prompt */
2404 strnfmt(out_val, 78, _("(コマンド、ESC=終了) コマンドを選んでください:", "(Command, ESC=exit) Choose command from menu."));
2408 /* Build a prompt */
2409 strnfmt(out_val, 78,
2410 _("(コマンド %c-%c、'*'=一覧、ESC=終了) コマンドを選んでください:", "(Command %c-%c, *=List, ESC=exit) Select a command: "),
2411 I2A(0), I2A(num - 1));
2414 choice = (always_show_list || use_menu) ? ESCAPE : 1;
2416 /* Get a command from the user */
2421 if (choice == ESCAPE) choice = ' ';
2422 else if (!get_com(out_val, &choice, TRUE)) break;
2424 if (use_menu && (choice != ' '))
2435 menu_line += (num - 1);
2464 if (menu_line > num) menu_line -= num;
2467 /* Request redraw */
2468 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
2471 if (!redraw || use_menu)
2479 /* Save the screen */
2480 if (!use_menu) screen_save();
2485 for (ctr = 0; ctr < num; ctr++)
2487 /* Letter/number for power selection */
2489 sprintf(buf, "%c%s ", (ctr == mode) ? '*' : ' ', (ctr == (menu_line - 1)) ? _("》", "> ") : " ");
2491 sprintf(buf, "%c%c) ", (ctr == mode) ? '*' : ' ', I2A(ctr));
2493 strcat(buf, power_desc[ctr]);
2495 prt(buf, y + ctr, x);
2498 prt("", y + MIN(ctr, 17), x);
2507 /* Restore the screen */
2518 ask = (isupper(choice));
2521 if (ask) choice = tolower(choice);
2523 /* Extract request */
2524 i = (islower(choice) ? A2I(choice) : -1);
2527 /* Totally Illegal */
2528 if ((i < 0) || (i >= num))
2538 strnfmt(buf, 78, _("%sを使いますか? ", "Use %s? "), power_desc[i]);
2540 /* Belay that order */
2541 if (!get_check(buf)) continue;
2548 /* Restore the screen */
2549 if (redraw) screen_load();
2551 /* Abort if needed */
2554 p_ptr->energy_use = 0;
2561 #endif /* ALLOW_REPEAT */
2565 case PET_DISMISS: /* Dismiss pets */
2567 /* Check pets (backwards) */
2568 for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
2570 /* Player has pet */
2571 if (is_pet(&m_list[pet_ctr])) break;
2576 msg_print(_("ペットがいない!", "You have no pets!"));
2579 do_cmd_pet_dismiss();
2580 (void)calculate_upkeep();
2585 project_length = -1;
2586 if (!target_set(TARGET_KILL)) pet_t_m_idx = 0;
2589 cave_type *c_ptr = &cave[target_row][target_col];
2590 if (c_ptr->m_idx && (m_list[c_ptr->m_idx].ml))
2592 pet_t_m_idx = cave[target_row][target_col].m_idx;
2593 p_ptr->pet_follow_distance = PET_DESTROY_DIST;
2595 else pet_t_m_idx = 0;
2602 case PET_STAY_CLOSE:
2604 p_ptr->pet_follow_distance = PET_CLOSE_DIST;
2611 p_ptr->pet_follow_distance = PET_FOLLOW_DIST;
2615 /* "Seek and destoy" */
2616 case PET_SEEK_AND_DESTROY:
2618 p_ptr->pet_follow_distance = PET_DESTROY_DIST;
2621 /* "Give me space" */
2622 case PET_ALLOW_SPACE:
2624 p_ptr->pet_follow_distance = PET_SPACE_DIST;
2630 p_ptr->pet_follow_distance = PET_AWAY_DIST;
2633 /* flag - allow pets to open doors */
2634 case PET_OPEN_DOORS:
2636 if (p_ptr->pet_extra_flags & PF_OPEN_DOORS) p_ptr->pet_extra_flags &= ~(PF_OPEN_DOORS);
2637 else p_ptr->pet_extra_flags |= (PF_OPEN_DOORS);
2640 /* flag - allow pets to pickup items */
2641 case PET_TAKE_ITEMS:
2643 if (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS)
2645 p_ptr->pet_extra_flags &= ~(PF_PICKUP_ITEMS);
2646 for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
2648 /* Access the monster */
2649 m_ptr = &m_list[pet_ctr];
2653 monster_drop_carried_objects(m_ptr);
2657 else p_ptr->pet_extra_flags |= (PF_PICKUP_ITEMS);
2661 /* flag - allow pets to teleport */
2664 if (p_ptr->pet_extra_flags & PF_TELEPORT) p_ptr->pet_extra_flags &= ~(PF_TELEPORT);
2665 else p_ptr->pet_extra_flags |= (PF_TELEPORT);
2668 /* flag - allow pets to cast attack spell */
2669 case PET_ATTACK_SPELL:
2671 if (p_ptr->pet_extra_flags & PF_ATTACK_SPELL) p_ptr->pet_extra_flags &= ~(PF_ATTACK_SPELL);
2672 else p_ptr->pet_extra_flags |= (PF_ATTACK_SPELL);
2675 /* flag - allow pets to cast attack spell */
2676 case PET_SUMMON_SPELL:
2678 if (p_ptr->pet_extra_flags & PF_SUMMON_SPELL) p_ptr->pet_extra_flags &= ~(PF_SUMMON_SPELL);
2679 else p_ptr->pet_extra_flags |= (PF_SUMMON_SPELL);
2682 /* flag - allow pets to cast attack spell */
2683 case PET_BALL_SPELL:
2685 if (p_ptr->pet_extra_flags & PF_BALL_SPELL) p_ptr->pet_extra_flags &= ~(PF_BALL_SPELL);
2686 else p_ptr->pet_extra_flags |= (PF_BALL_SPELL);
2692 (void)do_riding(FALSE);
2704 if (p_ptr->pet_extra_flags & PF_RYOUTE) p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
2705 else p_ptr->pet_extra_flags |= (PF_RYOUTE);
2706 p_ptr->update |= (PU_BONUS);