4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Spell/Prayer commands */
15 cptr spell_category_name(int tval)
20 case TV_HISSATSU_BOOK:
29 case TV_HISSATSU_BOOK:
42 * Allow user to choose a spell/prayer from the given book.
44 * If a valid spell is chosen, saves it in '*sn' and returns TRUE
45 * If the user hits escape, returns FALSE, and set '*sn' to -1
46 * If there are no legal choices, returns FALSE, and sets '*sn' to -2
48 * The "prompt" should be "cast", "recite", or "study"
49 * The "known" should be TRUE for cast/pray, FALSE for study
52 bool select_the_force = FALSE;
54 static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm)
62 bool flag, redraw, okay;
70 int menu_line = (use_menu ? 1 : 0);
72 #ifdef ALLOW_REPEAT /* TNB */
74 /* Get the spell, if available */
77 /* Verify the spell */
78 if (spell_okay(*sn, learned, FALSE, use_realm))
85 #endif /* ALLOW_REPEAT -- TNB */
87 p = spell_category_name(mp_ptr->spell_book);
90 for (spell = 0; spell < 32; spell++)
92 /* Check for this spell */
93 if ((fake_spell_flags[sval] & (1L << spell)))
95 /* Collect this spell */
96 spells[num++] = spell;
100 /* Assume no usable spells */
103 /* Assume no spells available */
106 /* Check for "okay" spells */
107 for (i = 0; i < num; i++)
109 /* Look for "okay" spells */
110 if (spell_okay(spells[i], learned, FALSE, use_realm)) okay = TRUE;
113 /* No "okay" spells */
114 if (!okay) return (FALSE);
115 if (((use_realm) != p_ptr->realm1) && ((use_realm) != p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return FALSE;
116 if (((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) && !is_magic(use_realm)) return FALSE;
117 if ((p_ptr->pclass == CLASS_RED_MAGE) && ((use_realm) != REALM_ARCANE) && (sval > 1)) return FALSE;
119 /* Assume cancelled */
122 /* Nothing chosen yet */
129 p_ptr->window |= (PW_SPELL);
134 /* Build a prompt (accept all spells) */
136 jverb1( prompt, jverb_buf );
137 (void) strnfmt(out_val, 78, "(%^s:%c-%c, '*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤Î%s¤ò%^s¤Þ¤¹¤«? ",
138 p, I2A(0), I2A(num - 1), p, jverb_buf );
140 (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) %^s which %s? ",
141 p, I2A(0), I2A(num - 1), prompt, p);
144 /* Get a spell from the user */
146 choice = (always_show_list || use_menu) ? ESCAPE : 1;
149 if (choice == ESCAPE) choice = ' ';
150 else if (!get_com(out_val, &choice, TRUE))break;
152 if (use_menu && choice != ' ')
166 menu_line += (num - 1);
188 if (menu_line > num) menu_line -= num;
189 /* Display a list of spells */
190 print_spells(menu_line, spells, num, 1, 15, use_realm);
196 if ((choice == ' ') || (choice == '*') || (choice == '?'))
204 /* Save the screen */
207 /* Display a list of spells */
208 print_spells(menu_line, spells, num, 1, 15, use_realm);
214 if (use_menu) continue;
219 /* Restore the screen */
229 ask = (isupper(choice));
232 if (ask) choice = tolower(choice);
234 /* Extract request */
235 i = (islower(choice) ? A2I(choice) : -1);
238 /* Totally Illegal */
239 if ((i < 0) || (i >= num))
245 /* Save the spell index */
248 /* Require "okay" spells */
249 if (!spell_okay(spell, learned, FALSE, use_realm))
253 msg_format("¤½¤Î%s¤ò%s¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£", p, prompt);
255 msg_format("You may not %s that %s.", prompt, p);
266 /* Access the spell */
267 if (!is_magic(use_realm))
269 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
273 s_ptr = &mp_ptr->info[use_realm - 1][spell];
276 /* Extract mana consumption rate */
277 if (use_realm == REALM_HISSATSU)
279 need_mana = s_ptr->smana;
283 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
288 jverb1( prompt, jverb_buf );
289 /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½¤ËÂбþ */
290 (void) strnfmt(tmp_val, 78, "%s(MP%d, ¼ºÇÔΨ%d%%)¤ò%s¤Þ¤¹¤«? ",
291 do_spell(use_realm, spell, SPELL_NAME), need_mana,
292 spell_chance(spell, use_realm),jverb_buf);
294 (void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ",
295 prompt, do_spell(use_realm, spell, SPELL_NAME), need_mana,
296 spell_chance(spell, use_realm));
300 /* Belay that order */
301 if (!get_check(tmp_val)) continue;
309 /* Restore the screen */
310 if (redraw) screen_load();
314 p_ptr->window |= (PW_SPELL);
320 /* Abort if needed */
321 if (!flag) return FALSE;
323 /* Save the choice */
326 #ifdef ALLOW_REPEAT /* TNB */
330 #endif /* ALLOW_REPEAT -- TNB */
337 static bool item_tester_learn_spell(object_type *o_ptr)
339 s32b choices = realm_choices2[p_ptr->pclass];
341 if (p_ptr->pclass == CLASS_PRIEST)
343 if (is_good_realm(p_ptr->realm1))
345 choices &= ~(CH_DEATH | CH_DAEMON);
349 choices &= ~(CH_LIFE | CH_CRUSADE);
353 if ((o_ptr->tval < TV_LIFE_BOOK) || (o_ptr->tval > (TV_LIFE_BOOK + MAX_REALM - 1))) return (FALSE);
354 if ((o_ptr->tval == TV_MUSIC_BOOK) && (p_ptr->pclass == CLASS_BARD)) return (TRUE);
355 else if (!is_magic(tval2realm(o_ptr->tval))) return FALSE;
356 if ((REALM1_BOOK == o_ptr->tval) || (REALM2_BOOK == o_ptr->tval)) return (TRUE);
357 if (choices & (0x0001 << (tval2realm(o_ptr->tval) - 1))) return (TRUE);
362 static bool player_has_no_spellbooks(void)
367 for (i = 0; i < INVEN_PACK; i++)
369 o_ptr = &inventory[i];
370 if (o_ptr->k_idx && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
373 for (i = cave[py][px].o_idx; i; i = o_ptr->next_o_idx)
376 if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
383 static void confirm_use_force(bool browse_only)
390 /* Get the item index */
391 if (repeat_pull(&item) && (item == INVEN_FORCE))
393 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
397 #endif /* ALLOW_REPEAT */
399 /* Show the prompt */
401 prt("('w'Îýµ¤½Ñ, ESC) 'w'¤«ESC¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤¡£ ", 0, 0);
403 prt("(w for the Force, ESC) Hit 'w' or ESC. ", 0, 0);
411 if (which == ESCAPE) break;
412 else if (which == 'w')
417 repeat_push(INVEN_FORCE);
419 #endif /* ALLOW_REPEAT */
425 /* Clear the prompt line */
430 browse_only ? do_cmd_mind_browse() : do_cmd_mind();
436 * Peruse the spells/prayers in a book
438 * Note that *all* spells in the book are listed
440 * Note that browsing is allowed while confused or blind,
441 * and in the dark, primarily to allow browsing in stores.
443 void do_cmd_browse(void)
445 int item, sval, use_realm = 0, j, line;
456 /* Warriors are illiterate */
457 if (!(p_ptr->realm1 || p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
460 msg_print("ËܤòÆɤळ¤È¤¬¤Ç¤¤Ê¤¤¡ª");
462 msg_print("You cannot read books!");
468 if (p_ptr->special_defense & KATA_MUSOU)
470 set_action(ACTION_NONE);
473 if (p_ptr->pclass == CLASS_FORCETRAINER)
475 if (player_has_no_spellbooks())
477 confirm_use_force(TRUE);
480 select_the_force = TRUE;
483 /* Restrict choices to "useful" books */
484 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
485 else item_tester_hook = item_tester_learn_spell;
489 q = "¤É¤ÎËܤòÆɤߤޤ¹¤«? ";
491 q = "Browse which book? ";
495 s = "Æɤá¤ëËܤ¬¤Ê¤¤¡£";
497 s = "You have no books that you can read.";
500 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
502 select_the_force = FALSE;
505 select_the_force = FALSE;
507 if (item == INVEN_FORCE) /* the_force */
509 do_cmd_mind_browse();
513 /* Get the item (in the pack) */
516 o_ptr = &inventory[item];
519 /* Get the item (on the floor) */
522 o_ptr = &o_list[0 - item];
525 /* Access the item's sval */
528 use_realm = tval2realm(o_ptr->tval);
530 /* Track the object kind */
531 object_kind_track(o_ptr->k_idx);
533 /* Hack -- Handle stuff */
538 for (spell = 0; spell < 32; spell++)
540 /* Check for this spell */
541 if ((fake_spell_flags[sval] & (1L << spell)))
543 /* Collect this spell */
544 spells[num++] = spell;
549 /* Save the screen */
552 /* Clear the top line */
555 /* Keep browsing spells. Exit browsing on cancel. */
558 /* Ask for a spell, allow cancel */
560 if (!get_spell(&spell, "Æɤà", o_ptr->sval, TRUE, use_realm))
562 if (!get_spell(&spell, "browse", o_ptr->sval, TRUE, use_realm))
565 /* If cancelled, leave immediately. */
566 if (spell == -1) break;
568 /* Display a list of spells */
569 print_spells(0, spells, num, 1, 15, use_realm);
571 /* Notify that there's nothing to see, and wait. */
572 if (use_realm == REALM_HISSATSU)
574 prt("Æɤá¤ëµ»¤¬¤Ê¤¤¡£", 0, 0);
576 prt("No techniques to browse.", 0, 0);
580 prt("Æɤá¤ë¼öʸ¤¬¤Ê¤¤¡£", 0, 0);
582 prt("No spells to browse.", 0, 0);
587 /* Restore the screen */
593 /* Clear lines, position cursor (really should use strlen here) */
594 Term_erase(14, 14, 255);
595 Term_erase(14, 13, 255);
596 Term_erase(14, 12, 255);
597 Term_erase(14, 11, 255);
599 roff_to_buf(do_spell(use_realm, spell, SPELL_DESC), 62, temp, sizeof(temp));
601 for (j = 0, line = 11; temp[j]; j += 1 + strlen(&temp[j]))
603 prt(&temp[j], line, 15);
608 /* Restore the screen */
613 static void change_realm2(int next_realm)
618 for (i = 0; i < 64; i++)
620 p_ptr->spell_order[j] = p_ptr->spell_order[i];
621 if (p_ptr->spell_order[i] < 32) j++;
624 p_ptr->spell_order[j] = 99;
626 for (i = 32; i < 64; i++)
628 p_ptr->spell_exp[i] = SPELL_EXP_UNSKILLED;
630 p_ptr->spell_learned2 = 0L;
631 p_ptr->spell_worked2 = 0L;
632 p_ptr->spell_forgotten2 = 0L;
635 sprintf(tmp,"ËâË¡¤ÎÎΰè¤ò%s¤«¤é%s¤ËÊѹ¹¤·¤¿¡£", realm_names[p_ptr->realm2], realm_names[next_realm]);
637 sprintf(tmp,"change magic realm from %s to %s.", realm_names[p_ptr->realm2], realm_names[next_realm]);
639 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
640 p_ptr->old_realm |= 1 << (p_ptr->realm2-1);
641 p_ptr->realm2 = next_realm;
643 p_ptr->notice |= (PN_REORDER);
644 p_ptr->update |= (PU_SPELLS);
647 /* Load an autopick preference file */
648 autopick_load_pref(FALSE);
653 * 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);
673 msg_print("ËܤòÆɤळ¤È¤¬¤Ç¤¤Ê¤¤¡ª");
675 msg_print("You cannot read books!");
681 if (p_ptr->blind || no_lite())
684 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡ª");
686 msg_print("You cannot see!");
695 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡ª");
697 msg_print("You are too confused!");
703 if (!(p_ptr->new_spells))
706 msg_format("¿·¤·¤¤%s¤ò³Ð¤¨¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡ª", p);
708 msg_format("You cannot learn any new %ss!", p);
714 if (p_ptr->special_defense & KATA_MUSOU)
716 set_action(ACTION_NONE);
720 if( p_ptr->new_spells < 10 ){
721 msg_format("¤¢¤È %d ¤Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
723 msg_format("¤¢¤È %d ¸Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
726 msg_format("You can learn %d new %s%s.", p_ptr->new_spells, p,
727 (p_ptr->new_spells == 1?"":"s"));
733 /* Restrict choices to "useful" books */
734 if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
735 else item_tester_hook = item_tester_learn_spell;
739 q = "¤É¤ÎËܤ«¤é³Ø¤Ó¤Þ¤¹¤«? ";
741 q = "Study which book? ";
745 s = "Æɤá¤ëËܤ¬¤Ê¤¤¡£";
747 s = "You have no books that you can read.";
750 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
752 /* Get the item (in the pack) */
755 o_ptr = &inventory[item];
758 /* Get the item (on the floor) */
761 o_ptr = &o_list[0 - item];
764 /* Access the item's sval */
767 if (o_ptr->tval == REALM2_BOOK) increment = 32;
768 else if (o_ptr->tval != REALM1_BOOK)
771 if (!get_check("ËÜÅö¤ËËâË¡¤ÎÎΰè¤òÊѹ¹¤·¤Þ¤¹¤«¡©")) return;
773 if (!get_check("Really, change magic realm? ")) return;
775 change_realm2(tval2realm(o_ptr->tval));
779 /* Track the object kind */
780 object_kind_track(o_ptr->k_idx);
782 /* Hack -- Handle stuff */
785 /* Mage -- Learn a selected spell */
786 if (mp_ptr->spell_book != TV_LIFE_BOOK)
788 /* Ask for a spell, allow cancel */
790 if (!get_spell(&spell, "³Ø¤Ö", sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1)
791 && (spell == -1)) return;
793 if (!get_spell(&spell, "study", sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1)
794 && (spell == -1)) return;
799 /* Priest -- Learn a random prayer */
807 for (spell = 0; spell < 32; spell++)
809 /* Check spells in the book */
810 if ((fake_spell_flags[sval] & (1L << spell)))
812 /* Skip non "okay" prayers */
813 if (!spell_okay(spell, FALSE, TRUE,
814 (increment ? p_ptr->realm2 : p_ptr->realm1))) continue;
816 /* Hack -- Prepare the randomizer */
819 /* Hack -- Apply the randomizer */
820 if (one_in_(k)) gift = spell;
828 /* Nothing to study */
833 msg_format("¤½¤ÎËܤˤϳؤ֤٤%s¤¬¤Ê¤¤¡£", p);
835 msg_format("You cannot learn any %ss in that book.", p);
844 if (increment) spell += increment;
846 /* Learn the spell */
849 if (p_ptr->spell_learned1 & (1L << spell)) learned = TRUE;
850 else p_ptr->spell_learned1 |= (1L << spell);
854 if (p_ptr->spell_learned2 & (1L << (spell - 32))) learned = TRUE;
855 else p_ptr->spell_learned2 |= (1L << (spell - 32));
860 int max_exp = (spell < 32) ? SPELL_EXP_MASTER : SPELL_EXP_EXPERT;
861 int old_exp = p_ptr->spell_exp[spell];
862 int new_rank = EXP_LEVEL_UNSKILLED;
863 cptr name = do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell%32, SPELL_NAME);
865 if (old_exp >= max_exp)
868 msg_format("¤½¤Î%s¤Ï´°Á´¤Ë»È¤¤¤³¤Ê¤»¤ë¤Î¤Ç³Ø¤ÖɬÍפϤʤ¤¡£", p);
870 msg_format("You don't need to study this %s anymore.", p);
875 if (!get_check(format("%s¤Î%s¤ò¤µ¤é¤Ë³Ø¤Ó¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡©", name, p)))
877 if (!get_check(format("You will study a %s of %s again. Are you sure? ", p, name)))
882 else if (old_exp >= SPELL_EXP_EXPERT)
884 p_ptr->spell_exp[spell] = SPELL_EXP_MASTER;
885 new_rank = EXP_LEVEL_MASTER;
887 else if (old_exp >= SPELL_EXP_SKILLED)
889 if (spell >= 32) p_ptr->spell_exp[spell] = SPELL_EXP_EXPERT;
890 else p_ptr->spell_exp[spell] += SPELL_EXP_EXPERT - SPELL_EXP_SKILLED;
891 new_rank = EXP_LEVEL_EXPERT;
893 else if (old_exp >= SPELL_EXP_BEGINNER)
895 p_ptr->spell_exp[spell] = SPELL_EXP_SKILLED + (old_exp - SPELL_EXP_BEGINNER) * 2 / 3;
896 new_rank = EXP_LEVEL_SKILLED;
900 p_ptr->spell_exp[spell] = SPELL_EXP_BEGINNER + old_exp / 3;
901 new_rank = EXP_LEVEL_BEGINNER;
904 msg_format("%s¤Î½ÏÎýÅÙ¤¬%s¤Ë¾å¤¬¤Ã¤¿¡£", name, exp_level_str[new_rank]);
906 msg_format("Your proficiency of %s is now %s rank.", name, exp_level_str[new_rank]);
911 /* Find the next open entry in "p_ptr->spell_order[]" */
912 for (i = 0; i < 64; i++)
914 /* Stop at the first empty space */
915 if (p_ptr->spell_order[i] == 99) break;
918 /* Add the spell to the known list */
919 p_ptr->spell_order[i++] = spell;
921 /* Mention the result */
923 /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½¤ËÂбþ */
924 if (mp_ptr->spell_book == TV_MUSIC_BOOK)
926 msg_format("%s¤ò³Ø¤ó¤À¡£",
927 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
931 msg_format("%s¤Î%s¤ò³Ø¤ó¤À¡£",
932 do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME) ,p);
935 msg_format("You have learned the %s of %s.",
936 p, do_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
943 switch (mp_ptr->spell_book)
946 chg_virtue(V_FAITH, 1);
949 chg_virtue(V_UNLIFE, 1);
952 chg_virtue(V_NATURE, 1);
955 chg_virtue(V_KNOWLEDGE, 1);
962 /* One less spell available */
963 p_ptr->learned_spells++;
965 /* Message if needed */
966 if (p_ptr->new_spells)
970 if (p_ptr->new_spells < 10) msg_format("¤¢¤È %d ¤Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
971 else msg_format("¤¢¤È %d ¸Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
973 msg_format("You can learn %d more %s%s.", p_ptr->new_spells, p,
974 (p_ptr->new_spells != 1) ? "s" : "");
980 p_ptr->update |= (PU_SPELLS);
983 /* Redraw object recall */
984 p_ptr->window |= (PW_OBJECT);
988 static void wild_magic(int spell)
991 int type = SUMMON_BIZARRE1 + randint0(6);
993 if (type < SUMMON_BIZARRE1) type = SUMMON_BIZARRE1;
994 else if (type > SUMMON_BIZARRE6) type = SUMMON_BIZARRE6;
996 switch (randint1(spell) + randint1(8) + 1)
1001 teleport_player(10, TELEPORT_PASSIVE);
1006 teleport_player(100, TELEPORT_PASSIVE);
1010 teleport_player(200, TELEPORT_PASSIVE);
1020 lite_area(damroll(2, 3), 2);
1023 destroy_doors_touch();
1028 sleep_monsters_touch();
1032 trap_creation(py, px);
1041 aggravate_monsters(0);
1044 earthquake(py, px, 5);
1048 (void)gain_random_mutation(0);
1052 apply_disenchant(1);
1058 fire_ball(GF_CHAOS, 0, spell + 5, 1 + (spell / 10));
1065 while (counter++ < 8)
1067 (void)summon_specific(0, py, px, (dun_level * 3) / 2, type, (PM_ALLOW_GROUP | PM_NO_PET));
1072 activate_hi_summon(py, px, FALSE);
1075 (void)summon_cyber(-1, py, px);
1080 (void)activate_ty_curse(FALSE, &count);
1092 void do_cmd_cast(void)
1094 int item, sval, spell, realm;
1108 /* Require spell ability */
1109 if (!p_ptr->realm1 && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
1112 msg_print("¼öʸ¤ò¾§¤¨¤é¤ì¤Ê¤¤¡ª");
1114 msg_print("You cannot cast spells!");
1121 if (p_ptr->blind || no_lite())
1123 if (p_ptr->pclass == CLASS_FORCETRAINER) confirm_use_force(FALSE);
1127 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡ª");
1129 msg_print("You cannot see!");
1136 /* Not when confused */
1137 if (p_ptr->confused)
1140 msg_print("º®Í𤷤Ƥ¤¤Æ¾§¤¨¤é¤ì¤Ê¤¤¡ª");
1142 msg_print("You are too confused!");
1148 if (p_ptr->pclass == CLASS_FORCETRAINER)
1150 if (player_has_no_spellbooks())
1152 confirm_use_force(FALSE);
1155 select_the_force = TRUE;
1158 prayer = spell_category_name(mp_ptr->spell_book);
1160 /* Restrict choices to spell books */
1161 item_tester_tval = mp_ptr->spell_book;
1165 q = "¤É¤Î¼öʸ½ñ¤ò»È¤¤¤Þ¤¹¤«? ";
1167 q = "Use which book? ";
1171 s = "¼öʸ½ñ¤¬¤Ê¤¤¡ª";
1173 s = "You have no spell books!";
1176 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
1178 select_the_force = FALSE;
1181 select_the_force = FALSE;
1183 if (item == INVEN_FORCE) /* the_force */
1189 /* Get the item (in the pack) */
1192 o_ptr = &inventory[item];
1195 /* Get the item (on the floor) */
1198 o_ptr = &o_list[0 - item];
1201 /* Access the item's sval */
1204 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && (o_ptr->tval == REALM2_BOOK)) increment = 32;
1207 /* Track the object kind */
1208 object_kind_track(o_ptr->k_idx);
1210 /* Hack -- Handle stuff */
1213 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
1214 realm = o_ptr->tval - TV_LIFE_BOOK + 1;
1215 else if (increment) realm = p_ptr->realm2;
1216 else realm = p_ptr->realm1;
1218 /* Ask for a spell */
1220 if (!get_spell(&spell,
1221 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "±Ó¾§¤¹¤ë" : (mp_ptr->spell_book == TV_MUSIC_BOOK) ? "²Î¤¦" : "¾§¤¨¤ë"),
1224 if (spell == -2) msg_format("¤½¤ÎËܤˤÏÃΤäƤ¤¤ë%s¤¬¤Ê¤¤¡£", prayer);
1228 if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1232 msg_format("You don't know any %ss in that book.", prayer);
1238 use_realm = tval2realm(o_ptr->tval);
1240 if (!is_magic(use_realm))
1242 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
1246 s_ptr = &mp_ptr->info[realm - 1][spell];
1249 /* Extract mana consumption rate */
1250 need_mana = mod_need_mana(s_ptr->smana, spell, realm);
1252 /* Verify "dangerous" spells */
1253 if (need_mana > p_ptr->csp)
1255 if (flush_failure) flush();
1259 msg_format("¤½¤Î%s¤ò%s¤Î¤Ë½½Ê¬¤Ê¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È¤¬¤Ê¤¤¡£",prayer,
1260 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "±Ó¾§¤¹¤ë" : (mp_ptr->spell_book == TV_LIFE_BOOK) ? "²Î¤¦" : "¾§¤¨¤ë"));
1262 msg_format("You do not have enough mana to %s this %s.",
1263 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1268 if (!over_exert) return;
1272 if (!get_check_strict("¤½¤ì¤Ç¤âÄ©À路¤Þ¤¹¤«? ", CHECK_OKAY_CANCEL)) return;
1274 if (!get_check_strict("Attempt it anyway? ", CHECK_OKAY_CANCEL)) return;
1280 /* Spell failure chance */
1281 chance = spell_chance(spell, use_realm);
1284 if (randint0(100) < chance)
1286 if (flush_failure) flush();
1289 msg_format("%s¤ò¤¦¤Þ¤¯¾§¤¨¤é¤ì¤Ê¤«¤Ã¤¿¡ª", prayer);
1291 msg_format("You failed to get the %s off!", prayer);
1299 if (randint1(100) < chance) chg_virtue(V_VITALITY, -1);
1302 if (randint1(100) < chance) chg_virtue(V_UNLIFE, -1);
1305 if (randint1(100) < chance) chg_virtue(V_NATURE, -1);
1308 if (randint1(100) < chance) chg_virtue(V_JUSTICE, 1);
1311 if (randint1(100) < chance) chg_virtue(V_JUSTICE, -1);
1314 if (randint1(100) < chance) chg_virtue(V_KNOWLEDGE, -1);
1318 /* Failure casting may activate some side effect */
1319 do_spell(realm, spell, SPELL_FAIL);
1322 if ((o_ptr->tval == TV_CHAOS_BOOK) && (randint1(100) < spell))
1325 msg_print("¥«¥ª¥¹Åª¤Ê¸ú²Ì¤òȯÀ¸¤·¤¿¡ª");
1327 msg_print("You produce a chaotic effect!");
1332 else if ((o_ptr->tval == TV_DEATH_BOOK) && (randint1(100) < spell))
1334 if ((sval == 3) && one_in_(2))
1336 sanity_blast(0, TRUE);
1341 msg_print("Äˤ¤¡ª");
1343 msg_print("It hurts!");
1347 take_hit(DAMAGE_LOSELIFE, damroll(o_ptr->sval + 1, 6), "°Å¹õËâË¡¤ÎµÕή", -1);
1349 take_hit(DAMAGE_LOSELIFE, damroll(o_ptr->sval + 1, 6), "a miscast Death spell", -1);
1352 if ((spell > 15) && one_in_(6) && !p_ptr->hold_life)
1353 lose_exp(spell * 250);
1356 else if ((o_ptr->tval == TV_MUSIC_BOOK) && (randint1(200) < spell))
1359 msg_print("¤¤¤ä¤Ê²»¤¬¶Á¤¤¤¿");
1361 msg_print("An infernal sound echoed.");
1364 aggravate_monsters(0);
1366 if (randint1(100) >= chance)
1367 chg_virtue(V_CHANCE,-1);
1373 /* Canceled spells cost neither a turn nor mana */
1374 if (!do_spell(realm, spell, SPELL_CAST)) return;
1376 if (randint1(100) < chance)
1377 chg_virtue(V_CHANCE,1);
1379 /* A spell was cast */
1381 (p_ptr->spell_worked2 & (1L << spell)) :
1382 (p_ptr->spell_worked1 & (1L << spell)))
1383 && (p_ptr->pclass != CLASS_SORCERER)
1384 && (p_ptr->pclass != CLASS_RED_MAGE))
1386 int e = s_ptr->sexp;
1388 /* The spell worked */
1389 if (realm == p_ptr->realm1)
1391 p_ptr->spell_worked1 |= (1L << spell);
1395 p_ptr->spell_worked2 |= (1L << spell);
1398 /* Gain experience */
1399 gain_exp(e * s_ptr->slevel);
1401 /* Redraw object recall */
1402 p_ptr->window |= (PW_OBJECT);
1407 chg_virtue(V_TEMPERANCE, 1);
1408 chg_virtue(V_COMPASSION, 1);
1409 chg_virtue(V_VITALITY, 1);
1410 chg_virtue(V_DILIGENCE, 1);
1413 chg_virtue(V_UNLIFE, 1);
1414 chg_virtue(V_JUSTICE, -1);
1415 chg_virtue(V_FAITH, -1);
1416 chg_virtue(V_VITALITY, -1);
1419 chg_virtue(V_JUSTICE, -1);
1420 chg_virtue(V_FAITH, -1);
1421 chg_virtue(V_HONOUR, -1);
1422 chg_virtue(V_TEMPERANCE, -1);
1425 chg_virtue(V_FAITH, 1);
1426 chg_virtue(V_JUSTICE, 1);
1427 chg_virtue(V_SACRIFICE, 1);
1428 chg_virtue(V_HONOUR, 1);
1431 chg_virtue(V_NATURE, 1);
1432 chg_virtue(V_HARMONY, 1);
1435 chg_virtue(V_KNOWLEDGE, 1);
1442 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, 1);
1443 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, 1);
1444 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, 1);
1445 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_DILIGENCE, 1);
1448 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_UNLIFE, 1);
1449 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1450 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1451 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, -1);
1454 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
1455 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
1456 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
1457 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, -1);
1460 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, 1);
1461 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, 1);
1462 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_SACRIFICE, 1);
1463 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, 1);
1466 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_NATURE, 1);
1467 if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HARMONY, 1);
1470 if (mp_ptr->spell_xtra & MAGIC_GAIN_EXP)
1472 s16b cur_exp = p_ptr->spell_exp[(increment ? 32 : 0)+spell];
1475 if (cur_exp < SPELL_EXP_BEGINNER)
1477 else if (cur_exp < SPELL_EXP_SKILLED)
1479 if ((dun_level > 4) && ((dun_level + 10) > p_ptr->lev))
1482 else if (cur_exp < SPELL_EXP_EXPERT)
1484 if (((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel))
1487 else if ((cur_exp < SPELL_EXP_MASTER) && !increment)
1489 if (((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel))
1492 p_ptr->spell_exp[(increment ? 32 : 0) + spell] += exp_gain;
1499 /* Sufficient mana */
1500 if (need_mana <= p_ptr->csp)
1503 p_ptr->csp -= need_mana;
1506 /* Over-exert the player */
1509 int oops = need_mana;
1513 p_ptr->csp_frac = 0;
1517 msg_print("Àº¿À¤ò½¸Ã椷¤¹¤®¤Æµ¤¤ò¼º¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
1519 msg_print("You faint from the effort!");
1523 /* Hack -- Bypass free action */
1524 (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
1529 chg_virtue(V_VITALITY, -10);
1532 chg_virtue(V_UNLIFE, -10);
1535 chg_virtue(V_JUSTICE, 10);
1538 chg_virtue(V_NATURE, -10);
1541 chg_virtue(V_JUSTICE, -10);
1544 chg_virtue(V_KNOWLEDGE, -10);
1548 /* Damage CON (possibly permanently) */
1549 if (randint0(100) < 50)
1551 bool perm = (randint0(100) < 25);
1555 msg_print("ÂΤò°¤¯¤·¤Æ¤·¤Þ¤Ã¤¿¡ª");
1557 msg_print("You have damaged your health!");
1561 /* Reduce constitution */
1562 (void)dec_stat(A_CON, 15 + randint1(10), perm);
1567 p_ptr->redraw |= (PR_MANA);
1570 p_ptr->window |= (PW_PLAYER);
1571 p_ptr->window |= (PW_SPELL);
1575 static bool ang_sort_comp_pet_dismiss(vptr u, vptr v, int a, int b)
1577 u16b *who = (u16b*)(u);
1582 monster_type *m_ptr1 = &m_list[w1];
1583 monster_type *m_ptr2 = &m_list[w2];
1584 monster_race *r_ptr1 = &r_info[m_ptr1->r_idx];
1585 monster_race *r_ptr2 = &r_info[m_ptr2->r_idx];
1590 if (w1 == p_ptr->riding) return TRUE;
1591 if (w2 == p_ptr->riding) return FALSE;
1593 if (m_ptr1->nickname && !m_ptr2->nickname) return TRUE;
1594 if (m_ptr2->nickname && !m_ptr1->nickname) return FALSE;
1596 if (!m_ptr1->parent_m_idx && m_ptr2->parent_m_idx) return TRUE;
1597 if (!m_ptr2->parent_m_idx && m_ptr1->parent_m_idx) return FALSE;
1599 if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return TRUE;
1600 if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return FALSE;
1602 if (r_ptr1->level > r_ptr2->level) return TRUE;
1603 if (r_ptr2->level > r_ptr1->level) return FALSE;
1605 if (m_ptr1->hp > m_ptr2->hp) return TRUE;
1606 if (m_ptr2->hp > m_ptr1->hp) return FALSE;
1611 void check_pets_num_and_align(monster_type *m_ptr, bool inc)
1613 s32b old_friend_align = friend_align;
1614 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1619 if (r_ptr->flags3 & RF3_GOOD) friend_align += r_ptr->level;
1620 if (r_ptr->flags3 & RF3_EVIL) friend_align -= r_ptr->level;
1625 if (r_ptr->flags3 & RF3_GOOD) friend_align -= r_ptr->level;
1626 if (r_ptr->flags3 & RF3_EVIL) friend_align += r_ptr->level;
1629 if (old_friend_align != friend_align) p_ptr->update |= (PU_BONUS);
1632 int calculate_upkeep(void)
1634 s32b old_friend_align = friend_align;
1636 bool have_a_unique = FALSE;
1637 s32b total_friend_levels = 0;
1642 for (m_idx = m_max - 1; m_idx >=1; m_idx--)
1644 monster_type *m_ptr;
1645 monster_race *r_ptr;
1647 m_ptr = &m_list[m_idx];
1648 if (!m_ptr->r_idx) continue;
1649 r_ptr = &r_info[m_ptr->r_idx];
1654 if (r_ptr->flags1 & RF1_UNIQUE)
1656 if (p_ptr->pclass == CLASS_CAVALRY)
1658 if (p_ptr->riding == m_idx)
1659 total_friend_levels += (r_ptr->level+5)*2;
1660 else if (!have_a_unique && (r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
1661 total_friend_levels += (r_ptr->level+5)*7/2;
1663 total_friend_levels += (r_ptr->level+5)*10;
1664 have_a_unique = TRUE;
1667 total_friend_levels += (r_ptr->level+5)*10;
1670 total_friend_levels += r_ptr->level;
1672 /* Determine pet alignment */
1673 if (r_ptr->flags3 & RF3_GOOD) friend_align += r_ptr->level;
1674 if (r_ptr->flags3 & RF3_EVIL) friend_align -= r_ptr->level;
1677 if (old_friend_align != friend_align) p_ptr->update |= (PU_BONUS);
1681 upkeep_factor = (total_friend_levels - (p_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
1682 if (upkeep_factor < 0) upkeep_factor = 0;
1683 if (upkeep_factor > 1000) upkeep_factor = 1000;
1684 return upkeep_factor;
1690 void do_cmd_pet_dismiss(void)
1692 monster_type *m_ptr;
1693 bool all_pets = FALSE;
1707 /* Allocate the "who" array */
1708 C_MAKE(who, max_m_idx, u16b);
1710 /* Process the monsters (backwards) */
1711 for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
1713 if (is_pet(&m_list[pet_ctr]))
1714 who[max_pet++] = pet_ctr;
1717 /* Select the sort method */
1718 ang_sort_comp = ang_sort_comp_pet_dismiss;
1719 ang_sort_swap = ang_sort_swap_hook;
1721 ang_sort(who, &dummy_why, max_pet);
1723 /* Process the monsters (backwards) */
1724 for (i = 0; i < max_pet; i++)
1727 char friend_name[80];
1731 /* Access the monster */
1733 m_ptr = &m_list[pet_ctr];
1735 delete_this = FALSE;
1736 kakunin = ((pet_ctr == p_ptr->riding) || (m_ptr->nickname));
1737 monster_desc(friend_name, m_ptr, MD_ASSUME_VISIBLE);
1741 /* Hack -- health bar for this monster */
1742 health_track(pet_ctr);
1744 /* Hack -- handle stuff */
1748 sprintf(buf, "%s¤òÊü¤·¤Þ¤¹¤«¡© [Yes/No/Unnamed (%dÂÎ)]", friend_name, max_pet - i);
1750 sprintf(buf, "Dismiss %s? [Yes/No/Unnamed (%d remain)]", friend_name, max_pet - i);
1755 move_cursor_relative(m_ptr->fy, m_ptr->fx);
1761 if (ch == 'Y' || ch == 'y')
1768 sprintf(buf, "ËÜÅö¤Ë¤è¤í¤·¤¤¤Ç¤¹¤«¡© (%s) ", friend_name);
1770 sprintf(buf, "Are you sure? (%s) ", friend_name);
1772 if (!get_check(buf))
1773 delete_this = FALSE;
1778 if (ch == 'U' || ch == 'u')
1784 if (ch == ESCAPE || ch == 'N' || ch == 'n')
1791 if ((all_pets && !kakunin) || (!all_pets && delete_this))
1793 if (record_named_pet && m_ptr->nickname)
1797 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1798 do_cmd_write_nikki(NIKKI_NAMED_PET, 2, m_name);
1801 if (pet_ctr == p_ptr->riding)
1804 msg_format("%s¤«¤é¹ß¤ê¤¿¡£", friend_name);
1806 msg_format("You have got off %s. ", friend_name);
1811 /* Update the monsters */
1812 p_ptr->update |= (PU_BONUS | PU_MONSTERS);
1813 p_ptr->redraw |= (PR_EXTRA | PR_UHEALTH);
1816 /* HACK : Add the line to message buffer */
1818 sprintf(buf, "%s ¤òÊü¤·¤¿¡£", friend_name);
1820 sprintf(buf, "Dismissed %s.", friend_name);
1823 p_ptr->window |= (PW_MESSAGE);
1826 delete_monster_idx(pet_ctr);
1835 C_KILL(who, max_m_idx, u16b);
1838 msg_format("%d ÂΤΥڥåȤòÊü¤·¤Þ¤·¤¿¡£", Dismissed);
1840 msg_format("You have dismissed %d pet%s.", Dismissed,
1841 (Dismissed == 1 ? "" : "s"));
1843 if (Dismissed == 0 && all_pets)
1845 msg_print("'U'nnamed ¤Ï¡¢¾èÇϰʳ°¤Î̾Á°¤Î¤Ê¤¤¥Ú¥Ã¥È¤À¤±¤òÁ´¤Æ²òÊü¤·¤Þ¤¹¡£");
1847 msg_print("'U'nnamed means all your pets except named pets and your mount.");
1851 static bool player_can_ride_aux(cave_type *c_ptr, bool now_riding)
1854 bool old_character_xtra = character_xtra;
1855 int old_riding = p_ptr->riding;
1856 bool old_riding_ryoute = p_ptr->riding_ryoute;
1857 bool old_old_riding_ryoute = p_ptr->old_riding_ryoute;
1858 bool old_pf_ryoute = (p_ptr->pet_extra_flags & PF_RYOUTE) ? TRUE : FALSE;
1860 /* Hack -- prevent "icky" message */
1861 character_xtra = TRUE;
1863 if (now_riding) p_ptr->riding = c_ptr->m_idx;
1867 p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
1868 p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
1873 p_can_enter = player_can_enter(c_ptr->feat, CEM_P_CAN_ENTER_PATTERN);
1875 p_ptr->riding = old_riding;
1876 if (old_pf_ryoute) p_ptr->pet_extra_flags |= (PF_RYOUTE);
1877 else p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
1878 p_ptr->riding_ryoute = old_riding_ryoute;
1879 p_ptr->old_riding_ryoute = old_old_riding_ryoute;
1883 character_xtra = old_character_xtra;
1888 bool rakuba(int dam, bool force)
1890 int i, y, x, oy, ox;
1891 int sn = 0, sy = 0, sx = 0;
1893 monster_type *m_ptr = &m_list[p_ptr->riding];
1894 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1895 bool fall_dam = FALSE;
1897 if (!p_ptr->riding) return FALSE;
1898 if (p_ptr->wild_mode) return FALSE;
1900 if (dam >= 0 || force)
1904 int cur = p_ptr->skill_exp[GINOU_RIDING];
1905 int max = s_info[p_ptr->pclass].s_max[GINOU_RIDING];
1906 int ridinglevel = r_ptr->level;
1908 /* ÍîÇϤΤ·¤ä¤¹¤µ */
1909 int rakubalevel = r_ptr->level;
1910 if (p_ptr->riding_ryoute) rakubalevel += 20;
1912 if ((cur < max) && (max > 1000) &&
1913 (dam / 2 + ridinglevel) > (cur / 30 + 10))
1917 if (ridinglevel > (cur / 100 + 15))
1918 inc += 1 + (ridinglevel - cur / 100 - 15);
1922 p_ptr->skill_exp[GINOU_RIDING] = MIN(max, cur + inc);
1925 /* ¥ì¥Ù¥ë¤ÎÄ㤤¾èÇϤ«¤é¤ÏÍîÇϤ·¤Ë¤¯¤¤ */
1926 if (randint0(dam / 2 + rakubalevel * 2) < cur / 30 + 10)
1928 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))
1935 /* Check around the player */
1936 for (i = 0; i < 8; i++)
1940 /* Access the location */
1941 y = py + ddy_ddd[i];
1942 x = px + ddx_ddd[i];
1944 c_ptr = &cave[y][x];
1946 if (c_ptr->m_idx) continue;
1948 /* Skip non-empty grids */
1949 if (!cave_have_flag_grid(c_ptr, FF_MOVE) && !cave_have_flag_grid(c_ptr, FF_CAN_FLY))
1951 if (!player_can_ride_aux(c_ptr, FALSE)) continue;
1954 if (cave_have_flag_grid(c_ptr, FF_PATTERN)) continue;
1956 /* Count "safe" grids */
1959 /* Randomize choice */
1960 if (randint0(sn) > 0) continue;
1962 /* Save the safe location */
1967 monster_desc(m_name, m_ptr, 0);
1969 msg_format("%s¤«¤é¿¶¤êÍî¤È¤µ¤ì¤½¤¦¤Ë¤Ê¤Ã¤Æ¡¢Êɤˤ֤Ĥ«¤Ã¤¿¡£",m_name);
1970 take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, "Êɤؤξ×ÆÍ", -1);
1972 msg_format("You have nearly fallen from %s, but bumped into wall.",m_name);
1973 take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, "bumping into wall", -1);
1984 /* Redraw the old spot */
1987 /* Redraw the new spot */
1990 /* Check for new panel */
1995 p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
1996 p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
2000 p_ptr->update |= (PU_BONUS);
2003 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
2006 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2008 p_ptr->redraw |= (PR_EXTRA);
2010 /* Update health track of mount */
2011 p_ptr->redraw |= (PR_UHEALTH);
2013 if (p_ptr->levitation && !force)
2015 monster_desc(m_name, m_ptr, 0);
2017 msg_format("%s¤«¤éÍî¤Á¤¿¤¬¡¢¶õÃæ¤Ç¤¦¤Þ¤¯ÂÎÀª¤òΩ¤Æľ¤·¤ÆÃåÃϤ·¤¿¡£",m_name);
2019 msg_format("You are thrown from %s, but make a good landing.",m_name);
2025 take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, "ÍîÇÏ", -1);
2027 take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, "Falling from riding", -1);
2032 /* Move the player */
2033 if (sy && !p_ptr->is_dead)
2034 (void)move_player_effect(py, px, MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
2039 bool do_riding(bool force)
2043 monster_type *m_ptr;
2045 if (!get_rep_dir2(&dir)) return FALSE;
2048 c_ptr = &cave[y][x];
2050 if (p_ptr->special_defense & KATA_MUSOU) set_action(ACTION_NONE);
2054 /* Skip non-empty grids */
2055 if (!player_can_ride_aux(c_ptr, FALSE))
2058 msg_print("¤½¤Á¤é¤Ë¤Ï¹ß¤ê¤é¤ì¤Þ¤»¤ó¡£");
2060 msg_print("You cannot go to that direction.");
2065 if (!pattern_seq(py, px, y, x)) return FALSE;
2074 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2076 msg_print("There is a monster in the way!");
2084 p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
2085 p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
2089 if (p_ptr->confused)
2092 msg_print("º®Í𤷤Ƥ¤¤Æ¾è¤ì¤Ê¤¤¡ª");
2094 msg_print("You are too confused!");
2099 m_ptr = &m_list[c_ptr->m_idx];
2101 if (!c_ptr->m_idx || !m_ptr->ml)
2104 msg_print("¤½¤Î¾ì½ê¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
2106 msg_print("Here is no monster.");
2111 if (!is_pet(m_ptr) && !force)
2114 msg_print("¤½¤Î¥â¥ó¥¹¥¿¡¼¤Ï¥Ú¥Ã¥È¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£");
2116 msg_print("That monster is not a pet.");
2121 if (!(r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
2124 msg_print("¤½¤Î¥â¥ó¥¹¥¿¡¼¤Ë¤Ï¾è¤ì¤Ê¤µ¤½¤¦¤À¡£");
2126 msg_print("This monster doesn't seem suitable for riding.");
2132 if (!pattern_seq(py, px, y, x)) return FALSE;
2134 if (!player_can_ride_aux(c_ptr, TRUE))
2136 /* Feature code (applying "mimic" field) */
2137 feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
2139 msg_format("¤½¤Î¥â¥ó¥¹¥¿¡¼¤Ï%s¤Î%s¤Ë¤¤¤ë¡£", f_name + f_ptr->name,
2140 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
2141 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE))) ?
2144 msg_format("This monster is %s the %s.",
2145 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
2146 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE))) ?
2147 "in" : "on", f_name + f_ptr->name);
2152 if (r_info[m_ptr->r_idx].level > randint1((p_ptr->skill_exp[GINOU_RIDING] / 50 + p_ptr->lev / 2 + 20)))
2155 msg_print("¤¦¤Þ¤¯¾è¤ì¤Ê¤«¤Ã¤¿¡£");
2157 msg_print("You failed to ride.");
2165 if (MON_CSLEEP(m_ptr))
2168 monster_desc(m_name, m_ptr, 0);
2169 (void)set_monster_csleep(c_ptr->m_idx, 0);
2171 msg_format("%s¤òµ¯¤³¤·¤¿¡£", m_name);
2173 msg_format("You have waked %s up.", m_name);
2177 if (p_ptr->action == ACTION_KAMAE) set_action(ACTION_NONE);
2179 p_ptr->riding = c_ptr->m_idx;
2181 /* Hack -- remove tracked monster */
2182 if (p_ptr->riding == p_ptr->health_who) health_track(0);
2187 /* Mega-Hack -- Forget the view and lite */
2188 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2190 /* Update the monsters */
2191 p_ptr->update |= (PU_BONUS);
2194 p_ptr->redraw |= (PR_MAP | PR_EXTRA);
2196 p_ptr->redraw |= (PR_UHEALTH);
2198 /* Move the player */
2199 (void)move_player_effect(y, x, MPE_HANDLE_STUFF | MPE_ENERGY_USE | MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
2204 static void do_name_pet(void)
2206 monster_type *m_ptr;
2209 bool old_name = FALSE;
2210 bool old_target_pet = target_pet;
2213 if (!target_set(TARGET_KILL))
2215 target_pet = old_target_pet;
2218 target_pet = old_target_pet;
2220 if (cave[target_row][target_col].m_idx)
2222 m_ptr = &m_list[cave[target_row][target_col].m_idx];
2228 msg_print("¤½¤Î¥â¥ó¥¹¥¿¡¼¤Ï¥Ú¥Ã¥È¤Ç¤Ï¤Ê¤¤¡£");
2230 msg_format("This monster is not a pet.");
2234 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2237 msg_print("¤½¤Î¥â¥ó¥¹¥¿¡¼¤Î̾Á°¤ÏÊѤ¨¤é¤ì¤Ê¤¤¡ª");
2239 msg_format("You cannot change name of this monster!");
2243 monster_desc(m_name, m_ptr, 0);
2247 msg_format("%s¤Ë̾Á°¤ò¤Ä¤±¤ë¡£", m_name);
2249 msg_format("Name %s.", m_name);
2254 /* Start with nothing */
2255 strcpy(out_val, "");
2257 /* Use old inscription */
2258 if (m_ptr->nickname)
2260 /* Start with the old inscription */
2261 strcpy(out_val, quark_str(m_ptr->nickname));
2265 /* Get a new inscription (possibly empty) */
2267 if (get_string("̾Á°: ", out_val, 15))
2269 if (get_string("Name: ", out_val, 15))
2275 /* Save the inscription */
2276 m_ptr->nickname = quark_add(out_val);
2277 if (record_named_pet)
2281 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2282 do_cmd_write_nikki(NIKKI_NAMED_PET, 0, m_name);
2287 if (record_named_pet && old_name)
2291 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2292 do_cmd_write_nikki(NIKKI_NAMED_PET, 1, m_name);
2294 m_ptr->nickname = 0;
2301 * Issue a pet command
2303 void do_cmd_pet(void)
2308 cptr power_desc[36];
2314 monster_type *m_ptr;
2321 char target_buf[160];
2326 power_desc[num] = "¥Ú¥Ã¥È¤òÊü¤¹";
2328 power_desc[num] = "dismiss pets";
2331 powers[num++] = PET_DISMISS;
2334 sprintf(target_buf, "¥Ú¥Ã¥È¤Î¥¿¡¼¥²¥Ã¥È¤ò»ØÄê (¸½ºß¡§%s)",
2335 (pet_t_m_idx ? (p_ptr->image ? "²¿¤«´ñ̯¤Êʪ" : (r_name + r_info[m_list[pet_t_m_idx].ap_r_idx].name)) : "»ØÄê¤Ê¤·"));
2337 sprintf(target_buf, "specify a target of pet (now:%s)",
2338 (pet_t_m_idx ? (p_ptr->image ? "something strange" : (r_name + r_info[m_list[pet_t_m_idx].ap_r_idx].name)) : "nothing"));
2340 power_desc[num] = target_buf;
2342 powers[num++] = PET_TARGET;
2345 power_desc[num] = "¶á¤¯¤Ë¤¤¤í";
2347 power_desc[num] = "stay close";
2350 if (p_ptr->pet_follow_distance == PET_CLOSE_DIST) mode = num;
2351 powers[num++] = PET_STAY_CLOSE;
2354 power_desc[num] = "¤Ä¤¤¤ÆÍ褤";
2356 power_desc[num] = "follow me";
2359 if (p_ptr->pet_follow_distance == PET_FOLLOW_DIST) mode = num;
2360 powers[num++] = PET_FOLLOW_ME;
2363 power_desc[num] = "Ũ¤ò¸«¤Ä¤±¤ÆÅݤ»";
2365 power_desc[num] = "seek and destroy";
2368 if (p_ptr->pet_follow_distance == PET_DESTROY_DIST) mode = num;
2369 powers[num++] = PET_SEEK_AND_DESTROY;
2372 power_desc[num] = "¾¯¤·Î¥¤ì¤Æ¤¤¤í";
2374 power_desc[num] = "give me space";
2377 if (p_ptr->pet_follow_distance == PET_SPACE_DIST) mode = num;
2378 powers[num++] = PET_ALLOW_SPACE;
2381 power_desc[num] = "Î¥¤ì¤Æ¤¤¤í";
2383 power_desc[num] = "stay away";
2386 if (p_ptr->pet_follow_distance == PET_AWAY_DIST) mode = num;
2387 powers[num++] = PET_STAY_AWAY;
2389 if (p_ptr->pet_extra_flags & PF_OPEN_DOORS)
2392 power_desc[num] = "¥É¥¢¤ò³«¤±¤ë (¸½ºß:ON)";
2394 power_desc[num] = "pets open doors (now On)";
2401 power_desc[num] = "¥É¥¢¤ò³«¤±¤ë (¸½ºß:OFF)";
2403 power_desc[num] = "pets open doors (now Off)";
2407 powers[num++] = PET_OPEN_DOORS;
2409 if (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS)
2412 power_desc[num] = "¥¢¥¤¥Æ¥à¤ò½¦¤¦ (¸½ºß:ON)";
2414 power_desc[num] = "pets pick up items (now On)";
2421 power_desc[num] = "¥¢¥¤¥Æ¥à¤ò½¦¤¦ (¸½ºß:OFF)";
2423 power_desc[num] = "pets pick up items (now Off)";
2427 powers[num++] = PET_TAKE_ITEMS;
2429 if (p_ptr->pet_extra_flags & PF_TELEPORT)
2432 power_desc[num] = "¥Æ¥ì¥Ý¡¼¥È·ÏËâË¡¤ò»È¤¦ (¸½ºß:ON)";
2434 power_desc[num] = "allow teleport (now On)";
2441 power_desc[num] = "¥Æ¥ì¥Ý¡¼¥È·ÏËâË¡¤ò»È¤¦ (¸½ºß:OFF)";
2443 power_desc[num] = "allow teleport (now Off)";
2447 powers[num++] = PET_TELEPORT;
2449 if (p_ptr->pet_extra_flags & PF_ATTACK_SPELL)
2452 power_desc[num] = "¹¶·âËâË¡¤ò»È¤¦ (¸½ºß:ON)";
2454 power_desc[num] = "allow cast attack spell (now On)";
2461 power_desc[num] = "¹¶·âËâË¡¤ò»È¤¦ (¸½ºß:OFF)";
2463 power_desc[num] = "allow cast attack spell (now Off)";
2467 powers[num++] = PET_ATTACK_SPELL;
2469 if (p_ptr->pet_extra_flags & PF_SUMMON_SPELL)
2472 power_desc[num] = "¾¤´ËâË¡¤ò»È¤¦ (¸½ºß:ON)";
2474 power_desc[num] = "allow cast summon spell (now On)";
2481 power_desc[num] = "¾¤´ËâË¡¤ò»È¤¦ (¸½ºß:OFF)";
2483 power_desc[num] = "allow cast summon spell (now Off)";
2487 powers[num++] = PET_SUMMON_SPELL;
2489 if (p_ptr->pet_extra_flags & PF_BALL_SPELL)
2492 power_desc[num] = "¥×¥ì¥¤¥ä¡¼¤ò´¬¤¹þ¤àÈÏ°ÏËâË¡¤ò»È¤¦ (¸½ºß:ON)";
2494 power_desc[num] = "allow involve player in area spell (now On)";
2501 power_desc[num] = "¥×¥ì¥¤¥ä¡¼¤ò´¬¤¹þ¤àÈÏ°ÏËâË¡¤ò»È¤¦ (¸½ºß:OFF)";
2503 power_desc[num] = "allow involve player in area spell (now Off)";
2507 powers[num++] = PET_BALL_SPELL;
2512 power_desc[num] = "¥Ú¥Ã¥È¤«¤é¹ß¤ê¤ë";
2514 power_desc[num] = "get off a pet";
2521 power_desc[num] = "¥Ú¥Ã¥È¤Ë¾è¤ë";
2523 power_desc[num] = "ride a pet";
2527 powers[num++] = PET_RIDING;
2530 power_desc[num] = "¥Ú¥Ã¥È¤Ë̾Á°¤ò¤Ä¤±¤ë";
2532 power_desc[num] = "name pets";
2535 powers[num++] = PET_NAME;
2539 if ((p_ptr->migite && (empty_hands(FALSE) == EMPTY_HAND_LARM) &&
2540 object_allow_two_hands_wielding(&inventory[INVEN_RARM])) ||
2541 (p_ptr->hidarite && (empty_hands(FALSE) == EMPTY_HAND_RARM) &&
2542 object_allow_two_hands_wielding(&inventory[INVEN_LARM])))
2544 if (p_ptr->pet_extra_flags & PF_RYOUTE)
2547 power_desc[num] = "Éð´ï¤òÊÒ¼ê¤Ç»ý¤Ä";
2549 power_desc[num] = "use one hand to control a riding pet";
2555 power_desc[num] = "Éð´ï¤òξ¼ê¤Ç»ý¤Ä";
2557 power_desc[num] = "use both hands for a weapon";
2561 powers[num++] = PET_RYOUTE;
2565 switch (p_ptr->pclass)
2568 case CLASS_FORCETRAINER:
2569 case CLASS_BERSERKER:
2570 if (empty_hands(FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
2572 if (p_ptr->pet_extra_flags & PF_RYOUTE)
2575 power_desc[num] = "ÊÒ¼ê¤Ç³ÊÆ®¤¹¤ë";
2577 power_desc[num] = "use one hand to control a riding pet";
2583 power_desc[num] = "ξ¼ê¤Ç³ÊÆ®¤¹¤ë";
2585 power_desc[num] = "use both hands for melee";
2589 powers[num++] = PET_RYOUTE;
2591 else if ((empty_hands(FALSE) != EMPTY_HAND_NONE) && !buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
2593 if (p_ptr->pet_extra_flags & PF_RYOUTE)
2596 power_desc[num] = "³ÊÆ®¤ò¹Ô¤ï¤Ê¤¤";
2598 power_desc[num] = "use one hand to control a riding pet";
2604 power_desc[num] = "³ÊÆ®¤ò¹Ô¤¦";
2606 power_desc[num] = "use one hand for melee";
2610 powers[num++] = PET_RYOUTE;
2617 /* Nothing chosen yet */
2620 /* Build a prompt (accept all spells) */
2623 /* Build a prompt (accept all spells) */
2625 strnfmt(out_val, 78, "(¥³¥Þ¥ó¥É %c-%c¡¢'*'=°ìÍ÷¡¢ESC=½ªÎ») ¥³¥Þ¥ó¥É¤òÁª¤ó¤Ç¤¯¤À¤µ¤¤:",
2627 strnfmt(out_val, 78, "(Command %c-%c, *=List, ESC=exit) Select a command: ",
2630 I2A(0), I2A(num - 1));
2635 strnfmt(out_val, 78, "(¥³¥Þ¥ó¥É %c-%c¡¢'*'=°ìÍ÷¡¢ESC=½ªÎ») ¥³¥Þ¥ó¥É¤òÁª¤ó¤Ç¤¯¤À¤µ¤¤:",
2637 strnfmt(out_val, 78, "(Command %c-%c, *=List, ESC=exit) Select a command: ",
2640 I2A(0), '0' + num - 27);
2646 /* Save the screen */
2653 prt(format("%s%c) %s", (ctr == mode) ? "*" : " ", I2A(ctr), power_desc[ctr]), y + ctr, x);
2659 prt("", y + ctr, x);
2666 /* Get a command from the user */
2667 while (!flag && get_com(out_val, &choice, TRUE))
2669 /* Request redraw */
2670 if ((choice == ' ') || (choice == '*') || (choice == '?'))
2682 /* Save the screen */
2689 sprintf(buf, "%s%c) %s", (ctr == mode) ? "*" : " ", I2A(ctr), power_desc[ctr]);
2690 prt(buf, y + ctr, x);
2696 prt("", y + ctr, x);
2710 /* Restore the screen */
2718 if (isalpha(choice))
2721 ask = (isupper(choice));
2724 if (ask) choice = tolower(choice);
2726 /* Extract request */
2727 i = (islower(choice) ? A2I(choice) : -1);
2731 ask = FALSE; /* Can't uppercase digits */
2733 i = choice - '0' + 26;
2736 /* Totally Illegal */
2737 if ((i < 0) || (i >= num))
2748 strnfmt(buf, 78, "%s¤ò»È¤¤¤Þ¤¹¤«¡© ", power_desc[i]);
2750 strnfmt(buf, 78, "Use %s? ", power_desc[i]);
2754 /* Belay that order */
2755 if (!get_check(buf)) continue;
2762 /* Restore the screen */
2763 if (redraw) Term_load();
2765 /* Abort if needed */
2774 case PET_DISMISS: /* Dismiss pets */
2776 /* Check pets (backwards) */
2777 for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
2779 /* Player has pet */
2780 if (is_pet(&m_list[pet_ctr])) break;
2786 msg_print("¥Ú¥Ã¥È¤¬¤¤¤Ê¤¤¡ª");
2788 msg_print("You have no pets!");
2792 do_cmd_pet_dismiss();
2793 (void)calculate_upkeep();
2798 project_length = -1;
2799 if (!target_set(TARGET_KILL)) pet_t_m_idx = 0;
2802 cave_type *c_ptr = &cave[target_row][target_col];
2803 if (c_ptr->m_idx && (m_list[c_ptr->m_idx].ml))
2805 pet_t_m_idx = cave[target_row][target_col].m_idx;
2806 p_ptr->pet_follow_distance = PET_DESTROY_DIST;
2808 else pet_t_m_idx = 0;
2815 case PET_STAY_CLOSE:
2817 p_ptr->pet_follow_distance = PET_CLOSE_DIST;
2824 p_ptr->pet_follow_distance = PET_FOLLOW_DIST;
2828 /* "Seek and destoy" */
2829 case PET_SEEK_AND_DESTROY:
2831 p_ptr->pet_follow_distance = PET_DESTROY_DIST;
2834 /* "Give me space" */
2835 case PET_ALLOW_SPACE:
2837 p_ptr->pet_follow_distance = PET_SPACE_DIST;
2843 p_ptr->pet_follow_distance = PET_AWAY_DIST;
2846 /* flag - allow pets to open doors */
2847 case PET_OPEN_DOORS:
2849 if (p_ptr->pet_extra_flags & PF_OPEN_DOORS) p_ptr->pet_extra_flags &= ~(PF_OPEN_DOORS);
2850 else p_ptr->pet_extra_flags |= (PF_OPEN_DOORS);
2853 /* flag - allow pets to pickup items */
2854 case PET_TAKE_ITEMS:
2856 if (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS)
2858 p_ptr->pet_extra_flags &= ~(PF_PICKUP_ITEMS);
2859 for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
2861 /* Access the monster */
2862 m_ptr = &m_list[pet_ctr];
2866 monster_drop_carried_objects(m_ptr);
2870 else p_ptr->pet_extra_flags |= (PF_PICKUP_ITEMS);
2874 /* flag - allow pets to teleport */
2877 if (p_ptr->pet_extra_flags & PF_TELEPORT) p_ptr->pet_extra_flags &= ~(PF_TELEPORT);
2878 else p_ptr->pet_extra_flags |= (PF_TELEPORT);
2881 /* flag - allow pets to cast attack spell */
2882 case PET_ATTACK_SPELL:
2884 if (p_ptr->pet_extra_flags & PF_ATTACK_SPELL) p_ptr->pet_extra_flags &= ~(PF_ATTACK_SPELL);
2885 else p_ptr->pet_extra_flags |= (PF_ATTACK_SPELL);
2888 /* flag - allow pets to cast attack spell */
2889 case PET_SUMMON_SPELL:
2891 if (p_ptr->pet_extra_flags & PF_SUMMON_SPELL) p_ptr->pet_extra_flags &= ~(PF_SUMMON_SPELL);
2892 else p_ptr->pet_extra_flags |= (PF_SUMMON_SPELL);
2895 /* flag - allow pets to cast attack spell */
2896 case PET_BALL_SPELL:
2898 if (p_ptr->pet_extra_flags & PF_BALL_SPELL) p_ptr->pet_extra_flags &= ~(PF_BALL_SPELL);
2899 else p_ptr->pet_extra_flags |= (PF_BALL_SPELL);
2905 (void)do_riding(FALSE);
2917 if (p_ptr->pet_extra_flags & PF_RYOUTE) p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
2918 else p_ptr->pet_extra_flags |= (PF_RYOUTE);
2919 p_ptr->update |= (PU_BONUS);