identify_pack (trunk only)

Three years ago <email deleted> reported that
stepping off the end of inventory via typing space to go to the next menu
page wasted his identify scroll.  He suggested that some people might do
that because they don't know how to back up in a multi-page menu.  I
pointed out the Guidebook section that describes < and ^ to go back one
page or back to start and left things at that.  However, traditional mode
reprompts if you step through all of inventory without choosing something,
so this changes identify-via-menu to do likewise.  You can dismiss the
menu with ESC to really avoid choosing anything.

     This also makes identification of N items when you're carrying N or
fewer unID'd things behave the same as identify all:  identify everything
without any prompting.
This commit is contained in:
nethack.rankin
2008-02-16 02:31:34 +00:00
parent 406582009b
commit da172c5773
4 changed files with 27 additions and 13 deletions
+1
View File
@@ -280,6 +280,7 @@ implement energy vortex's previously unused energy drain attack
changing alignment type resets alignment record to 0 (nomimally aligned) changing alignment type resets alignment record to 0 (nomimally aligned)
while polymorphed, suppress attribute gain/lose earned by pre-poly exercise while polymorphed, suppress attribute gain/lose earned by pre-poly exercise
wizard mode #monpolycontrol prompting asked about "it" when monster was unseen wizard mode #monpolycontrol prompting asked about "it" when monster was unseen
reprompt if player fails to make a menu choice during inventory identification
Platform- and/or Interface-Specific Fixes Platform- and/or Interface-Specific Fixes
+3 -2
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)hack.h 3.5 2008/01/30 */ /* SCCS Id: @(#)hack.h 3.5 2008/02/15 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -221,7 +221,8 @@ NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */
#define USE_INVLET 0x4 /* use object's invlet */ #define USE_INVLET 0x4 /* use object's invlet */
#define INVORDER_SORT 0x8 /* sort objects by packorder */ #define INVORDER_SORT 0x8 /* sort objects by packorder */
#define SIGNAL_NOMENU 0x10 /* return -1 rather than 0 if none allowed */ #define SIGNAL_NOMENU 0x10 /* return -1 rather than 0 if none allowed */
#define FEEL_COCKATRICE 0x20 /* engage cockatrice checks and react */ #define SIGNAL_ESCAPE 0x20 /* return -2 rather than 0 for ESC */
#define FEEL_COCKATRICE 0x40 /* engage cockatrice checks and react */
/* Flags to control query_category() */ /* Flags to control query_category() */
/* BY_NEXTHERE used by query_category() too, so skip 0x01 */ /* BY_NEXTHERE used by query_category() too, so skip 0x01 */
+17 -9
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)invent.c 3.5 2007/11/01 */ /* SCCS Id: @(#)invent.c 3.5 2008/02/15 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1626,15 +1626,16 @@ menu_identify(id_limit)
int id_limit; int id_limit;
{ {
menu_item *pick_list; menu_item *pick_list;
int n, i, first = 1; int n, i, first = 1, tryct = 5;
char buf[BUFSZ]; char buf[BUFSZ];
/* assumptions: id_limit > 0 and at least one unID'd item is present */ /* assumptions: id_limit > 0 and at least one unID'd item is present */
while (id_limit) { while (id_limit) {
Sprintf(buf, "What would you like to identify %s?", Sprintf(buf, "What would you like to identify %s?",
first ? "first" : "next"); first ? "first" : "next");
n = query_objlist(buf, invent, SIGNAL_NOMENU|USE_INVLET|INVORDER_SORT, n = query_objlist(buf, invent,
&pick_list, PICK_ANY, not_fully_identified); SIGNAL_NOMENU|SIGNAL_ESCAPE|USE_INVLET|INVORDER_SORT,
&pick_list, PICK_ANY, not_fully_identified);
if (n > 0) { if (n > 0) {
if (n > id_limit) n = id_limit; if (n > id_limit) n = id_limit;
@@ -1642,11 +1643,18 @@ int id_limit;
(void) identify(pick_list[i].item.a_obj); (void) identify(pick_list[i].item.a_obj);
free((genericptr_t) pick_list); free((genericptr_t) pick_list);
mark_synch(); /* Before we loop to pop open another menu */ mark_synch(); /* Before we loop to pop open another menu */
} else { first = 0;
if (n < 0) pline("That was all."); } else if (n == -2) { /* player used ESC to quit menu */
id_limit = 0; /* Stop now */ break;
} else if (n == -1) { /* no eligible items found */
pline("That was all.");
break;
} else if (!--tryct) { /* stop re-prompting */
pline(thats_enough_tries);
break;
} else { /* try again */
pline("Choose an item; use ESC to decline.");
} }
first = 0;
} }
} }
@@ -1667,7 +1675,7 @@ boolean learning_id; /* true if we just read unknown identify scroll */
if (!unid_cnt) { if (!unid_cnt) {
You("have already identified all %sof your possessions.", You("have already identified all %sof your possessions.",
learning_id ? "the rest " : ""); learning_id ? "the rest " : "");
} else if (!id_limit) { } else if (!id_limit || id_limit >= unid_cnt) {
/* identify everything */ /* identify everything */
if (unid_cnt == 1) { if (unid_cnt == 1) {
(void) identify(the_obj); (void) identify(the_obj);
+6 -2
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)pickup.c 3.5 2007/04/25 */ /* SCCS Id: @(#)pickup.c 3.5 2008/02/15 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -717,6 +717,8 @@ menu_item **pick_list; /* list of objects and counts to pick up */
* USE_INVLET - Use object's invlet. * USE_INVLET - Use object's invlet.
* INVORDER_SORT - Use hero's pack order. * INVORDER_SORT - Use hero's pack order.
* SIGNAL_NOMENU - Return -1 rather than 0 if nothing passes "allow". * SIGNAL_NOMENU - Return -1 rather than 0 if nothing passes "allow".
* SIGNAL_ESCAPE - Return -1 rather than 0 if player uses ESC to
* pick nothing.
*/ */
int int
query_objlist(qstr, olist, qflags, pick_list, how, allow) query_objlist(qstr, olist, qflags, pick_list, how, allow)
@@ -808,7 +810,9 @@ boolean FDECL((*allow), (OBJ_P));/* allow function */
if (mi->count == -1L || mi->count > mi->item.a_obj->quan) if (mi->count == -1L || mi->count > mi->item.a_obj->quan)
mi->count = mi->item.a_obj->quan; mi->count = mi->item.a_obj->quan;
} else if (n < 0) { } else if (n < 0) {
n = 0; /* caller's don't expect -1 */ /* -1 is used for SIGNAL_NOMENU, so callers don't expect it
to indicate that the player declined to make a choice */
n = (qflags & SIGNAL_ESCAPE) ? -2 : 0;
} }
return n; return n;
} }