change #vanquished from wizard mode to normal play

Make the existing '#vanquished' command be available during regular
play, with M-V bound to it.  'm #vanquished' or 'm M-V' brings up
the sorting menu that you get when answering 'a' rather than 'y' at
the end-of-game "disclose vanquished creatures?" prompt.

The original #vanquished came from slash'em, where it was available
in normal play.  When added to nethack, it was put in as wizard-mode-
only. I added the sorting capability several years ago.

The chosen sort is remembered and re-used if not reset but only for
the remainder of the current session.  It probably ought of become
a run-time option so be settable in advance and across sessions but
I haven't done that.
This commit is contained in:
PatR
2022-11-03 00:00:34 -07:00
parent 5ac048c8a6
commit f6b3b968e7
7 changed files with 76 additions and 32 deletions
+1
View File
@@ -140,6 +140,7 @@ M-s sit sit down
M-t turn turn undead if role allows that M-t turn turn undead if role allows that
M-T tip upend a container to dump out its contents M-T tip upend a container to dump out its contents
M-u untrap untrap something M-u untrap untrap something
M-V vanquished list number and type of vanquished monsters
M-v version print compile time options for this version M-v version print compile time options for this version
M-w wipe wipe off your face M-w wipe wipe off your face
M-X explore switch from regular play to non-scoring explore mode M-X explore switch from regular play to non-scoring explore mode
-1
View File
@@ -19,7 +19,6 @@ Debug-Mode Quick Reference:
#stats == show memory statistics #stats == show memory statistics
#terrain == show current level (more options than in normal play) #terrain == show current level (more options than in normal play)
#timeout == look at timeout queue and hero's timed intrinsics #timeout == look at timeout queue and hero's timed intrinsics
#vanquished == disclose counts of dead monsters sorted in various ways
#vision == show vision array #vision == show vision array
#wizborn == show monster birth/death/geno/extinct stats #wizborn == show monster birth/death/geno/extinct stats
#wizcast == cast any spell #wizcast == cast any spell
+17 -2
View File
@@ -1672,9 +1672,22 @@ In some circumstances it can also be used to rescue trapped monsters.
Go up a staircase. Go up a staircase.
Default key is \(oq<\(cq. Default key is \(oq<\(cq.
.lp #vanquished .lp #vanquished
List vanquished monsters. List vanquished monsters by type and count.
.lp ""
Note that the vanquished monsters list includes all monsters killed by
traps and each other as well as by you, and omits any which got removed
from the game without being killed (perhaps by genocide, or by a mollified
shopkeeper dismissing summoned Kops).
.lp ""
Using the \(lqrequest menu\(rq prefix prior to #vanquished brings up
a menu of sorting orders available.
Whichever one is picked is remembered for subsequent #vanquished commands
during the current play session but not saved and restored across sessions.
During end-of-game disclosure, when asked whether to show vanquished
monsters answering \(oq\f(CRa\fP\(cq will let you choose from the sort menu.
.lp ""
Autocompletes. Autocompletes.
Debug mode only. Default key is \(oqM-V\(cq.
.lp "#version " .lp "#version "
Print compile time options for this version of NetHack. Print compile time options for this version of NetHack.
.lp "" .lp ""
@@ -1875,6 +1888,8 @@ option is enabled)
#untrap #untrap
.lp M-v .lp M-v
#version #version
.lp M-V
#vanquished
.lp M-w .lp M-w
#wipe #wipe
.lp M-X .lp M-X
+21 -2
View File
@@ -1795,9 +1795,25 @@ In some circumstances it can also be used to rescue trapped monsters.
Go up a staircase. Default key is `{\tt <}'. Go up a staircase. Default key is `{\tt <}'.
%.lp %.lp
\item[\tb{\#vanquished}] \item[\tb{\#vanquished}]
List vanquished monsters. List vanquished monsters by type and count.
\\
%.lp ""
Note that the vanquished monsters list includes all monsters killed by
traps and each other as well as by you, and omits any which got removed
from the game without being killed (perhaps by genocide, or by a mollified
shopkeeper dismissing summoned Kops).
\\
%.lp ""
Using the ``request menu'' prefix prior to \#vanquished brings up
a menu of sort orders available.
Whichever one is picked is remembered for subsequent \#vanquished commands
during the current play session but not saved and restored across sessions.
During end-of-game disclosure, when asked whether to show vanquished
monsters answering `{\tt a}' will let you choose from the sort menu.
\\
%.lp ""
Autocompletes. Autocompletes.
Debug mode only. Default key is `{\tt M-V}'.
%.lp %.lp
\item[\tb{\#version}] \item[\tb{\#version}]
Print compile time options for this version of {\it NetHack\/}. Print compile time options for this version of {\it NetHack\/}.
@@ -2041,6 +2057,9 @@ equivalent is used for another command, so the three key combination
\item[\tb{M-v}] \item[\tb{M-v}]
{\tt\#version} {\tt\#version}
%.lp %.lp
\item[\tb{M-V}]
{\tt\#vanquished}
%.lp
\item[\tb{M-w}] \item[\tb{M-w}]
{\tt\#wipe} {\tt\#wipe}
%.lp %.lp
+1
View File
@@ -1874,6 +1874,7 @@ add some tins of spinach to monk's quest (vegan => no Str from giant corpses)
very large humanoids can wear mummy wrappings very large humanoids can wear mummy wrappings
for ranger characters, shooting any type of arrow while wielding the Longbow for ranger characters, shooting any type of arrow while wielding the Longbow
of Diana gets an extra +1 to multi-shot of Diana gets an extra +1 to multi-shot
change the #vanquished command from debug-only to general user command
Platform- and/or Interface-Specific New Features Platform- and/or Interface-Specific New Features
+2 -2
View File
@@ -2724,8 +2724,8 @@ struct ext_func_tab extcmdlist[] = {
{ '<', "up", "go up a staircase", { '<', "up", "go up a staircase",
/* (see comment for dodown() above */ /* (see comment for dodown() above */
doup, CMD_M_PREFIX, NULL }, doup, CMD_M_PREFIX, NULL },
{ '\0', "vanquished", "list vanquished monsters", { M('V'), "vanquished", "list vanquished monsters",
dovanquished, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL }, dovanquished, IFBURIED | AUTOCOMPLETE | CMD_M_PREFIX, NULL },
{ M('v'), "version", { M('v'), "version",
"list compile time options for this version of NetHack", "list compile time options for this version of NetHack",
doextversion, IFBURIED | AUTOCOMPLETE | GENERALCMD, NULL }, doextversion, IFBURIED | AUTOCOMPLETE | GENERALCMD, NULL },
+34 -25
View File
@@ -2485,19 +2485,22 @@ show_gamelog(int final)
* Vanquished monsters. * Vanquished monsters.
*/ */
static const char *vanqorders[NUM_VANQ_ORDER_MODES] = { /* the two uppercase choices are implemented but suppressed from menu */
"traditional: by monster level, by internal monster index", static const char *vanqorders[NUM_VANQ_ORDER_MODES][2] = {
"by monster toughness, by internal monster index", { "t", "traditional: by monster level, by internal monster index" },
"alphabetically, first unique monsters, then others", { "d", "by monster difficulty rating, by internal monster index" },
"alphabetically, unique monsters and others intermixed", { "a", "alphabetically, first unique monsters, then others" },
"by monster class, high to low level within class", { "A", "alphabetically, unique monsters and others intermixed" },
"by monster class, low to high level within class", { "C", "by monster class, high to low level within class" },
"by count, high to low, by internal index within tied count", { "c", "by monster class, low to high level within class" },
"by count, low to high, by internal index within tied count", { "n", "by count, high to low, by internal index within tied count" },
{ "z", "by count, low to high, by internal index within tied count" },
}; };
static int QSORTCALLBACK static int QSORTCALLBACK
vanqsort_cmp(const genericptr vptr1, const genericptr vptr2) vanqsort_cmp(
const genericptr vptr1,
const genericptr vptr2)
{ {
int indx1 = *(short *) vptr1, indx2 = *(short *) vptr2, int indx1 = *(short *) vptr1, indx2 = *(short *) vptr2,
mlev1, mlev2, mstr1, mstr2, uniq1, uniq2, died1, died2, res; mlev1, mlev2, mstr1, mstr2, uniq1, uniq2, died1, died2, res;
@@ -2508,12 +2511,14 @@ vanqsort_cmp(const genericptr vptr1, const genericptr vptr2)
default: default:
case VANQ_MLVL_MNDX: case VANQ_MLVL_MNDX:
/* sort by monster level */ /* sort by monster level */
mlev1 = mons[indx1].mlevel, mlev2 = mons[indx2].mlevel; mlev1 = mons[indx1].mlevel;
mlev2 = mons[indx2].mlevel;
res = mlev2 - mlev1; /* mlevel high to low */ res = mlev2 - mlev1; /* mlevel high to low */
break; break;
case VANQ_MSTR_MNDX: case VANQ_MSTR_MNDX:
/* sort by monster toughness */ /* sort by monster toughness */
mstr1 = mons[indx1].difficulty, mstr2 = mons[indx2].difficulty; mstr1 = mons[indx1].difficulty;
mstr2 = mons[indx2].difficulty;
res = mstr2 - mstr1; /* monstr high to low */ res = mstr2 - mstr1; /* monstr high to low */
break; break;
case VANQ_ALPHA_SEP: case VANQ_ALPHA_SEP:
@@ -2525,8 +2530,8 @@ vanqsort_cmp(const genericptr vptr1, const genericptr vptr2)
} /* else both unique or neither unique */ } /* else both unique or neither unique */
/*FALLTHRU*/ /*FALLTHRU*/
case VANQ_ALPHA_MIX: case VANQ_ALPHA_MIX:
name1 = mons[indx1].pmnames[NEUTRAL], name1 = mons[indx1].pmnames[NEUTRAL];
name2 = mons[indx2].pmnames[NEUTRAL]; name2 = mons[indx2].pmnames[NEUTRAL];
res = strcmpi(name1, name2); /* caseblind alhpa, low to high */ res = strcmpi(name1, name2); /* caseblind alhpa, low to high */
break; break;
case VANQ_MCLS_HTOL: case VANQ_MCLS_HTOL:
@@ -2535,7 +2540,8 @@ vanqsort_cmp(const genericptr vptr1, const genericptr vptr2)
if 'char' happens to be unsigned, (mlet1 - mlet2) would yield if 'char' happens to be unsigned, (mlet1 - mlet2) would yield
an inappropriate result when mlet2 is greater than mlet1, an inappropriate result when mlet2 is greater than mlet1,
so force our copies (mcls1, mcls2) to be signed */ so force our copies (mcls1, mcls2) to be signed */
mcls1 = (schar) mons[indx1].mlet, mcls2 = (schar) mons[indx2].mlet; mcls1 = (schar) mons[indx1].mlet;
mcls2 = (schar) mons[indx2].mlet;
/* S_ANT through S_ZRUTY correspond to lowercase monster classes, /* S_ANT through S_ZRUTY correspond to lowercase monster classes,
S_ANGEL through S_ZOMBIE correspond to uppercase, and various S_ANGEL through S_ZOMBIE correspond to uppercase, and various
punctuation characters are used for classes beyond those */ punctuation characters are used for classes beyond those */
@@ -2555,7 +2561,8 @@ vanqsort_cmp(const genericptr vptr1, const genericptr vptr2)
} }
res = mcls1 - mcls2; /* class */ res = mcls1 - mcls2; /* class */
if (res == 0) { if (res == 0) {
mlev1 = mons[indx1].mlevel, mlev2 = mons[indx2].mlevel; mlev1 = mons[indx1].mlevel;
mlev2 = mons[indx2].mlevel;
res = mlev1 - mlev2; /* mlevel low to high */ res = mlev1 - mlev2; /* mlevel low to high */
if (g.vanq_sortmode == VANQ_MCLS_HTOL) if (g.vanq_sortmode == VANQ_MCLS_HTOL)
res = -res; /* mlevel high to low */ res = -res; /* mlevel high to low */
@@ -2563,7 +2570,8 @@ vanqsort_cmp(const genericptr vptr1, const genericptr vptr2)
break; break;
case VANQ_COUNT_H_L: case VANQ_COUNT_H_L:
case VANQ_COUNT_L_H: case VANQ_COUNT_L_H:
died1 = g.mvitals[indx1].died, died2 = g.mvitals[indx2].died; died1 = g.mvitals[indx1].died;
died2 = g.mvitals[indx2].died;
res = died2 - died1; /* dead count high to low */ res = died2 - died1; /* dead count high to low */
if (g.vanq_sortmode == VANQ_COUNT_L_H) if (g.vanq_sortmode == VANQ_COUNT_L_H)
res = -res; /* dead count low to high */ res = -res; /* dead count low to high */
@@ -2592,10 +2600,10 @@ set_vanq_order(void)
if (i == VANQ_ALPHA_MIX || i == VANQ_MCLS_HTOL) /* skip these */ if (i == VANQ_ALPHA_MIX || i == VANQ_MCLS_HTOL) /* skip these */
continue; continue;
any.a_int = i + 1; any.a_int = i + 1;
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, add_menu(tmpwin, &nul_glyphinfo, &any, *vanqorders[i][0], 0,
vanqorders[i], ATR_NONE, clr, vanqorders[i][1],
(i == g.vanq_sortmode) (i == g.vanq_sortmode) ? MENU_ITEMFLAGS_SELECTED
? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); : MENU_ITEMFLAGS_NONE);
} }
end_menu(tmpwin, "Sort order for vanquished monster counts"); end_menu(tmpwin, "Sort order for vanquished monster counts");
@@ -2616,7 +2624,7 @@ set_vanq_order(void)
int int
dovanquished(void) dovanquished(void)
{ {
list_vanquished('a', FALSE); list_vanquished(iflags.menu_requested ? 'a' : 'y', FALSE);
return ECMD_OK; return ECMD_OK;
} }
@@ -2706,15 +2714,16 @@ list_vanquished(char defquery, boolean ask)
if (c == 'q') if (c == 'q')
done_stopprint++; done_stopprint++;
if (c == 'y' || c == 'a') { if (c == 'y' || c == 'a') {
if (c == 'a') { /* ask player to choose sort order */ if (c == 'a' && ntypes > 1) { /* ask player to choose sort order */
/* choose value for vanq_sortmode via menu; ESC cancels list /* choose value for vanq_sortmode via menu; ESC cancels list
of vanquished monsters but does not set 'done_stopprint' */ of vanquished monsters but does not set 'done_stopprint' */
if (set_vanq_order() < 0) if (set_vanq_order() < 0)
return; return;
} }
uniq_header = (g.vanq_sortmode == VANQ_ALPHA_SEP); uniq_header = (g.vanq_sortmode == VANQ_ALPHA_SEP);
class_header = (g.vanq_sortmode == VANQ_MCLS_LTOH class_header = ((g.vanq_sortmode == VANQ_MCLS_LTOH
|| g.vanq_sortmode == VANQ_MCLS_HTOL); || g.vanq_sortmode == VANQ_MCLS_HTOL)
&& ntypes > 1);
klwin = create_nhwindow(NHW_MENU); klwin = create_nhwindow(NHW_MENU);
putstr(klwin, 0, "Vanquished creatures:"); putstr(klwin, 0, "Vanquished creatures:");