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(SPELL_IDX *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;
470 SPELL_IDX spell = -1;
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)
658 OBJECT_SUBTYPE_VALUE sval;
660 bool learned = FALSE;
662 /* Spells of realm2 will have an increment of +32 */
663 SPELL_IDX spell = -1;
665 cptr p = spell_category_name(mp_ptr->spell_book);
673 msg_print(_("本を読むことができない!", "You cannot read books!"));
677 if (p_ptr->blind || no_lite())
679 msg_print(_("目が見えない!", "You cannot see!"));
685 msg_print(_("混乱していて読めない!", "You are too confused!"));
689 if (!(p_ptr->new_spells))
691 msg_format(_("新しい%sを覚えることはできない!", "You cannot learn any new %ss!"), p);
695 if (p_ptr->special_defense & KATA_MUSOU)
697 set_action(ACTION_NONE);
701 if( p_ptr->new_spells < 10 ){
702 msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
704 msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
707 msg_format("You can learn %d new %s%s.", p_ptr->new_spells, p,
708 (p_ptr->new_spells == 1?"":"s"));
714 /* Restrict choices to "useful" books */
715 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
716 else item_tester_hook = item_tester_learn_spell;
719 q = _("どの本から学びますか? ", "Study which book? ");
720 s = _("読める本がない。", "You have no books that you can read.");
722 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
724 /* Get the item (in the pack) */
727 o_ptr = &inventory[item];
730 /* Get the item (on the floor) */
733 o_ptr = &o_list[0 - item];
736 /* Access the item's sval */
739 if (o_ptr->tval == REALM2_BOOK) increment = 32;
740 else if (o_ptr->tval != REALM1_BOOK)
742 if (!get_check(_("本当に魔法の領域を変更しますか?", "Really, change magic realm? "))) return;
743 change_realm2(tval2realm(o_ptr->tval));
747 /* Track the object kind */
748 object_kind_track(o_ptr->k_idx);
750 /* Hack -- Handle stuff */
753 /* Mage -- Learn a selected spell */
754 if (mp_ptr->spell_book != TV_LIFE_BOOK)
756 /* Ask for a spell, allow cancel */
758 if (!get_spell(&spell, "学ぶ", sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1)
759 && (spell == -1)) return;
761 if (!get_spell(&spell, "study", sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1)
762 && (spell == -1)) return;
767 /* Priest -- Learn a random prayer */
775 for (spell = 0; spell < 32; spell++)
777 /* Check spells in the book */
778 if ((fake_spell_flags[sval] & (1L << spell)))
780 /* Skip non "okay" prayers */
781 if (!spell_okay(spell, FALSE, TRUE,
782 (increment ? p_ptr->realm2 : p_ptr->realm1))) continue;
784 /* Hack -- Prepare the randomizer */
787 /* Hack -- Apply the randomizer */
788 if (one_in_(k)) gift = spell;
796 /* Nothing to study */
800 msg_format(_("その本には学ぶべき%sがない。", "You cannot learn any %ss in that book."), p);
807 if (increment) spell += increment;
809 /* Learn the spell */
812 if (p_ptr->spell_learned1 & (1L << spell)) learned = TRUE;
813 else p_ptr->spell_learned1 |= (1L << spell);
817 if (p_ptr->spell_learned2 & (1L << (spell - 32))) learned = TRUE;
818 else p_ptr->spell_learned2 |= (1L << (spell - 32));
823 int max_exp = (spell < 32) ? SPELL_EXP_MASTER : SPELL_EXP_EXPERT;
824 int old_exp = p_ptr->spell_exp[spell];
825 int new_rank = EXP_LEVEL_UNSKILLED;
826 cptr name = do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell%32, SPELL_NAME);
828 if (old_exp >= max_exp)
830 msg_format(_("その%sは完全に使いこなせるので学ぶ必要はない。", "You don't need to study this %s anymore."), p);
834 if (!get_check(format("%sの%sをさらに学びます。よろしいですか?", name, p)))
836 if (!get_check(format("You will study a %s of %s again. Are you sure? ", p, name)))
841 else if (old_exp >= SPELL_EXP_EXPERT)
843 p_ptr->spell_exp[spell] = SPELL_EXP_MASTER;
844 new_rank = EXP_LEVEL_MASTER;
846 else if (old_exp >= SPELL_EXP_SKILLED)
848 if (spell >= 32) p_ptr->spell_exp[spell] = SPELL_EXP_EXPERT;
849 else p_ptr->spell_exp[spell] += SPELL_EXP_EXPERT - SPELL_EXP_SKILLED;
850 new_rank = EXP_LEVEL_EXPERT;
852 else if (old_exp >= SPELL_EXP_BEGINNER)
854 p_ptr->spell_exp[spell] = SPELL_EXP_SKILLED + (old_exp - SPELL_EXP_BEGINNER) * 2 / 3;
855 new_rank = EXP_LEVEL_SKILLED;
859 p_ptr->spell_exp[spell] = SPELL_EXP_BEGINNER + old_exp / 3;
860 new_rank = EXP_LEVEL_BEGINNER;
862 msg_format(_("%sの熟練度が%sに上がった。", "Your proficiency of %s is now %s rank."), name, exp_level_str[new_rank]);
866 /* Find the next open entry in "p_ptr->spell_order[]" */
867 for (i = 0; i < 64; i++)
869 /* Stop at the first empty space */
870 if (p_ptr->spell_order[i] == 99) break;
873 /* Add the spell to the known list */
874 p_ptr->spell_order[i++] = spell;
876 /* Mention the result */
879 if (mp_ptr->spell_book == TV_MUSIC_BOOK)
881 msg_format("%sを学んだ。",
882 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
886 msg_format("%sの%sを学んだ。",
887 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME) ,p);
890 msg_format("You have learned the %s of %s.",
891 p, do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
896 p_ptr->energy_use = 100;
898 switch (mp_ptr->spell_book)
901 chg_virtue(V_FAITH, 1);
904 chg_virtue(V_UNLIFE, 1);
907 chg_virtue(V_NATURE, 1);
910 chg_virtue(V_KNOWLEDGE, 1);
917 /* One less spell available */
918 p_ptr->learned_spells++;
920 /* Message if needed */
921 if (p_ptr->new_spells)
925 if (p_ptr->new_spells < 10) msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
926 else msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
928 msg_format("You can learn %d more %s%s.", p_ptr->new_spells, p,
929 (p_ptr->new_spells != 1) ? "s" : "");
935 p_ptr->update |= (PU_SPELLS);
938 /* Redraw object recall */
939 p_ptr->window |= (PW_OBJECT);
943 * @brief 運命の輪、並びにカオス的な効果の発動
944 * @param spell ランダムな効果を選択するための基準ID
947 static void wild_magic(int spell)
950 int type = SUMMON_MOLD + randint0(6);
952 if (type < SUMMON_MOLD) type = SUMMON_MOLD;
953 else if (type > SUMMON_MIMIC) type = SUMMON_MIMIC;
955 switch (randint1(spell) + randint1(8) + 1)
960 teleport_player(10, TELEPORT_PASSIVE);
965 teleport_player(100, TELEPORT_PASSIVE);
969 teleport_player(200, TELEPORT_PASSIVE);
979 lite_area(damroll(2, 3), 2);
982 destroy_doors_touch();
987 sleep_monsters_touch();
991 trap_creation(p_ptr->y, p_ptr->x);
1000 aggravate_monsters(0);
1003 earthquake(p_ptr->y, p_ptr->x, 5);
1007 (void)gain_random_mutation(0);
1011 apply_disenchant(1);
1017 fire_ball(GF_CHAOS, 0, spell + 5, 1 + (spell / 10));
1024 while (counter++ < 8)
1026 (void)summon_specific(0, p_ptr->y, p_ptr->x, (dun_level * 3) / 2, type, (PM_ALLOW_GROUP | PM_NO_PET));
1031 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
1034 (void)summon_cyber(-1, p_ptr->y, p_ptr->x);
1039 (void)activate_ty_curse(FALSE, &count);
1049 * @brief 魔法を詠唱するコマンドのメインルーチン /
1053 void do_cmd_cast(void)
1056 OBJECT_SUBTYPE_VALUE sval;
1068 const magic_type *s_ptr;
1072 bool over_exerted = FALSE;
1074 /* Require spell ability */
1075 if (!p_ptr->realm1 && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
1077 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
1082 if (p_ptr->blind || no_lite())
1084 if (p_ptr->pclass == CLASS_FORCETRAINER) confirm_use_force(FALSE);
1087 msg_print(_("目が見えない!", "You cannot see!"));
1093 /* Not when confused */
1094 if (p_ptr->confused)
1096 msg_print(_("混乱していて唱えられない!", "You are too confused!"));
1102 if (p_ptr->realm1 == REALM_HEX)
1104 if (hex_spell_fully())
1107 msg_print(_("これ以上新しい呪文を詠唱することはできない。", "Can not spell new spells more."));
1109 if (p_ptr->lev >= 35) flag = stop_hex_spell();
1114 if (p_ptr->pclass == CLASS_FORCETRAINER)
1116 if (player_has_no_spellbooks())
1118 confirm_use_force(FALSE);
1121 select_the_force = TRUE;
1124 prayer = spell_category_name(mp_ptr->spell_book);
1126 /* Restrict choices to spell books */
1127 item_tester_tval = mp_ptr->spell_book;
1130 q = _("どの呪文書を使いますか? ", "Use which book? ");
1131 s = _("呪文書がない!", "You have no spell books!");
1133 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
1135 select_the_force = FALSE;
1138 select_the_force = FALSE;
1140 if (item == INVEN_FORCE) /* the_force */
1146 /* Get the item (in the pack) */
1149 o_ptr = &inventory[item];
1152 /* Get the item (on the floor) */
1155 o_ptr = &o_list[0 - item];
1158 /* Access the item's sval */
1161 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && (o_ptr->tval == REALM2_BOOK)) increment = 32;
1164 /* Track the object kind */
1165 object_kind_track(o_ptr->k_idx);
1167 /* Hack -- Handle stuff */
1170 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
1171 realm = o_ptr->tval - TV_LIFE_BOOK + 1;
1172 else if (increment) realm = p_ptr->realm2;
1173 else realm = p_ptr->realm1;
1175 /* Ask for a spell */
1177 if (!get_spell(&spell,
1178 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_MUSIC_BOOK) ? "歌う" : "唱える"),
1181 if (spell == -2) msg_format("その本には知っている%sがない。", prayer);
1185 if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1189 msg_format("You don't know any %ss in that book.", prayer);
1195 use_realm = tval2realm(o_ptr->tval);
1198 if (use_realm == REALM_HEX)
1200 if (hex_spelling(spell))
1202 msg_print(_("その呪文はすでに詠唱中だ。", "You are already casting it."));
1207 if (!is_magic(use_realm))
1209 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
1213 s_ptr = &mp_ptr->info[realm - 1][spell];
1216 /* Extract mana consumption rate */
1217 need_mana = mod_need_mana(s_ptr->smana, spell, realm);
1219 /* Verify "dangerous" spells */
1220 if (need_mana > p_ptr->csp)
1222 if (flush_failure) flush();
1226 msg_format("その%sを%sのに十分なマジックポイントがない。",prayer,
1227 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "詠唱する" : (mp_ptr->spell_book == TV_LIFE_BOOK) ? "歌う" : "唱える"));
1229 msg_format("You do not have enough mana to %s this %s.",
1230 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1235 if (!over_exert) return;
1238 if (!get_check_strict(_("それでも挑戦しますか? ", "Attempt it anyway? "), CHECK_OKAY_CANCEL)) return;
1241 /* Spell failure chance */
1242 chance = spell_chance(spell, use_realm);
1244 /* Sufficient mana */
1245 if (need_mana <= p_ptr->csp)
1248 p_ptr->csp -= need_mana;
1250 else over_exerted = TRUE;
1253 p_ptr->redraw |= (PR_MANA);
1256 if (randint0(100) < chance)
1258 if (flush_failure) flush();
1260 msg_format(_("%sをうまく唱えられなかった!", "You failed to get the %s off!"), prayer);
1266 if (randint1(100) < chance) chg_virtue(V_VITALITY, -1);
1269 if (randint1(100) < chance) chg_virtue(V_UNLIFE, -1);
1272 if (randint1(100) < chance) chg_virtue(V_NATURE, -1);
1275 if (randint1(100) < chance) chg_virtue(V_JUSTICE, 1);
1278 if (randint1(100) < chance) chg_virtue(V_JUSTICE, -1);
1281 if (randint1(100) < chance) chg_virtue(V_COMPASSION, -1);
1284 if (randint1(100) < chance) chg_virtue(V_KNOWLEDGE, -1);
1288 /* Failure casting may activate some side effect */
1289 do_spell(realm, spell, SPELL_FAIL);
1292 if ((o_ptr->tval == TV_CHAOS_BOOK) && (randint1(100) < spell))
1294 msg_print(_("カオス的な効果を発生した!", "You produce a chaotic effect!"));
1297 else if ((o_ptr->tval == TV_DEATH_BOOK) && (randint1(100) < spell))
1299 if ((sval == 3) && one_in_(2))
1301 sanity_blast(0, TRUE);
1305 msg_print(_("痛い!", "It hurts!"));
1306 take_hit(DAMAGE_LOSELIFE, damroll(o_ptr->sval + 1, 6), _("暗黒魔法の逆流", "a miscast Death spell"), -1);
1308 if ((spell > 15) && one_in_(6) && !p_ptr->hold_exp)
1309 lose_exp(spell * 250);
1312 else if ((o_ptr->tval == TV_MUSIC_BOOK) && (randint1(200) < spell))
1314 msg_print(_("いやな音が響いた", "An infernal sound echoed."));
1315 aggravate_monsters(0);
1317 if (randint1(100) >= chance)
1318 chg_virtue(V_CHANCE,-1);
1324 /* Canceled spells cost neither a turn nor mana */
1325 if (!do_spell(realm, spell, SPELL_CAST)) return;
1327 if (randint1(100) < chance)
1328 chg_virtue(V_CHANCE,1);
1330 /* A spell was cast */
1332 (p_ptr->spell_worked2 & (1L << spell)) :
1333 (p_ptr->spell_worked1 & (1L << spell)))
1334 && (p_ptr->pclass != CLASS_SORCERER)
1335 && (p_ptr->pclass != CLASS_RED_MAGE))
1337 int e = s_ptr->sexp;
1339 /* The spell worked */
1340 if (realm == p_ptr->realm1)
1342 p_ptr->spell_worked1 |= (1L << spell);
1346 p_ptr->spell_worked2 |= (1L << spell);
1349 /* Gain experience */
1350 gain_exp(e * s_ptr->slevel);
1352 /* Redraw object recall */
1353 p_ptr->window |= (PW_OBJECT);
1358 chg_virtue(V_TEMPERANCE, 1);
1359 chg_virtue(V_COMPASSION, 1);
1360 chg_virtue(V_VITALITY, 1);
1361 chg_virtue(V_DILIGENCE, 1);
1364 chg_virtue(V_UNLIFE, 1);
1365 chg_virtue(V_JUSTICE, -1);
1366 chg_virtue(V_FAITH, -1);
1367 chg_virtue(V_VITALITY, -1);
1370 chg_virtue(V_JUSTICE, -1);
1371 chg_virtue(V_FAITH, -1);
1372 chg_virtue(V_HONOUR, -1);
1373 chg_virtue(V_TEMPERANCE, -1);
1376 chg_virtue(V_FAITH, 1);
1377 chg_virtue(V_JUSTICE, 1);
1378 chg_virtue(V_SACRIFICE, 1);
1379 chg_virtue(V_HONOUR, 1);
1382 chg_virtue(V_NATURE, 1);
1383 chg_virtue(V_HARMONY, 1);
1386 chg_virtue(V_JUSTICE, -1);
1387 chg_virtue(V_FAITH, -1);
1388 chg_virtue(V_HONOUR, -1);
1389 chg_virtue(V_COMPASSION, -1);
1392 chg_virtue(V_KNOWLEDGE, 1);
1399 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, 1);
1400 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, 1);
1401 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, 1);
1402 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_DILIGENCE, 1);
1405 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_UNLIFE, 1);
1406 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1407 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1408 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, -1);
1411 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1412 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1413 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1414 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, -1);
1417 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, 1);
1418 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, 1);
1419 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_SACRIFICE, 1);
1420 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, 1);
1423 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_NATURE, 1);
1424 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HARMONY, 1);
1427 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1428 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1429 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1430 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, -1);
1433 if (mp_ptr->spell_xtra & MAGIC_GAIN_EXP)
1435 s16b cur_exp = p_ptr->spell_exp[(increment ? 32 : 0)+spell];
1438 if (cur_exp < SPELL_EXP_BEGINNER)
1440 else if (cur_exp < SPELL_EXP_SKILLED)
1442 if ((dun_level > 4) && ((dun_level + 10) > p_ptr->lev))
1445 else if (cur_exp < SPELL_EXP_EXPERT)
1447 if (((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel))
1450 else if ((cur_exp < SPELL_EXP_MASTER) && !increment)
1452 if (((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel))
1455 p_ptr->spell_exp[(increment ? 32 : 0) + spell] += exp_gain;
1460 p_ptr->energy_use = 100;
1463 /* Over-exert the player */
1466 int oops = need_mana;
1470 p_ptr->csp_frac = 0;
1473 msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
1475 /* Hack -- Bypass free action */
1476 (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
1481 chg_virtue(V_VITALITY, -10);
1484 chg_virtue(V_UNLIFE, -10);
1487 chg_virtue(V_JUSTICE, 10);
1490 chg_virtue(V_NATURE, -10);
1493 chg_virtue(V_JUSTICE, -10);
1496 chg_virtue(V_COMPASSION, 10);
1499 chg_virtue(V_KNOWLEDGE, -10);
1503 /* Damage CON (possibly permanently) */
1504 if (randint0(100) < 50)
1506 bool perm = (randint0(100) < 25);
1509 msg_print(_("体を悪くしてしまった!", "You have damaged your health!"));
1511 /* Reduce constitution */
1512 (void)dec_stat(A_CON, 15 + randint1(10), perm);
1517 p_ptr->window |= (PW_PLAYER);
1518 p_ptr->window |= (PW_SPELL);
1522 * @brief ペットになっているモンスターをソートするための比較処理
1523 * @param u モンスターの構造体配列
1525 * @param a 比較対象のモンスターID1
1526 * @param b 比較対象のモンスターID2
1527 * @return 2番目が大ならばTRUEを返す
1529 static bool ang_sort_comp_pet_dismiss(vptr u, vptr v, int a, int b)
1531 u16b *who = (u16b*)(u);
1536 monster_type *m_ptr1 = &m_list[w1];
1537 monster_type *m_ptr2 = &m_list[w2];
1538 monster_race *r_ptr1 = &r_info[m_ptr1->r_idx];
1539 monster_race *r_ptr2 = &r_info[m_ptr2->r_idx];
1544 if (w1 == p_ptr->riding) return TRUE;
1545 if (w2 == p_ptr->riding) return FALSE;
1547 if (m_ptr1->nickname && !m_ptr2->nickname) return TRUE;
1548 if (m_ptr2->nickname && !m_ptr1->nickname) return FALSE;
1550 if (!m_ptr1->parent_m_idx && m_ptr2->parent_m_idx) return TRUE;
1551 if (!m_ptr2->parent_m_idx && m_ptr1->parent_m_idx) return FALSE;
1553 if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return TRUE;
1554 if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return FALSE;
1556 if (r_ptr1->level > r_ptr2->level) return TRUE;
1557 if (r_ptr2->level > r_ptr1->level) return FALSE;
1559 if (m_ptr1->hp > m_ptr2->hp) return TRUE;
1560 if (m_ptr2->hp > m_ptr1->hp) return FALSE;
1566 * @brief ペットの善悪属性に応じた維持コストの途中計算処理
1567 * @param m_ptr 計算基準となるモンスターの構造体参照ポインタ
1568 * @param inc m_ptrで指定したモンスターを維持コスト計算に加えるならTRUE、外すならFALSEを指定
1571 void check_pets_num_and_align(monster_type *m_ptr, bool inc)
1573 s32b old_friend_align = friend_align;
1574 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1579 if (r_ptr->flags3 & RF3_GOOD) friend_align += r_ptr->level;
1580 if (r_ptr->flags3 & RF3_EVIL) friend_align -= r_ptr->level;
1585 if (r_ptr->flags3 & RF3_GOOD) friend_align -= r_ptr->level;
1586 if (r_ptr->flags3 & RF3_EVIL) friend_align += r_ptr->level;
1589 if (old_friend_align != friend_align) p_ptr->update |= (PU_BONUS);
1593 * @brief ペットの維持コスト計算
1596 int calculate_upkeep(void)
1598 s32b old_friend_align = friend_align;
1600 bool have_a_unique = FALSE;
1601 s32b total_friend_levels = 0;
1606 for (m_idx = m_max - 1; m_idx >=1; m_idx--)
1608 monster_type *m_ptr;
1609 monster_race *r_ptr;
1611 m_ptr = &m_list[m_idx];
1612 if (!m_ptr->r_idx) continue;
1613 r_ptr = &r_info[m_ptr->r_idx];
1618 if (r_ptr->flags1 & RF1_UNIQUE)
1620 if (p_ptr->pclass == CLASS_CAVALRY)
1622 if (p_ptr->riding == m_idx)
1623 total_friend_levels += (r_ptr->level+5)*2;
1624 else if (!have_a_unique && (r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
1625 total_friend_levels += (r_ptr->level+5)*7/2;
1627 total_friend_levels += (r_ptr->level+5)*10;
1628 have_a_unique = TRUE;
1631 total_friend_levels += (r_ptr->level+5)*10;
1634 total_friend_levels += r_ptr->level;
1636 /* Determine pet alignment */
1637 if (r_ptr->flags3 & RF3_GOOD) friend_align += r_ptr->level;
1638 if (r_ptr->flags3 & RF3_EVIL) friend_align -= r_ptr->level;
1641 if (old_friend_align != friend_align) p_ptr->update |= (PU_BONUS);
1645 upkeep_factor = (total_friend_levels - (p_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
1646 if (upkeep_factor < 0) upkeep_factor = 0;
1647 if (upkeep_factor > 1000) upkeep_factor = 1000;
1648 return upkeep_factor;
1655 * @brief ペットを開放するコマンドのメインルーチン
1658 void do_cmd_pet_dismiss(void)
1660 monster_type *m_ptr;
1661 bool all_pets = FALSE;
1662 MONSTER_IDX pet_ctr;
1676 /* Allocate the "who" array */
1677 C_MAKE(who, max_m_idx, u16b);
1679 /* Process the monsters (backwards) */
1680 for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
1682 if (is_pet(&m_list[pet_ctr]))
1683 who[max_pet++] = pet_ctr;
1686 /* Select the sort method */
1687 ang_sort_comp = ang_sort_comp_pet_dismiss;
1688 ang_sort_swap = ang_sort_swap_hook;
1690 ang_sort(who, &dummy_why, max_pet);
1692 /* Process the monsters (backwards) */
1693 for (i = 0; i < max_pet; i++)
1696 char friend_name[80];
1699 /* Access the monster */
1701 m_ptr = &m_list[pet_ctr];
1703 delete_this = FALSE;
1704 kakunin = ((pet_ctr == p_ptr->riding) || (m_ptr->nickname));
1705 monster_desc(friend_name, m_ptr, MD_ASSUME_VISIBLE);
1709 /* Hack -- health bar for this monster */
1710 health_track(pet_ctr);
1712 /* Hack -- handle stuff */
1715 msg_format(_("%sを放しますか? [Yes/No/Unnamed (%d体)]","Dismiss %s? [Yes/No/Unnamed (%d remain)]"), friend_name, max_pet - i);
1718 move_cursor_relative(m_ptr->fy, m_ptr->fx);
1724 if (ch == 'Y' || ch == 'y')
1730 msg_format(_("本当によろしいですか? (%s) ","Are you sure? (%s) "), friend_name);
1732 if (ch != 'Y' && ch != 'y')
1733 delete_this = FALSE;
1738 if (ch == 'U' || ch == 'u')
1744 if (ch == ESCAPE || ch == 'N' || ch == 'n')
1751 if ((all_pets && !kakunin) || (!all_pets && delete_this))
1753 if (record_named_pet && m_ptr->nickname)
1757 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1758 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_DISMISS, m_name);
1761 if (pet_ctr == p_ptr->riding)
1763 msg_format(_("%sから降りた。","You have got off %s. "), friend_name);
1767 /* Update the monsters */
1768 p_ptr->update |= (PU_BONUS | PU_MONSTERS);
1769 p_ptr->redraw |= (PR_EXTRA | PR_UHEALTH);
1772 /* HACK : Add the line to message buffer */
1773 msg_format(_("%s を放した。","Dismissed %s."), friend_name);
1774 p_ptr->window |= (PW_MESSAGE);
1777 delete_monster_idx(pet_ctr);
1786 C_KILL(who, max_m_idx, MONSTER_IDX);
1789 msg_format("%d 体のペットを放しました。", Dismissed);
1791 msg_format("You have dismissed %d pet%s.", Dismissed,
1792 (Dismissed == 1 ? "" : "s"));
1794 if (Dismissed == 0 && all_pets)
1795 msg_print(_("'U'nnamed は、乗馬以外の名前のないペットだけを全て解放します。", "'U'nnamed means all your pets except named pets and your mount."));
1799 * @brief プレイヤーの騎乗/下馬処理判定
1800 * @param c_ptr プレイヤーの移動先マスの構造体参照ポインタ
1801 * @param now_riding TRUEなら下馬処理、FALSEならば騎乗処理
1802 * @return 可能ならばTRUEを返す
1804 static bool player_can_ride_aux(cave_type *c_ptr, bool now_riding)
1807 bool old_character_xtra = character_xtra;
1808 MONSTER_IDX old_riding = p_ptr->riding;
1809 bool old_riding_ryoute = p_ptr->riding_ryoute;
1810 bool old_old_riding_ryoute = p_ptr->old_riding_ryoute;
1811 bool old_pf_ryoute = (p_ptr->pet_extra_flags & PF_RYOUTE) ? TRUE : FALSE;
1813 /* Hack -- prevent "icky" message */
1814 character_xtra = TRUE;
1816 if (now_riding) p_ptr->riding = c_ptr->m_idx;
1820 p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
1821 p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
1826 p_can_enter = player_can_enter(c_ptr->feat, CEM_P_CAN_ENTER_PATTERN);
1828 p_ptr->riding = old_riding;
1829 if (old_pf_ryoute) p_ptr->pet_extra_flags |= (PF_RYOUTE);
1830 else p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
1831 p_ptr->riding_ryoute = old_riding_ryoute;
1832 p_ptr->old_riding_ryoute = old_old_riding_ryoute;
1836 character_xtra = old_character_xtra;
1842 * @brief プレイヤーの落馬判定処理
1843 * @param dam 落馬判定を発した際に受けたダメージ量
1844 * @param force TRUEならば強制的に落馬する
1845 * @return 実際に落馬したらTRUEを返す
1847 bool rakuba(int dam, bool force)
1849 int i, y, x, oy, ox;
1850 int sn = 0, sy = 0, sx = 0;
1852 monster_type *m_ptr = &m_list[p_ptr->riding];
1853 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1854 bool fall_dam = FALSE;
1856 if (!p_ptr->riding) return FALSE;
1857 if (p_ptr->wild_mode) return FALSE;
1859 if (dam >= 0 || force)
1863 int cur = p_ptr->skill_exp[GINOU_RIDING];
1864 int max = s_info[p_ptr->pclass].s_max[GINOU_RIDING];
1865 int ridinglevel = r_ptr->level;
1868 int rakubalevel = r_ptr->level;
1869 if (p_ptr->riding_ryoute) rakubalevel += 20;
1871 if ((cur < max) && (max > 1000) &&
1872 (dam / 2 + ridinglevel) > (cur / 30 + 10))
1876 if (ridinglevel > (cur / 100 + 15))
1877 inc += 1 + (ridinglevel - cur / 100 - 15);
1881 p_ptr->skill_exp[GINOU_RIDING] = MIN(max, cur + inc);
1884 /* レベルの低い乗馬からは落馬しにくい */
1885 if (randint0(dam / 2 + rakubalevel * 2) < cur / 30 + 10)
1887 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))
1894 /* Check around the player */
1895 for (i = 0; i < 8; i++)
1899 /* Access the location */
1900 y = p_ptr->y + ddy_ddd[i];
1901 x = p_ptr->x + ddx_ddd[i];
1903 c_ptr = &cave[y][x];
1905 if (c_ptr->m_idx) continue;
1907 /* Skip non-empty grids */
1908 if (!cave_have_flag_grid(c_ptr, FF_MOVE) && !cave_have_flag_grid(c_ptr, FF_CAN_FLY))
1910 if (!player_can_ride_aux(c_ptr, FALSE)) continue;
1913 if (cave_have_flag_grid(c_ptr, FF_PATTERN)) continue;
1915 /* Count "safe" grids */
1918 /* Randomize choice */
1919 if (randint0(sn) > 0) continue;
1921 /* Save the safe location */
1926 monster_desc(m_name, m_ptr, 0);
1928 msg_format("%sから振り落とされそうになって、壁にぶつかった。",m_name);
1929 take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, "壁への衝突", -1);
1931 msg_format("You have nearly fallen from %s, but bumped into wall.",m_name);
1932 take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, "bumping into wall", -1);
1943 /* Redraw the old spot */
1946 /* Redraw the new spot */
1947 lite_spot(p_ptr->y, p_ptr->x);
1949 /* Check for new panel */
1954 p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
1955 p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
1959 p_ptr->update |= (PU_BONUS);
1962 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1965 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1967 p_ptr->redraw |= (PR_EXTRA);
1969 /* Update health track of mount */
1970 p_ptr->redraw |= (PR_UHEALTH);
1972 if (p_ptr->levitation && !force)
1974 monster_desc(m_name, m_ptr, 0);
1975 msg_format(_("%sから落ちたが、空中でうまく体勢を立て直して着地した。", "You are thrown from %s, but make a good landing."),m_name);
1979 take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, _("落馬", "Falling from riding"), -1);
1983 /* Move the player */
1984 if (sy && !p_ptr->is_dead)
1985 (void)move_player_effect(p_ptr->y, p_ptr->x, MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
1991 * @brief ペットから騎乗/下馬するコマンドのメインルーチン /
1992 * @param force 強制的に騎乗/下馬するならばTRUE
1993 * @return 騎乗/下馬できたらTRUE
1995 bool do_riding(bool force)
1999 monster_type *m_ptr;
2001 if (!get_rep_dir2(&dir)) return FALSE;
2002 y = p_ptr->y + ddy[dir];
2003 x = p_ptr->x + ddx[dir];
2004 c_ptr = &cave[y][x];
2006 if (p_ptr->special_defense & KATA_MUSOU) set_action(ACTION_NONE);
2010 /* Skip non-empty grids */
2011 if (!player_can_ride_aux(c_ptr, FALSE))
2013 msg_print(_("そちらには降りられません。", "You cannot go to that direction."));
2017 if (!pattern_seq(p_ptr->y, p_ptr->x, y, x)) return FALSE;
2022 p_ptr->energy_use = 100;
2025 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2032 p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
2033 p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
2037 if (p_ptr->confused)
2039 msg_print(_("混乱していて乗れない!", "You are too confused!"));
2043 m_ptr = &m_list[c_ptr->m_idx];
2045 if (!c_ptr->m_idx || !m_ptr->ml)
2047 msg_print(_("その場所にはモンスターはいません。", "Here is no monster."));
2050 if (!is_pet(m_ptr) && !force)
2052 msg_print(_("そのモンスターはペットではありません。", "That monster is not a pet."));
2055 if (!(r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
2057 msg_print(_("そのモンスターには乗れなさそうだ。", "This monster doesn't seem suitable for riding."));
2061 if (!pattern_seq(p_ptr->y, p_ptr->x, y, x)) return FALSE;
2063 if (!player_can_ride_aux(c_ptr, TRUE))
2065 /* Feature code (applying "mimic" field) */
2066 feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
2068 msg_format("そのモンスターは%sの%sにいる。", f_name + f_ptr->name,
2069 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
2070 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE))) ?
2073 msg_format("This monster is %s the %s.",
2074 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
2075 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE))) ?
2076 "in" : "on", f_name + f_ptr->name);
2081 if (r_info[m_ptr->r_idx].level > randint1((p_ptr->skill_exp[GINOU_RIDING] / 50 + p_ptr->lev / 2 + 20)))
2083 msg_print(_("うまく乗れなかった。", "You failed to ride."));
2084 p_ptr->energy_use = 100;
2088 if (MON_CSLEEP(m_ptr))
2091 monster_desc(m_name, m_ptr, 0);
2092 (void)set_monster_csleep(c_ptr->m_idx, 0);
2093 msg_format(_("%sを起こした。", "You have waked %s up."), m_name);
2096 if (p_ptr->action == ACTION_KAMAE) set_action(ACTION_NONE);
2098 p_ptr->riding = c_ptr->m_idx;
2100 /* Hack -- remove tracked monster */
2101 if (p_ptr->riding == p_ptr->health_who) health_track(0);
2104 p_ptr->energy_use = 100;
2106 /* Mega-Hack -- Forget the view and lite */
2107 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2109 /* Update the monsters */
2110 p_ptr->update |= (PU_BONUS);
2113 p_ptr->redraw |= (PR_MAP | PR_EXTRA);
2115 p_ptr->redraw |= (PR_UHEALTH);
2117 /* Move the player */
2118 (void)move_player_effect(y, x, MPE_HANDLE_STUFF | MPE_ENERGY_USE | MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
2124 * @brief ペットに名前をつけるコマンドのメインルーチン
2127 static void do_name_pet(void)
2129 monster_type *m_ptr;
2132 bool old_name = FALSE;
2133 bool old_target_pet = target_pet;
2136 if (!target_set(TARGET_KILL))
2138 target_pet = old_target_pet;
2141 target_pet = old_target_pet;
2143 if (cave[target_row][target_col].m_idx)
2145 m_ptr = &m_list[cave[target_row][target_col].m_idx];
2150 msg_print(_("そのモンスターはペットではない。", "This monster is not a pet."));
2153 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2155 msg_print(_("そのモンスターの名前は変えられない!", "You cannot change name of this monster!"));
2158 monster_desc(m_name, m_ptr, 0);
2161 msg_format(_("%sに名前をつける。", "Name %s."), m_name);
2164 /* Start with nothing */
2165 strcpy(out_val, "");
2167 /* Use old inscription */
2168 if (m_ptr->nickname)
2170 /* Start with the old inscription */
2171 strcpy(out_val, quark_str(m_ptr->nickname));
2175 /* Get a new inscription (possibly empty) */
2176 if (get_string(_("名前: ", "Name: "), out_val, 15))
2180 /* Save the inscription */
2181 m_ptr->nickname = quark_add(out_val);
2182 if (record_named_pet)
2184 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2185 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_NAME, m_name);
2190 if (record_named_pet && old_name)
2192 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2193 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_UNNAME, m_name);
2195 m_ptr->nickname = 0;
2203 * @brief ペットに関するコマンドリストのメインルーチン /
2204 * Issue a pet command
2207 void do_cmd_pet(void)
2212 cptr power_desc[36];
2217 monster_type *m_ptr;
2222 char target_buf[160];
2224 int menu_line = use_menu ? 1 : 0;
2228 power_desc[num] = _("ペットを放す", "dismiss pets");
2229 powers[num++] = PET_DISMISS;
2232 sprintf(target_buf, "ペットのターゲットを指定 (現在:%s)",
2233 (pet_t_m_idx ? (p_ptr->image ? "何か奇妙な物" : (r_name + r_info[m_list[pet_t_m_idx].ap_r_idx].name)) : "指定なし"));
2235 sprintf(target_buf, "specify a target of pet (now:%s)",
2236 (pet_t_m_idx ? (p_ptr->image ? "something strange" : (r_name + r_info[m_list[pet_t_m_idx].ap_r_idx].name)) : "nothing"));
2238 power_desc[num] = target_buf;
2239 powers[num++] = PET_TARGET;
2240 power_desc[num] = _("近くにいろ", "stay close");
2242 if (p_ptr->pet_follow_distance == PET_CLOSE_DIST) mode = num;
2243 powers[num++] = PET_STAY_CLOSE;
2244 power_desc[num] = _("ついて来い", "follow me");
2246 if (p_ptr->pet_follow_distance == PET_FOLLOW_DIST) mode = num;
2247 powers[num++] = PET_FOLLOW_ME;
2248 power_desc[num] = _("敵を見つけて倒せ", "seek and destroy");
2250 if (p_ptr->pet_follow_distance == PET_DESTROY_DIST) mode = num;
2251 powers[num++] = PET_SEEK_AND_DESTROY;
2252 power_desc[num] = _("少し離れていろ", "give me space");
2254 if (p_ptr->pet_follow_distance == PET_SPACE_DIST) mode = num;
2255 powers[num++] = PET_ALLOW_SPACE;
2256 power_desc[num] = _("離れていろ", "stay away");
2258 if (p_ptr->pet_follow_distance == PET_AWAY_DIST) mode = num;
2259 powers[num++] = PET_STAY_AWAY;
2261 if (p_ptr->pet_extra_flags & PF_OPEN_DOORS)
2263 power_desc[num] = _("ドアを開ける (現在:ON)", "pets open doors (now On)");
2267 power_desc[num] = _("ドアを開ける (現在:OFF)", "pets open doors (now Off)");
2269 powers[num++] = PET_OPEN_DOORS;
2271 if (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS)
2273 power_desc[num] = _("アイテムを拾う (現在:ON)", "pets pick up items (now On)");
2277 power_desc[num] = _("アイテムを拾う (現在:OFF)", "pets pick up items (now Off)");
2279 powers[num++] = PET_TAKE_ITEMS;
2281 if (p_ptr->pet_extra_flags & PF_TELEPORT)
2283 power_desc[num] = _("テレポート系魔法を使う (現在:ON)", "allow teleport (now On)");
2287 power_desc[num] = _("テレポート系魔法を使う (現在:OFF)", "allow teleport (now Off)");
2289 powers[num++] = PET_TELEPORT;
2291 if (p_ptr->pet_extra_flags & PF_ATTACK_SPELL)
2293 power_desc[num] = _("攻撃魔法を使う (現在:ON)", "allow cast attack spell (now On)");
2297 power_desc[num] = _("攻撃魔法を使う (現在:OFF)", "allow cast attack spell (now Off)");
2299 powers[num++] = PET_ATTACK_SPELL;
2301 if (p_ptr->pet_extra_flags & PF_SUMMON_SPELL)
2303 power_desc[num] = _("召喚魔法を使う (現在:ON)", "allow cast summon spell (now On)");
2307 power_desc[num] = _("召喚魔法を使う (現在:OFF)", "allow cast summon spell (now Off)");
2309 powers[num++] = PET_SUMMON_SPELL;
2311 if (p_ptr->pet_extra_flags & PF_BALL_SPELL)
2313 power_desc[num] = _("プレイヤーを巻き込む範囲魔法を使う (現在:ON)", "allow involve player in area spell (now On)");
2317 power_desc[num] = _("プレイヤーを巻き込む範囲魔法を使う (現在:OFF)", "allow involve player in area spell (now Off)");
2319 powers[num++] = PET_BALL_SPELL;
2323 power_desc[num] = _("ペットから降りる", "get off a pet");
2327 power_desc[num] = _("ペットに乗る", "ride a pet");
2329 powers[num++] = PET_RIDING;
2330 power_desc[num] = _("ペットに名前をつける", "name pets");
2331 powers[num++] = PET_NAME;
2335 if ((p_ptr->migite && (empty_hands(FALSE) == EMPTY_HAND_LARM) &&
2336 object_allow_two_hands_wielding(&inventory[INVEN_RARM])) ||
2337 (p_ptr->hidarite && (empty_hands(FALSE) == EMPTY_HAND_RARM) &&
2338 object_allow_two_hands_wielding(&inventory[INVEN_LARM])))
2340 if (p_ptr->pet_extra_flags & PF_RYOUTE)
2342 power_desc[num] = _("武器を片手で持つ", "use one hand to control a riding pet");
2346 power_desc[num] = _("武器を両手で持つ", "use both hands for a weapon");
2349 powers[num++] = PET_RYOUTE;
2353 switch (p_ptr->pclass)
2356 case CLASS_FORCETRAINER:
2357 case CLASS_BERSERKER:
2358 if (empty_hands(FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
2360 if (p_ptr->pet_extra_flags & PF_RYOUTE)
2362 power_desc[num] = _("片手で格闘する", "use one hand to control a riding pet");
2366 power_desc[num] = _("両手で格闘する", "use both hands for melee");
2369 powers[num++] = PET_RYOUTE;
2371 else if ((empty_hands(FALSE) != EMPTY_HAND_NONE) && !buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
2373 if (p_ptr->pet_extra_flags & PF_RYOUTE)
2375 power_desc[num] = _("格闘を行わない", "use one hand to control a riding pet");
2379 power_desc[num] = _("格闘を行う", "use one hand for melee");
2382 powers[num++] = PET_RYOUTE;
2390 if (!(repeat_pull(&i) && (i >= 0) && (i < num)))
2392 #endif /* ALLOW_REPEAT */
2394 /* Nothing chosen yet */
2402 /* Save the screen */
2405 /* Build a prompt */
2406 strnfmt(out_val, 78, _("(コマンド、ESC=終了) コマンドを選んでください:", "(Command, ESC=exit) Choose command from menu."));
2410 /* Build a prompt */
2411 strnfmt(out_val, 78,
2412 _("(コマンド %c-%c、'*'=一覧、ESC=終了) コマンドを選んでください:", "(Command %c-%c, *=List, ESC=exit) Select a command: "),
2413 I2A(0), I2A(num - 1));
2416 choice = (always_show_list || use_menu) ? ESCAPE : 1;
2418 /* Get a command from the user */
2423 if (choice == ESCAPE) choice = ' ';
2424 else if (!get_com(out_val, &choice, TRUE)) break;
2426 if (use_menu && (choice != ' '))
2437 menu_line += (num - 1);
2466 if (menu_line > num) menu_line -= num;
2469 /* Request redraw */
2470 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
2473 if (!redraw || use_menu)
2481 /* Save the screen */
2482 if (!use_menu) screen_save();
2487 for (ctr = 0; ctr < num; ctr++)
2489 /* Letter/number for power selection */
2491 sprintf(buf, "%c%s ", (ctr == mode) ? '*' : ' ', (ctr == (menu_line - 1)) ? _("》", "> ") : " ");
2493 sprintf(buf, "%c%c) ", (ctr == mode) ? '*' : ' ', I2A(ctr));
2495 strcat(buf, power_desc[ctr]);
2497 prt(buf, y + ctr, x);
2500 prt("", y + MIN(ctr, 17), x);
2509 /* Restore the screen */
2520 ask = (isupper(choice));
2523 if (ask) choice = tolower(choice);
2525 /* Extract request */
2526 i = (islower(choice) ? A2I(choice) : -1);
2529 /* Totally Illegal */
2530 if ((i < 0) || (i >= num))
2540 strnfmt(buf, 78, _("%sを使いますか? ", "Use %s? "), power_desc[i]);
2542 /* Belay that order */
2543 if (!get_check(buf)) continue;
2550 /* Restore the screen */
2551 if (redraw) screen_load();
2553 /* Abort if needed */
2556 p_ptr->energy_use = 0;
2563 #endif /* ALLOW_REPEAT */
2567 case PET_DISMISS: /* Dismiss pets */
2569 /* Check pets (backwards) */
2570 for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
2572 /* Player has pet */
2573 if (is_pet(&m_list[pet_ctr])) break;
2578 msg_print(_("ペットがいない!", "You have no pets!"));
2581 do_cmd_pet_dismiss();
2582 (void)calculate_upkeep();
2587 project_length = -1;
2588 if (!target_set(TARGET_KILL)) pet_t_m_idx = 0;
2591 cave_type *c_ptr = &cave[target_row][target_col];
2592 if (c_ptr->m_idx && (m_list[c_ptr->m_idx].ml))
2594 pet_t_m_idx = cave[target_row][target_col].m_idx;
2595 p_ptr->pet_follow_distance = PET_DESTROY_DIST;
2597 else pet_t_m_idx = 0;
2604 case PET_STAY_CLOSE:
2606 p_ptr->pet_follow_distance = PET_CLOSE_DIST;
2613 p_ptr->pet_follow_distance = PET_FOLLOW_DIST;
2617 /* "Seek and destoy" */
2618 case PET_SEEK_AND_DESTROY:
2620 p_ptr->pet_follow_distance = PET_DESTROY_DIST;
2623 /* "Give me space" */
2624 case PET_ALLOW_SPACE:
2626 p_ptr->pet_follow_distance = PET_SPACE_DIST;
2632 p_ptr->pet_follow_distance = PET_AWAY_DIST;
2635 /* flag - allow pets to open doors */
2636 case PET_OPEN_DOORS:
2638 if (p_ptr->pet_extra_flags & PF_OPEN_DOORS) p_ptr->pet_extra_flags &= ~(PF_OPEN_DOORS);
2639 else p_ptr->pet_extra_flags |= (PF_OPEN_DOORS);
2642 /* flag - allow pets to pickup items */
2643 case PET_TAKE_ITEMS:
2645 if (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS)
2647 p_ptr->pet_extra_flags &= ~(PF_PICKUP_ITEMS);
2648 for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
2650 /* Access the monster */
2651 m_ptr = &m_list[pet_ctr];
2655 monster_drop_carried_objects(m_ptr);
2659 else p_ptr->pet_extra_flags |= (PF_PICKUP_ITEMS);
2663 /* flag - allow pets to teleport */
2666 if (p_ptr->pet_extra_flags & PF_TELEPORT) p_ptr->pet_extra_flags &= ~(PF_TELEPORT);
2667 else p_ptr->pet_extra_flags |= (PF_TELEPORT);
2670 /* flag - allow pets to cast attack spell */
2671 case PET_ATTACK_SPELL:
2673 if (p_ptr->pet_extra_flags & PF_ATTACK_SPELL) p_ptr->pet_extra_flags &= ~(PF_ATTACK_SPELL);
2674 else p_ptr->pet_extra_flags |= (PF_ATTACK_SPELL);
2677 /* flag - allow pets to cast attack spell */
2678 case PET_SUMMON_SPELL:
2680 if (p_ptr->pet_extra_flags & PF_SUMMON_SPELL) p_ptr->pet_extra_flags &= ~(PF_SUMMON_SPELL);
2681 else p_ptr->pet_extra_flags |= (PF_SUMMON_SPELL);
2684 /* flag - allow pets to cast attack spell */
2685 case PET_BALL_SPELL:
2687 if (p_ptr->pet_extra_flags & PF_BALL_SPELL) p_ptr->pet_extra_flags &= ~(PF_BALL_SPELL);
2688 else p_ptr->pet_extra_flags |= (PF_BALL_SPELL);
2694 (void)do_riding(FALSE);
2706 if (p_ptr->pet_extra_flags & PF_RYOUTE) p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
2707 else p_ptr->pet_extra_flags |= (PF_RYOUTE);
2708 p_ptr->update |= (PU_BONUS);