OSDN Git Service

自動破壊と自動刻み機能を、床上や持ち物の鑑定の後にも適用するようにした。
authormogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Mon, 6 May 2002 08:24:59 +0000 (08:24 +0000)
committermogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Mon, 6 May 2002 08:24:59 +0000 (08:24 +0000)
並の武器を破壊する設定をしてあれば、鑑定した瞬間に破壊、
%刻みの設定をしてあれば*鑑定*した瞬間に耐性刻み、等ができる。

src/autopick.c
src/cmd1.c
src/externs.h
src/spells3.c

index f331339..6add888 100644 (file)
@@ -733,6 +733,209 @@ int is_autopick(object_type *o_ptr)
 
 
 /*
+ * Automatically destroy items in this grid.
+ */
+static bool is_opt_confirm_destroy(object_type *o_ptr)
+{
+       if (!destroy_items) return FALSE;
+
+       /* Known to be worthless? */
+       if (leave_worth)
+               if (object_value(o_ptr) > 0) return FALSE;
+       
+       if (leave_equip)
+               if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_DRAG_ARMOR)) return FALSE;
+       
+       if (leave_chest)
+               if ((o_ptr->tval == TV_CHEST) && o_ptr->pval) return FALSE;
+       
+       if (leave_wanted)
+       {
+               if (o_ptr->tval == TV_CORPSE
+                   && object_is_shoukinkubi(o_ptr)) return FALSE;
+       }
+       
+       if (leave_corpse)
+               if (o_ptr->tval == TV_CORPSE) return FALSE;
+       
+       if (leave_junk)
+               if ((o_ptr->tval == TV_SKELETON) || (o_ptr->tval == TV_BOTTLE) || (o_ptr->tval == TV_JUNK) || (o_ptr->tval == TV_STATUE)) return FALSE;
+       
+       if (o_ptr->tval == TV_GOLD) return FALSE;
+       
+       return TRUE;
+}
+
+
+/*
+ * Determines whether an item has '=g' in its inscription for easy-auto-picker
+ */
+static bool is_autopick2( object_type *o_ptr) {
+      cptr s;
+
+      /* No inscription */
+      if (!o_ptr->inscription) return (FALSE);
+
+      /* Find a '=' */
+      s = strchr(quark_str(o_ptr->inscription), '=');
+
+      /* Process inscription */
+      while (s)
+      {
+              /* Auto-pickup on "=g" */
+              if (s[1] == 'g') return (TRUE);
+
+              /* Find another '=' */
+              s = strchr(s + 1, '=');
+      }
+
+      /* Don't auto-pickup */
+      return (FALSE);
+}
+
+
+/*
+ *  Auto inscription
+ */
+void auto_inscribe_item(object_type *o_ptr, int idx)
+{
+       if (idx >= 0 && autopick_list[idx].insc && !o_ptr->inscription)
+               o_ptr->inscription = inscribe_flags(o_ptr, autopick_list[idx].insc);
+}
+
+
+/*
+ * Automatically destroy an item if it is to be destroyed
+ */
+bool auto_destroy_item(s16b item, int autopick_idx)
+{
+       char o_name[MAX_NLEN];
+       object_type *o_ptr;
+
+       /* Get the item (in the pack) */
+       if (item >= 0) o_ptr = &inventory[item];
+
+       /* Get the item (on the floor) */
+       else o_ptr = &o_list[0 - item];
+
+
+       if ((autopick_idx == -1 && is_opt_confirm_destroy(o_ptr)) ||
+           (autopick_idx >= 0 && (autopick_list[autopick_idx].action & DO_AUTODESTROY)))
+       {
+               disturb(0,0);
+
+               /* Artifact? */
+               if (!can_player_destroy_object(o_ptr))
+               {
+                       /* Describe the object (with {terrible/special}) */
+                       object_desc(o_name, o_ptr, TRUE, 3);
+
+                       /* Message */
+#ifdef JP
+                       msg_format("%s¤ÏÇ˲õÉÔǽ¤À¡£", o_name);
+#else
+                       msg_format("You cannot auto-destroy %s.", o_name);
+#endif
+
+                       /* Done */
+                       return TRUE;
+               }
+
+               /* Record name of destroyed item */
+               autopick_free_entry(&autopick_entry_last_destroyed);
+               autopick_entry_from_object(&autopick_entry_last_destroyed, o_ptr);
+
+               /* Eliminate the item (from the pack) */
+               if (item >= 0)
+               {
+                       inven_item_increase(item, -(o_ptr->number));
+                       inven_item_optimize(item);
+               }
+
+               /* Eliminate the item (from the floor) */
+               else
+               {
+                       delete_object_idx(0 - item);
+               }
+
+               /* Print a message */
+#ifdef JP
+               msg_format("%s¤ò¼«Æ°Ç˲õ¤·¤Þ¤¹¡£", o_name);
+#else
+               msg_format("Auto-destroying %s.", o_name);
+#endif
+                       
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
+
+/*
+ * Automatically pickup/destroy items in this grid.
+ */
+void auto_pickup_items(cave_type *c_ptr)
+{
+       s16b this_o_idx, next_o_idx = 0;
+       s16b inscribe_flags(object_type *o_ptr, cptr out_val);
+       
+       /* Scan the pile of objects */
+       for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
+       {
+               int idx;
+       
+               /* Acquire object */
+               object_type *o_ptr = &o_list[this_o_idx];
+               
+               /* Acquire next object */
+               next_o_idx = o_ptr->next_o_idx;
+
+               idx = is_autopick(o_ptr);
+
+               auto_inscribe_item(o_ptr, idx);
+
+               if (is_autopick2(o_ptr) ||
+                   (idx >= 0 && (autopick_list[idx].action & DO_AUTOPICK)))
+               {
+                       disturb(0,0);
+
+                       if (!inven_carry_okay(o_ptr))
+                       {
+                               char o_name[MAX_NLEN];
+
+                               /* Describe the object */
+                               object_desc(o_name, o_ptr, TRUE, 3);
+
+                               /* Message */
+#ifdef JP
+                               msg_format("¥¶¥Ã¥¯¤Ë¤Ï%s¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£", o_name);
+#else
+                               msg_format("You have no room for %s.", o_name);
+#endif
+                               continue;
+                       }
+                       py_pickup_aux(this_o_idx);
+
+                       continue;
+               }
+               
+               /*
+                * Do auto-destroy;
+                * When always_pickup is 'yes', we disable
+                * auto-destroyer from autopick function, and do only
+                * easy-auto-destroyer.
+                */
+               else
+               {
+                       if (auto_destroy_item(this_o_idx, (!always_pickup ? idx : -2)))
+                               continue;
+               }
+       }
+}
+
+
+/*
  * Describe which kind of object is Auto-picked/destroyed
  */
 static void describe_autopick(char *buff, autopick_type *entry)
index fed0ccc..9a33061 100644 (file)
@@ -803,148 +803,6 @@ bool can_player_destroy_object(object_type *o_ptr)
        return TRUE;
 }
 
-/*
- * Easy auto-pick inscription
- */
-static bool is_autopick2( object_type *o_ptr) {
-      cptr s;
-
-      /* No inscription */
-      if (!o_ptr->inscription) return (FALSE);
-
-      /* Find a '=' */
-      s = strchr(quark_str(o_ptr->inscription), '=');
-
-      /* Process inscription */
-      while (s)
-      {
-              /* Auto-pickup on "=g" */
-              if (s[1] == 'g') return (TRUE);
-
-              /* Find another '=' */
-              s = strchr(s + 1, '=');
-      }
-
-      /* Don't auto pickup */
-      return (FALSE);
-}
-
-/*
- * Automatically destroy items in this grid.
- */
-static bool is_opt_confirm_destroy(object_type *o_ptr)
-{
-       if (!destroy_items) return FALSE;
-
-       /* Known to be worthless? */
-       if (leave_worth)
-               if (object_value(o_ptr) > 0) return FALSE;
-       
-       if (leave_equip)
-               if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_DRAG_ARMOR)) return FALSE;
-       
-       if (leave_chest)
-               if ((o_ptr->tval == TV_CHEST) && o_ptr->pval) return FALSE;
-       
-       if (leave_wanted)
-       {
-               if (o_ptr->tval == TV_CORPSE
-                   && object_is_shoukinkubi(o_ptr)) return FALSE;
-       }
-       
-       if (leave_corpse)
-               if (o_ptr->tval == TV_CORPSE) return FALSE;
-       
-       if (leave_junk)
-               if ((o_ptr->tval == TV_SKELETON) || (o_ptr->tval == TV_BOTTLE) || (o_ptr->tval == TV_JUNK) || (o_ptr->tval == TV_STATUE)) return FALSE;
-       
-       if (o_ptr->tval == TV_GOLD) return FALSE;
-       
-       return TRUE;
-}
-
-/*
- * Automatically pickup/destroy items in this grid.
- */
-static void auto_pickup_items(cave_type *c_ptr)
-{
-       s16b this_o_idx, next_o_idx = 0;
-       s16b inscribe_flags(object_type *o_ptr, cptr out_val);
-       
-       char o_name[MAX_NLEN];
-       int idx;
-       
-       /* Scan the pile of objects */
-       for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
-       {
-               /* Acquire object */
-               object_type *o_ptr = &o_list[this_o_idx];
-               
-               /* Acquire next object */
-               next_o_idx = o_ptr->next_o_idx;
-               idx = is_autopick(o_ptr);
-
-               if (idx >= 0 && autopick_list[idx].insc && !o_ptr->inscription)
-                       o_ptr->inscription = inscribe_flags(o_ptr, autopick_list[idx].insc);
-
-               if (is_autopick2(o_ptr) ||
-                  (idx >= 0 && (autopick_list[idx].action & DO_AUTOPICK)))
-               {
-                       disturb(0,0);
-
-                       if (!inven_carry_okay(o_ptr)){
-                               /* Describe the object */
-                               object_desc(o_name, o_ptr, TRUE, 3);
-                               /* Message */
-#ifdef JP
-                               msg_format("¥¶¥Ã¥¯¤Ë¤Ï%s¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£", o_name);
-#else
-                               msg_format("You have no room for %s.", o_name);
-#endif
-                               continue;
-                       }
-                       py_pickup_aux(this_o_idx);
-
-                       continue;
-               }
-               
-               else if ((idx == -1 && is_opt_confirm_destroy(o_ptr)) ||
-                        (!always_pickup && (idx != -1 && (autopick_list[idx].action & DO_AUTODESTROY))))
-               {
-                       disturb(0,0);
-                       /* Describe the object (with {terrible/special}) */
-                       object_desc(o_name, o_ptr, TRUE, 3);
-                       /* Artifact? */
-                       if (!can_player_destroy_object(o_ptr))
-                       {
-                               /* Message */
-#ifdef JP
-                               msg_format("%s¤ÏÇ˲õÉÔǽ¤À¡£", o_name);
-#else
-                               msg_format("You cannot auto-destroy %s.", o_name);
-#endif
-                               
-                               /* Done */
-                               continue;
-                       }
-                       autopick_free_entry(&autopick_entry_last_destroyed);
-                       autopick_entry_from_object(&autopick_entry_last_destroyed, o_ptr);
-
-                       /* Destroy the item */
-                       delete_object_idx(this_o_idx);
-                       
-                       /* Print a message */
-#ifdef JP
-                       msg_format("%s¤ò¼«Æ°Ç˲õ¤·¤Þ¤¹¡£", o_name);
-#else
-                       msg_format("Auto-destroying %s.", o_name);
-#endif
-                       
-                       continue;
-               }
-       }
-}
-
 
 /*
  * Player "wants" to pick up an object or gold.
index aecb594..2a6029d 100644 (file)
@@ -544,6 +544,9 @@ extern cptr autopick_line_from_entry(autopick_type *entry);
 extern bool autopick_new_entry(autopick_type *entry, cptr str);
 extern void autopick_free_entry(autopick_type *entry);
 extern int is_autopick(object_type *o_ptr);
+extern void auto_inscribe_item(object_type *o_ptr, int idx);
+extern bool auto_destroy_item(s16b item, int autopick_idx);
+extern void auto_pickup_items(cave_type *c_ptr);
 extern void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr);
 extern void do_cmd_edit_autopick();
 
@@ -1072,7 +1075,7 @@ extern bool enchant_spell(int num_hit, int num_dam, int num_ac);
 extern bool artifact_scroll(void);
 extern bool ident_spell(bool only_equip);
 extern bool mundane_spell(bool only_equip);
-extern void identify_item(object_type *o_ptr);
+extern bool identify_item(object_type *o_ptr);
 extern bool identify_fully(bool only_equip);
 extern bool recharge(int num);
 extern bool bless_weapon(void);
index fda8b9a..fd0f2f2 100644 (file)
@@ -2565,16 +2565,16 @@ msg_print("
 /*
  * Identify an object
  */
-void identify_item(object_type *o_ptr)
+bool identify_item(object_type *o_ptr)
 {
-       bool motoart = TRUE;
+       bool old_known = FALSE;
        char o_name[MAX_NLEN];
 
        /* Description */
        object_desc(o_name, o_ptr, TRUE, 3);
 
-       if ((artifact_p(o_ptr) || o_ptr->art_name) && !(o_ptr->ident & IDENT_KNOWN))
-               motoart = FALSE;
+       if (o_ptr->ident & IDENT_KNOWN)
+               old_known = TRUE;
 
        if (!(o_ptr->ident & (IDENT_MENTAL)))
        {
@@ -2601,10 +2601,12 @@ void identify_item(object_type *o_ptr)
        /* Description */
        object_desc(o_name, o_ptr, TRUE, 0);
 
-       if(record_fix_art && !motoart && artifact_p(o_ptr))
+       if(record_fix_art && !old_known && artifact_p(o_ptr))
                do_cmd_write_nikki(NIKKI_ART, 0, o_name);
-       if(record_rand_art && !motoart && o_ptr->art_name)
+       if(record_rand_art && !old_known && o_ptr->art_name)
                do_cmd_write_nikki(NIKKI_ART, 0, o_name);
+
+       return old_known;
 }
 
 
@@ -2631,6 +2633,8 @@ bool ident_spell(bool only_equip)
        object_type     *o_ptr;
        char            o_name[MAX_NLEN];
        cptr            q, s;
+       bool old_known;
+       int idx;
 
        item_tester_no_ryoute = TRUE;
 
@@ -2675,7 +2679,7 @@ s = "
        }
 
        /* Identify it */
-       identify_item(o_ptr);
+       old_known = identify_item(o_ptr);
 
        /* Description */
        object_desc(o_name, o_ptr, TRUE, 3);
@@ -2684,34 +2688,33 @@ s = "
        if (item >= INVEN_RARM)
        {
 #ifdef JP
-msg_format("%^s: %s(%c)¡£",
+               msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
 #else
-               msg_format("%^s: %s (%c).",
+               msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
 #endif
-
-                          describe_use(item), o_name, index_to_label(item));
        }
        else if (item >= 0)
        {
 #ifdef JP
-msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£",
+               msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
 #else
-               msg_format("In your pack: %s (%c).",
+               msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
 #endif
-
-                          o_name, index_to_label(item));
        }
        else
        {
 #ifdef JP
-msg_format("¾²¾å: %s¡£",
+               msg_format("¾²¾å: %s¡£", o_name);
 #else
-               msg_format("On the ground: %s.",
+               msg_format("On the ground: %s.", o_name);
 #endif
-
-                          o_name);
        }
 
+       /* Auto-inscription/destroy */
+       idx = is_autopick(o_ptr);
+       auto_inscribe_item(o_ptr, idx);
+       if (!old_known) auto_destroy_item(item, idx);
+
        /* Something happened */
        return (TRUE);
 }
@@ -2806,6 +2809,8 @@ bool identify_fully(bool only_equip)
        object_type     *o_ptr;
        char            o_name[MAX_NLEN];
        cptr            q, s;
+       bool old_known;
+       int idx;
 
        item_tester_no_ryoute = TRUE;
        if (only_equip)
@@ -2845,7 +2850,7 @@ s = "
        }
 
        /* Identify it */
-       identify_item(o_ptr);
+       old_known = identify_item(o_ptr);
 
        /* Mark the item as fully known */
        o_ptr->ident |= (IDENT_MENTAL);
@@ -2860,37 +2865,38 @@ s = "
        if (item >= INVEN_RARM)
        {
 #ifdef JP
-msg_format("%^s: %s(%c)¡£",
+               msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
 #else
-               msg_format("%^s: %s (%c).",
+               msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
 #endif
 
-                          describe_use(item), o_name, index_to_label(item));
+
        }
        else if (item >= 0)
        {
 #ifdef JP
-msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£",
+               msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
 #else
-               msg_format("In your pack: %s (%c).",
+               msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
 #endif
-
-                          o_name, index_to_label(item));
        }
        else
        {
 #ifdef JP
-msg_format("¾²¾å: %s¡£",
+               msg_format("¾²¾å: %s¡£", o_name);
 #else
-               msg_format("On the ground: %s.",
+               msg_format("On the ground: %s.", o_name);
 #endif
-
-                          o_name);
        }
 
        /* Describe it fully */
        (void)identify_fully_aux(o_ptr);
 
+       /* Auto-inscription/destroy */
+       idx = is_autopick(o_ptr);
+       auto_inscribe_item(o_ptr, idx);
+       if (!old_known) auto_destroy_item(item, idx);
+
        /* Success */
        return (TRUE);
 }