OSDN Git Service

自動破壊を簡単に設定する機能を破壊コマンド(k/^D)に追加した。
[hengband/hengband.git] / src / cmd3.c
index 62a8528..e42620f 100644 (file)
@@ -3,11 +3,11 @@
 /* Purpose: Inventory commands */
 
 /*
- * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
  *
- * This software may be copied and distributed for educational, research, and
- * not for profit purposes provided that this copyright and statement are
- * included in all such copies.
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies.  Other copyrights may also apply.
  */
 
 #include "angband.h"
@@ -253,116 +253,107 @@ void do_cmd_wield(void)
 
        /* Check the slot */
        slot = wield_slot(o_ptr);
-#if 1 /* EASY_RING -- TNB */
 
-       if ((o_ptr->tval == TV_RING) && inventory[INVEN_LEFT].k_idx &&
-               inventory[INVEN_RIGHT].k_idx)
+       switch (o_ptr->tval)
        {
-               /* Restrict the choices */
-               item_tester_tval = TV_RING;
-               item_tester_no_ryoute = TRUE;
-
-               /* Choose a ring from the equipment only */
-#ifdef JP
-q = "¤É¤Á¤é¤Î»ØÎؤȼè¤êÂؤ¨¤Þ¤¹¤«?";
-#else
-               q = "Replace which ring? ";
-#endif
+       /* Shields and some misc. items */
+       case TV_CAPTURE:
+       case TV_SHIELD:
+       case TV_CARD:
+               if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
+               {
+                       /* Restrict the choices */
+                       item_tester_hook = item_tester_hook_melee_weapon;
+                       item_tester_no_ryoute = TRUE;
 
+                       /* Choose a weapon from the equipment only */
 #ifdef JP
-s = "¤ª¤Ã¤È¡£";
+                       q = "¤É¤Á¤é¤ÎÉð´ï¤È¼è¤êÂؤ¨¤Þ¤¹¤«?";
+                       s = "¤ª¤Ã¤È¡£";
 #else
-               s = "Oops.";
+                       q = "Replace which weapon? ";
+                       s = "Oops.";
 #endif
 
-               if (!get_item(&slot, q, s, (USE_EQUIP)))
-                       return;
-       }
-
-#endif /* EASY_RING -- TNB */
+                       if (!get_item(&slot, q, s, (USE_EQUIP))) return;
+                       if ((slot == INVEN_RARM) && !cursed_p(&inventory[INVEN_RARM]))
+                       {
+                               object_type *or_ptr = &inventory[INVEN_RARM];
+                               object_type *ol_ptr = &inventory[INVEN_LARM];
+                               object_type object_tmp;
+                               object_type *otmp_ptr = &object_tmp;
+                               char ol_name[MAX_NLEN];
 
-       if (((o_ptr->tval == TV_SHIELD) || (o_ptr->tval == TV_CARD) || (o_ptr->tval == TV_CAPTURE)) &&
-               buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
-       {
-               /* Restrict the choices */
-               item_tester_hook = item_tester_hook_melee_weapon;
-               item_tester_no_ryoute = TRUE;
+                               object_desc(ol_name, ol_ptr, FALSE, 0);
 
-               /* Choose a weapon from the equipment only */
+                               object_copy(otmp_ptr, ol_ptr);
+                               object_copy(ol_ptr, or_ptr);
+                               object_copy(or_ptr, otmp_ptr);
 #ifdef JP
-q = "¤É¤Á¤é¤ÎÉð´ï¤È¼è¤êÂؤ¨¤Þ¤¹¤«?";
+                               msg_format("%s¤ò%s¤Ë¹½¤¨¤Ê¤ª¤·¤¿¡£", ol_name, left_hander ? "º¸¼ê" : "±¦¼ê");
 #else
-               q = "Replace which weapon? ";
+                               msg_format("You wield %s at %s hand.", ol_name, left_hander ? "left" : "right");
 #endif
 
+                               slot = INVEN_LARM;
+                       }
+               }
+               break;
+
+       /* Melee weapons */
+       case TV_DIGGING:
+       case TV_HAFTED:
+       case TV_POLEARM:
+       case TV_SWORD:
+               /* Asking for dual wielding */
+               if (slot == INVEN_LARM)
+               {
 #ifdef JP
-s = "¤ª¤Ã¤È¡£";
+                       if (!get_check("ÆóÅáή¤ÇÀ襤¤Þ¤¹¤«¡©")) slot = INVEN_RARM;
 #else
-               s = "Oops.";
+                       if (!get_check("Dual wielding? ")) slot = INVEN_RARM;
 #endif
+               }
 
-               if (!get_item(&slot, q, s, (USE_EQUIP)))
-                       return;
-               if (slot == INVEN_RARM)
+               /* Both arms are already used */
+               else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
                {
-                       object_type *or_ptr = &inventory[INVEN_RARM];
-                       object_type *ol_ptr = &inventory[INVEN_LARM];
-                       object_type *otmp_ptr;
-                       object_type object_tmp;
-                       char ol_name[MAX_NLEN];
+                       /* Restrict the choices */
+                       item_tester_hook = item_tester_hook_mochikae;
 
-                       otmp_ptr = &object_tmp;
-
-                       object_desc(ol_name, ol_ptr, FALSE, 0);
-
-                       object_copy(otmp_ptr, ol_ptr);
-                       object_copy(ol_ptr, or_ptr);
-                       object_copy(or_ptr, otmp_ptr);
+                       /* Choose a hand */
 #ifdef JP
-                       msg_format("%s¤ò%s¤Ë¹½¤¨¤Ê¤ª¤·¤¿¡£", ol_name, left_hander ? "º¸¼ê" : "±¦¼ê");
+                       q = "¤É¤Á¤é¤Î¼ê¤ËÁõÈ÷¤·¤Þ¤¹¤«?";
+                       s = "¤ª¤Ã¤È¡£";
 #else
-                       msg_format("You wield %s at %s hand.", ol_name, left_hander ? "left" : "right");
+                       q = "Equip which hand? ";
+                       s = "Oops.";
 #endif
 
-                       slot = INVEN_LARM;
+                       if (!get_item(&slot, q, s, (USE_EQUIP))) return;
                }
-       }
+               break;
 
-       /* ÆóÅáή¤Ë¤¹¤ë¤«¤É¤¦¤« */
-       if ((o_ptr->tval >= TV_DIGGING) && (o_ptr->tval <= TV_SWORD) && (slot == INVEN_LARM))
-       {
-#ifdef JP
-               if (!get_check("ÆóÅáή¤ÇÀ襤¤Þ¤¹¤«¡©"))
-#else
-               if (!get_check("Dual wielding? "))
-#endif
+       /* Rings */
+       case TV_RING:
+               if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
                {
-                       slot = INVEN_RARM;
-               }
-       }
-
-       if ((o_ptr->tval >= TV_DIGGING) && (o_ptr->tval <= TV_SWORD) &&
-           inventory[INVEN_LARM].k_idx &&
-               inventory[INVEN_RARM].k_idx)
-       {
-               /* Restrict the choices */
-               item_tester_hook = item_tester_hook_mochikae;
-
-               /* Choose a ring from the equipment only */
-#ifdef JP
-q = "¤É¤Á¤é¤Î¼ê¤ËÁõÈ÷¤·¤Þ¤¹¤«?";
-#else
-               q = "Equip which hand? ";
-#endif
+                       /* Restrict the choices */
+                       item_tester_tval = TV_RING;
+                       item_tester_no_ryoute = TRUE;
 
+                       /* Choose a ring from the equipment only */
 #ifdef JP
-s = "¤ª¤Ã¤È¡£";
+                       q = "¤É¤Á¤é¤Î»ØÎؤȼè¤êÂؤ¨¤Þ¤¹¤«?";
+                       s = "¤ª¤Ã¤È¡£";
 #else
-               s = "Oops.";
+                       q = "Replace which ring? ";
+                       s = "Oops.";
 #endif
 
-               if (!get_item(&slot, q, s, (USE_EQUIP)))
-                       return;
+                       if (!get_item(&slot, q, s, (USE_EQUIP))) return;
+               }
+               break;
        }
 
        /* Prevent wielding into a cursed slot */
@@ -380,7 +371,6 @@ s = "
                           o_name, describe_use(slot));
 #endif
 
-
                /* Cancel the command */
                return;
        }
@@ -399,9 +389,7 @@ sprintf(dummy, "
                sprintf(dummy, "Really use the %s {cursed}? ", o_name);
 #endif
 
-
-               if (!get_check(dummy))
-                       return;
+               if (!get_check(dummy)) return;
        }
 
        if ((o_ptr->name1 == ART_STONEMASK) && object_known_p(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
@@ -418,9 +406,7 @@ sprintf(dummy, "%s
                sprintf(dummy, "Do you become a vampire?");
 #endif
 
-
-               if (!get_check(dummy))
-                       return;
+               if (!get_check(dummy)) return;
        }
 
        /* Check if completed a quest */
@@ -443,7 +429,13 @@ msg_print("
                }
        }
 
-       if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) identify_item(o_ptr);
+       if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
+       {
+               identify_item(o_ptr);
+
+               /* Auto-inscription */
+               auto_inscribe_item(item, is_autopick(o_ptr));
+       }
 
        /* Take a turn */
        energy_use = 100;
@@ -491,9 +483,10 @@ msg_print("
        equip_cnt++;
 
        /* Where is the item now */
-       if (slot == INVEN_RARM)
+       switch (slot)
        {
-               if((o_ptr->tval != TV_SHIELD) && (o_ptr->tval != TV_CAPTURE) && (o_ptr->tval != TV_CARD) && (empty_hands(FALSE) & 0x00000001) && ((o_ptr->weight > 99) || (o_ptr->tval == TV_POLEARM)) && (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE)))
+       case INVEN_RARM:
+               if ((o_ptr->tval != TV_SHIELD) && (o_ptr->tval != TV_CAPTURE) && (o_ptr->tval != TV_CARD) && (empty_hands(FALSE) & EMPTY_HAND_LARM) && ((o_ptr->weight > 99) || (o_ptr->tval == TV_POLEARM)) && (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE)))
 #ifdef JP
                        act = "¤òξ¼ê¤Ç¹½¤¨¤¿";
 #else
@@ -505,43 +498,39 @@ msg_print("
 #else
                        act = "You are wielding";
 #endif
+               break;
 
-       }
-       else if (slot == INVEN_LARM)
-       {
+       case INVEN_LARM:
 #ifdef JP
                act = (left_hander ? "¤ò±¦¼ê¤ËÁõÈ÷¤·¤¿" : "¤òº¸¼ê¤ËÁõÈ÷¤·¤¿");
 #else
                act = "You are wielding";
 #endif
+               break;
 
-       }
-       else if (slot == INVEN_BOW)
-       {
+       case INVEN_BOW:
 #ifdef JP
                act = "¤ò¼Í·âÍѤËÁõÈ÷¤·¤¿";
 #else
                act = "You are shooting with";
 #endif
+               break;
 
-       }
-       else if (slot == INVEN_LITE)
-       {
+       case INVEN_LITE:
 #ifdef JP
                act = "¤ò¸÷¸»¤Ë¤·¤¿";
 #else
                act = "Your light source is";
 #endif
+               break;
 
-       }
-       else
-       {
+       default:
 #ifdef JP
                act = "¤òÁõÈ÷¤·¤¿";
 #else
                act = "You are wearing";
 #endif
-
+               break;
        }
 
        /* Describe the result */
@@ -676,31 +665,34 @@ void kamaenaoshi(int item)
                        msg_format("You are wielding %s with %s hand.", o_name, (left_hander ? "left":"right") );
 #endif
        }
-       else if ((item == INVEN_LARM) && buki_motteruka(INVEN_RARM))
+       else if (item == INVEN_LARM)
        {
-               o_ptr = &inventory[INVEN_RARM];
-               object_desc(o_name, o_ptr, TRUE, 3);
-               if (((o_ptr->weight > 99) || (o_ptr->tval == TV_POLEARM)) && (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE)))
+               if (buki_motteruka(INVEN_RARM))
+               {
+                       o_ptr = &inventory[INVEN_RARM];
+                       object_desc(o_name, o_ptr, TRUE, 3);
+                       if (((o_ptr->weight > 99) || (o_ptr->tval == TV_POLEARM)) && (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE)))
 #ifdef JP
-                       msg_format("%s¤òξ¼ê¤Ç¹½¤¨¤¿¡£", o_name );
+                               msg_format("%s¤òξ¼ê¤Ç¹½¤¨¤¿¡£", o_name );
 #else
-                       msg_format("You are wielding %s with two-handed.", o_name );
+                               msg_format("You are wielding %s with two-handed.", o_name );
 #endif
-       }
-       else if ((item == INVEN_LARM) && !(empty_hands(FALSE) & 0x0002))
-       {
-               o_ptr = &inventory[INVEN_LARM];
-               o2_ptr = &inventory[INVEN_RARM];
-               object_copy(o_ptr, o2_ptr);
-               p_ptr->total_weight += o2_ptr->weight;
-               inven_item_increase(INVEN_RARM,-1);
-               inven_item_optimize(INVEN_RARM);
-               object_desc(o_name, o_ptr, TRUE, 3);
+               }
+               else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM))
+               {
+                       o_ptr = &inventory[INVEN_LARM];
+                       o2_ptr = &inventory[INVEN_RARM];
+                       object_copy(o_ptr, o2_ptr);
+                       p_ptr->total_weight += o2_ptr->weight;
+                       inven_item_increase(INVEN_RARM,-1);
+                       inven_item_optimize(INVEN_RARM);
+                       object_desc(o_name, o_ptr, TRUE, 3);
 #ifdef JP
-               msg_format("%s¤ò»ý¤ÁÂؤ¨¤¿¡£", o_name );
+                       msg_format("%s¤ò»ý¤ÁÂؤ¨¤¿¡£", o_name);
 #else
-               msg_format("You switched hand of %s.", o_name );
+                       msg_format("You switched hand of %s.", o_name);
 #endif
+               }
        }
 }
 
@@ -992,19 +984,70 @@ void do_cmd_destroy(void)
        o_ptr->number = old_number;
 
        /* Verify unless quantity given */
-       if (!force)
+       if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
        {
-               if (confirm_destroy || (object_value(o_ptr) > 0))
-               {
-                       /* Make a verification */
+               bool okay = TRUE;
+
+               /* Make a verification */
+               sprintf(out_val, 
 #ifdef JP
-               sprintf(out_val, "ËÜÅö¤Ë%s¤ò²õ¤·¤Þ¤¹¤«? ", o_name);
+                       "ËÜÅö¤Ë%s¤ò²õ¤·¤Þ¤¹¤«? [y/n/Auto]",
 #else
-                       sprintf(out_val, "Really destroy %s? ", o_name);
+                       "Really destroy %s? [y/n/Auto]",
 #endif
+                       o_name);
+
+               msg_print(NULL);
+
+               /* Prompt */
+               prt(out_val, 0, 0);
+
+               /* HACK : Add the line to message buffer */
+               message_add(out_val);
+               p_ptr->window |= (PW_MESSAGE);
+               window_stuff();
 
-                       if (!get_check(out_val)) return;
+               /* Get an acceptable answer */
+               while (TRUE)
+               {
+                       char i = inkey();
+
+                       if (i == 'y' || i == 'Y')
+                       {
+                               okay = TRUE;
+                               break;
+                       }
+                       if (i == ESCAPE || i == 'n' || i == 'N')
+                       {
+                               /* Cancel */
+                               okay = FALSE;
+                               break;
+                       }
+                       if (i == 'a' || i == 'A')
+                       {
+                               int idx;
+
+                               /* Add an auto-destroy preference line */
+                               if (add_auto_register(o_ptr))
+                               {
+                                       /* Auto-destroy it */
+                                       idx = is_autopick(o_ptr);
+                                       auto_destroy_item(item, idx);
+                               }
+
+                               /* The object is already destroyed. */
+                               return;
+                       }
+
+                       /* Loop */
+                       continue;
                }
+
+               /* Erase the prompt */
+               prt("", 0, 0);
+
+               /* Cancelled */
+               if (!okay) return;
        }
 
        /* Take a turn */
@@ -1831,7 +1874,6 @@ bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
 
        int z1, z2;
 
-
        /* Sort by player kills */
        if (*why >= 4)
        {
@@ -1901,6 +1943,9 @@ void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
 
        u16b holder;
 
+       /* Unused */
+       (void)v;
+
        /* Swap */
        holder = who[a];
        who[a] = who[b];
@@ -2142,17 +2187,6 @@ void do_cmd_query_symbol(void)
                /* Hack -- Handle stuff */
                handle_stuff();
 
-               /* Hack -- Begin the prompt */
-               roff_top(r_idx);
-
-               /* Hack -- Complete the prompt */
-#ifdef JP
-               Term_addstr(-1, TERM_WHITE, " ['r'»×¤¤½Ð, ESC]");
-#else
-               Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]");
-#endif
-
-
                /* Interact */
                while (1)
                {
@@ -2164,16 +2198,18 @@ void do_cmd_query_symbol(void)
 
                                /* Recall on screen */
                                screen_roff(who[i], 0);
+                       }
+
+                       /* Hack -- Begin the prompt */
+                       roff_top(r_idx);
 
-                               /* Hack -- Complete the prompt (again) */
+                       /* Hack -- Complete the prompt */
 #ifdef JP
-                               Term_addstr(-1, TERM_WHITE, " ['r'»×¤¤½Ð, ESC]");
+                       Term_addstr(-1, TERM_WHITE, " ['r'»×¤¤½Ð, ESC]");
 #else
-                               Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]");
+                       Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]");
 #endif
 
-                       }
-
                        /* Command */
                        query = inkey();