OSDN Git Service

ペット命令メニューを繰り返しコマンドとEnterメニューに対応.
[hengband/hengband.git] / src / cmd5.c
index 8424576..49e67e2 100644 (file)
@@ -27,7 +27,7 @@ cptr spell_category_name(int tval)
                return "¼öʸ";
 #else
        case TV_HISSATSU_BOOK:
-               return "arts";
+               return "art";
        case TV_LIFE_BOOK:
                return "prayer";
        case TV_MUSIC_BOOK:
@@ -998,16 +998,16 @@ static void wild_magic(int spell)
        case 1:
        case 2:
        case 3:
-               teleport_player(10, TRUE);
+               teleport_player(10, TELEPORT_PASSIVE);
                break;
        case 4:
        case 5:
        case 6:
-               teleport_player(100, TRUE);
+               teleport_player(100, TELEPORT_PASSIVE);
                break;
        case 7:
        case 8:
-               teleport_player(200, TRUE);
+               teleport_player(200, TELEPORT_PASSIVE);
                break;
        case 9:
        case 10:
@@ -1572,14 +1572,6 @@ msg_print("
 }
 
 
-/*
- * Pray a prayer -- Unused in Hengband
- */
-void do_cmd_pray(void)
-{
-       msg_print("Praying is not used in Hengband. Use magic spell casting instead.");
-}
-
 static bool ang_sort_comp_pet_dismiss(vptr u, vptr v, int a, int b)
 {
        u16b *who = (u16b*)(u);
@@ -1616,14 +1608,35 @@ static bool ang_sort_comp_pet_dismiss(vptr u, vptr v, int a, int b)
        return w1 <= w2;
 }
 
+void check_pets_num_and_align(monster_type *m_ptr, bool inc)
+{
+       s32b old_friend_align = friend_align;
+       monster_race *r_ptr = &r_info[m_ptr->r_idx];
+
+       if (inc)
+       {
+               total_friends++;
+               if (r_ptr->flags3 & RF3_GOOD) friend_align += r_ptr->level;
+               if (r_ptr->flags3 & RF3_EVIL) friend_align -= r_ptr->level;
+       }
+       else
+       {
+               total_friends--;
+               if (r_ptr->flags3 & RF3_GOOD) friend_align -= r_ptr->level;
+               if (r_ptr->flags3 & RF3_EVIL) friend_align += r_ptr->level;
+       }
+
+       if (old_friend_align != friend_align) p_ptr->update |= (PU_BONUS);
+}
+
 int calculate_upkeep(void)
 {
        s32b old_friend_align = friend_align;
        int m_idx;
        bool have_a_unique = FALSE;
+       s32b total_friend_levels = 0;
 
        total_friends = 0;
-       total_friend_levels = 0;
        friend_align = 0;
 
        for (m_idx = m_max - 1; m_idx >=1; m_idx--)
@@ -1732,9 +1745,9 @@ void do_cmd_pet_dismiss(void)
                        handle_stuff();
 
 #ifdef JP
-                       sprintf(buf, "%s¤òÊü¤·¤Þ¤¹¤«¡© [Yes/No/Unnamed (%dɤ)]", friend_name, max_pet-i);
+                       sprintf(buf, "%s¤òÊü¤·¤Þ¤¹¤«¡© [Yes/No/Unnamed (%dÂÎ)]", friend_name, max_pet - i);
 #else
-                       sprintf(buf, "Dismiss %s? [Yes/No/Unnamed (%d remain)]", friend_name, max_pet-i);
+                       sprintf(buf, "Dismiss %s? [Yes/No/Unnamed (%d remain)]", friend_name, max_pet - i);
 #endif
                        prt(buf, 0, 0);
 
@@ -1782,7 +1795,7 @@ void do_cmd_pet_dismiss(void)
                                char m_name[80];
 
                                monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
-                               do_cmd_write_nikki(NIKKI_NAMED_PET, 2, m_name);
+                               do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_DISMISS, m_name);
                        }
 
                        if (pet_ctr == p_ptr->riding)
@@ -1822,7 +1835,7 @@ void do_cmd_pet_dismiss(void)
        C_KILL(who, max_m_idx, u16b);
 
 #ifdef JP
-       msg_format("%d ɤ¤Î¥Ú¥Ã¥È¤òÊü¤·¤Þ¤·¤¿¡£", Dismissed);
+       msg_format("%d ÂΤΥڥåȤòÊü¤·¤Þ¤·¤¿¡£", Dismissed);
 #else
        msg_format("You have dismissed %d pet%s.", Dismissed,
                   (Dismissed == 1 ? "" : "s"));
@@ -2034,6 +2047,8 @@ bool do_riding(bool force)
        x = px + ddx[dir];
        c_ptr = &cave[y][x];
 
+       if (p_ptr->special_defense & KATA_MUSOU) set_action(ACTION_NONE);
+
        if (p_ptr->riding)
        {
                /* Skip non-empty grids */
@@ -2147,12 +2162,11 @@ bool do_riding(bool force)
                        return FALSE;
                }
 
-               if (m_ptr->csleep)
+               if (MON_CSLEEP(m_ptr))
                {
                        char m_name[80];
                        monster_desc(m_name, m_ptr, 0);
-                       m_ptr->csleep = 0;
-                       mproc_remove(c_ptr->m_idx, m_ptr->mproc_idx[MPROC_CSLEEP], MPROC_CSLEEP);
+                       (void)set_monster_csleep(c_ptr->m_idx, 0);
 #ifdef JP
                        msg_format("%s¤òµ¯¤³¤·¤¿¡£", m_name);
 #else
@@ -2160,6 +2174,8 @@ bool do_riding(bool force)
 #endif
                }
 
+               if (p_ptr->action == ACTION_KAMAE) set_action(ACTION_NONE);
+
                p_ptr->riding = c_ptr->m_idx;
 
                /* Hack -- remove tracked monster */
@@ -2263,7 +2279,7 @@ static void do_name_pet(void)
                                        char m_name[80];
 
                                        monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
-                                       do_cmd_write_nikki(NIKKI_NAMED_PET, 0, m_name);
+                                       do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_NAME, m_name);
                                }
                        }
                        else
@@ -2273,7 +2289,7 @@ static void do_name_pet(void)
                                        char m_name[80];
 
                                        monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
-                                       do_cmd_write_nikki(NIKKI_NAMED_PET, 1, m_name);
+                                       do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_UNNAME, m_name);
                                }
                                m_ptr->nickname = 0;
                        }
@@ -2299,11 +2315,11 @@ void do_cmd_pet(void)
 
        int mode = 0;
 
-       byte y = 1, x = 0;
-       int ctr = 0;
        char buf[160];
        char target_buf[160];
 
+       int menu_line = use_menu ? 1 : 0;
+
        num = 0;
 
 #ifdef JP
@@ -2315,18 +2331,18 @@ void do_cmd_pet(void)
        powers[num++] = PET_DISMISS;
 
 #ifdef JP
-       sprintf(target_buf,"¥Ú¥Ã¥È¤Î¥¿¡¼¥²¥Ã¥È¤ò»ØÄê (¸½ºß¡§%s)",
-               (pet_t_m_idx ? r_name + r_info[m_list[pet_t_m_idx].r_idx].name : "»ØÄê¤Ê¤·"));
+       sprintf(target_buf, "¥Ú¥Ã¥È¤Î¥¿¡¼¥²¥Ã¥È¤ò»ØÄê (¸½ºß¡§%s)",
+               (pet_t_m_idx ? (p_ptr->image ? "²¿¤«´ñ̯¤Êʪ" : (r_name + r_info[m_list[pet_t_m_idx].ap_r_idx].name)) : "»ØÄê¤Ê¤·"));
 #else
-       sprintf(target_buf,"specify a targert of pet (now:%s)",
-               (pet_t_m_idx ? r_name + r_info[m_list[pet_t_m_idx].r_idx].name : "nothing"));
+       sprintf(target_buf, "specify a target of pet (now:%s)",
+               (pet_t_m_idx ? (p_ptr->image ? "something strange" : (r_name + r_info[m_list[pet_t_m_idx].ap_r_idx].name)) : "nothing"));
 #endif
        power_desc[num] = target_buf;
 
        powers[num++] = PET_TARGET;
 
 #ifdef JP
-power_desc[num] = "¶á¤¯¤Ë¤¤¤í";
+       power_desc[num] = "¶á¤¯¤Ë¤¤¤í";
 #else
        power_desc[num] = "stay close";
 #endif
@@ -2344,7 +2360,7 @@ power_desc[num] = "
        powers[num++] = PET_FOLLOW_ME;
 
 #ifdef JP
-power_desc[num] = "Ũ¤ò¸«¤Ä¤±¤ÆÅݤ»";
+       power_desc[num] = "Ũ¤ò¸«¤Ä¤±¤ÆÅݤ»";
 #else
        power_desc[num] = "seek and destroy";
 #endif
@@ -2353,7 +2369,7 @@ power_desc[num] = "Ũ
        powers[num++] = PET_SEEK_AND_DESTROY;
 
 #ifdef JP
-power_desc[num] = "¾¯¤·Î¥¤ì¤Æ¤¤¤í";
+       power_desc[num] = "¾¯¤·Î¥¤ì¤Æ¤¤¤í";
 #else
        power_desc[num] = "give me space";
 #endif
@@ -2362,7 +2378,7 @@ power_desc[num] = "
        powers[num++] = PET_ALLOW_SPACE;
 
 #ifdef JP
-power_desc[num] = "Î¥¤ì¤Æ¤¤¤í";
+       power_desc[num] = "Î¥¤ì¤Æ¤¤¤í";
 #else
        power_desc[num] = "stay away";
 #endif
@@ -2377,7 +2393,6 @@ power_desc[num] = "Υ
 #else
                power_desc[num] = "pets open doors (now On)";
 #endif
-
        }
        else
        {
@@ -2386,7 +2401,6 @@ power_desc[num] = "Υ
 #else
                power_desc[num] = "pets open doors (now Off)";
 #endif
-
        }
        powers[num++] = PET_OPEN_DOORS;
 
@@ -2397,7 +2411,6 @@ power_desc[num] = "Υ
 #else
                power_desc[num] = "pets pick up items (now On)";
 #endif
-
        }
        else
        {
@@ -2406,7 +2419,6 @@ power_desc[num] = "Υ
 #else
                power_desc[num] = "pets pick up items (now Off)";
 #endif
-
        }
        powers[num++] = PET_TAKE_ITEMS;
 
@@ -2417,7 +2429,6 @@ power_desc[num] = "Υ
 #else
                power_desc[num] = "allow teleport (now On)";
 #endif
-
        }
        else
        {
@@ -2426,7 +2437,6 @@ power_desc[num] = "Υ
 #else
                power_desc[num] = "allow teleport (now Off)";
 #endif
-
        }
        powers[num++] = PET_TELEPORT;
 
@@ -2437,7 +2447,6 @@ power_desc[num] = "Υ
 #else
                power_desc[num] = "allow cast attack spell (now On)";
 #endif
-
        }
        else
        {
@@ -2446,7 +2455,6 @@ power_desc[num] = "Υ
 #else
                power_desc[num] = "allow cast attack spell (now Off)";
 #endif
-
        }
        powers[num++] = PET_ATTACK_SPELL;
 
@@ -2457,7 +2465,6 @@ power_desc[num] = "Υ
 #else
                power_desc[num] = "allow cast summon spell (now On)";
 #endif
-
        }
        else
        {
@@ -2466,7 +2473,6 @@ power_desc[num] = "Υ
 #else
                power_desc[num] = "allow cast summon spell (now Off)";
 #endif
-
        }
        powers[num++] = PET_SUMMON_SPELL;
 
@@ -2477,7 +2483,6 @@ power_desc[num] = "Υ
 #else
                power_desc[num] = "allow involve player in area spell (now On)";
 #endif
-
        }
        else
        {
@@ -2486,7 +2491,6 @@ power_desc[num] = "Υ
 #else
                power_desc[num] = "allow involve player in area spell (now Off)";
 #endif
-
        }
        powers[num++] = PET_BALL_SPELL;
 
@@ -2497,7 +2501,6 @@ power_desc[num] = "Υ
 #else
                power_desc[num] = "get off a pet";
 #endif
-
        }
        else
        {
@@ -2506,7 +2509,6 @@ power_desc[num] = "Υ
 #else
                power_desc[num] = "ride a pet";
 #endif
-
        }
        powers[num++] = PET_RIDING;
 
@@ -2598,91 +2600,126 @@ power_desc[num] = "Υ
                }
        }
 
+#ifdef ALLOW_REPEAT
+       if (!(repeat_pull(&i) && (i >= 0) && (i < num)))
+       {
+#endif /* ALLOW_REPEAT */
+
        /* Nothing chosen yet */
        flag = FALSE;
 
-       /* Build a prompt (accept all spells) */
-       if (num <= 26)
+       /* No redraw yet */
+       redraw = FALSE;
+
+       if (use_menu)
        {
-               /* Build a prompt (accept all spells) */
+               /* Save the screen */
+               screen_save();
+
+               /* Build a prompt */
 #ifdef JP
-strnfmt(out_val, 78, "(¥³¥Þ¥ó¥É %c-%c¡¢'*'=°ìÍ÷¡¢ESC=½ªÎ») ¥³¥Þ¥ó¥É¤òÁª¤ó¤Ç¤¯¤À¤µ¤¤:",
+               strnfmt(out_val, 78, "(¥³¥Þ¥ó¥É¡¢ESC=½ªÎ») ¥³¥Þ¥ó¥É¤òÁª¤ó¤Ç¤¯¤À¤µ¤¤:");
 #else
-               strnfmt(out_val, 78, "(Command %c-%c, *=List, ESC=exit) Select a command: ",
+               strnfmt(out_val, 78, "(Command, ESC=exit) Choose command from menu.");
 #endif
-
-                       I2A(0), I2A(num - 1));
        }
        else
        {
+               /* Build a prompt */
+               strnfmt(out_val, 78,
 #ifdef JP
-strnfmt(out_val, 78, "(¥³¥Þ¥ó¥É %c-%c¡¢'*'=°ìÍ÷¡¢ESC=½ªÎ») ¥³¥Þ¥ó¥É¤òÁª¤ó¤Ç¤¯¤À¤µ¤¤:",
+                       "(¥³¥Þ¥ó¥É %c-%c¡¢'*'=°ìÍ÷¡¢ESC=½ªÎ») ¥³¥Þ¥ó¥É¤òÁª¤ó¤Ç¤¯¤À¤µ¤¤:",
 #else
-               strnfmt(out_val, 78, "(Command %c-%c, *=List, ESC=exit) Select a command: ",
+                       "(Command %c-%c, *=List, ESC=exit) Select a command: ",
 #endif
-
-                       I2A(0), '0' + num - 27);
+                       I2A(0), I2A(num - 1));
        }
 
-       /* Show list */
-       redraw = TRUE;
+       choice = (always_show_list || use_menu) ? ESCAPE : 1;
 
-       /* Save the screen */
-       Term_save();
+       /* Get a command from the user */
+       while (!flag)
+       {
+               if (choice == ESCAPE) choice = ' ';
+               else if (!get_com(out_val, &choice, TRUE)) break;
 
-       prt("", y++, x);
+               if (use_menu && (choice != ' '))
+               {
+                       switch (choice)
+                       {
+                       case '0':
+                               screen_load();
+                               return;
+
+                       case '8':
+                       case 'k':
+                       case 'K':
+                               menu_line += (num - 1);
+                               break;
 
-       while (ctr < num)
-       {
-               prt(format("%s%c) %s", (ctr == mode) ? "*" : " ", I2A(ctr), power_desc[ctr]), y + ctr, x);
-               ctr++;
-       }
+                       case '2':
+                       case 'j':
+                       case 'J':
+                               menu_line++;
+                               break;
 
-       if (ctr < 17)
-       {
-               prt("", y + ctr, x);
-       }
-       else
-       {
-               prt("", y + 17, x);
-       }
+                       case '4':
+                       case 'h':
+                       case 'H':
+                               menu_line = 1;
+                               break;
+
+                       case '6':
+                       case 'l':
+                       case 'L':
+                               menu_line = num;
+                               break;
+
+                       case 'x':
+                       case 'X':
+                       case '\r':
+                       case '\n':
+                               i = menu_line - 1;
+                               ask = FALSE;
+                               break;
+                       }
+                       if (menu_line > num) menu_line -= num;
+               }
 
-       /* Get a command from the user */
-       while (!flag && get_com(out_val, &choice, TRUE))
-       {
                /* Request redraw */
-               if ((choice == ' ') || (choice == '*') || (choice == '?'))
+               if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
                {
                        /* Show the list */
-                       if (!redraw)
+                       if (!redraw || use_menu)
                        {
-                               y = 1;
-                               x = 0;
-                               ctr = 0;
+                               byte y = 1, x = 0;
+                               int ctr = 0;
 
                                /* Show list */
                                redraw = TRUE;
 
                                /* Save the screen */
-                               Term_save();
+                               if (!use_menu) screen_save();
 
                                prt("", y++, x);
 
-                               while (ctr < num)
+                               /* Print list */
+                               for (ctr = 0; ctr < num; ctr++)
                                {
-                                       sprintf(buf, "%s%c) %s", (ctr == mode) ? "*" : " ", I2A(ctr), power_desc[ctr]);
+                                       /* Letter/number for power selection */
+#ifdef JP
+                                       if (use_menu) sprintf(buf, "%c%s ", (ctr == mode) ? '*' : ' ', (ctr == (menu_line - 1)) ? "¡Õ" : "  ");
+#else
+                                       if (use_menu) sprintf(buf, "%c%s ", (ctr == mode) ? '*' : ' ', (ctr == (menu_line - 1)) ? "> " : "  ");
+#endif
+                                       else sprintf(buf, "%c%c) ", (ctr == mode) ? '*' : ' ', I2A(ctr));
+
+                                       strcat(buf, power_desc[ctr]);
+
                                        prt(buf, y + ctr, x);
-                                       ctr++;
                                }
 
-                               if (ctr < 17)
-                               {
-                                       prt("", y + ctr, x);
-                               }
-                               else
-                               {
-                                       prt("", y + 17, x);
-                               }
+                               prt("", y + MIN(ctr, 17), x);
                        }
 
                        /* Hide the list */
@@ -2692,14 +2729,14 @@ strnfmt(out_val, 78, "(
                                redraw = FALSE;
 
                                /* Restore the screen */
-                               Term_load();
+                               screen_load();
                        }
 
                        /* Redo asking */
                        continue;
                }
 
-               if (isalpha(choice))
+               if (!use_menu)
                {
                        /* Note verify */
                        ask = (isupper(choice));
@@ -2710,12 +2747,6 @@ strnfmt(out_val, 78, "(
                        /* Extract request */
                        i = (islower(choice) ? A2I(choice) : -1);
                }
-               else
-               {
-                       ask = FALSE; /* Can't uppercase digits */
-
-                       i = choice - '0' + 26;
-               }
 
                /* Totally Illegal */
                if ((i < 0) || (i >= num))
@@ -2734,7 +2765,6 @@ strnfmt(out_val, 78, "(
                        strnfmt(buf, 78, "Use %s? ", power_desc[i]);
 #endif
 
-
                        /* Belay that order */
                        if (!get_check(buf)) continue;
                }
@@ -2744,7 +2774,7 @@ strnfmt(out_val, 78, "(
        }
 
        /* Restore the screen */
-       if (redraw) Term_load();
+       if (redraw) screen_load();
 
        /* Abort if needed */
        if (!flag)
@@ -2753,6 +2783,11 @@ strnfmt(out_val, 78, "(
                return;
        }
 
+#ifdef ALLOW_REPEAT
+       repeat_push(i);
+       }
+#endif /* ALLOW_REPEAT */
+
        switch (powers[i])
        {
                case PET_DISMISS: /* Dismiss pets */