From a582e4f4171e4d9dc98c1acbe8007810dc7c2254 Mon Sep 17 00:00:00 2001 From: mogami Date: Mon, 6 May 2002 08:24:59 +0000 Subject: [PATCH] =?utf8?q?=E8=87=AA=E5=8B=95=E7=A0=B4=E5=A3=8A=E3=81=A8?= =?utf8?q?=E8=87=AA=E5=8B=95=E5=88=BB=E3=81=BF=E6=A9=9F=E8=83=BD=E3=82=92?= =?utf8?q?=E3=80=81=E5=BA=8A=E4=B8=8A=E3=82=84=E6=8C=81=E3=81=A1=E7=89=A9?= =?utf8?q?=E3=81=AE=E9=91=91=E5=AE=9A=E3=81=AE=E5=BE=8C=E3=81=AB=E3=82=82?= =?utf8?q?=E9=81=A9=E7=94=A8=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?utf8?q?=E3=81=97=E3=81=9F=E3=80=82=20=E4=B8=A6=E3=81=AE=E6=AD=A6?= =?utf8?q?=E5=99=A8=E3=82=92=E7=A0=B4=E5=A3=8A=E3=81=99=E3=82=8B=E8=A8=AD?= =?utf8?q?=E5=AE=9A=E3=82=92=E3=81=97=E3=81=A6=E3=81=82=E3=82=8C=E3=81=B0?= =?utf8?q?=E3=80=81=E9=91=91=E5=AE=9A=E3=81=97=E3=81=9F=E7=9E=AC=E9=96=93?= =?utf8?q?=E3=81=AB=E7=A0=B4=E5=A3=8A=E3=80=81=20%=E5=88=BB=E3=81=BF?= =?utf8?q?=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=82=92=E3=81=97=E3=81=A6=E3=81=82?= =?utf8?q?=E3=82=8C=E3=81=B0*=E9=91=91=E5=AE=9A*=E3=81=97=E3=81=9F?= =?utf8?q?=E7=9E=AC=E9=96=93=E3=81=AB=E8=80=90=E6=80=A7=E5=88=BB=E3=81=BF?= =?utf8?q?=E3=80=81=E7=AD=89=E3=81=8C=E3=81=A7=E3=81=8D=E3=82=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/autopick.c | 203 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/cmd1.c | 142 ---------------------------------------- src/externs.h | 5 +- src/spells3.c | 68 ++++++++++--------- 4 files changed, 244 insertions(+), 174 deletions(-) diff --git a/src/autopick.c b/src/autopick.c index f33133972..6add8882c 100644 --- a/src/autopick.c +++ b/src/autopick.c @@ -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) diff --git a/src/cmd1.c b/src/cmd1.c index fed0ccc10..9a330612d 100644 --- a/src/cmd1.c +++ b/src/cmd1.c @@ -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. diff --git a/src/externs.h b/src/externs.h index aecb594dc..2a6029d66 100644 --- a/src/externs.h +++ b/src/externs.h @@ -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); diff --git a/src/spells3.c b/src/spells3.c index fda8b9aa2..fd0f2f29c 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -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); } -- 2.11.0