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
dat/hh
View File

@@ -140,6 +140,7 @@ M-s sit sit down
M-t turn turn undead if role allows that
M-T tip upend a container to dump out its contents
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-w wipe wipe off your face
M-X explore switch from regular play to non-scoring explore mode

View File

@@ -19,7 +19,6 @@ Debug-Mode Quick Reference:
#stats == show memory statistics
#terrain == show current level (more options than in normal play)
#timeout == look at timeout queue and hero's timed intrinsics
#vanquished == disclose counts of dead monsters sorted in various ways
#vision == show vision array
#wizborn == show monster birth/death/geno/extinct stats
#wizcast == cast any spell

View File

@@ -1672,9 +1672,22 @@ In some circumstances it can also be used to rescue trapped monsters.
Go up a staircase.
Default key is \(oq<\(cq.
.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.
Debug mode only.
Default key is \(oqM-V\(cq.
.lp "#version "
Print compile time options for this version of NetHack.
.lp ""
@@ -1875,6 +1888,8 @@ option is enabled)
#untrap
.lp M-v
#version
.lp M-V
#vanquished
.lp M-w
#wipe
.lp M-X

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 <}'.
%.lp
\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.
Debug mode only.
Default key is `{\tt M-V}'.
%.lp
\item[\tb{\#version}]
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}]
{\tt\#version}
%.lp
\item[\tb{M-V}]
{\tt\#vanquished}
%.lp
\item[\tb{M-w}]
{\tt\#wipe}
%.lp

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
for ranger characters, shooting any type of arrow while wielding the Longbow
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

View File

@@ -2724,8 +2724,8 @@ struct ext_func_tab extcmdlist[] = {
{ '<', "up", "go up a staircase",
/* (see comment for dodown() above */
doup, CMD_M_PREFIX, NULL },
{ '\0', "vanquished", "list vanquished monsters",
dovanquished, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL },
{ M('V'), "vanquished", "list vanquished monsters",
dovanquished, IFBURIED | AUTOCOMPLETE | CMD_M_PREFIX, NULL },
{ M('v'), "version",
"list compile time options for this version of NetHack",
doextversion, IFBURIED | AUTOCOMPLETE | GENERALCMD, NULL },

View File

@@ -2485,19 +2485,22 @@ show_gamelog(int final)
* Vanquished monsters.
*/
static const char *vanqorders[NUM_VANQ_ORDER_MODES] = {
"traditional: by monster level, by internal monster index",
"by monster toughness, by internal monster index",
"alphabetically, first unique monsters, then others",
"alphabetically, unique monsters and others intermixed",
"by monster class, high to low level within class",
"by monster class, low to high level within class",
"by count, high to low, by internal index within tied count",
"by count, low to high, by internal index within tied count",
/* the two uppercase choices are implemented but suppressed from menu */
static const char *vanqorders[NUM_VANQ_ORDER_MODES][2] = {
{ "t", "traditional: by monster level, by internal monster index" },
{ "d", "by monster difficulty rating, by internal monster index" },
{ "a", "alphabetically, first unique monsters, then others" },
{ "A", "alphabetically, unique monsters and others intermixed" },
{ "C", "by monster class, high to low level within class" },
{ "c", "by monster class, low to high level within class" },
{ "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
vanqsort_cmp(const genericptr vptr1, const genericptr vptr2)
vanqsort_cmp(
const genericptr vptr1,
const genericptr vptr2)
{
int indx1 = *(short *) vptr1, indx2 = *(short *) vptr2,
mlev1, mlev2, mstr1, mstr2, uniq1, uniq2, died1, died2, res;
@@ -2508,12 +2511,14 @@ vanqsort_cmp(const genericptr vptr1, const genericptr vptr2)
default:
case VANQ_MLVL_MNDX:
/* 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 */
break;
case VANQ_MSTR_MNDX:
/* 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 */
break;
case VANQ_ALPHA_SEP:
@@ -2525,8 +2530,8 @@ vanqsort_cmp(const genericptr vptr1, const genericptr vptr2)
} /* else both unique or neither unique */
/*FALLTHRU*/
case VANQ_ALPHA_MIX:
name1 = mons[indx1].pmnames[NEUTRAL],
name2 = mons[indx2].pmnames[NEUTRAL];
name1 = mons[indx1].pmnames[NEUTRAL];
name2 = mons[indx2].pmnames[NEUTRAL];
res = strcmpi(name1, name2); /* caseblind alhpa, low to high */
break;
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
an inappropriate result when mlet2 is greater than mlet1,
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_ANGEL through S_ZOMBIE correspond to uppercase, and various
punctuation characters are used for classes beyond those */
@@ -2555,7 +2561,8 @@ vanqsort_cmp(const genericptr vptr1, const genericptr vptr2)
}
res = mcls1 - mcls2; /* class */
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 */
if (g.vanq_sortmode == VANQ_MCLS_HTOL)
res = -res; /* mlevel high to low */
@@ -2563,7 +2570,8 @@ vanqsort_cmp(const genericptr vptr1, const genericptr vptr2)
break;
case VANQ_COUNT_H_L:
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 */
if (g.vanq_sortmode == VANQ_COUNT_L_H)
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 */
continue;
any.a_int = i + 1;
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr,
vanqorders[i],
(i == g.vanq_sortmode)
? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE);
add_menu(tmpwin, &nul_glyphinfo, &any, *vanqorders[i][0], 0,
ATR_NONE, clr, vanqorders[i][1],
(i == g.vanq_sortmode) ? MENU_ITEMFLAGS_SELECTED
: MENU_ITEMFLAGS_NONE);
}
end_menu(tmpwin, "Sort order for vanquished monster counts");
@@ -2616,7 +2624,7 @@ set_vanq_order(void)
int
dovanquished(void)
{
list_vanquished('a', FALSE);
list_vanquished(iflags.menu_requested ? 'a' : 'y', FALSE);
return ECMD_OK;
}
@@ -2706,15 +2714,16 @@ list_vanquished(char defquery, boolean ask)
if (c == 'q')
done_stopprint++;
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
of vanquished monsters but does not set 'done_stopprint' */
if (set_vanq_order() < 0)
return;
}
uniq_header = (g.vanq_sortmode == VANQ_ALPHA_SEP);
class_header = (g.vanq_sortmode == VANQ_MCLS_LTOH
|| g.vanq_sortmode == VANQ_MCLS_HTOL);
class_header = ((g.vanq_sortmode == VANQ_MCLS_LTOH
|| g.vanq_sortmode == VANQ_MCLS_HTOL)
&& ntypes > 1);
klwin = create_nhwindow(NHW_MENU);
putstr(klwin, 0, "Vanquished creatures:");