From 79cdcff7e44fe47b39b9ee9f66237e2f2987c0cf Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Wed, 29 Nov 2023 19:20:07 -0500 Subject: [PATCH 01/78] Fix: msg_window:combination and TTY getlin() ^P The ability to use ^P from within a TTY getlin prompt didn't work with msg_window:combination: it's a combination (unsurprisingly) of 'full' and 'single', but hooked_tty_getlin() was treating it like 'full': i.e. expecting everything to be displayed at once, with doprev_message() returning only once the user was finished reading. I didn't even know ^P was supposed to be accessible from a getlin prompt until Pat's recent commit 5120764, because I have always used msg_window:combination -- I had come up with a system where I'd name a potion thrown at me "xx", check the previous messages with ^P, and then rename it from the discoveries list. This will be a lot easier! --- win/tty/getline.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/win/tty/getline.c b/win/tty/getline.c index 38215abd18..093ef37ccb 100644 --- a/win/tty/getline.c +++ b/win/tty/getline.c @@ -48,7 +48,7 @@ hooked_tty_getlin( register char *obufp = bufp; register int c; struct WinDesc *cw = wins[WIN_MESSAGE]; - boolean doprev = 0; + boolean doprev = FALSE; if (ttyDisplay->toplin == TOPLINE_NEED_MORE && !(cw->flags & WIN_STOP)) more(); @@ -100,29 +100,36 @@ hooked_tty_getlin( *bufp = 0; } if (c == C('p')) { /* ctrl-P, doesn't honor rebinding #prevmsg cmd */ - if (iflags.prevmsg_window != 's') { - int sav = ttyDisplay->inread; + int sav = ttyDisplay->inread; - ttyDisplay->inread = 0; + ttyDisplay->inread = 0; + if (iflags.prevmsg_window == 's' + || (iflags.prevmsg_window == 'c' && !doprev)) { + /* msg_window:single, or msg_window:combination while it's + behaving like msg_window:single */ + if (!doprev) + (void) tty_doprev_message(); /* need two initially */ + (void) tty_doprev_message(); + ttyDisplay->inread = sav; + doprev = TRUE; + continue; + } else { + /* msg_window:full or reverse, or msg_window:combination while + it's behaving like msg_window:full */ (void) tty_doprev_message(); ttyDisplay->inread = sav; + doprev = FALSE; tty_clear_nhwindow(WIN_MESSAGE); cw->maxcol = cw->maxrow; addtopl(query); addtopl(" "); *bufp = 0; addtopl(obufp); - } else { - if (!doprev) - (void) tty_doprev_message(); /* need two initially */ - (void) tty_doprev_message(); - doprev = 1; - continue; } - } else if (doprev && iflags.prevmsg_window == 's') { + } else if (doprev) { tty_clear_nhwindow(WIN_MESSAGE); cw->maxcol = cw->maxrow; - doprev = 0; + doprev = FALSE; addtopl(query); addtopl(" "); *bufp = 0; From b36d79233464cf4b6dbb0461db39ce5d303ae473 Mon Sep 17 00:00:00 2001 From: SHIRAKATA Kentaro Date: Sun, 21 Aug 2022 21:22:43 +0900 Subject: [PATCH 02/78] remove unnecessary null-check on bhitm() `otmp` here is always non-null, otherwise it leads segv at earlier code. --- src/zap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zap.c b/src/zap.c index 0a66af4da8..70040128e3 100644 --- a/src/zap.c +++ b/src/zap.c @@ -163,7 +163,7 @@ bhitm(struct monst *mtmp, struct obj *otmp) reveal_invis = FALSE; gn.notonhead = (mtmp->mx != gb.bhitpos.x || mtmp->my != gb.bhitpos.y); - skilled_spell = (otmp && otmp->oclass == SPBOOK_CLASS && otmp->blessed); + skilled_spell = (otmp->oclass == SPBOOK_CLASS && otmp->blessed); switch (otyp) { case WAN_STRIKING: From d8421aa219d40f0fdb4e444103d213c35069e987 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Mon, 4 Dec 2023 17:44:51 +0200 Subject: [PATCH 03/78] Save and restore hero tracks The tracks left by hero were cleared when player saved and restored the game, or changed levels. Now the tracks are saved in the dungeon level, so changing levels keeps the tracks left by hero in that level. Also increased the length of tracks from 50 to 100, and simplify the tracking function. Thing not done: fade out old tracks when returning to a level. Breaks saves and bones. --- doc/fixes3-7-0.txt | 1 + include/extern.h | 3 +++ include/patchlevel.h | 2 +- src/allmain.c | 2 +- src/do.c | 2 -- src/restore.c | 1 + src/save.c | 1 + src/teleport.c | 1 - src/track.c | 55 ++++++++++++++++++++++++++++++++++---------- 9 files changed, 51 insertions(+), 17 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index e9f7289bb1..5a0d06e3ce 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1311,6 +1311,7 @@ if a monster fled from hero by intentionally jumping into a vault teleporter, but the spot would remain a secret corridor and not become accessible spellbooks weight 50 units but Book of the Dead only 20, and novels only 1; the Book of the Dead has been changed to 50 and novels to 10 +save and restore hero tracks, increase track length Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/include/extern.h b/include/extern.h index de4802bd8d..f44a56487a 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2919,6 +2919,9 @@ extern int tt_doppel(struct monst *); extern void initrack(void); extern void settrack(void); extern coord *gettrack(coordxy, coordxy); +extern void save_track(NHFILE *); +extern void rest_track(NHFILE *); +extern void printtrack(void); /* ### trap.c ### */ diff --git a/include/patchlevel.h b/include/patchlevel.h index 2ce8c41011..42ba716f61 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -17,7 +17,7 @@ * Incrementing EDITLEVEL can be used to force invalidation of old bones * and save files. */ -#define EDITLEVEL 90 +#define EDITLEVEL 91 /* * Development status possibilities. diff --git a/src/allmain.c b/src/allmain.c index c20175e3c7..6f8c47856c 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -77,6 +77,7 @@ moveloop_preamble(boolean resuming) /* give hero initial movement points; new game only--for restore, pending movement points were included in the save file */ u.umovement = NORMAL_SPEED; + initrack(); } gc.context.botlx = TRUE; /* for STATUS_HILITES */ if (resuming) { /* restoring old game */ @@ -89,7 +90,6 @@ moveloop_preamble(boolean resuming) gd.defer_see_monsters = FALSE; see_monsters(); } - initrack(); u.uz0.dlevel = u.uz.dlevel; gc.context.move = 0; diff --git a/src/do.c b/src/do.c index 4fad35dc43..dd963232ae 100644 --- a/src/do.c +++ b/src/do.c @@ -1787,8 +1787,6 @@ goto_level( if ((mtmp = m_at(u.ux, u.uy)) != 0) u_collide_m(mtmp); - initrack(); - /* initial movement of bubbles just before vision_recalc */ if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz)) movebubbles(); diff --git a/src/restore.c b/src/restore.c index fe9034be6f..109f1770e8 100644 --- a/src/restore.c +++ b/src/restore.c @@ -1150,6 +1150,7 @@ getlev(NHFILE *nhfp, int pid, xint8 lev) rest_regions(nhfp); rest_bubbles(nhfp); /* for water and air; empty marker on other levels */ load_exclusions(nhfp); + rest_track(nhfp); if (ghostly) { stairway *stway = gs.stairs; diff --git a/src/save.c b/src/save.c index 7d04cb1fe5..d8edaaae87 100644 --- a/src/save.c +++ b/src/save.c @@ -554,6 +554,7 @@ savelev_core(NHFILE *nhfp, xint8 lev) save_regions(nhfp); save_bubbles(nhfp, lev); /* for water and air */ save_exclusions(nhfp); + save_track(nhfp); if (nhfp->mode != FREEING) { if (nhfp->structlevel) diff --git a/src/teleport.c b/src/teleport.c index 5183db45b6..f0d30fe297 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -502,7 +502,6 @@ teleds(coordxy nux, coordxy nuy, int teleds_flags) fill_pit(u.ux0, u.uy0); if (ball_active && uchain && uchain->where == OBJ_FREE) placebc(); /* put back the ball&chain if they were taken off map */ - initrack(); /* teleports mess up tracking monsters without this */ update_player_regions(); /* * Make sure the hero disappears from the old location. This will diff --git a/src/track.c b/src/track.c index b5ccd2d7fc..20f0a9d8a1 100644 --- a/src/track.c +++ b/src/track.c @@ -6,7 +6,7 @@ #include "hack.h" -#define UTSZ 50 +#define UTSZ 100 static NEARDATA int utcnt, utpnt; static NEARDATA coord utrack[UTSZ]; @@ -15,6 +15,7 @@ void initrack(void) { utcnt = utpnt = 0; + (void) memset((genericptr_t) &utrack, 0, sizeof(utrack)); } /* add to track */ @@ -30,6 +31,8 @@ settrack(void) utpnt++; } +/* get a track coord on or next to x,y and last tracked by hero, + returns null if no such track */ coord * gettrack(coordxy x, coordxy y) { @@ -43,20 +46,48 @@ gettrack(coordxy x, coordxy y) tc--; ndist = distmin(x, y, tc->x, tc->y); - /* if far away, skip track entries til we're closer */ - if (ndist > 2) { - ndist -= 2; /* be careful due to extra decrement at top of loop */ - cnt -= ndist; - if (cnt <= 0) - return (coord *) 0; /* too far away, no matches possible */ - if (tc < &utrack[ndist]) - tc += (UTSZ - ndist); - else - tc -= ndist; - } else if (ndist <= 1) + if (ndist <= 1) return (ndist ? tc : 0); } return (coord *) 0; } +/* save the hero tracking info */ +void +save_track(NHFILE *nhfp) +{ + if (perform_bwrite(nhfp)) { + if (nhfp->structlevel) { + int i; + + bwrite(nhfp->fd, (genericptr_t) &utcnt, sizeof utcnt); + bwrite(nhfp->fd, (genericptr_t) &utpnt, sizeof utpnt); + for (i = 0; i < utcnt; i++) { + bwrite(nhfp->fd, (genericptr_t) &utrack[i].x, sizeof utrack[i].x); + bwrite(nhfp->fd, (genericptr_t) &utrack[i].y, sizeof utrack[i].y); + } + } + } + if (release_data(nhfp)) + initrack(); +} + +/* restore the hero tracking info */ +void +rest_track(NHFILE *nhfp) +{ + if (nhfp->structlevel) { + int i; + + mread(nhfp->fd, (genericptr_t) &utcnt, sizeof utcnt); + mread(nhfp->fd, (genericptr_t) &utpnt, sizeof utpnt); + if (utcnt > UTSZ || utpnt > UTSZ) + panic("rest_track: impossible pt counts"); + for (i = 0; i < utcnt; i++) { + mread(nhfp->fd, (genericptr_t) &utrack[i].x, sizeof utrack[i].x); + mread(nhfp->fd, (genericptr_t) &utrack[i].y, sizeof utrack[i].y); + } + } +} + /*track.c*/ From 1c933d689ea1defd28ce31d0c850b51fd17402f5 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Mon, 4 Dec 2023 17:57:58 +0200 Subject: [PATCH 04/78] Remove leftover debug extern define --- include/extern.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/extern.h b/include/extern.h index f44a56487a..a8f57c305a 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2921,7 +2921,6 @@ extern void settrack(void); extern coord *gettrack(coordxy, coordxy); extern void save_track(NHFILE *); extern void rest_track(NHFILE *); -extern void printtrack(void); /* ### trap.c ### */ From d8909ec3d0a53368adfeacb7c90ce06303655c14 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 4 Dec 2023 11:26:50 -0500 Subject: [PATCH 05/78] comment 1st dereference of otmp in bhitm() --- src/zap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zap.c b/src/zap.c index 498cda0239..ca2ae21f8b 100644 --- a/src/zap.c +++ b/src/zap.c @@ -153,7 +153,7 @@ bhitm(struct monst *mtmp, struct obj *otmp) boolean reveal_invis = FALSE, learn_it = FALSE; boolean dbldam = Role_if(PM_KNIGHT) && u.uhave.questart; boolean skilled_spell, helpful_gesture = FALSE; - int dmg, otyp = otmp->otyp; + int dmg, otyp = otmp->otyp; /* otmp is not NULL */ const char *zap_type_text = "spell"; struct obj *obj; boolean disguised_mimic = (mtmp->data->mlet == S_MIMIC From b0f5ad13e1bfd233fba7be64a1a777caabea0d13 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 4 Dec 2023 11:49:39 -0500 Subject: [PATCH 06/78] fixes3-7-0.txt catch up --- doc/fixes3-7-0.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 5a0d06e3ce..c4d2a2403d 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1305,10 +1305,14 @@ alchemy may affect only a portion of the dipped potions if a large monster kills can no longer deathdrop comestibles (other than the monster's corpse) unless the monster collects food or generates with food +about 10% of the heroes will now be left-handed; track the handedness of the + hero in the 'you' struct if a monster fled from hero by intentionally jumping into a vault teleporter, it would teleport randomly instead of into the vault, and if the teleport trap's niche wasn't mapped yet, the trap would become mapped but the spot would remain a secret corridor and not become accessible +boomerang travels in a clockwise arc when thrown by a left-handed hero and in + a counterclockwise arc when thrown by a right-handed hero spellbooks weight 50 units but Book of the Dead only 20, and novels only 1; the Book of the Dead has been changed to 50 and novels to 10 save and restore hero tracks, increase track length From 05f9950c998e8e0f162d1f84ba8f59fd6a0b4430 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Mon, 4 Dec 2023 13:07:43 -0500 Subject: [PATCH 07/78] Fix: fumbling vs losing footing in earthquake Fumbling was apparently meant to make it harder to keep your footing when an earthquake created a pit under you, requiring a 1/5 roll to stay upright, but because it was added as an additional OR it actually just gave the hero an additional (albeit unlikely) chance to retain her footing. Make it actually have a negative impact on the hero's ability to retain his footing rather than a minor boost. --- src/music.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/music.c b/src/music.c index ff667e03c5..045e6e839c 100644 --- a/src/music.c +++ b/src/music.c @@ -415,9 +415,9 @@ do_earthquake(int force) selftouch("Falling, you"); } else if (u.utrap && u.utraptype == TT_PIT) { boolean keepfooting = - ((Fumbling && !rn2(5)) - || (!rnl(Role_if(PM_ARCHEOLOGIST) ? 3 : 9)) - || ((ACURR(A_DEX) > 7) && rn2(5))); + (!(Fumbling && rn2(5)) + && (!(rnl(Role_if(PM_ARCHEOLOGIST) ? 3 : 9)) + || ((ACURR(A_DEX) > 7) && rn2(5)))); You("are jostled around violently!"); set_utrap(rn1(6, 2), TT_PIT); From 418953e0e6162ff29691357a91d08f36809fe495 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 4 Dec 2023 14:20:07 -0500 Subject: [PATCH 08/78] symbol parsing improvement This gets rid of a FIXME and K4056 internal bug report. Allow the comma to be quoted as follows: SYMBOLS=S_ice:\, or SYMBOLS=S_ice:',' Disclaimer: The use of the comma on the map could conflict with future use of that currently unused symbol for other intended purposes. --- src/options.c | 2 ++ src/symbols.c | 38 ++++++++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/options.c b/src/options.c index e8d758d958..94971838c0 100644 --- a/src/options.c +++ b/src/options.c @@ -6491,6 +6491,8 @@ escapes(const char *cp, /* might be 'tp', updating in place */ case 'r': cval = '\r'; break; + case ',': + cval = ','; default: cval = *cp; } diff --git a/src/symbols.c b/src/symbols.c index 8e3456c87b..3d201ad7f8 100644 --- a/src/symbols.c +++ b/src/symbols.c @@ -764,25 +764,43 @@ boolean parsesymbols(register char *opts, int which_set) { int val; - char *op, *symname, *strval; + unsigned i; + char *symname, *strval, *ch = opts, + *first_unquoted_comma = 0, *first_unquoted_colon = 0; const struct symparse *symp; boolean is_glyph = FALSE; - /* - * FIXME: - * The parsing here (and next) yields incorrect results for - * "S_sample=','" or "S_sample=':'". - */ + /* are there any commas or colons that aren't quoted? */ + for (i = 0; i < strlen(opts); ++i) { + char *prech, *postch; - if ((op = strchr(opts, ',')) != 0) { - *op++ = '\0'; - if (!parsesymbols(op, which_set)) + ch++; /* we never want to match on the first char, so this is ok */ + prech = ch - 1; + postch = ch + 1; + if (*ch == ',') { + if (*prech == '\'' && *postch == '\'') + continue; + if (*prech == '\\') + continue; + } + if (*ch == ':') { + if (*prech == '\'' && *postch == '\'') + continue; + } + if (*ch == ',' && !first_unquoted_comma) + first_unquoted_comma = ch; + if (*ch == ':' && !first_unquoted_colon) + first_unquoted_colon = ch; + } + if (first_unquoted_comma != 0) { + *first_unquoted_comma++ = '\0'; + if (!parsesymbols(first_unquoted_comma, which_set)) return FALSE; } /* S_sample:string */ symname = opts; - strval = strchr(opts, ':'); + strval = first_unquoted_colon; if (!strval) strval = strchr(opts, '='); if (!strval) From a15d5173260f728e9a9c24e8231f0edfd539138a Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Mon, 4 Dec 2023 14:40:16 -0500 Subject: [PATCH 09/78] Refine ice fumbling effects vs mounted hero Fumbling makes the hero fall from the saddle, but the justification was weak if the only fumbling source is riding over ice (the messages were things like "you drop the reins" which made more sense from magical fumbling). Make all fumbling from ice alone go into the ice-specific "slip on the ice" block and add a chance to fall from your mount there. If fumbling from another source while riding on ice, the hero will always fall from his steed, since that's what happens on normal floor -- ice had actually been reducing this chance. --- src/timeout.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/timeout.c b/src/timeout.c index 36dd270760..dee2509f78 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -1175,14 +1175,23 @@ slip_or_trip(void) an(mons[otmp->corpsenm].pmnames[NEUTRAL])); instapetrify(gk.killer.name); } - } else if (rn2(3) && is_ice(u.ux, u.uy)) { + } else if ((HFumbling & FROMOUTSIDE) || (is_ice(u.ux, u.uy) && !rn2(3))) { + /* is fumbling from ice alone? */ + boolean ice_only = !(EFumbling || (HFumbling & ~FROMOUTSIDE)); + pline("%s %s%s on the ice.", - u.usteed ? upstart(x_monnam(u.usteed, - (has_mgivenname(u.usteed)) ? ARTICLE_NONE - : ARTICLE_THE, - (char *) 0, SUPPRESS_SADDLE, FALSE)) + u.usteed ? upstart(x_monnam(u.usteed, ARTICLE_THE, (char *) 0, + SUPPRESS_SADDLE, FALSE)) : "You", rn2(2) ? "slip" : "slide", on_foot ? "" : "s"); + /* fumbling outside of ice while mounted always causes the hero to + fall from the saddle, so to avoid a counterintuitive effect where + ice makes riding _less_ hazardous, unconditionally dismount if + fumbling is from a non-ice source */ + if (!on_foot && (!ice_only || !rn2(3))) { + You("lose your balance."); + dismount_steed(DISMOUNT_FELL); + } } else { if (on_foot) { switch (rn2(4)) { From 986c8e7ff4208505e68d1752bb1a3019fcac5acf Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Mon, 4 Dec 2023 14:48:27 -0500 Subject: [PATCH 10/78] Check whether steed will slip on ice if mounted If riding over ice, check whether the steed, rather than the hero, is cold-resistant or floating to determine whether it should slip, since it is the monster which would actually be in contact with the ice. --- src/hack.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hack.c b/src/hack.c index 4b9bc0c6c3..92914e172d 100644 --- a/src/hack.c +++ b/src/hack.c @@ -2142,12 +2142,13 @@ static void slippery_ice_fumbling(void) { boolean on_ice = !Levitation && is_ice(u.ux, u.uy); + struct monst *iceskater = u.usteed ? u.usteed : &gy.youmonst; if (on_ice) { if ((uarmf && objdescr_is(uarmf, "snow boots")) - || resists_cold(&gy.youmonst) || Flying - || is_floater(gy.youmonst.data) || is_clinger(gy.youmonst.data) - || is_whirly(gy.youmonst.data)) { + || resists_cold(iceskater) || Flying + || is_floater(iceskater->data) || is_clinger(iceskater->data) + || is_whirly(iceskater->data)) { on_ice = FALSE; } else if (!rn2(Cold_resistance ? 3 : 2)) { HFumbling |= FROMOUTSIDE; From df789bc2003b7efbe35a5fa400ebe2c7eab1de3c Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 4 Dec 2023 12:18:03 -0800 Subject: [PATCH 11/78] fix showing discoveries A few add_menu_heading() calls were added to the '\' and '`' commands which use a text window rather than a menu. For some reason they were using create_nhwindow(NHW_MENU) but only populating it with text so the heading lines sent as menu entries were lost. (Might panic with Qt; I didn't check.) --- src/o_init.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/o_init.c b/src/o_init.c index 51501cfc46..80770d4b48 100644 --- a/src/o_init.c +++ b/src/o_init.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 o_init.c $NHDT-Date: 1672829455 2023/01/04 10:50:55 $ $NHDT-Branch: naming-overflow-fix $:$NHDT-Revision: 1.68 $ */ +/* NetHack 3.7 o_init.c $NHDT-Date: 1701720461 2023/12/04 20:07:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.79 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -398,7 +398,7 @@ restnames(NHFILE* nhfp) mread(nhfp->fd, (genericptr_t) gb.bases, sizeof gb.bases); mread(nhfp->fd, (genericptr_t) gd.disco, sizeof gd.disco); mread(nhfp->fd, (genericptr_t) objects, - sizeof(struct objclass) * NUM_OBJECTS); + NUM_OBJECTS * sizeof (struct objclass)); } for (i = 0; i < NUM_OBJECTS; i++) { if (objects[i].oc_uname) { @@ -691,7 +691,7 @@ dodiscovered(void) /* free after Robert Viduya */ lootsort = (flags.discosort == 's'); sortindx = strchr(disco_order_let, flags.discosort) - disco_order_let; - tmpwin = create_nhwindow(NHW_MENU); + tmpwin = create_nhwindow(NHW_TEXT); Sprintf(buf, "Discoveries, %s", disco_orders_descr[sortindx]); putstr(tmpwin, 0, buf); putstr(tmpwin, 0, ""); @@ -702,7 +702,7 @@ dodiscovered(void) /* free after Robert Viduya */ for (i = dis = 0; i < SIZE(uniq_objs); i++) if (objects[uniq_objs[i]].oc_name_known) { if (!dis++) - add_menu_heading(tmpwin, "Unique items"); + putstr(tmpwin, iflags.menu_headings.attr, "Unique items"); ++uniq_ct; Sprintf(buf, " %s", OBJ_NAME(objects[uniq_objs[i]])); putstr(tmpwin, 0, buf); @@ -742,8 +742,8 @@ dodiscovered(void) /* free after Robert Viduya */ } if (!alphabetized || alphabyclass) { /* header for new class */ - add_menu_heading(tmpwin, - let_to_name(oclass, FALSE, FALSE)); + putstr(tmpwin, iflags.menu_headings.attr, + let_to_name(oclass, FALSE, FALSE)); prev_class = oclass; } } @@ -768,7 +768,7 @@ dodiscovered(void) /* free after Robert Viduya */ classes, we normally don't need a header; but it we showed any unique items or any artifacts then we do need one */ if ((uniq_ct || arti_ct) && alphabetized && !alphabyclass) - add_menu_heading(tmpwin, "Discovered items"); + putstr(tmpwin, iflags.menu_headings.attr, "Discovered items"); qsort(sorted_lines, sorted_ct, sizeof (char *), discovered_cmp); for (j = 0; j < sorted_ct; ++j) { p = sorted_lines[j]; @@ -938,11 +938,12 @@ doclassdisco(void) /* * show discoveries for object class c */ - tmpwin = create_nhwindow(NHW_MENU); + tmpwin = create_nhwindow(NHW_TEXT); ct = 0; switch (c) { case 'u': - add_menu_heading(tmpwin, upstart(strcpy(buf, unique_items))); + putstr(tmpwin, iflags.menu_headings.attr, + upstart(strcpy(buf, unique_items))); for (i = 0; i < SIZE(uniq_objs); i++) if (objects[uniq_objs[i]].oc_name_known) { ++ct; From 4a9d68bf7f3a523c675d59bd14fdf987cf969c12 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 4 Dec 2023 15:41:09 -0500 Subject: [PATCH 12/78] symbol parsing follow-up --- src/symbols.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/symbols.c b/src/symbols.c index 3d201ad7f8..9690c4004c 100644 --- a/src/symbols.c +++ b/src/symbols.c @@ -764,19 +764,19 @@ boolean parsesymbols(register char *opts, int which_set) { int val; - unsigned i; - char *symname, *strval, *ch = opts, + char *symname, *strval, *ch, *first_unquoted_comma = 0, *first_unquoted_colon = 0; const struct symparse *symp; boolean is_glyph = FALSE; /* are there any commas or colons that aren't quoted? */ - for (i = 0; i < strlen(opts); ++i) { + for (ch = opts + 1; *ch; ++ch) { char *prech, *postch; - ch++; /* we never want to match on the first char, so this is ok */ prech = ch - 1; postch = ch + 1; + if (!*postch) + break; if (*ch == ',') { if (*prech == '\'' && *postch == '\'') continue; From 3ca4571011ed45babded77f424c462c204e3232d Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 4 Dec 2023 15:46:24 -0500 Subject: [PATCH 13/78] more SYMBOLS follow-up missing break --- src/options.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/options.c b/src/options.c index 94971838c0..94a5059280 100644 --- a/src/options.c +++ b/src/options.c @@ -6493,6 +6493,7 @@ escapes(const char *cp, /* might be 'tp', updating in place */ break; case ',': cval = ','; + break; default: cval = *cp; } From d52049a5d3eb7c37a8bf174d45c82504c8f76198 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 4 Dec 2023 16:12:04 -0500 Subject: [PATCH 14/78] The src/options.c change was unneeded --- src/options.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/options.c b/src/options.c index 94a5059280..e8d758d958 100644 --- a/src/options.c +++ b/src/options.c @@ -6491,9 +6491,6 @@ escapes(const char *cp, /* might be 'tp', updating in place */ case 'r': cval = '\r'; break; - case ',': - cval = ','; - break; default: cval = *cp; } From 2d8ba944e11e4a3213b4c207ba730fd7dfdf84dd Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 4 Dec 2023 13:20:25 -0800 Subject: [PATCH 15/78] add some flexibility to TTY_PERM_INVENT Allow perm_invent to be enabled with 1 less line when statuslines==2 by not reserving a line for statuslines==3. If the player changes that from 2 to 3, the perm_invent window is torn down and repositioned one line lower if that will fit. If it won't fit, it won't reenable. Temporarily(?) allow perminv_mode==InUse to be enabled with room for only 8 lines instead of requiring 15. It will use more than 8 if are more rows. 8 happens to be the amount (via 1+21+3+(1+8+1)) that will fit within 35 lines which is the biggest I can make fit on may laptop without switching to a smaller font. Switching is a nuisance, worse than that for the font tiny enough to fit the full perm_invent. ToDo: if in-use won't fit in the number of lines allotted, switch to two columns before resorting to ignoring the excess. Maybe: allow fewer lines for full perm_invent too and use the '|' command to scroll them. Might be too clumsy to be worthwhile. --- win/tty/wintty.c | 58 +++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/win/tty/wintty.c b/win/tty/wintty.c index ab2b554a4d..e054d90f5a 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 wintty.c $NHDT-Date: 1700385095 2023/11/19 09:11:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.365 $ */ +/* NetHack 3.7 wintty.c $NHDT-Date: 1701723543 2023/12/04 20:59:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.369 $ */ /* Copyright (c) David Cohrs, 1991 */ /* NetHack may be freely redistributed. See license for details. */ @@ -233,9 +233,9 @@ static const char *compress_str(const char *); #ifndef STATUS_HILITES static void tty_putsym(winid, int, int, char); #endif -#ifdef STATUS_HILITES #define MAX_STATUS_ROWS 3 #define StatusRows() ((iflags.wc2_statuslines <= 2) ? 2 : MAX_STATUS_ROWS) +#ifdef STATUS_HILITES static boolean check_fields(boolean forcefields, int sz[MAX_STATUS_ROWS]); static void render_status(void); static void tty_putstatusfield(const char *, int, int); @@ -516,7 +516,7 @@ tty_init_nhwindows(int *argcp UNUSED, char **argv UNUSED) /* options aren't processed yet so wc2_statuslines might be 0; make sure that it has a reasonable value during tty setup */ - iflags.wc2_statuslines = (iflags.wc2_statuslines < 3) ? 2 : 3; + iflags.wc2_statuslines = StatusRows(); /* 2 or 3; 0 => 2 */ /* * Remember tty modes, to be restored on exit. * @@ -596,7 +596,10 @@ tty_init_nhwindows(int *argcp UNUSED, char **argv UNUSED) void tty_preference_update(const char *pref) { - if (!strcmp(pref, "statuslines") && iflags.window_inited) { + boolean newstatuslines = (!strcmp(pref, "statuslines") + && iflags.window_inited); + + if (newstatuslines) { new_status_window(); newclipping(u.ux, u.uy); } @@ -617,6 +620,13 @@ tty_preference_update(const char *pref) if (WIN_INVEN != WIN_ERR) tty_invent_box_glyph_init(wins[WIN_INVEN]); } + /* if newstatuslines has been toggled between 2 and 3 or vice versa + then we want to reposition the perm_invent window to match */ + if (newstatuslines && WIN_INVEN != WIN_ERR) { + perm_invent_toggled(TRUE); /*TEMP?*/ + tty_destroy_nhwindow(WIN_INVEN), WIN_INVEN = WIN_ERR; + perm_invent_toggled(FALSE); /*TEMP?*/ + } #endif return; } @@ -2426,7 +2436,7 @@ tty_display_file( #endif ) { /* attempt to scroll text below map window if there's room */ - wins[datawin]->offy = wins[WIN_STATUS]->offy + 3; + wins[datawin]->offy = wins[WIN_STATUS]->offy + StatusRows(); if ((int) wins[datawin]->offy + 12 > (int) ttyDisplay->rows) wins[datawin]->offy = 0; } @@ -2816,7 +2826,7 @@ tty_ctrl_nhwindow(winid window UNUSED, int request, win_request_info *wri) wri->tocore = zero_tocore; tty_ok = assesstty(ttyinvmode, &offx, &offy, &rows, &cols, &maxcol, &minrow, &maxrow); - wri->tocore.needrows = (int) (minrow + 1 + ROWNO + 3); + wri->tocore.needrows = (int) (minrow + 1 + ROWNO + StatusRows()); wri->tocore.needcols = (int) tty_perminv_mincol; wri->tocore.haverows = (int) ttyDisplay->rows; wri->tocore.havecols = (int) ttyDisplay->cols; @@ -2890,7 +2900,7 @@ ttyinv_create_window(int newid, struct WinDesc *newwin) pline("%s.", "tty perm_invent could not be enabled"); pline("tty perm_invent needs a terminal that is at least %dx%d, " "yours is %dx%d.", - (int) (minrow + 1 + ROWNO + 3), tty_perminv_mincol, + (int) (minrow + 1 + ROWNO + StatusRows()), tty_perminv_mincol, ttyDisplay->rows, ttyDisplay->cols); tty_wait_synch(); set_option_mod_status("perm_invent", set_gameview); @@ -2901,7 +2911,7 @@ ttyinv_create_window(int newid, struct WinDesc *newwin) /* * Terminal/window/screen is big enough. */ - newwin->maxrow = minrow; + /*newwin->maxrow = minrow;*/ newwin->maxcol = newwin->cols; /* establish the borders */ bordercol[border_left] = 0; @@ -2995,9 +3005,12 @@ ttyinv_add_menu( char invbuf[BUFSZ]; const char *text; boolean show_gold = (ttyinvmode & InvShowGold) != 0, + inuse_only = (ttyinvmode & InvInUse) != 0, ignore = FALSE; int row, side, slot, - rows_per_side = (!show_gold ? 26 : 27); + rows_per_side = (inuse_only ? (cw->maxrow - 2) + : !show_gold ? 26 + : 27); if (!gp.program_state.in_moveloop) return; @@ -3210,27 +3223,32 @@ assesstty( short *offx, short *offy, long *rows, long *cols, long *maxcol, long *minrow, long *maxrow) { - boolean show_gold = (invmode & InvShowGold) != 0, - inuse_only = (invmode & InvInUse) != 0; + boolean inuse_only = (invmode & InvInUse) != 0, + show_gold = (invmode & InvShowGold) != 0 && !inuse_only; *offx = 0; /* topline + map rows + status lines */ - *offy = 1 + ROWNO + 3; /* 3: + 2 + (iflags.wc2_statuslines > 2) */ - *rows = (ttyDisplay->rows - (*offy)); + *offy = 1 + ROWNO + StatusRows(); /* 1 + 21 + (2 or 3) */ + *rows = (ttyDisplay->rows - *offy); *cols = ttyDisplay->cols; *minrow = tty_perminv_minrow; if (show_gold) *minrow += 1; +#define SMALL_INUSE_WINDOW +#ifdef SMALL_INUSE_WINDOW +#undef SMALL_INUSE_WINDOW + /* simplify testing by not requiring a small font to have enough room */ + if (inuse_only) + *minrow = 1 + 8 + 1; +#else /* "normal" max for items in use would be 3 weapon + 7 armor + 4 - accessories == 14, but being punished and picking up the ball will - add 1, and some quest artifacts have an an #invoke property that's - tracked via obj->owornmask so could add more; also, lit lamps/candles - and attached leashes are included; if hero ends up with more than - 15 in-use items, some will be left out */ + accessories == 14, but lit lamps/candles and attached leashes are + also included; if hero ends up with more than 15 in-use items, + some will be left out */ if (inuse_only) *minrow = 1 + 15 + 1; /* top border + 15 lines + bottom border */ - *maxrow = *minrow; /* FIXME: inuse_only should be able to use more - * than the minimum if extra lines are available */ +#endif + *maxrow = *rows; *maxcol = *cols; return !(*rows < *minrow || *cols < tty_perminv_mincol); } From 7ca9951996c943f03a13a3178089c0918015ac4d Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Tue, 5 Dec 2023 04:34:24 +0000 Subject: [PATCH 16/78] Reduce code duplication in extrinsics-protect-items code The same checks were being repeated for every damage type; this sends them through two centralised functions (one for checking whether an extrinsic blocks a specific instance of item destruction and one for the enlightenment message), so that new mechanisms of item destruction prevention will need to change only one point in the code. --- include/extern.h | 3 ++- src/dothrow.c | 5 +++-- src/insight.c | 33 ++++++++++++++++++--------------- src/trap.c | 6 +++--- src/zap.c | 37 +++++++++++++++++++++++++++++-------- 5 files changed, 55 insertions(+), 29 deletions(-) diff --git a/include/extern.h b/include/extern.h index a8f57c305a..7f0e72aaa4 100644 --- a/include/extern.h +++ b/include/extern.h @@ -3582,7 +3582,8 @@ extern void melt_ice_away(union any *, long); extern int zap_over_floor(coordxy, coordxy, int, boolean *, boolean, short); extern void fracture_rock(struct obj *); extern boolean break_statue(struct obj *); -extern boolean u_adtyp_resistance_obj(int); +extern int u_adtyp_resistance_obj(int); +extern boolean inventory_resistance_check(int); extern char *item_what(int); extern void destroy_item(int, int); extern int destroy_mitem(struct monst *, int, int); diff --git a/src/dothrow.c b/src/dothrow.c index 1ca322c2eb..8ecab42e97 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -2524,8 +2524,9 @@ breakobj( } /* - * Check to see if obj is going to break, but don't actually break it. - * Return 0 if the object isn't going to break, 1 if it is. + * Check to see if obj (which has just hit hard something at speed, e.g. + * thrown or dropped from height) is going to break, but don't actually + * break it. Return 0 if the object isn't going to break, 1 if it is. */ boolean breaktest(struct obj *obj) diff --git a/src/insight.c b/src/insight.c index ddeb56c673..e5b4964a4c 100644 --- a/src/insight.c +++ b/src/insight.c @@ -1429,6 +1429,19 @@ weapon_insight(int final) } /* skill applies */ } +static void +item_resistance_message(int adtyp, const char *prot_message, int final) +{ + int protection = u_adtyp_resistance_obj(adtyp); + if (protection) { + boolean somewhat = protection < 99; + enl_msg("Your items ", + somewhat ? "are somewhat" : "are", + somewhat ? "were somewhat" : "were", + prot_message, item_what(adtyp)); + } +} + /* attributes: intrinsics and the like, other non-obvious capabilities */ static void attributes_enlightenment(int unused_mode UNUSED, int final) @@ -1469,26 +1482,18 @@ attributes_enlightenment(int unused_mode UNUSED, int final) you_are("magic-protected", from_what(ANTIMAGIC)); if (Fire_resistance) you_are("fire resistant", from_what(FIRE_RES)); - if (u_adtyp_resistance_obj(AD_FIRE)) - enl_msg("Your items ", "are", "were", " protected from fire", - item_what(AD_FIRE)); + item_resistance_message(AD_FIRE, " protected from fire", final); if (Cold_resistance) you_are("cold resistant", from_what(COLD_RES)); - if (u_adtyp_resistance_obj(AD_COLD)) - enl_msg("Your items ", "are", "were", " protected from cold", - item_what(AD_COLD)); + item_resistance_message(AD_COLD, " protected from cold", final); if (Sleep_resistance) you_are("sleep resistant", from_what(SLEEP_RES)); if (Disint_resistance) you_are("disintegration resistant", from_what(DISINT_RES)); - if (u_adtyp_resistance_obj(AD_DISN)) - enl_msg("Your items ", "are", "were", - " protected from disintegration", item_what(AD_DISN)); + item_resistance_message(AD_DISN, " protected from disintegration", final); if (Shock_resistance) you_are("shock resistant", from_what(SHOCK_RES)); - if (u_adtyp_resistance_obj(AD_ELEC)) - enl_msg("Your items ", "are", "were", - " protected from electric shocks", item_what(AD_ELEC)); + item_resistance_message(AD_ELEC, " protected from electric shocks", final); if (Poison_resistance) you_are("poison resistant", from_what(POISON_RES)); if (Acid_resistance) { @@ -1497,9 +1502,7 @@ attributes_enlightenment(int unused_mode UNUSED, int final) "acid resistant"); you_are(buf, from_what(ACID_RES)); } - if (u_adtyp_resistance_obj(AD_ACID)) - enl_msg("Your items ", "are", "were", " protected from acid", - item_what(AD_ACID)); + item_resistance_message(AD_ACID, " protected from acid", final); if (Drain_resistance) you_are("level-drain resistant", from_what(DRAIN_RES)); if (Sick_resistance) diff --git a/src/trap.c b/src/trap.c index 8dee860a32..4f41c2d0e1 100644 --- a/src/trap.c +++ b/src/trap.c @@ -198,7 +198,7 @@ erode_obj( switch (type) { case ERODE_BURN: - if (uvictim && u_adtyp_resistance_obj(AD_FIRE) && rn2(100)) + if (uvictim && inventory_resistance_check(AD_FIRE)) return ER_NOTHING; vulnerable = is_flammable(otmp); check_grease = FALSE; @@ -215,7 +215,7 @@ erode_obj( cost_type = COST_ROT; break; case ERODE_CORRODE: - if (uvictim && u_adtyp_resistance_obj(AD_ACID) && rn2(100)) + if (uvictim && inventory_resistance_check(AD_ACID)) return ER_NOTHING; vulnerable = is_corrodeable(otmp); is_primary = FALSE; @@ -4362,7 +4362,7 @@ acid_damage(struct obj* obj) victim = carried(obj) ? &gy.youmonst : mcarried(obj) ? obj->ocarry : NULL; vismon = victim && (victim != &gy.youmonst) && canseemon(victim); - if (victim == &gy.youmonst && u_adtyp_resistance_obj(AD_ACID) && rn2(100)) + if (victim == &gy.youmonst && inventory_resistance_check(AD_ACID)) return; if (obj->greased) { diff --git a/src/zap.c b/src/zap.c index e10c43e5af..dd3f6d259e 100644 --- a/src/zap.c +++ b/src/zap.c @@ -4317,7 +4317,7 @@ zhitu( break; case ZT_DEATH: if (abstyp == ZT_BREATH(ZT_DEATH)) { - boolean disn_prot = u_adtyp_resistance_obj(AD_DISN) && rn2(100); + boolean disn_prot = inventory_resistance_check(AD_DISN); if (Disint_resistance) { You("are not disintegrated."); @@ -5391,20 +5391,41 @@ adtyp_to_prop(int dmgtyp) return 0; /* prop_types start at 1 */ } -/* is hero wearing or wielding an object with resistance - to attack damage type */ -boolean +/* Is hero wearing or wielding an object with resistance to attack + damage type? Returns the percentage protectoin that the object + gives. */ +int u_adtyp_resistance_obj(int dmgtyp) { int prop = adtyp_to_prop(dmgtyp); if (!prop) - return FALSE; + return 0; if ((u.uprops[prop].extrinsic & (W_ARMOR | W_ACCESSORY | W_WEP)) != 0) - return TRUE; + return 99; /* 99% protected */ - return FALSE; + return 0; +} + +/* Rolls to see whether an object in inventory resists damage from the + given damage type, due to an equipped item protecting it. Use + u_adtyp_resistance_obj to discover whether objects are protected in + general (e.g. for enlightenment) and this function to actually do + the roll to see whether a specific object is protected. + + This function doesn't check for other reasons why an object might + be protected; you will usually need to do an obj_resists() call + too. */ +boolean +inventory_resistance_check(int dmgtyp) +{ + int prob = u_adtyp_resistance_obj(dmgtyp); + + if (!prob) + return FALSE; + + return rn2(100) < prob; } /* for enlightenment; currently only useful in wizard mode; cf from_what() */ @@ -5491,7 +5512,7 @@ destroy_one_item(struct obj *obj, int osym, int dmgtyp) quan = 0L; /* external worn item protects inventory? */ - if (u_adtyp_resistance_obj(dmgtyp) && rn2(100)) + if (inventory_resistance_check(dmgtyp)) return; switch (dmgtyp) { From b98a70e3ecaa4cbb5eb18c99de61cf84a2b52213 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Tue, 5 Dec 2023 04:52:02 +0000 Subject: [PATCH 17/78] Dwarvish cloaks somewhat protect inventory from cold and fire The change to Sokoban difficulty calculation introduced a balance issue: previously the Sokoban prize was obtainable before item- destruction attacks became common and would protect from them, whereas now they commonly appear in Sokoban itself, before the prize is accessible. This makes scrolls and potions much less usable as escape items, and potions of healing less usable for HP recovery, because they either get stashed or destroyed (and in either case aren't usable by the character in time-critical situations). This commit attempts to alleviate the problem by adding a way to protect items from cold and fire in the early game. It's a little unreliable, and requires equipping an item that has bad stats and generally isn't otherwise used, but which is generally easy to find early on. Not included in this commit, but probably necessary for a "finished" version of the feature: some way of letting players know the new mechanic. It shows up in enlightenment, but there should probably be at least rumors (and maybe even a major Oracle consultation) hinting at the mechanic. We might also want to change the unIDed description of the dwarvish cloak as a hint, although that would require, e.g., new database entries. --- doc/fixes3-7-0.txt | 1 + src/zap.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index c4d2a2403d..91f0504328 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -616,6 +616,7 @@ yet another fix for display problems during restore: if game is saved while being obfuscated by hallucination, but when displaying the hero there instead it would access steed pointer before that has been set up resistances gained from worn or wielded items also protect hero's inventory +dwarvish cloaks somewhat protect hero's inventory from cold and fire non-metallic gloves protect worn rings from shock message "Oops! food rations out of your grasp!" occurred due to perm_invent in mid-operation overwriting all of xname's/doname's obufs; fixed by diff --git a/src/zap.c b/src/zap.c index dd3f6d259e..22c11e64db 100644 --- a/src/zap.c +++ b/src/zap.c @@ -5392,7 +5392,7 @@ adtyp_to_prop(int dmgtyp) } /* Is hero wearing or wielding an object with resistance to attack - damage type? Returns the percentage protectoin that the object + damage type? Returns the percentage protection that the object gives. */ int u_adtyp_resistance_obj(int dmgtyp) @@ -5402,8 +5402,16 @@ u_adtyp_resistance_obj(int dmgtyp) if (!prop) return 0; + /* Items that give an extrinsic resistance give 99% protection to + your items */ if ((u.uprops[prop].extrinsic & (W_ARMOR | W_ACCESSORY | W_WEP)) != 0) - return 99; /* 99% protected */ + return 99; + + /* Dwarvish cloaks give a 90% protection to items against heat and + cold */ + if (uarmc && uarmc->otyp == DWARVISH_CLOAK && + (dmgtyp == AD_COLD || dmgtyp == AD_FIRE)) + return 90; return 0; } From 5dc94f3d83f0a9009e3355403e5b31a6cae8d421 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Tue, 5 Dec 2023 10:06:27 +0200 Subject: [PATCH 18/78] Macro for picking random entry from array --- include/hack.h | 3 +++ src/artifact.c | 4 ++-- src/do_name.c | 4 ++-- src/dokick.c | 2 +- src/engrave.c | 2 +- src/invent.c | 2 +- src/makemon.c | 4 ++-- src/minion.c | 4 ++-- src/mklev.c | 4 ++-- src/mkmaze.c | 2 +- src/mkobj.c | 2 +- src/mkroom.c | 2 +- src/mondata.c | 2 +- src/mthrowu.c | 2 +- src/music.c | 2 +- src/potion.c | 4 ++-- src/pray.c | 2 +- src/shk.c | 8 ++++---- src/sounds.c | 8 ++++---- src/sp_lev.c | 4 ++-- src/steal.c | 2 +- src/trap.c | 2 +- src/u_init.c | 2 +- src/wizard.c | 14 +++++++------- 24 files changed, 45 insertions(+), 42 deletions(-) diff --git a/include/hack.h b/include/hack.h index 69645f086d..d973ac6d62 100644 --- a/include/hack.h +++ b/include/hack.h @@ -1404,6 +1404,9 @@ typedef uint32_t mmflags_nht; /* makemon MM_ flags */ /* monster shooting a wand; note: not -9 to -0 because -0 is ambiguous */ #define BZ_M_WAND(bztyp) (-30 - (bztyp)) /* -39..-30 */ +/* pick a random entry from array */ +#define ROLL_FROM(array) array[rn2(SIZE(array))] + #define FEATURE_NOTICE_VER(major, minor, patch) \ (((unsigned long) major << 24) | ((unsigned long) minor << 16) \ | ((unsigned long) patch << 8) | ((unsigned long) 0)) diff --git a/src/artifact.c b/src/artifact.c index f15efdc5c0..a79d828bd0 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -1505,7 +1505,7 @@ artifact_hit( return TRUE; } *dmgptr = 2 * mdef->mhp + FATAL_DAMAGE_MODIFIER; - pline(behead_msg[rn2(SIZE(behead_msg))], wepdesc, + pline(ROLL_FROM(behead_msg), wepdesc, mon_nam(mdef)); if (Hallucination && !flags.female) pline("Good job Henry, but that wasn't Anne."); @@ -1525,7 +1525,7 @@ artifact_hit( return TRUE; } *dmgptr = 2 * (Upolyd ? u.mh : u.uhp) + FATAL_DAMAGE_MODIFIER; - pline(behead_msg[rn2(SIZE(behead_msg))], wepdesc, "you"); + pline(ROLL_FROM(behead_msg), wepdesc, "you"); otmp->dknown = TRUE; /* Should amulets fall off? */ return TRUE; diff --git a/src/do_name.c b/src/do_name.c index 3d0ddbec2c..e6c4ec459f 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -1899,7 +1899,7 @@ static const char *const ghostnames[] = { const char * rndghostname(void) { - return rn2(7) ? ghostnames[rn2(SIZE(ghostnames))] + return rn2(7) ? ROLL_FROM(ghostnames) : (const char *) gp.plname; } @@ -2635,7 +2635,7 @@ rndorcname(char *s) for (i = 0; i < iend; ++i) { vstart = 1 - vstart; /* 0 -> 1, 1 -> 0 */ Sprintf(eos(s), "%s%s", (i > 0 && !rn2(30)) ? "-" : "", - vstart ? v[rn2(SIZE(v))] : snd[rn2(SIZE(snd))]); + vstart ? ROLL_FROM(v) : ROLL_FROM(snd)); } } return s; diff --git a/src/dokick.c b/src/dokick.c index 45004a8ef5..d6927d1166 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -689,7 +689,7 @@ really_kick_object(coordxy x, coordxy y) if (!Deaf) pline1("Thwwpingg!"); - You("%s!", flyingcoinmsg[rn2(SIZE(flyingcoinmsg))]); + You("%s!", ROLL_FROM(flyingcoinmsg)); (void) scatter(x, y, rnd(3), VIS_EFFECTS | MAY_HIT, gk.kickedobj); newsym(x, y); diff --git a/src/engrave.c b/src/engrave.c index 9b57f14117..7772d82bb1 100644 --- a/src/engrave.c +++ b/src/engrave.c @@ -1549,7 +1549,7 @@ static const char blind_writing[][21] = { static const char * blengr(void) { - return blind_writing[rn2(SIZE(blind_writing))]; + return ROLL_FROM(blind_writing); } /*engrave.c*/ diff --git a/src/invent.c b/src/invent.c index a6dc1a460a..c4b1b4962b 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1501,7 +1501,7 @@ currency(long amount) { const char *res; - res = Hallucination ? currencies[rn2(SIZE(currencies))] : "zorkmid"; + res = Hallucination ? ROLL_FROM(currencies) : "zorkmid"; if (amount != 1L) res = makeplural(res); return res; diff --git a/src/makemon.c b/src/makemon.c index 95f5411b5c..1253a13141 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -2317,7 +2317,7 @@ set_mimic_sym(register struct monst *mtmp) goto assign_sym; } } else { - s_sym = syms[rn2(SIZE(syms))]; + s_sym = ROLL_FROM(syms); assign_sym: if (s_sym == MAXOCLASSES) { static const int furnsyms[] = { @@ -2326,7 +2326,7 @@ set_mimic_sym(register struct monst *mtmp) }; ap_type = M_AP_FURNITURE; - appear = furnsyms[rn2(SIZE(furnsyms))]; + appear = ROLL_FROM(furnsyms); } else { ap_type = M_AP_OBJECT; if (s_sym == S_MIMIC_DEF) { diff --git a/src/minion.c b/src/minion.c index f7b99bb91b..85494a1102 100644 --- a/src/minion.c +++ b/src/minion.c @@ -109,7 +109,7 @@ msummon(struct monst *mon) if (!rn2(6)) { switch (atyp) { /* see summon_minion */ case A_NEUTRAL: - dtype = elementals[rn2(SIZE(elementals))]; + dtype = ROLL_FROM(elementals); break; case A_CHAOTIC: case A_NONE: @@ -204,7 +204,7 @@ summon_minion(aligntyp alignment, boolean talk) mnum = lminion(); break; case A_NEUTRAL: - mnum = elementals[rn2(SIZE(elementals))]; + mnum = ROLL_FROM(elementals); break; case A_CHAOTIC: case A_NONE: diff --git a/src/mklev.c b/src/mklev.c index a5fea6c8a4..4c2746291f 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -956,7 +956,7 @@ fill_ordinary_room(struct mkroom *croom, boolean bonus_items) WAN_DIGGING, SPE_HEALING, }; - otyp = supply_items[rn2(SIZE(supply_items))]; + otyp = ROLL_FROM(supply_items); } otmp = mksobj(otyp, TRUE, FALSE); if (otyp == POT_HEALING && rn2(2)) @@ -991,7 +991,7 @@ fill_ordinary_room(struct mkroom *croom, boolean bonus_items) SPBOOK_no_NOVEL, SPBOOK_no_NOVEL }; - int oclass = extra_classes[rn2(SIZE(extra_classes))]; + int oclass = ROLL_FROM(extra_classes); otmp = mkobj(oclass, FALSE); if (oclass == SPBOOK_no_NOVEL) { /* bias towards lower level by generating again diff --git a/src/mkmaze.c b/src/mkmaze.c index 1a3aec851a..ef7d5d8d92 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -756,7 +756,7 @@ migr_booty_item(int otyp, const char* gang) Strcpy(ONAME(otmp), gang); if (objects[otyp].oc_class == FOOD_CLASS) { if (otyp == SLIME_MOLD) - otmp->spe = fruitadd((char *) orcfruit[rn2(SIZE(orcfruit))], + otmp->spe = fruitadd((char *) ROLL_FROM(orcfruit), (struct fruit *) 0); otmp->quan += (long) rn2(3); otmp->owt = weight(otmp); diff --git a/src/mkobj.c b/src/mkobj.c index cd1e957651..f3affc40a3 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -1910,7 +1910,7 @@ static const int treefruits[] = { struct obj * rnd_treefruit_at(coordxy x, coordxy y) { - return mksobj_at(treefruits[rn2(SIZE(treefruits))], x, y, TRUE, FALSE); + return mksobj_at(ROLL_FROM(treefruits), x, y, TRUE, FALSE); } /* create a stack of N gold pieces; never returns Null */ diff --git a/src/mkroom.c b/src/mkroom.c index 53828b12ec..3ca05a7d04 100644 --- a/src/mkroom.c +++ b/src/mkroom.c @@ -819,7 +819,7 @@ squadmon(void) goto gotone; } } - mndx = squadprob[rn2(SIZE(squadprob))].pm; + mndx = ROLL_FROM(squadprob).pm; gotone: if (!(gm.mvitals[mndx].mvflags & G_GONE)) return &mons[mndx]; diff --git a/src/mondata.c b/src/mondata.c index 04e4b1c8d4..da9fdfcc24 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -1546,7 +1546,7 @@ get_atkdam_type(int adtyp) static const int rnd_breath_typ[] = { AD_MAGM, AD_FIRE, AD_COLD, AD_SLEE, AD_DISN, AD_ELEC, AD_DRST, AD_ACID }; - return rnd_breath_typ[rn2(SIZE(rnd_breath_typ))]; + return ROLL_FROM(rnd_breath_typ); } return adtyp; } diff --git a/src/mthrowu.c b/src/mthrowu.c index bafb3c8c62..5829f05e0f 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -48,7 +48,7 @@ const char *const hallublasts[] = { const char * rnd_hallublast(void) { - return hallublasts[rn2(SIZE(hallublasts))]; + return ROLL_FROM(hallublasts); } boolean diff --git a/src/music.c b/src/music.c index 045e6e839c..2703f2f0af 100644 --- a/src/music.c +++ b/src/music.c @@ -695,7 +695,7 @@ do_improvisation(struct obj* instr) /* TODO maybe: sound effects for these riffs */ You("%s %s.", rn2(2) ? "butcher" : rn2(2) ? "manage" : "pull off", - an(beats[rn2(SIZE(beats))])); + an(ROLL_FROM(beats))); Hero_playnotes(obj_to_instr(&itmp), improvisation, 50); } awaken_monsters(u.ulevel * (mundane ? 5 : 40)); diff --git a/src/potion.c b/src/potion.c index 91e59ad020..93eed9dfe0 100644 --- a/src/potion.c +++ b/src/potion.c @@ -1468,9 +1468,9 @@ const char * bottlename(void) { if (Hallucination) - return hbottlenames[rn2(SIZE(hbottlenames))]; + return ROLL_FROM(hbottlenames); else - return bottlenames[rn2(SIZE(bottlenames))]; + return ROLL_FROM(bottlenames); } /* handle item dipped into water potion or steed saddle splashed by same */ diff --git a/src/pray.c b/src/pray.c index 4884f686f8..387e5a4342 100644 --- a/src/pray.c +++ b/src/pray.c @@ -1398,7 +1398,7 @@ godvoice(aligntyp g_align, const char *words) words = ""; pline_The("voice of %s %s: %s%s%s", align_gname(g_align), - godvoices[rn2(SIZE(godvoices))], quot, words, quot); + ROLL_FROM(godvoices), quot, words, quot); } static void diff --git a/src/shk.c b/src/shk.c index 07c7780506..7968bcd021 100644 --- a/src/shk.c +++ b/src/shk.c @@ -697,7 +697,7 @@ u_entered_shop(char *enterstring) s_suffix(shkname(shkp)), shtypes[rt - SHOPBASE].name); } else { pline("%s seems %s over your return to %s %s!", - Shknam(shkp), angrytexts[rn2(SIZE(angrytexts))], + Shknam(shkp), ROLL_FROM(angrytexts), noit_mhis(shkp), shtypes[rt - SHOPBASE].name); } } else if (eshkp->surcharge) { @@ -4613,7 +4613,7 @@ pay_for_damage(const char *dmgstr, boolean cant_mollify) dugwall ? "shop" : "door"); } else { pline("%s is %s that you decided to %s %s %s!", - Shknam(shkp), angrytexts[rn2(SIZE(angrytexts))], + Shknam(shkp), ROLL_FROM(angrytexts), dmgstr, noit_mhis(shkp), dugwall ? "shop" : "door"); } } else { @@ -4624,7 +4624,7 @@ pay_for_damage(const char *dmgstr, boolean cant_mollify) dugwall ? "shop" : "door"); } else { pline("%s is %s that someone decided to %s %s %s!", - Shknam(shkp), angrytexts[rn2(SIZE(angrytexts))], + Shknam(shkp), ROLL_FROM(angrytexts), dmgstr, noit_mhis(shkp), dugwall ? "shop" : "door"); } } @@ -4926,7 +4926,7 @@ shk_chat(struct monst* shkp) (!Deaf && !muteshk(shkp)) ? "says" : "indicates"); } else if (is_izchak(shkp, FALSE)) { if (!Deaf && !muteshk(shkp)) - pline(Izchak_speaks[rn2(SIZE(Izchak_speaks))], shkname(shkp)); + pline(ROLL_FROM(Izchak_speaks), shkname(shkp)); } else { if (!Deaf && !muteshk(shkp)) pline("%s talks about the problem of shoplifters.", Shknam(shkp)); diff --git a/src/sounds.c b/src/sounds.c index 34245860fa..cfeea58a80 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -406,7 +406,7 @@ growl(register struct monst* mtmp) /* presumably nearness and soundok checks have already been made */ if (Hallucination) - growl_verb = h_sounds[rn2(SIZE(h_sounds))]; + growl_verb = ROLL_FROM(h_sounds); else growl_verb = growl_sound(mtmp); if (growl_verb) { @@ -432,7 +432,7 @@ yelp(register struct monst* mtmp) /* presumably nearness and soundok checks have already been made */ if (Hallucination) - yelp_verb = h_sounds[rn2(SIZE(h_sounds))]; + yelp_verb = ROLL_FROM(h_sounds); else switch (mtmp->data->msound) { case MS_MEW: @@ -483,7 +483,7 @@ whimper(register struct monst* mtmp) /* presumably nearness and soundok checks have already been made */ if (Hallucination) - whimper_verb = h_sounds[rn2(SIZE(h_sounds))]; + whimper_verb = ROLL_FROM(h_sounds); else switch (mtmp->data->msound) { case MS_MEW: @@ -602,7 +602,7 @@ maybe_gasp(struct monst* mon) break; } if (dogasp) { - return Exclam[rn2(SIZE(Exclam))]; /* [mon->m_id % SIZE(Exclam)]; */ + return ROLL_FROM(Exclam); /* [mon->m_id % SIZE(Exclam)]; */ } return (const char *) 0; } diff --git a/src/sp_lev.c b/src/sp_lev.c index 066cd7f1d3..bbeb5930a5 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -1125,7 +1125,7 @@ rnddoor(void) { static int state[] = { D_NODOOR, D_BROKEN, D_ISOPEN, D_CLOSED, D_LOCKED }; - return state[rn2(SIZE(state))]; + return ROLL_FROM(state); } /* @@ -5789,7 +5789,7 @@ generate_way_out_method( /* generate one of the escape items */ if (selection_rndcoord(ov2, &x, &y, FALSE)) { - mksobj_at(escapeitems[rn2(SIZE(escapeitems))], x, y, TRUE, FALSE); + mksobj_at(ROLL_FROM(escapeitems), x, y, TRUE, FALSE); goto gotitdone; } diff --git a/src/steal.c b/src/steal.c index 1f4b24a938..eff28499db 100644 --- a/src/steal.c +++ b/src/steal.c @@ -419,7 +419,7 @@ steal(struct monst* mtmp, char* objnambuf) "take" }; cant_take: pline("%s tries to %s %s%s but gives up.", Monnam(mtmp), - how[rn2(SIZE(how))], + ROLL_FROM(how), (otmp->owornmask & W_ARMOR) ? "your " : "", (otmp->owornmask & W_ARMOR) ? equipname(otmp) : yname(otmp)); diff --git a/src/trap.c b/src/trap.c index 4f41c2d0e1..3bd83449c0 100644 --- a/src/trap.c +++ b/src/trap.c @@ -6097,7 +6097,7 @@ chest_trap( case 1: case 0: pline("A cloud of %s gas billows from %s.", - Blind ? blindgas[rn2(SIZE(blindgas))] : rndcolor(), + Blind ? ROLL_FROM(blindgas) : rndcolor(), the(xname(obj))); if (!Stunned) { if (Hallucination) diff --git a/src/u_init.c b/src/u_init.c index 001be68ce7..d6afd9a349 100644 --- a/src/u_init.c +++ b/src/u_init.c @@ -849,7 +849,7 @@ u_init(void) if (Role_if(PM_CLERIC) || Role_if(PM_WIZARD)) { static int trotyp[] = { WOODEN_FLUTE, TOOLED_HORN, WOODEN_HARP, BELL, BUGLE, LEATHER_DRUM }; - Instrument[0].trotyp = trotyp[rn2(SIZE(trotyp))]; + Instrument[0].trotyp = ROLL_FROM(trotyp); ini_inv(Instrument); } diff --git a/src/wizard.c b/src/wizard.c index c17966916a..16473254e7 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -502,7 +502,7 @@ clonewiz(void) } if (!Protection_from_shape_changers) { mtmp2->m_ap_type = M_AP_MONSTER; - mtmp2->mappearance = wizapp[rn2(SIZE(wizapp))]; + mtmp2->mappearance = ROLL_FROM(wizapp); } newsym(mtmp2->mx, mtmp2->my); } @@ -513,7 +513,7 @@ int pick_nasty( int difcap) /* if non-zero, try to make difficulty be lower than this */ { - int alt, res = nasties[rn2(SIZE(nasties))]; + int alt, res = ROLL_FROM(nasties); /* To do? Possibly should filter for appropriate forms when * in the elemental planes or surrounded by water or lava. @@ -523,7 +523,7 @@ pick_nasty( */ if (Is_rogue_level(&u.uz) && !('A' <= mons[res].mlet && mons[res].mlet <= 'Z')) - res = nasties[rn2(SIZE(nasties))]; + res = ROLL_FROM(nasties); /* if genocided or too difficult or out of place, try a substitute when a suitable one exists @@ -822,20 +822,20 @@ cuss(struct monst *mtmp) } else if (u.uhave.amulet && !rn2(SIZE(random_insult))) { SetVoice(mtmp, 0, 80, 0); verbalize("Relinquish the amulet, %s!", - random_insult[rn2(SIZE(random_insult))]); + ROLL_FROM(random_insult)); } else if (u.uhp < 5 && !rn2(2)) { /* Panic */ SetVoice(mtmp, 0, 80, 0); verbalize(rn2(2) ? "Even now thy life force ebbs, %s!" : "Savor thy breath, %s, it be thy last!", - random_insult[rn2(SIZE(random_insult))]); + ROLL_FROM(random_insult)); } else if (mtmp->mhp < 5 && !rn2(2)) { /* Parthian shot */ SetVoice(mtmp, 0, 80, 0); verbalize(rn2(2) ? "I shall return." : "I'll be back."); } else { SetVoice(mtmp, 0, 80, 0); verbalize("%s %s!", - random_malediction[rn2(SIZE(random_malediction))], - random_insult[rn2(SIZE(random_insult))]); + ROLL_FROM(random_malediction), + ROLL_FROM(random_insult)); } } else if (is_lminion(mtmp) && !(mtmp->isminion && EMIN(mtmp)->renegade)) { From 027b325a3dee3935e7526e5a8fcb48a65ea93c4f Mon Sep 17 00:00:00 2001 From: SHIRAKATA Kentaro Date: Thu, 10 Feb 2022 05:35:17 +0900 Subject: [PATCH 19/78] remove unnecessary null-check on get_table_mapchr_opt() `name` here is always non-null, otherwise it leads segv at earlier code. --- src/nhlua.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nhlua.c b/src/nhlua.c index dad9f55b6d..ff8c985e95 100644 --- a/src/nhlua.c +++ b/src/nhlua.c @@ -239,7 +239,7 @@ get_table_mapchr_opt(lua_State *L, const char *name, schar defval) xint8 typ; ter = get_table_str_opt(L, name, emptystr); - if (name && ter && *ter) { + if (ter && *ter) { typ = (xint8) check_mapchr(ter); if (typ == INVALID_TYPE) nhl_error(L, "Erroneous map char"); From 1b1c45d3cee0677bf00a2771baaa8756b4fb9dd9 Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 6 Dec 2023 02:19:41 -0800 Subject: [PATCH 20/78] TTY_PERM_INVENT perminv_mode=inuse Revise the tty permanent inventory window's in-use mode to be able to switch back and forth between one full width panel and two side-by-side half width panels on the fly as needs dictate. A lot of trial and error involved but I think it has reached a state where it is reliable, and the smaller number of lines required at present can probably be viable for actual usage. At the moment it requires at least 10 extra lines below the standard tty mesg+map+stat display, 34 lines total for statuslines:2 or 35 for statuslines:3. The top and bottom of the 10 or more extra lines get drawn as boundary lines using wall characters, leaving 8 lines for full width or 16 half lines when 8 isn't enough. If more that 16 items are in use (maybe lots of lit candles forced into separate inventory slots or a menagerie on leashes), the excess get skipped. However, it will use more lines if they are available. Prior to a few days ago it was requiring 17 extra lines and able to show 15 items as full lines only, unable to take advantage of more lines when available. --- win/tty/wintty.c | 199 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 150 insertions(+), 49 deletions(-) diff --git a/win/tty/wintty.c b/win/tty/wintty.c index e054d90f5a..2037c780b9 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -263,6 +263,7 @@ static int inuse_only_start = 0; /* next slot to use for in-use-only mode */ static boolean done_tty_perm_invent_init = FALSE; enum { tty_slots = invlet_basic + invlet_gold + invlet_overflow }; /* 54 */ static boolean slot_tracker[tty_slots]; +static int ttyinv_slots_used = 0; /* 1-based, slot_trackter[0..slots-1] */ static long last_glyph_reset_when; #ifndef NOINVSYM /* invent.c */ #define NOINVSYM '#' @@ -274,13 +275,16 @@ static void ttyinv_add_menu(winid, struct WinDesc *, char ch, int attr, int clr, const char *str); static int selector_to_slot(char ch, const int invflags, boolean *ignore); static char slot_to_invlet(int, boolean); +static void ttyinv_inuse_fulllines(struct WinDesc *, int); +static void ttyinv_inuse_twosides(struct WinDesc *, int); +static void ttyinv_end_menu(int, struct WinDesc *); static void ttyinv_render(winid window, struct WinDesc *cw); static void tty_invent_box_glyph_init(struct WinDesc *cw); static boolean assesstty(enum inv_modes, short *, short *, long *, long *, long *, long *, long *); static void ttyinv_populate_slot(struct WinDesc *, int, int, const char *, int32_t); -#endif +#endif /* TTY_PERM_INVENT */ /* * A string containing all the default commands -- to add to a list @@ -2615,12 +2619,9 @@ tty_end_menu( ttywindowpanic(); } #ifdef TTY_PERM_INVENT - if (cw->mbehavior == MENU_BEHAVE_PERMINV - && (iflags.perm_invent - || gp.perm_invent_toggling_direction == toggling_on) - && window == WIN_INVEN) { - if (gp.program_state.in_moveloop) - ttyinv_render(window, cw); + /* (probably don't need to check both of these conditions) */ + if (cw->mbehavior == MENU_BEHAVE_PERMINV && window == WIN_INVEN) { + ttyinv_end_menu(window, cw); return; } #endif @@ -2917,18 +2918,19 @@ ttyinv_create_window(int newid, struct WinDesc *newwin) bordercol[border_left] = 0; bordercol[border_middle] = (newwin->maxcol + 1) / 2; bordercol[border_right] = newwin->maxcol - 1; - /* for in-use mode, use full lines */ + /* for in-use mode, use full lines; it will switch to two panels if + there are more items than the number of full lines */ if ((ttyinvmode & InvInUse) != 0) bordercol[border_middle] = bordercol[border_right]; - n = (unsigned) (newwin->maxrow * sizeof(struct tty_perminvent_cell *)); + n = (unsigned) (newwin->maxrow * sizeof (struct tty_perminvent_cell *)); newwin->cells = (struct tty_perminvent_cell **) alloc(n); - n = (unsigned) (newwin->maxcol * sizeof(struct tty_perminvent_cell)); + n = (unsigned) (newwin->maxcol * sizeof (struct tty_perminvent_cell)); for (i = 0; i < newwin->maxrow; i++) newwin->cells[i] = (struct tty_perminvent_cell *) alloc(n); - n = (unsigned) sizeof(glyph_info); + n = (unsigned) sizeof (glyph_info); for (r = 0; r < newwin->maxrow; r++) for (c = 0; c < newwin->maxcol; c++) { newwin->cells[r][c] = zerottycell; @@ -2942,6 +2944,7 @@ ttyinv_create_window(int newid, struct WinDesc *newwin) } } newwin->active = 1; + ttyinv_slots_used = 0; tty_invent_box_glyph_init(newwin); return newid; } @@ -3015,9 +3018,20 @@ ttyinv_add_menu( if (!gp.program_state.in_moveloop) return; slot = selector_to_slot(ch, ttyinvmode, &ignore); + if (inuse_only && slot > 2 * rows_per_side) + ignore = TRUE; /* left & right sides full; no 3rd 'side' available */ if (!ignore) { slot_tracker[slot] = TRUE; - /* maxslot = ((int) cw->maxrow - 2) * (!inuse_only ? 2 : 1); */ + /* if we need to expand inuse_only from one side to two, do so now; + entries are shown in row 1 thru rows_per_side (with rows 0 and + rows_per_side+1 containing boundary lines) but stored in + slots 0 thru rows_per_side-1, so zero-based slot==rows_per_side + is the entry that will be shown on first row of the second side + (and one-base ttyinv_slots_used==rows_per_side means that on the + previous inventory_update(), full lines filled all the rows) */ + if (inuse_only && slot == rows_per_side + && ttyinv_slots_used == rows_per_side) + ttyinv_inuse_twosides(cw, rows_per_side); /* TODO: check for MENUCOLORS match */ text = str; /* 'text' will switch to invbuf[] below */ @@ -3138,6 +3152,64 @@ slot_to_invlet(int slot, boolean incl_gold) return res; } +/* called if inuse_only contracts from two sides to one; there won't be + full lines shown until the next inventory update because the data past + the middle boundary was clipped rather than saved; caller or caller's + caller or somewhere up the call chain will call update_inventory() to + redraw it all and rectify that */ +static void +ttyinv_inuse_fulllines( + struct WinDesc *cw, + int rows_per_side UNUSED) +{ + bordercol[border_middle] = bordercol[border_right]; + tty_invent_box_glyph_init(cw); +} + +/* called when inuse_only expands from full lines (one side) to two sides */ +static void +ttyinv_inuse_twosides( + struct WinDesc *cw, + int rows_per_side) +{ + int row, col; + + bordercol[border_middle] = (cw->maxcol + 1) / 2; + tty_invent_box_glyph_init(cw); + /* draw the middle boundary */ + col = bordercol[border_middle]; + for (row = 0; row <= rows_per_side; ++row) + tty_refresh_inventory(col, col, row); +} + +/* split out of tty_end_menu(); persistent inventory is ready to display */ +static void +ttyinv_end_menu(int window, struct WinDesc *cw) +{ + if (iflags.perm_invent + || gp.perm_invent_toggling_direction == toggling_on) { + if (gp.program_state.in_moveloop) { + boolean inuse_only = ((ttyinvmode & InvInUse) != 0); + int rows_per_side = inuse_only ? cw->maxrow - 2 : 0; + int old_slots_used = ttyinv_slots_used; /* value before render */ + + ttyinv_render(window, cw); + + /* if inuse_only was using two sides and has just shrunk to one, + it will switch to full rows instead of side-by-side panels + but current data only holds the left-hand panel's portion; + rerun the whole thing to regenerate previously clipped data; + fortunately this should be a fairly rare occurrence */ + if (inuse_only && old_slots_used > rows_per_side + /* 'ttyinv_slots_used' was just updated by ttyinv_render() + to the number of entries currently shown */ + && ttyinv_slots_used <= rows_per_side) + tty_update_inventory(0); /* will call back to core for data */ + } + } +} + +/* display persistent inventory */ static void ttyinv_render(winid window, struct WinDesc *cw) { @@ -3145,15 +3217,18 @@ ttyinv_render(winid window, struct WinDesc *cw) struct tty_perminvent_cell *cell; char invbuf[BUFSZ]; boolean force_redraw = gp.program_state.in_docrt ? TRUE : FALSE, - show_gold = (ttyinvmode & InvShowGold) != 0, inuse_only = (ttyinvmode & InvInUse) != 0, + show_gold = (ttyinvmode & InvShowGold) != 0 && !inuse_only, sparse = (ttyinvmode & InvSparse) != 0 && !inuse_only; - int rows_per_side = (!show_gold ? 26 : 27); + int rows_per_side = (inuse_only ? (cw->maxrow - 2) + : !show_gold ? 26 + : 27); slot_limit = SIZE(slot_tracker); if (inuse_only) { - rows_per_side = cw->maxrow - 2; /* -2 top and bottom borders */ - slot_limit = rows_per_side; + slot_limit = rows_per_side; /* assume one side */ + if (ttyinv_slots_used >= rows_per_side) + slot_limit *= 2; /* second side is populated */ } else if (!show_gold) { slot_limit -= 2; /* there are two extra slots for gold and overflow; * blanking them for !show_gold would wrap back to @@ -3163,6 +3238,7 @@ ttyinv_render(winid window, struct WinDesc *cw) for (slot = 0; slot < slot_limit; ++slot) if (slot_tracker[slot]) filled_count++; + /* clear unused slots */ for (slot = 0; slot < slot_limit; ++slot) { if (slot_tracker[slot]) continue; @@ -3181,6 +3257,23 @@ ttyinv_render(winid window, struct WinDesc *cw) side = slot / rows_per_side; ttyinv_populate_slot(cw, row, side, invbuf, 0); } + + /* inuse_only might switch from one panel to two or vice versa */ + if (inuse_only && filled_count != ttyinv_slots_used) { + if (filled_count > rows_per_side + && ttyinv_slots_used <= rows_per_side) { + /* need second side; set up the middle border */ + /* done earlier, in add_menu(): + ttyinv_inuse_twosides(cw, rows_per_side); + */ + } else if (filled_count <= rows_per_side + && ttyinv_slots_used > rows_per_side) { + /* have second side but don't need/want it anymore */ + ttyinv_inuse_fulllines(cw, rows_per_side); + } + ttyinv_slots_used = filled_count; + } + /* has there been a glyph reset since we last got here? */ if (gg.glyph_reset_timestamp > last_glyph_reset_when) { /* // tty_invent_box_glyph_init(wins[WIN_INVEN]); */ @@ -3265,12 +3358,13 @@ ttyinv_populate_slot( struct tty_perminvent_cell *cell; char c; int ccnt, col, endcol; - boolean inuse_only = (ttyinvmode & InvInUse) != 0; + boolean oops, inuse_only = (ttyinvmode & InvInUse) != 0; - if (inuse_only && side == 1) /* there might be more in use than fits */ - return; - if (row < 0 || (long) row >= cw->maxrow || side < 0 || side > 1) - panic("ttyinv_populate_slot row=%d, size=%d", row, side); + oops = (row < 0 || (long) row >= cw->maxrow || side < 0); + if (inuse_only && side > 1 && !oops) + return; /* there might be more in-use than fits; ignore excess */ + if (oops || side > 1) + panic("ttyinv_populate_slot row=%d, side=%d", row, side); col = bordercol[side] + 1; endcol = bordercol[side + 1] - 1; @@ -3283,8 +3377,8 @@ ttyinv_populate_slot( memory allocated for it; gi pointer and ttychar character overlay each other in a union, so clear gi before assigning ttychar */ if (cell->glyph) { - free((genericptr_t) cell->content.gi), cell->content.gi = 0; - cell->glyph = 0; /* cell->content.gi is gone */ + free((genericptr_t) cell->content.gi); + *cell = zerottycell; /* clears cell->glyph and cell->content */ } if ((c = *text) != '\0') @@ -3343,8 +3437,8 @@ RESTORE_WARNING_FORMAT_NONLITERAL static void tty_invent_box_glyph_init(struct WinDesc *cw) - { - int row, col; +{ + int row, col, glyph; uchar sym; struct tty_perminvent_cell *cell; @@ -3354,13 +3448,7 @@ tty_invent_box_glyph_init(struct WinDesc *cw) for (row = 0; row < cw->maxrow; ++row) for (col = 0; col < cw->maxcol; ++col) { cell = &cw->cells[row][col]; - /* cell->glyph is a flag for whether the content union contains - a glyph_info structure rather than just a char */ - if (!cell->glyph) - continue; - /* sym will always get another value; if for some reason it - doesn't, this default is valid for cmap_walls_to_glyph() */ - sym = S_crwall; + sym = S_crwall; /* placeholder */ /* note: for top and bottom, check [border_right] before [border_middle] because they could be the same column (for InvInUse) and if so we want corner rather than tee there */ @@ -3395,25 +3483,38 @@ tty_invent_box_glyph_init(struct WinDesc *cw) sym = S_vwall; } - /* to get here, cell->glyph is 1 and cell->content union has gi */ - { - int oldsymidx = cell->content.gi->gm.sym.symidx; -#ifdef ENHANCED_SYMBOLS - struct unicode_representation * - oldgmu = cell->content.gi->gm.u; -#endif - int glyph = cmap_D0walls_to_glyph(sym); - - map_glyphinfo(0, 0, glyph, 0, cell->content.gi); - if ( -#ifdef ENHANCED_SYMBOLS - cell->content.gi->gm.u != oldgmu || -#endif - cell->content.gi->gm.sym.symidx != oldsymidx) + if (sym == S_crwall) { /* not a boundary (but might have been) */ + if (cell->glyph) { + /* presumably is no longer wanted middle vertical line */ + free((genericptr_t) cell->content.gi); + *cell = zerottycell; /* clears cell->glyph */ + cell->content.ttychar = ' '; + cell->text = 1; cell->refresh = 1; - cell->glyph = 1; /* (redundant) */ - cell->text = 0; + } + continue; + } + /* a boundary, but might not have been if this is the middle + and we were showing full lines and are now going to show two + sides; allocate glyph_info for middle vertical line */ + if (!cell->glyph) { + cell->content.gi = (glyph_info *) alloc(sizeof (glyph_info)); + *(cell->content.gi) = zerogi; + cell->glyph = 1, cell->text = 0; } + + /* to get here, cell->glyph is 1 and cell->content union has gi */ + glyph = cmap_D0walls_to_glyph(sym); + map_glyphinfo(0, 0, glyph, 0, cell->content.gi); + cell->glyph = 1; /* (redundant) */ + cell->text = 0; + /* originaly this conditionally set refresh depending upon + whether the glyph was already shown, but that optimization + is for something that rarely happens (boundary lines aren't + redrawn very often, and most of the time when they are it's + because they were erased or overwritten by something so + won't match the prior value anymore) so skip it */ + cell->refresh = 1; } done_tty_perm_invent_init = TRUE; } From 1f52205ee22df6111a88004db936e4677edab66e Mon Sep 17 00:00:00 2001 From: Ray Chason Date: Wed, 6 Dec 2023 09:05:23 -0500 Subject: [PATCH 21/78] Fix crashes and weirdness in VESA text mode --- sys/msdos/vidvesa.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/msdos/vidvesa.c b/sys/msdos/vidvesa.c index 461bc13fe6..31598de343 100644 --- a/sys/msdos/vidvesa.c +++ b/sys/msdos/vidvesa.c @@ -89,6 +89,7 @@ static struct map_struct { unsigned special; short int tileidx; int framecolor; + int inverse; } map[ROWNO][COLNO]; /* track the glyphs */ #define vesa_clearmap() \ @@ -102,6 +103,7 @@ static struct map_struct { map[y][x].attr = 0; \ map[y][x].special = 0; \ map[y][x].tileidx = Tile_unexplored; \ + map[y][x].inverse = 0; \ } \ } #define TOP_MAP_ROW 1 @@ -705,6 +707,7 @@ vesa_xputg(const glyph_info *glyphinfo, const glyph_info *bkglyphinfo UNUSED) map[ry][col].special = special; map[ry][col].tileidx = glyphinfo->gm.tileidx; map[ry][col].attr = attr; + map[ry][col].inverse = inversed; if (bkglyphinfo->framecolor != NO_COLOR) { map[ry][col].framecolor = bkglyphinfo->framecolor; @@ -820,6 +823,8 @@ vesa_redrawmap(void) for (cx = clipx; cx <= (unsigned) clipxmax && cx < COLNO; ++cx) { t_row[cx].chr = map[cy][cx].ch; t_row[cx].colour = map[cy][cx].attr; + t_row[cx].bgcolour = BACKGROUND_VESA_COLOR; + t_row[cx].inverse = map[cy][cx].inverse; } vesa_WriteTextRow(0, y, t_row + clipx, cx - clipx); x = (cx - clipx) * vesa_char_width; From 54332f5598d1838d3b9784d4dc5d14e7745418f8 Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 6 Dec 2023 13:30:33 -0500 Subject: [PATCH 22/78] TTY_PERM_INVENT: honor color passed by add_menu() Features like menucolors and so forth, are now done in the core, and passed to the window interfaces via add_menu(). TTY_PERM_INVENT was disregarding the passed color value. That can be turned off by the option !menucolors. If a way to turn off menucolors in TTY_PERM_INVENT (or perhaps in any perm_invent implementation), while keeping it on for other menus, then a new option will be required. --- win/tty/wintty.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 2037c780b9..0cab26a823 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -3002,7 +3002,7 @@ ttyinv_add_menu( winid window UNUSED, struct WinDesc *cw, char ch, - int attr UNUSED, int clr UNUSED, + int attr UNUSED, int clr, const char *str) { char invbuf[BUFSZ]; @@ -3060,7 +3060,7 @@ ttyinv_add_menu( row = (slot % rows_per_side) + 1; /* +1: top border */ /* side: left side panel or right side panel, not a window column */ side = slot / rows_per_side; - ttyinv_populate_slot(cw, row, side, text, 0); + ttyinv_populate_slot(cw, row, side, text, clr); } return; } @@ -3213,7 +3213,8 @@ ttyinv_end_menu(int window, struct WinDesc *cw) static void ttyinv_render(winid window, struct WinDesc *cw) { - int row, col, slot, side, filled_count = 0, slot_limit; + int row, col, slot, side, filled_count = 0, slot_limit, + current_row_color = NO_COLOR; struct tty_perminvent_cell *cell; char invbuf[BUFSZ]; boolean force_redraw = gp.program_state.in_docrt ? TRUE : FALSE, @@ -3282,7 +3283,7 @@ ttyinv_render(winid window, struct WinDesc *cw) } /* render to the display */ calling_from_update_inventory = TRUE; - for (row = 0; row < cw->maxrow; ++row) + for (row = 0; row < cw->maxrow; ++row) { for (col = 0; col < cw->maxcol; ++col) { cell = &cw->cells[row][col]; if (cell->refresh || force_redraw) { @@ -3291,6 +3292,14 @@ ttyinv_render(winid window, struct WinDesc *cw) &nul_glyphinfo); end_glyphout(); } else { + if (cell->color + && (current_row_color != cell->color - 1)) { + current_row_color = cell->color - 1; + if (current_row_color == NO_COLOR) + term_end_color(); + else + term_start_color(current_row_color); + } if (col != cw->curx || row != cw->cury) tty_curs(window, col + 1, row); (void) putchar(cell->content.ttychar); @@ -3300,6 +3309,9 @@ ttyinv_render(winid window, struct WinDesc *cw) cell->refresh = 0; } } + if (current_row_color != NO_COLOR) + term_end_color(); + } tty_curs(window, 1, 0); for (slot = 0; slot < SIZE(slot_tracker); ++slot) slot_tracker[slot] = FALSE; @@ -3369,9 +3381,6 @@ ttyinv_populate_slot( col = bordercol[side] + 1; endcol = bordercol[side + 1] - 1; cell = &cw->cells[row][col]; - if (cell->color != color) - cell->refresh = 1; - cell->color = color; for (ccnt = col; ccnt <= endcol; ++ccnt, ++cell) { /* [don't expect this to happen] if there was a glyph here, release memory allocated for it; gi pointer and ttychar character overlay @@ -3389,6 +3398,10 @@ ttyinv_populate_slot( cell->content.ttychar = c; cell->refresh = 1; } + if (cell->color != color + 1) { + cell->color = color + 1; /* offsets color by 1 so 0 isn't valid */ + cell->refresh = 1; + } cell->text = 1; /* cell->content.ttychar is current */ } } @@ -3438,7 +3451,7 @@ RESTORE_WARNING_FORMAT_NONLITERAL static void tty_invent_box_glyph_init(struct WinDesc *cw) { - int row, col, glyph; + int row, col, glyph, bordercolor = NO_COLOR; uchar sym; struct tty_perminvent_cell *cell; @@ -3491,6 +3504,7 @@ tty_invent_box_glyph_init(struct WinDesc *cw) cell->content.ttychar = ' '; cell->text = 1; cell->refresh = 1; + cell->color = bordercolor; } continue; } @@ -3501,6 +3515,7 @@ tty_invent_box_glyph_init(struct WinDesc *cw) cell->content.gi = (glyph_info *) alloc(sizeof (glyph_info)); *(cell->content.gi) = zerogi; cell->glyph = 1, cell->text = 0; + cell->color = bordercolor; } /* to get here, cell->glyph is 1 and cell->content union has gi */ From 8018fe64cf59a8f99eb8863bccebbb51a7393827 Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 6 Dec 2023 13:42:28 -0500 Subject: [PATCH 23/78] remove an outdated TODO: comment in wintty.c A comment made reference to something that is fulfilled by the core now, but that probably wasn't the case when that comment was originally added. --- win/tty/wintty.c | 1 - 1 file changed, 1 deletion(-) diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 0cab26a823..dbba04db8d 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -3033,7 +3033,6 @@ ttyinv_add_menu( && ttyinv_slots_used == rows_per_side) ttyinv_inuse_twosides(cw, rows_per_side); - /* TODO: check for MENUCOLORS match */ text = str; /* 'text' will switch to invbuf[] below */ /* strip away "a"/"an"/"the" prefix to show a bit more of the interesting part of the object's description; this From 45856e3b5b61c0161183ad07f7f721213890c1ce Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 6 Dec 2023 13:49:33 -0500 Subject: [PATCH 24/78] follow-up: bordercolor lacked have expected offset --- win/tty/wintty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/win/tty/wintty.c b/win/tty/wintty.c index dbba04db8d..960570ca32 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -3503,7 +3503,7 @@ tty_invent_box_glyph_init(struct WinDesc *cw) cell->content.ttychar = ' '; cell->text = 1; cell->refresh = 1; - cell->color = bordercolor; + cell->color = bordercolor + 1; /* cell color is offset */ } continue; } @@ -3514,7 +3514,7 @@ tty_invent_box_glyph_init(struct WinDesc *cw) cell->content.gi = (glyph_info *) alloc(sizeof (glyph_info)); *(cell->content.gi) = zerogi; cell->glyph = 1, cell->text = 0; - cell->color = bordercolor; + cell->color = bordercolor + 1; /* cell color is offset */ } /* to get here, cell->glyph is 1 and cell->content union has gi */ From 0d508cc93628b7b0ebb1a335bfe2f7eee3fe4188 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Wed, 6 Dec 2023 19:57:44 +0000 Subject: [PATCH 25/78] Implement the spellbook of chain lightning Prior to this commit, there was no good way to deal with swarms of weak, good-AC enemies using magic; trying to play a wizard as a pure spellcaster would make bees and ants very difficult to deal with (because they would usually dodge force bolts). This commit adds a new spell designed to be very good against swarms of weak enemies: "chain lightning", which does 2d6 lightning damage to every monster around you. It has an initially short range, but can chain from monster to monster to cover potentially large distances (as long as none of the monsters en route are shock resistant or tame/peaceful; the spell can't chain past shock resistant monsters and avoids peacefuls). Monsters within one space of the visible lightning bolts are affected. Unlike other lightning effects, this one does only 2d6 damage, not enough to blind affected monsters. This commit breaks existing save and bones files (thus the EDITLEVEL increase). --- include/objects.h | 12 ++- include/patchlevel.h | 2 +- src/spell.c | 176 ++++++++++++++++++++++++++++++++++++++++++ src/zap.c | 6 +- win/share/objects.txt | 19 +++++ 5 files changed, 208 insertions(+), 7 deletions(-) diff --git a/include/objects.h b/include/objects.h index 11de04b07d..98ee04a7f8 100644 --- a/include/objects.h +++ b/include/objects.h @@ -1287,10 +1287,10 @@ SPELL("healing", "white", P_HEALING_SPELL, 40, 2, 1, 1, IMMEDIATE, CLR_WHITE, SPE_HEALING), SPELL("knock", "pink", - P_MATTER_SPELL, 35, 1, 1, 1, IMMEDIATE, CLR_BRIGHT_MAGENTA, + P_MATTER_SPELL, 25, 1, 1, 1, IMMEDIATE, CLR_BRIGHT_MAGENTA, SPE_KNOCK), SPELL("force bolt", "red", - P_ATTACK_SPELL, 35, 2, 1, 1, IMMEDIATE, CLR_RED, + P_ATTACK_SPELL, 30, 2, 1, 1, IMMEDIATE, CLR_RED, SPE_FORCE_BOLT), SPELL("confuse monster", "orange", P_ENCHANTMENT_SPELL, 49, 2, 1, 1, IMMEDIATE, CLR_ORANGE, @@ -1305,7 +1305,7 @@ SPELL("slow monster", "light green", P_ENCHANTMENT_SPELL, 30, 2, 2, 1, IMMEDIATE, CLR_BRIGHT_GREEN, SPE_SLOW_MONSTER), SPELL("wizard lock", "dark green", - P_MATTER_SPELL, 30, 3, 2, 1, IMMEDIATE, CLR_GREEN, + P_MATTER_SPELL, 25, 3, 2, 1, IMMEDIATE, CLR_GREEN, SPE_WIZARD_LOCK), SPELL("create monster", "turquoise", P_CLERIC_SPELL, 35, 3, 2, 1, NODIR, CLR_BRIGHT_CYAN, @@ -1341,7 +1341,7 @@ SPELL("restore ability", "light brown", P_HEALING_SPELL, 25, 5, 4, 1, NODIR, CLR_BROWN, SPE_RESTORE_ABILITY), SPELL("invisibility", "dark brown", - P_ESCAPE_SPELL, 25, 5, 4, 1, NODIR, CLR_BROWN, + P_ESCAPE_SPELL, 20, 5, 4, 1, NODIR, CLR_BROWN, SPE_INVISIBILITY), SPELL("detect treasure", "gray", P_DIVINATION_SPELL, 20, 5, 4, 1, NODIR, CLR_GRAY, @@ -1379,6 +1379,10 @@ SPELL("jumping", "thin", SPELL("stone to flesh", "thick", P_HEALING_SPELL, 15, 1, 3, 1, IMMEDIATE, HI_PAPER, SPE_STONE_TO_FLESH), +SPELL("chain lightning", "checkered", + P_ATTACK_SPELL, 25, 4, 2, 1, NODIR, CLR_GRAY, + SPE_CHAIN_LIGHTNING), + #if 0 /* DEFERRED */ /* from slash'em, create a tame critter which explodes when attacking, damaging adjacent creatures--friend or foe--and dying in the process */ diff --git a/include/patchlevel.h b/include/patchlevel.h index 42ba716f61..0abd715764 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -17,7 +17,7 @@ * Incrementing EDITLEVEL can be used to force invalidation of old bones * and save files. */ -#define EDITLEVEL 91 +#define EDITLEVEL 92 /* * Development status possibilities. diff --git a/src/spell.c b/src/spell.c index 940de8c35f..e16367534f 100644 --- a/src/spell.c +++ b/src/spell.c @@ -41,6 +41,7 @@ static int percent_success(int); static char *spellretention(int, char *); static int throwspell(void); static void cast_protection(void); +static void cast_chain_lightning(void); static void spell_backfire(int); static boolean spelleffects_check(int, int *, int *); static const char *spelltypemnemonic(int); @@ -865,6 +866,178 @@ skill_based_spellbook_id(void) } } + +/* Limit the total area chain lightning can cover; this is both for + technical reasons (making it possible to limit the size of arrays + here and in the display code) and for gameplay balance reasons; + this value should be smaller than TMP_AT_MAX_GLYPHS (display.c) in + order for chain lightning to display properly */ +#define CHAIN_LIGHTNING_LIMIT 100 +/* Unlike most zaps, chain lightning can't hit solid terrain (it + doesn't have enough power), it only covers open space; this also + means that it can't hit monsters inside walls, which makes sense as + they would be earthed */ +#define CHAIN_LIGHTNING_TYP(typ) (IS_POOL(typ) || SPACE_POS(typ)) +#define CHAIN_LIGHTNING_POS(x, y) \ + (isok(x, y) && (CHAIN_LIGHTNING_TYP(levl[x][y].typ) || \ + (IS_DOOR(levl[x][y].typ) && \ + !(levl[x][y].doormask & (D_CLOSED | D_LOCKED))))) + +struct chain_lightning_zap { + /* direction in which this zap is currently moving; this is an + enum movementdirs, clamped to the range 0 inclusive to N_DIRS + exclusive */ + uchar dir; + /* current location of the zap */ + coordxy x, y; + /* distance this zap can cover without chaining */ + char strength; +}; + +struct chain_lightning_queue { + struct chain_lightning_zap q[CHAIN_LIGHTNING_LIMIT]; + int head; + int tail; + int displayed_beam; +}; + +/* Given a potential chain lightning zap, moves it one square forward in + the given direction, then adds it to the queue unless it would hit an + invalid square or is out of power. + + zap is passed by value, so the move-forward doesn't change the passed + argument. */ +static void +propagate_chain_lightning( + struct chain_lightning_queue *clq, + struct chain_lightning_zap zap) +{ + struct monst *mon; + + zap.x += xdir[zap.dir]; + zap.y += ydir[zap.dir]; + + if (clq->tail >= CHAIN_LIGHTNING_LIMIT) + return; /* zap has covered too many squares */ + if (!CHAIN_LIGHTNING_POS(zap.x, zap.y)) + return; /* zap can't go to this square */ + + mon = m_at(zap.x, zap.y); + if (mon && mon->mpeaceful) + return; /* chain lightning avoids peaceful and tame monsters */ + + /* When hitting a monster that isn't electricity-resistant, a + particular chain lightning zap regains all its power, allowing it to + chain to other monsters; upon hitting a shock-resistant monster it + can't continue any further, but we let it hit the monster to show + the shield effect */ + if (mon && !resists_elec(mon) && !defended(mon, AD_ELEC)) + zap.strength = 3; + else if (mon) + zap.strength = 0; + + /* Unless it hits a monster, the last square of a zap isn't drawn on + screen and can't propagate further, so it may as well be discarded + now */ + if (!mon && !zap.strength) + return; + + /* The same square can't be chained to twice. */ + for (int i = 0; i < clq->tail; i++) { + if (clq->q[i].x == zap.x && clq->q[i].y == zap.y) + return; + } + + /* This array access must be inbounds due to the CHAIN_LIGHTNING_LIMIT + check earlier. */ + clq->q[clq->tail++] = zap; + + /* Draw it. */ + tmp_at(DISP_CHANGE, zapdir_to_glyph( + xdir[zap.dir], ydir[zap.dir], clq->displayed_beam)); + tmp_at(zap.x, zap.y); +} + +static void +cast_chain_lightning(void) +{ + struct chain_lightning_queue clq = { + {{0}}, 0, 0, Hallucination ? rn2_on_display_rng(6) : (AD_ELEC - 1) + }; + + if (u.uswallow) { + // TODO: damage the engulfer + return; + } + + /* set the type of beam we're using; the direction here is arbitrary + because we change the beam direction just before drawing the beam + anyway */ + tmp_at(DISP_BEAM, zapdir_to_glyph(0, 1, clq.displayed_beam)); + + /* start by propagating in all directions from the caster */ + for (int dir = 0; dir < N_DIRS; dir++) { + struct chain_lightning_zap zap = { dir, u.ux, u.uy, 2 }; + propagate_chain_lightning(&clq, zap); + } + nh_delay_output(); + + while (clq.head < clq.tail) { + int delay_tail = clq.tail; + while (clq.head < delay_tail) { + struct chain_lightning_zap zap = clq.q[clq.head++]; + + /* damage any monster that was hit */ + struct monst *mon = m_at(zap.x, zap.y); + if (mon) { + struct obj *unused; /* AD_ELEC can't destroy armor */ + int dmg = zhitm( + mon, BZ_U_SPELL(AD_ELEC - 1), 2, &unused); + + if (dmg) { + /* mon has been damaged, but we haven't yet printed the + messages or given kill credit; assume the hero can + sense their spell hitting monsters, because they can + steer it away from peacefuls */ + if (DEADMONSTER(mon)) + xkilled(mon, XKILL_GIVEMSG); + else + pline("You shock %s%s", mon_nam(mon), exclam(dmg)); + } else if (canseemon(mon)) { + pline("%s resists.", Monnam(mon)); + } + } + + /* each zap propagates forwards with 1 less strength, and + diagonally with 0 strength (thus the diagonal zaps aren't + drawn and don't spread unless they hit a monster); + exception: if the zap just hit a monster, the diagonals have + as much strength as the forwards zap */ + if (!zap.strength) + continue; /* happens upon hitting a shock-resistant monster */ + zap.strength--; + + propagate_chain_lightning(&clq, zap); + + if (zap.strength < 2) + zap.strength = 0; + else if (u.uen) + u.uen--; /* propagating past monsters increases Pw cost a bit */ + zap.dir = DIR_LEFT(zap.dir); + propagate_chain_lightning(&clq, zap); + + zap.dir = DIR_RIGHT2(zap.dir); + propagate_chain_lightning(&clq, zap); + } + nh_delay_output(); + } + nh_delay_output(); + nh_delay_output(); + + tmp_at(DISP_END, 0); +} + + static void cast_protection(void) { @@ -1336,6 +1509,9 @@ spelleffects(int spell_otyp, boolean atme, boolean force) if (!(jump(max(role_skill, 1)) & ECMD_TIME)) pline1(nothing_happens); break; + case SPE_CHAIN_LIGHTNING: + cast_chain_lightning(); + break; default: impossible("Unknown spell %d attempted.", spell); obfree(pseudo, (struct obj *) 0); diff --git a/src/zap.c b/src/zap.c index 22c11e64db..b8d77bfff2 100644 --- a/src/zap.c +++ b/src/zap.c @@ -4198,10 +4198,12 @@ zhitm( /* can still blind the monster */ } else tmp = d(nd, 6); - if (spellcaster) + if (spellcaster && tmp) tmp = spell_damage_bonus(tmp); if (!resists_blnd(mon) - && !(type > 0 && engulfing_u(mon))) { + && !(type > 0 && engulfing_u(mon)) + && nd > 2) { + /* sufficiently powerful lightning blinds monsters */ register unsigned rnd_tmp = rnd(50); mon->mcansee = 0; if ((mon->mblinded + rnd_tmp) > 127) diff --git a/win/share/objects.txt b/win/share/objects.txt index e8ab2335b0..7ce7c8d807 100644 --- a/win/share/objects.txt +++ b/win/share/objects.txt @@ -7745,6 +7745,25 @@ Z = (195, 195, 195) .......JJJAA.... ................ } +# tile 405 (checkered / chain lightning) +{ + ................ + ................ + ................ + ....AAAA........ + ....AAAAAA...... + ...AAADDDANNP... + ...AADDAADNNN... + ..PNAADDNNNNOA.. + ..NNDNADDNNNOAA. + .PNNNDDDAAAONA.. + .NNNNNNAAAAAAA.. + .NOONNAAAAAOA... + ..PNOOOAAAOA.... + ....PAAOOOA..... + .......AAA...... + ................ +} # tile 405 (plain / blank paper) { ................ From 11a926c4cc1ac87edff679878569f7f1b1ecfa4f Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 6 Dec 2023 15:41:06 -0500 Subject: [PATCH 26/78] TTY_PERM_INVENT: menucolors colors text, not inv letter This diff is slightly inflated because I relocated a tty function within win/tty/wintty.c. --- win/tty/wintty.c | 118 +++++++++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 55 deletions(-) diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 960570ca32..8e2091ea73 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -283,7 +283,7 @@ static void tty_invent_box_glyph_init(struct WinDesc *cw); static boolean assesstty(enum inv_modes, short *, short *, long *, long *, long *, long *, long *); static void ttyinv_populate_slot(struct WinDesc *, int, int, - const char *, int32_t); + const char *, int32_t, int); #endif /* TTY_PERM_INVENT */ /* @@ -3010,7 +3010,7 @@ ttyinv_add_menu( boolean show_gold = (ttyinvmode & InvShowGold) != 0, inuse_only = (ttyinvmode & InvInUse) != 0, ignore = FALSE; - int row, side, slot, + int row, side, slot, startcolor_at = 0, rows_per_side = (inuse_only ? (cw->maxrow - 2) : !show_gold ? 26 : 27); @@ -3056,10 +3056,11 @@ ttyinv_add_menu( */ Snprintf(invbuf, sizeof invbuf, "%c - %s", ch, text); text = invbuf; + startcolor_at = sizeof ("a - ") - 1; row = (slot % rows_per_side) + 1; /* +1: top border */ /* side: left side panel or right side panel, not a window column */ side = slot / rows_per_side; - ttyinv_populate_slot(cw, row, side, text, clr); + ttyinv_populate_slot(cw, row, side, text, clr, startcolor_at); } return; } @@ -3255,7 +3256,7 @@ ttyinv_render(winid window, struct WinDesc *cw) row = (slot % rows_per_side) + 1; /* +1: top border */ /* side: left side panel or right side panel, not a window column */ side = slot / rows_per_side; - ttyinv_populate_slot(cw, row, side, invbuf, 0); + ttyinv_populate_slot(cw, row, side, invbuf, NO_COLOR, 0); } /* inuse_only might switch from one panel to two or vice versa */ @@ -3286,19 +3287,19 @@ ttyinv_render(winid window, struct WinDesc *cw) for (col = 0; col < cw->maxcol; ++col) { cell = &cw->cells[row][col]; if (cell->refresh || force_redraw) { + if (cell->color + && (current_row_color != cell->color - 1)) { + current_row_color = cell->color - 1; + if (current_row_color == NO_COLOR) + term_end_color(); + else + term_start_color(current_row_color); + } if (cell->glyph) { tty_print_glyph(window, col + 1, row, cell->content.gi, &nul_glyphinfo); end_glyphout(); } else { - if (cell->color - && (current_row_color != cell->color - 1)) { - current_row_color = cell->color - 1; - if (current_row_color == NO_COLOR) - term_end_color(); - else - term_start_color(current_row_color); - } if (col != cw->curx || row != cw->cury) tty_curs(window, col + 1, row); (void) putchar(cell->content.ttychar); @@ -3318,45 +3319,6 @@ ttyinv_render(winid window, struct WinDesc *cw) return; } -/* - * returns TRUE if things are ok - */ -static boolean -assesstty( - enum inv_modes invmode, - short *offx, short *offy, long *rows, long *cols, - long *maxcol, long *minrow, long *maxrow) -{ - boolean inuse_only = (invmode & InvInUse) != 0, - show_gold = (invmode & InvShowGold) != 0 && !inuse_only; - - *offx = 0; - /* topline + map rows + status lines */ - *offy = 1 + ROWNO + StatusRows(); /* 1 + 21 + (2 or 3) */ - *rows = (ttyDisplay->rows - *offy); - *cols = ttyDisplay->cols; - *minrow = tty_perminv_minrow; - if (show_gold) - *minrow += 1; -#define SMALL_INUSE_WINDOW -#ifdef SMALL_INUSE_WINDOW -#undef SMALL_INUSE_WINDOW - /* simplify testing by not requiring a small font to have enough room */ - if (inuse_only) - *minrow = 1 + 8 + 1; -#else - /* "normal" max for items in use would be 3 weapon + 7 armor + 4 - accessories == 14, but lit lamps/candles and attached leashes are - also included; if hero ends up with more than 15 in-use items, - some will be left out */ - if (inuse_only) - *minrow = 1 + 15 + 1; /* top border + 15 lines + bottom border */ -#endif - *maxrow = *rows; - *maxcol = *cols; - return !(*rows < *minrow || *cols < tty_perminv_mincol); -} - /* put the formatted object description for one item into a particular row and left/right panel, truncating if long or padding with spaces if short */ static void @@ -3364,7 +3326,9 @@ ttyinv_populate_slot( struct WinDesc *cw, int row, /* 'row' within the window, not within screen */ int side, /* 'side'==0 is left panel or ==1 is right panel */ - const char *text, int32_t color) + const char *text, + int32_t color, + int clroffset) { struct tty_perminvent_cell *cell; char c; @@ -3393,12 +3357,17 @@ ttyinv_populate_slot( ++text; else c = ' '; + if (cell->content.ttychar != c) { cell->content.ttychar = c; cell->refresh = 1; } if (cell->color != color + 1) { - cell->color = color + 1; /* offsets color by 1 so 0 isn't valid */ + /* offset color by 1 so 0 is not valid */ + if (ccnt >= (col + clroffset)) + cell->color = color + 1; + else + cell->color = NO_COLOR + 1; cell->refresh = 1; } cell->text = 1; /* cell->content.ttychar is current */ @@ -3503,7 +3472,6 @@ tty_invent_box_glyph_init(struct WinDesc *cw) cell->content.ttychar = ' '; cell->text = 1; cell->refresh = 1; - cell->color = bordercolor + 1; /* cell color is offset */ } continue; } @@ -3514,7 +3482,6 @@ tty_invent_box_glyph_init(struct WinDesc *cw) cell->content.gi = (glyph_info *) alloc(sizeof (glyph_info)); *(cell->content.gi) = zerogi; cell->glyph = 1, cell->text = 0; - cell->color = bordercolor + 1; /* cell color is offset */ } /* to get here, cell->glyph is 1 and cell->content union has gi */ @@ -3529,10 +3496,51 @@ tty_invent_box_glyph_init(struct WinDesc *cw) because they were erased or overwritten by something so won't match the prior value anymore) so skip it */ cell->refresh = 1; + cell->color = bordercolor + 1; } done_tty_perm_invent_init = TRUE; } +/* + * returns TRUE if things are ok + */ +static boolean +assesstty( + enum inv_modes invmode, + short *offx, short *offy, long *rows, long *cols, + long *maxcol, long *minrow, long *maxrow) +{ + boolean inuse_only = (invmode & InvInUse) != 0, + show_gold = (invmode & InvShowGold) != 0 && !inuse_only; + + *offx = 0; + /* topline + map rows + status lines */ + *offy = 1 + ROWNO + StatusRows(); /* 1 + 21 + (2 or 3) */ + *rows = (ttyDisplay->rows - *offy); + *cols = ttyDisplay->cols; + *minrow = tty_perminv_minrow; + if (show_gold) + *minrow += 1; +#define SMALL_INUSE_WINDOW +#ifdef SMALL_INUSE_WINDOW +#undef SMALL_INUSE_WINDOW + /* simplify testing by not requiring a small font to have enough room */ + if (inuse_only) + *minrow = 1 + 8 + 1; +#else + /* "normal" max for items in use would be 3 weapon + 7 armor + 4 + accessories == 14, but lit lamps/candles and attached leashes are + also included; if hero ends up with more than 15 in-use items, + some will be left out */ + if (inuse_only) + *minrow = 1 + 15 + 1; /* top border + 15 lines + bottom border */ +#endif + *maxrow = *rows; + *maxcol = *cols; + return !(*rows < *minrow || *cols < tty_perminv_mincol); +} + + #endif /* TTY_PERM_INVENT */ /* update persistent inventory window */ From c1910026f052ffde65bb0d4fde1e8a327b69c79f Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 6 Dec 2023 21:41:49 -0500 Subject: [PATCH 27/78] include some more enum dumps --- include/defsym.h | 71 ++++++++++++++++++++++++++++++++++---- src/allmain.c | 88 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 145 insertions(+), 14 deletions(-) diff --git a/include/defsym.h b/include/defsym.h index 8bef0c0067..cda01dc0d5 100644 --- a/include/defsym.h +++ b/include/defsym.h @@ -28,10 +28,15 @@ to #include defsym.h) - in win/share/tilemap.c for processing a tile file (define PCHAR_TILES prior to #include defsym.h). + - in src/allmain.c for setting up the dumping of several enums + (define DUMP_ENUMS_PCHAR, DUMP_ENUMS_MONSYS, DUMP_ENUMS_MONSYMS_DEFCHAR + DUMP_ENUMS_OBJCLASS_DEFCHARS, DUMP_ENUMS_OBJCLASS_DEFCHARS + DUMP_ENUMS_OBJCLASS_CLASSES, DUMP_ENUMS_OBJCLASS_SYMS) */ #if defined(PCHAR_S_ENUM) || defined(PCHAR_PARSE) \ - || defined(PCHAR_DRAWING) || defined(PCHAR_TILES) + || defined(PCHAR_DRAWING) || defined(PCHAR_TILES) \ + || defined(DUMP_ENUMS_PCHAR) /* PCHAR(idx, ch, sym, desc, clr) @@ -67,6 +72,13 @@ /* win/share/tilemap.c */ #define PCHAR(idx, ch, sym, desc, clr) { sym, desc, desc }, #define PCHAR2(idx, ch, sym, tilenm, desc, clr) { sym, tilenm, desc }, + +#elif defined(DUMP_ENUMS_PCHAR) +/* allmain.c */ +#define PCHAR(idx, ch, sym, desc, clr) { sym, #sym }, +#ifndef PCHAR2 +#define PCHAR2(idx, ch, sym, tilenm, desc, clr) { sym, #sym }, +#endif #endif /* PCHAR with extra arg */ @@ -229,10 +241,12 @@ PCHAR2(104, '/', S_expl_br, "explosion bottom right", "", CLR_ORANGE) #undef PCHAR #undef PCHAR2 -#endif /* PCHAR_S_ENUM || PCHAR_PARSE || PCHAR_DRAWING || PCHAR_TILES */ +#endif /* PCHAR_S_ENUM || PCHAR_PARSE || PCHAR_DRAWING || PCHAR_TILES + * || DUMP_ENUMS_PCHAR */ #if defined(MONSYMS_S_ENUM) || defined(MONSYMS_DEFCHAR_ENUM) \ - || defined(MONSYMS_PARSE) || defined(MONSYMS_DRAWING) + || defined(MONSYMS_PARSE) || defined(MONSYMS_DRAWING) \ + || defined(DUMP_ENUMS_MONSYMS) || defined(DUMP_ENUMS_MONSYMS_DEFCHAR) /* MONSYM(idx, ch, sym desc) @@ -258,6 +272,14 @@ #elif defined(MONSYMS_DRAWING) /* drawing.c */ #define MONSYM(idx, ch, basename, sym, desc) { DEF_##basename, "", desc }, + +/* allmain.c */ +#elif defined(DUMP_ENUMS_MONSYMS) +#define MONSYM(idx, ch, basename, sym, desc) { sym, #sym }, + +#elif defined(DUMP_ENUMS_MONSYMS_DEFCHAR) +#define MONSYM(idx, ch, basename, sym, desc) { DEF_##basename, "DEF_" #basename }, + #endif MONSYM( 1, 'a', ANT, S_ANT, "ant or other insect") @@ -335,11 +357,14 @@ #undef MONSYM #endif /* MONSYMS_S_ENUM || MONSYMS_DEFCHAR_ENUM || MONSYMS_PARSE - * || MONSYMS_DRAWING */ + * || MONSYMS_DRAWING || DUMP_ENUMS_MONSYMS) + * || DUMP_ENUMS_MONSYMS_DEFCHAR */ #if defined(OBJCLASS_S_ENUM) || defined(OBJCLASS_DEFCHAR_ENUM) \ || defined(OBJCLASS_CLASS_ENUM) || defined(OBJCLASS_PARSE) \ - || defined (OBJCLASS_DRAWING) + || defined(OBJCLASS_DRAWING) || defined(DUMP_ENUMS_OBJCLASS_DEFCHARS) \ + || defined(DUMP_ENUMS_OBJCLASS_CLASSES) \ + || defined(DUMP_ENUMS_OBJCLASS_SYMS) /* OBJCLASS(idx, ch, basename, sym, name, explain) @@ -387,6 +412,21 @@ /* drawing.c */ #define OBJCLASS(idx, ch, basename, sym, name, explain) \ { basename##_SYM, name, explain }, + +#elif defined(DUMP_ENUMS_OBJCLASS_DEFCHARS) +/* allmain.c */ +#define OBJCLASS(idx, ch, basename, sym, name, explain) \ + { basename##_SYM, #basename "_SYM" }, + +#elif defined(DUMP_ENUMS_OBJCLASS_CLASSES) +/* allmain.c */ +#define OBJCLASS(idx, ch, basename, sym, name, explain) \ + { basename##_CLASS, #basename "_CLASS" }, + +#elif defined(DUMP_ENUMS_OBJCLASS_SYMS) +/* allmain.c */ +#define OBJCLASS(idx, ch, basename, sym, name, explain) \ + { sym , #sym }, #endif /* OBJCLASS with extra arg */ @@ -396,6 +436,15 @@ #elif defined(OBJCLASS_DRAWING) #define OBJCLASS2(idx, ch, basename, sname, sym, name, explain) \ { sname, name, explain }, +#elif defined(DUMP_ENUMS_OBJCLASS_DEFCHARS) +#define OBJCLASS2(idx, ch, basename, sname, sym, name, explain) \ + { sname, #sname }, +#elif defined(DUMP_ENUMS_OBJCLASS_CLASSES) +#define OBJCLASS2(idx, ch, basename, sname, sym, name, explain) \ + { basename##_CLASS, #basename "_CLASS" }, +#elif defined(DUMP_ENUMS_OBJCLASS_SYMS) +#define OBJCLASS2(idx, ch, basename, sname, sym, name, explain) \ + { sym , #sym }, #else #define OBJCLASS2(idx, ch, basename, sname, sym, name, explain) \ OBJCLASS(idx, ch, basename, sym, name, explain) @@ -424,16 +473,24 @@ #undef OBJCLASS #undef OBJCLASS2 #endif /* OBJCLASS_S_ENUM || OBJCLASS_DEFCHAR_ENUM || OBJCLASS_CLASS_ENUM - * || OBJCLASS_PARSE || OBJCLASS_DRAWING */ + * || OBJCLASS_PARSE || OBJCLASS_DRAWING + * || DUMP_ENUMS_OBJCLASS_DEFCHARS || DUMP_ENUMS_OBJCLASS_CLASSES + * || DUMP_ENUMS_OBJCLASS_SYMS */ #ifdef DEBUG #if !defined(PCHAR_S_ENUM) && !defined(PCHAR_DRAWING) \ && !defined(PCHAR_PARSE) && !defined(PCHAR_TILES) \ + && !defined(DUMP_ENUMS_PCHAR) \ && !defined(MONSYMS_S_ENUM) && !defined(MONSYMS_DEFCHAR_ENUM) \ && !defined(MONSYMS_PARSE) && !defined(MONSYMS_DRAWING) \ + && !defined(DUMP_ENUMS_MONSYMS) \ + && !defined(DUMP_ENUMS_MONSYMS_DEFCHAR) \ && !defined(OBJCLASS_S_ENUM) && !defined(OBJCLASS_DEFCHAR_ENUM) \ && !defined(OBJCLASS_CLASS_ENUM) && !defined(OBJCLASS_PARSE) \ - && !defined (OBJCLASS_DRAWING) + && !defined (OBJCLASS_DRAWING) \ + && !defined(DUMP_ENUMS_OBJCLASS_DEFCHARS) \ + && !defined(DUMP_ENUMS_OBJCLASS_CLASSES) \ + && !defined(DUMP_ENUMS_OBJCLASS_SYMS) #error Non-productive inclusion of defsym.h #endif #endif /* DEBUG */ diff --git a/src/allmain.c b/src/allmain.c index 6f8c47856c..dbe9b0fe7d 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -1118,9 +1118,49 @@ struct enum_dump objdump[] = { #include "objects.h" { NUM_OBJECTS, "NUM_OBJECTS" }, }; + +#define DUMP_ENUMS_PCHAR +struct enum_dump defsym_cmap_dump[] = { +#include "defsym.h" + { MAXPCHARS, "MAXPCHARS" }, +}; +#undef DUMP_ENUMS_PCHAR + +#define DUMP_ENUMS_MONSYMS +struct enum_dump defsym_mon_syms_dump[] = { +#include "defsym.h" + { MAXMCLASSES, "MAXMCLASSES" }, +}; +#undef DUMP_ENUMS_MONSYMS + +#define DUMP_ENUMS_MONSYMS_DEFCHAR +struct enum_dump defsym_mon_defchars_dump[] = { +#include "defsym.h" +}; +#undef DUMP_ENUMS_MONSYMS_DEFCHAR + +#define DUMP_ENUMS_OBJCLASS_DEFCHARS +struct enum_dump objclass_defchars_dump[] = { +#include "defsym.h" +}; +#undef DUMP_ENUMS_OBJCLASS_DEFCHARS + +#define DUMP_ENUMS_OBJCLASS_CLASSES +struct enum_dump objclass_classes_dump[] = { +#include "defsym.h" +}; +#undef DUMP_ENUMS_OBJCLASS_CLASSES + +#define DUMP_ENUMS_OBJCLASS_SYMS +struct enum_dump objclass_syms_dump[] = { +#include "defsym.h" +}; +#undef DUMP_ENUMS_OBJCLASS_SYMS + #undef DUMP_ENUMS #ifndef NODUMPENUMS + static void dump_enums(void) { @@ -1128,10 +1168,19 @@ dump_enums(void) monsters_enum, objects_enum, objects_misc_enum, + defsym_cmap_enum, + defsym_mon_syms_enum, + defsym_mon_defchars_enum, + objclass_defchars_enum, + objclass_classes_enum, + objclass_syms_enum, NUM_ENUM_DUMPS }; static const char *const titles[NUM_ENUM_DUMPS] = { - "monnums", "objects_nums" , "misc_object_nums" + "monnums", "objects_nums" , "misc_object_nums", + "cmap_symbols", "mon_syms", "mon_defchars", + "objclass_defchars", "objclass_classes", + "objclass_syms", }; #define dump_om(om) { om, #om } static const struct enum_dump omdump[] = { @@ -1153,14 +1202,29 @@ dump_enums(void) }; #undef dump_om static const struct enum_dump *const ed[NUM_ENUM_DUMPS] = { - monsdump, objdump, omdump + monsdump, objdump, omdump, + defsym_cmap_dump, defsym_mon_syms_dump, + defsym_mon_defchars_dump, + objclass_defchars_dump, + objclass_classes_dump, + objclass_syms_dump, }; - static const char *const pfx[NUM_ENUM_DUMPS] = { "PM_", "", "" }; - static int szd[NUM_ENUM_DUMPS] = { - SIZE(monsdump), SIZE(objdump), SIZE(omdump) + static const char *const pfx[NUM_ENUM_DUMPS] = { "PM_", "", "", + "", "", "", "", + "", "" }; + /* 0 = dump numerically only, 1 = add 'char' comment */ + static const int dumpflgs[NUM_ENUM_DUMPS] = { 0, 0, 0, 0, 0, 1, 1, 0, 0}; + static int szd[NUM_ENUM_DUMPS] = { SIZE(monsdump), SIZE(objdump), + SIZE(omdump), SIZE(defsym_cmap_dump), + SIZE(defsym_mon_syms_dump), + SIZE(defsym_mon_defchars_dump), + SIZE(objclass_defchars_dump), + SIZE(objclass_classes_dump), + SIZE(objclass_syms_dump) }; const char *nmprefix; int i, j, nmwidth; + char comment[BUFSZ]; for (i = 0; i < NUM_ENUM_DUMPS; ++ i) { raw_printf("enum %s = {", titles[i]); @@ -1169,8 +1233,18 @@ dump_enums(void) nmprefix = (j >= szd[i] - unprefixed_count) ? "" : pfx[i]; /* "" or "PM_" */ nmwidth = 27 - (int) strlen(nmprefix); /* 27 or 24 */ - raw_printf(" %s%*s = %3d,", - nmprefix, -nmwidth, ed[i][j].nm, ed[i][j].val); + if (dumpflgs[i] > 0) { + Snprintf(comment, sizeof comment, + " /* '%c' */", + (ed[i][j].val >= 32 && ed[i][j].val <= 126) + ? ed[i][j].val : ' '); + } else { + comment[0] = '\0'; + } + raw_printf(" %s%*s = %3d,%s", + nmprefix, -nmwidth, + ed[i][j].nm, ed[i][j].val, + comment); } raw_print("};"); raw_print(""); From ee3ebcc10dabbb2a53160adffd5e7faceb0b1a39 Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 6 Dec 2023 22:18:11 -0500 Subject: [PATCH 28/78] fix bug in mon.c reported by paxed Also adds a shorthand macro monsym(&mons[n]) for getting the default symbol, used in the bugfix. --- include/mondata.h | 1 + src/detect.c | 2 +- src/makemon.c | 2 +- src/mon.c | 2 +- src/sp_lev.c | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/mondata.h b/include/mondata.h index f777a1d6ed..f565d9da11 100644 --- a/include/mondata.h +++ b/include/mondata.h @@ -260,5 +260,6 @@ #define pmname(ptr,g) ((((g) == MALE || (g) == FEMALE) && (ptr)->pmnames[g]) \ ? (ptr)->pmnames[g] : (ptr)->pmnames[NEUTRAL]) #endif +#define monsym(ptr) (def_monsyms[(int) (ptr)->mlet].sym) #endif /* MONDATA_H */ diff --git a/src/detect.c b/src/detect.c index 00960fba99..efba899fad 100644 --- a/src/detect.c +++ b/src/detect.c @@ -106,7 +106,7 @@ browse_map(unsigned ter_typ, const char *ter_explain) static void map_monst(struct monst *mtmp, boolean showtail) { - int glyph = (def_monsyms[(int) mtmp->data->mlet].sym == ' ') + int glyph = (monsym(mtmp->data) == ' ') ? detected_mon_to_glyph(mtmp, newsym_rn2) : mtmp->mtame ? pet_to_glyph(mtmp, newsym_rn2) diff --git a/src/makemon.c b/src/makemon.c index 1253a13141..26c0dadd3a 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -1640,7 +1640,7 @@ rndmonst_adj(int minadj, int maxadj) if (montooweak(mndx, minmlev) || montoostrong(mndx, maxmlev)) continue; - if (upper && !isupper((uchar) def_monsyms[(int) ptr->mlet].sym)) + if (upper && !isupper(monsym(ptr))) continue; if (elemlevel && wrong_elem_type(ptr)) continue; diff --git a/src/mon.c b/src/mon.c index 65eb2837ff..a5e626acf4 100644 --- a/src/mon.c +++ b/src/mon.c @@ -4419,7 +4419,7 @@ pick_animal(void) /* rogue level should use monsters represented by uppercase letters only, but since chameleons aren't generated there (not uppercase!) we don't perform a lot of retries */ - if (Is_rogue_level(&u.uz) && !isupper((uchar) mons[res].mlet)) + if (Is_rogue_level(&u.uz) && !isupper(monsym(&mons[res]))) res = ga.animal_list[rn2(ga.animal_list_count)]; return res; } diff --git a/src/sp_lev.c b/src/sp_lev.c index bbeb5930a5..504cadd6e5 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -3306,7 +3306,7 @@ lspo_monster(lua_State *L) tmpmons.coord = SP_COORD_PACK(mx, my); if (tmpmons.id != NON_PM && tmpmons.class == -1) - tmpmons.class = def_monsyms[(int) mons[tmpmons.id].mlet].sym; + tmpmons.class = monsym(&mons[tmpmons.id]); create_monster(&tmpmons, gc.coder->croom); From 7c20bf4afa6e4a62c5610b5bb8548f57730a8153 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 7 Dec 2023 02:52:41 -0800 Subject: [PATCH 29/78] tty: term_start_color(NO_COLOR) Make term_start_color() more versatile. If it gets passed NO_COLOR then it performs term_end_color(). Should be able to streamline some of the color handling this way although this hasn't done so. --- win/tty/termcap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/win/tty/termcap.c b/win/tty/termcap.c index c205b43b5d..6a2a0be4ef 100644 --- a/win/tty/termcap.c +++ b/win/tty/termcap.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 termcap.c $NHDT-Date: 1609459769 2021/01/01 00:09:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.41 $ */ +/* NetHack 3.7 termcap.c $NHDT-Date: 1701946349 2023/12/07 10:52:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.60 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1429,7 +1429,9 @@ term_end_color(void) void term_start_color(int color) { - if (color < CLR_MAX && hilites[color] && *hilites[color]) + if (color == NO_COLOR) + xputs(nh_HE); /* inline term_end_color() */ + else if (color < CLR_MAX && hilites[color] && *hilites[color]) xputs(hilites[color]); } From 634f492827eee6c8ebcc5161771625ccfeb093cd Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 7 Dec 2023 03:22:44 -0800 Subject: [PATCH 30/78] fix #K4058 - tty: perm_invent fixes I think this fixes all problems with the boundary boz drawn around perm_invent. Also, if you enabled perm_invent in inuse_only mode while there are already more items in use than would fix in the available number of lines, it wasn't switching to two columns until the next update_inventory(). And the new color handling wasn't incorporate into tty_refresh_inventory() so after a corner window clobbered some of perm_invent, it got redrawn but without color, again until the next update_inventory(). With any luck this fixes more bugs than it introduces.... --- win/tty/wintty.c | 165 +++++++++++++++++++++++------------------------ 1 file changed, 80 insertions(+), 85 deletions(-) diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 8e2091ea73..8276f3a099 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -180,7 +180,7 @@ static volatile int erasing_tty_screen; /* volatile: SIGWINCH */ static char obuf[BUFSIZ]; /* BUFSIZ is defined in stdio.h */ #endif -static char winpanicstr[] = "Bad window Id %d (%s)"; +static const char winpanicstr[] = "Bad window Id %d (%s)"; #define ttywindowpanic() panic(winpanicstr, window, __func__) char defmorestr[] = "--More--"; @@ -253,7 +253,9 @@ void g_pututf8(uint8 *utf8str); #endif #ifdef TTY_PERM_INVENT -static struct tty_perminvent_cell zerottycell = { 0, 0, 0, { 0 }, 0 }; +static struct tty_perminvent_cell emptyttycell = { + 0, 0, 0, { 0 }, NO_COLOR + 1 +}; static glyph_info zerogi = { 0 }; static struct to_core zero_tocore = { 0 }; enum { border_left, border_middle, border_right, border_elements }; @@ -959,7 +961,10 @@ tty_create_nhwindow(int type) RESTORE_WARNING_UNREACHABLE_CODE static void -erase_menu_or_text(winid window, struct WinDesc *cw, boolean clear) +erase_menu_or_text( + winid window, + struct WinDesc *cw, + boolean clear) { if (cw->offx == 0) { if (cw->offy) { @@ -1023,8 +1028,6 @@ free_window_info(struct WinDesc *cw, boolean free_data) } } -DISABLE_WARNING_FORMAT_NONLITERAL - void tty_clear_nhwindow(winid window) { @@ -1100,8 +1103,6 @@ tty_clear_nhwindow(winid window) /* cw->blanked = TRUE; -- this isn't used */ } -RESTORE_WARNING_FORMAT_NONLITERAL - /* toggle a specific entry */ static boolean toggle_menu_curr( @@ -1815,8 +1816,6 @@ process_text_window(winid window, struct WinDesc *cw) } } -DISABLE_WARNING_FORMAT_NONLITERAL /* RESTORE after tty_select_menu */ - /*ARGSUSED*/ void tty_display_nhwindow( @@ -2798,10 +2797,11 @@ tty_message_menu(char let, int how, const char *mesg) return ((how == PICK_ONE && morc == let) || morc == '\033') ? morc : '\0'; } -RESTORE_WARNING_FORMAT_NONLITERAL - win_request_info * -tty_ctrl_nhwindow(winid window UNUSED, int request, win_request_info *wri) +tty_ctrl_nhwindow( + winid window UNUSED, + int request, + win_request_info *wri) { #if defined(TTY_PERM_INVENT) boolean tty_ok /*, show_gold */, inuse_only; @@ -2859,7 +2859,7 @@ tty_ctrl_nhwindow(winid window UNUSED, int request, win_request_info *wri) static int ttyinv_create_window(int newid, struct WinDesc *newwin) { - int i, r, c; + int r, c; long minrow; /* long to match maxrow declaration */ unsigned n; @@ -2897,14 +2897,17 @@ ttyinv_create_window(int newid, struct WinDesc *newwin) if (!assesstty(ttyinvmode, &newwin->offx, &newwin->offy, &newwin->rows, &newwin->cols, &newwin->maxcol, &minrow, &newwin->maxrow)) { - tty_destroy_nhwindow(newid); /* sets WIN_INVEN to WIN_ERR */ + tty_destroy_nhwindow(newid); + WIN_INVEN = WIN_ERR; pline("%s.", "tty perm_invent could not be enabled"); pline("tty perm_invent needs a terminal that is at least %dx%d, " "yours is %dx%d.", (int) (minrow + 1 + ROWNO + StatusRows()), tty_perminv_mincol, ttyDisplay->rows, ttyDisplay->cols); tty_wait_synch(); +#ifndef RESIZABLE set_option_mod_status("perm_invent", set_gameview); +#endif iflags.perm_invent = FALSE; return WIN_ERR; } @@ -2922,30 +2925,20 @@ ttyinv_create_window(int newid, struct WinDesc *newwin) there are more items than the number of full lines */ if ((ttyinvmode & InvInUse) != 0) bordercol[border_middle] = bordercol[border_right]; + ttyinv_slots_used = 0; n = (unsigned) (newwin->maxrow * sizeof (struct tty_perminvent_cell *)); newwin->cells = (struct tty_perminvent_cell **) alloc(n); n = (unsigned) (newwin->maxcol * sizeof (struct tty_perminvent_cell)); - for (i = 0; i < newwin->maxrow; i++) - newwin->cells[i] = (struct tty_perminvent_cell *) alloc(n); - - n = (unsigned) sizeof (glyph_info); - for (r = 0; r < newwin->maxrow; r++) - for (c = 0; c < newwin->maxcol; c++) { - newwin->cells[r][c] = zerottycell; - if (r == 0 || r == newwin->maxrow - 1 - || c == bordercol[border_left] - || c == bordercol[border_middle] - || c == bordercol[border_right]) { - newwin->cells[r][c].content.gi = (glyph_info *) alloc(n); - *newwin->cells[r][c].content.gi = zerogi; - newwin->cells[r][c].glyph = 1; - } - } + for (r = 0; r < newwin->maxrow; r++) { + newwin->cells[r] = (struct tty_perminvent_cell *) alloc(n); + for (c = 0; c < newwin->maxcol; c++) + newwin->cells[r][c] = emptyttycell; + } newwin->active = 1; - ttyinv_slots_used = 0; tty_invent_box_glyph_init(newwin); + return newid; } @@ -2972,7 +2965,7 @@ ttyinv_remove_data(boolean destroy) contains a glyph_info structure or just a char */ if (invcell->glyph) free((genericptr_t) invcell->content.gi); - *invcell = zerottycell; /* sets glyph flag to 0 */ + *invcell = emptyttycell; /* sets glyph flag to 0 */ if (!destroy) { /* erasing */ invcell->content.ttychar = ' '; invcell->text = 1; @@ -2995,6 +2988,7 @@ ttyinv_remove_data(boolean destroy) /*WIN_INVEN = WIN_ERR;*/ /* caller's responsibility */ done_tty_perm_invent_init = FALSE; } + ttyinv_slots_used = 0; /* reset: inuse_only isn't using any slots */ } static void @@ -3028,9 +3022,10 @@ ttyinv_add_menu( slots 0 thru rows_per_side-1, so zero-based slot==rows_per_side is the entry that will be shown on first row of the second side (and one-base ttyinv_slots_used==rows_per_side means that on the - previous inventory_update(), full lines filled all the rows) */ + previous inventory_update(), full lines filled all the rows; + ttyinv_slots_used==0 means that we've just enabled perm_invent) */ if (inuse_only && slot == rows_per_side - && ttyinv_slots_used == rows_per_side) + && ttyinv_slots_used % rows_per_side == 0) ttyinv_inuse_twosides(cw, rows_per_side); text = str; /* 'text' will switch to invbuf[] below */ @@ -3056,7 +3051,7 @@ ttyinv_add_menu( */ Snprintf(invbuf, sizeof invbuf, "%c - %s", ch, text); text = invbuf; - startcolor_at = sizeof ("a - ") - 1; + startcolor_at = (int) (sizeof "a - " - sizeof ""); /* 4 */ row = (slot % rows_per_side) + 1; /* +1: top border */ /* side: left side panel or right side panel, not a window column */ side = slot / rows_per_side; @@ -3209,7 +3204,7 @@ ttyinv_end_menu(int window, struct WinDesc *cw) } } -/* display persistent inventory */ +/* display persistent inventory from data collected by add_menu() */ static void ttyinv_render(winid window, struct WinDesc *cw) { @@ -3228,7 +3223,7 @@ ttyinv_render(winid window, struct WinDesc *cw) slot_limit = SIZE(slot_tracker); if (inuse_only) { slot_limit = rows_per_side; /* assume one side */ - if (ttyinv_slots_used >= rows_per_side) + if (ttyinv_slots_used == 0 || ttyinv_slots_used >= rows_per_side) slot_limit *= 2; /* second side is populated */ } else if (!show_gold) { slot_limit -= 2; /* there are two extra slots for gold and overflow; @@ -3287,12 +3282,13 @@ ttyinv_render(winid window, struct WinDesc *cw) for (col = 0; col < cw->maxcol; ++col) { cell = &cw->cells[row][col]; if (cell->refresh || force_redraw) { - if (cell->color - && (current_row_color != cell->color - 1)) { + if (cell->color && (current_row_color != cell->color - 1)) { current_row_color = cell->color - 1; +#if 0 if (current_row_color == NO_COLOR) term_end_color(); else +#endif term_start_color(current_row_color); } if (cell->glyph) { @@ -3350,7 +3346,7 @@ ttyinv_populate_slot( each other in a union, so clear gi before assigning ttychar */ if (cell->glyph) { free((genericptr_t) cell->content.gi); - *cell = zerottycell; /* clears cell->glyph and cell->content */ + *cell = emptyttycell; /* clears cell->glyph and cell->content */ } if ((c = *text) != '\0') @@ -3374,8 +3370,6 @@ ttyinv_populate_slot( } } -DISABLE_WARNING_FORMAT_NONLITERAL - void tty_refresh_inventory(int start, int stop, int y) { @@ -3383,8 +3377,10 @@ tty_refresh_inventory(int start, int stop, int y) struct WinDesc *cw = 0; winid window = WIN_INVEN; struct tty_perminvent_cell *cell; + boolean printing_glyphs; - if (window == WIN_ERR || !iflags.perm_invent || y < 0) + if (window == WIN_ERR || !iflags.perm_invent + || gp.perm_invent_toggling_direction == toggling_off) return; if ((cw = wins[window]) == (struct WinDesc *) 0) @@ -3393,17 +3389,21 @@ tty_refresh_inventory(int start, int stop, int y) if (col_limit > cw->maxcol) col_limit = cw->maxcol; - if (row >= cw->maxrow) - return; /* out of our range. Huge menus can do this */ - /* we've been asked to redisplay a portion of the screen, one row */ + printing_glyphs = FALSE; for (col = start - 1; col < col_limit; ++col) { cell = &cw->cells[row][col]; + if (cell->color != ttyDisplay->color + 1) { + term_start_color(cell->color - 1); + ttyDisplay->color = cell->color - 1; + } if (cell->glyph) { tty_print_glyph(window, col + 1, row, cell->content.gi, &nul_glyphinfo); - end_glyphout(); + printing_glyphs = TRUE; } else { + if (printing_glyphs) + end_glyphout(); if (col != cw->curx || row != cw->cury) tty_curs(window, col + 1, row); (void) putchar(cell->content.ttychar); @@ -3412,16 +3412,26 @@ tty_refresh_inventory(int start, int stop, int y) } cell->refresh = 0; } + if (printing_glyphs) + end_glyphout(); + if (ttyDisplay->color != NO_COLOR) { + term_end_color(); + ttyDisplay->color = NO_COLOR; + } } -RESTORE_WARNING_FORMAT_NONLITERAL - static void tty_invent_box_glyph_init(struct WinDesc *cw) { int row, col, glyph, bordercolor = NO_COLOR; uchar sym; struct tty_perminvent_cell *cell; + boolean inuse_only = (ttyinvmode & InvInUse) != 0, + show_gold = (ttyinvmode & InvShowGold) != 0 && !inuse_only; + int rows_per_side = (inuse_only ? (cw->maxrow - 2) + : !show_gold ? 26 + : 27), + bottomrow = rows_per_side + 1; if (cw == 0 || !cw->active) return; @@ -3434,50 +3444,35 @@ tty_invent_box_glyph_init(struct WinDesc *cw) [border_middle] because they could be the same column (for InvInUse) and if so we want corner rather than tee there */ if (row == 0) { - if (col == bordercol[border_left]) - sym = S_tlcorn; - else if (col == bordercol[border_right]) - sym = S_trcorn; - else if (col == bordercol[border_middle]) - sym = S_tdwall; - else /*if ((col > bordercol[border_left] - && col < bordercol[border_middle]) - || (col > bordercol[border_middle] - && col < bordercol[border_right]))*/ - sym = S_hwall; - } else if (row == (cw->maxrow - 1)) { - if (col == bordercol[border_left]) - sym = S_blcorn; - else if (col == bordercol[border_right]) - sym = S_brcorn; - else if (col == bordercol[border_middle]) - sym = S_tuwall; - else /*if ((col > bordercol[border_left] - && col < bordercol[border_middle]) - || (col > bordercol[border_middle] - && col < bordercol[border_right]))*/ - sym = S_hwall; - } else { + sym = (col == bordercol[border_left]) ? S_tlcorn + : (col == bordercol[border_right]) ? S_trcorn + : (col == bordercol[border_middle]) ? S_tdwall + : S_hwall; + } else if (row < bottomrow) { if (col == bordercol[border_left] || col == bordercol[border_middle] || col == bordercol[border_right]) sym = S_vwall; + /* else sym keeps placeholder value */ + } else if (row == bottomrow) { + sym = (col == bordercol[border_left]) ? S_blcorn + : (col == bordercol[border_right]) ? S_brcorn + : (col == bordercol[border_middle]) ? S_tuwall + : S_hwall; } if (sym == S_crwall) { /* not a boundary (but might have been) */ if (cell->glyph) { /* presumably is no longer wanted middle vertical line */ free((genericptr_t) cell->content.gi); - *cell = zerottycell; /* clears cell->glyph */ + *cell = emptyttycell; /* clears cell->glyph */ cell->content.ttychar = ' '; cell->text = 1; cell->refresh = 1; } continue; } - /* a boundary, but might not have been if this is the middle - and we were showing full lines and are now going to show two - sides; allocate glyph_info for middle vertical line */ + /* a boundary; if it doesn't hold a glyph yet, allocate one */ if (!cell->glyph) { cell->content.gi = (glyph_info *) alloc(sizeof (glyph_info)); *(cell->content.gi) = zerogi; @@ -3489,7 +3484,7 @@ tty_invent_box_glyph_init(struct WinDesc *cw) map_glyphinfo(0, 0, glyph, 0, cell->content.gi); cell->glyph = 1; /* (redundant) */ cell->text = 0; - /* originaly this conditionally set refresh depending upon + /* originally this conditionally set refresh depending upon whether the glyph was already shown, but that optimization is for something that rarely happens (boundary lines aren't redrawn very often, and most of the time when they are it's @@ -3512,15 +3507,14 @@ assesstty( { boolean inuse_only = (invmode & InvInUse) != 0, show_gold = (invmode & InvShowGold) != 0 && !inuse_only; + int perminv_minrow = tty_perminv_minrow + (show_gold ? 1 : 0); *offx = 0; /* topline + map rows + status lines */ *offy = 1 + ROWNO + StatusRows(); /* 1 + 21 + (2 or 3) */ *rows = (ttyDisplay->rows - *offy); *cols = ttyDisplay->cols; - *minrow = tty_perminv_minrow; - if (show_gold) - *minrow += 1; + *minrow = perminv_minrow; #define SMALL_INUSE_WINDOW #ifdef SMALL_INUSE_WINDOW #undef SMALL_INUSE_WINDOW @@ -3535,7 +3529,7 @@ assesstty( if (inuse_only) *minrow = 1 + 15 + 1; /* top border + 15 lines + bottom border */ #endif - *maxrow = *rows; + *maxrow = min(*rows, perminv_minrow); *maxcol = *cols; return !(*rows < *minrow || *cols < tty_perminv_mincol); } @@ -3599,7 +3593,7 @@ docorner( #ifdef TTY_PERM_INVENT struct WinDesc *icw = 0; - if (WIN_INVEN != WIN_ERR) + if (WIN_INVEN != WIN_ERR && iflags.perm_invent) icw = wins[WIN_INVEN]; #endif @@ -3628,8 +3622,9 @@ docorner( if (!ystart_between_menu_pages) cl_end(); /* clear to end of line */ #ifdef TTY_PERM_INVENT - /* the whole thing is beyond the board */ - if (icw) + /* the whole thing is beyond the board but not necessarily all the + way to the bottom of the screen */ + if (icw && y >= (int) icw->offy && y < icw->offy + icw->maxrow) tty_refresh_inventory(xmin - (int) icw->offx, icw->maxcol, y - (int) icw->offy); #endif From 6e2fa243447228ca6d989f2255131193843c5d33 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Thu, 7 Dec 2023 13:50:48 +0200 Subject: [PATCH 31/78] Change hezrou and vrock color to green There are many red major demons, and hezrous and vrocks now emit poison gas, so change the symbol color to green. Also adjust vrock tiles to have green. The hezrou tiles already are green. --- doc/fixes3-7-0.txt | 1 + include/monsters.h | 4 ++-- win/share/monsters.txt | 48 +++++++++++++++++++++--------------------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 91f0504328..c32cb82caf 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1317,6 +1317,7 @@ boomerang travels in a clockwise arc when thrown by a left-handed hero and in spellbooks weight 50 units but Book of the Dead only 20, and novels only 1; the Book of the Dead has been changed to 50 and novels to 10 save and restore hero tracks, increase track length +change vrock and hezrou from red to green, adjust vrock tile to have green Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/include/monsters.h b/include/monsters.h index 1adfa7749c..d2138d26e8 100644 --- a/include/monsters.h +++ b/include/monsters.h @@ -2519,14 +2519,14 @@ ATTK(AT_BITE, AD_PHYS, 1, 6), NO_ATTK), SIZ(WT_HUMAN, 400, MS_SILENT, MZ_LARGE), MR_FIRE | MR_POISON, 0, M1_POIS, M2_DEMON | M2_STALK | M2_HOSTILE | M2_NASTY, - M3_INFRAVISIBLE | M3_INFRAVISION, 11, CLR_RED, VROCK), + M3_INFRAVISIBLE | M3_INFRAVISION, 11, CLR_GREEN, VROCK), MON("hezrou", S_DEMON, LVL(9, 6, -2, 55, -10), (G_HELL | G_NOCORPSE | G_SGROUP | 2), A(ATTK(AT_CLAW, AD_PHYS, 1, 3), ATTK(AT_CLAW, AD_PHYS, 1, 3), ATTK(AT_BITE, AD_PHYS, 4, 4), NO_ATTK, NO_ATTK, NO_ATTK), SIZ(WT_HUMAN, 400, MS_SILENT, MZ_LARGE), MR_FIRE | MR_POISON, 0, M1_HUMANOID | M1_POIS, M2_DEMON | M2_STALK | M2_HOSTILE | M2_NASTY, - M3_INFRAVISIBLE | M3_INFRAVISION, 12, CLR_RED, HEZROU), + M3_INFRAVISIBLE | M3_INFRAVISION, 12, CLR_GREEN, HEZROU), MON("bone devil", S_DEMON, LVL(9, 15, -1, 40, -9), (G_HELL | G_NOCORPSE | G_SGROUP | 2), A(ATTK(AT_WEAP, AD_PHYS, 3, 4), ATTK(AT_STNG, AD_DRST, 2, 4), NO_ATTK, diff --git a/win/share/monsters.txt b/win/share/monsters.txt index 7825cd8112..53fa551af2 100644 --- a/win/share/monsters.txt +++ b/win/share/monsters.txt @@ -11613,18 +11613,18 @@ Z = (195, 195, 195) ................ ......OPP.O..... ......PPPP...... - .....CPPDP...... - ....CCCPPP...... - ....CCPPPP...... - ....C..PPA...... - .....DDAADD.AAA. - ....DDDDDDDDAAA. - ....DADDDDADAAA. - ....DADDDDADAAA. - ....DADDDDADAAA. - ......DAADAAAA.. - ......DAADAA.A.. - .....DDA.DDA.... + .....KPPDP...... + ....KJJPPP...... + ....KJPPPP...... + ....K..PPA...... + .....GGAAGG.AAA. + ....FDFDFDFDAAA. + ..G.GADGDFAGAGA. + ....GAFGFGAGAAA. + ..G.DADFDGAFAAA. + ......GAADAAAG.. + .F.G..GAAFAA.A.. + .....DFA.GGA..F. ................ } # tile 605 (vrock,female) @@ -11632,18 +11632,18 @@ Z = (195, 195, 195) ................ ......OPP.O..... ......PPPP...... - .....CPPDP...... - ....CCCPPP...... - ....CCPPPP...... - ....C..PPA...... - .....DDAADD.AAA. - ....DDDDDDDDAAA. - ....DADDDDADAAA. - ....DADDDDADAAA. - ....DADDDDADAAA. - ......DAADAAAA.. - ......DAADAA.A.. - .....DDA.DDA.... + .....LPPGP...... + ....LCCPPP...... + ....LCPPPP...... + ....L..PPA...... + .....GGAAGG.AAA. + ....FDFDFDFDAAA. + ..G.GADGDFAGAGA. + ....GAFGFGAGAAA. + ..G.DADFDGAFAAA. + ......GAADAAAG.. + .F.G..GAAFAA.A.. + .....DFA.GGA..F. ................ } # tile 606 (hezrou,male) From 5c5a5cf2ccccaeafc2dcac14016cb5c79a1e816f Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 7 Dec 2023 04:05:26 -0800 Subject: [PATCH 32/78] minor memory leak in mdlib opttext[] opttext[] was given 120 elements but the MAXOPT macro used to limit populating it was only 40. There happen to be exactly 40 lines of runtime info--at least for my config--and the last slot was going to waste, so the final dupstr("") at the end of build_options() wasn't being tracked and freed. It's interesting the whatever other memory checker is being used failed to find something caught by old heaputil. Maybe the configs running whatever it is are generating smaller options text? --- src/mdlib.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/mdlib.c b/src/mdlib.c index e90b76b1cf..59ca587ae2 100644 --- a/src/mdlib.c +++ b/src/mdlib.c @@ -93,8 +93,8 @@ static void opt_out_words(char *, int *); static void build_savebones_compat_string(void); static int idxopttext, done_runtime_opt_init_once = 0; -#define MAXOPT 40 -static char *opttext[120] = { 0 }; +#define MAXOPT 60 /* 3.7: currently 40 lines get inserted into opttext[] */ +static char *opttext[MAXOPT] = { 0 }; char optbuf[COLBUFSZ]; static struct version_info version; static const char opt_indent[] = " "; @@ -736,7 +736,7 @@ opt_out_words( *word = '\0'; if (*length_p + (int) strlen(str) > COLNO - 5) { opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < (MAXOPT - 1)) + if (idxopttext < MAXOPT) idxopttext++; Sprintf(optbuf, "%s", opt_indent), *length_p = (int) strlen(opt_indent); @@ -763,7 +763,7 @@ build_options(void) #endif build_savebones_compat_string(); opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < (MAXOPT - 1)) + if (idxopttext < MAXOPT) idxopttext++; #if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) #if (NH_DEVEL_STATUS == NH_STATUS_BETA) @@ -777,11 +777,11 @@ build_options(void) Sprintf(optbuf, "%sNetHack version %d.%d.%d%s\n", opt_indent, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, STATUS_ARG); opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < (MAXOPT - 1)) + if (idxopttext < MAXOPT) idxopttext++; Sprintf(optbuf, "Options compiled into this edition:"); opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < (MAXOPT - 1)) + if (idxopttext < MAXOPT) idxopttext++; optbuf[0] = '\0'; length = COLNO + 1; /* force 1st item onto new line */ @@ -799,17 +799,17 @@ build_options(void) opt_out_words(buf, &length); } opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < (MAXOPT - 1)) + if (idxopttext < MAXOPT) idxopttext++; optbuf[0] = '\0'; winsyscnt = count_and_validate_winopts(); opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < (MAXOPT - 1)) + if (idxopttext < MAXOPT) idxopttext++; Sprintf(optbuf, "Supported windowing system%s:", (winsyscnt > 1) ? "s" : ""); opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < (MAXOPT - 1)) + if (idxopttext < MAXOPT) idxopttext++; optbuf[0] = '\0'; length = COLNO + 1; /* force 1st item onto new line */ @@ -843,17 +843,17 @@ build_options(void) #if !defined(MAKEDEFS_C) cnt = 0; opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < (MAXOPT - 1)) + if (idxopttext < MAXOPT) idxopttext++; optbuf[0] = '\0'; soundlibcnt = count_and_validate_soundlibopts(); opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < (MAXOPT - 1)) + if (idxopttext < MAXOPT) idxopttext++; Sprintf(optbuf, "Supported soundlib%s:", (soundlibcnt > 1) ? "s" : ""); opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < (MAXOPT - 1)) + if (idxopttext < MAXOPT) idxopttext++; optbuf[0] = '\0'; length = COLNO + 1; /* force 1st item onto new line */ @@ -893,7 +893,7 @@ build_options(void) #endif /* !MAKEDEFS_C */ opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < (MAXOPT - 1)) + if (idxopttext < MAXOPT) idxopttext++; optbuf[0] = '\0'; @@ -921,7 +921,7 @@ build_options(void) ":TAG:" substitutions are deferred to caller */ for (i = 0; lua_info[i]; ++i) { opttext[idxopttext] = dupstr(lua_info[i]); - if (idxopttext < (MAXOPT - 1)) + if (idxopttext < MAXOPT) idxopttext++; } } @@ -929,8 +929,9 @@ build_options(void) /* end with a blank line */ opttext[idxopttext] = dupstr(""); - if (idxopttext < (MAXOPT - 1)) + if (idxopttext < MAXOPT) idxopttext++; + opttext[MAXOPT - 1] = NULL; return; } @@ -974,7 +975,7 @@ do_runtime_info(int *rtcontext) if (!done_runtime_opt_init_once) runtime_info_init(); if (idxopttext && rtcontext) - if (*rtcontext >= 0 && *rtcontext < (MAXOPT - 1)) { + if (*rtcontext >= 0 && *rtcontext < MAXOPT) { retval = opttext[*rtcontext]; *rtcontext += 1; } From df66ee1ad92972d73da87e1f9e69d4fed9689fd5 Mon Sep 17 00:00:00 2001 From: Ray Chason Date: Thu, 7 Dec 2023 07:07:21 -0500 Subject: [PATCH 33/78] Avoid calling Curses after it is shut down --- win/curses/cursmain.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index 088d9614a1..2d4f278bcf 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -841,9 +841,11 @@ wait_synch() -- Wait until all pending output is complete (*flush*() for void curses_wait_synch(void) { - if (curses_got_output()) - (void) curses_more(); - curses_mark_synch(); + if (iflags.window_inited) { + if (curses_got_output()) + (void) curses_more(); + curses_mark_synch(); + } /* [do we need 'if (counting) curses_count_window((char *)0);' here?] */ } From e639c4bdaab6aad593fcde4c1494c1e132045a65 Mon Sep 17 00:00:00 2001 From: nhmall Date: Thu, 7 Dec 2023 09:34:05 -0500 Subject: [PATCH 34/78] A recent patch 634f4928 introduced new tty behavior, where calling term_start_color(NO_COLOR) would have the same effect as calling term_end_color(). That change only included a change for termcap, but not any of the NO_TERMS configurations. (NO_TERMS is defined for an implementation where termcap is not used). This attempts to make sys/msdos/video.c and sys/windows/consoletty.c honor the change. The msdos change has not yet been tested. No attempt was made to alter the term_start_color() implementations within the outdated tree. --- sys/msdos/video.c | 5 ++++- sys/windows/consoletty.c | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/msdos/video.c b/sys/msdos/video.c index 02a461f8e1..03ca3f18f7 100644 --- a/sys/msdos/video.c +++ b/sys/msdos/video.c @@ -354,7 +354,10 @@ term_start_color(int color) if (monoflag) { g_attribute = attrib_text_normal; } else { - if (color >= 0 && color < CLR_MAX) { + if (color == NO_COLOR) { /* 3.7 behave like term_end_color() */ + g_attribute = iflags.grmode ? attrib_gr_normal : attrib_text_normal; + curframecolor = NO_COLOR; + } else if (color >= 0 && color < CLR_MAX) { if (iflags.grmode) g_attribute = color; else diff --git a/sys/windows/consoletty.c b/sys/windows/consoletty.c index 5c31ad534a..fdc42f07af 100644 --- a/sys/windows/consoletty.c +++ b/sys/windows/consoletty.c @@ -1747,7 +1747,9 @@ term_start_raw_bold(void) void term_start_color(int color) { - if (color >= 0 && color < CLR_MAX) { + if (color == NO_COLOR) { + term_end_color(); + } else if (color >= 0 && color < CLR_MAX) { console.current_nhcolor = color; } else { console.current_nhcolor = NO_COLOR; @@ -1757,7 +1759,7 @@ term_start_color(int color) void term_start_bgcolor(int color) { - if (color >= 0 && color < CLR_MAX) { + if (color != NO_COLOR && (color >= 0 && color < CLR_MAX)) { console.current_nhbkcolor = color; } else { console.current_nhbkcolor = NO_COLOR; From 12ca2be5b4ddfbf7fea846bcc807ceb53b1b05b1 Mon Sep 17 00:00:00 2001 From: nhmall Date: Thu, 7 Dec 2023 09:55:37 -0500 Subject: [PATCH 35/78] more fixes via monsym() --- src/mon.c | 4 ++-- src/wizard.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mon.c b/src/mon.c index a5e626acf4..5d736be1e0 100644 --- a/src/mon.c +++ b/src/mon.c @@ -4760,7 +4760,7 @@ select_newcham_form(struct monst* mon) } while (--tryct > 0 && !validspecmon(mon, mndx) /* try harder to select uppercase monster on rogue level */ && (tryct > 40 && Is_rogue_level(&u.uz) - && !isupper((uchar) mons[mndx].mlet))); + && !isupper(monsym(&mons[mndx])))); } return mndx; } @@ -4865,7 +4865,7 @@ newcham( /* for the first several tries we require upper-case on the rogue level (after that, we take whatever we get) */ if (tryct > 15 && Is_rogue_level(&u.uz) - && mdat && !isupper((uchar) mdat->mlet)) + && mdat && !isupper(monsym(mdat))) mdat = 0; if (mdat) break; diff --git a/src/wizard.c b/src/wizard.c index 16473254e7..26d27a782a 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -522,7 +522,7 @@ pick_nasty( * but we don't try very hard. */ if (Is_rogue_level(&u.uz) - && !('A' <= mons[res].mlet && mons[res].mlet <= 'Z')) + && !('A' <= monsym(&mons[res]) && monsym(&mons[res]) <= 'Z')) res = ROLL_FROM(nasties); /* if genocided or too difficult or out of place, try a substitute From f31a110d756aa0e80a30a3249322bfc744b1021d Mon Sep 17 00:00:00 2001 From: nhmall Date: Thu, 7 Dec 2023 09:59:34 -0500 Subject: [PATCH 36/78] yet more monsym() --- src/utf8map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utf8map.c b/src/utf8map.c index 136ba4c788..06b337522a 100644 --- a/src/utf8map.c +++ b/src/utf8map.c @@ -270,7 +270,7 @@ glyph_find_core(const char *id, struct find_struct *findwhat) break; case find_pm: if (glyph_is_monster(glyph) - && mons[glyph_to_mon(glyph)].mlet == findwhat->val) + && monsym(&mons[glyph_to_mon(glyph)]) == findwhat->val) do_callback = TRUE; break; case find_oc: From 3b2d3eabedb983a149f7ab9715c2a8c5499eadaf Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Thu, 7 Dec 2023 17:40:15 +0200 Subject: [PATCH 37/78] Change wolf, werewolf, and warg colors There were 6 brown 'd' monsters; move wolf and werewolf to grey, and warg to black, as those colors had no canines. The wolf tiles are already greyish; changed warg tile to be slightly darker. --- doc/fixes3-7-0.txt | 1 + include/monsters.h | 6 ++--- win/share/monsters.txt | 56 +++++++++++++++++++++--------------------- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index c32cb82caf..3496a777b4 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1318,6 +1318,7 @@ spellbooks weight 50 units but Book of the Dead only 20, and novels only 1; the Book of the Dead has been changed to 50 and novels to 10 save and restore hero tracks, increase track length change vrock and hezrou from red to green, adjust vrock tile to have green +change wolf and werewolf to grey, warg to black Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/include/monsters.h b/include/monsters.h index d2138d26e8..18dcb3a035 100644 --- a/include/monsters.h +++ b/include/monsters.h @@ -235,13 +235,13 @@ NO_ATTK), SIZ(500, 250, MS_BARK, MZ_MEDIUM), 0, 0, M1_ANIMAL | M1_NOHANDS | M1_CARNIVORE, M2_HOSTILE, M3_INFRAVISIBLE, - 6, CLR_BROWN, WOLF), + 6, CLR_GRAY, WOLF), MON("werewolf", S_DOG, LVL(5, 12, 4, 20, -7), (G_NOGEN | G_NOCORPSE), A(ATTK(AT_BITE, AD_WERE, 2, 6), NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK), SIZ(500, 250, MS_BARK, MZ_MEDIUM), MR_POISON, 0, M1_NOHANDS | M1_POIS | M1_REGEN | M1_CARNIVORE, - M2_NOPOLY | M2_WERE | M2_HOSTILE, M3_INFRAVISIBLE, 7, CLR_BROWN, + M2_NOPOLY | M2_WERE | M2_HOSTILE, M3_INFRAVISIBLE, 7, CLR_GRAY, WEREWOLF), MON("winter wolf cub", S_DOG, LVL(5, 12, 4, 0, -5), (G_NOHELL | G_GENO | G_SGROUP | 2), @@ -255,7 +255,7 @@ NO_ATTK), SIZ(850, 350, MS_BARK, MZ_MEDIUM), 0, 0, M1_ANIMAL | M1_NOHANDS | M1_CARNIVORE, M2_HOSTILE, M3_INFRAVISIBLE, - 8, CLR_BROWN, WARG), + 8, CLR_BLACK, WARG), MON("winter wolf", S_DOG, LVL(7, 12, 4, 20, 0), (G_NOHELL | G_GENO | 1), A(ATTK(AT_BITE, AD_PHYS, 2, 6), ATTK(AT_BREA, AD_COLD, 2, 6), NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK), diff --git a/win/share/monsters.txt b/win/share/monsters.txt index 53fa551af2..0d3341f828 100644 --- a/win/share/monsters.txt +++ b/win/share/monsters.txt @@ -923,39 +923,39 @@ Z = (195, 195, 195) # tile 46 (warg,male) { ................ - ...P..P....PP... - ...P.PP......P.. - ..PPPP.......P.A - ..N.NPP......P.A - .P..PPPPP....P.A - PPPPDPPPPPPPPPAA - DPPNDPPPPPPPPPAA - ..DDDPPPPPPPPPAA - PNDNP.PPPPPPPPAA - .PPPPAPPPPAPP.A. - ...PAAPPAAAAPPAA - ...PAAP.AAAAP.A. - .PPPAAPAAAAAPAA. - ....PPPAA.PPPA.. + ...P..0....P0... + ...0.0P......0.. + ..0P0P.......P.A + ..N.N0P......0.A + .P..0P0P0....P.A + P0P0D0P0P0P0P0AA + DP0NDP0P0P0P0PAA + ..DDD0P0P0P0P0AA + 0NDN0.0P0P0P0PAA + .0P0PAP0P0A0P.A. + ...PAA0PAAAA0PAA + ...0AAP.AAAAP.A. + .P0PAA0AAAAA0AA. + ....P0PAA.P0PA.. ................ } # tile 47 (warg,female) { ................ - ...P..P.....P... - ...P.PP......P.. - ..PPPP.......P.A - ..N.NPP......P.A - .P..PPPPP....P.A - PPPPDPPPPPPPPPAA - DPPNDPPPPPPPPPAA - ..DDDPPPPPPPPPAA - PNDNP.PPPPPPPPAA - .PPPPAPPPPAPP.A. - ...PAAPPAAAAPPAA - ...PAAP.AAAAP.A. - .PPPAAPAAAAAPAA. - ....PPPAA.PPPA.. + ...P..0.....P... + ...0.0P......0.. + ..0P0P.......P.A + ..N.N0P......0.A + .P..0P0P0....P.A + P0P0D0P0P0P0P0AA + DP0NDP0P0P0P0PAA + ..DDD0P0P0P0P0AA + 0NDN0.0P0P0P0PAA + .0P0PAP0P0A0P.A. + ...PAA0PAAAA0PAA + ...0AAP.AAAAP.A. + .P0PAA0AAAAA0AA. + ....P0PAA.P0PA.. ................ } # tile 48 (winter wolf,male) From b1f67a9842503a352adc66bb0a5cbabda693beac Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 7 Dec 2023 11:48:05 -0800 Subject: [PATCH 38/78] lua memory usage Silence a bunch of complaints from heaputil about freeing Null pointers. The C standard allows that but it makes the data collected about mallocs and frees not match up when nethack has MONITOR_HEAP enabled. --- src/nhlua.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/nhlua.c b/src/nhlua.c index dad9f55b6d..383125a4af 100644 --- a/src/nhlua.c +++ b/src/nhlua.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 nhlua.c $NHDT-Date: 1695159626 2023/09/19 21:40:26 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.115 $ */ +/* NetHack 3.7 nhlua.c $NHDT-Date: 1701978168 2023/12/07 19:42:48 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.120 $ */ /* Copyright (c) 2018 by Pasi Kallinen */ /* NetHack may be freely redistributed. See license for details. */ @@ -2673,7 +2673,8 @@ nhl_alloc(void *ud, void *ptr, size_t osize, size_t nsize) } if (nsize == 0) { - free(ptr); + if (ptr != NULL) + free(ptr); return NULL; } From 5186af22c7c77812dc33ebbdde8df005cd9c66a1 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 7 Dec 2023 18:31:56 -0800 Subject: [PATCH 39/78] another MONITOR_HEAP bit Another instance of freeing a null pointer. --- src/mklev.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mklev.c b/src/mklev.c index 4c2746291f..fbc27d13c8 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 mklev.c $NHDT-Date: 1691877661 2023/08/12 22:01:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.155 $ */ +/* NetHack 3.7 mklev.c $NHDT-Date: 1702002703 2023/12/08 02:31:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.162 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Alex Smith, 2017. */ /* NetHack may be freely redistributed. See license for details. */ @@ -814,9 +814,11 @@ clear_level_structures(void) gn.nsubroom = 0; gs.subrooms[0].hx = -1; gd.doorindex = 0; - gd.doors_alloc = 0; - free(gd.doors); - gd.doors = (coord *) 0; + if (gd.doors_alloc) { + free((genericptr_t) gd.doors); + gd.doors = (coord *) 0; + gd.doors_alloc = 0; + } init_rect(); init_vault(); stairway_free_all(); From 4140a0023c17e06da7886a211040d7381fdb7452 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 7 Dec 2023 18:36:14 -0800 Subject: [PATCH 40/78] fix #4059 - TTY_PERM_INVENT not freeing memory As part of the tty resize handling revision, code dealing with the perm_invent window was moved out of tty_destroy_nhwindow() was moved into a separate routine. The new routine would have been called for a window of NHW_PERMINVENT, but WIN_INVENT doesn't have that type, just ordinary NHW_MENU, so the cleanup wasn't happening, resulting in a memory leak. --- src/end.c | 4 ++-- win/tty/wintty.c | 28 +++++++++++++++------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/end.c b/src/end.c index 416e77d479..4ac2124f15 100644 --- a/src/end.c +++ b/src/end.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 end.c $NHDT-Date: 1700012887 2023/11/15 01:48:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.282 $ */ +/* NetHack 3.7 end.c $NHDT-Date: 1702002966 2023/12/08 02:36:06 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.284 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1344,7 +1344,7 @@ done_object_cleanup(void) a normal popup one; avoids "Bad fruit #n" when saving bones */ if (iflags.perm_invent) { iflags.perm_invent = FALSE; - update_inventory(); /* make interface notice the change */ + perm_invent_toggled(TRUE); /* make interface notice the change */ } return; } diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 8276f3a099..fb6942ae8d 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 wintty.c $NHDT-Date: 1701723543 2023/12/04 20:59:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.369 $ */ +/* NetHack 3.7 wintty.c $NHDT-Date: 1702002970 2023/12/08 02:36:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.376 $ */ /* Copyright (c) David Cohrs, 1991 */ /* NetHack may be freely redistributed. See license for details. */ @@ -272,7 +272,7 @@ static long last_glyph_reset_when; #endif static boolean calling_from_update_inventory = FALSE; static int ttyinv_create_window(int, struct WinDesc *); -static void ttyinv_remove_data(boolean); +static void ttyinv_remove_data(struct WinDesc *, boolean); static void ttyinv_add_menu(winid, struct WinDesc *, char ch, int attr, int clr, const char *str); static int selector_to_slot(char ch, const int invflags, boolean *ignore); @@ -1087,17 +1087,20 @@ tty_clear_nhwindow(winid window) break; case NHW_MENU: case NHW_TEXT: +#ifdef TTY_PERM_INVENT + case NHW_PERMINVENT: +#endif if (!erasing_tty_screen) { if (cw->active) erase_menu_or_text(window, cw, TRUE); - free_window_info(cw, FALSE); - } - break; #ifdef TTY_PERM_INVENT - case NHW_PERMINVENT: - ttyinv_remove_data(FALSE); - break; + if (window == WIN_INVEN) + ttyinv_remove_data(cw, FALSE); + else #endif + free_window_info(cw, FALSE); + } + break; } cw->curx = cw->cury = 0; /* cw->blanked = TRUE; -- this isn't used */ @@ -1942,6 +1945,7 @@ tty_dismiss_nhwindow(winid window) break; case NHW_MENU: case NHW_TEXT: + case NHW_PERMINVENT: if (cw->active) { /* skip erasure if window_inited has been reset to 0 during final run-down in case this is the end-of-game window; @@ -1985,8 +1989,8 @@ tty_destroy_nhwindow(winid window) if (cw->type == NHW_MAP) term_clear_screen(); #ifdef TTY_PERM_INVENT - if (cw->type == NHW_PERMINVENT) - ttyinv_remove_data(TRUE); + if (cw->type == NHW_PERMINVENT || window == WIN_INVEN) + ttyinv_remove_data(cw, TRUE); #endif free_window_info(cw, TRUE); free((genericptr_t) cw); @@ -2944,10 +2948,8 @@ ttyinv_create_window(int newid, struct WinDesc *newwin) /* discard perminvent window or erase it and set remembered data to spaces */ static void -ttyinv_remove_data(boolean destroy) +ttyinv_remove_data(struct WinDesc *cw, boolean destroy) { - struct WinDesc *cw = (WIN_INVEN != WIN_ERR) ? wins[WIN_INVEN] : NULL; - if (!cw) { impossible("Removing ttyinv data for nonexistent perm invent window?"); return; From d2ae6fd5d2f487299e8760fc557d80f1e0706625 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Fri, 8 Dec 2023 08:32:07 +0200 Subject: [PATCH 41/78] Split out wizmode monpolycontrol part --- src/mon.c | 157 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 82 insertions(+), 75 deletions(-) diff --git a/src/mon.c b/src/mon.c index 5d736be1e0..ce6a6dcaff 100644 --- a/src/mon.c +++ b/src/mon.c @@ -30,6 +30,7 @@ static int pick_animal(void); static int pickvampshape(struct monst *); static boolean isspecmon(struct monst *); static boolean validspecmon(struct monst *, int); +static int wiz_force_cham_form(struct monst *); static struct permonst *accept_newcham_form(struct monst *, int); static void kill_eggs(struct obj *); static void pacify_guard(struct monst *); @@ -4623,6 +4624,85 @@ validvamp(struct monst* mon, int* mndx_p, int monclass) return (boolean) (*mndx_p != NON_PM); } +static int +wiz_force_cham_form(struct monst *mon) +{ + char pprompt[BUFSZ], parttwo[QBUFSZ], buf[BUFSZ], prevbuf[BUFSZ]; + int monclass, len, tryct, mndx = NON_PM; + + /* construct prompt in pieces */ + Sprintf(pprompt, "Change %s", noit_mon_nam(mon)); + Sprintf(parttwo, " @ %s into what?", + coord_desc((int) mon->mx, (int) mon->my, buf, + (iflags.getpos_coords != GPCOORDS_NONE) + ? iflags.getpos_coords : GPCOORDS_MAP)); + /* combine the two parts, not exceeding QBUFSZ-1 in overall length; + if combined length is too long it has to be due to monster's + name so we'll chop enough of that off to fit the second part */ + if ((len = (int) strlen(pprompt) + (int) strlen(parttwo)) >= QBUFSZ) + /* strlen(parttwo) is less than QBUFSZ/2 so strlen(pprompt) is + more than QBUFSZ/2 and excess amount being truncated can't + exceed pprompt's length and back up to before &pprompt[0]) */ + *(eos(pprompt) - (len - (QBUFSZ - 1))) = '\0'; + Strcat(pprompt, parttwo); + + buf[0] = prevbuf[0] = '\0'; /* clear buffer for EDIT_GETLIN */ +#define TRYLIMIT 5 + tryct = TRYLIMIT; + do { + if (tryct == TRYLIMIT - 1) { /* first retry */ + /* change "into what?" to "into what kind of monster?" */ + if (strlen(pprompt) + sizeof " kind of monster" - 1 < QBUFSZ) + Strcpy(eos(pprompt) - 1, " kind of monster?"); + } +#undef TRYLIMIT + monclass = 0; + getlin(pprompt, buf); + mungspaces(buf); + /* for ESC, take form selected above (might be NON_PM) */ + if (*buf == '\033') + break; + /* for "*", use NON_PM to pick an arbitrary shape below */ + if (!strcmp(buf, "*") || !strcmpi(buf, "random")) { + mndx = NON_PM; + break; + } + mndx = name_to_mon(buf, (int *) 0); + if (mndx == NON_PM) { + /* didn't get a type, so check whether it's a class + (single letter or text match with def_monsyms[]) */ + monclass = name_to_monclass(buf, &mndx); + if (monclass && mndx == NON_PM) + mndx = mkclass_poly(monclass); + } + if (mndx >= LOW_PM) { + /* got a specific type of monster; use it if we can */ + if (validvamp(mon, &mndx, monclass)) + break; + /* can't; revert to random in case we exhaust tryct */ + mndx = NON_PM; + } + + pline("It can't become that."); +#ifdef EDIT_GETLIN + /* EDIT_GETLIN preloads the input buffer with the previous + response but we shouldn't just keep repeating that if player + leaves it unchanged; affects retry for empty input too */ + if (!strcmp(buf, prevbuf)) + Strcpy(buf, "random"); + Strcpy(prevbuf, buf); +#else + nhUse(prevbuf); +#endif + } while (--tryct > 0); + + if (!tryct) + pline1(thats_enough_tries); + if (is_vampshifter(mon) && !validvamp(mon, &mndx, monclass)) + mndx = pickvampshape(mon); /* don't resort to arbitrary */ + return mndx; +} + int select_newcham_form(struct monst* mon) { @@ -4676,81 +4756,8 @@ select_newcham_form(struct monst* mon) } /* for debugging: allow control of polymorphed monster */ - if (wizard && iflags.mon_polycontrol) { - char pprompt[BUFSZ], parttwo[QBUFSZ], buf[BUFSZ], prevbuf[BUFSZ]; - int monclass, len; - - /* construct prompt in pieces */ - Sprintf(pprompt, "Change %s", noit_mon_nam(mon)); - Sprintf(parttwo, " @ %s into what?", - coord_desc((int) mon->mx, (int) mon->my, buf, - (iflags.getpos_coords != GPCOORDS_NONE) - ? iflags.getpos_coords : GPCOORDS_MAP)); - /* combine the two parts, not exceeding QBUFSZ-1 in overall length; - if combined length is too long it has to be due to monster's - name so we'll chop enough of that off to fit the second part */ - if ((len = (int) strlen(pprompt) + (int) strlen(parttwo)) >= QBUFSZ) - /* strlen(parttwo) is less than QBUFSZ/2 so strlen(pprompt) is - more than QBUFSZ/2 and excess amount being truncated can't - exceed pprompt's length and back up to before &pprompt[0]) */ - *(eos(pprompt) - (len - (QBUFSZ - 1))) = '\0'; - Strcat(pprompt, parttwo); - - buf[0] = prevbuf[0] = '\0'; /* clear buffer for EDIT_GETLIN */ -#define TRYLIMIT 5 - tryct = TRYLIMIT; - do { - if (tryct == TRYLIMIT - 1) { /* first retry */ - /* change "into what?" to "into what kind of monster?" */ - if (strlen(pprompt) + sizeof " kind of monster" - 1 < QBUFSZ) - Strcpy(eos(pprompt) - 1, " kind of monster?"); - } -#undef TRYLIMIT - monclass = 0; - getlin(pprompt, buf); - mungspaces(buf); - /* for ESC, take form selected above (might be NON_PM) */ - if (*buf == '\033') - break; - /* for "*", use NON_PM to pick an arbitrary shape below */ - if (!strcmp(buf, "*") || !strcmpi(buf, "random")) { - mndx = NON_PM; - break; - } - mndx = name_to_mon(buf, (int *) 0); - if (mndx == NON_PM) { - /* didn't get a type, so check whether it's a class - (single letter or text match with def_monsyms[]) */ - monclass = name_to_monclass(buf, &mndx); - if (monclass && mndx == NON_PM) - mndx = mkclass_poly(monclass); - } - if (mndx >= LOW_PM) { - /* got a specific type of monster; use it if we can */ - if (validvamp(mon, &mndx, monclass)) - break; - /* can't; revert to random in case we exhaust tryct */ - mndx = NON_PM; - } - - pline("It can't become that."); -#ifdef EDIT_GETLIN - /* EDIT_GETLIN preloads the input buffer with the previous - response but we shouldn't just keep repeating that if player - leaves it unchanged; affects retry for empty input too */ - if (!strcmp(buf, prevbuf)) - Strcpy(buf, "random"); - Strcpy(prevbuf, buf); -#else - nhUse(prevbuf); -#endif - } while (--tryct > 0); - - if (!tryct) - pline1(thats_enough_tries); - if (is_vampshifter(mon) && !validvamp(mon, &mndx, monclass)) - mndx = pickvampshape(mon); /* don't resort to arbitrary */ - } + if (wizard && iflags.mon_polycontrol) + mndx = wiz_force_cham_form(mon); /* if no form was specified above, pick one at random now */ if (mndx == NON_PM) { From 2bd967fe8a451b594a23c9ab98c056c4bad144e9 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 7 Dec 2023 22:47:57 -0800 Subject: [PATCH 42/78] a few fewer update_inventory() calls A couple of things I noticed while running umpteen tests for tty perm_invent. Remove the update_inventory() from unmul(), and limit the one that deals with seeing inventory when recovering from blindness. Just a drop in the bucket overall, and the screen updates nearly instantly for update_inventory() except when debugging perm_invent so players aren't likely to notice this. --- src/do_wear.c | 41 ++++++++++++++++++++++++++++------------- src/hack.c | 5 ++--- src/invent.c | 7 +++++-- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/do_wear.c b/src/do_wear.c index e421badc2c..1b3f4450a0 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 do_wear.c $NHDT-Date: 1650875489 2022/04/25 08:31:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.156 $ */ +/* NetHack 3.7 do_wear.c $NHDT-Date: 1702017586 2023/12/08 06:39:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.175 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -213,8 +213,11 @@ Boots_on(void) default: impossible(unknown_type, c_boots, uarmf->otyp); } - if (uarmf) /* could be Null here (levitation boots put on over a sink) */ + /* uarmf could be Null here (levitation boots put on over a sink) */ + if (uarmf && !uarmf->known) { uarmf->known = 1; /* boots' +/- evident because of status line AC */ + update_inventory(); + } return 0; } @@ -332,8 +335,10 @@ Cloak_on(void) default: impossible(unknown_type, c_cloak, uarmc->otyp); } - if (uarmc) /* no known instance of !uarmc here but play it safe */ + if (uarmc && !uarmc->known) { /* no known instance of !uarmc here */ uarmc->known = 1; /* cloak's +/- evident because of status line AC */ + update_inventory(); + } return 0; } @@ -461,8 +466,10 @@ Helmet_on(void) impossible(unknown_type, c_helmet, uarmh->otyp); } /* uarmh could be Null due to uchangealign() */ - if (uarmh) + if (uarmh && !uarmh->known) { uarmh->known = 1; /* helmet's +/- evident because of status line AC */ + update_inventory(); + } return 0; } @@ -544,8 +551,10 @@ Gloves_on(void) default: impossible(unknown_type, c_gloves, uarmg->otyp); } - if (uarmg) /* no known instance of !uarmg here but play it safe */ + if (!uarmg->known) { uarmg->known = 1; /* gloves' +/- evident because of status line AC */ + update_inventory(); + } return 0; } @@ -667,8 +676,10 @@ Shield_on(void) default: impossible(unknown_type, c_shield, uarms->otyp); } - if (uarms) /* no known instance of !uarms here but play it safe */ + if (!uarms->known) { uarms->known = 1; /* shield's +/- evident because of status line AC */ + update_inventory(); + } return 0; } @@ -708,8 +719,10 @@ Shirt_on(void) default: impossible(unknown_type, c_shirt, uarmu->otyp); } - if (uarmu) /* no known instances of !uarmu here but play it safe */ + if (!uarmu->known) { uarmu->known = 1; /* shirt's +/- evident because of status line AC */ + update_inventory(); + } return 0; } @@ -827,10 +840,12 @@ Armor_on(void) { if (!uarm) /* no known instances of !uarm here but play it safe */ return 0; - uarm->known = 1; /* suit's +/- evident because of status line AC */ - + if (!uarm->known) { + uarm->known = 1; /* suit's +/- evident because of status line AC */ + update_inventory(); + } dragon_armor_handling(uarm, TRUE, TRUE); - /* gold DSM requires special handling since it emits light when worn; + /* gold DSM requires extra handling since it emits light when worn; do that after the special armor handling */ if (artifact_light(uarm) && !uarm->lamplit) { begin_burn(uarm, FALSE); @@ -1117,7 +1132,7 @@ adjust_attrib(struct obj *obj, int which, int val) } void -Ring_on(register struct obj *obj) +Ring_on(struct obj *obj) { long oldprop = u.uprops[objects[obj->otyp].oc_oprop].extrinsic; boolean observable; @@ -1412,8 +1427,8 @@ Blindf_off(struct obj *otmp) /* called in moveloop()'s prologue to set side-effects of worn start-up items; also used by poly_obj() when a worn item gets transformed */ void -set_wear(struct obj *obj) /* if null, do all worn items; - * otherwise just obj itself */ +set_wear( + struct obj *obj) /* if Null, do all worn items; otherwise just obj */ { gi.initial_don = !obj; diff --git a/src/hack.c b/src/hack.c index 92914e172d..5dac909567 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 hack.c $NHDT-Date: 1695932717 2023/09/28 20:25:17 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.410 $ */ +/* NetHack 3.7 hack.c $NHDT-Date: 1702017600 2023/12/08 06:40:00 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.422 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -3766,6 +3766,7 @@ unmul(const char *msg_override) gn.nomovemsg = 0; u.usleep = 0; gm.multi_reason = NULL, gm.multireasonbuf[0] = '\0'; + if (ga.afternmv) { int (*f)(void) = ga.afternmv; @@ -3773,8 +3774,6 @@ unmul(const char *msg_override) encumbrance hack for levitation--see weight_cap()) */ ga.afternmv = (int (*)(void)) 0; (void) (*f)(); - /* for finishing Armor/Boots/&c_on() */ - update_inventory(); } } diff --git a/src/invent.c b/src/invent.c index c4b1b4962b..29f2a3ad18 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 invent.c $NHDT-Date: 1700869704 2023/11/24 23:48:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.476 $ */ +/* NetHack 3.7 invent.c $NHDT-Date: 1702017603 2023/12/08 06:40:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.484 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2611,6 +2611,7 @@ void learn_unseen_invent(void) { struct obj *otmp; + boolean invupdated = FALSE; if (Blind) return; /* sanity check */ @@ -2618,6 +2619,7 @@ learn_unseen_invent(void) for (otmp = gi.invent; otmp; otmp = otmp->nobj) { if (otmp->dknown && (otmp->bknown || !Role_if(PM_CLERIC))) continue; /* already seen */ + invupdated = TRUE; /* xname() will set dknown, perhaps bknown (for priest[ess]); result from xname() is immediately released for re-use */ maybereleaseobuf(xname(otmp)); @@ -2626,7 +2628,8 @@ learn_unseen_invent(void) * handle deferred discovery here. */ } - update_inventory(); + if (invupdated) + update_inventory(); } /* persistent inventory window is maintained by interface code; From c41cb1a7fad7c07f627d8f782f2f5644b128429b Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 8 Dec 2023 00:30:10 -0800 Subject: [PATCH 43/78] source reformatting Fixup some of the inconsistently formatted code that has been introduced recently or been building up for a while. Done manually. I wasn't systematic except for looking for lines ending in '&' or '|' (which wouldn't find such things if they're followed by a comment) so there might be lots more. I changed a bunch of C++-style //... comments to old style C /*...*/ so that they'll match the rest of the core's code rather than because they shouldn't be used. --- src/do.c | 6 +-- src/end.c | 143 +++++++++++++++++++++++++++++--------------------- src/insight.c | 13 +++-- src/invent.c | 6 +-- src/mklev.c | 43 ++++++++------- src/mon.c | 20 +++---- src/spell.c | 38 +++++++++----- src/write.c | 6 +-- src/zap.c | 12 ++--- 9 files changed, 164 insertions(+), 123 deletions(-) diff --git a/src/do.c b/src/do.c index dd963232ae..7a469c5bd0 100644 --- a/src/do.c +++ b/src/do.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 do.c $NHDT-Date: 1689629244 2023/07/17 21:27:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.358 $ */ +/* NetHack 3.7 do.c $NHDT-Date: 1702023250 2023/12/08 08:14:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.368 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -303,8 +303,8 @@ flooreffects(struct obj *obj, coordxy x, coordxy y, const char *verb) } else if (gc.context.mon_moving && IS_ALTAR(levl[x][y].typ) && cansee(x,y)) { doaltarobj(obj); - } else if (obj->oclass == POTION_CLASS && gl.level.flags.temperature > 0 && - (levl[x][y].typ == ROOM || levl[x][y].typ == CORR)) { + } else if (obj->oclass == POTION_CLASS && gl.level.flags.temperature > 0 + && (levl[x][y].typ == ROOM || levl[x][y].typ == CORR)) { /* Potions are sometimes destroyed when landing on very hot ground. The basic odds are 50% for nonblessed potions and 30% for blessed potions; if you have handled the object diff --git a/src/end.c b/src/end.c index 4ac2124f15..f4ac873d52 100644 --- a/src/end.c +++ b/src/end.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 end.c $NHDT-Date: 1702002966 2023/12/08 02:36:06 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.284 $ */ +/* NetHack 3.7 end.c $NHDT-Date: 1702023265 2023/12/08 08:14:25 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.285 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -244,46 +244,51 @@ NH_abort(char *why) # define HASH_FINISH(ctx, out) MD4_Final(out, ctx) # define HASH_RESULT_SIZE MD4_DIGEST_LENGTH # endif -// Binary ID - Use only as a hint to contact.html for recognizing our own -// binaries. This is easily spoofed! -static char bid[(2*HASH_RESULT_SIZE)+1]; +/* Binary ID - Use only as a hint to contact.html for recognizing our own + * binaries. This is easily spoofed! */ +static char bid[(2 * HASH_RESULT_SIZE) + 1]; /* ARGSUSED */ void -crashreport_init(int argc UNUSED, char *argv[] UNUSED){ +crashreport_init(int argc UNUSED, char *argv[] UNUSED) +{ unsigned char tmp[HASH_RESULT_SIZE]; HASH_PRAGMA_START HASH_CONTEXT ctx; HASH_INIT(&ctx); #ifdef MACOS char *binfile = argv[0]; + if (!binfile || !*binfile) { -# ifdef BETA - // If this triggers, investigate CFBundleGetMainBundle - // or CFBundleCopyExecutableURL. +#ifdef BETA + /* If this triggers, investigate CFBundleGetMainBundle + * or CFBundleCopyExecutableURL. */ raw_print("BETA warning: crashreport_init called without useful info"); -# endif +#endif goto skip; } #endif #ifdef __linux__ - char binfile[PATH_MAX+1]; - int len = readlink("/proc/self/exe", binfile, sizeof(binfile)-1); - if (len>0) { + char binfile[PATH_MAX + 1]; + int len = readlink("/proc/self/exe", binfile, sizeof binfile - 1); + + if (len > 0) { binfile[len] = '\0'; } else { goto skip; } #endif int fd = open(binfile, O_RDONLY, 0); + if (fd == -1) { -# ifdef BETA - raw_printf("open e=%s",strerror(errno)); -# endif +#ifdef BETA + raw_printf("open e=%s", strerror(errno)); +#endif goto skip; } int segsize; char segment[4096]; + while (0 < (segsize = read(fd, segment,sizeof(segment)))) { HASH_UPDATE(&ctx, segment, segsize); } @@ -292,14 +297,15 @@ crashreport_init(int argc UNUSED, char *argv[] UNUSED){ char *p = bid; unsigned char *in = &tmp[0]; - char cnt=HASH_RESULT_SIZE; + char cnt = HASH_RESULT_SIZE; + while (cnt--) { - p += snprintf(p, HASH_RESULT_SIZE-(p-bid), "%02x",*(in++)); + p += snprintf(p, HASH_RESULT_SIZE - (p - bid), "%02x", *(in++)); } *p = '\0'; return; -skip: - strncpy((char *) bid, "unknown", sizeof(bid) - 1); + skip: + strncpy((char *) bid, "unknown", sizeof bid - 1); HASH_PRAGMA_END } #undef HASH_CONTEXT @@ -311,55 +317,66 @@ crashreport_init(int argc UNUSED, char *argv[] UNUSED){ #undef HASH_PRAGMA_END void -crashreport_bidshow(void){ +crashreport_bidshow(void) +{ raw_print(bid); } boolean -submit_web_report(const char *msg, char *why){ +submit_web_report(const char *msg, char *why) +{ if (sysopt.crashreporturl) { const char *xargv[SWR_LINES]; char version[100]; - char versionstring[200]; // used twice as a temp + char versionstring[200]; /* used twice as a temp */ int xargc = 0; - char wholetrace[SWR_LINES*80]; // XXX roughly 71 on MacOS, plus buffer - int prelines = 0; // count of lines in trace header - char nbuf[6]; // number buffer + char wholetrace[SWR_LINES * 80]; /* XXX roughly 71 on MacOS, + * plus buffer */ + int prelines = 0; /* count of lines in trace header */ + char nbuf[6]; /* number buffer */ extern char **environ; pid_t pid; SWR_ADD(CRASHREPORT); SWR_ADD(sysopt.crashreporturl); - // then pairs of key value - // subject, generate something useful + /* then pairs of key value */ + /* subject, generate something useful */ SWR_ADD("subject"); - snprintf(version, sizeof(version), "%s report for NetHack %s", - msg, version_string(versionstring, sizeof(versionstring))); + snprintf(version, sizeof version, "%s report for NetHack %s", + msg, version_string(versionstring, sizeof versionstring)); SWR_ADD(version); - // name: someday, this might be stored in nethackcnf - // email: someday, this might be stored in nethackcnf - // gitver, pull from version.c + /* name: someday, this might be stored in nethackcnf + * email: someday, this might be stored in nethackcnf + * gitver, pull from version.c */ SWR_ADD("gitver"); - SWR_ADD(getversionstring(versionstring, sizeof(versionstring))); - // hardware: leave for user - // software: leave for user - // comments: leave for user - // details: stack trace + SWR_ADD(getversionstring(versionstring, sizeof versionstring)); + /* hardware: leave for user + * software: leave for user + * comments: leave for user + * details: stack trace */ SWR_ADD("details"); -// XXX header for wholetrace - what other info do we want? -// NB: prelines not tested against size of SWR_FRAMES. +/* // XXX header for wholetrace - what other info do we want? */ +/* // NB: prelines not tested against size of SWR_FRAMES. */ #define SWR_HDR(line) \ - if (endp<&wholetrace[sizeof(wholetrace)]) { \ - endp+=snprintf(endp, sizeof(wholetrace)-(endp-wholetrace), "%s\n",line); \ - prelines++; \ - } + do { + if (endp < &wholetrace[sizeof wholetrace]) { \ + endp += snprintf(endp, sizeof wholetrace - (endp - wholetrace), \ + "%s\n", line); \ + prelines++; \ + } \ + } while (0) #define SWR_HDRnonl(line) \ - if (endp<&wholetrace[sizeof(wholetrace)]) { \ - endp+=snprintf(endp, sizeof(wholetrace)-(endp-wholetrace), "%s",line); \ - } + do { \ + if (endp < &wholetrace[sizeof wholetrace]) { \ + endp += snprintf(endp, sizeof wholetrace - (endp - wholetrace), \ + "%s", line); \ + } \ + } while (0) + char *endp = wholetrace; - wholetrace[0] = 0; + + wholetrace[0] = '\0'; if (why) { SWR_HDR(why); } @@ -378,36 +395,38 @@ submit_web_report(const char *msg, char *why){ /* try to remove up to 16 blank spaces by removing 8 twice */ (void) strsubst(buf, " ", ""); (void) strsubst(buf, " ", ""); - snprintf(endp, SWR_FRAMES*80-(endp-wholetrace), "[%02lu] %s\n", - (unsigned long) x, buf); + snprintf(endp, SWR_FRAMES * 80 - (endp - wholetrace), + "[%02lu] %s\n", (unsigned long) x, buf); endp = eos(endp); } - *(endp-1) = '\0'; // remove last newline + *(endp - 1) = '\0'; /* remove last newline */ SWR_ADD(wholetrace); - // detailrows min(actual,50) Guess since we can't know the - // width of the window. + /* detailrows min(actual,50) Guess since we can't know the + * width of the window. */ SWR_ADD("detailrows"); - (void) snprintf(nbuf, sizeof nbuf,"%d",count+prelines); + (void) snprintf(nbuf, sizeof nbuf, "%d", count + prelines); SWR_ADD(nbuf); - xargv[xargc++] = 0; // terminate array + xargv[xargc++] = 0; /* terminate array */ pid = fork(); if (pid == 0) { - execve(CRASHREPORT, (char * const *)xargv, environ); char err[100]; - sprintf(err, "Can't start " CRASHREPORT ": %s", strerror(errno)); + + (int) execve(CRASHREPORT, (char * const *) xargv, environ); + Sprintf(err, "Can't start " CRASHREPORT ": %s", strerror(errno)); raw_print(err); } else { int status; errno=0; - // XXX do we _really_ know this is the right pid? + /* XXX do we _really_ know this is the right pid? */ (void) waitpid(pid, &status, 0); - if (status) { // XXX check could be more precise + if (status) { /* // XXX check could be more precise */ #if 0 - // Not useful at the moment. XXX + /* // Not useful at the moment. XXX */ char err[100]; - sprintf(err, "pid=%d e=%d status=%0x",wpid,errno,status); + + Sprintf(err, "pid=%d e=%d status=%0x", wpid, errno, status); raw_print(err); #endif return FALSE; @@ -422,6 +441,7 @@ submit_web_report(const char *msg, char *why){ #undef SWR_ADD #undef SWR_FRAMES #undef SWR_HDR +#undef SWR_HDRnonl #undef SWR_LINES /*ARGSUSED*/ @@ -429,7 +449,8 @@ static boolean NH_panictrace_libc(char *why UNUSED) { #ifdef CRASHREPORT - if(submit_web_report("Panic",why)) return TRUE; + if (submit_web_report("Panic", why)) + return TRUE; #endif #ifdef PANICTRACE_LIBC diff --git a/src/insight.c b/src/insight.c index e5b4964a4c..ea32037683 100644 --- a/src/insight.c +++ b/src/insight.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 insight.c $NHDT-Date: 1701677864 2023/12/04 08:17:44 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.102 $ */ +/* NetHack 3.7 insight.c $NHDT-Date: 1702023267 2023/12/08 08:14:27 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.104 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1430,11 +1430,16 @@ weapon_insight(int final) } static void -item_resistance_message(int adtyp, const char *prot_message, int final) +item_resistance_message( + int adtyp, + const char *prot_message, + int final) { int protection = u_adtyp_resistance_obj(adtyp); + if (protection) { boolean somewhat = protection < 99; + enl_msg("Your items ", somewhat ? "are somewhat" : "are", somewhat ? "were somewhat" : "were", @@ -1444,7 +1449,9 @@ item_resistance_message(int adtyp, const char *prot_message, int final) /* attributes: intrinsics and the like, other non-obvious capabilities */ static void -attributes_enlightenment(int unused_mode UNUSED, int final) +attributes_enlightenment( + int unused_mode UNUSED, + int final) { static NEARDATA const char if_surroundings_permitted[] = " if surroundings permitted"; diff --git a/src/invent.c b/src/invent.c index 29f2a3ad18..d05c93813b 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 invent.c $NHDT-Date: 1702017603 2023/12/08 06:40:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.484 $ */ +/* NetHack 3.7 invent.c $NHDT-Date: 1702023269 2023/12/08 08:14:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.485 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -941,8 +941,8 @@ merged(struct obj **potmp, struct obj **pobj) information about the items (with the exception of thrown items, where this would be too spammy as such items get unidentified by monsters very frequently). */ - if (discovered && otmp->where == OBJ_INVENT && - !obj->was_thrown && !otmp->was_thrown) { + if (discovered && otmp->where == OBJ_INVENT + && !obj->was_thrown && !otmp->was_thrown) { pline("You learn more about your items by comparing them."); } diff --git a/src/mklev.c b/src/mklev.c index fbc27d13c8..7de4c86517 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 mklev.c $NHDT-Date: 1702002703 2023/12/08 02:31:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.162 $ */ +/* NetHack 3.7 mklev.c $NHDT-Date: 1702023271 2023/12/08 08:14:31 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.163 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Alex Smith, 2017. */ /* NetHack may be freely redistributed. See license for details. */ @@ -923,30 +923,31 @@ fill_ordinary_room(struct mkroom *croom, boolean bonus_items) if (bonus_items && somexyspace(croom, &pos)) { branch *uz_branch = Is_branchlev(&u.uz); - if (uz_branch && u.uz.dnum != mines_dnum && - (uz_branch->end1.dnum == mines_dnum || - uz_branch->end2.dnum == mines_dnum)) { - (void) mksobj_at( - rn2(5) < 3 ? FOOD_RATION : rn2(2) ? CRAM_RATION : LEMBAS_WAFER, - pos.x, pos.y, TRUE, FALSE); - } else if (u.uz.dnum == oracle_level.dnum && - u.uz.dlevel < oracle_level.dlevel && rn2(3)) { + if (uz_branch && u.uz.dnum != mines_dnum + && (uz_branch->end1.dnum == mines_dnum + || uz_branch->end2.dnum == mines_dnum)) { + (void) mksobj_at((rn2(5) < 3) ? FOOD_RATION + : rn2(2) ? CRAM_RATION + : LEMBAS_WAFER, + pos.x, pos.y, TRUE, FALSE); + } else if (u.uz.dnum == oracle_level.dnum + && u.uz.dlevel < oracle_level.dlevel && rn2(3)) { struct obj *otmp; + int otyp, tryct = 0; + boolean cursed; /* reverse probabilities compared to non-supply chests; these are twice as likely to be chests than large boxes, rather than vice versa */ - struct obj *supply_chest = mksobj_at( - rn2(3) ? CHEST : LARGE_BOX, pos.x, pos.y, FALSE, FALSE); + struct obj *supply_chest = mksobj_at(rn2(3) ? CHEST : LARGE_BOX, + pos.x, pos.y, FALSE, FALSE); + supply_chest->olocked = !!(rn2(6)); - int tryct = 0; - boolean cursed; do { - int otyp; /* 50% this is a potion of healing */ - if (rn2(2)) + if (rn2(2)) { otyp = POT_HEALING; - else { + } else { static const int supply_items[] = { POT_EXTRA_HEALING, POT_SPEED, @@ -958,6 +959,7 @@ fill_ordinary_room(struct mkroom *croom, boolean bonus_items) WAN_DIGGING, SPE_HEALING, }; + otyp = ROLL_FROM(supply_items); } otmp = mksobj(otyp, TRUE, FALSE); @@ -994,12 +996,15 @@ fill_ordinary_room(struct mkroom *croom, boolean bonus_items) SPBOOK_no_NOVEL }; int oclass = ROLL_FROM(extra_classes); + otmp = mkobj(oclass, FALSE); if (oclass == SPBOOK_no_NOVEL) { /* bias towards lower level by generating again and taking the lower-level book */ struct obj *otmp2 = mkobj(oclass, FALSE); - if (objects[otmp->otyp].oc_level <= objects[otmp2->otyp].oc_level) { + + if (objects[otmp->otyp].oc_level + <= objects[otmp2->otyp].oc_level) { dealloc_obj(otmp2); } else { dealloc_obj(otmp); @@ -1020,8 +1025,8 @@ fill_ordinary_room(struct mkroom *croom, boolean bonus_items) * when few rooms; chance for 3 or more is negligible. */ if (!rn2(gn.nroom * 5 / 2) && somexyspace(croom, &pos) && !skip_chests) - (void) mksobj_at((rn2(3)) ? LARGE_BOX : CHEST, - pos.x, pos.y, TRUE, FALSE); + (void) mksobj_at(rn2(3) ? LARGE_BOX : CHEST, + pos.x, pos.y, TRUE, FALSE); /* maybe make some graffiti */ if (!rn2(27 + 3 * abs(depth(&u.uz)))) { diff --git a/src/mon.c b/src/mon.c index ce6a6dcaff..a00489ab8b 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 mon.c $NHDT-Date: 1693292534 2023/08/29 07:02:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.517 $ */ +/* NetHack 3.7 mon.c $NHDT-Date: 1702023272 2023/12/08 08:14:32 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.532 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -157,13 +157,13 @@ sanity_check_single_mon( if (ceiling_hider(mptr) /* normally !accessible would be overridable with passes_walls, but not for hiding on the ceiling */ - && (!has_ceiling(&u.uz) || - !(levl[mx][my].typ == POOL - || levl[mx][my].typ == MOAT - || levl[mx][my].typ == WATER - || levl[mx][my].typ == LAVAPOOL - || levl[mx][my].typ == LAVAWALL - || accessible(mx, my)))) + && (!has_ceiling(&u.uz) + || !(levl[mx][my].typ == POOL + || levl[mx][my].typ == MOAT + || levl[mx][my].typ == WATER + || levl[mx][my].typ == LAVAPOOL + || levl[mx][my].typ == LAVAWALL + || accessible(mx, my)))) impossible("ceiling hider hiding %s (%s)", !has_ceiling(&u.uz) ? "without ceiling" : "in solid stone", @@ -3286,8 +3286,8 @@ xkilled( otmp = mkobj(RANDOM_CLASS, TRUE); /* don't create large objects from small monsters */ otyp = otmp->otyp; - if (otmp->oclass == FOOD_CLASS && !(mdat->mflags2 & M2_COLLECT) && - !otmp->oartifact) { + if (otmp->oclass == FOOD_CLASS && !(mdat->mflags2 & M2_COLLECT) + && !otmp->oartifact) { /* don't drop newly created permafood from kills, unless the monster collects food; it creates too much nutrition in the late game and encourages grinding in the early diff --git a/src/spell.c b/src/spell.c index e16367534f..1bed24fa3c 100644 --- a/src/spell.c +++ b/src/spell.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 spell.c $NHDT-Date: 1646838390 2022/03/09 15:06:30 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.131 $ */ +/* NetHack 3.7 spell.c $NHDT-Date: 1702023273 2023/12/08 08:14:33 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.157 $ */ /* Copyright (c) M. Stephenson 1988 */ /* NetHack may be freely redistributed. See license for details. */ @@ -846,19 +846,28 @@ skill_based_spellbook_id(void) for (booktype = gb.bases[spbook_class]; booktype < gb.bases[spbook_class + 1]; booktype++) { + int known_up_to_level; int skill = spell_skilltype(booktype); - if (skill == P_NONE) continue; - int known_up_to_level; + if (skill == P_NONE) + continue; + switch (P_SKILL(skill)) { case P_BASIC: - known_up_to_level = 3; break; + known_up_to_level = 3; + break; case P_SKILLED: - known_up_to_level = 5; break; - case P_EXPERT: case P_MASTER: case P_GRAND_MASTER: - known_up_to_level = 7; break; - case P_UNSKILLED: default: - known_up_to_level = 1; break; + known_up_to_level = 5; + break; + case P_EXPERT: + case P_MASTER: + case P_GRAND_MASTER: + known_up_to_level = 7; + break; + case P_UNSKILLED: + default: + known_up_to_level = 1; + break; } if (objects[booktype].oc_level <= known_up_to_level) @@ -978,21 +987,22 @@ cast_chain_lightning(void) /* start by propagating in all directions from the caster */ for (int dir = 0; dir < N_DIRS; dir++) { struct chain_lightning_zap zap = { dir, u.ux, u.uy, 2 }; + propagate_chain_lightning(&clq, zap); } nh_delay_output(); while (clq.head < clq.tail) { int delay_tail = clq.tail; + while (clq.head < delay_tail) { struct chain_lightning_zap zap = clq.q[clq.head++]; - /* damage any monster that was hit */ struct monst *mon = m_at(zap.x, zap.y); + if (mon) { struct obj *unused; /* AD_ELEC can't destroy armor */ - int dmg = zhitm( - mon, BZ_U_SPELL(AD_ELEC - 1), 2, &unused); + int dmg = zhitm(mon, BZ_U_SPELL(AD_ELEC - 1), 2, &unused); if (dmg) { /* mon has been damaged, but we haven't yet printed the @@ -1021,8 +1031,8 @@ cast_chain_lightning(void) if (zap.strength < 2) zap.strength = 0; - else if (u.uen) - u.uen--; /* propagating past monsters increases Pw cost a bit */ + else if (u.uen > 0) + u.uen--; /* propagating past mons increases Pw cost a bit */ zap.dir = DIR_LEFT(zap.dir); propagate_chain_lightning(&clq, zap); diff --git a/src/write.c b/src/write.c index 8ca32a6677..ac0a335e16 100644 --- a/src/write.c +++ b/src/write.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 write.c $NHDT-Date: 1596498232 2020/08/03 23:43:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.26 $ */ +/* NetHack 3.7 write.c $NHDT-Date: 1702023275 2023/12/08 08:14:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.41 $ */ /* NetHack may be freely redistributed. See license for details. */ #include "hack.h" @@ -349,8 +349,8 @@ dowrite(struct obj *pen) /* else fresh knowledge of the spell works */ && spell_knowledge != spe_Fresh /* and Luck might override after previous checks have failed */ - && rnl(((Role_if(PM_WIZARD) && paper->oclass != SPBOOK_CLASS) || - spell_knowledge == spe_GoingStale) + && rnl(((Role_if(PM_WIZARD) && paper->oclass != SPBOOK_CLASS) + || spell_knowledge == spe_GoingStale) ? 5 : 15)) { You("%s to write that.", by_descr ? "fail" : "don't know how"); /* scrolls disappear, spellbooks don't */ diff --git a/src/zap.c b/src/zap.c index b8d77bfff2..83d2dcf62c 100644 --- a/src/zap.c +++ b/src/zap.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 zap.c $NHDT-Date: 1698264791 2023/10/25 20:13:11 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.481 $ */ +/* NetHack 3.7 zap.c $NHDT-Date: 1702023277 2023/12/08 08:14:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.498 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -5394,8 +5394,7 @@ adtyp_to_prop(int dmgtyp) } /* Is hero wearing or wielding an object with resistance to attack - damage type? Returns the percentage protection that the object - gives. */ + damage type? Returns the percentage protection that the object gives. */ int u_adtyp_resistance_obj(int dmgtyp) { @@ -5409,10 +5408,9 @@ u_adtyp_resistance_obj(int dmgtyp) if ((u.uprops[prop].extrinsic & (W_ARMOR | W_ACCESSORY | W_WEP)) != 0) return 99; - /* Dwarvish cloaks give a 90% protection to items against heat and - cold */ - if (uarmc && uarmc->otyp == DWARVISH_CLOAK && - (dmgtyp == AD_COLD || dmgtyp == AD_FIRE)) + /* Dwarvish cloaks give a 90% protection to items against heat and cold */ + if (uarmc && uarmc->otyp == DWARVISH_CLOAK + && (dmgtyp == AD_COLD || dmgtyp == AD_FIRE)) return 90; return 0; From 2a9ede0fd70173e3c415b16f318c41fe1df705eb Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 8 Dec 2023 05:01:47 -0500 Subject: [PATCH 44/78] ill-formed macro (build fix) --- src/end.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/end.c b/src/end.c index f4ac873d52..1c73dfd8c5 100644 --- a/src/end.c +++ b/src/end.c @@ -359,7 +359,7 @@ submit_web_report(const char *msg, char *why) /* // XXX header for wholetrace - what other info do we want? */ /* // NB: prelines not tested against size of SWR_FRAMES. */ #define SWR_HDR(line) \ - do { + do { \ if (endp < &wholetrace[sizeof wholetrace]) { \ endp += snprintf(endp, sizeof wholetrace - (endp - wholetrace), \ "%s\n", line); \ From a1f21b702d862cd86989fb053e5075eb359a8c4a Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 8 Dec 2023 03:30:32 -0800 Subject: [PATCH 45/78] warning fix for #if CRASHREPORT Thinko in the reformatting, not triggered during testing because I was using !CRASHREPORT. With it enabled, setting a watchpoint in gdb on something unrelated resulted in nethack going into crashreport_init() and never caming out. (I imagine that it would have eventually but 10 or 15 minutes with nothing noticeable taking place was unbearable, and the program hadn't even really started yet.) --- src/end.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/end.c b/src/end.c index 1c73dfd8c5..c426004015 100644 --- a/src/end.c +++ b/src/end.c @@ -413,7 +413,7 @@ submit_web_report(const char *msg, char *why) if (pid == 0) { char err[100]; - (int) execve(CRASHREPORT, (char * const *) xargv, environ); + (void) execve(CRASHREPORT, (char * const *) xargv, environ); Sprintf(err, "Can't start " CRASHREPORT ": %s", strerror(errno)); raw_print(err); } else { From 20b91270baba6f6098fae5eeaa753ff4b27ced4e Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Fri, 8 Dec 2023 14:10:08 +0200 Subject: [PATCH 46/78] Fix wrong level flags in mazes below Medusa The mazes between Medusa and the Castle had couple wrong default level flags, because those levels don't go through the special level routines. --- src/mklev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mklev.c b/src/mklev.c index 7de4c86517..9a02c01bc8 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -803,8 +803,9 @@ clear_level_structures(void) gl.level.flags.has_town = 0; gl.level.flags.wizard_bones = 0; gl.level.flags.corrmaze = 0; - gl.level.flags.rndmongen = 0; - gl.level.flags.deathdrops = 0; + gl.level.flags.temperature = In_hell(&u.uz) ? 1 : 0; + gl.level.flags.rndmongen = 1; + gl.level.flags.deathdrops = 1; gl.level.flags.noautosearch = 0; gl.level.flags.fumaroles = 0; gl.level.flags.stormy = 0; From 348f88c7269c239b3a22cff1f33d934bdb2e1dd2 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Fri, 8 Dec 2023 18:31:16 +0200 Subject: [PATCH 47/78] Walking into a shopkeeper tries to pay the bill --- doc/fixes3-7-0.txt | 1 + src/uhitm.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 3496a777b4..2249db1646 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1319,6 +1319,7 @@ spellbooks weight 50 units but Book of the Dead only 20, and novels only 1; save and restore hero tracks, increase track length change vrock and hezrou from red to green, adjust vrock tile to have green change wolf and werewolf to grey, warg to black +walking into a shopkeeper tries to pay the bill Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/uhitm.c b/src/uhitm.c index 951e94f00b..85ba4ad13c 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -478,6 +478,9 @@ do_attack(struct monst *mtmp) if (inshop || foo) { char buf[BUFSZ]; + if (!gc.context.travel && !gc.context.run) + return ECMD_TIME | dopay(); + if (mtmp->mtame) /* see 'additional considerations' above */ monflee(mtmp, rnd(6), FALSE, FALSE); Strcpy(buf, y_monnam(mtmp)); From dbb41f4a2d59d463975c6cebcfbdf3ae3c56aff0 Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 8 Dec 2023 12:31:49 -0500 Subject: [PATCH 48/78] const warning in sound/fmod/fmod.c Parameter did not match those in include/sndprocs.h --- sound/fmod/fmod.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/fmod/fmod.c b/sound/fmod/fmod.c index 230047f3fe..26ad2fff3b 100644 --- a/sound/fmod/fmod.c +++ b/sound/fmod/fmod.c @@ -17,7 +17,7 @@ static void fmod_exit_nhsound(const char *); static void fmod_achievement(schar, schar, int32_t); static void fmod_soundeffect(char *, int32_t, int32_t); static void fmod_hero_playnotes(int32_t instrument, const char *str, int32_t volume); -static void fmod_play_usersound(const char *, int32_t, int32_t); +static void fmod_play_usersound(char *, int32_t, int32_t); static void fmod_ambience(int32_t, int32_t, int32_t); static void fmod_verbal(char *, int32_t, int32_t, int32_t, int32_t); @@ -72,7 +72,7 @@ static void fmod_hero_playnotes(int32_t instrument, const char *str, int32_t vol /* fulfill SOUND_TRIGGER_USERSOUNDS */ static void -fmod_play_usersound(const char *filename, int32_t volume UNUSED, int32_t idx UNUSED) +fmod_play_usersound(char *filename, int32_t volume UNUSED, int32_t idx UNUSED) { FMOD_System_CreateSound(systemvar, filename, FMOD_CREATESAMPLE, 0, &soundvar); From 7259ae21f52908f819a15839e4137d817c604e50 Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 8 Dec 2023 13:01:52 -0500 Subject: [PATCH 49/78] initializer fix for !VIRTUAL_TERMINAL_SEQUENCES For windows sys/windows/consoletty.c. Resolves #1169 --- sys/windows/consoletty.c | 50 +++++++++++++--------------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/sys/windows/consoletty.c b/sys/windows/consoletty.c index fdc42f07af..7c686763a4 100644 --- a/sys/windows/consoletty.c +++ b/sys/windows/consoletty.c @@ -186,15 +186,8 @@ struct console_t { WCHAR cpMap[256]; boolean font_changed; CONSOLE_FONT_INFOEX orig_font_info; -#ifndef VIRTUAL_TERMINAL_SEQUENCES - UINT original_code_page; -} console = { - 0, - (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED), - (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED), - NO_COLOR, -#else /* VIRTUAL_TERMINAL_SEQUENCES */ UINT orig_code_page; +#ifdef VIRTUAL_TERMINAL_SEQUENCES char *orig_localestr; DWORD orig_in_cmode; DWORD orig_out_cmode; @@ -205,33 +198,17 @@ struct console_t { DWORD out_cmode; long color24; int color256idx; +#endif /* VIRTUAL_TERMINAL_SEQUENCES */ } console = { - FALSE, - 0, + FALSE, /* is_ready */ + 0, /* hWnd */ (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED), /* background */ (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED), /* foreground */ 0, /* attr */ 0, /* current_nhcolor */ 0, /* current_nhbkcolor */ -#endif /* VIRTUAL_TERMINAL_SEQUENCES */ {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}, -#ifndef VIRTUAL_TERMINAL_SEQUENCES - {0, 0}, - NULL, - NULL, - { 0 }, - 0, - 0, - FALSE, - 0, - NULL, - NULL, - { 0 }, - FALSE, - { 0 }, - 0 -#else /* VIRTUAL_TERMINAL_SEQUENCES */ - { 0, 0 }, /* cursor */ + {0, 0}, /* cursor */ NULL, /* hConOut*/ NULL, /* hConIn */ { 0 }, /* cbsi */ @@ -245,6 +222,7 @@ struct console_t { FALSE, /* font_changed */ { 0 }, /* orig_font_info */ 0U, /* orig_code_page */ +#ifdef VIRTUAL_TERMINAL_SEQUENCES NULL, /* orig_localestr */ 0, /* orig_in_cmode */ 0, /* orig_out_cmode */ @@ -1446,8 +1424,6 @@ g_putch(int in_ch) buffer_write(console.back_buffer, &cell, console.cursor); } -#ifdef VIRTUAL_TERMINAL_SEQUENCES -#ifdef UTF8_FROM_CORE /* * Overrides wintty.c function of the same name * for win32. It is used for glyphs only, not text and @@ -1458,6 +1434,8 @@ g_putch(int in_ch) void g_pututf8(uint8 *sequence) { +#ifdef VIRTUAL_TERMINAL_SEQUENCES +#ifdef UTF8_FROM_CORE set_console_cursor(ttyDisplay->curx, ttyDisplay->cury); cell_t cell; cell.attr = console.attr; @@ -1468,23 +1446,27 @@ g_pututf8(uint8 *sequence) Snprintf((char *) cell.utf8str, sizeof cell.utf8str, "%s", (char *) sequence); buffer_write(console.back_buffer, &cell, console.cursor); -} #endif /* UTF8_FROM_CORE */ +#endif +} void term_start_24bitcolor(struct unicode_representation *uval) { +#ifdef VIRTUAL_TERMINAL_SEQUENCES console.color24 = uval->ucolor; /* color 0 has bit 0x1000000 set */ console.color256idx = uval->u256coloridx; +#endif } void term_end_24bitcolor(void) { +#ifdef VIRTUAL_TERMINAL_SEQUENCES console.color24 = 0L; console.color256idx = 0; +#endif } -#endif /* VIRTUAL_TERMINAL_SEQUENCES */ void cl_end(void) @@ -2210,7 +2192,7 @@ set_known_good_console_font(void) console.font_changed = TRUE; #ifndef VIRTUAL_TERMINAL_SEQUENCES console.orig_font_info = console_font_info; - console.original_code_page = GetConsoleOutputCP(); + console.orig_code_page = GetConsoleOutputCP(); #else /* VIRTUAL_TERMINAL_SEQUENCES */ console.code_page = GetConsoleOutputCP(); @@ -2245,7 +2227,7 @@ restore_original_console_font(void) BOOL success; #ifndef VIRTUAL_TERMINAL_SEQUENCES raw_print("Restoring original font and code page\n"); - success = SetConsoleOutputCP(console.original_code_page); + success = SetConsoleOutputCP(console.orig_code_page); #else /* VIRTUAL_TERMINAL_SEQUENCES */ if (wizard) raw_print("Restoring original font, code page and locale\n"); From ad833ce02d58febc7b23cfb5af79c52763dd2b8c Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Fri, 8 Dec 2023 21:15:07 +0200 Subject: [PATCH 50/78] Add more tile grayscale mappings Color I added to the warg tiles was missing from the greyscale mapping when generating statue tiles. Map the missing greys to slightly darker shades. --- win/share/tiletext.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/win/share/tiletext.c b/win/share/tiletext.c index 9209b1d700..b5f7be7005 100644 --- a/win/share/tiletext.c +++ b/win/share/tiletext.c @@ -71,10 +71,10 @@ enum { MONSTER_SET, OBJECT_SET, OTHER_SET}; [21] U = (205,205,205) grayshade maps to [20] or T for shade of gray [22] V = (104, 104, 104) grayshade maps to [27] or 0 for shade of gray [23] W = (131, 131, 131) grayshade maps to [22] or V for shade of gray - [24] X = (140, 140, 140) grayshade not mapped in graymappings - [25] Y = (149, 149, 149) grayshade not mapped in graymappings - [26] Z = (195, 195, 195) grayshade not mapped in graymappings - [27] 0 = (100, 100, 100) grayshade not mapped in graymappings + [24] X = (140, 140, 140) grayshade maps to [23] or W for shade of gray + [25] Y = (149, 149, 149) grayshade maps to [24] or X for shade of gray + [26] Z = (195, 195, 195) grayshade maps to [25] or Y for shade of gray + [27] 0 = (100, 100, 100) grayshade maps to [20] or T for shade of gray [28] 1 = (72, 108, 108) not mapped in graymappings ----------------------------------------------------------------------------- */ @@ -84,8 +84,8 @@ static int grayscale = 0; static const int graymappings[] = { /* . A B C D E F G H I J K L M N O P */ 0, 1, 17, 18, 19, 20, 27, 22, 23, 24, 25, 26, 21, 15, 13, 14, 14, - /* Q R S T U V W */ - 1, 17, 18, 19, 20, 27, 22 + /* Q R S T U V W X Y Z 0 */ + 1, 17, 18, 19, 20, 27, 22, 23, 24, 25, 20 }; void From 9ea2894448de23bce4d93b36e52ba5a9451a75f1 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 8 Dec 2023 11:41:53 -0800 Subject: [PATCH 51/78] fix discovered artifact panic When known discoveries was displayed on a window of type NHW_MENU, header lines sent to it via menu_add_heading() disappeared into the bit bucket. Switching back to putstr() made them show up. But I also changed the type to NHW_TEXT. A menu_add_heading() in artifact.c was overlooked, and after the window type change that started triggering a panic when '\' or '`a' was used while any artifacts were discovered. Not sure how other interfaces were dealing with this. --- src/artifact.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/artifact.c b/src/artifact.c index a79d828bd0..db303b7a95 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 artifact.c $NHDT-Date: 1654717838 2022/06/08 19:50:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.190 $ */ +/* NetHack 3.7 artifact.c $NHDT-Date: 1702064500 2023/12/08 19:41:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.214 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1037,7 +1037,8 @@ undiscovered_artifact(xint16 m) /* display a list of discovered artifacts; return their count */ int -disp_artifact_discoveries(winid tmpwin) /* supplied by dodiscover() */ +disp_artifact_discoveries( + winid tmpwin) /* supplied by dodiscover(); type is NHW_TEXT */ { int i, m, otyp; const char *algnstr; @@ -1050,7 +1051,7 @@ disp_artifact_discoveries(winid tmpwin) /* supplied by dodiscover() */ continue; /* for WIN_ERR, we just count */ if (i == 0) - add_menu_heading(tmpwin, "Artifacts"); + putstr(tmpwin, iflags.menu_headings.attr, "Artifacts"); m = artidisco[i]; otyp = artilist[m].otyp; algnstr = align_str(artilist[m].alignment); From ecb3a1a68dcd9073c04f6dbb4f659eb9522a1129 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Fri, 8 Dec 2023 22:03:54 +0200 Subject: [PATCH 52/78] Change mind flayers, the Wizard, and the riders to bright magenta --- doc/fixes3-7-0.txt | 1 + include/color.h | 1 + include/monsters.h | 12 ++++++------ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 2249db1646..d4902dc0b4 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1319,6 +1319,7 @@ spellbooks weight 50 units but Book of the Dead only 20, and novels only 1; save and restore hero tracks, increase track length change vrock and hezrou from red to green, adjust vrock tile to have green change wolf and werewolf to grey, warg to black +change [master] mind flayer, the Wizard, and the riders to bright magenta walking into a shopkeeper tries to pay the bill diff --git a/include/color.h b/include/color.h index 17fe9f6126..fe7ba3fbce 100644 --- a/include/color.h +++ b/include/color.h @@ -36,6 +36,7 @@ /* color aliases used in monsters.h and display.c */ #define HI_DOMESTIC CLR_WHITE /* for player + pets */ #define HI_LORD CLR_MAGENTA /* for high-end monsters */ +#define HI_OVERLORD CLR_BRIGHT_MAGENTA /* for few uniques */ /* these can be configured */ #define HI_OBJ CLR_MAGENTA diff --git a/include/monsters.h b/include/monsters.h index 18dcb3a035..14ee32dd63 100644 --- a/include/monsters.h +++ b/include/monsters.h @@ -454,7 +454,7 @@ SIZ(1450, 400, MS_HISS, MZ_HUMAN), 0, 0, M1_HUMANOID | M1_FLY | M1_SEE_INVIS | M1_OMNIVORE, M2_HOSTILE | M2_NASTY | M2_GREEDY | M2_JEWELS | M2_COLLECT, - M3_INFRAVISIBLE | M3_INFRAVISION, 13, CLR_MAGENTA, MIND_FLAYER), + M3_INFRAVISIBLE | M3_INFRAVISION, 13, CLR_BRIGHT_MAGENTA, MIND_FLAYER), MON("master mind flayer", S_HUMANOID, LVL(13, 12, 0, 90, -8), (G_GENO | 1), A(ATTK(AT_WEAP, AD_PHYS, 1, 8), ATTK(AT_TENT, AD_DRIN, 2, 1), @@ -463,7 +463,7 @@ SIZ(1450, 400, MS_HISS, MZ_HUMAN), 0, 0, M1_HUMANOID | M1_FLY | M1_SEE_INVIS | M1_OMNIVORE, M2_HOSTILE | M2_NASTY | M2_GREEDY | M2_JEWELS | M2_COLLECT, - M3_INFRAVISIBLE | M3_INFRAVISION, 19, CLR_MAGENTA, + M3_INFRAVISIBLE | M3_INFRAVISION, 19, CLR_BRIGHT_MAGENTA, MASTER_MIND_FLAYER), /* * imps & other minor demons/devils @@ -2408,7 +2408,7 @@ | M1_TPORT | M1_TPORT_CNTRL | M1_OMNIVORE, M2_NOPOLY | M2_HUMAN | M2_HOSTILE | M2_STRONG | M2_NASTY | M2_PRINCE | M2_MALE | M2_MAGIC, - M3_COVETOUS | M3_WAITFORU | M3_INFRAVISIBLE, 34, HI_LORD, + M3_COVETOUS | M3_WAITFORU | M3_INFRAVISIBLE, 34, HI_OVERLORD, WIZARD_OF_YENDOR), MON("Croesus", S_HUMAN, LVL(20, 15, 0, 40, 15), (G_UNIQ | G_NOGEN), A(ATTK(AT_WEAP, AD_PHYS, 4, 10), NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, @@ -2672,7 +2672,7 @@ MR_FIRE | MR_COLD | MR_ELEC | MR_SLEEP | MR_POISON | MR_STONE, 0, M1_FLY | M1_HUMANOID | M1_REGEN | M1_SEE_INVIS | M1_TPORT_CNTRL, M2_NOPOLY | M2_STALK | M2_HOSTILE | M2_PNAME | M2_STRONG | M2_NASTY, - M3_INFRAVISIBLE | M3_INFRAVISION | M3_DISPLACES, 34, HI_LORD, + M3_INFRAVISIBLE | M3_INFRAVISION | M3_DISPLACES, 34, HI_OVERLORD, DEATH), MON("Pestilence", S_DEMON, LVL(30, 12, -5, 100, 0), (G_UNIQ | G_NOGEN), A(ATTK(AT_TUCH, AD_PEST, 8, 8), ATTK(AT_TUCH, AD_PEST, 8, 8), NO_ATTK, @@ -2681,7 +2681,7 @@ MR_FIRE | MR_COLD | MR_ELEC | MR_SLEEP | MR_POISON | MR_STONE, 0, M1_FLY | M1_HUMANOID | M1_REGEN | M1_SEE_INVIS | M1_TPORT_CNTRL, M2_NOPOLY | M2_STALK | M2_HOSTILE | M2_PNAME | M2_STRONG | M2_NASTY, - M3_INFRAVISIBLE | M3_INFRAVISION | M3_DISPLACES, 34, HI_LORD, + M3_INFRAVISIBLE | M3_INFRAVISION | M3_DISPLACES, 34, HI_OVERLORD, PESTILENCE), MON("Famine", S_DEMON, LVL(30, 12, -5, 100, 0), (G_UNIQ | G_NOGEN), A(ATTK(AT_TUCH, AD_FAMN, 8, 8), ATTK(AT_TUCH, AD_FAMN, 8, 8), NO_ATTK, @@ -2690,7 +2690,7 @@ MR_FIRE | MR_COLD | MR_ELEC | MR_SLEEP | MR_POISON | MR_STONE, 0, M1_FLY | M1_HUMANOID | M1_REGEN | M1_SEE_INVIS | M1_TPORT_CNTRL, M2_NOPOLY | M2_STALK | M2_HOSTILE | M2_PNAME | M2_STRONG | M2_NASTY, - M3_INFRAVISIBLE | M3_INFRAVISION | M3_DISPLACES, 34, HI_LORD, + M3_INFRAVISIBLE | M3_INFRAVISION | M3_DISPLACES, 34, HI_OVERLORD, FAMINE), /* other demons */ From 275713b56ee581b2f9a5c993ae35a00ccd0726bd Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 8 Dec 2023 12:15:24 -0800 Subject: [PATCH 53/78] more source reformatting Less extensive this time. Contributed by entrez. --- src/do.c | 6 ++++-- src/save.c | 36 +++++++++++++++++------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/do.c b/src/do.c index 7a469c5bd0..f74b36b0c3 100644 --- a/src/do.c +++ b/src/do.c @@ -325,8 +325,10 @@ flooreffects(struct obj *obj, coordxy x, coordxy y, const char *verb) } int survival_chance = obj->blessed ? 70 : 50; - if (obj->invlet) survival_chance += Luck * 2; - if (obj->otyp == POT_OIL) survival_chance = 100; + if (obj->invlet) + survival_chance += Luck * 2; + if (obj->otyp == POT_OIL) + survival_chance = 100; if (!obj_resists(obj, survival_chance, 100)) { if (cansee(x,y)) { diff --git a/src/save.c b/src/save.c index d8edaaae87..4606012066 100644 --- a/src/save.c +++ b/src/save.c @@ -22,11 +22,11 @@ static void savedamage(NHFILE *); static void save_bubbles(NHFILE *, xint8); static void save_stairs(NHFILE *); static void save_bc(NHFILE *); -static void saveobj(NHFILE *,struct obj *); -static void saveobjchn(NHFILE *,struct obj **); -static void savemon(NHFILE *,struct monst *); -static void savemonchn(NHFILE *,struct monst *); -static void savetrapchn(NHFILE *,struct trap *); +static void saveobj(NHFILE *, struct obj *); +static void saveobjchn(NHFILE *, struct obj **); +static void savemon(NHFILE *, struct monst *); +static void savemonchn(NHFILE *, struct monst *); +static void savetrapchn(NHFILE *, struct trap *); static void save_gamelog(NHFILE *); static void savegamestate(NHFILE *); static void savelev_core(NHFILE *, xint8); @@ -344,7 +344,7 @@ savegamestate(NHFILE *nhfp) /* potentially called from goto_level(do.c) as well as savestateinlock() */ boolean -tricked_fileremoved(NHFILE* nhfp, char* whynot) +tricked_fileremoved(NHFILE *nhfp, char *whynot) { if (!nhfp) { pline1(whynot); @@ -571,7 +571,7 @@ savelev_core(NHFILE *nhfp, xint8 lev) } static void -savelevl(NHFILE* nhfp, boolean rlecomp) +savelevl(NHFILE *nhfp, boolean rlecomp) { #ifdef RLECOMP struct rm *prm, *rgrm; @@ -654,7 +654,7 @@ save_bubbles(NHFILE *nhfp, xint8 lev) /* used when saving a level and also when saving dungeon overview data */ void -savecemetery(NHFILE* nhfp, struct cemetery** cemeteryaddr) +savecemetery(NHFILE *nhfp, struct cemetery **cemeteryaddr) { struct cemetery *thisbones, *nextbones; int flag; @@ -679,7 +679,7 @@ savecemetery(NHFILE* nhfp, struct cemetery** cemeteryaddr) } static void -savedamage(NHFILE* nhfp) +savedamage(NHFILE *nhfp) { register struct damage *damageptr, *tmp_dam; unsigned int xl = 0; @@ -706,7 +706,7 @@ savedamage(NHFILE* nhfp) } static void -save_stairs(NHFILE* nhfp) +save_stairs(NHFILE *nhfp) { stairway *stway = gs.stairs; int buflen = (int) sizeof *stway; @@ -815,7 +815,7 @@ saveobj(NHFILE *nhfp, struct obj *otmp) /* save an object chain; sets head of list to Null when done; handles release_data() for each object in the list */ static void -saveobjchn(NHFILE* nhfp, struct obj** obj_p) +saveobjchn(NHFILE *nhfp, struct obj **obj_p) { register struct obj *otmp = *obj_p; struct obj *otmp2; @@ -878,7 +878,7 @@ saveobjchn(NHFILE* nhfp, struct obj** obj_p) } static void -savemon(NHFILE* nhfp, struct monst* mtmp) +savemon(NHFILE *nhfp, struct monst *mtmp) { int buflen; @@ -941,7 +941,7 @@ savemon(NHFILE* nhfp, struct monst* mtmp) } static void -savemonchn(NHFILE* nhfp, register struct monst* mtmp) +savemonchn(NHFILE *nhfp, register struct monst *mtmp) { register struct monst *mtmp2; int minusone = -1; @@ -978,7 +978,7 @@ savemonchn(NHFILE* nhfp, register struct monst* mtmp) /* save traps; gf.ftrap is the only trap chain so the 2nd arg is superfluous */ static void -savetrapchn(NHFILE* nhfp, register struct trap* trap) +savetrapchn(NHFILE *nhfp, register struct trap *trap) { static struct trap zerotrap; register struct trap *trap2; @@ -1011,7 +1011,7 @@ savetrapchn(NHFILE* nhfp, register struct trap* trap) * level routine marks nonexistent fruits by making the fid negative. */ void -savefruitchn(NHFILE* nhfp) +savefruitchn(NHFILE *nhfp) { static struct fruit zerofruit; register struct fruit *f2, *f1; @@ -1035,10 +1035,8 @@ savefruitchn(NHFILE* nhfp) gf.ffruit = 0; } - - static void -savelevchn(NHFILE* nhfp) +savelevchn(NHFILE *nhfp) { s_level *tmplev, *tmplev2; int cnt = 0; @@ -1110,7 +1108,7 @@ save_msghistory(NHFILE *nhfp) } void -store_savefileinfo(NHFILE* nhfp) +store_savefileinfo(NHFILE *nhfp) { /* sfcap (decl.c) describes the savefile feature capabilities * that are supported by this port/platform build. From d7d1c1476de58e70742b7c58cdf10d10072f8035 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Thu, 16 Nov 2023 09:57:31 -0500 Subject: [PATCH 54/78] Add option to exclude dropped items from autopick This is based on a feature in UnNetHack (and I think some other variants as well). If the hero intentionally drops an item with 'pickup_dropped' disabled, don't autopick it back up when walking over that square again. Typically when the player drops an item, it's because she doesn't want it in her inventory any more, and this option stops autopickup from defeating that goal (especially useful for tasks like stash management without a container). Players have come up with workarounds to this problem like toggling autopickup when approaching their stash pile or adding name-based autopickup exceptions to allow them to exclude individual items from autopickup, but this behavior should reduce the need for those things. I think 'pickup_dropped' is a little unfortunate because it suggests equivalence to 'pickup_thrown' (i.e. any dropped items will be automatically picked up regardless of autopickup exceptions). Calling it something like 'nopick_dropped' might be better, but as far as I can tell options cannot start with the word 'no' because it's interpreted as a negation of the rest of the option name. --- dat/opthelp | 1 + doc/Guidebook.mn | 11 +++++++++++ doc/Guidebook.tex | 9 +++++++++ include/flag.h | 1 + include/obj.h | 5 +++-- include/optlist.h | 3 +++ src/bones.c | 1 + src/do.c | 1 + src/invent.c | 2 +- src/options.c | 3 ++- src/pickup.c | 11 ++++++++--- 11 files changed, 41 insertions(+), 7 deletions(-) diff --git a/dat/opthelp b/dat/opthelp index 938debeda9..73945261a6 100644 --- a/dat/opthelp +++ b/dat/opthelp @@ -50,6 +50,7 @@ null allow nulls to be sent to your terminal [True] delay code) if moving objects seem to teleport across rooms perm_invent keep inventory in a permanent window [False] pickup_thrown override pickup_types for thrown objects [True] +pickup_dropped evaluate pickup_types for dropped objects [True] pushweapon when wielding a new weapon, put your previously [False] wielded weapon into the secondary weapon slot quick_farsight usually skip the chance to browse the map when [False] diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index d778e72cb0..16e45fa548 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -4387,6 +4387,17 @@ level (Unencumbered, Burdened, streSsed, straiNed, overTaxed, or overLoaded), you will be asked if you want to continue. (Default \(oqS\(cq). Persistent. +.lp pickup_dropped +If this option is on, items you dropped will be treated like normal items for +.op autopickup +purposes. If it is disabled, items you dropped will not be automatically +picked up, even if +.op autopickup +is on and they are in +.op pickup_types +or match a positive autopickup exception. +Default is on. +Persistent. .lp pickup_thrown If this option is on and .op autopickup diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index 116ef004f0..7f74e62b2a 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -4809,6 +4809,15 @@ \subsection*{Customization options} or overLoaded), you will be asked if you want to continue. (Default `S'). Persistent. %.lp +\item[\ib{pickup\verb+_+dropped}] +If this option is on, items you dropped will be treated like normal items for +``{\it autopickup\/}'' purposes. If it disabled, items you dropped will not be +automatically picked up, even if ``{\it autopickup\/}'' is on and they are in +``{\it pickup\verb+_+types\/}'' or +match an autopickup exception. +Default is on. +Persistent. +%.lp \item[\ib{pickup\verb+_+thrown}] If this option is on and ``{\it autopickup\/}'' is also on, try to pick up things that you threw, even if they aren't in diff --git a/include/flag.h b/include/flag.h index 19771a830b..8fd5a07bb1 100644 --- a/include/flag.h +++ b/include/flag.h @@ -47,6 +47,7 @@ struct flag { boolean nap; /* `timed_delay' option for display effects */ boolean null; /* OK to send nulls to the terminal */ boolean pickup; /* whether you pickup or move and look */ + boolean pickup_dropped; /* items you dropped may be autopicked */ boolean pickup_thrown; /* auto-pickup items you threw */ boolean pushweapon; /* When wielding, push old weapon into second slot */ boolean quick_farsight; /* True disables map browsing during random diff --git a/include/obj.h b/include/obj.h index 5a8de9a7a8..7c430c38f8 100644 --- a/include/obj.h +++ b/include/obj.h @@ -127,6 +127,7 @@ struct obj { Bitfield(greased, 1); /* covered with grease */ Bitfield(nomerge, 1); /* set temporarily to prevent merging */ Bitfield(was_thrown, 1); /* thrown by hero since last picked up */ + Bitfield(was_dropped, 1); /* dropped deliberately by the hero */ Bitfield(in_use, 1); /* for magic items before useup items */ Bitfield(bypass, 1); /* mark this as an object to be skipped by bhito() */ @@ -144,9 +145,9 @@ struct obj { Bitfield(eknown, 1); /* effect known for wands zapped or rings worn when * not seen yet after being picked up while blind * [maybe for remaining stack of used potion too] */ - /* 0 free bits */ + /* 7 free bits */ #else - /* 2 free bits */ + /* 1 free bit */ #endif int corpsenm; /* type of corpse is mons[corpsenm] */ diff --git a/include/optlist.h b/include/optlist.h index 91c0518ea7..16be32b318 100644 --- a/include/optlist.h +++ b/include/optlist.h @@ -531,6 +531,9 @@ static int optfn_##a(int, int, boolean, char *, char *); NHOPTC(pickup_burden, Advanced, 20, opt_in, set_in_game, No, Yes, No, Yes, NoAlias, "maximum burden picked up before prompt") + NHOPTB(pickup_dropped, Behavior, 0, opt_out, set_in_game, + On, Yes, No, No, NoAlias, &flags.pickup_dropped, Term_False, + "consider dropped items for autopickup") NHOPTB(pickup_thrown, Behavior, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias, &flags.pickup_thrown, Term_False, "autopickup thrown items") diff --git a/src/bones.c b/src/bones.c index 0abdb4000f..c6d79d8301 100644 --- a/src/bones.c +++ b/src/bones.c @@ -108,6 +108,7 @@ resetobjs(struct obj *ochain, boolean restore) otmp->invlet = 0; otmp->no_charge = 0; otmp->was_thrown = 0; + otmp->was_dropped = 0; /* strip user-supplied names */ /* Statue and some corpse names are left intact, diff --git a/src/do.c b/src/do.c index f74b36b0c3..86a81d8d0e 100644 --- a/src/do.c +++ b/src/do.c @@ -760,6 +760,7 @@ drop(struct obj *obj) if (!IS_ALTAR(levl[u.ux][u.uy].typ) && flags.verbose) You("drop %s.", doname(obj)); } + obj->was_dropped = 1; dropx(obj); return ECMD_TIME; } diff --git a/src/invent.c b/src/invent.c index d05c93813b..af0322c96c 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1050,7 +1050,7 @@ addinv_core0(struct obj *obj, struct obj *other_obj, if (Has_contents(obj)) picked_container(obj); /* clear no_charge */ obj_was_thrown = obj->was_thrown; - obj->was_thrown = 0; /* not meaningful for invent */ + obj->was_thrown = obj->was_dropped = 0; /* not meaningful for invent */ if (gl.loot_reset_justpicked) { gl.loot_reset_justpicked = FALSE; diff --git a/src/options.c b/src/options.c index e8d758d958..57e32d4576 100644 --- a/src/options.c +++ b/src/options.c @@ -8593,7 +8593,8 @@ doset_simple_menu(void) /* pickup_types is separated from autopickup due to the spelling of their names; emphasize what it means */ if (allopt[i].idx == opt_pickup_types - || allopt[i].idx == opt_pickup_thrown) + || allopt[i].idx == opt_pickup_thrown + || allopt[i].idx == opt_pickup_dropped) Strcat(buf, " (for autopickup)"); add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, NO_COLOR, buf, MENU_ITEMFLAGS_NONE); diff --git a/src/pickup.c b/src/pickup.c index f1d0a733cf..8a531668c9 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -904,6 +904,12 @@ autopick_testobj(struct obj *otmp, boolean calc_costly) if (costly && !otmp->no_charge) return FALSE; + /* pickup_thrown/!pickup_dropped override pickup_types and exceptions */ + if (flags.pickup_thrown && otmp->was_thrown) + return TRUE; + if (!flags.pickup_dropped && otmp->was_dropped) + return FALSE; + /* check for pickup_types */ pickit = (!*otypes || strchr(otypes, otmp->oclass)); @@ -912,9 +918,6 @@ autopick_testobj(struct obj *otmp, boolean calc_costly) if (ape) pickit = ape->grab; - /* pickup_thrown overrides pickup_types and exceptions */ - if (!pickit) - pickit = (flags.pickup_thrown && otmp->was_thrown); return pickit; } @@ -3664,6 +3667,7 @@ tipcontainer(struct obj *box) /* or bag */ (void) add_to_container(targetbox, otmp); } } else if (highdrop) { + otmp->was_dropped = 1; /* might break or fall down stairs; handles altars itself */ hitfloor(otmp, TRUE); } else { @@ -3676,6 +3680,7 @@ tipcontainer(struct obj *box) /* or bag */ pline("%s%c", doname(otmp), nobj ? ',' : '.'); iflags.last_msg = PLNMSG_OBJNAM_ONLY; } + otmp->was_dropped = 1; dropy(otmp); if (iflags.last_msg != PLNMSG_OBJNAM_ONLY) terse = FALSE; /* terse formatting has been interrupted */ From e2e89cb93ea1e12d18673b16f201a63faedcd5d6 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Thu, 16 Nov 2023 23:38:21 -0500 Subject: [PATCH 55/78] Rename/invert 'pickup_dropped' to 'dropped_nopick' --- dat/opthelp | 2 +- doc/Guidebook.mn | 18 +++++++----------- doc/Guidebook.tex | 15 ++++++--------- include/flag.h | 2 +- include/optlist.h | 6 +++--- src/options.c | 2 +- src/pickup.c | 4 ++-- 7 files changed, 21 insertions(+), 28 deletions(-) diff --git a/dat/opthelp b/dat/opthelp index 73945261a6..de91c565b9 100644 --- a/dat/opthelp +++ b/dat/opthelp @@ -17,6 +17,7 @@ cmdassist give help for errors on direction & other commands [True] color use different colors for objects on screen [True for micros] confirm ask before hitting tame or peaceful monsters [True] dark_room show floor not in sight in different color [True] +dropped_nopick exclude dropped objects from autopickup [False] eight_bit_tty send 8-bit characters straight to terminal [False] extmenu tty, curses: use menu for # (extended commands) [False] X11: menu has all commands (T) or traditional subset (F) @@ -50,7 +51,6 @@ null allow nulls to be sent to your terminal [True] delay code) if moving objects seem to teleport across rooms perm_invent keep inventory in a permanent window [False] pickup_thrown override pickup_types for thrown objects [True] -pickup_dropped evaluate pickup_types for dropped objects [True] pushweapon when wielding a new weapon, put your previously [False] wielded weapon into the secondary weapon slot quick_farsight usually skip the chance to browse the map when [False] diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index 16e45fa548..33563866ed 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -3868,6 +3868,13 @@ Show out-of-sight areas of lit rooms (default on). Persistent. .lp "deaf " Start the character permanently deaf (default false). Persistent. +.lp dropped_nopick +If this option is on, items you dropped will not be automatically +picked up, even if +.op autopickup +is also on and they are in +.op pickup_types +or match a positive autopickup exception (defualt off). Persistent. .lp disclose Controls what information the program reveals when the game ends. Value is a space separated list of prompting/category pairs @@ -4387,17 +4394,6 @@ level (Unencumbered, Burdened, streSsed, straiNed, overTaxed, or overLoaded), you will be asked if you want to continue. (Default \(oqS\(cq). Persistent. -.lp pickup_dropped -If this option is on, items you dropped will be treated like normal items for -.op autopickup -purposes. If it is disabled, items you dropped will not be automatically -picked up, even if -.op autopickup -is on and they are in -.op pickup_types -or match a positive autopickup exception. -Default is on. -Persistent. .lp pickup_thrown If this option is on and .op autopickup diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index 7f74e62b2a..6254b89d27 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -4224,6 +4224,12 @@ \subsection*{Customization options} \item[\ib{deaf}] Start the character permanently deaf (default false). Persistent. %.lp +\item[\ib{dropped\verb+_+nopick}] +If this option is on, items you dropped will not be automatically picked up, +even if ``{\it autopickup\/}'' is also on and they are in +``{\it pickup\verb+_+types\/}'' or match a positive autopickup exception +(default off). Persistent. +%.lp \item[\ib{disclose}] Controls what information the program reveals when the game ends. Value is a space separated list of prompting/category pairs @@ -4809,15 +4815,6 @@ \subsection*{Customization options} or overLoaded), you will be asked if you want to continue. (Default `S'). Persistent. %.lp -\item[\ib{pickup\verb+_+dropped}] -If this option is on, items you dropped will be treated like normal items for -``{\it autopickup\/}'' purposes. If it disabled, items you dropped will not be -automatically picked up, even if ``{\it autopickup\/}'' is on and they are in -``{\it pickup\verb+_+types\/}'' or -match an autopickup exception. -Default is on. -Persistent. -%.lp \item[\ib{pickup\verb+_+thrown}] If this option is on and ``{\it autopickup\/}'' is also on, try to pick up things that you threw, even if they aren't in diff --git a/include/flag.h b/include/flag.h index 8fd5a07bb1..852878931b 100644 --- a/include/flag.h +++ b/include/flag.h @@ -45,9 +45,9 @@ struct flag { boolean mention_decor; /* give feedback for unobscured furniture */ boolean mention_walls; /* give feedback when bumping walls */ boolean nap; /* `timed_delay' option for display effects */ + boolean nopick_dropped; /* items you dropped may be autopicked */ boolean null; /* OK to send nulls to the terminal */ boolean pickup; /* whether you pickup or move and look */ - boolean pickup_dropped; /* items you dropped may be autopicked */ boolean pickup_thrown; /* auto-pickup items you threw */ boolean pushweapon; /* When wielding, push old weapon into second slot */ boolean quick_farsight; /* True disables map browsing during random diff --git a/include/optlist.h b/include/optlist.h index 16be32b318..8823f28abe 100644 --- a/include/optlist.h +++ b/include/optlist.h @@ -261,6 +261,9 @@ static int optfn_##a(int, int, boolean, char *, char *); NHOPTC(dogname, Advanced, PL_PSIZ, opt_in, set_gameview, No, Yes, No, No, NoAlias, "name of your starting pet if it is a little dog") + NHOPTB(dropped_nopick, Behavior, 0, opt_in, set_in_game, + Off, Yes, No, No, NoAlias, &flags.nopick_dropped, Term_False, + "don't autopickup dropped items") NHOPTC(dungeon, Advanced, MAXDCHARS + 1,opt_in, set_in_config, No, Yes, No, No, NoAlias, "list of symbols to use in drawing the dungeon map") @@ -531,9 +534,6 @@ static int optfn_##a(int, int, boolean, char *, char *); NHOPTC(pickup_burden, Advanced, 20, opt_in, set_in_game, No, Yes, No, Yes, NoAlias, "maximum burden picked up before prompt") - NHOPTB(pickup_dropped, Behavior, 0, opt_out, set_in_game, - On, Yes, No, No, NoAlias, &flags.pickup_dropped, Term_False, - "consider dropped items for autopickup") NHOPTB(pickup_thrown, Behavior, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias, &flags.pickup_thrown, Term_False, "autopickup thrown items") diff --git a/src/options.c b/src/options.c index 57e32d4576..740bcaa9a3 100644 --- a/src/options.c +++ b/src/options.c @@ -8594,7 +8594,7 @@ doset_simple_menu(void) spelling of their names; emphasize what it means */ if (allopt[i].idx == opt_pickup_types || allopt[i].idx == opt_pickup_thrown - || allopt[i].idx == opt_pickup_dropped) + || allopt[i].idx == opt_dropped_nopick) Strcat(buf, " (for autopickup)"); add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, NO_COLOR, buf, MENU_ITEMFLAGS_NONE); diff --git a/src/pickup.c b/src/pickup.c index 8a531668c9..d7c7c20262 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -904,10 +904,10 @@ autopick_testobj(struct obj *otmp, boolean calc_costly) if (costly && !otmp->no_charge) return FALSE; - /* pickup_thrown/!pickup_dropped override pickup_types and exceptions */ + /* pickup_thrown/nopick_dropped override pickup_types and exceptions */ if (flags.pickup_thrown && otmp->was_thrown) return TRUE; - if (!flags.pickup_dropped && otmp->was_dropped) + if (flags.nopick_dropped && otmp->was_dropped) return FALSE; /* check for pickup_types */ From c07d114644a7dc07d35095746604533d9586eccf Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Fri, 17 Nov 2023 08:45:55 -0500 Subject: [PATCH 56/78] Add object sanity check for was_dropped/was_thrown --- src/mkobj.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mkobj.c b/src/mkobj.c index f3affc40a3..44b23165bf 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -2863,6 +2863,10 @@ objlist_sanity(struct obj *objlist, int wheretype, const char *mesg) for (obj = objlist; obj; obj = obj->nobj) { if (obj->where != wheretype) insane_object(obj, ofmt0, mesg, (struct monst *) 0); + if (obj->was_thrown && obj->was_dropped) { + insane_object(obj, "%s obj is both thrown and dropped! %s %s: %s", + mesg, obj->ocarry); + } if (Has_contents(obj)) { if (wheretype == OBJ_ONBILL) /* containers on shop bill should always be empty */ From ecda85cc32362c93368e8b239be8c8fb0769b2e4 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Fri, 17 Nov 2023 08:49:14 -0500 Subject: [PATCH 57/78] Don't merge stacks w/ different was_thrown/dropped Previously, if you threw a dagger into a pile of daggers, you'd pick up the entire pile with pickup_thrown on. Since pickup_thrown and dropped_nopick options are supposed to apply specifically to items you've handled, don't merge items with different values in those fields. --- src/invent.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/invent.c b/src/invent.c index af0322c96c..33cbba4946 100644 --- a/src/invent.c +++ b/src/invent.c @@ -4822,7 +4822,9 @@ mergable( if (obj->unpaid != otmp->unpaid || obj->spe != otmp->spe || obj->no_charge != otmp->no_charge || obj->obroken != otmp->obroken - || obj->otrapped != otmp->otrapped || obj->lamplit != otmp->lamplit) + || obj->otrapped != otmp->otrapped || obj->lamplit != otmp->lamplit + || obj->was_thrown != otmp->was_thrown + || obj->was_dropped != otmp->was_dropped) return FALSE; if (obj->oclass == FOOD_CLASS From 1736f3caaa66c14f24d5ef4669c13a82a4bfc312 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Fri, 17 Nov 2023 09:37:16 -0500 Subject: [PATCH 58/78] Add 'pickup_stolen' option Add pickup_stolen option to autopick items stolen from you by a nymph or monkey, even if they don't match your normal autopickup settings. Replace was_dropped, was_thrown with a 2-bit bitfield that can contain values LOST_DROPPED, LOST_THROWN, and LOST_STOLEN (or 0), since they should all be mutually exclusive anyway as they track the most recent way the item left the hero's inventory. [Rebase/merge conflict fixed up. PR] --- dat/opthelp | 1 + doc/Guidebook.mn | 9 +++++++++ doc/Guidebook.tex | 8 ++++++++ include/flag.h | 1 + include/obj.h | 13 +++++++++---- include/optlist.h | 3 +++ src/bones.c | 3 +-- src/do.c | 2 +- src/dothrow.c | 4 ++-- src/invent.c | 10 +++++----- src/mkobj.c | 7 ++++--- src/nhlobj.c | 2 +- src/options.c | 1 + src/pickup.c | 12 +++++++----- src/steal.c | 1 + 15 files changed, 54 insertions(+), 23 deletions(-) diff --git a/dat/opthelp b/dat/opthelp index de91c565b9..35337d1046 100644 --- a/dat/opthelp +++ b/dat/opthelp @@ -50,6 +50,7 @@ null allow nulls to be sent to your terminal [True] try turning this option off (forcing NetHack to use its own delay code) if moving objects seem to teleport across rooms perm_invent keep inventory in a permanent window [False] +pickup_stolen override pickup_types for stolen objects [True] pickup_thrown override pickup_types for thrown objects [True] pushweapon when wielding a new weapon, put your previously [False] wielded weapon into the secondary weapon slot diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index 33563866ed..e634e6232b 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -4394,6 +4394,15 @@ level (Unencumbered, Burdened, streSsed, straiNed, overTaxed, or overLoaded), you will be asked if you want to continue. (Default \(oqS\(cq). Persistent. +.lp pickup_stolen +If this option is on and +.op autopickup +is also on, try to pick up things that a monster stole from you, even if they +aren't in +.op pickup_types +or match an autopickup exception. +Default is on. +Persistent. .lp pickup_thrown If this option is on and .op autopickup diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index 6254b89d27..57fee57604 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -4815,6 +4815,14 @@ \subsection*{Customization options} or overLoaded), you will be asked if you want to continue. (Default `S'). Persistent. %.lp +\item[\ib{pickup\verb+_+stolen}] +If this option is on and ``{\it autopickup\/}'' is also on, try to pick up +things that a monster stole from you, even if they aren't in +``{\it pickup\verb+_+types\/}'' or +match an autopickup exception. +Default is on. +Persistent. +%.lp \item[\ib{pickup\verb+_+thrown}] If this option is on and ``{\it autopickup\/}'' is also on, try to pick up things that you threw, even if they aren't in diff --git a/include/flag.h b/include/flag.h index 852878931b..aa2a6420bf 100644 --- a/include/flag.h +++ b/include/flag.h @@ -48,6 +48,7 @@ struct flag { boolean nopick_dropped; /* items you dropped may be autopicked */ boolean null; /* OK to send nulls to the terminal */ boolean pickup; /* whether you pickup or move and look */ + boolean pickup_stolen; /* auto-pickup items stolen by a monster */ boolean pickup_thrown; /* auto-pickup items you threw */ boolean pushweapon; /* When wielding, push old weapon into second slot */ boolean quick_farsight; /* True disables map browsing during random diff --git a/include/obj.h b/include/obj.h index 7c430c38f8..f3d8a424ed 100644 --- a/include/obj.h +++ b/include/obj.h @@ -124,10 +124,9 @@ struct obj { #define on_ice recharged /* corpse on ice */ Bitfield(lamplit, 1); /* a light-source -- can be lit */ Bitfield(globby, 1); /* combines with like types on adjacent squares */ - Bitfield(greased, 1); /* covered with grease */ - Bitfield(nomerge, 1); /* set temporarily to prevent merging */ - Bitfield(was_thrown, 1); /* thrown by hero since last picked up */ - Bitfield(was_dropped, 1); /* dropped deliberately by the hero */ + Bitfield(greased, 1); /* covered with grease */ + Bitfield(nomerge, 1); /* set temporarily to prevent merging */ + Bitfield(how_lost, 2); /* stolen by mon or thrown, dropped by hero */ Bitfield(in_use, 1); /* for magic items before useup items */ Bitfield(bypass, 1); /* mark this as an object to be skipped by bhito() */ @@ -459,6 +458,12 @@ struct obj { #define POTHIT_MONST_THROW 2 /* thrown by a monster */ #define POTHIT_OTHER_THROW 3 /* propelled by some other means [scatter()] */ +/* tracking how an item left your inventory */ +#define LOST_NONE 0 /* still in inventory, or method not covered below */ +#define LOST_THROWN 1 /* thrown or fired by the hero */ +#define LOST_DROPPED 2 /* dropped or tipped out of a container by the hero */ +#define LOST_STOLEN 3 /* stolen from hero's inventory by a monster */ + /* * Notes for adding new oextra structures: * diff --git a/include/optlist.h b/include/optlist.h index 8823f28abe..689810349e 100644 --- a/include/optlist.h +++ b/include/optlist.h @@ -534,6 +534,9 @@ static int optfn_##a(int, int, boolean, char *, char *); NHOPTC(pickup_burden, Advanced, 20, opt_in, set_in_game, No, Yes, No, Yes, NoAlias, "maximum burden picked up before prompt") + NHOPTB(pickup_stolen, Behavior, 0, opt_out, set_in_game, + On, Yes, No, No, NoAlias, &flags.pickup_stolen, Term_False, + "autopickup thrown items") NHOPTB(pickup_thrown, Behavior, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias, &flags.pickup_thrown, Term_False, "autopickup thrown items") diff --git a/src/bones.c b/src/bones.c index c6d79d8301..4497fcf9b3 100644 --- a/src/bones.c +++ b/src/bones.c @@ -107,8 +107,7 @@ resetobjs(struct obj *ochain, boolean restore) otmp->cknown = 0; otmp->invlet = 0; otmp->no_charge = 0; - otmp->was_thrown = 0; - otmp->was_dropped = 0; + otmp->how_lost = LOST_NONE; /* strip user-supplied names */ /* Statue and some corpse names are left intact, diff --git a/src/do.c b/src/do.c index 86a81d8d0e..3ff95fac94 100644 --- a/src/do.c +++ b/src/do.c @@ -760,7 +760,7 @@ drop(struct obj *obj) if (!IS_ALTAR(levl[u.ux][u.uy].typ) && flags.verbose) You("drop %s.", doname(obj)); } - obj->was_dropped = 1; + obj->how_lost = LOST_DROPPED; dropx(obj); return ECMD_TIME; } diff --git a/src/dothrow.c b/src/dothrow.c index 8ecab42e97..e04f22e4e6 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -1504,7 +1504,7 @@ throwit(struct obj *obj, } gt.thrownobj = obj; - gt.thrownobj->was_thrown = 1; + gt.thrownobj->how_lost = LOST_THROWN; iflags.returning_missile = AutoReturn(obj, wep_mask) ? (genericptr_t) obj : (genericptr_t) 0; /* NOTE: No early returns after this point or returning_missile @@ -1719,7 +1719,7 @@ throwit(struct obj *obj, if (tethered_weapon) tmp_at(DISP_END, 0); /* when this location is stepped on, the weapon will be - auto-picked up due to 'obj->was_thrown' of 1; + auto-picked up due to 'obj->how_lost' of LOST_THROWN; addinv() prevents thrown Mjollnir from being placed into the quiver slot, but an aklys will end up there if that slot is empty at the time; since hero will need to diff --git a/src/invent.c b/src/invent.c index 33cbba4946..b6a2dd011f 100644 --- a/src/invent.c +++ b/src/invent.c @@ -942,7 +942,8 @@ merged(struct obj **potmp, struct obj **pobj) items, where this would be too spammy as such items get unidentified by monsters very frequently). */ if (discovered && otmp->where == OBJ_INVENT - && !obj->was_thrown && !otmp->was_thrown) { + && obj->how_lost != LOST_THROWN + && otmp->how_lost != LOST_THROWN) { pline("You learn more about your items by comparing them."); } @@ -1049,8 +1050,8 @@ addinv_core0(struct obj *obj, struct obj *other_obj, obj->no_charge = 0; /* should not be set in hero's invent */ if (Has_contents(obj)) picked_container(obj); /* clear no_charge */ - obj_was_thrown = obj->was_thrown; - obj->was_thrown = obj->was_dropped = 0; /* not meaningful for invent */ + obj_was_thrown = (obj->how_lost == LOST_THROWN); + obj->how_lost = LOST_NONE; if (gl.loot_reset_justpicked) { gl.loot_reset_justpicked = FALSE; @@ -4823,8 +4824,7 @@ mergable( if (obj->unpaid != otmp->unpaid || obj->spe != otmp->spe || obj->no_charge != otmp->no_charge || obj->obroken != otmp->obroken || obj->otrapped != otmp->otrapped || obj->lamplit != otmp->lamplit - || obj->was_thrown != otmp->was_thrown - || obj->was_dropped != otmp->was_dropped) + || obj->how_lost != otmp->how_lost) return FALSE; if (obj->oclass == FOOD_CLASS diff --git a/src/mkobj.c b/src/mkobj.c index 44b23165bf..c926276ed6 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -2863,9 +2863,10 @@ objlist_sanity(struct obj *objlist, int wheretype, const char *mesg) for (obj = objlist; obj; obj = obj->nobj) { if (obj->where != wheretype) insane_object(obj, ofmt0, mesg, (struct monst *) 0); - if (obj->was_thrown && obj->was_dropped) { - insane_object(obj, "%s obj is both thrown and dropped! %s %s: %s", - mesg, obj->ocarry); + if (obj->where == OBJ_INVENT && obj->how_lost != LOST_NONE) { + char lostbuf[40]; + Sprintf(lostbuf, "how_lost=%d obj in inventory!", obj->how_lost); + insane_object(obj, ofmt0, lostbuf, (struct monst *) 0); } if (Has_contents(obj)) { if (wheretype == OBJ_ONBILL) diff --git a/src/nhlobj.c b/src/nhlobj.c index d5bbaf3813..619af7de0a 100644 --- a/src/nhlobj.c +++ b/src/nhlobj.c @@ -312,7 +312,7 @@ l_obj_to_table(lua_State *L) nhl_add_table_entry_int(L, "globby", obj->globby); nhl_add_table_entry_int(L, "greased", obj->greased); nhl_add_table_entry_int(L, "nomerge", obj->nomerge); - nhl_add_table_entry_int(L, "was_thrown", obj->was_thrown); + nhl_add_table_entry_int(L, "how_lost", obj->how_lost); nhl_add_table_entry_int(L, "in_use", obj->in_use); nhl_add_table_entry_int(L, "bypass", obj->bypass); nhl_add_table_entry_int(L, "cknown", obj->cknown); diff --git a/src/options.c b/src/options.c index 740bcaa9a3..a3c9f16889 100644 --- a/src/options.c +++ b/src/options.c @@ -8594,6 +8594,7 @@ doset_simple_menu(void) spelling of their names; emphasize what it means */ if (allopt[i].idx == opt_pickup_types || allopt[i].idx == opt_pickup_thrown + || allopt[i].idx == opt_pickup_stolen || allopt[i].idx == opt_dropped_nopick) Strcat(buf, " (for autopickup)"); add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, diff --git a/src/pickup.c b/src/pickup.c index d7c7c20262..7b77811165 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -904,10 +904,12 @@ autopick_testobj(struct obj *otmp, boolean calc_costly) if (costly && !otmp->no_charge) return FALSE; - /* pickup_thrown/nopick_dropped override pickup_types and exceptions */ - if (flags.pickup_thrown && otmp->was_thrown) + /* pickup_thrown/pickup_stolen/nopick_dropped override pickup_types and + exceptions */ + if ((flags.pickup_thrown && otmp->how_lost == LOST_THROWN) + || (flags.pickup_stolen && otmp->how_lost == LOST_STOLEN)) return TRUE; - if (flags.nopick_dropped && otmp->was_dropped) + if (flags.nopick_dropped && otmp->how_lost == LOST_DROPPED) return FALSE; /* check for pickup_types */ @@ -3667,7 +3669,7 @@ tipcontainer(struct obj *box) /* or bag */ (void) add_to_container(targetbox, otmp); } } else if (highdrop) { - otmp->was_dropped = 1; + otmp->how_lost = LOST_DROPPED; /* might break or fall down stairs; handles altars itself */ hitfloor(otmp, TRUE); } else { @@ -3680,7 +3682,7 @@ tipcontainer(struct obj *box) /* or bag */ pline("%s%c", doname(otmp), nobj ? ',' : '.'); iflags.last_msg = PLNMSG_OBJNAM_ONLY; } - otmp->was_dropped = 1; + otmp->how_lost = LOST_DROPPED; dropy(otmp); if (iflags.last_msg != PLNMSG_OBJNAM_ONLY) terse = FALSE; /* terse formatting has been interrupted */ diff --git a/src/steal.c b/src/steal.c index eff28499db..1ddf9da5bb 100644 --- a/src/steal.c +++ b/src/steal.c @@ -527,6 +527,7 @@ steal(struct monst* mtmp, char* objnambuf) (void) encumber_msg(); could_petrify = (otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm])); + otmp->how_lost = LOST_STOLEN; (void) mpickobj(mtmp, otmp); /* may free otmp */ if (could_petrify && !(mtmp->misc_worn_check & W_ARMG)) { minstapetrify(mtmp, TRUE); From e42706356044a5b52e30fd43fb243c11ce19f2cd Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Fri, 17 Nov 2023 12:23:49 -0500 Subject: [PATCH 59/78] Enable 'dropped_nopick' by default --- dat/opthelp | 2 +- doc/Guidebook.mn | 2 +- doc/Guidebook.tex | 2 +- include/optlist.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dat/opthelp b/dat/opthelp index 35337d1046..d865c468ce 100644 --- a/dat/opthelp +++ b/dat/opthelp @@ -17,7 +17,7 @@ cmdassist give help for errors on direction & other commands [True] color use different colors for objects on screen [True for micros] confirm ask before hitting tame or peaceful monsters [True] dark_room show floor not in sight in different color [True] -dropped_nopick exclude dropped objects from autopickup [False] +dropped_nopick exclude dropped objects from autopickup [True] eight_bit_tty send 8-bit characters straight to terminal [False] extmenu tty, curses: use menu for # (extended commands) [False] X11: menu has all commands (T) or traditional subset (F) diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index e634e6232b..f7d7c5f68f 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -3874,7 +3874,7 @@ picked up, even if .op autopickup is also on and they are in .op pickup_types -or match a positive autopickup exception (defualt off). Persistent. +or match a positive autopickup exception (defualt on). Persistent. .lp disclose Controls what information the program reveals when the game ends. Value is a space separated list of prompting/category pairs diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index 57fee57604..23ebe3a5e4 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -4228,7 +4228,7 @@ \subsection*{Customization options} If this option is on, items you dropped will not be automatically picked up, even if ``{\it autopickup\/}'' is also on and they are in ``{\it pickup\verb+_+types\/}'' or match a positive autopickup exception -(default off). Persistent. +(default on). Persistent. %.lp \item[\ib{disclose}] Controls what information the program reveals when the game ends. diff --git a/include/optlist.h b/include/optlist.h index 689810349e..ae866b5e1b 100644 --- a/include/optlist.h +++ b/include/optlist.h @@ -261,8 +261,8 @@ static int optfn_##a(int, int, boolean, char *, char *); NHOPTC(dogname, Advanced, PL_PSIZ, opt_in, set_gameview, No, Yes, No, No, NoAlias, "name of your starting pet if it is a little dog") - NHOPTB(dropped_nopick, Behavior, 0, opt_in, set_in_game, - Off, Yes, No, No, NoAlias, &flags.nopick_dropped, Term_False, + NHOPTB(dropped_nopick, Behavior, 0, opt_out, set_in_game, + On, Yes, No, No, NoAlias, &flags.nopick_dropped, Term_False, "don't autopickup dropped items") NHOPTC(dungeon, Advanced, MAXDCHARS + 1,opt_in, set_in_config, No, Yes, No, No, NoAlias, From c08304f875d0a3654c79b949c8b995806a49bd7a Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 8 Dec 2023 15:30:04 -0800 Subject: [PATCH 60/78] fixes entry for PR #1140 - nopick_dropped Pull request from entrez: add 'nopick_dropped' option of not pick up items dropped by hero via autopickup and 'pickup_stolen' to picup up items stolen from hero via autopickup, bypassing pickup_types and autopickup_exceptions like existing 'pickup_thrown'. This fixes entry commit also fixes the description of pickup_stolen. Closes #1140 --- doc/fixes3-7-0.txt | 4 ++++ include/optlist.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index d4902dc0b4..9280ea463b 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -2572,6 +2572,10 @@ add Unicode support to Qt (pr #910 by chasonr) add Unicode, IBMgraphics and DECgraphics support to X11 (pr #923 by chasonr) add some glue code for those that might wish to build with 3rd party fmod sound library support (pr #962 by MrEveryDay98) +add new options 'nopick_dropped' and 'pickup_stolen' options to avoid + auto-pickup of items dropped by hero and to auto-pickup things + previously stolen from hero if moved upon while autopickup is On; both + bypass pickup_types and autopickup_exceptions (pr #1140 by entrez) Code Cleanup and Reorganization diff --git a/include/optlist.h b/include/optlist.h index ae866b5e1b..e0abe2393c 100644 --- a/include/optlist.h +++ b/include/optlist.h @@ -536,7 +536,7 @@ static int optfn_##a(int, int, boolean, char *, char *); "maximum burden picked up before prompt") NHOPTB(pickup_stolen, Behavior, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias, &flags.pickup_stolen, Term_False, - "autopickup thrown items") + "autopickup stolen items") NHOPTB(pickup_thrown, Behavior, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias, &flags.pickup_thrown, Term_False, "autopickup thrown items") From c459630bf3179b4a92f8d47681854435bed08753 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 8 Dec 2023 15:49:16 -0800 Subject: [PATCH 61/78] bump EDITLEVEL for nopick_dropped+pickup_stolen Despite the tag on the pull request (#1140), I forgot to increment EDITLEVEL to reflect the new options' affect on old save files. --- include/patchlevel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/patchlevel.h b/include/patchlevel.h index 0abd715764..fca6e09580 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -1,4 +1,4 @@ -/* NetHack 3.7 patchlevel.h $NHDT-Date: 1686726254 2023/06/14 07:04:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.241 $ */ +/* NetHack 3.7 patchlevel.h $NHDT-Date: 1702079342 2023/12/08 23:49:02 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.247 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -17,7 +17,7 @@ * Incrementing EDITLEVEL can be used to force invalidation of old bones * and save files. */ -#define EDITLEVEL 92 +#define EDITLEVEL 93 /* * Development status possibilities. From 07ee773a0b4509c349782e4df34f5bc52df29a11 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Thu, 30 Nov 2023 14:17:08 -0500 Subject: [PATCH 62/78] Call hallu high priest "grand poohbah", not "high" "Grand poohbah" is a common term while "high poohbah" is not, and it seems appropriate for hallucinogen-distorted high priests. (It seems to most commonly be spelled "grand poobah" but I left that alone; "poohbah" seems like a decent compromise between that and the spelling of the character's name in the Mikado). --- src/priest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/priest.c b/src/priest.c index 21350e71b9..ae55e5787d 100644 --- a/src/priest.c +++ b/src/priest.c @@ -347,7 +347,7 @@ priestname( ; /* polymorphed priest; use ``what'' as is */ } else { if (high_priest) - Strcat(pname, "high "); + Strcat(pname, Hallucination ? "grand " : "high "); if (Hallucination) what = "poohbah"; else if (mon->female) From a6985b1f1a053f7a1d01a9cdf1e4fb8a0df066b4 Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 8 Dec 2023 19:45:07 -0500 Subject: [PATCH 63/78] Guidebook updates --- doc/Guidebook.mn | 2 +- doc/Guidebook.tex | 2 +- doc/Guidebook.txt | 3416 +++++++++++++++++++++++---------------------- 3 files changed, 1743 insertions(+), 1677 deletions(-) diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index f7d7c5f68f..b6b3564f6b 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -46,7 +46,7 @@ .ds f0 \*(vr .ds f1 \" empty .\"DO NOT REMOVE NH_DATESUB .ds f2 DATE(%B %-d, %Y) -.ds f2 "November 17, 2023 +.ds f2 December 08, 2023 . .\" A note on some special characters: .\" \(lq = left double quote diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index 23ebe3a5e4..380ece9c71 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -46,7 +46,7 @@ \author{Original version - Eric S. Raymond\\ (Edited and expanded for 3.7.0 by Mike Stephenson and others)} %DO NOT REMOVE NH_DATESUB \date{DATE(%B %-d, %Y)} -\date{November 27, 2023} +\date{December 08, 2023} \maketitle diff --git a/doc/Guidebook.txt b/doc/Guidebook.txt index 646525dbef..4e37d793df 100644 --- a/doc/Guidebook.txt +++ b/doc/Guidebook.txt @@ -15,25 +15,25 @@ Original version - Eric S. Raymond (Edited and expanded for NetHack 3.7.0 by Mike Stephenson and others) - November 13, 2023 + December 08, 2023 1. Introduction Recently, you have begun to find yourself unfulfilled and distant - in your daily occupation. Strange dreams of prospecting, stealing, - crusading, and combat have haunted you in your sleep for many months, - but you aren't sure of the reason. You wonder whether you have in - fact been having those dreams all your life, and somehow managed to - forget about them until now. Some nights you awaken suddenly and cry - out, terrified at the vivid recollection of the strange and powerful - creatures that seem to be lurking behind every corner of the dungeon - in your dream. Could these details haunting your dreams be real? As + in your daily occupation. Strange dreams of prospecting, stealing, + crusading, and combat have haunted you in your sleep for many months, + but you aren't sure of the reason. You wonder whether you have in + fact been having those dreams all your life, and somehow managed to + forget about them until now. Some nights you awaken suddenly and cry + out, terrified at the vivid recollection of the strange and powerful + creatures that seem to be lurking behind every corner of the dungeon + in your dream. Could these details haunting your dreams be real? As each night passes, you feel the desire to enter the mysterious caverns near the ruins grow stronger. Each morning, however, you quickly put the idea out of your head as you recall the tales of those who entered - the caverns before you and did not return. Eventually you can resist + the caverns before you and did not return. Eventually you can resist the yearning to seek out the fantastic place in your dreams no longer. After all, when other adventurers came back this way after spending time in the caverns, they usually seemed better off than when they @@ -41,15 +41,15 @@ who did not return had not just kept going? Asking around, you hear about a bauble, called the Amulet of Yen- - dor by some, which, if you can find it, will bring you great wealth. - One legend you were told even mentioned that the one who finds the + dor by some, which, if you can find it, will bring you great wealth. + One legend you were told even mentioned that the one who finds the amulet will be granted immortality by the gods. The amulet is rumored to be somewhere beyond the Valley of Gehennom, deep within the Mazes of Menace. Upon hearing the legends, you immediately realize that there is some profound and undiscovered reason that you are to descend - into the caverns and seek out that amulet of which they spoke. Even - if the rumors of the amulet's powers are untrue, you decide that you - should at least be able to sell the tales of your adventures to the + into the caverns and seek out that amulet of which they spoke. Even + if the rumors of the amulet's powers are untrue, you decide that you + should at least be able to sell the tales of your adventures to the local minstrels for a tidy sum, especially if you encounter any of the terrifying and magical creatures of your dreams along the way. You spend one last night fortifying yourself at the local inn, becoming @@ -70,35 +70,35 @@ - ancient ruins that mark the entrance to the Mazes of Menace. It is - late at night, so you make camp at the entrance and spend the night - sleeping under the open skies. In the morning, you gather your gear, + ancient ruins that mark the entrance to the Mazes of Menace. It is + late at night, so you make camp at the entrance and spend the night + sleeping under the open skies. In the morning, you gather your gear, eat what may be your last meal outside, and enter the dungeon.... 2. What is going on here? - You have just begun a game of NetHack. Your goal is to grab as - much treasure as you can, retrieve the Amulet of Yendor, and escape + You have just begun a game of NetHack. Your goal is to grab as + much treasure as you can, retrieve the Amulet of Yendor, and escape the Mazes of Menace alive. - Your abilities and strengths for dealing with the hazards of ad- + Your abilities and strengths for dealing with the hazards of ad- venture will vary with your background and training: - Archeologists understand dungeons pretty well; this enables them - to move quickly and sneak up on the local nasties. They start + Archeologists understand dungeons pretty well; this enables them + to move quickly and sneak up on the local nasties. They start equipped with the tools for a proper scientific expedition. - Barbarians are warriors out of the hinterland, hardened to bat- - tle. They begin their quests with naught but uncommon strength, a + Barbarians are warriors out of the hinterland, hardened to bat- + tle. They begin their quests with naught but uncommon strength, a trusty hauberk, and a great two-handed sword. Cavemen and Cavewomen start with exceptional strength but, unfor- tunately, with neolithic weapons. Healers are wise in medicine and apothecary. They know the herbs - and simples that can restore vitality, ease pain, anesthetize, and - neutralize poisons; and with their instruments, they can divine a be- - ing's state of health or sickness. Their medical practice earns them + and simples that can restore vitality, ease pain, anesthetize, and + neutralize poisons; and with their instruments, they can divine a be- + ing's state of health or sickness. Their medical practice earns them quite reasonable amounts of money, with which they enter the dungeon. Knights are distinguished from the common skirmisher by their de- @@ -126,7 +126,7 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -170,11 +170,11 @@ ground mine complex built by this race exists within the Mazes of Men- ace, filled with both riches and danger. - Humans are by far the most common race of the surface world, and - are thus the norm to which other races are often compared. Although + Humans are by far the most common race of the surface world, and + are thus the norm to which other races are often compared. Although they have no special abilities, they can succeed in any role. - Orcs are a cruel and barbaric race that hate every living thing + Orcs are a cruel and barbaric race that hate every living thing (including other orcs). Above all others, Orcs hate Elves with a pas- sion unequalled, and will go out of their way to kill one at any op- portunity. The armor and weapons fashioned by the Orcs are typically @@ -187,12 +187,12 @@ level, it appears on the screen in front of you. When NetHack's ancestor rogue first appeared, its screen orienta- - tion was almost unique among computer fantasy games. Since then, - screen orientation has become the norm rather than the exception; - NetHack continues this fine tradition. Unlike text adventure games + tion was almost unique among computer fantasy games. Since then, + screen orientation has become the norm rather than the exception; + NetHack continues this fine tradition. Unlike text adventure games - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -202,7 +202,7 @@ - that accept commands in pseudo-English sentences and explain the re- + that accept commands in pseudo-English sentences and explain the re- sults in words, NetHack commands are all one or two keystrokes and the results are displayed graphically on the screen. A minimum screen size of 24 lines by 80 columns is recommended; if the screen is @@ -212,53 +212,53 @@ of Braille readers or speech synthesisers. Instructions for configur- ing NetHack for the blind are included later in this document. - NetHack generates a new dungeon every time you play it; even the + NetHack generates a new dungeon every time you play it; even the authors still find it an entertaining and exciting game despite having won several times. NetHack offers a variety of display options. The options avail- able to you will vary from port to port, depending on the capabilities - of your hardware and software, and whether various compile-time op- + of your hardware and software, and whether various compile-time op- tions were enabled when your executable was created. The three possi- ble display options are: a monochrome character interface, a color character interface, and a graphical interface using small pictures called tiles. The two character interfaces allow fonts with other characters to be substituted, but the default assignments use standard - ASCII characters to represent everything. There is no difference be- - tween the various display options with respect to game play. Because - we cannot reproduce the tiles or colors in the Guidebook, and because - it is common to all ports, we will use the default ASCII characters - from the monochrome character display when referring to things you + ASCII characters to represent everything. There is no difference be- + tween the various display options with respect to game play. Because + we cannot reproduce the tiles or colors in the Guidebook, and because + it is common to all ports, we will use the default ASCII characters + from the monochrome character display when referring to things you might see on the screen during your game. - In order to understand what is going on in NetHack, first you - must understand what NetHack is doing with the screen. The NetHack - screen replaces the "You see ..." descriptions of text adventure + In order to understand what is going on in NetHack, first you + must understand what NetHack is doing with the screen. The NetHack + screen replaces the "You see ..." descriptions of text adventure games. Figure 1 is a sample of what a NetHack screen might look like. The way the screen looks for you depends on your platform. - +---------------------------------------------------------------+ - |The bat bites! | - | | - | ------ | - | |....| ---------- | - | |.<..|####...@...$.| | - | |....-# |...B....+ | - | |....| |.d......| | - | ------ -------|-- | - | | - | | - | | - |Player the Rambler St:12 Dx:7 Co:18 In:11 Wi:9 Ch:15 Neutral | - |Dlvl:1 $:993 HP:9(12) Pw:3(3) AC:10 Exp:1/19 T:752 Hungry Conf | - +---------------------------Figure-1----------------------------+ + +----------------------------------------------------------------+ + | The bat bites! | + | | + | ------ | + | |....| ---------- | + | |.<..|####...@...$.| | + | |....-# |...B....+ | + | |....| |.d......| | + | ------ -------|-- | + | | + | | + | | + | Player the Rambler St:12 Dx:7 Co:18 In:11 Wi:9 Ch:15 Neutral | + | Dlvl:1 $:993 HP:9(12) Pw:3(3) AC:10 Exp:1/19 T:752 Hungry Conf | + +----------------------------------------------------------------+ + Figure 1 - - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -268,11 +268,12 @@ - +---------------------------------------------------------------+ - |Player the Rambler St:12 Dx:7 Co:18 In:11 Wi:9 Ch:15 | - |Neutral $:993 HP:9(12) Pw:3(3) AC:10 Exp:1/19 Hungry | - |Dlvl:1 T:752 Conf | - +---------------------------Figure-2----------------------------+ + +----------------------------------------------------------------+ + | Player the Rambler St:12 Dx:7 Co:18 In:11 Wi:9 Ch:15 | + | Neutral $:993 HP:9(12) Pw:3(3) AC:10 Exp:1/19 Hungry | + | Dlvl:1 T:752 Conf | + +----------------------------------------------------------------+ + Figure 2 3.1. The status lines (bottom) @@ -280,11 +281,11 @@ cryptic pieces of information describing your current status. Figure 1 shows the traditional two-line status area below the map. Figure 2 shows just the status area, when the statuslines:3 option has been set - (not all interfaces support this option). If any status line becomes - wider than the screen, you might not see all of it due to truncation. - When the numbers grow bigger and multiple conditions are present, the - two-line format will run out of room on the second line, but sta- - tuslines:2 is the default because a basic 24-line terminal isn't tall + (not all interfaces support this option). If any status line becomes + wider than the screen, you might not see all of it due to truncation. + When the numbers grow bigger and multiple conditions are present, the + two-line format will run out of room on the second line, but sta- + tuslines:2 is the default because a basic 24-line terminal isn't tall enough for the third line. Here are explanations of what the various status items mean: @@ -295,22 +296,22 @@ Strength A measure of your character's strength; one of your six basic at- - tributes. A human character's attributes can range from 3 to 18 - inclusive; non-humans may exceed these limits (occasionally you - may get super-strengths of the form 18/xx, and magic can also - cause attributes to exceed the normal limits). The higher your - strength, the stronger you are. Strength affects how success- - fully you perform physical tasks, how much damage you do in com- + tributes. A human character's attributes can range from 3 to 18 + inclusive; non-humans may exceed these limits (occasionally you + may get super-strengths of the form 18/xx, and magic can also + cause attributes to exceed the normal limits). The higher your + strength, the stronger you are. Strength affects how success- + fully you perform physical tasks, how much damage you do in com- bat, and how much loot you can carry. Dexterity - Dexterity affects your chances to hit in combat, to avoid traps, + Dexterity affects your chances to hit in combat, to avoid traps, and do other tasks requiring agility or manipulation of objects. Constitution - Constitution affects your ability to recover from injuries and - other strains on your stamina. When strength is low or modest, - constitution also affects how much you can carry. With suffi- + Constitution affects your ability to recover from injuries and + other strains on your stamina. When strength is low or modest, + constitution also affects how much you can carry. With suffi- ciently high strength, the contribution to carrying capacity from your constitution no longer matters. @@ -323,8 +324,7 @@ dealing with magic). It affects your magical energy. - - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -339,17 +339,17 @@ ticular, it can affect the prices shopkeepers offer you. Alignment - Lawful, Neutral, or Chaotic. Often, Lawful is taken as good and - Chaotic as evil, but legal and ethical do not always coincide. - Your alignment influences how other monsters react toward you. - Monsters of a like alignment are more likely to be non-aggres- - sive, while those of an opposing alignment are more likely to be + Lawful, Neutral, or Chaotic. Often, Lawful is taken as good and + Chaotic as evil, but legal and ethical do not always coincide. + Your alignment influences how other monsters react toward you. + Monsters of a like alignment are more likely to be non-aggres- + sive, while those of an opposing alignment are more likely to be seriously offended at your presence. Dungeon Level - How deep you are in the dungeon. You start at level one and the - number increases as you go deeper into the dungeon. Some levels - are special, and are identified by a name and not a number. The + How deep you are in the dungeon. You start at level one and the + number increases as you go deeper into the dungeon. Some levels + are special, and are identified by a name and not a number. The Amulet of Yendor is reputed to be somewhere beneath the twentieth level. @@ -360,37 +360,37 @@ Hit Points Your current and maximum hit points. Hit points indicate how much damage you can take before you die. The more you get hit in - a fight, the lower they get. You can regain hit points by rest- - ing, or by using certain magical items or spells. The number in + a fight, the lower they get. You can regain hit points by rest- + ing, or by using certain magical items or spells. The number in parentheses is the maximum number your hit points can reach. Power - Spell points. This tells you how much mystic energy (mana) you + Spell points. This tells you how much mystic energy (mana) you have available for spell casting. Again, resting will regenerate the amount available. Armor Class A measure of how effectively your armor stops blows from un- friendly creatures. The lower this number is, the more effective - the armor; it is quite possible to have negative armor class. + the armor; it is quite possible to have negative armor class. See the Armor subsection of Objects for more information. Experience - Your current experience level. If the showexp option is set, it + Your current experience level. If the showexp option is set, it will be followed by a slash and experience points. As you adven- ture, you gain experience points. At certain experience point totals, you gain an experience level. The more experienced you are, the better you fight and withstand magical attacks. (By the - time your level reaches double digits, the usefulness of showing - the points with it has dropped significantly. You can use the - `O' command to turn showexp off to avoid using up the limited + time your level reaches double digits, the usefulness of showing + the points with it has dropped significantly. You can use the + `O' command to turn showexp off to avoid using up the limited status line space.) Time - The number of turns elapsed so far, displayed if you have the + The number of turns elapsed so far, displayed if you have the - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -403,13 +403,13 @@ time option set. Status - Hunger: your current hunger status. Values are Satiated, Not - Hungry (or Normal), Hungry, Weak, and Fainting. Not shown when + Hunger: your current hunger status. Values are Satiated, Not + Hungry (or Normal), Hungry, Weak, and Fainting. Not shown when Normal. - Encumbrance: an indication of how what you are carrying affects - your ability to move. Values are Unencumbered, Burdened, - Stressed, Strained, Overtaxed, and Overloaded. Not shown when + Encumbrance: an indication of how what you are carrying affects + your ability to move. Values are Unencumbered, Burdened, + Stressed, Strained, Overtaxed, and Overloaded. Not shown when Unencumbered. Fatal conditions: Stone (aka Petrifying, turning to stone), Slime @@ -426,8 +426,8 @@ Other conditions and modifiers exist, but there isn't enough room to display them with the other status fields. - The #attributes command (default key ^X) will show all current status - information in unabbreviated format. It also shows other information + The #attributes command (default key ^X) will show all current status + information in unabbreviated format. It also shows other information which might be included on the status lines if those had more room. 3.2. The message line (top) @@ -447,7 +447,7 @@ The rest of the screen is the map of the level as you have ex- plored it so far. Each symbol on the screen represents something. You can set various graphics options to change some of the symbols the - game uses; otherwise, the game will use default symbols. Here is a + game uses; otherwise, the game will use default symbols. Here is a list of what the default symbols mean: - and | @@ -456,7 +456,7 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -468,14 +468,14 @@ . The floor of a room, ice, or a doorless doorway. - # A corridor, or iron bars, or a tree, or possibly a kitchen sink + # A corridor, or iron bars, or a tree, or possibly a kitchen sink (if your dungeon has sinks), or a drawbridge. > Stairs down: a way to the next level. < Stairs up: a way to the previous level. - + A closed door, or a spellbook containing a spell you may be able + + A closed door, or a spellbook containing a spell you may be able to learn. @ Your character or a human. @@ -517,12 +517,12 @@ \ An opulent throne. a-zA-Z and other symbols - Letters and certain other symbols represent the various inhabi- - tants of the Mazes of Menace. Watch out, they can be nasty and + Letters and certain other symbols represent the various inhabi- + tants of the Mazes of Menace. Watch out, they can be nasty and vicious. Sometimes, however, they can be helpful. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -532,7 +532,7 @@ - I This marks the last known location of an invisible or otherwise + I This marks the last known location of an invisible or otherwise unseen monster. Note that the monster could have moved. The `F' and `m' commands may be useful here. @@ -560,7 +560,7 @@ dicating that you may choose an object not on the list, if you wanted to use something unexpected. Typing a `*' lists your entire inven- tory, so you can see the inventory letters of every object you're car- - rying. Finally, if you change your mind and decide you don't want to + rying. Finally, if you change your mind and decide you don't want to do this command after all, you can press the ESC key to abort the com- mand. @@ -578,17 +578,17 @@ ? Help menu: display one of several help texts available. - / The "whatis" command, to tell what a symbol represents. You may - choose to specify a location or type a symbol (or even a whole - word) to explain. Specifying a location is done by moving the - cursor to a particular spot on the map and then pressing one of + / The "whatis" command, to tell what a symbol represents. You may + choose to specify a location or type a symbol (or even a whole + word) to explain. Specifying a location is done by moving the + cursor to a particular spot on the map and then pressing one of `.', `,', `;', or `:'. `.' will explain the symbol at the chosen location, conditionally check for "More info?" depending upon whether the help option is on, and then you will be asked to pick - another location; `,' will explain the symbol but skip any + another location; `,' will explain the symbol but skip any - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -598,47 +598,48 @@ - additional information, then let you pick another location; `;' - will skip additional info and also not bother asking you to - choose another location to examine; `:' will show additional - info, if any, without asking for confirmation. When picking a - location, pressing the ESC key will terminate this command, or + additional information, then let you pick another location; `;' + will skip additional info and also not bother asking you to + choose another location to examine; `:' will show additional + info, if any, without asking for confirmation. When picking a + location, pressing the ESC key will terminate this command, or pressing `?' will give a brief reminder about how it works. If the autodescribe option is on, a short description of what you see at each location is shown as you move the cursor. Typing `#' - while picking a location will toggle that option on or off. The - whatis_coord option controls whether the short description in- + while picking a location will toggle that option on or off. The + whatis_coord option controls whether the short description in- cludes map coordinates. - Specifying a name rather than a location always gives any addi- + Specifying a name rather than a location always gives any addi- tional information available about that name. - You may also request a description of nearby monsters, all mon- - sters currently displayed, nearby objects, or all objects. The - whatis_coord option controls which format of map coordinate is + You may also request a description of nearby monsters, all mon- + sters currently displayed, nearby objects, or all objects. The + whatis_coord option controls which format of map coordinate is included with their descriptions. & Tell what a command does. - < Go up to the previous level (if you are on a staircase or lad- + < Go up to the previous level (if you are on a staircase or lad- der). > Go down to the next level (if you are on a staircase or ladder). [yuhjklbn] - Go one step in the direction indicated (see Figure 3). If you + Go one step in the direction indicated (see Figure 3). If you sense or remember a monster there, you will fight the monster in- stead. Only these one-step movement commands cause you to fight monsters; the others (below) are "safe." - +----------------------------------------------------------------+ - | y k u 7 8 9 | - | \ | / \ | / | - | h- . -l 4- . -6 | - | / | \ / | \ | - | b j n 1 2 3 | - | (number_pad off) (number_pad on) | - +---------------------------Figure-3-----------------------------+ + +-----------------------------------------------------+ + | y k u 7 8 9 | + | \ | / \ | / | + | h- . -l 4- . -6 | + | / | \ / | \ | + | b j n 1 2 3 | + | (number_pad off) (number_pad on) | + +-----------------------------------------------------+ + Figure 3 [YUHJKLBN] Go in that direction until you hit a wall or run into something. @@ -651,10 +652,9 @@ ing via menu (to temporarily override the menustyle:traditional option). Primarily useful for `,' (pickup) when there is only one class of objects present (where there won't be any "what - kinds of objects?" prompt, so no opportunity to answer `m' at - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -664,13 +664,14 @@ + kinds of objects?" prompt, so no opportunity to answer `m' at that prompt). The prefix will make "#travel" command show a menu of interesting - targets in sight. It can also be used with the `\' (known, show + targets in sight. It can also be used with the `\' (known, show a list of all discovered objects) and the ``' (knownclass, show a list of discovered objects in a particular class) commands to of- - fer a menu of several sorting alternatives (which sets a new + fer a menu of several sorting alternatives (which sets a new value for the sortdiscoveries option); also for "#vanquished" and "#genocided" commands to offer a sorting menu. @@ -703,24 +704,23 @@ Old versions supported `M' as a movement prefix which combined the effect of `m' with +. That is no longer supported as a prefix but similar effect can be achieved by using - `m' and G in combination. m can also be used in com- + `m' and G in combination. m can also be used in com- bination with g, +, or +. _ Travel to a map location via a shortest-path algorithm. - The shortest path is computed over map locations the hero knows - about (e.g. seen or previously traversed). If there is no known - path, a guess is made instead. Stops on most of the same condi- - tions as the `G' prefix, but without picking up objects, so im- - plicitly forces the `m' prefix. For ports with mouse support, - the command is also invoked when a mouse-click takes place on a + The shortest path is computed over map locations the hero knows + about (e.g. seen or previously traversed). If there is no known + path, a guess is made instead. Stops on most of the same condi- + tions as the `G' prefix, but without picking up objects, so im- + plicitly forces the `m' prefix. For ports with mouse support, + the command is also invoked when a mouse-click takes place on a location other than the current position. - - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -786,7 +786,7 @@ and novelty (`P', recently picked up items; controlled by picking - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -800,7 +800,7 @@ If you specify more than one value in a category (such as "!?" for potions and scrolls or "BU" for blessed and uncursed), an in- - ventory object will meet the criteria if it matches any of the + ventory object will meet the criteria if it matches any of the specified values (so "!?" means `!' or `?'). If you specify more than one category, an inventory object must meet each of the cat- egory criteria (so "%u" means class `%' and unpaid `u'). Lastly, @@ -829,16 +829,16 @@ E- - write in the dust with your fingers. Engraving the word "Elbereth" will cause most monsters to not at- - tack you hand-to-hand (but if you attack, you will rub it out); + tack you hand-to-hand (but if you attack, you will rub it out); this is often useful to give yourself a breather. - f Fire (shoot or throw) one of the objects placed in your quiver - (or quiver sack, or that you have at the ready). You may select - ammunition with a previous `Q' command, or let the computer pick - something appropriate if autoquiver is true. If your wielded - weapon has the throw-and-return property, your quiver is empty, - and autoquiver is false, you will throw that wielded weapon in- - stead of filling the quiver. This will also automatically use a + f Fire (shoot or throw) one of the objects placed in your quiver + (or quiver sack, or that you have at the ready). You may select + ammunition with a previous `Q' command, or let the computer pick + something appropriate if autoquiver is true. If your wielded + weapon has the throw-and-return property, your quiver is empty, + and autoquiver is false, you will throw that wielded weapon in- + stead of filling the quiver. This will also automatically use a polearm if wielded. If fireassist is true, firing will automati- cally try to wield a launcher (for example, a bow or a sling) matching the ammo in the quiver; this might take multiple turns, @@ -852,7 +852,7 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -882,29 +882,29 @@ A menu showing the current option values will be displayed. You can change most values simply by selecting the menu entry for the - given option (ie, by typing its letter or clicking upon it, de- - pending on your user interface). For the non-boolean choices, a - further menu or prompt will appear once you've closed this menu. - The available options are listed later in this Guidebook. Op- - tions are usually set before the game rather than with the `O' - command; see the section on options below. Precede `O' with the + given option (ie, by typing its letter or clicking upon it, de- + pending on your user interface). For the non-boolean choices, a + further menu or prompt will appear once you've closed this menu. + The available options are listed later in this Guidebook. Op- + tions are usually set before the game rather than with the `O' + command; see the section on options below. Precede `O' with the `m' prefix to show advanced options. ^O Show overview. - Shortcut for "#overview": list interesting dungeon levels vis- + Shortcut for "#overview": list interesting dungeon levels vis- ited. - (Prior to 3.6.0, `^O' was a debug mode command which listed the - placement of all special levels. Use "#wizwhere" to run that + (Prior to 3.6.0, `^O' was a debug mode command which listed the + placement of all special levels. Use "#wizwhere" to run that command.) p Pay your shopping bill. P Put on an accessory (ring, amulet, or blindfold). - This command may also be used to wear armor. The prompt for - which inventory item to use will only list accessories, but + This command may also be used to wear armor. The prompt for + which inventory item to use will only list accessories, but choosing an unlisted item of armor will attempt to wear it. (See the `W' command below. It lists armor as the inventory choices but will accept an accessory and attempt to put that on.) @@ -918,7 +918,7 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -930,10 +930,10 @@ When there is a fountain or sink present, it asks whether to drink from that. If that is declined, then it offers a chance to - choose a potion from inventory. Precede `q' with the `m' prefix + choose a potion from inventory. Precede `q' with the `m' prefix to skip asking about drinking from a fountain or sink. - Q Select an object for your quiver, quiver sack, or just generally + Q Select an object for your quiver, quiver sack, or just generally at the ready (only one of these is available at a time). You can then throw this (or one of these) using the `f' command. @@ -946,16 +946,16 @@ be removed without asking, but you can set the paranoid_confirma- tion:Remove option to require a prompt. - This command may also be used to take off armor. The prompt for - which inventory item to remove only lists worn accessories, but + This command may also be used to take off armor. The prompt for + which inventory item to remove only lists worn accessories, but an item of worn armor can be chosen. (See the `T' command below. It lists armor as the inventory choices but will accept an acces- sory and attempt to remove it.) ^R Redraw the screen. - s Search for secret doors and traps around you. It usually takes - several tries to find something. Precede with the `m' prefix to + s Search for secret doors and traps around you. It usually takes + several tries to find something. Precede with the `m' prefix to search for a turn even next to a hostile monster, if safe_wait is on. @@ -979,12 +979,12 @@ t Throw an object or shoot a projectile. There's no separate "shoot" command. If you throw an arrow while - wielding a bow, you are shooting that arrow and any weapon skill - bonus or penalty for bow applies. If you throw an arrow while - not wielding a bow, you are throwing it by hand and it will + wielding a bow, you are shooting that arrow and any weapon skill + bonus or penalty for bow applies. If you throw an arrow while + not wielding a bow, you are throwing it by hand and it will - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -1010,8 +1010,8 @@ This command may also be used to remove accessories. The prompt for which inventory item to take off only lists worn armor, but a - worn accessory can be chosen. (See the `R' command above. It - lists accessories as the inventory choices but will accept an + worn accessory can be chosen. (See the `R' command above. It + lists accessories as the inventory choices but will accept an item of armor and attempt to take it off.) ^T Teleport, if you have the ability. @@ -1024,33 +1024,33 @@ w- - wield nothing, use your bare (or gloved) hands. - Some characters can wield two weapons at once; use the `X' com- + Some characters can wield two weapons at once; use the `X' com- mand (or the "#twoweapon" extended command) to do so. W Wear armor. - This command may also be used to put on an accessory (ring, - amulet, or blindfold). The prompt for which inventory item to + This command may also be used to put on an accessory (ring, + amulet, or blindfold). The prompt for which inventory item to use will only list armor, but choosing an unlisted accessory will attempt to put it on. (See the `P' command above. It lists ac- cessories as the inventory choices but will accept an item of ar- mor and attempt to wear it.) - x Exchange your wielded weapon with the item in your alternate + x Exchange your wielded weapon with the item in your alternate weapon slot. The latter is used as your secondary weapon when engaging in two- weapon combat. Note that if one of these slots is empty, the ex- change still takes place. - X Toggle two-weapon combat, if your character can do it. Also + X Toggle two-weapon combat, if your character can do it. Also available via the "#twoweapon" extended command. - (In versions prior to 3.6 this keystroke ran the command to + (In versions prior to 3.6 this keystroke ran the command to switch from normal play to "explore mode", also known as - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -1060,16 +1060,16 @@ - "discovery mode", which has now been moved to "#exploremode" and + "discovery mode", which has now been moved to "#exploremode" and M-X.) ^X Display basic information about your character. - Displays name, role, race, gender (unless role name makes that - redundant, such as Caveman or Priestess), and alignment, along - with your patron deity and his or her opposition. It also shows - most of the various items of information from the status line(s) - in a less terse form, including several additional things which + Displays name, role, race, gender (unless role name makes that + redundant, such as Caveman or Priestess), and alignment, along + with your patron deity and his or her opposition. It also shows + most of the various items of information from the status line(s) + in a less terse form, including several additional things which don't appear in the normal status display due to space considera- tions. @@ -1085,7 +1085,7 @@ Z. - to cast at yourself, use `.' for the direction. - ^Z Suspend the game (UNIX(R) versions with job control only). See + ^Z Suspend the game (UNIX(R) versions with job control only). See "#suspend" below for more details. : Look at what is here. @@ -1116,7 +1116,7 @@ (R)UNIX is a registered trademark of The Open Group. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -1174,15 +1174,15 @@ on others. It is sometimes displayed as ^? even though that is not an actual control character. - Many terminals have an option to swap the and - keys, so typing the key might not execute this - command. If that happens, you can use the extended command - "#terrain" instead. + Many terminals have an option to swap the and keys, so typing the key might not execute this com- + mand. If that happens, you can use the extended command "#ter- + rain" instead. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -1198,20 +1198,20 @@ As you can see, the authors of NetHack used up all the letters, so this is a way to introduce the less frequently used commands. What - extended commands are available depends on what features the game was + extended commands are available depends on what features the game was compiled with. #adjust - Adjust inventory letters (most useful when the fixinv option is + Adjust inventory letters (most useful when the fixinv option is "on"). Autocompletes. Default key is `M-a'. - This command allows you to move an item from one particular in- - ventory slot to another so that it has a letter which is more - meaningful for you or that it will appear in a particular loca- - tion when inventory listings are displayed. You can move to a - currently empty slot, or if the destination is occupied--and - won't merge--the item there will swap slots with the one being - moved. "#adjust" can also be used to split a stack of objects; + This command allows you to move an item from one particular in- + ventory slot to another so that it has a letter which is more + meaningful for you or that it will appear in a particular loca- + tion when inventory listings are displayed. You can move to a + currently empty slot, or if the destination is occupied--and + won't merge--the item there will swap slots with the one being + moved. "#adjust" can also be used to split a stack of objects; when choosing the item to adjust, enter a count prior to its let- ter. @@ -1222,7 +1222,7 @@ same name or with no name will merge provided that all their other attributes match. If it does not have a name, only other stacks with no name are eligible. In either case, otherwise com- - patible stacks with a different name will not be merged. This + patible stacks with a different name will not be merged. This contrasts with using "#adjust" to move from one slot to a differ- ent slot. In that situation, moving (no count given) a compati- ble stack will merge if either stack has a name when the other @@ -1248,7 +1248,7 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -1294,7 +1294,7 @@ Dip an object into something. Autocompletes. Default key is `M- d'. - The `m' prefix skips dipping into a fountain or pool if there is + The `m' prefix skips dipping into a fountain or pool if there is one at your location. #down @@ -1307,14 +1307,14 @@ Drop specific item types. Default key is `D'. #eat - Eat something. Default key is `e'. The `m' prefix skips eating + Eat something. Default key is `e'. The `m' prefix skips eating items on the floor. #engrave Engrave writing on the floor. Default key is `E'. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -1325,7 +1325,7 @@ #enhance - Advance or check weapon and spell skills. Autocompletes. De- + Advance or check weapon and spell skills. Autocompletes. De- fault key is `M-e'. #exploremode @@ -1354,13 +1354,13 @@ tinct. The display order is the same as is used by #vanquished. The `m' - prefix brings up a menu of available sorting orders, and doing - that for either #genocided or #vanquished changes the order for + prefix brings up a menu of available sorting orders, and doing + that for either #genocided or #vanquished changes the order for both. - If the sorting order is "count high to low" or "count low to - high" (which are applicable for #vanquished), that will be ig- - nored for #genocided and alphabetical will be used instead. The + If the sorting order is "count high to low" or "count low to + high" (which are applicable for #vanquished), that will be ig- + nored for #genocided and alphabetical will be used instead. The menu omits those two choices when used for #genocide. Autocompletes. Default key is `M-g'. @@ -1380,7 +1380,7 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -1423,7 +1423,7 @@ played. #knownclass - Show discovered types for one class of objects. Default key is + Show discovered types for one class of objects. Default key is ``'. The `m' prefix operates the same as for "#known". @@ -1438,15 +1438,15 @@ Look at what is here, under you. Default key is `:'. #loot - Loot a box or bag on the floor beneath you, or the saddle from a + Loot a box or bag on the floor beneath you, or the saddle from a steed standing next to you. Autocompletes. Precede with the `m' prefix to skip containers at your location and go directly to re- - moving a saddle. Default key is `M-l', and also `l' if num- + moving a saddle. Default key is `M-l', and also `l' if num- ber_pad is on. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -1457,11 +1457,11 @@ #monster - Use a monster's special ability (when polymorphed into monster + Use a monster's special ability (when polymorphed into monster form). Autocompletes. Default key is `M-m'. #name - Name a monster, an individual object, or a type of object. Same + Name a monster, an individual object, or a type of object. Same as "#call". Autocompletes. Default keys are `N', `M-n', and `M- N'. @@ -1512,7 +1512,7 @@ tion:quit option to require a response of yes instead. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -1526,10 +1526,10 @@ Pay your shopping bill. Default key is `p'. #perminv - If persistent inventory display is supported and enabled (with - the perm_invent option), interact with it instead of with the - map. You'll be prompted for menu scrolling keystrokes such as - `>' and `<'. Press Return or Escape to resume normal play. De- + If persistent inventory display is supported and enabled (with + the perm_invent option), interact with it instead of with the + map. You'll be prompted for menu scrolling keystrokes such as + `>' and `<'. Press Return or Escape to resume normal play. De- fault key is `|'. #pickup @@ -1578,7 +1578,7 @@ Read a scroll, a spellbook, or something else. Default key is - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -1644,7 +1644,7 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 @@ -1654,25 +1654,48 @@ + Will display in-use items in a menu even when there is only one. + #seeamulet Show the amulet currently worn. Default key is `"'. + Using the `m' prefix will force the display of a worn amulet in a + menu rather than with just a message. + #seearmor Show the armor currently worn. Default key is `['. + Will display worn armor in a menu even when there is only thing + worn. + #seerings Show the ring(s) currently worn. Default key is `='. + Will display worn rings in a menu if there are two (or there is + just one and is a meat ring rather than a "real" ring). Use the + `m' prefix to force a menu for one ring. + #seetools Show the tools currently in use. Default key is `('. + Will display the result in a message if there is one tool in use + (worn blindfold or towel or lenses, lit lamp(s) and/or candle(s), + leashes attached to pets). Will display a menu if there are more + than one or if the command is preceded by the `m' prefix. + #seeweapon Show the weapon currently wielded. Default key is `)'. + If dual-wielding, a separate message about the secondary weapon + will be given. Using the `m' prefix will force a menu and it + will include primary weapon, alternate weapon even when not dual- + wielding, and also whatever is currently assigned to the quiver + slot. + #shell - Do a shell escape, switching from NetHack to a subprocess. Can - be disabled at the time the program is built. When enabled, ac- - cess for specific users can be controlled by the system configu- + Do a shell escape, switching from NetHack to a subprocess. Can + be disabled at the time the program is built. When enabled, ac- + cess for specific users can be controlled by the system configu- ration file. Use the shell command `exit' to return to the game. Default key is `!'. @@ -1684,6 +1707,19 @@ #showspells List and reorder known spells. Default key is `+'. + + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 27 + + + #showtrap Describe an adjacent trap, possibly covered by objects or a mon- ster. To be eligible, the trap must already be discovered. (The @@ -1707,19 +1743,6 @@ #swap Swap wielded and secondary weapons. Default key is `x'. - - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 27 - - - #takeoff Take off one piece of armor. Default key is `T'. @@ -1750,14 +1773,27 @@ #throw Throw something. Default key is `t'. + + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 28 + + + #timeout Look at the timeout queue. Autocompletes. Debug mode only. #tip Tip over a container (bag or box) to pour out its contents. When - there are containers on the floor, the game will prompt to pick - one of them or "tip something being carried". If the latter is - chosen, there will be another prompt for which item from inven- + there are containers on the floor, the game will prompt to pick + one of them or "tip something being carried". If the latter is + chosen, there will be another prompt for which item from inven- tory to tip. The `m' prefix makes the command skip containers on the floor and @@ -1775,32 +1811,21 @@ line will show "(no travel path)" if your character does not know of a path to that location. See also #retravel. - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 28 - - - #turn Turn undead away. Autocompletes. Default key is `M-t'. #twoweapon - Toggle two-weapon combat on or off. Autocompletes. Default key + Toggle two-weapon combat on or off. Autocompletes. Default key is `X', and also `M-2' if number_pad is off. - Note that you must use suitable weapons for this type of combat, + Note that you must use suitable weapons for this type of combat, or it will be automatically turned off. #untrap - Untrap something (trap, door, or chest). Default key is `M-u', + Untrap something (trap, door, or chest). Default key is `M-u', and `u' if number_pad is on. - In some circumstances it can also be used to rescue trapped mon- + In some circumstances it can also be used to rescue trapped mon- sters. #up @@ -1809,17 +1834,29 @@ #vanquished List vanquished monsters by type and count. - 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) + 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) or were already corpses when placed on the map. - Using the "request menu" prefix prior to #vanquished brings up a - menu of sorting orders available (provided that the vanquished - monsters list contains at least two types of monsters). Which- - ever ordering is picked gets assigned to the sortvanquished op- - tion so is remembered for subsequent #vanquished requests. The + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 29 + + + + Using the "request menu" prefix prior to #vanquished brings up a + menu of sorting orders available (provided that the vanquished + monsters list contains at least two types of monsters). + Whichever ordering is picked gets assigned to the sortvanquished + option so is remembered for subsequent #vanquished requests. The "#genocided" command shares this sorting order. During end-of-game disclosure, when asked whether to show van- @@ -1840,18 +1877,6 @@ #versionshort Show the program's version number, plus the date and time that - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 29 - - - the running copy was built from sources (not the version's re- lease date). Default key is `v'. @@ -1882,16 +1907,27 @@ Show monster birth, death, genocide, and extinct statistics. De- bug mode only. + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 30 + + + #wizbury - Bury objects under and around you. Autocompletes. Debug mode + Bury objects under and around you. Autocompletes. Debug mode only. #wizcast Cast any spell. Debug mode only. #wizdetect - Reveal hidden things (secret doors or traps or unseen monsters) - within a modest radius. No time elapses. Autocompletes. Debug + Reveal hidden things (secret doors or traps or unseen monsters) + within a modest radius. No time elapses. Autocompletes. Debug mode only. Default key is `^E'. #wizgenesis @@ -1906,22 +1942,10 @@ Set one or more intrinsic attributes. Autocompletes. Debug mode only. - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 30 - - - #wizkill - Remove monsters from play by just pointing at them. By default - the hero gets credit or blame for killing the targets. Precede - this command with the `m' prefix to override that. Autocom- + Remove monsters from play by just pointing at them. By default + the hero gets credit or blame for killing the targets. Precede + this command with the `m' prefix to override that. Autocom- pletes. Debug mode only. #wizlevelport @@ -1948,6 +1972,18 @@ #wizsmell Smell monster. Autocompletes. Debug mode only. + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 31 + + + #wizwhere Show locations of special levels. Autocompletes. Debug mode only. @@ -1972,30 +2008,18 @@ "high"] bit), you can invoke many extended commands by meta-ing the first letter of the command. - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 31 - - - On Windows and MS-DOS, the "Alt" key can be used in this fashion. - On other systems, if typing "Alt" plus another key transmits a two - character sequence consisting of an Escape followed by the other key, - you may set the altmeta option to have NetHack combine them into - meta+. (This combining action only takes place when NetHack is + On other systems, if typing "Alt" plus another key transmits a two + character sequence consisting of an Escape followed by the other key, + you may set the altmeta option to have NetHack combine them into + meta+. (This combining action only takes place when NetHack is expecting a command to execute, not when accepting input to name some- thing or to make a wish.) Unlike control characters, where ^x and ^X denote the same thing, - meta characters are case-sensitive: M-x and M-X represent different - things. Some commands which can be run via a meta character require - that the letter be capitalized because the lower-case equivalent is + meta characters are case-sensitive: M-x and M-X represent different + things. Some commands which can be run via a meta character require + that the letter be capitalized because the lower-case equivalent is used for another command, so the three key combination meta+Shift+ is needed. @@ -2014,6 +2038,18 @@ M-d #dip + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 32 + + + M-e #enhance M-f #force @@ -2038,18 +2074,6 @@ M-r #rub - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 32 - - - M-R #ride M-s #sit @@ -2070,7 +2094,7 @@ - If the number_pad option is on, some additional letter commands + If the number_pad option is on, some additional letter commands are available: h #help @@ -2079,6 +2103,19 @@ k #kick + + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 33 + + + l #loot N #name @@ -2088,100 +2125,88 @@ 5. Rooms and corridors - Rooms and corridors in the dungeon are either lit or dark. Any - lit areas within your line of sight will be displayed; dark areas are - only displayed if they are within one space of you. Walls and corri- + Rooms and corridors in the dungeon are either lit or dark. Any + lit areas within your line of sight will be displayed; dark areas are + only displayed if they are within one space of you. Walls and corri- dors remain on the map as you explore them. Secret corridors are hidden and appear to be solid rock. You can find them with the `s' (search) command when adjacent to them. Multi- - ple search attempts may be needed. When searching is successful, se- + ple search attempts may be needed. When searching is successful, se- cret corridors become ordinary open corridor locations. Mapping magic reveals secret corridors, so converts them into ordinary corridors and shows them as such. 5.1. Doorways - Doorways connect rooms and corridors. Some doorways have no - doors; you can walk right through. Others have doors in them, which + Doorways connect rooms and corridors. Some doorways have no + doors; you can walk right through. Others have doors in them, which + may be open, closed, or locked. To open a closed door, use the `o' + (open) command; to close it again, use the `c' (close) command. By + default the autoopen option is enabled, so simply attempting to walk + onto a closed door's location will attempt to open it without needing + `o'. Opening via autoopen will not work if you are confused or + stunned or suffer from the fumbling attribute. + Open doors cannot be entered diagonally; you must approach them + straight on, horizontally or vertically. Doorways without doors are + not restricted in this fashion except on one particular level (de- + scribed by "#overview" as "a primitive area"). - NetHack 3.7.0 November 13, 2023 + Unlocking magic exists but usually won't be available early on. + You can get through a locked door without magic by first using an un- + locking tool with the `a' (apply) command, and then opening it. By + default the autounlock option is also enabled, so if you attempt to + open (via `o' or autoopen) a locked door while carrying an unlocking + tool, you'll be asked whether to use it on the door's lock. Alterna- + tively, you can break a closed door (whether locked or not) down by + kicking it via the `^D' (kick) command. Kicking down a door destroys + it and makes a lot of noise which might wake sleeping monsters. + Some closed doors are booby-trapped and will explode if an at- + tempt is made to open (when unlocked) or unlock (when locked) or kick + down. Like kicking, an explosion destroys the door and makes a lot of + noise. The "#untrap" command can be used to search a door for traps + but might take multiple attempts to find one. When one is found, + you'll be asked whether to try to disarm it. If you accede, success + will eliminate the trap but failure will set off the trap's explosion. + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 33 - may be open, closed, or locked. To open a closed door, use the `o' - (open) command; to close it again, use the `c' (close) command. By - default the autoopen option is enabled, so simply attempting to walk - onto a closed door's location will attempt to open it without needing - `o'. Opening via autoopen will not work if you are confused or - stunned or suffer from the fumbling attribute. + NetHack Guidebook 34 - Open doors cannot be entered diagonally; you must approach them - straight on, horizontally or vertically. Doorways without doors are - not restricted in this fashion except on one particular level (de- - scribed by "#overview" as "a primitive area"). - Unlocking magic exists but usually won't be available early on. - You can get through a locked door without magic by first using an un- - locking tool with the `a' (apply) command, and then opening it. By - default the autounlock option is also enabled, so if you attempt to - open (via `o' or autoopen) a locked door while carrying an unlocking - tool, you'll be asked whether to use it on the door's lock. Alterna- - tively, you can break a closed door (whether locked or not) down by - kicking it via the `^D' (kick) command. Kicking down a door destroys - it and makes a lot of noise which might wake sleeping monsters. - Some closed doors are booby-trapped and will explode if an at- - tempt is made to open (when unlocked) or unlock (when locked) or kick - down. Like kicking, an explosion destroys the door and makes a lot of - noise. The "#untrap" command can be used to search a door for traps - but might take multiple attempts to find one. When one is found, - you'll be asked whether to try to disarm it. If you accede, success - will eliminate the trap but failure will set off the trap's explosion. (If you decline, you effectively forget that a trap was found there.) - Closed doors can be useful for shutting out monsters. Most mon- - sters cannot open closed doors, although a few don't need to (for ex- - ample, ghosts can walk through doors and fog clouds can flow under + Closed doors can be useful for shutting out monsters. Most mon- + sters cannot open closed doors, although a few don't need to (for ex- + ample, ghosts can walk through doors and fog clouds can flow under them). Some monsters who can open doors can also use unlocking tools. And some (giants) can smash doors. Secret doors are hidden and appear to be ordinary wall (from in- side a room) or solid rock (from outside). You can find them with the - `s' (search) command but it might take multiple tries (possibly many - tries if your luck is poor). Once found they are in all ways equiva- + `s' (search) command but it might take multiple tries (possibly many + tries if your luck is poor). Once found they are in all ways equiva- lent to normal doors. Mapping magic does not reveal secret doors. 5.2. Traps (`^') - There are traps throughout the dungeon to snare the unwary in- - truder. For example, you may suddenly fall into a pit and be stuck + There are traps throughout the dungeon to snare the unwary in- + truder. For example, you may suddenly fall into a pit and be stuck for a few turns trying to climb out (see below). A trap usually won't appear on your map until you trigger it by moving onto it, you see someone else trigger it, or you discover it with the `s' (search) com- - mand (multiple attempts are often needed; if your luck is poor, many - attempts might be needed). Wands of secret door detection and spell - of detect unseen also reveal traps within a modest radius but only if + mand (multiple attempts are often needed; if your luck is poor, many + attempts might be needed). Wands of secret door detection and spell + of detect unseen also reveal traps within a modest radius but only if the trap is also within line-of-sight (whether you can see at the time - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 34 - - - or not). There is also other magic which can reveal traps. Monsters can fall prey to traps, too, which can potentially be @@ -2190,30 +2215,43 @@ moving onto a trap which is shown on your map if they have encountered that type of trap before. - Some traps such as pits, bear traps, and webs hold you in one - place. You can escape by simply trying to move to an adjacent spot + Some traps such as pits, bear traps, and webs hold you in one + place. You can escape by simply trying to move to an adjacent spot and repeat as needed; eventually you will get free. - Other traps can send you to different locations. Teleporters - send you elsewhere on the same dungeon level. Level teleporters send - you to a random dungeon level, the destination chosen from a few lev- - els lower all the way to the top. These traps choose a new destina- - tion each time they're activated. Trap doors and holes also send you - to another level, but one which is always below the current level. - Usually that will be the next level down but it can be farther. Un- - like (level) teleporters, the destination level of a particular trap - door or hole is persistent, so falling into one will bring you to the - same level each time--though not necessarily the same spot on the + Other traps can send you to different locations. Teleporters + send you elsewhere on the same dungeon level. Level teleporters send + you to a random dungeon level, the destination chosen from a few lev- + els lower all the way to the top. These traps choose a new destina- + tion each time they're activated. Trap doors and holes also send you + to another level, but one which is always below the current level. + Usually that will be the next level down but it can be farther. Un- + like (level) teleporters, the destination level of a particular trap + door or hole is persistent, so falling into one will bring you to the + same level each time--though not necessarily the same spot on the level. Magic portals behave similarly, but with some additional vari- ation. Some portals are two-way and their remote destination is al- ways the same: another portal which can take you back. Others are one-way and send you to a specific destination level but not necessar- ily to a specific location there. - There is a special multi-level branch of the dungeon with pre- - mapped levels based on the classic computer game "Sokoban." In that - game, you operate as a warehouse worker who pushes crates around ob- - stacles to position them at designated locations. In NetHack, the + + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 35 + + + + There is a special multi-level branch of the dungeon with pre- + mapped levels based on the classic computer game "Sokoban." In that + game, you operate as a warehouse worker who pushes crates around ob- + stacles to position them at designated locations. In NetHack, the goal is to push boulders into pits or holes until those traps have all been nullified, giving access to whatever is beyond them. In the Sokoban game, you can only move in the four cardinal compass direc- @@ -2237,33 +2275,22 @@ tion for information about getting feedback for your actions in Sokoban. - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 35 - - - 5.3. Stairs and ladders (`<', `>') In general, each level in the dungeon will have a staircase going - up (`<') to the previous level and another going down (`>') to the - next level. There are some exceptions though. For instance, fairly - early in the dungeon you will find a level with two down staircases, - one continuing into the dungeon and the other branching into an area + up (`<') to the previous level and another going down (`>') to the + next level. There are some exceptions though. For instance, fairly + early in the dungeon you will find a level with two down staircases, + one continuing into the dungeon and the other branching into an area known as the Gnomish Mines. Those mines eventually hit a dead end, so after exploring them (if you choose to do so), you'll need to climb back up to the main dungeon. When you traverse a set of stairs, or trigger a trap which sends you to another level, the level you're leaving will be deactivated and - stored in a file on disk. If you're moving to a previously visited - level, it will be loaded from its file on disk and reactivated. If - you're moving to a level which has not yet been visited, it will be + stored in a file on disk. If you're moving to a previously visited + level, it will be loaded from its file on disk and reactivated. If + you're moving to a level which has not yet been visited, it will be created (from scratch for most random levels, from a template for some "special" levels, or loaded from the remains of an earlier game for a "bones" level as briefly described below). Monsters are only active @@ -2271,21 +2298,33 @@ into stasis. Ordinarily when you climb a set of stairs, you will arrive on the - corresponding staircase at your destination. However, pets (see be- + corresponding staircase at your destination. However, pets (see be- low) and some other monsters will follow along if they're close enough when you travel up or down stairs, and occasionally one of these crea- - tures will displace you during the climb. When that occurs, the pet - or other monster will arrive on the staircase and you will end up + tures will displace you during the climb. When that occurs, the pet + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 36 + + + + or other monster will arrive on the staircase and you will end up nearby. - Ladders serve the same purpose as staircases, and the two types - of inter-level connections are nearly indistinguishable during game + Ladders serve the same purpose as staircases, and the two types + of inter-level connections are nearly indistinguishable during game play. 5.4. Shops and shopping - Occasionally you will run across a room with a shopkeeper near - the door and many items lying on the floor. You can buy items by + Occasionally you will run across a room with a shopkeeper near + the door and many items lying on the floor. You can buy items by picking them up and then using the `p' command. You can inquire about the price of an item prior to picking it up by using the "#chat" com- mand while standing on it. Using an item prior to paying for it will @@ -2302,21 +2341,9 @@ usually claim ownership without offering any compensation. You'll have to buy it back if you want to reclaim it. - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 36 - - - Shopkeepers sometime run out of money. When that happens, you'll - be offered credit instead of gold when you try to sell something. - Credit can be used to pay for purchases, but it is only good in the + be offered credit instead of gold when you try to sell something. + Credit can be used to pay for purchases, but it is only good in the shop where it was obtained; other shopkeepers won't honor it. (If you happen to find a "credit card" in the dungeon, don't bother trying to use it in shops; shopkeepers will not accept it.) @@ -2340,45 +2367,47 @@ * While the shopkeeper watches you like a hawk, he or she will gener- ally ignore any other customers. - * If a shop is "closed for inventory," it will not open of its own ac- - cord. - * Shops do not get restocked with new items, regardless of inventory - depletion. - 5.5. Movement feedback - Moving around the map usually provides no feedback--other than - drawing the hero at the new location--unless you step on an object or - pile of objects, or on a trap, or attempt to move onto a spot where a - monster is located. There are several options which can be used to - augment the normal feedback. + NetHack 3.7.0 December 08, 2023 + - The pile_limit option controls how many objects can be in a - pile--sharing the same map location--for the game to state "there are - objects here" instead of listing them. The default is 5. Setting it - to 1 would always give that message instead of listing any objects. - Setting it to 0 is a special case which will always list all objects - no matter how big a pile is. Note that the number refers to the count - of separate stacks of objects present rather than the sum of the quan- - tities of those stacks (so 7 arrows or 25 gold pieces will each count - as 1 rather than as 7 and 25, respectively, and total to 2 when both - are at the same location). - The "nopickup" command prefix (default `m') can be used before a - movement direction to step on objects without attempting auto-pickup - and without giving feedback about them. - NetHack 3.7.0 November 13, 2023 + NetHack Guidebook 37 + + * If a shop is "closed for inventory," it will not open of its own ac- + cord. + * Shops do not get restocked with new items, regardless of inventory + depletion. + 5.5. Movement feedback - NetHack Guidebook 37 + Moving around the map usually provides no feedback--other than + drawing the hero at the new location--unless you step on an object or + pile of objects, or on a trap, or attempt to move onto a spot where a + monster is located. There are several options which can be used to + augment the normal feedback. + The pile_limit option controls how many objects can be in a + pile--sharing the same map location--for the game to state "there are + objects here" instead of listing them. The default is 5. Setting it + to 1 would always give that message instead of listing any objects. + Setting it to 0 is a special case which will always list all objects + no matter how big a pile is. Note that the number refers to the count + of separate stacks of objects present rather than the sum of the quan- + tities of those stacks (so 7 arrows or 25 gold pieces will each count + as 1 rather than as 7 and 25, respectively, and total to 2 when both + are at the same location). + The "nopickup" command prefix (default `m') can be used before a + movement direction to step on objects without attempting auto-pickup + and without giving feedback about them. The mention_walls option controls whether you get feedback if you try to walk into a wall or solid stone or off the edge of the map. @@ -2394,22 +2423,34 @@ this option to true will describe such things even when they aren't obscured. Doorless doorways and open doors aren't considered worthy of mention; closed doors (if you can move onto their spots) and broken - doors are. Assuming that you're able to do so, moving onto water or - lava or ice will give feedback if not yet on that type of terrain but - not repeat it (unless there has been some intervening message) when - moving from water to another water spot, or lava to lava, or ice to - ice. Moving off of any of those back onto "normal" terrain will give - one message too, unless there is feedback about one or more objects, + doors are. Assuming that you're able to do so, moving onto water or + lava or ice will give feedback if not yet on that type of terrain but + not repeat it (unless there has been some intervening message) when + moving from water to another water spot, or lava to lava, or ice to + ice. Moving off of any of those back onto "normal" terrain will give + one message too, unless there is feedback about one or more objects, in which case the back on land circumstance is implied. - The confirm and safe_pet options control what happens when you + The confirm and safe_pet options control what happens when you try to move onto a peaceful monster's spot or a tame one's spot. - The "nopickup" command prefix (default `m') is also the move- - without-attacking prefix and can be used to try to step onto a visible - monster's spot without the move being considered an attack (see the - Fighting subsection of Monsters below). The "fight" command prefix - (default `F'; also `-' if number_pad is on) can be used to force an + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 38 + + + + The "nopickup" command prefix (default `m') is also the move- + without-attacking prefix and can be used to try to step onto a visible + monster's spot without the move being considered an attack (see the + Fighting subsection of Monsters below). The "fight" command prefix + (default `F'; also `-' if number_pad is on) can be used to force an attack, when guessing where an unseen monster is or when deliberately attacking a peaceful or tame creature. @@ -2428,24 +2469,11 @@ are shown as % rather than < and >. There are some minor differences in actual game play: doorways lack doors; a scroll, wand, or spell of light used in a room lights up the whole room rather than within a ra- - dius around your character. And monsters represented by lower-case + dius around your character. And monsters represented by lower-case letters aren't randomly generated on the rogue level. The slight strangeness of this level is a feature, not a bug.... - - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 38 - - - 6. Monsters Monsters you cannot see are not displayed on the screen. Beware! @@ -2469,11 +2497,23 @@ If you see a monster and you wish to fight it, just attempt to walk into it. Many monsters you find will mind their own business un- - less you attack them. Some of them are very dangerous when angered. + less you attack them. Some of them are very dangerous when angered. Remember: discretion is the better part of valor. - In most circumstances, if you attempt to attack a peaceful mon- - ster by moving into its location, you'll be asked to confirm your in- + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 39 + + + + In most circumstances, if you attempt to attack a peaceful mon- + ster by moving into its location, you'll be asked to confirm your in- tent. By default an answer of `y' acknowledges that intent, which can be error prone if you're using `y' to move. You can set the para- noid_confirmation:attack option to require a response of "yes" in- @@ -2481,11 +2521,11 @@ If you can't see a monster (if it is invisible, or if you are blinded), the symbol `I' will be shown when you learn of its presence. - If you attempt to walk into it, you will try to fight it just like a - monster that you can see; of course, if the monster has moved, you - will attack empty air. If you guess that the monster has moved and - you don't wish to fight, you can use the `m' command to move without - fighting; likewise, if you don't remember a monster but want to try + If you attempt to walk into it, you will try to fight it just like a + monster that you can see; of course, if the monster has moved, you + will attack empty air. If you guess that the monster has moved and + you don't wish to fight, you can use the `m' command to move without + fighting; likewise, if you don't remember a monster but want to try fighting anyway, you can use the `F' command. 6.2. Your pet @@ -2495,27 +2535,15 @@ you. Like you, your pet needs food to survive. Dogs and cats usually feed themselves on fresh carrion and other meats; horses need vegetar- ian food which is harder to come by. If you're worried about your pet - or want to train it, you can feed it, too, by throwing it food. A + or want to train it, you can feed it, too, by throwing it food. A properly trained pet can be very useful under certain circumstances. - Your pet also gains experience from killing monsters, and can - grow over time, gaining hit points and doing more damage. Initially, - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 39 - - - - your pet may even be better at killing things than you, which makes + Your pet also gains experience from killing monsters, and can + grow over time, gaining hit points and doing more damage. Initially, + your pet may even be better at killing things than you, which makes pets useful for low-level characters. - Your pet will follow you up and down staircases if it is next to + Your pet will follow you up and down staircases if it is next to you when you move. Otherwise your pet will be stranded and may become wild. Similarly, when you trigger certain types of traps which alter your location (for instance, a trap door which drops you to a lower @@ -2525,8 +2553,8 @@ 6.3. Steeds - Some types of creatures in the dungeon can actually be ridden if - you have the right equipment and skill. Convincing a wild beast to + Some types of creatures in the dungeon can actually be ridden if + you have the right equipment and skill. Convincing a wild beast to let you saddle it up is difficult to say the least. Many a dungeoneer has had to resort to magic and wizardry in order to forge the al- liance. Once you do have the beast under your control however, you @@ -2538,12 +2566,24 @@ Riding skill is managed by the "#enhance" command. See the sec- tion on Weapon proficiency for more information about that. + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 40 + + + Use the `a' (apply) command and pick a saddle in your inventory to attempt to put that saddle on an adjacent creature. If successful, it will be transferred to that creature's inventory. - Use the "#loot" command while adjacent to a saddled creature to - try to remove the saddle from that creature. If successful, it will + Use the "#loot" command while adjacent to a saddled creature to + try to remove the saddle from that creature. If successful, it will be transferred to your inventory. 6.4. Bones levels @@ -2552,35 +2592,23 @@ even former incarnations of yourself!) and their personal effects. Ghosts are hard to kill, but easy to avoid, since they're slow and do little damage. You can plunder the deceased adventurer's possessions; - however, they are likely to be cursed. Beware of whatever killed the - former player; it is probably still lurking around, gloating over its + however, they are likely to be cursed. Beware of whatever killed the + former player; it is probably still lurking around, gloating over its last victory. 6.5. Persistence of Monsters - Monsters (a generic reference which also includes humans and + Monsters (a generic reference which also includes humans and pets) are only shown while they can be seen or otherwise sensed. Mov- ing to a location where you can't see or sense a monster any more will - result in it disappearing from your map, similarly if it is the one + result in it disappearing from your map, similarly if it is the one who moved rather than you. - However, if you encounter a monster which you can't see or + However, if you encounter a monster which you can't see or sense--perhaps it is invisible and has just tapped you on the noggin-- - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 40 - - - a special "remembered, unseen monster" marker will be displayed at the - location where you think it is. That will persist until you have - proven that there is no monster there, even if the unseen monster + location where you think it is. That will persist until you have + proven that there is no monster there, even if the unseen monster moves to another location or you move to a spot where the marker's lo- cation ordinarily wouldn't be seen any more. @@ -2601,25 +2629,37 @@ are, the less the additional load will affect you. There comes a point, though, when the weight of all of that stuff you are carrying around with you through the dungeon will encumber you. Your reactions - will get slower and you'll burn calories faster, requiring food more - frequently to cope with it. Eventually, you'll be so overloaded that + will get slower and you'll burn calories faster, requiring food more + frequently to cope with it. Eventually, you'll be so overloaded that you'll either have to discard some of what you're carrying or collapse + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 41 + + + under its weight. NetHack will tell you how badly you have loaded yourself. If you - are encumbered, one of the conditions Burdened, Stressed, Strained, - Overtaxed, or Overloaded will be shown on the bottom line status dis- + are encumbered, one of the conditions Burdened, Stressed, Strained, + Overtaxed, or Overloaded will be shown on the bottom line status dis- play. - When you pick up an object, it is assigned an inventory letter. - Many commands that operate on objects must ask you to find out which - object you want to use. When NetHack asks you to choose a particular - object you are carrying, you are usually presented with a list of in- + When you pick up an object, it is assigned an inventory letter. + Many commands that operate on objects must ask you to find out which + object you want to use. When NetHack asks you to choose a particular + object you are carrying, you are usually presented with a list of in- ventory letters to choose from (see Commands, above). - Some objects, such as weapons, are easily differentiated. Oth- - ers, like scrolls and potions, are given descriptions which vary ac- - cording to type. During a game, any two objects with the same de- + Some objects, such as weapons, are easily differentiated. Oth- + ers, like scrolls and potions, are given descriptions which vary ac- + cording to type. During a game, any two objects with the same de- scription are the same type. However, the descriptions will vary from game to game. @@ -2629,26 +2669,14 @@ object so you will recognize it later. You can also use the "#name" command, for the same purpose at any time, to name all objects of a particular type or just an individual object. When you use "#name" on - an object which has already been named, specifying a space as the + an object which has already been named, specifying a space as the value will remove the prior name instead of assigning a new one. - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 41 - - - 7.1. Curses and Blessings - Any object that you find may be cursed, even if the object is - otherwise helpful. The most common effect of a curse is being stuck - with (and to) the item. Cursed weapons weld themselves to your hand + Any object that you find may be cursed, even if the object is + otherwise helpful. The most common effect of a curse is being stuck + with (and to) the item. Cursed weapons weld themselves to your hand when wielded, so you cannot unwield them. Any cursed item you wear is not removable by ordinary means. In addition, cursed arms and armor usually, but not always, bear negative enchantments that make them @@ -2661,15 +2689,27 @@ Objects which are neither cursed nor blessed are referred to as uncursed. They could just as easily have been described as unblessed, - but the uncursed designation is what you will see within the game. A + but the uncursed designation is what you will see within the game. A "glass half full versus glass half empty" situation; make of that what you will. There are magical means of bestowing or removing curses upon ob- jects, so even if you are stuck with one, you can still have the curse - lifted and the item removed. Priests and Priestesses have an innate - sensitivity to this property in any object, so they can more easily - avoid cursed objects than other character roles. Dropping objects + lifted and the item removed. Priests and Priestesses have an innate + sensitivity to this property in any object, so they can more easily + avoid cursed objects than other character roles. Dropping objects + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 42 + + + onto an altar will reveal their bless or curse state provided that you can see them land. @@ -2689,35 +2729,23 @@ 7.2. Weapons (`)') - Given a chance, most monsters in the Mazes of Menace will gratu- - itously try to kill you. You need weapons for self-defense (killing - them first). Without a weapon, you do only 1-2 hit points of damage - (plus bonuses, if any). Monk characters are an exception; they nor- - mally do more damage with bare (or gloved) hands than they do with + Given a chance, most monsters in the Mazes of Menace will gratu- + itously try to kill you. You need weapons for self-defense (killing + them first). Without a weapon, you do only 1-2 hit points of damage + (plus bonuses, if any). Monk characters are an exception; they nor- + mally do more damage with bare (or gloved) hands than they do with weapons. - There are wielded weapons, like maces and swords, and thrown - weapons, like arrows and spears. To hit monsters with a weapon, you - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 42 - - - - must wield it and attack them, or throw it at them. You can simply - elect to throw a spear. To shoot an arrow, you should first wield a - bow, then throw the arrow. Crossbows shoot crossbow bolts. Slings + There are wielded weapons, like maces and swords, and thrown + weapons, like arrows and spears. To hit monsters with a weapon, you + must wield it and attack them, or throw it at them. You can simply + elect to throw a spear. To shoot an arrow, you should first wield a + bow, then throw the arrow. Crossbows shoot crossbow bolts. Slings hurl rocks and (other) stones (like gems). - Enchanted weapons have a "plus" (or "to hit enhancement" which - can be either positive or negative) that adds to your chance to hit - and the damage you do to a monster. The only way to determine a + Enchanted weapons have a "plus" (or "to hit enhancement" which + can be either positive or negative) that adds to your chance to hit + and the damage you do to a monster. The only way to determine a weapon's enchantment is to have it magically identified somehow. Most weapons are subject to some type of damage like rust. Such "erosion" damage can be repaired. @@ -2726,9 +2754,9 @@ the amount of damage such a hit will do, depends upon many factors. Among them are: type of weapon, quality of weapon (enchantment and/or erosion), experience level, strength, dexterity, encumbrance, and pro- - ficiency (see below). The monster's armor class--a general defense - rating, not necessarily due to wearing of armor--is a factor too; - also, some monsters are particularly vulnerable to certain types of + ficiency (see below). The monster's armor class--a general defense + rating, not necessarily due to wearing of armor--is a factor too; + also, some monsters are particularly vulnerable to certain types of weapons. Many weapons can be wielded in one hand; some require both hands. @@ -2736,6 +2764,18 @@ versa. When wielding a one-handed weapon, you can have another weapon ready to use by setting things up with the `x' command, which ex- changes your primary (the one being wielded) and alternate weapons. + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 43 + + + And if you have proficiency in the "two weapon combat" skill, you may wield both weapons simultaneously as primary and secondary; use the `X' command to engage or disengage that. Only some types of charac- @@ -2746,106 +2786,95 @@ There might be times when you'd rather not wield any weapon at all. To accomplish that, wield `-', or else use the `A' command which - allows you to unwield the current weapon in addition to taking off + allows you to unwield the current weapon in addition to taking off other worn items. - Those of you in the audience who are AD&D players, be aware that + Those of you in the audience who are AD&D players, be aware that each weapon which existed in AD&D does roughly the same damage to mon- sters in NetHack. Some of the more obscure weapons (such as the aklys, lucern hammer, and bec-de-corbin) are defined in an appendix to Unearthed Arcana, an AD&D supplement. - The commands to use weapons are `w' (wield), `t' (throw), `f' - (fire), `Q' (quiver), `x' (exchange), `X' (twoweapon), and "#enhance" + The commands to use weapons are `w' (wield), `t' (throw), `f' + (fire), `Q' (quiver), `x' (exchange), `X' (twoweapon), and "#enhance" (see below). 7.2.1. Throwing and shooting - You can throw just about anything via the `t' command. It will + You can throw just about anything via the `t' command. It will prompt for the item to throw; picking `?' will list things in your in- ventory which are considered likely to be thrown, or picking `*' will + list your entire inventory. After you've chosen what to throw, you + will be prompted for a direction rather than for a specific target. + The distance something can be thrown depends mainly on the type of ob- + ject and your strength. Arrows can be thrown by hand, but can be + thrown much farther and will be more likely to hit when thrown while + you are wielding a bow. + Some weapons will return when thrown. A boomerang--provided it + fails to hit anything--is an obvious example. If an aklys (thonged + club) is thrown while it is wielded, it will return even when it hits + something. A sufficiently strong hero can throw the warhammer Mjoll- + nir; when thrown by a Valkyrie it will return too. However, aklyses + and Mjollnir occasionally fail to return. Returning thrown objects + occasionally fail to be caught, sometimes even hitting the thrower, + but when caught they become re-wielded. - NetHack 3.7.0 November 13, 2023 + You can simplify the throwing operation by using the `Q' command + to select your preferred "missile", then using the `f' command to + throw it. You'll be prompted for a direction as above, but you don't + have to specify which item to throw each time you use `f'. There is + also an option, autoquiver, which has NetHack choose another item to + automatically fill your quiver (or quiver sack, or have at the ready) + when the inventory slot used for `Q' runs out. If your quiver is + empty, autoquiver is false, and you are wielding a weapon which re- + turns when thrown, you will throw that weapon instead of filling the + quiver. The fire command also has extra assistance, if fireassist is + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 43 + NetHack Guidebook 44 - list your entire inventory. After you've chosen what to throw, you - will be prompted for a direction rather than for a specific target. - The distance something can be thrown depends mainly on the type of ob- - ject and your strength. Arrows can be thrown by hand, but can be - thrown much farther and will be more likely to hit when thrown while - you are wielding a bow. - Some weapons will return when thrown. A boomerang--provided it - fails to hit anything--is an obvious example. If an aklys (thonged - club) is thrown while it is wielded, it will return even when it hits - something. A sufficiently strong hero can throw the warhammer Mjoll- - nir; when thrown by a Valkyrie it will return too. However, aklyses - and Mjollnir occasionally fail to return. Returning thrown objects - occasionally fail to be caught, sometimes even hitting the thrower, - but when caught they become re-wielded. - You can simplify the throwing operation by using the `Q' command - to select your preferred "missile", then using the `f' command to - throw it. You'll be prompted for a direction as above, but you don't - have to specify which item to throw each time you use `f'. There is - also an option, autoquiver, which has NetHack choose another item to - automatically fill your quiver (or quiver sack, or have at the ready) - when the inventory slot used for `Q' runs out. If your quiver is - empty, autoquiver is false, and you are wielding a weapon which re- - turns when thrown, you will throw that weapon instead of filling the - quiver. The fire command also has extra assistance, if fireassist is on it will try to wield a launcher matching the ammo in the quiver. - Some characters have the ability to throw or shoot a volley of - multiple items (from the same stack) in a single action. Knowing how + Some characters have the ability to throw or shoot a volley of + multiple items (from the same stack) in a single action. Knowing how to load several rounds of ammunition at once--or hold several missiles in your hand--and still hit a target is not an easy task. Rangers are among those who are adept at this task, as are those with a high level of proficiency in the relevant weapon skill (in bow skill if you're wielding one to shoot arrows, in crossbow skill if you're wielding one - to shoot bolts, or in sling skill if you're wielding one to shoot - stones). The number of items that the character has a chance to fire - varies from turn to turn. You can explicitly limit the number of - shots by using a numeric prefix before the `t' or `f' command. For + to shoot bolts, or in sling skill if you're wielding one to shoot + stones). The number of items that the character has a chance to fire + varies from turn to turn. You can explicitly limit the number of + shots by using a numeric prefix before the `t' or `f' command. For example, "2f" (or "n2f" if using number_pad mode) would ensure that at most 2 arrows are shot even if you could have fired 3. If you specify - a larger number than would have been shot ("4f" in this example), - you'll just end up shooting the same number (3, here) as if no limit - had been specified. Once the volley is in motion, all of the items - will travel in the same direction; if the first ones kill a monster, + a larger number than would have been shot ("4f" in this example), + you'll just end up shooting the same number (3, here) as if no limit + had been specified. Once the volley is in motion, all of the items + will travel in the same direction; if the first ones kill a monster, the others can still continue beyond that spot. 7.2.2. Weapon proficiency - You will have varying degrees of skill in the weapons available. + You will have varying degrees of skill in the weapons available. Weapon proficiency, or weapon skills, affect how well you can use par- ticular types of weapons, and you'll be able to improve your skills as - you progress through a game, depending on your role, your experience + you progress through a game, depending on your role, your experience level, and use of the weapons. - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 44 - - - - For the purposes of proficiency, weapons have been divided up - into various groups such as daggers, broadswords, and polearms. Each - role has a limit on what level of proficiency a character can achieve - for each group. For instance, wizards can become highly skilled in + For the purposes of proficiency, weapons have been divided up + into various groups such as daggers, broadswords, and polearms. Each + role has a limit on what level of proficiency a character can achieve + for each group. For instance, wizards can become highly skilled in daggers or staves but not in swords or bows. The "#enhance" extended command is used to review current weapons @@ -2865,12 +2894,24 @@ amount of damage done when you do hit; at basic level, there is no penalty or bonus; at skilled level, you receive a modest bonus in the chance to hit and amount of damage done; at expert level, the bonus is - higher. A successful hit has a chance to boost your training towards + higher. A successful hit has a chance to boost your training towards the next skill level (unless you've already reached the limit for this + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 45 + + + skill). Once such training reaches the threshold for that next level, - you'll be told that you feel more confident in your skills. At that - point you can use "#enhance" to increase one or more skills. Such - skills are not increased automatically because there is a limit to + you'll be told that you feel more confident in your skills. At that + point you can use "#enhance" to increase one or more skills. Such + skills are not increased automatically because there is a limit to your total overall skills, so you need to actively choose which skills to enhance and which to ignore. @@ -2883,55 +2924,56 @@ weapons are not fully equal; the one in the hand you normally wield with is considered primary and the other one is considered secondary. The most noticeable difference is after you stop--or before you begin, - for that matter--wielding two weapons at once. The primary is your - wielded weapon and the secondary is just an item in your inventory + for that matter--wielding two weapons at once. The primary is your + wielded weapon and the secondary is just an item in your inventory that's been designated as alternate weapon.) - If your primary weapon is wielded but your off hand is empty or - has the wrong weapon, use the sequence `x', `w', `x' to first swap - your primary into your off hand, wield whatever you want as secondary - weapon, then swap them both back into the intended hands. If your - secondary or alternate weapon is correct but your primary one is not, - simply use `w' to wield the primary. Lastly, if neither hand holds + If your primary weapon is wielded but your off hand is empty or + has the wrong weapon, use the sequence `x', `w', `x' to first swap + your primary into your off hand, wield whatever you want as secondary + weapon, then swap them both back into the intended hands. If your + secondary or alternate weapon is correct but your primary one is not, + simply use `w' to wield the primary. Lastly, if neither hand holds the correct weapon, use `w', `x', `w' to first wield the intended sec- ondary, swap it to off hand, and then wield the primary. + The whole process can be simplified via use of the pushweapon op- + tion. When it is enabled, then using `w' to wield something causes + the currently wielded weapon to become your alternate weapon. So the + sequence `w', `w' can be used to first wield the weapon you intend to + be secondary, and then wield the one you want as primary which will + push the first into secondary position. + When in two-weapon combat mode, using the `X' command toggles + back to single-weapon mode. Throwing or dropping either of the + weapons or having one of them be stolen or destroyed will also make + you revert to single-weapon combat. - NetHack 3.7.0 November 13, 2023 + 7.3. Armor (`[') + Lots of unfriendly things lurk about; you need armor to protect + yourself from their blows. Some types of armor offer better protec- + tion than others. Your armor class is a measure of this protection. + Armor class (AC) is measured as in AD&D, with 10 being the equivalent + of no armor, and lower numbers meaning better armor. Each suit of ar- + mor which exists in AD&D gives the same protection in NetHack. + Here is a list of the armor class values provided by suits of ar- + mor: + Dragon scale mail 1 - NetHack Guidebook 45 + NetHack 3.7.0 December 08, 2023 - The whole process can be simplified via use of the pushweapon op- - tion. When it is enabled, then using `w' to wield something causes - the currently wielded weapon to become your alternate weapon. So the - sequence `w', `w' can be used to first wield the weapon you intend to - be secondary, and then wield the one you want as primary which will - push the first into secondary position. - When in two-weapon combat mode, using the `X' command toggles - back to single-weapon mode. Throwing or dropping either of the - weapons or having one of them be stolen or destroyed will also make - you revert to single-weapon combat. - 7.3. Armor (`[') + NetHack Guidebook 46 + - Lots of unfriendly things lurk about; you need armor to protect - yourself from their blows. Some types of armor offer better protec- - tion than others. Your armor class is a measure of this protection. - Armor class (AC) is measured as in AD&D, with 10 being the equivalent - of no armor, and lower numbers meaning better armor. Each suit of ar- - mor which exists in AD&D gives the same protection in NetHack. - Here is a list of the armor class values provided by suits of ar- - mor: - Dragon scale mail 1 Plate mail, Crystal plate mail 3 Bronze plate mail, Splint mail, Banded mail, Dwarvish mithril-coat 4 @@ -2943,8 +2985,8 @@ Leather jacket 9 none 10 - You can also wear other pieces of armor (cloak over suit, shirt - under suit, helmet, gloves, boots, shield) to lower your armor class + You can also wear other pieces of armor (cloak over suit, shirt + under suit, helmet, gloves, boots, shield) to lower your armor class even further. Most of these provide a one or two point improvement to AC (making the overall value smaller and eventually negative) but can also be enchanted. Shirts are an exception; they don't provide any @@ -2955,25 +2997,13 @@ If a piece of armor is enchanted, its armor protection will be better (or worse) than normal, and its "plus" (or minus) will subtract - from your armor class. For example, a +1 chain mail would give you - better protection than normal chain mail, lowering your armor class - one unit further to 4. When you put on a piece of armor, you immedi- - ately find out the armor class and any "plusses" it provides. Cursed - pieces of armor usually have negative enchantments (minuses) in addi- + from your armor class. For example, a +1 chain mail would give you + better protection than normal chain mail, lowering your armor class + one unit further to 4. When you put on a piece of armor, you immedi- + ately find out the armor class and any "plusses" it provides. Cursed + pieces of armor usually have negative enchantments (minuses) in addi- tion to being unremovable. - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 46 - - - Many types of armor are subject to some kind of damage like rust. Such damage can be repaired. Some types of armor may inhibit spell casting. @@ -2985,19 +3015,31 @@ The commands to use armor are `W' (wear) and `T' (take off). The `A' command can be used to take off armor as well as other worn items. Also, `P' (put on) and `R' (remove) which are normally for accessories - can be used for armor, but pieces of armor won't be shown as likely + can be used for armor, but pieces of armor won't be shown as likely candidates in a prompt for choosing what to put on or remove. 7.4. Food (`%') - Food is necessary to survive. If you go too long without eating - you will faint, and eventually die of starvation. Some types of food - will spoil, and become unhealthy to eat, if not protected. Food - stored in ice boxes or tins ("cans") will usually stay fresh, but ice + Food is necessary to survive. If you go too long without eating + you will faint, and eventually die of starvation. Some types of food + will spoil, and become unhealthy to eat, if not protected. Food + stored in ice boxes or tins ("cans") will usually stay fresh, but ice boxes are heavy, and tins take a while to open. When you kill monsters, they usually leave corpses which are also "food." Many, but not all, of these are edible; some also give you + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 47 + + + special powers when you eat them. A good rule of thumb is "you are what you eat." @@ -3005,44 +3047,32 @@ ian monsters will typically never eat animal corpses, while vegetarian players can, but with some rather unpleasant side-effects. - You can name one food item after something you like to eat with + You can name one food item after something you like to eat with the fruit option. The command to eat food is `e'. 7.5. Scrolls (`?') - Scrolls are labeled with various titles, probably chosen by an- - cient wizards for their amusement value (for example "READ ME," or - "THANX MAUD" backwards). Scrolls disappear after you read them (ex- + Scrolls are labeled with various titles, probably chosen by an- + cient wizards for their amusement value (for example "READ ME," or + "THANX MAUD" backwards). Scrolls disappear after you read them (ex- cept for blank ones, without magic spells on them). - One of the most useful of these is the scroll of identify, which - can be used to determine what another object is, whether it is cursed + One of the most useful of these is the scroll of identify, which + can be used to determine what another object is, whether it is cursed or blessed, and how many uses it has left. Some objects of subtle en- chantment are difficult to identify without these. A mail daemon may run up and deliver mail to you as a scroll of mail (on versions compiled with this feature). To use this feature on - versions where NetHack mail delivery is triggered by electronic mail - appearing in your system mailbox, you must let NetHack know where to - look for new mail by setting the "MAIL" environment variable to the - file name of your mailbox. You may also want to set the "MAILREADER" - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 47 - - - - environment variable to the file name of your favorite reader, so - NetHack can shell to it when you read the scroll. On versions of - NetHack where mail is randomly generated internal to the game, these + versions where NetHack mail delivery is triggered by electronic mail + appearing in your system mailbox, you must let NetHack know where to + look for new mail by setting the "MAIL" environment variable to the + file name of your mailbox. You may also want to set the "MAILREADER" + environment variable to the file name of your favorite reader, so + NetHack can shell to it when you read the scroll. On versions of + NetHack where mail is randomly generated internal to the game, these environment variables are ignored. You can disable the mail daemon by turning off the mail option. @@ -3056,11 +3086,26 @@ Clear potions are potions of water. Sometimes these are blessed or cursed, resulting in holy or unholy water. Holy water is the bane of the undead, so potions of holy water are good things to throw (`t') - at them. It is also sometimes very useful to dip ("#dip") an object + at them. It is also sometimes very useful to dip ("#dip") an object into a potion. The command to drink a potion is `q' (quaff). + + + + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 48 + + + 7.7. Wands (`/') Wands usually have multiple magical charges. Some types of wands @@ -3070,11 +3115,11 @@ direction. The number of charges in a wand is random and decreases by one whenever you use it. - When the number of charges left in a wand becomes zero, attempts - to use the wand will usually result in nothing happening. Occasion- - ally, however, it may be possible to squeeze the last few mana points - from an otherwise spent wand, destroying it in the process. A wand - may be recharged by using suitable magic, but doing so runs the risk + When the number of charges left in a wand becomes zero, attempts + to use the wand will usually result in nothing happening. Occasion- + ally, however, it may be possible to squeeze the last few mana points + from an otherwise spent wand, destroying it in the process. A wand + may be recharged by using suitable magic, but doing so runs the risk of causing it to explode. The chance for such an explosion starts out very small and increases each time the wand is recharged. @@ -3085,52 +3130,52 @@ When you have fully identified a particular wand, inventory dis- play will include additional information in parentheses: the number of - times it has been recharged followed by a colon and then by its cur- - rent number of charges. A current charge count of -1 is a special + times it has been recharged followed by a colon and then by its cur- + rent number of charges. A current charge count of -1 is a special case indicating that the wand has been cancelled. - The command to use a wand is `z' (zap). To break one, use the + The command to use a wand is `z' (zap). To break one, use the `a' (apply) command. + 7.8. Rings (`=') + Rings are very useful items, since they are relatively permanent + magic, unlike the usually fleeting effects of potions, scrolls, and + wands. + Putting on a ring activates its magic. You can wear at most two + rings at any time, one on the ring finger of each hand. + Most worn rings also cause you to grow hungry more rapidly, the + rate varying with the type of ring. - NetHack 3.7.0 November 13, 2023 + When wearing gloves, rings are worn underneath. If the gloves + are cursed, rings cannot be put on and any already being worn cannot + be removed. When worn gloves aren't cursed, you don't have to manu- + ally take them off before putting on or removing a ring and then re- + wear them after. That's done implicitly to avoid unnecessary tedium. + The commands to use rings are `P' (put on) and `R' (remove). + `A', `W', and `T' can also be used; see Amulets. - NetHack Guidebook 48 + NetHack 3.7.0 December 08, 2023 - 7.8. Rings (`=') - Rings are very useful items, since they are relatively permanent - magic, unlike the usually fleeting effects of potions, scrolls, and - wands. - Putting on a ring activates its magic. You can wear at most two - rings at any time, one on the ring finger of each hand. - Most worn rings also cause you to grow hungry more rapidly, the - rate varying with the type of ring. + NetHack Guidebook 49 - When wearing gloves, rings are worn underneath. If the gloves - are cursed, rings cannot be put on and any already being worn cannot - be removed. When worn gloves aren't cursed, you don't have to manu- - ally take them off before putting on or removing a ring and then re- - wear them after. That's done implicitly to avoid unnecessary tedium. - The commands to use rings are `P' (put on) and `R' (remove). - `A', `W', and `T' can also be used; see Amulets. 7.9. Spellbooks (`+') - Spellbooks are tomes of mighty magic. When studied with the `r' - (read) command, they transfer to the reader the knowledge of a spell + Spellbooks are tomes of mighty magic. When studied with the `r' + (read) command, they transfer to the reader the knowledge of a spell (and therefore eventually become unreadable)--unless the attempt back- fires. Reading a cursed spellbook or one with mystic runes beyond your ken can be harmful to your health! @@ -3144,8 +3189,8 @@ Casting a spell calls forth magical energies and focuses them with your naked mind. Some of the magical energy released comes from within you. Casting temporarily drains your magical power, which will - slowly be recovered, and causes you to need additional food. Casting - of spells also requires practice. With practice, your skill in each + slowly be recovered, and causes you to need additional food. Casting + of spells also requires practice. With practice, your skill in each category of spell casting will improve. Over time, however, your mem- ory of each spell will dim, and you will need to relearn it. @@ -3159,55 +3204,55 @@ become proficient (to varying degrees), spells are similarly grouped. Successfully casting a spell exercises its skill group; using the "#enhance" command to advance a sufficiently exercised skill will af- - fect all spells within the group. Advanced skill may increase the + fect all spells within the group. Advanced skill may increase the po- + tency of spells, reduce their risk of failure during casting attempts, + and improve the accuracy of the estimate for how much longer they will + be retained in your memory. Skill slots are shared with weapons + skills. (See also the section on "Weapon proficiency".) + Casting a spell also requires flexible movement, and wearing var- + ious types of armor may interfere with that. - NetHack 3.7.0 November 13, 2023 + The command to read a spellbook is the same as for scrolls, `r' + (read). The `+' command lists each spell you know along with its + level, skill category, chance of failure when casting, and an estimate + of how strongly it is remembered. The `Z' (cast) command casts a + spell. + 7.10. Tools (`(') + Tools are miscellaneous objects with various purposes. Some + tools have a limited number of uses, akin to wand charges. For exam- + ple, lamps burn out after a while. Other tools are containers, which + objects can be placed into or taken out of. - NetHack Guidebook 49 + NetHack 3.7.0 December 08, 2023 - potency of spells, reduce their risk of failure during casting at- - tempts, and improve the accuracy of the estimate for how much longer - they will be retained in your memory. Skill slots are shared with - weapons skills. (See also the section on "Weapon proficiency".) - Casting a spell also requires flexible movement, and wearing var- - ious types of armor may interfere with that. - The command to read a spellbook is the same as for scrolls, `r' - (read). The `+' command lists each spell you know along with its - level, skill category, chance of failure when casting, and an estimate - of how strongly it is remembered. The `Z' (cast) command casts a - spell. + NetHack Guidebook 50 - 7.10. Tools (`(') - Tools are miscellaneous objects with various purposes. Some - tools have a limited number of uses, akin to wand charges. For exam- - ple, lamps burn out after a while. Other tools are containers, which - objects can be placed into or taken out of. - Some tools (such as a blindfold) can be worn and can be put on - and removed like other accessories (rings, amulets); see Amulets. - Other tools (such as pick-axe) can be wielded as weapons in addition - to being applied for their usual purpose, and in some cases (again, + Some tools (such as a blindfold) can be worn and can be put on + and removed like other accessories (rings, amulets); see Amulets. + Other tools (such as pick-axe) can be wielded as weapons in addition + to being applied for their usual purpose, and in some cases (again, pick-axe) become wielded as a weapon even when applied. - The blind option can be set (prior to game start) to attempt to - play the entire game without being able to see (a self-imposed chal- + The blind option can be set (prior to game start) to attempt to + play the entire game without being able to see (a self-imposed chal- lenge which is very difficult to accomplish). The command to use a tool is `a' (apply). 7.10.1. Containers - You may encounter bags, boxes, and chests in your travels. A + You may encounter bags, boxes, and chests in your travels. A tool of this sort can be opened with the "#loot" extended command when you are standing on top of it (that is, on the same floor spot), or with the `a' (apply) command when you are carrying it. However, @@ -3224,26 +3269,15 @@ 7.11. Amulets (`"') Amulets are very similar to rings, and often more powerful. Like - rings, amulets have various magical properties, some beneficial, some + rings, amulets have various magical properties, some beneficial, some harmful, which are activated by putting them on. - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 50 - - - - Only one amulet may be worn at a time, around your neck. Like - wearing rings, wearing an amulet affects your metabolism, causing you + Only one amulet may be worn at a time, around your neck. Like + wearing rings, wearing an amulet affects your metabolism, causing you to grow hungry more rapidly. - The commands to use amulets are the same as for rings, `P' (put - on) and `R' (remove). `A' can be used to remove various worn items + The commands to use amulets are the same as for rings, `P' (put + on) and `R' (remove). `A' can be used to remove various worn items including amulets. Also, `W' (wear) and `T' (take off) which are nor- mally for armor can be used for amulets and other accessories (rings and eyewear), but accessories won't be shown as likely candidates in a @@ -3251,13 +3285,25 @@ 7.12. Gems (`*') - Some gems are valuable, and can be sold for a lot of gold. They - are also a far more efficient way of carrying your riches. Valuable + Some gems are valuable, and can be sold for a lot of gold. They + are also a far more efficient way of carrying your riches. Valuable gems increase your score if you bring them with you when you exit. Other small rocks are also categorized as gems, but they are much less valuable. All rocks, however, can be used as projectile weapons (if you have a sling). In the most desperate of cases, you can still + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 51 + + + throw them by hand. 7.13. Large rocks (``') @@ -3267,23 +3313,23 @@ Boulders occasionally block your path. You can push one forward (by attempting to walk onto its spot) when nothing blocks its path, or - you can smash it into a pile of small rocks with breaking magic or a + you can smash it into a pile of small rocks with breaking magic or a pick-axe. It is possible to move onto a boulder's location if certain conditions are met; ordinarily one of those conditions is that pushing - it any further be blocked. Using the move-without-picking-up prefix - (default key `m') prior to the direction of movement will attempt to - move to a boulder's location without pushing it in addition to the + it any further be blocked. Using the move-without-picking-up prefix + (default key `m') prior to the direction of movement will attempt to + move to a boulder's location without pushing it in addition to the prefix's usual action of suppressing auto-pickup at the destination. - Very large humanoids (giants and their ilk) have been known to + Very large humanoids (giants and their ilk) have been known to pick up boulders and use them as missile weapons. - Unlike boulders, statues can't be pushed, but don't need to be - because they don't block movement. They can be smashed into rocks + Unlike boulders, statues can't be pushed, but don't need to be + because they don't block movement. They can be smashed into rocks though. - For some configurations of the program, statues are no longer - shown as ``' but by the letter representing the monster they depict + For some configurations of the program, statues are no longer + shown as ``' but by the letter representing the monster they depict instead. 7.14. Gold (`$') @@ -3292,24 +3338,12 @@ There are a number of monsters in the dungeon that may be influenced by the amount of gold you are carrying (shopkeepers aside). - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 51 - - - Gold pieces are the only type of object where bless/curse state does not apply. They're always uncursed but never described as un- cursed even if you turn off the implicit_uncursed option. You can set - the goldX option if you prefer to have gold pieces be treated as - bless/curse state unknown rather than as known to be uncursed. Only - matters when you're using an object selection prompt that can filter + the goldX option if you prefer to have gold pieces be treated as + bless/curse state unknown rather than as known to be uncursed. Only + matters when you're using an object selection prompt that can filter by "BUCX" state. 7.15. Persistence of Objects @@ -3322,9 +3356,21 @@ location again. One notable exception is that if the object gets cov- ered by the "remembered, unseen monster" marker. When that marker is later removed after you've verified that no monster is there, you will - have forgotten that there was any object there regardless of whether - the unseen monster actually took the object. If the object is still - there, then once you see or feel that location again you will re-dis- + have forgotten that there was any object there regardless of whether + the unseen monster actually took the object. If the object is still + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 52 + + + + there, then once you see or feel that location again you will re-dis- cover the object and resume remembering it. The situation is the same for a pile of objects, except that only @@ -3334,18 +3380,18 @@ 8. Conduct - As if winning NetHack were not difficult enough, certain players - seek to challenge themselves by imposing restrictions on the way they - play the game. The game automatically tracks some of these chal- - lenges, which can be checked at any time with the #conduct command or - at the end of the game. When you perform an action which breaks a - challenge, it will no longer be listed. This gives players extra - "bragging rights" for winning the game with these challenges. Note - that it is perfectly acceptable to win the game without resorting to - these restrictions and that it is unusual for players to adhere to + As if winning NetHack were not difficult enough, certain players + seek to challenge themselves by imposing restrictions on the way they + play the game. The game automatically tracks some of these chal- + lenges, which can be checked at any time with the #conduct command or + at the end of the game. When you perform an action which breaks a + challenge, it will no longer be listed. This gives players extra + "bragging rights" for winning the game with these challenges. Note + that it is perfectly acceptable to win the game without resorting to + these restrictions and that it is unusual for players to adhere to challenges the first time they win the game. - Several of the challenges are related to eating behavior. The + Several of the challenges are related to eating behavior. The most difficult of these is the foodless challenge. Although creatures can survive long periods of time without food, there is a physiologi- cal need for water; thus there is no restriction on drinking bever- @@ -3355,22 +3401,10 @@ A strict vegan diet is one which avoids any food derived from an- imals. The primary source of nutrition is fruits and vegetables. The - corpses and tins of blobs (`b'), jellies (`j'), and fungi (`F') are - also considered to be vegetable matter. Certain human food is pre- - pared without animal products; namely, lembas wafers, cram rations, - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 52 - - - - food rations (gunyoki), K-rations, and C-rations. Metal or another + corpses and tins of blobs (`b'), jellies (`j'), and fungi (`F') are + also considered to be vegetable matter. Certain human food is pre- + pared without animal products; namely, lembas wafers, cram rations, + food rations (gunyoki), K-rations, and C-rations. Metal or another normally indigestible material eaten while polymorphed into a creature that can digest it is also considered vegan food. Note however that eating such items still counts against foodless conduct. @@ -3383,25 +3417,37 @@ of royal jelly. Monks are expected to observe a vegetarian diet. Eating any kind of meat violates the vegetarian, vegan, and food- - less conducts. This includes tripe rations, the corpses or tins of + less conducts. This includes tripe rations, the corpses or tins of any monsters not mentioned above, and the various other chunks of meat found in the dungeon. Swallowing and digesting a monster while poly- morphed is treated as if you ate the creature's corpse. Eating leather, dragon hide, or bone items while polymorphed into a creature that can digest it, or eating monster brains while polymorphed into a mind flayer, is considered eating an animal, although wax is only an + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 53 + + + animal byproduct. Regardless of conduct, there will be some items which are indi- gestible, and others which are hazardous to eat. Using a swallow-and- - digest attack against a monster is equivalent to eating the monster's - corpse. Please note that the term "vegan" is used here only in the - context of diet. You are still free to choose not to use or wear - items derived from animals (e.g. leather, dragon hide, bone, horns, - coral), but the game will not keep track of this for you. Also note - that "milky" potions may be a translucent white, but they do not con- - tain milk, so they are compatible with a vegan diet. Slime molds or - player-defined "fruits", although they could be anything from "cher- + digest attack against a monster is equivalent to eating the monster's + corpse. Please note that the term "vegan" is used here only in the + context of diet. You are still free to choose not to use or wear + items derived from animals (e.g. leather, dragon hide, bone, horns, + coral), but the game will not keep track of this for you. Also note + that "milky" potions may be a translucent white, but they do not con- + tain milk, so they are compatible with a vegan diet. Slime molds or + player-defined "fruits", although they could be anything from "cher- ries" to "pork chops", are also assumed to be vegan. An atheist is one who rejects religion. This means that you can- @@ -3414,50 +3460,51 @@ other religious figure; a true atheist would hear the words but attach no special meaning to them. - Most players fight with a wielded weapon (or tool intended to be - wielded as a weapon). Another challenge is to win the game without - using such a wielded weapon. You are still permitted to throw, fire, - and kick weapons; use a wand, spell, or other type of item; or fight + Most players fight with a wielded weapon (or tool intended to be + wielded as a weapon). Another challenge is to win the game without + using such a wielded weapon. You are still permitted to throw, fire, + and kick weapons; use a wand, spell, or other type of item; or fight with your hands and feet. - In NetHack, a pacifist refuses to cause the death of any other - monster (i.e. if you would get experience for the death). This is a - particularly difficult challenge, although it is still possible to + In NetHack, a pacifist refuses to cause the death of any other + monster (i.e. if you would get experience for the death). This is a + particularly difficult challenge, although it is still possible to gain experience by other means. - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 53 - - - - An illiterate character does not read or write. This includes + An illiterate character does not read or write. This includes reading a scroll, spellbook, fortune cookie message, or t-shirt; writ- ing a scroll; or making an engraving of anything other than a single "X" (the traditional signature of an illiterate person). Reading an engraving, or any item that is absolutely necessary to win the game, is not counted against this conduct. The identity of scrolls and spellbooks (and knowledge of spells) in your starting inventory is as- - sumed to be learned from your teachers prior to the start of the game + sumed to be learned from your teachers prior to the start of the game and isn't counted. - There is a side-branch to the main dungeon called "Sokoban," - briefly described in the earlier section about Traps. As mentioned - there, the goal is to push boulders into pits and/or holes to plug - those in order to both get the boulders out of the way and be able to - go past the traps. There are some special "rules" that are active - when in that branch of the dungeon. Some rules can't be bypassed, - such as being unable to push a boulder diagonally. Other rules can, + There is a side-branch to the main dungeon called "Sokoban," + briefly described in the earlier section about Traps. As mentioned + there, the goal is to push boulders into pits and/or holes to plug + those in order to both get the boulders out of the way and be able to + go past the traps. There are some special "rules" that are active + when in that branch of the dungeon. Some rules can't be bypassed, + such as being unable to push a boulder diagonally. Other rules can, such as not smashing boulders with magic or tools, but doing so causes you to receive a luck penalty. No message about that is given at the + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 54 + + + time, but it is tracked as a conduct. The #conduct command and end of - game disclosure will report whether you have abided by the special - rules of Sokoban, and if not, how many times you violated them, pro- + game disclosure will report whether you have abided by the special + rules of Sokoban, and if not, how many times you violated them, pro- viding you with a way to discover which actions incur bad luck so that you can be better informed about whether or not to avoid repeating those actions in the future. (Note: the Sokoban conduct will only be @@ -3471,10 +3518,10 @@ There are several other challenges tracked by the game. It is possible to eliminate one or more species of monsters by genocide; playing without this feature is considered a challenge. When the game - offers you an opportunity to genocide monsters, you may respond with - the monster type "none" if you want to decline. You can change the - form of an item into another item of the same type ("polypiling") or - the form of your own body into another creature ("polyself") by wand, + offers you an opportunity to genocide monsters, you may respond with + the monster type "none" if you want to decline. You can change the + form of an item into another item of the same type ("polypiling") or + the form of your own body into another creature ("polyself") by wand, spell, or potion of polymorph; avoiding these effects are each consid- ered challenges. Polymorphing monsters, including pets, does not break either of these challenges. Finally, you may sometimes receive @@ -3490,18 +3537,6 @@ representing progress toward ultimate ascension, if any have been at- tained. They aren't directly related to conduct but are grouped with it because they fall into the same category of "bragging rights" and - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 54 - - - to limit the number of questions during disclosure. Listed here roughly in order of difficulty and not necessarily in the order in which you might accomplish them. @@ -3521,6 +3556,18 @@ and found a special item there. Medusa - Defeated Medusa. Tune - Discovered the tune that can be used to open and close + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 55 + + + the drawbridge on the Castle level. Bell - Acquired the Bell of Opening. Gehennom - Entered Gehennom. @@ -3547,30 +3594,18 @@ to revert to lower rank(s) does not discard the corresponding achieve- ment(s). - There's no guaranteed Novel so the achievement to read one might - not always be attainable (except perhaps by wishing). Similarly, the - Big Room level is not always present. Unlike with the Novel, there's + There's no guaranteed Novel so the achievement to read one might + not always be attainable (except perhaps by wishing). Similarly, the + Big Room level is not always present. Unlike with the Novel, there's no way to wish for this opportunity. - The "special items" hidden in Mines' End and Sokoban are not - unique but are considered to be prizes or rewards for exploring those - levels since doing so is not necessary to complete the game. Finding - other instances of the same objects doesn't record the corresponding - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 55 - - - + The "special items" hidden in Mines' End and Sokoban are not + unique but are considered to be prizes or rewards for exploring those + levels since doing so is not necessary to complete the game. Finding + other instances of the same objects doesn't record the corresponding achievement. - The Medusa achievement is recorded if she dies for any reason, + The Medusa achievement is recorded if she dies for any reason, even if you are not directly responsible, and only if she dies. The 5-note tune can be learned via trial and error with a musical @@ -3581,13 +3616,28 @@ enabled by setting the correspondingly named option in NETHACKOPTIONS or run-time configuration file prior to game start. In the case of Blind and Deaf, the option also enforces the conduct. They aren't re- - ally significant accomplishments unless/until you make substantial + ally significant accomplishments unless/until you make substantial progress into the dungeon. + + + + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 56 + + + 9. Options - Due to variations in personal tastes and conceptions of how - NetHack should do things, there are options you can set to change how + Due to variations in personal tastes and conceptions of how + NetHack should do things, there are options you can set to change how NetHack behaves. 9.1. Setting the options @@ -3609,31 +3659,19 @@ directory. The file may not exist, but it is a normal ASCII text file and can be created with any text editor. - On Windows, the name is ".nethackrc" located in the folder - "%USERPROFILE%\NetHack\". The file may not exist, but it is a normal - ASCII text file can can be created with any text editor. After run- - ning NetHack for the first time, you should find a default template - for the configuration file named ".nethackrc.template" in - "%USERPROFILE%\NetHack\". If you have not created the configuration + On Windows, the name is ".nethackrc" located in the folder + "%USERPROFILE%\NetHack\". The file may not exist, but it is a normal + ASCII text file can can be created with any text editor. After run- + ning NetHack for the first time, you should find a default template + for the configuration file named ".nethackrc.template" in + "%USERPROFILE%\NetHack\". If you have not created the configuration file, NetHack will create one for you using the default template file. On MS-DOS, it is "defaults.nh" in the same folder as nethack.exe. - Any line in the configuration file starting with `#' is treated + Any line in the configuration file starting with `#' is treated as a comment and ignored. Empty lines are ignored. - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 56 - - - Any line beginning with `[' and ending in `]' is a section marker (the closing `]' can be followed by whitespace and then an arbitrary comment beginning with `#'). The text between the square brackets is @@ -3649,14 +3687,27 @@ written in capital letters, followed by an equals sign, followed by settings particular to that directive. + + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 57 + + + Here is a list of allowed directives: OPTIONS - There are two types of options, boolean and compound options. Bool- - ean options toggle a setting on or off, while compound options take - more diverse values. Prefix a boolean option with "no" or `!' to - turn it off. For compound options, the option name and value are - separated by a colon. Some options are persistent, and apply only + There are two types of options, boolean and compound options. + Boolean options toggle a setting on or off, while compound options + take more diverse values. Prefix a boolean option with "no" or `!' + to turn it off. For compound options, the option name and value are + separated by a colon. Some options are persistent, and apply only to new games. You can specify multiple OPTIONS directives, and mul- tiple options separated by commas in a single OPTIONS directive. (Comma separated options are processed from right to left.) @@ -3668,15 +3719,15 @@ HACKDIR Default location of files NetHack needs. On Windows HACKDIR defaults - to the location of the NetHack.exe or NetHackw.exe file so setting + to the location of the NetHack.exe or NetHackw.exe file so setting HACKDIR to override that is not usually necessary or recommended. LEVELDIR - The location that in-progress level files are stored. Defaults to + The location that in-progress level files are stored. Defaults to HACKDIR, must be writable. SAVEDIR - The location where saved games are kept. Defaults to HACKDIR, must + The location where saved games are kept. Defaults to HACKDIR, must be writable. BONESDIR @@ -3687,33 +3738,33 @@ The location that file synchronization locks are stored. Defaults to HACKDIR, must be writable. + TROUBLEDIR + The location that a record of game aborts and self-diagnosed game + problems is kept. Defaults to HACKDIR, must be writable. + AUTOCOMPLETE + Enable or disable an extended command autocompletion. Autocomple- + tion has no effect for the X11 windowport. You can specify multiple + autocompletions. To enable autocompletion, list the extended com- + mand. Prefix the command with "!" to disable the autocompletion for + that command. + Example: - NetHack 3.7.0 November 13, 2023 + AUTOCOMPLETE=zap,!annotate + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 57 - TROUBLEDIR - The location that a record of game aborts and self-diagnosed game - problems is kept. Defaults to HACKDIR, must be writable. - AUTOCOMPLETE - Enable or disable an extended command autocompletion. Autocomple- - tion has no effect for the X11 windowport. You can specify multiple - autocompletions. To enable autocompletion, list the extended com- - mand. Prefix the command with "!" to disable the autocompletion for - that command. + NetHack Guidebook 58 - Example: - AUTOCOMPLETE=zap,!annotate AUTOPICKUP_EXCEPTION Set exceptions to the pickup_types option. See the "Configuring Au- @@ -3721,8 +3772,8 @@ BINDINGS Change the key bindings of some special keys, menu accelerators, ex- - tended commands, or mouse buttons. You can specify multiple bind- - ings. Format is key followed by the command, separated by a colon. + tended commands, or mouse buttons. You can specify multiple bind- + ings. Format is key followed by the command, separated by a colon. See the "Changing Key Bindings" section for more information. Example: @@ -3745,43 +3796,43 @@ OPTIONS=!rest_on_space If [] is present, the preceding section is closed and no new section - begins; whatever follows will be common to all sections. Otherwise + begins; whatever follows will be common to all sections. Otherwise the last section extends to the end of the options file. MENUCOLOR - Highlight menu lines with different colors. See the "Configuring + Highlight menu lines with different colors. See the "Configuring Menu Colors" section. MSGTYPE - Change the way messages are shown in the top status line. See the + Change the way messages are shown in the top status line. See the + "Configuring Message Types" section. + ROGUESYMBOLS + Custom symbols for for the rogue level's symbol set. See SYMBOLS + below. - NetHack 3.7.0 November 13, 2023 + SOUND + Define a sound mapping. See the "Configuring User Sounds" section. + SOUNDDIR + Define the directory that contains the sound files. See the "Con- + figuring User Sounds" section. + SYMBOLS + Override one or more symbols in the symbol set used for all dungeon + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 58 - "Configuring Message Types" section. - ROGUESYMBOLS - Custom symbols for for the rogue level's symbol set. See SYMBOLS - below. + NetHack Guidebook 59 - SOUND - Define a sound mapping. See the "Configuring User Sounds" section. - SOUNDDIR - Define the directory that contains the sound files. See the "Con- - figuring User Sounds" section. - SYMBOLS - Override one or more symbols in the symbol set used for all dungeon - levels except for the special rogue level. See the "Modifying + levels except for the special rogue level. See the "Modifying NetHack Symbols" section. Example: @@ -3821,37 +3872,35 @@ + 9.3. Using the NETHACKOPTIONS environment variable - NetHack 3.7.0 November 13, 2023 - - + The NETHACKOPTIONS variable is a comma-separated list of initial + values for the various options. Some can only be turned on or off. + You turn one of these on by adding the name of the option to the list, + and turn it off by typing a `!' or "no" before the name. Others take + a character string as a value. You can set string options by typing + the option name, a colon or equals sign, and then the value of the + string. The value is terminated by the next comma or the end of + string. + For example, to set up an environment variable so that color is + on, legacy is off, character name is set to "Blue Meanie", and named + fruit is set to "lime", you would enter the command - NetHack Guidebook 59 + NetHack 3.7.0 December 08, 2023 - 9.3. Using the NETHACKOPTIONS environment variable + NetHack Guidebook 60 - The NETHACKOPTIONS variable is a comma-separated list of initial - values for the various options. Some can only be turned on or off. - You turn one of these on by adding the name of the option to the list, - and turn it off by typing a `!' or "no" before the name. Others take - a character string as a value. You can set string options by typing - the option name, a colon or equals sign, and then the value of the - string. The value is terminated by the next comma or the end of - string. - For example, to set up an environment variable so that color is - on, legacy is off, character name is set to "Blue Meanie", and named - fruit is set to "lime", you would enter the command % setenv NETHACKOPTIONS "color,\!leg,name:Blue Meanie,fruit:lime" - in csh (note the need to escape the `!' since it's special to that + in csh (note the need to escape the `!' since it's special to that shell), or the pair of commands $ NETHACKOPTIONS="color,!leg,name:Blue Meanie,fruit:lime" @@ -3859,7 +3908,7 @@ in sh, ksh, or bash. - The NETHACKOPTIONS value is effectively the same as a single OP- + The NETHACKOPTIONS value is effectively the same as a single OP- TIONS directive in a configuration file. The "OPTIONS=" prefix is im- plied and comma separated options are processed from right to left. Other types of configuration directives such as BIND or MSGTYPE are @@ -3882,22 +3931,10 @@ applies only to new games. acoustics - Enable messages about what your character hears (default on). Note + Enable messages about what your character hears (default on). Note that this has nothing to do with your computer's audio capabilities. Persistent. - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 60 - - - alignment Your starting alignment (align:lawful, align:neutral, or align:chaotic). You may specify just the first letter. Many roles @@ -3915,6 +3952,18 @@ Automatically dig if you are wielding a digging tool and moving into a place that can be dug (default false). Persistent. + + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 61 + + + autoopen Walking into a closed door attempts to open it (default true). Per- sistent. @@ -3933,44 +3982,32 @@ command when nothing is quivered or readied (default false). When true, the computer will fill your quiver or quiver sack or make ready some suitable weapon. Note that it will not take into account - the blessed/cursed status, enchantment, damage, or quality of the - weapon; you are free to manually fill your quiver or quiver sack or - make ready with the `Q' command instead. If no weapon is found or - the option is false, the `t' (throw) command is executed instead. + the blessed/cursed status, enchantment, damage, or quality of the + weapon; you are free to manually fill your quiver or quiver sack or + make ready with the `Q' command instead. If no weapon is found or + the option is false, the `t' (throw) command is executed instead. Persistent. autounlock - Controls what action to take when attempting to walk into a locked - door or to loot a locked container. Takes a plus-sign separated + Controls what action to take when attempting to walk into a locked + door or to loot a locked container. Takes a plus-sign separated list of values: Untrap - prompt about whether to attempt to find a trap; it might fail to find one even when present; if it does find one, - it will ask whether you want to try to disarm the trap; + it will ask whether you want to try to disarm the trap; if you decline, your character will forget that the door or box is trapped; Apply-Key - if carrying a key or other unlocking tool, prompt about using it; Kick - kick the door (if you omit untrap or decline to attempt - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 61 - - - untrap and you omit apply-key or you lack a key or you decline to use the key; has no effect on containers); Force - try to force a container's lid with your currently wielded weapon (if you omit untrap or decline to attempt - untrap and you omit apply-key or you lack a key or you + untrap and you omit apply-key or you lack a key or you decline to use the key; has no effect on doors); - None - none of the above; can't be combined with the other + None - none of the above; can't be combined with the other choices. Omitting the value is treated as if autounlock:apply-key. Preceding @@ -3982,6 +4019,17 @@ its lock and might also destroy some of its contents or damage your weapon or both. + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 62 + + + The default is Apply-Key. Persistent. blind @@ -4007,37 +4055,46 @@ program crash (default on). Persistent. cmdassist - Have the game provide some additional command assistance for new + Have the game provide some additional command assistance for new players if it detects some anticipated mistakes (default on). confirm - Have user confirm attacks on pets, shopkeepers, and other peaceable + Have user confirm attacks on pets, shopkeepers, and other peaceable creatures (default on). Persistent. dark_room Show out-of-sight areas of lit rooms (default on). Persistent. + deaf + Start the character permanently deaf (default false). Persistent. + dropped_nopick + If this option is on, items you dropped will not be automatically + picked up, even if autopickup is also on and they are in + pickup_types or match a positive autopickup exception (defualt on). + Persistent. + disclose + Controls what information the program reveals when the game ends. + Value is a space separated list of prompting/category pairs (default + is "ni na nv ng nc no", prompt with default response of `n' for each + candidate). Persistent. The possibilities are: - NetHack 3.7.0 November 13, 2023 - NetHack Guidebook 62 + NetHack 3.7.0 December 08, 2023 - deaf - Start the character permanently deaf (default false). Persistent. - disclose - Controls what information the program reveals when the game ends. - Value is a space separated list of prompting/category pairs (default - is "ni na nv ng nc no", prompt with default response of `n' for each - candidate). Persistent. The possibilities are: + + + NetHack Guidebook 63 + + i - disclose your inventory; a - disclose your attributes; @@ -4071,12 +4128,12 @@ of-game disclosure follows a set sequence. (for example "disclose:yi na +v -g o") The example sets inventory to - prompt and default to yes, attributes to prompt and default to no, - vanquished to disclose without prompting, genocided to not disclose - and not prompt, conduct to implicitly prompt and default to no, and + prompt and default to yes, attributes to prompt and default to no, + vanquished to disclose without prompting, genocided to not disclose + and not prompt, conduct to implicitly prompt and default to no, and overview to disclose without prompting. - Note that the vanquished monsters list includes all monsters killed + Note that the vanquished monsters list includes all monsters killed by traps and each other as well as by you. And the dungeon overview shows all levels you had visited but does not reveal things about them that you hadn't discovered. @@ -4085,25 +4142,26 @@ Name your starting dog (for example "dogname:Fang"). Cannot be set with the `O' command. + extmenu + Changes the extended commands interface to pop-up a menu of avail- + able commands. It is keystroke compatible with the traditional in- + terface except that it does not require that you hit Enter. It is + implemented for the tty interface (default off). - NetHack 3.7.0 November 13, 2023 + For the X11 interface, which always uses a menu for choosing an ex- + tended command, it controls whether the menu shows all available + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 63 + NetHack Guidebook 64 + - extmenu - Changes the extended commands interface to pop-up a menu of avail- - able commands. It is keystroke compatible with the traditional in- - terface except that it does not require that you hit Enter. It is - implemented for the tty interface (default off). - For the X11 interface, which always uses a menu for choosing an ex- - tended command, it controls whether the menu shows all available commands (on) or just the subset of commands which have tradition- ally been considered extended ones (off). @@ -4112,9 +4170,9 @@ command. fireassist - This option controls what happens when you attempt the `f' (fire) - and don't have an appropriate launcher, such as a bow or a sling, - wielded. If on, you will automatically wield the launcher. Default + This option controls what happens when you attempt the `f' (fire) + and don't have an appropriate launcher, such as a bow or a sling, + wielded. If on, you will automatically wield the launcher. Default is on. fixinv @@ -4129,15 +4187,15 @@ fruit Name a fruit after something you enjoy eating (for example "fruit:mango") (default "slime mold"). Basically a nostalgic whimsy - that NetHack uses from time to time. You should set this to some- - thing you find more appetizing than slime mold. Apples, oranges, - pears, bananas, and melons already exist in NetHack, so don't use + that NetHack uses from time to time. You should set this to some- + thing you find more appetizing than slime mold. Apples, oranges, + pears, bananas, and melons already exist in NetHack, so don't use those. gender - Your starting gender (gender:male or gender:female). You may spec- - ify just the first letter. Although you can still denote your gen- - der using either of the deprecated male and female options, if the + Your starting gender (gender:male or gender:female). You may spec- + ify just the first letter. Although you can still denote your gen- + der using either of the deprecated male and female options, if the gender option is also present it will take precedence. See role for a description of how to use negation to exclude choices. @@ -4145,30 +4203,30 @@ goldX When filtering objects based on bless/curse state (BUCX), whether to - treat gold pieces as X (unknown bless/curse state, when "on") or U - (known to be uncursed, when "off", the default). Gold is never - blessed or cursed, but it is not described as "uncursed" even when + treat gold pieces as X (unknown bless/curse state, when "on") or U + (known to be uncursed, when "off", the default). Gold is never + blessed or cursed, but it is not described as "uncursed" even when the implicit_uncursed option is "off". + help + If more information is available for an object looked at with the + `/' command, ask if you want to see it (default on). Turning help + off makes just looking at things faster, since you aren't inter- + rupted with the "More info?" prompt, but it also means that you + might miss some interesting and/or important information. Persis- + tent. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 64 + NetHack Guidebook 65 - help - If more information is available for an object looked at with the - `/' command, ask if you want to see it (default on). Turning help - off makes just looking at things faster, since you aren't inter- - rupted with the "More info?" prompt, but it also means that you - might miss some interesting and/or important information. Persis- - tent. herecmd_menu When using a windowport that supports mouse and clicking on yourself @@ -4181,12 +4239,12 @@ In text windowing, text highlighting or inverse video is often used; with tiles, generally displays a heart symbol near pets. - With the curses interface, the petattr option controls how to high- - light pets and setting it will turn the hilite_pet option on or off + With the curses interface, the petattr option controls how to high- + light pets and setting it will turn the hilite_pet option on or off as warranted. hilite_pile - Visually distinguish piles of objects from individual objects (de- + Visually distinguish piles of objects from individual objects (de- fault off). The behavior of this option depends on the type of win- dowing you use. In text windowing, text highlighting or inverse video is often used; with tiles, generally displays a small plus- @@ -4216,44 +4274,45 @@ lit_corridor Show corridor squares seen by night vision or a light source held by + your character as lit (default off). Persistent. + lootabc + When using a menu to interact with a container, use the old `a', + `b', and `c' keyboard shortcuts rather than the mnemonics `o', `i', + and `b' (default off). Persistent. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 65 - your character as lit (default off). Persistent. + NetHack Guidebook 66 + - lootabc - When using a menu to interact with a container, use the old `a', - `b', and `c' keyboard shortcuts rather than the mnemonics `o', `i', - and `b' (default off). Persistent. mail Enable mail delivery during the game (default on). Persistent. male - An obsolete synonym for "gender:male". Cannot be set with the `O' + An obsolete synonym for "gender:male". Cannot be set with the `O' command. mention_decor - Give feedback when walking onto various dungeon features such as - stairs, fountains, or altars which are ordinarily only described - when covered by one or more objects (default off). Cannot be set + Give feedback when walking onto various dungeon features such as + stairs, fountains, or altars which are ordinarily only described + when covered by one or more objects (default off). Cannot be set with the `O' command. Persistent. mention_walls - Give feedback when walking against a wall (default off). Persis- + Give feedback when walking against a wall (default off). Persis- tent. menucolors - Enable coloring menu lines (default off). See "Configuring Menu + Enable coloring menu lines (default off). See "Configuring Menu Colors" on how to configure the colors. menustyle @@ -4267,7 +4326,7 @@ it consists of a prompt for object class characters, followed by an object-by-object prompt for all items matching the selected object class(es). Combination starts with a prompt for object class(es) of - interest, but then displays a menu of matching objects rather than + interest, but then displays a menu of matching objects rather than prompting one-by-one. Full displays a menu of object classes rather than a character prompt, and then a menu of matching objects for se- lection. (Choosing its `A' (Autoselect-All) choice skips the second @@ -4281,27 +4340,25 @@ menu_deselect_page Key to deselect all items on this page of a menu. Default `\'. + menu_first_page + Key to jump to the first page in a menu. Default `^'. + menu_headings + Controls how the headings in a menu are highlighted. Takes a text + attribute, or text color and attribute separated by ampersand. For + allowed attributes and colors, see "Configuring Menu Colors". Not + all ports can actually display all types. - NetHack 3.7.0 November 13, 2023 - - + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 66 + NetHack Guidebook 67 - menu_first_page - Key to jump to the first page in a menu. Default `^'. - menu_headings - Controls how the headings in a menu are highlighted. Takes a text - attribute, or text color and attribute separated by ampersand. For - allowed attributes and colors, see "Configuring Menu Colors". Not - all ports can actually display all types. menu_invert_all Key to invert all items in a menu. Default `@'. @@ -4316,7 +4373,7 @@ Key to go to the next menu page. Default `>'. menu_objsyms - Show object symbols in menu headings in menus where the object sym- + Show object symbols in menu headings in menus where the object sym- bols act as menu accelerators (default off). menu_overlay @@ -4338,36 +4395,36 @@ menu_shift_left Key to scroll a menu--one which has been scrolled right--back to the - left. Implemented for perm_invent only by curses and X11. Default + left. Implemented for perm_invent only by curses and X11. Default `{'. menu_shift_right - Key to scroll a menu which has text beyond the right edge to the + Key to scroll a menu which has text beyond the right edge to the right. Implemented for perm_invent only by curses and X11. Default `}'. monpolycontrol Prompt for new form whenever any monster changes shape (default + off). Debug mode only. + montelecontrol + Prompt for destination whenever any monster gets teleported (default + off). Debug mode only. - NetHack 3.7.0 November 13, 2023 + mouse_support + Allow use of the mouse for input and travel. Valid settings are: + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 67 - off). Debug mode only. + NetHack Guidebook 68 - montelecontrol - Prompt for destination whenever any monster gets teleported (default - off). Debug mode only. - mouse_support - Allow use of the mouse for input and travel. Valid settings are: 0 - disabled 1 - enabled and make OS adjustments to support mouse use @@ -4404,7 +4461,7 @@ news Read the NetHack news file, if present (default on). Since the news - is shown at the beginning of the game, there's no point in setting + is shown at the beginning of the game, there's no point in setting this with the `O' command. nudist @@ -4413,19 +4470,6 @@ null Send padding nulls to the terminal (default on). Persistent. - - - - NetHack 3.7.0 November 13, 2023 - - - - - - NetHack Guidebook 68 - - - number_pad Use digit keys instead of letters to move (default 0 or off). Valid settings are: @@ -4437,42 +4481,53 @@ 4 - combines 3 with 2; phone layout plus MS-DOS compatibility -1 - by letters but use `z' to go northwest, `y' to zap wands + + NetHack 3.7.0 December 08, 2023 + + + + + + NetHack Guidebook 69 + + + For backward compatibility, omitting a value is the same as specify- - ing 1 and negating number_pad is the same as specifying 0. (Set- - tings 2 and 4 are for compatibility with MS-DOS or old PC Hack; in - addition to the different behavior for `5', `Alt-5' acts as `G' and - `Alt-0' acts as `I'. Setting -1 is to accommodate some QWERTZ key- - boards which have the location of the `y' and `z' keys swapped.) - When moving by numbers, to enter a count prefix for those commands - which accept one (such as "12s" to search twelve times), precede it + ing 1 and negating number_pad is the same as specifying 0. (Set- + tings 2 and 4 are for compatibility with MS-DOS or old PC Hack; in + addition to the different behavior for `5', `Alt-5' acts as `G' and + `Alt-0' acts as `I'. Setting -1 is to accommodate some QWERTZ key- + boards which have the location of the `y' and `z' keys swapped.) + When moving by numbers, to enter a count prefix for those commands + which accept one (such as "12s" to search twelve times), precede it with the letter `n' ("n12s"). packorder - Specify the order to list object types in (default + Specify the order to list object types in (default "")[%?+!=/(*`0_"). The value of this option should be a string con- taining the symbols for the various object types. Any omitted types are filled in at the end from the previous order. paranoid_confirmation - A space separated list of specific situations where alternate - prompting is desired. The default is "paranoid_confirmation:pray + A space separated list of specific situations where alternate + prompting is desired. The default is "paranoid_confirmation:pray swim". - Confirm - for any prompts which are set to require "yes" rather - than `y', also require "no" to reject instead of ac- - cepting any non-yes response as no; changes pray and + Confirm - for any prompts which are set to require "yes" rather + than `y', also require "no" to reject instead of ac- + cepting any non-yes response as no; changes pray and AutoAll to require "yes" or `no' too; - quit - require "yes" rather than `y' to confirm quitting the + quit - require "yes" rather than `y' to confirm quitting the game or switching into non-scoring explore mode; - die - require "yes" rather than `y' to confirm dying (not + die - require "yes" rather than `y' to confirm dying (not useful in normal play; applies to explore mode); - bones - require "yes" rather than `y' to confirm saving bones + bones - require "yes" rather than `y' to confirm saving bones data when dying in debug mode; - attack - require "yes" rather than `y' to confirm attacking a + attack - require "yes" rather than `y' to confirm attacking a peaceful monster; - wand-break - require "yes" rather than `y' to confirm breaking a + wand-break - require "yes" rather than `y' to confirm breaking a wand with the apply command; - eating - require "yes" rather than `y' to confirm whether to + eating - require "yes" rather than `y' to confirm whether to continue eating; Were-change - require "yes" rather than `y' to confirm changing form due to lycanthropy when hero has polymorph control; @@ -4480,29 +4535,29 @@ immediately praying; on by default; (to require "yes" rather than just `y', set Confirm too); trap - require `y' to confirm an attempt to move into or onto + a known trap, unless doing so is considered to be + harmless; (to require "yes" rather than just `y', set + Confirm too); confirmation can be skipped by using the + `m' movement prefix; + swim - prevent walking into water or lava; on by default; (to + deliberately step onto/into such terrain when this is + set, use the `m' movement prefix when adjacent); + AutoAll - require confirmation when the `A' (Autoselect-All) + choice is selected in object class filtering menus for + menustyle:Full; (to require "yes" rather than just + `y', set Confirm too); - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 69 + NetHack Guidebook 70 - a known trap, unless doing so is considered to be - harmless; (to require "yes" rather than just `y', set - Confirm too); confirmation can be skipped by using the - `m' movement prefix; - swim - prevent walking into water or lava; on by default; (to - deliberately step onto/into such terrain when this is - set, use the `m' movement prefix when adjacent); - AutoAll - require confirmation when the `A' (Autoselect-All) - choice is selected in object class filtering menus for - menustyle:Full; (to require "yes" rather than just - `y', set Confirm too); Remove - require selection from inventory for `R' and `T' com- mands even when wearing just one applicable item; all - turn on all of the above. @@ -4526,7 +4581,7 @@ false). This only makes sense for windowing system interfaces that implement - this feature. For those that do, the perminv_mode option can be + this feature. For those that do, the perminv_mode option can be used to refine what gets displayed for perm_invent. Setting that to a value other than none while perm_invent is false will change it to true. @@ -4545,24 +4600,29 @@ Note: if gold has been equipped in quiver/ammo-pouch then it will be included for all despite that mode normally omitting gold. + petattr + Specifies one or more text highlighting attributes to use when show- + ing pets on the map. Effectively a superset of the hilite_pet + boolean option. Curses interface only; value is one or more of the + following letters. - NetHack 3.7.0 November 13, 2023 - NetHack Guidebook 70 + + NetHack 3.7.0 December 08, 2023 + - petattr - Specifies one or more text highlighting attributes to use when show- - ing pets on the map. Effectively a superset of the hilite_pet bool- - ean option. Curses interface only; value is one or more of the fol- - lowing letters. + + NetHack Guidebook 71 + + n - Normal text (no highlighting) i - Inverse video (default) @@ -4578,28 +4638,34 @@ depending upon terminal hardware or terminal emulation software. Currently multiple highlight-style letters can be combined by simply - stringing them together (for example, "bk"), but in the future they - might require being separated by plus signs (such as "b+k", which - works already). When using the `n' choice, it should be specified + stringing them together (for example, "bk"), but in the future they + might require being separated by plus signs (such as "b+k", which + works already). When using the `n' choice, it should be specified on its own, not in combination with any of the other letters. pettype Specify the type of your initial pet, if you are playing a character class that uses multiple types of pets; or choose to have no initial - pet at all. Possible values are "cat", "dog", "horse", and "none". + pet at all. Possible values are "cat", "dog", "horse", and "none". If the choice is not allowed for the role you are currently playing, it will be silently ignored. For example, "horse" will only be hon- ored when playing a knight. Cannot be set with the `O' command. pickup_burden - When you pick up an item that would exceed this encumbrance level - (Unencumbered, Burdened, streSsed, straiNed, overTaxed, or over- - Loaded), you will be asked if you want to continue. (Default `S'). + When you pick up an item that would exceed this encumbrance level + (Unencumbered, Burdened, streSsed, straiNed, overTaxed, or over- + Loaded), you will be asked if you want to continue. (Default `S'). Persistent. + pickup_stolen + If this option is on and autopickup is also on, try to pick up + things that a monster stole from you, even if they aren't in + pickup_types or match an autopickup exception. Default is on. Per- + sistent. + pickup_thrown - If this option is on and autopickup is also on, try to pick up - things that you threw, even if they aren't in pickup_types or match + If this option is on and autopickup is also on, try to pick up + things that you threw, even if they aren't in pickup_types or match an autopickup exception. Default is on. Persistent. pickup_types @@ -4614,13 +4680,13 @@ empty value reverts to "all".) If you want to avoid automatically - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 71 + NetHack Guidebook 72 @@ -4633,7 +4699,7 @@ pile_limit When walking across a pile of objects on the floor, threshold at which the message "there are few/several/many objects here" is given - instead of showing a popup list of those objects. A value of 0 + instead of showing a popup list of those objects. A value of 0 means "no limit" (always list the objects); a value of 1 effectively means "never show the objects" since the pile size will always be at least that big; default value is 5. Persistent. @@ -4656,14 +4722,14 @@ quick_farsight When set, usually prevents the "you sense your surroundings" message - where play pauses to allow you to browse the map whenever clairvoy- - ance randomly activates. Some situations, such as being underwater - or engulfed, ignore this option. It does not affect the clairvoy- - ance spell where pausing to examine revealed objects or monsters is + where play pauses to allow you to browse the map whenever clairvoy- + ance randomly activates. Some situations, such as being underwater + or engulfed, ignore this option. It does not affect the clairvoy- + ance spell where pausing to examine revealed objects or monsters is less intrusive. Default is off. Persistent. race - Selects your race (for example, race:human). Choices are human, + Selects your race (for example, race:human). Choices are human, dwarf, elf, gnome, and orc but most roles restrict which of the non- human races are allowed. See role for a description of how to use negation to exclude choices. @@ -4676,23 +4742,23 @@ role Pick your type of character (for example, role:Samurai); synonym for - character. See name for an alternate method of specifying your + character. See name for an alternate method of specifying your role. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 72 + NetHack Guidebook 73 - This option can also be used to limit selection when role is chosen - randomly. Use a space-separated list of roles and either negate - each one or negate the option itself instead. Negation is accom- + This option can also be used to limit selection when role is chosen + randomly. Use a space-separated list of roles and either negate + each one or negate the option itself instead. Negation is accom- plished in the same manner as with boolean options, by prefixing the option or its value(s) with `!' or "no". Examples: @@ -4716,9 +4782,9 @@ on reading an existing save file. runmode - Controls the amount of screen updating for the map window when en- - gaged in multi-turn movement (running via shift+direction or con- - trol+direction and so forth, or via the travel command or mouse + Controls the amount of screen updating for the map window when en- + gaged in multi-turn movement (running via shift+direction or con- + trol+direction and so forth, or via the travel command or mouse click). The possible values are: teleport - update the map after movement has finished; @@ -4726,10 +4792,10 @@ walk - update the map after each step; crawl - like walk, but pause briefly after each step. - This option only affects the game's screen display, not the actual - results of moving. The default is "run"; versions prior to 3.4.1 - used "teleport" only. Whether or not the effect is noticeable will - depend upon the window port used or on the type of terminal. Per- + This option only affects the game's screen display, not the actual + results of moving. The default is "run"; versions prior to 3.4.1 + used "teleport" only. Whether or not the effect is noticeable will + depend upon the window port used or on the type of terminal. Per- sistent. safe_pet @@ -4746,13 +4812,13 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 73 + NetHack Guidebook 74 @@ -4785,45 +4851,45 @@ The possible values are: - o - list object types by class, in discovery order within each + o - list object types by class, in discovery order within each class; default; - s - list object types by sortloot classification: by class, by sub- - class within class for classes which have substantial groupings - (like helmets, boots, gloves, and so forth for armor), with ob- - ject types partly-discovered via assigned name coming before + s - list object types by sortloot classification: by class, by sub- + class within class for classes which have substantial groupings + (like helmets, boots, gloves, and so forth for armor), with ob- + ject types partly-discovered via assigned name coming before fully identified types; c - list by class, alphabetically within each class; a - list alphabetically across all classes. - Can be interactively set via the `O' command or via using the `m' + Can be interactively set via the `O' command or via using the `m' prefix before the `\' or ``' command. sortloot - Controls the sorting behavior of the pickup lists for inventory and + Controls the sorting behavior of the pickup lists for inventory and #loot commands and some others. Persistent. The possible values are: full - always sort the lists; - loot - only sort the lists that don't use inventory letters, like + loot - only sort the lists that don't use inventory letters, like with the #loot and pickup commands; none - show lists the traditional way without sorting; default. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 74 + NetHack Guidebook 75 sortpack - Sort the pack contents by type when displaying inventory (default + Sort the pack contents by type when displaying inventory (default on). Persistent. sortvanquished @@ -4834,9 +4900,9 @@ t - traditional--order by monster level; ties are broken by internal monster index; default; - d - order by monster difficulty rating; ties broken by internal in- + d - order by monster difficulty rating; ties broken by internal in- dex; - a - order alphabetically, first any unique monsters then all the + a - order alphabetically, first any unique monsters then all the others; c - order by monster class, by low to high level within each class; n - order by count, high to low; ties are broken by internal monster @@ -4852,7 +4918,7 @@ on). sparkle - Display a sparkly effect when a monster (including yourself) is hit + Display a sparkly effect when a monster (including yourself) is hit by an attack to which it is resistant (default on). Persistent. standout @@ -4864,12 +4930,12 @@ ing Status Hilites" for further information. status_updates - Allow updates to the status lines at the bottom of the screen (de- + Allow updates to the status lines at the bottom of the screen (de- fault true). suppress_alert - This option may be set to a NetHack version level to suppress alert - notification messages about feature changes for that and prior ver- + This option may be set to a NetHack version level to suppress alert + notification messages about feature changes for that and prior ver- sions (for example "suppress_alert:3.3.1"). symset @@ -4878,13 +4944,13 @@ "symset:default" to explicitly select the default symbols. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 75 + NetHack Guidebook 76 @@ -4926,8 +4992,8 @@ Provide more commentary during the game (default on). Persistent. whatis_coord - When using the `/' or `;' commands to look around on the map with - autodescribe on, display coordinates after the description. Also + When using the `/' or `;' commands to look around on the map with + autodescribe on, display coordinates after the description. Also works in other situations where you are asked to pick a location. The possible settings are: @@ -4938,33 +5004,33 @@ s - screen [row,column] (row is offset to match tty usage); n - none (no coordinates shown) [default]. - The whatis_coord option is also used with the "/m", "/M", "/o", and - "/O" sub-commands of `/', where the "none" setting is overridden + The whatis_coord option is also used with the "/m", "/M", "/o", and + "/O" sub-commands of `/', where the "none" setting is overridden with "map". - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 76 + NetHack Guidebook 77 whatis_filter - When getting a location on the map, and using the keys to cycle - through next and previous targets, allows filtering the possible + When getting a location on the map, and using the keys to cycle + through next and previous targets, allows filtering the possible targets. n - no filtering [default] v - in view only a - in same area only - The area-filter tries to be slightly predictive--if you're standing - on a doorway, it will consider the area on the side of the door you + The area-filter tries to be slightly predictive--if you're standing + on a doorway, it will consider the area on the side of the door you were last moving towards. Filtering can also be changed when getting a location with the "get- @@ -4972,22 +5038,22 @@ whatis_menu When getting a location on the map, and using a key to cycle through - next and previous targets, use a menu instead to pick a target. + next and previous targets, use a menu instead to pick a target. (default off) whatis_moveskip - When getting a location on the map, and using shifted movement keys - or meta-digit keys to fast-move, instead of moving 8 units at a + When getting a location on the map, and using shifted movement keys + or meta-digit keys to fast-move, instead of moving 8 units at a time, move by skipping the same glyphs. (default off) windowtype - When the program has been built to support multiple interfaces, se- - lect which one to use, such as "tty" or "X11" (default depends on - build-time settings; use "#version" to check). Cannot be set with + When the program has been built to support multiple interfaces, se- + lect which one to use, such as "tty" or "X11" (default depends on + build-time settings; use "#version" to check). Cannot be set with the `O' command. - When used, it should be the first option set since its value might - enable or disable the availability of various other options. For + When used, it should be the first option set since its value might + enable or disable the availability of various other options. For multiple lines in a configuration file, that would be the first non- comment line. For a comma-separated list in NETHACKOPTIONS or an OPTIONS line in a configuration file, that would be the rightmost @@ -5004,19 +5070,19 @@ 9.5. Window Port Customization options - Here are explanations of the various options that are used to - customize and change the characteristics of the windowtype that you - have chosen. Character strings that are too long may be truncated. - Not all window ports will adjust for all settings listed here. You + Here are explanations of the various options that are used to + customize and change the characteristics of the windowtype that you + have chosen. Character strings that are too long may be truncated. + Not all window ports will adjust for all settings listed here. You - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 77 + NetHack Guidebook 78 @@ -5029,19 +5095,19 @@ `O' command. align_message - Where to align or place the message window (top, bottom, left, or + Where to align or place the message window (top, bottom, left, or right) align_status - Where to align or place the status window (top, bottom, left, or + Where to align or place the status window (top, bottom, left, or right). ascii_map - If NetHack can, it should display the map using simple characters - (letters and punctuation) rather than tiles graphics. In some - cases, characters can be augmented with line-drawing symbols; use - the symset option to select a symbol set such as DECgraphics or - IBMgraphics if your display supports them. Setting ascii_map to + If NetHack can, it should display the map using simple characters + (letters and punctuation) rather than tiles graphics. In some + cases, characters can be augmented with line-drawing symbols; use + the symset option to select a symbol set such as DECgraphics or + IBMgraphics if your display supports them. Setting ascii_map to True forces tiled_map to be False. color @@ -5050,15 +5116,15 @@ eight_bit_tty If NetHack can, it should pass eight-bit character values (for exam- - ple, specified with the traps option) straight through to your ter- + ple, specified with the traps option) straight through to your ter- minal (default off). font_map - if NetHack can, it should use a font by the chosen name for the map + if NetHack can, it should use a font by the chosen name for the map window. font_menu - If NetHack can, it should use a font by the chosen name for menu + If NetHack can, it should use a font by the chosen name for menu windows. font_message @@ -5070,19 +5136,19 @@ tus window. font_text - If NetHack can, it should use a font by the chosen name for text + If NetHack can, it should use a font by the chosen name for text windows. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 78 + NetHack Guidebook 79 @@ -5102,12 +5168,12 @@ If NetHack can, it should use this size font for text windows. fullscreen - If NetHack can, it should try and display on the entire screen + If NetHack can, it should try and display on the entire screen rather than in a window. guicolor - Use color text and/or highlighting attributes when displaying some - non-map data (such as menu selector letters). Curses interface + Use color text and/or highlighting attributes when displaying some + non-map data (such as menu selector letters). Curses interface only; default is on. large_font @@ -5117,17 +5183,17 @@ If NetHack can, it should display the map in the manner specified. player_selection - If NetHack can, it should pop up dialog boxes, or use prompts for + If NetHack can, it should pop up dialog boxes, or use prompts for character selection. popup_dialog If NetHack can, it should pop up dialog boxes for input. preload_tiles - If NetHack can, it should preload tiles into memory. For example, + If NetHack can, it should preload tiles into memory. For example, in the protected mode MS-DOS version, control whether tiles get pre- loaded into RAM at the start of the game. Doing so enhances perfor- - mance of the tile graphics, but uses more memory. (default on). + mance of the tile graphics, but uses more memory. (default on). Cannot be set with the `O' command. scroll_amount @@ -5142,13 +5208,13 @@ If NetHack can, it should display a menu of existing saved games for - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 79 + NetHack Guidebook 80 @@ -5156,15 +5222,15 @@ support this option. softkeyboard - Display an onscreen keyboard. Handhelds are most likely to support + Display an onscreen keyboard. Handhelds are most likely to support this option. splash_screen - If NetHack can, it should display an opening splash screen when it + If NetHack can, it should display an opening splash screen when it starts up (default yes). statuslines - Number of lines for traditional below-the-map status display. Ac- + Number of lines for traditional below-the-map status display. Ac- ceptable values are 2 and 3 (default is 2). When set to 3, the tty interface moves some fields around and mainly @@ -5175,11 +5241,11 @@ The curses interface does likewise if the align_status option is set to top or bottom but ignores statuslines when set to left or right. - The Qt interface already displays more than 3 lines for status so + The Qt interface already displays more than 3 lines for status so uses the statuslines value differently. A value of 3 renders status in the Qt interface's original format, with the status window spread - out vertically. A value of 2 makes status be slightly condensed, - moving some fields to different lines to eliminate one whole line, + out vertically. A value of 2 makes status be slightly condensed, + moving some fields to different lines to eliminate one whole line, reducing the height needed. (If NetHack has been built using a ver- sion of Qt older than qt-5.9, statuslines can only be set in the run-time configuration file or via NETHACKOPTIONS, not during play @@ -5208,13 +5274,13 @@ Specify the preferred width of each tile in a tile capable port - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 80 + NetHack Guidebook 81 @@ -5246,27 +5312,27 @@ 3 - on, except forced off for perm_invent 4 - auto, except forced off for perm_invent - (The 26x82 size threshold for `2' refers to number of rows and col- - umns of the display. A width of at least 110 columns (80+2+26+2) is - needed to show borders if align_status is set to left or right.) + (The 26x82 size threshold for `2' refers to number of rows and + columns of the display. A width of at least 110 columns (80+2+26+2) + is needed to show borders if align_status is set to left or right.) - The persistent inventory window, when enabled, can grow until it is + The persistent inventory window, when enabled, can grow until it is too big to fit on most displays, resulting in truncation of its con- tents. If borders are forced on (1) or the display is big enough to show them (2), setting the value to 3 or 4 instead will keep borders for the map, message, and status windows but have room for two addi- - tional lines of inventory plus widen each inventory line by two col- - umns. + tional lines of inventory plus widen each inventory line by two + columns. windowcolors - If NetHack can, it should display windows with the specified fore- + If NetHack can, it should display windows with the specified fore- ground/background colors. Windows GUI only. The format is OPTION=windowcolors:wintype foreground/background - where wintype is one of "menu", "message", "status", or "text", + where wintype is one of "menu", "message", "status", or "text", and foreground and background are colors, either a hexadecimal - \'#rrggbb', one of the named colors (black, red, green, brown, blue, + \'#rrggbb', one of the named colors (black, red, green, brown, blue, magenta, cyan, orange, brightgreen, yellow, brightblue, brightmagenta, brightcyan, white, trueblack, gray, purple, silver, maroon, fuchsia, lime, olive, navy, teal, aqua), or one of Windows UI colors (active- @@ -5274,13 +5340,13 @@ btntext, captiontext, graytext, greytext, highlight, highlighttext, - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 81 + NetHack Guidebook 82 @@ -5310,13 +5376,13 @@ prompts. Note that typing one or more digits as a count prefix prior to a command--preceded by n if the number_pad option is set-- is also subject to this conversion, so attempting to abort the count - by typing ESC will leave NetHack waiting for another character to - complete the two character sequence. Type a second ESC to finish + by typing ESC will leave NetHack waiting for another character to + complete the two character sequence. Type a second ESC to finish cancelling such a count. At other prompts a single ESC suffices. BIOS - Use BIOS calls to update the screen display quickly and to read the - keyboard (allowing the use of arrow keys to move) on machines with + Use BIOS calls to update the screen display quickly and to read the + keyboard (allowing the use of arrow keys to move) on machines with an IBM PC compatible BIOS ROM (default off, OS/2, PC, and ST NetHack only). @@ -5329,31 +5395,31 @@ subkeyvalue (Win32 tty NetHack only). May be used to alter the value of key- strokes that the operating system returns to NetHack to help compen- - sate for international keyboard issues. OPTIONS=subkeyvalue:171/92 - will return 92 to NetHack, if 171 was originally going to be re- + sate for international keyboard issues. OPTIONS=subkeyvalue:171/92 + will return 92 to NetHack, if 171 was originally going to be re- turned. You can use multiple subkeyvalue assignments in the config- uration file if needed. Cannot be set with the `O' command. video Set the video mode used (PC NetHack only). Values are "autodetect", - "default", "vga", or "vesa". Setting "vesa" will cause the game to - display tiles, using the full capability of the VGA hardware. + "default", "vga", or "vesa". Setting "vesa" will cause the game to + display tiles, using the full capability of the VGA hardware. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 82 + NetHack Guidebook 83 Setting "vga" will cause the game to display tiles, fixed at 640x480 in 16 colors, a mode that is compatible with all VGA hardware. Third - party tilesets will probably not work. Setting "autodetect" at- - tempts "vesa", then "vga", and finally sets "default" if neither of + party tilesets will probably not work. Setting "autodetect" at- + tempts "vesa", then "vga", and finally sets "default" if neither of those modes works. Cannot be set with the `O' command. video_height @@ -5363,30 +5429,30 @@ Set the VGA mode resolution width (MS-DOS only, with video:vesa) videocolors - Set the color palette for PC systems using NO_TERMS (default - 4-2-6-1-5-3-15-12-10-14-9-13-11, (PC NetHack only). The order of - colors is red, green, brown, blue, magenta, cyan, bright.white, - bright.red, bright.green, yellow, bright.blue, bright.magenta, and + Set the color palette for PC systems using NO_TERMS (default + 4-2-6-1-5-3-15-12-10-14-9-13-11, (PC NetHack only). The order of + colors is red, green, brown, blue, magenta, cyan, bright.white, + bright.red, bright.green, yellow, bright.blue, bright.magenta, and bright.cyan. Cannot be set with the `O' command. videoshades - Set the intensity level of the three gray scales available (default - dark normal light, PC NetHack only). If the game display is diffi- - cult to read, try adjusting these scales; if this does not correct + Set the intensity level of the three gray scales available (default + dark normal light, PC NetHack only). If the game display is diffi- + cult to read, try adjusting these scales; if this does not correct the problem, try !color. Cannot be set with the `O' command. 9.7. Regular Expressions - Regular expressions are normally POSIX extended regular expres- - sions. It is possible to compile NetHack without regular expression - support on a platform where there is no regular expression library. - While this is not true of any modern platform, if your NetHack was - built this way, patterns are instead glob patterns. This applies to + Regular expressions are normally POSIX extended regular expres- + sions. It is possible to compile NetHack without regular expression + support on a platform where there is no regular expression library. + While this is not true of any modern platform, if your NetHack was + built this way, patterns are instead glob patterns. This applies to Autopickup exceptions, Message types, Menu colors, and User sounds. 9.8. Configuring Autopickup Exceptions - You can further refine the behavior of the autopickup option be- + You can further refine the behavior of the autopickup option be- yond what is available through the pickup_types option. By placing autopickup_exception lines in your configuration file, @@ -5406,13 +5472,13 @@ > - never pickup an object that matches rest of pattern. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 83 + NetHack Guidebook 84 @@ -5421,7 +5487,7 @@ later rule to override an earlier rule. Exceptions can be set with the `O' command, but because they are not - included in your configuration file, they won't be in effect if you + included in your configuration file, they won't be in effect if you save and then restore your game. autopickup_exception rules and not saved with the game. @@ -5433,7 +5499,7 @@ The first example above will result in autopickup of any type of arrow. The second example results in the exclusion of any corpse from - autopickup. The last example results in the exclusion of items known + autopickup. The last example results in the exclusion of items known to be cursed from autopickup. 9.9. Changing Key Bindings @@ -5458,7 +5524,7 @@ Menu accelerator keys The menu control or accelerator keys can also be rebound via OPTIONS - lines in the configuration file. You cannot bind object symbols or + lines in the configuration file. You cannot bind object symbols or selection letters into menu accelerators. Some interfaces only sup- port some of the menu accelerators. @@ -5472,30 +5538,30 @@ text", and if bound to same keys, only one of those commands will be - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 84 + NetHack Guidebook 85 available. Special command can only be bound to a single key. count - Prefix key to start a count, to repeat a command this many times. + Prefix key to start a count, to repeat a command this many times. With number_pad only. Default is `n'. getdir.help - When asked for a direction, the key to show the help. Default is + When asked for a direction, the key to show the help. Default is `?'. getdir.mouse - When asked for a direction, the key to initiate a simulated mouse - click. You will be asked to pick a location. Use movement key- - strokes to move the cursor around the map, then type the get- + When asked for a direction, the key to initiate a simulated mouse + click. You will be asked to pick a location. Use movement key- + strokes to move the cursor around the map, then type the get- pos.pick.once key (default `,') or the getpos.pick key (default `.') to finish as if performing a left or right click. Only useful when using the #therecmdmenu command. Default is `_'. @@ -5517,11 +5583,11 @@ thing. Default is `a'. getpos.all.prev - When asked for a location, the key to go to previous closest inter- + When asked for a location, the key to go to previous closest inter- esting thing. Default is `A'. getpos.door.next - When asked for a location, the key to go to next closest door or + When asked for a location, the key to go to next closest door or doorway. Default is `d'. getpos.door.prev @@ -5538,13 +5604,13 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 85 + NetHack Guidebook 86 @@ -5561,69 +5627,69 @@ Default is `O'. getpos.menu - When asked for a location, and using one of the next or previous - keys to cycle through targets, toggle showing a menu instead. De- + When asked for a location, and using one of the next or previous + keys to cycle through targets, toggle showing a menu instead. De- fault is `!'. getpos.moveskip - When asked for a location, and using the shifted movement keys or - meta-digit keys to fast-move around, move by skipping the same + When asked for a location, and using the shifted movement keys or + meta-digit keys to fast-move around, move by skipping the same glyphs instead of by 8 units. Default is `*'. getpos.filter - When asked for a location, change the filtering mode when using one - of the next or previous keys to cycle through targets. Toggles be- - tween no filtering, in view only, and in the same area only. De- + When asked for a location, change the filtering mode when using one + of the next or previous keys to cycle through targets. Toggles be- + tween no filtering, in view only, and in the same area only. De- fault is `"'. getpos.pick - When asked for a location, the key to choose the location, and pos- - sibly ask for more info. When simulating a mouse click after being - asked for a direction (see getdir.mouse above), the key to use to + When asked for a location, the key to choose the location, and pos- + sibly ask for more info. When simulating a mouse click after being + asked for a direction (see getdir.mouse above), the key to use to respond as right click. Default is `.'. getpos.pick.once - When asked for a location, the key to choose the location, and skip - asking for more info. When simulating a mouse click after being + When asked for a location, the key to choose the location, and skip + asking for more info. When simulating a mouse click after being asked for a direction, the key to respond as left click. Default is `,'. getpos.pick.quick When asked for a location, the key to choose the location, skip ask- - ing for more info, and exit the location asking loop. Default is + ing for more info, and exit the location asking loop. Default is `;'. getpos.pick.verbose - When asked for a location, the key to choose the location, and show + When asked for a location, the key to choose the location, and show more info without asking. Default is `:'. getpos.self - When asked for a location, the key to go to your location. Default + When asked for a location, the key to go to your location. Default is `@'. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 86 + NetHack Guidebook 87 getpos.unexplored.next - When asked for a location, the key to go to next closest unexplored + When asked for a location, the key to go to next closest unexplored location. Default is `x'. getpos.unexplored.prev - When asked for a location, the key to go to previous closest unex- + When asked for a location, the key to go to previous closest unex- plored location. Default is `X'. getpos.valid - When asked for a location, the key to go to show valid target loca- + When asked for a location, the key to go to show valid target loca- tions. Default is `$'. getpos.valid.next @@ -5670,13 +5736,13 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 87 + NetHack Guidebook 88 @@ -5702,10 +5768,10 @@ Allowed colors are black, red, green, brown, blue, magenta, cyan, gray, orange, light-green, yellow, light-blue, light-magenta, light- - cyan, and white. And no-color, the default foreground color, which + cyan, and white. And no-color, the default foreground color, which isn't necessarily the same as any of the other colors. - Allowed attributes are none, bold, dim, italic, underline, blink, + Allowed attributes are none, bold, dim, italic, underline, blink, and inverse. "Normal" is a synonym for "none". Note that the plat- form used may interpret the attributes any way it wants. @@ -5718,31 +5784,31 @@ specifies that any menu line with " blessed " contained in it will be shown in green color, lines with " cursed " will be shown in red, - and lines with " cursed " followed by "(being worn)" on the same + and lines with " cursed " followed by "(being worn)" on the same line will be shown in red color and underlined. You can have multi- ple MENUCOLOR entries in your configuration file, and the last MENU- COLOR line that matches a menu line will be used for the line. - Note that if you intend to have one or more color specifications - match " uncursed ", you will probably want to turn the implicit_un- - cursed option off so that all items known to be uncursed are actually + Note that if you intend to have one or more color specifications + match " uncursed ", you will probably want to turn the implicit_un- + cursed option off so that all items known to be uncursed are actually displayed with the "uncursed" description. 9.12. Configuring User Sounds - Some platforms allow you to define sound files to be played when + Some platforms allow you to define sound files to be played when a message that matches a user-defined pattern is delivered to the mes- sage window. At this time the Qt port and the win32tty and win32gui ports support the use of user sounds. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 88 + NetHack Guidebook 89 @@ -5756,9 +5822,9 @@ An entry that maps a sound file to a user-specified message pattern. Each SOUND entry is broken down into the following parts: - MESG - message window mapping (the only one supported in + MESG - message window mapping (the only one supported in 3.7.0); - msgtype - optional; message type to use, see "Configuring Mes- + msgtype - optional; message type to use, see "Configuring Mes- sage Types" pattern - the pattern to match; sound file - the sound file to play; @@ -5777,63 +5843,63 @@ 9.13. Configuring Status Hilites - Your copy of NetHack may have been compiled with support for - "Status Hilites". If so, you can customize your game display by set- - ting thresholds to change the color or appearance of fields in the + Your copy of NetHack may have been compiled with support for + "Status Hilites". If so, you can customize your game display by set- + ting thresholds to change the color or appearance of fields in the status display. The format for defining status colors is: OPTION=hilite_status:field-name/behavior/color&attributes - For example, the following line in your configuration file will - cause the hitpoints field to display in the color red if your hit- + For example, the following line in your configuration file will + cause the hitpoints field to display in the color red if your hit- points drop to or below a threshold of 30%: OPTION=hilite_status:hitpoints/<=30%/red/normal - (That example is actually specifying red&normal for <=30% and no- + (That example is actually specifying red&normal for <=30% and no- color&normal for >30%.) - For another example, the following line in your configuration + For another example, the following line in your configuration file will cause wisdom to be displayed red if it drops and green if it rises: OPTION=hilite_status:wisdom/down/red/up/green - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 89 + NetHack Guidebook 90 Allowed colors are black, red, green, brown, blue, magenta, cyan, - gray, orange, light-green, yellow, light-blue, light-magenta, light- - cyan, and white. And "no-color", the default foreground color on the + gray, orange, light-green, yellow, light-blue, light-magenta, light- + cyan, and white. And "no-color", the default foreground color on the display, which is not necessarily the same as black or white or any of the other colors. Allowed attributes are none, bold, dim, underline, blink, and in- - verse. "Normal" is a synonym for "none"; they should not be used in + verse. "Normal" is a synonym for "none"; they should not be used in combination with any of the other attributes. - To specify both a color and an attribute, use `&' to combine - them. To specify multiple attributes, use `+' to combine those. For + To specify both a color and an attribute, use `&' to combine + them. To specify multiple attributes, use `+' to combine those. For example: "magenta&inverse+dim". - Note that the display may substitute or ignore particular at- - tributes depending upon its capabilities, and in general may interpret - the attributes any way it wants. For example, on some display systems - a request for bold might yield blink or vice versa. On others, issu- - ing an attribute request while another is already set up will replace - the earlier attribute rather than combine with it. Since NetHack is- - sues attribute requests sequentially (at least with the tty interface) - rather than all at once, the only way a situation like that can be + Note that the display may substitute or ignore particular attrib- + utes depending upon its capabilities, and in general may interpret the + attributes any way it wants. For example, on some display systems a + request for bold might yield blink or vice versa. On others, issuing + an attribute request while another is already set up will replace the + earlier attribute rather than combine with it. Since NetHack issues + attribute requests sequentially (at least with the tty interface) + rather than all at once, the only way a situation like that can be controlled is to specify just one attribute. You can adjust the appearance of the following status fields: @@ -5846,53 +5912,53 @@ charisma armor-class condition alignment score - The pseudo-field "characteristics" can be used to set all six of - Str, Dex, Con, Int, Wis, and Cha at once. "HD" is "hit dice", an - approximation of experience level displayed when polymorphed. "ex- + The pseudo-field "characteristics" can be used to set all six of + Str, Dex, Con, Int, Wis, and Cha at once. "HD" is "hit dice", an + approximation of experience level displayed when polymorphed. "ex- perience", "time", and "score" are conditionally displayed depending upon your other option settings. Instead of a behavior, "condition" takes the following condition flags: stone, slime, strngl, foodpois, termill, blind, deaf, stun, conf, hallu, lev, fly, and ride. You can use "major_troubles" as an - alias for stone through termill, "minor_troubles" for blind through + alias for stone through termill, "minor_troubles" for blind through hallu, "movement" for lev, fly, and ride, and "all" for every condi- tion. Allowed behaviors are "always", "up", "down", "changed", a percent- age or absolute number threshold, or text to match against. For the - hitpoints field, the additional behavior "criticalhp" is available. - It overrides other behavior rules if hit points are at or below the - major problem threshold (which varies depending upon maximum hit + hitpoints field, the additional behavior "criticalhp" is available. + It overrides other behavior rules if hit points are at or below the + major problem threshold (which varies depending upon maximum hit points and experience level). - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 90 + NetHack Guidebook 91 * "always" will set the default attributes for that field. - * "up", "down" set the field attributes for when the field value - changes upwards or downwards. This attribute times out after + * "up", "down" set the field attributes for when the field value + changes upwards or downwards. This attribute times out after statushilites turns. - * "changed" sets the field attribute for when the field value - changes. This attribute times out after statushilites turns. - (If a field has both a "changed" rule and an "up" or "down" - rule which matches a change in the field's value, the "up" or + * "changed" sets the field attribute for when the field value + changes. This attribute times out after statushilites turns. + (If a field has both a "changed" rule and an "up" or "down" + rule which matches a change in the field's value, the "up" or "down" one takes precedence.) - * percentage sets the field attribute when the field value - matches the percentage. It is specified as a number between 0 - and 100, followed by `%' (percent sign). If the percentage is + * percentage sets the field attribute when the field value + matches the percentage. It is specified as a number between 0 + and 100, followed by `%' (percent sign). If the percentage is prefixed with `<=' or `>=', it also matches when value is below or above the percentage. Use prefix `<' or `>' to match when strictly below or above. (The numeric limit is relaxed @@ -5902,45 +5968,45 @@ sponding maximum field. Percentage highlight rules are also allowed for "experience level" and "experience points" (valid when the showexp option is enabled). For those, the percentage - is based on the progress from the start of the current experi- - ence level to the start of the next level. So if level 2 - starts at 20 points and level 3 starts at 40 points, having 30 - points is 50% and 35 points is 75%. 100% is unattainable for - experience because you'll gain a level and the calculations - will be reset for that new level, but a rule for =100% is al- - lowed and matches the special case of being exactly 1 experi- + is based on the progress from the start of the current experi- + ence level to the start of the next level. So if level 2 + starts at 20 points and level 3 starts at 40 points, having 30 + points is 50% and 35 points is 75%. 100% is unattainable for + experience because you'll gain a level and the calculations + will be reset for that new level, but a rule for =100% is al- + lowed and matches the special case of being exactly 1 experi- ence point short of the next level. - * absolute value sets the attribute when the field value matches - that number. The number must be 0 or higher, except for "ar- - mor-class' which allows negative values, and may optionally be + * absolute value sets the attribute when the field value matches + that number. The number must be 0 or higher, except for "ar- + mor-class' which allows negative values, and may optionally be preceded by `='. If the number is preceded by `<=' or `>=' in- stead, it also matches when value is below or above. If the prefix is `<' or `>', only match when strictly above or below. * criticalhp only applies to the hitpoints field and only when current hit points are below a threshold (which varies by maxi- - mum hit points and experience level). When the threshold is - met, a criticalhp rule takes precedence over all other hit- + mum hit points and experience level). When the threshold is + met, a criticalhp rule takes precedence over all other hit- points rules. - * text match sets the attribute when the field value matches the - text. Text matches can only be used for "alignment", "carry- + * text match sets the attribute when the field value matches the + text. Text matches can only be used for "alignment", "carry- ing-capacity", "hunger", "dungeon-level", and "title". For ti- tle, only the role's rank title is tested; the character's name is ignored. - The in-game options menu can help you determine the correct syn- + The in-game options menu can help you determine the correct syn- tax for a configuration file. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 91 + NetHack Guidebook 92 @@ -5979,10 +6045,10 @@ You can also override one or more symbols using the SYMBOLS and ROGUESYMBOLS configuration file options. Symbols are specified as name:value pairs. Note that NetHack escape-processes the value string - in conventional C fashion. This means that \ is a prefix to take the - following character literally. Thus \ needs to be represented as \\. - The special prefix form \m switches on the meta bit in the symbol - value, and the ^ prefix causes the following character to be treated + in conventional C fashion. This means that \ is a prefix to take the + following character literally. Thus \ needs to be represented as \\. + The special prefix form \m switches on the meta bit in the symbol + value, and the ^ prefix causes the following character to be treated as a control character. NetHack Symbols @@ -6000,13 +6066,13 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 92 + NetHack Guidebook 93 @@ -6066,13 +6132,13 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 93 + NetHack Guidebook 94 @@ -6132,13 +6198,13 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 94 + NetHack Guidebook 95 @@ -6198,13 +6264,13 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 95 + NetHack Guidebook 96 @@ -6225,7 +6291,7 @@ Notes: - * Several symbols in this table appear to be blank. They are the + * Several symbols in this table appear to be blank. They are the space character, except for S_pet_override and S_hero_override which don't have any default value and can only be used if enabled in the "sysconf" file. @@ -6240,17 +6306,17 @@ If your platform or terminal supports the display of UTF-8 char- acter sequences, you can customize your game display by assigning Uni- - code codepoint values and red-green-blue colors to glyph representa- - tions. The customizations can be specified for use with a symset that - has a UTF8 handler within the symbols file such as the enhanced1 set, + code codepoint values and red-green-blue colors to glyph representa- + tions. The customizations can be specified for use with a symset that + has a UTF8 handler within the symbols file such as the enhanced1 set, or individually within your nethack.rc file. The format for defining a glyph representation is: OPTIONS=glyph:glyphid/U+nnnn/R-G-B - The window port that is active needs to provide support for dis- - playing UTF-8 character sequences and explicit red-green-blue colors + The window port that is active needs to provide support for dis- + playing UTF-8 character sequences and explicit red-green-blue colors in order for the glyph representation to be visible. For example, the following line in your configuration file will cause the glyph repre- sentation for glyphid G_pool to use Unicode codepoint U+224B and the @@ -6260,36 +6326,36 @@ The list of acceptable glyphid's can be produced by nethack --dumpg- lyphids. Individual NetHack glyphs can be specified using the G_ pre- - fix, or you can use an S_ symbol for a glyphid and store the custom - representation for all NetHack glyphs that would map to that + fix, or you can use an S_ symbol for a glyphid and store the custom + representation for all NetHack glyphs that would map to that - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 96 + NetHack Guidebook 97 particular symbol. - You will need to select a symset with a UTF8 handler to enable + You will need to select a symset with a UTF8 handler to enable the display of the customizations, such as the Enhanced symset. 9.16. Configuring NetHack for Play by the Blind - NetHack can be set up to use only standard ASCII characters for - making maps of the dungeons. This makes even the MS-DOS versions of - NetHack (which use special line-drawing characters by default) com- - pletely accessible to the blind who use speech and/or Braille access - technologies. Players will require a good working knowledge of their + NetHack can be set up to use only standard ASCII characters for + making maps of the dungeons. This makes even the MS-DOS versions of + NetHack (which use special line-drawing characters by default) com- + pletely accessible to the blind who use speech and/or Braille access + technologies. Players will require a good working knowledge of their screen-reader's review features, and will have to know how to navigate horizontally and vertically character by character. They will also find the search capabilities of their screen-readers to be quite valu- - able. Be certain to examine this Guidebook before playing so you have + able. Be certain to examine this Guidebook before playing so you have an idea what the screen layout is like. You'll also need to be able to locate the PC cursor. It is always where your character is located. Merely searching for an @-sign will not always find your character @@ -6299,7 +6365,7 @@ are often useful in giving players a better sense of the overall loca- tion of items on the screen. - NetHack can also be compiled with support for sending the game + NetHack can also be compiled with support for sending the game messages to an external program, such as a text-to-speech synthesizer. If the "#version" extended command shows "external program as a mes- sage handler", your NetHack has been compiled with the capability. @@ -6330,13 +6396,13 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 97 + NetHack Guidebook 98 @@ -6360,26 +6426,26 @@ instead of moving 8 units at a time. nostatus_updates - Prevent updates to the status lines at the bottom of the screen, if - your screen-reader reads those lines. The same information can be + Prevent updates to the status lines at the bottom of the screen, if + your screen-reader reads those lines. The same information can be seen via the "#attributes" command. 9.17. Global Configuration for System Administrators - If NetHack is compiled with the SYSCF option, a system adminis- - trator should set up a global configuration; this is a file in the - same format as the traditional per-user configuration file (see - above). This file should be named sysconf and placed in the same di- + If NetHack is compiled with the SYSCF option, a system adminis- + trator should set up a global configuration; this is a file in the + same format as the traditional per-user configuration file (see + above). This file should be named sysconf and placed in the same di- rectory as the other NetHack support files. The options recognized in this file are listed below. Any option not set uses a compiled-in de- fault (which may not be appropriate for your system). - WIZARDS = A space-separated list of user names who are allowed to - play in debug mode (commonly referred to as wizard mode). A value - of a single asterisk (*) allows anyone to start a game in debug + WIZARDS = A space-separated list of user names who are allowed to + play in debug mode (commonly referred to as wizard mode). A value + of a single asterisk (*) allows anyone to start a game in debug mode. - SHELLERS = A list of users who are allowed to use the shell escape + SHELLERS = A list of users who are allowed to use the shell escape command (!). The syntax is the same as WIZARDS. EXPLORERS = A list of users who are allowed to use the explore mode. @@ -6392,17 +6458,17 @@ space. The first format in the list will written as well as read. The second format will be read only if no save file in the first format exists. Valid choices are "historical" for binary writing of - entire structs, "lendian" for binary writing of each field in lit- + entire structs, "lendian" for binary writing of each field in lit- tle-endian order, "ascii" for writing the save file content in ascii - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 98 + NetHack Guidebook 99 @@ -6439,41 +6505,41 @@ ENTRYMAX = Maximum number of entries in the score file. - POINTSMIN = Minimum number of points to get an entry in the score + POINTSMIN = Minimum number of points to get an entry in the score file. - PERS_IS_UID = 0 or 1 to use user names or numeric userids, respec- + PERS_IS_UID = 0 or 1 to use user names or numeric userids, respec- tively, to identify unique people for the score file. - HIDEUSAGE = 0 or 1 to control whether the help menu entry for com- + HIDEUSAGE = 0 or 1 to control whether the help menu entry for com- mand line usage is shown or suppressed. - MAX_STATUENAME_RANK = Maximum number of score file entries to use + MAX_STATUENAME_RANK = Maximum number of score file entries to use for random statue names (default is 10). ACCESSIBILITY = 0 or 1 to disable or enable, respectively, the abil- ity for players to set S_pet_override and S_hero_override symbols in their configuration file. - PORTABLE_DEVICE_PATHS = 0 or 1 Windows OS only, the game will look - for all of its external files, and write to all of its output files + PORTABLE_DEVICE_PATHS = 0 or 1 Windows OS only, the game will look + for all of its external files, and write to all of its output files in one place rather than at the standard locations. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 99 + NetHack Guidebook 100 - DUMPLOGFILE = A filename where the end-of-game dumplog is saved. - Not defining this will prevent dumplog from being created. Only + DUMPLOGFILE = A filename where the end-of-game dumplog is saved. + Not defining this will prevent dumplog from being created. Only available if your game is compiled with DUMPLOG. Allows the follow- ing placeholders: @@ -6492,9 +6558,9 @@ panying the program contains a comment which lists the meaning of the various bits used. Intended for server systems supporting si- multaneous play by multiple players (to be clear, each one running a - separate single player game), for displaying their game progress to - observers. Only relevant if the program was built with LIVELOG en- - abled. When available, it should be left commented out on single + separate single player game), for displaying their game progress to + observers. Only relevant if the program was built with LIVELOG en- + abled. When available, it should be left commented out on single player installations because over time the file could grow to be ex- tremely large unless it is actively maintained. @@ -6506,7 +6572,7 @@ 10. Scoring NetHack maintains a list of the top scores or scorers on your ma- - chine, depending on how it is set up. In the latter case, each ac- + chine, depending on how it is set up. In the latter case, each ac- count on the machine can post only one non-winning score on this list. If you score higher than someone else on this list, or better your previous score, you will be inserted in the proper place under your @@ -6528,13 +6594,13 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 100 + NetHack Guidebook 101 @@ -6547,7 +6613,7 @@ paltry cost of not getting on the high score list. There are two ways of enabling explore mode. One is to start the - game with the -X command-line switch or with the playmode:explore op- + game with the -X command-line switch or with the playmode:explore op- tion. The other is to issue the "#exploremode" extended command while already playing the game. Starting a new game in explore mode pro- vides your character with a wand of wishing in initial inventory; @@ -6557,12 +6623,12 @@ 11.1. Debug mode Debug mode, also known as wizard mode, is undocumented aside from - this brief description and the various "debug mode only" commands - listed among the command descriptions. It is intended for tracking - down problems within the program rather than to provide god-like pow- - ers to your character, and players who attempt debugging are expected - to figure out how to use it themselves. It is initiated by starting - the game with the -D command-line switch or with the playmode:debug + this brief description and the various "debug mode only" commands + listed among the command descriptions. It is intended for tracking + down problems within the program rather than to provide god-like pow- + ers to your character, and players who attempt debugging are expected + to figure out how to use it themselves. It is initiated by starting + the game with the -D command-line switch or with the playmode:debug option. For some systems, the player must be logged in under a particular @@ -6576,31 +6642,31 @@ The original hack game was modeled on the Berkeley UNIX rogue game. Large portions of this document were shamelessly cribbed from A - Guide to the Dungeons of Doom, by Michael C. Toy and Kenneth C. R. C. - Arnold. Small portions were adapted from Further Exploration of the + Guide to the Dungeons of Doom, by Michael C. Toy and Kenneth C. R. C. + Arnold. Small portions were adapted from Further Exploration of the Dungeons of Doom, by Ken Arromdee. - NetHack is the product of literally scores of people's work. + NetHack is the product of literally scores of people's work. Main events in the course of the game development are described below: - Jay Fenlason wrote the original Hack, with help from Kenny Wood- + Jay Fenlason wrote the original Hack, with help from Kenny Wood- land, Mike Thome, and Jon Payne. - Andries Brouwer did a major re-write while at Stichting Mathema- - tisch Centrum (now Centrum Wiskunde & Informatica), transforming Hack + Andries Brouwer did a major re-write while at Stichting Mathema- + tisch Centrum (now Centrum Wiskunde & Informatica), transforming Hack into a very different game. He published the Hack source code for use on UNIX systems by posting that to Usenet newsgroup net.sources (later - renamed comp.sources) releasing version 1.0 in December of 1984, then - versions 1.0.1, 1.0.2, and finally 1.0.3 in July of 1985. Usenet + renamed comp.sources) releasing version 1.0 in December of 1984, then + versions 1.0.1, 1.0.2, and finally 1.0.3 in July of 1985. Usenet - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 101 + NetHack Guidebook 102 @@ -6626,47 +6692,47 @@ Later, Mike coordinated a major re-write of the game, heading a team which included Ken Arromdee, Jean-Christophe Collet, Steve Creps, - Eric Hendrickson, Izchak Miller, Eric S. Raymond, John Rupley, Mike + Eric Hendrickson, Izchak Miller, Eric S. Raymond, John Rupley, Mike Threepoint, and Janet Walz, to produce NetHack 3.0c. - NetHack 3.0 was ported to the Atari by Eric R. Smith, to OS/2 by - Timo Hakulinen, and to VMS by David Gentzel. The three of them and - Kevin Darcy later joined the main NetHack Development Team to produce + NetHack 3.0 was ported to the Atari by Eric R. Smith, to OS/2 by + Timo Hakulinen, and to VMS by David Gentzel. The three of them and + Kevin Darcy later joined the main NetHack Development Team to produce subsequent revisions of 3.0. - Olaf Seibert ported NetHack 2.3 and 3.0 to the Amiga. Norm - Meluch, Stephen Spackman and Pierre Martineau designed overlay code - for PC NetHack 3.0. Johnny Lee ported NetHack 3.0 to the Macintosh. - Along with various other Dungeoneers, they continued to enhance the + Olaf Seibert ported NetHack 2.3 and 3.0 to the Amiga. Norm + Meluch, Stephen Spackman and Pierre Martineau designed overlay code + for PC NetHack 3.0. Johnny Lee ported NetHack 3.0 to the Macintosh. + Along with various other Dungeoneers, they continued to enhance the PC, Macintosh, and Amiga ports through the later revisions of 3.0. - Version 3.0 went through ten relatively rapidly released "patch- + Version 3.0 went through ten relatively rapidly released "patch- level" revisions. Versions at the time were known as 3.0 for the base release and variously as "3.0a" through "3.0j", "3.0 patchlevel 1" through "3.0 patchlevel 10", or "3.0pl1" through "3.0pl10" rather than - 3.0.0 and 3.0.1 through 3.0.10; the three component numbering scheme + 3.0.0 and 3.0.1 through 3.0.10; the three component numbering scheme began to be used with 3.1.0. - Headed by Mike Stephenson and coordinated by Izchak Miller and - Janet Walz, the NetHack Development Team which now included Ken Ar- - romdee, David Cohrs, Jean-Christophe Collet, Kevin Darcy, Matt Day, - Timo Hakulinen, Steve Linhart, Dean Luick, Pat Rankin, Eric Raymond, - and Eric Smith undertook a radical revision of 3.0. They re-struc- - tured the game's design, and re-wrote major parts of the code. They - added multiple dungeons, a new display, special individual character - quests, a new endgame and many other new features, and produced + Headed by Mike Stephenson and coordinated by Izchak Miller and + Janet Walz, the NetHack Development Team which now included Ken Ar- + romdee, David Cohrs, Jean-Christophe Collet, Kevin Darcy, Matt Day, + Timo Hakulinen, Steve Linhart, Dean Luick, Pat Rankin, Eric Raymond, + and Eric Smith undertook a radical revision of 3.0. They re-struc- + tured the game's design, and re-wrote major parts of the code. They + added multiple dungeons, a new display, special individual character + quests, a new endgame and many other new features, and produced NetHack 3.1. Version 3.1.0 was released in January of 1993. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 102 + NetHack Guidebook 103 @@ -6679,14 +6745,14 @@ 3.1 to the PC. Jon W{tte and Hao-yang Wang, with help from Ross Brown, Mike Eng- - ber, David Hairston, Michael Hamel, Jonathan Handler, Johnny Lee, Tim - Lennan, Rob Menke, and Andy Swanson, developed NetHack 3.1 for the - Macintosh, porting it for MPW. Building on their development, Bart + ber, David Hairston, Michael Hamel, Jonathan Handler, Johnny Lee, Tim + Lennan, Rob Menke, and Andy Swanson, developed NetHack 3.1 for the + Macintosh, porting it for MPW. Building on their development, Bart House added a Think C port. - Timo Hakulinen ported NetHack 3.1 to OS/2. Eric Smith ported - NetHack 3.1 to the Atari. Pat Rankin, with help from Joshua De- - lahunty, was responsible for the VMS version of NetHack 3.1. Michael + Timo Hakulinen ported NetHack 3.1 to OS/2. Eric Smith ported + NetHack 3.1 to the Atari. Pat Rankin, with help from Joshua De- + lahunty, was responsible for the VMS version of NetHack 3.1. Michael Allison ported NetHack 3.1 to Windows NT. Dean Luick, with help from David Cohrs, developed NetHack 3.1 for @@ -6694,31 +6760,31 @@ nh10.bdf, an optionally used custom X11 font which has tiny images in place of letters and punctuation, a precursor of tiles. Those images don't extend to individual monster and object types, just replacements - for monster and object classes (so one custom image for all "a" in- - sects and another for all "[" armor and so forth, not separate images + for monster and object classes (so one custom image for all "a" in- + sects and another for all "[" armor and so forth, not separate images for beetles and ants or for cloaks and boots). - Warwick Allison wrote a graphically displayed version of NetHack - for the Atari where the tiny pictures were described as "icons" and - were distinct for specific types of monsters and objects rather than - just their classes. He contributed them to the NetHack Development - Team which rechristened them "tiles", original usage which has subse- - quently been picked up by various other games. NetHack's tiles sup- - port was then implemented on other platforms (initially MS-DOS but + Warwick Allison wrote a graphically displayed version of NetHack + for the Atari where the tiny pictures were described as "icons" and + were distinct for specific types of monsters and objects rather than + just their classes. He contributed them to the NetHack Development + Team which rechristened them "tiles", original usage which has subse- + quently been picked up by various other games. NetHack's tiles sup- + port was then implemented on other platforms (initially MS-DOS but eventually Windows, Qt, and X11 too). - The 3.2 NetHack Development Team, comprised of Michael Allison, - Ken Arromdee, David Cohrs, Jessie Collet, Steve Creps, Kevin Darcy, - Timo Hakulinen, Steve Linhart, Dean Luick, Pat Rankin, Eric Smith, - Mike Stephenson, Janet Walz, and Paul Winner, released version 3.2.0 + The 3.2 NetHack Development Team, comprised of Michael Allison, + Ken Arromdee, David Cohrs, Jessie Collet, Steve Creps, Kevin Darcy, + Timo Hakulinen, Steve Linhart, Dean Luick, Pat Rankin, Eric Smith, + Mike Stephenson, Janet Walz, and Paul Winner, released version 3.2.0 in April of 1996. - Version 3.2 marked the tenth anniversary of the formation of the + Version 3.2 marked the tenth anniversary of the formation of the development team. In a testament to their dedication to the game, all thirteen members of the original NetHack Development Team remained on the team at the start of work on that release. During the interval between the release of 3.1.3 and 3.2.0, one of the founding members of - the NetHack Development Team, Dr. Izchak Miller, was diagnosed with + the NetHack Development Team, Dr. Izchak Miller, was diagnosed with cancer and passed away. That release of the game was dedicated to him by the development and porting teams. @@ -6726,13 +6792,13 @@ Many bugs were fixed, abuses eliminated, and game features tuned for - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 103 + NetHack Guidebook 104 @@ -6743,22 +6809,22 @@ "variants" publicly available: Tom Proudfoot and Yuval Oren created NetHack++, which was quickly - renamed NetHack-- when some people incorrectly assumed that it was a - conversion of the C source code to C++. Working independently, - Stephen White wrote NetHack Plus. Tom Proudfoot later merged NetHack - Plus and his own NetHack-- to produce SLASH. Larry Stewart-Zerba and - Warwick Allison improved the spell casting system with the Wizard + renamed NetHack-- when some people incorrectly assumed that it was a + conversion of the C source code to C++. Working independently, + Stephen White wrote NetHack Plus. Tom Proudfoot later merged NetHack + Plus and his own NetHack-- to produce SLASH. Larry Stewart-Zerba and + Warwick Allison improved the spell casting system with the Wizard Patch. Warwick Allison also ported NetHack to use the Qt interface. - Warren Cheung combined SLASH with the Wizard Patch to produce + Warren Cheung combined SLASH with the Wizard Patch to produce Slash'EM, and with the help of Kevin Hugo, added more features. Kevin later joined the NetHack Development Team and incorporated the best of these ideas into NetHack 3.3. - The final update to 3.2 was the bug fix release 3.2.3, which was - released simultaneously with 3.3.0 in December 1999 just in time for - the Year 2000. Because of the newer version, 3.2.3 was released as a - source code patch only, without any ready-to-play distribution for + The final update to 3.2 was the bug fix release 3.2.3, which was + released simultaneously with 3.3.0 in December 1999 just in time for + the Year 2000. Because of the newer version, 3.2.3 was released as a + source code patch only, without any ready-to-play distribution for systems that usually had such. (To anyone considering resurrecting an old version: all versions @@ -6767,71 +6833,71 @@ 1999's year 99 was followed by 2000's year 100. That got written out successfully but it unintentionally introduced an extra column in the file layout which prevented score entries from being read back in cor- - rectly, interfering with insertion of new high scores and with re- - trieval of old character names to use for random ghost and statue + rectly, interfering with insertion of new high scores and with re- + trieval of old character names to use for random ghost and statue names in the current game.) - The 3.3 NetHack Development Team, consisting of Michael Allison, - Ken Arromdee, David Cohrs, Jessie Collet, Steve Creps, Kevin Darcy, + The 3.3 NetHack Development Team, consisting of Michael Allison, + Ken Arromdee, David Cohrs, Jessie Collet, Steve Creps, Kevin Darcy, Timo Hakulinen, Kevin Hugo, Steve Linhart, Ken Lorber, Dean Luick, Pat Rankin, Eric Smith, Mike Stephenson, Janet Walz, and Paul Winner, re- leased 3.3.0 in December 1999 and 3.3.1 in August of 2000. Version 3.3 offered many firsts. It was the first version to sep- - arate race and profession. The Elf class was removed in preference to - an elf race, and the races of dwarves, gnomes, and orcs made their - first appearance in the game alongside the familiar human race. Monk - and Ranger roles joined Archeologists, Barbarians, Cavemen, Healers, - Knights, Priests, Rogues, Samurai, Tourists, Valkyries and of course, - Wizards. It was also the first version to allow you to ride a steed, - and was the first version to have a publicly available web-site list- - ing all the bugs that had been discovered. Despite that constantly - growing bug list, 3.3 proved stable enough to last for more than a + arate race and profession. The Elf class was removed in preference to + an elf race, and the races of dwarves, gnomes, and orcs made their + first appearance in the game alongside the familiar human race. Monk + and Ranger roles joined Archeologists, Barbarians, Cavemen, Healers, + Knights, Priests, Rogues, Samurai, Tourists, Valkyries and of course, + Wizards. It was also the first version to allow you to ride a steed, + and was the first version to have a publicly available web-site list- + ing all the bugs that had been discovered. Despite that constantly + growing bug list, 3.3 proved stable enough to last for more than a year and a half. - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 104 + NetHack Guidebook 105 - The 3.4 NetHack Development Team initially consisted of Michael - Allison, Ken Arromdee, David Cohrs, Jessie Collet, Kevin Hugo, Ken - Lorber, Dean Luick, Pat Rankin, Mike Stephenson, Janet Walz, and Paul - Winner, with Warwick Allison joining just before the release of + The 3.4 NetHack Development Team initially consisted of Michael + Allison, Ken Arromdee, David Cohrs, Jessie Collet, Kevin Hugo, Ken + Lorber, Dean Luick, Pat Rankin, Mike Stephenson, Janet Walz, and Paul + Winner, with Warwick Allison joining just before the release of NetHack 3.4.0 in March 2002. - As with version 3.3, various people contributed to the game as a - whole as well as supporting ports on the different platforms that + As with version 3.3, various people contributed to the game as a + whole as well as supporting ports on the different platforms that NetHack runs on: Pat Rankin maintained 3.4 for VMS. - Michael Allison maintained NetHack 3.4 for the MS-DOS platform. + Michael Allison maintained NetHack 3.4 for the MS-DOS platform. Paul Winner and Yitzhak Sapir provided encouragement. - Dean Luick, Mark Modrall, and Kevin Hugo maintained and enhanced + Dean Luick, Mark Modrall, and Kevin Hugo maintained and enhanced the Macintosh port of 3.4. - Michael Allison, David Cohrs, Alex Kompel, Dion Nicolaas, and - Yitzhak Sapir maintained and enhanced 3.4 for the Microsoft Windows - platform. Alex Kompel contributed a new graphical interface for the - Windows port. Alex Kompel also contributed a Windows CE port for + Michael Allison, David Cohrs, Alex Kompel, Dion Nicolaas, and + Yitzhak Sapir maintained and enhanced 3.4 for the Microsoft Windows + platform. Alex Kompel contributed a new graphical interface for the + Windows port. Alex Kompel also contributed a Windows CE port for 3.4.1. - Ron Van Iwaarden was the sole maintainer of NetHack for OS/2 the - past several releases. Unfortunately Ron's last OS/2 machine stopped - working in early 2006. A great many thanks to Ron for keeping NetHack + Ron Van Iwaarden was the sole maintainer of NetHack for OS/2 the + past several releases. Unfortunately Ron's last OS/2 machine stopped + working in early 2006. A great many thanks to Ron for keeping NetHack alive on OS/2 all these years. - Janne Salmijarvi and Teemu Suikki maintained and enhanced the + Janne Salmijarvi and Teemu Suikki maintained and enhanced the Amiga port of 3.4 after Janne Salmijarvi resurrected it for 3.3.1. Christian "Marvin" Bressler maintained 3.4 for the Atari after he @@ -6841,43 +6907,43 @@ ning of a long release hiatus. 3.4.3 proved to be a remarkably stable version that provided continued enjoyment by the community for more than a decade. The NetHack Development Team slowly and quietly contin- - ued to work on the game behind the scenes during the tenure of 3.4.3. - It was during that same period that several new variants emerged - within the NetHack community. Notably sporkhack by Derek S. Ray, un- - nethack by Patric Mueller, nitrohack and its successors originally by - Daniel Thaler and then by Alex Smith, and Dynahack by Tung Nguyen. - Some of those variants continue to be developed, maintained, and en- + ued to work on the game behind the scenes during the tenure of 3.4.3. + It was during that same period that several new variants emerged + within the NetHack community. Notably sporkhack by Derek S. Ray, un- + nethack by Patric Mueller, nitrohack and its successors originally by + Daniel Thaler and then by Alex Smith, and Dynahack by Tung Nguyen. + Some of those variants continue to be developed, maintained, and en- joyed by the community to this day. In September 2014, an interim snapshot of the code under develop- ment was released publicly by other parties. Since that code was a work-in-progress and had not gone through the process of debugging it as a suitable release, it was decided that the version numbers present - on that code snapshot would be retired and never used in an official - NetHack release. An announcement was posted on the NetHack Develop- - ment Team's official nethack.org website to that effect, stating that + on that code snapshot would be retired and never used in an official + NetHack release. An announcement was posted on the NetHack Develop- + ment Team's official nethack.org website to that effect, stating that - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 105 + NetHack Guidebook 106 there would never be a 3.4.4, 3.5, or 3.5.0 official release version. - In January 2015, preparation began for the release of NetHack + In January 2015, preparation began for the release of NetHack 3.6. At the beginning of development for what would eventually get re- leased as 3.6.0, the NetHack Development Team consisted of Warwick Al- - lison, Michael Allison, Ken Arromdee, David Cohrs, Jessie Collet, Ken - Lorber, Dean Luick, Pat Rankin, Mike Stephenson, Janet Walz, and Paul - Winner. In early 2015, ahead of the release of 3.6.0, new members + lison, Michael Allison, Ken Arromdee, David Cohrs, Jessie Collet, Ken + Lorber, Dean Luick, Pat Rankin, Mike Stephenson, Janet Walz, and Paul + Winner. In early 2015, ahead of the release of 3.6.0, new members Sean Hunt, Pasi Kallinen, and Derek S. Ray joined the NetHack Develop- ment Team. @@ -6886,36 +6952,36 @@ game, author Terry Pratchett, passed away. NetHack 3.6.0 introduced a tribute to him. - 3.6.0 was released in December 2015, and merged work done by the - development team since the release of 3.4.3 with some of the beloved - community patches. Many bugs were fixed and some code was restruc- + 3.6.0 was released in December 2015, and merged work done by the + development team since the release of 3.4.3 with some of the beloved + community patches. Many bugs were fixed and some code was restruc- tured. - The NetHack Development Team, as well as Steve VanDevender and - Kevin Smolkowski, ensured that NetHack 3.6 continued to operate on + The NetHack Development Team, as well as Steve VanDevender and + Kevin Smolkowski, ensured that NetHack 3.6 continued to operate on various UNIX flavors and maintained the X11 interface. - Ken Lorber, Haoyang Wang, Pat Rankin, and Dean Luick maintained + Ken Lorber, Haoyang Wang, Pat Rankin, and Dean Luick maintained the port of NetHack 3.6 for MacOS. - Michael Allison, David Cohrs, Bart House, Pasi Kallinen, Alex - Kompel, Dion Nicolaas, Derek S. Ray and Yitzhak Sapir maintained the + Michael Allison, David Cohrs, Bart House, Pasi Kallinen, Alex + Kompel, Dion Nicolaas, Derek S. Ray and Yitzhak Sapir maintained the port of NetHack 3.6 for Microsoft Windows. - Pat Rankin attempted to keep the VMS port running for NetHack - 3.6, hindered by limited access. Kevin Smolkowski has updated and - tested it for the most recent version of OpenVMS (V8.4 as of this + Pat Rankin attempted to keep the VMS port running for NetHack + 3.6, hindered by limited access. Kevin Smolkowski has updated and + tested it for the most recent version of OpenVMS (V8.4 as of this writing) on Alpha and Integrity (aka Itanium aka IA64) but not VAX. - Ray Chason resurrected the MS-DOS port for 3.6 and contributed + Ray Chason resurrected the MS-DOS port for 3.6 and contributed the necessary updates to the community at large. - In late April 2018, several hundred bug fixes for 3.6.0 and some - new features were assembled and released as NetHack 3.6.1. The - NetHack Development Team at the time of release of 3.6.1 consisted of - Warwick Allison, Michael Allison, Ken Arromdee, David Cohrs, Jessie - Collet, Pasi Kallinen, Ken Lorber, Dean Luick, Patric Mueller, Pat - Rankin, Derek S. Ray, Alex Smith, Mike Stephenson, Janet Walz, and + In late April 2018, several hundred bug fixes for 3.6.0 and some + new features were assembled and released as NetHack 3.6.1. The + NetHack Development Team at the time of release of 3.6.1 consisted of + Warwick Allison, Michael Allison, Ken Arromdee, David Cohrs, Jessie + Collet, Pasi Kallinen, Ken Lorber, Dean Luick, Patric Mueller, Pat + Rankin, Derek S. Ray, Alex Smith, Mike Stephenson, Janet Walz, and Paul Winner. In early May 2019, another 320 bug fixes along with some enhance- @@ -6924,13 +6990,13 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 106 + NetHack Guidebook 107 @@ -6950,29 +7016,29 @@ NetHack 3.6.6 was released on March 8, 2020 containing a security fix and some bug fixes. - NetHack 3.6.7 was released on February 16, 2023 containing a se- + NetHack 3.6.7 was released on February 16, 2023 containing a se- curity fix and some bug fixes. - The official NetHack web site is maintained by Ken Lorber at + The official NetHack web site is maintained by Ken Lorber at https://www.nethack.org/. 12.1. Special Thanks - On behalf of the NetHack community, thank you very much once - again to M. Drew Streib and Pasi Kallinen for providing a public - NetHack server at nethack.alt.org. Thanks to Keith Simpson and Andy - Thomson for hardfought.org. Thanks to all those unnamed dungeoneers - who invest their time and effort into annual NetHack tournaments such - as Junethack, The November NetHack Tournament, and in days past, de- + On behalf of the NetHack community, thank you very much once + again to M. Drew Streib and Pasi Kallinen for providing a public + NetHack server at nethack.alt.org. Thanks to Keith Simpson and Andy + Thomson for hardfought.org. Thanks to all those unnamed dungeoneers + who invest their time and effort into annual NetHack tournaments such + as Junethack, The November NetHack Tournament, and in days past, de- vnull.net (gone for now, but not forgotten). 12.2. Dungeoneers - From time to time, some depraved individual out there in netland - sends a particularly intriguing modification to help out with the - game. The NetHack Development Team sometimes makes note of the names + From time to time, some depraved individual out there in netland + sends a particularly intriguing modification to help out with the + game. The NetHack Development Team sometimes makes note of the names of the worst of these miscreants in this, the list of Dungeoneers: Adam Aronow J. Ali Harlow Mikko Juola @@ -6990,13 +7056,13 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 - NetHack Guidebook 107 + NetHack Guidebook 108 @@ -7033,7 +7099,7 @@ - Brand and product names are trademarks or registered trademarks + Brand and product names are trademarks or registered trademarks of their respective holders. @@ -7056,7 +7122,7 @@ - NetHack 3.7.0 November 13, 2023 + NetHack 3.7.0 December 08, 2023 From cb1eadd6b7bbc384c86b8540c5a0e6225273b4fc Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Sat, 9 Dec 2023 02:03:31 +0000 Subject: [PATCH 64/78] Don't pay the shopkeeper when displacing a pet in a shop The recent commit to interpret walking into a shopkeeper as a "pay" command was triggering in too many circumstances. Check to ensure that the monster that we're walking into is a known shopkeeper before activating the special case. --- src/uhitm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/uhitm.c b/src/uhitm.c index 85ba4ad13c..acda2b1518 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -479,7 +479,8 @@ do_attack(struct monst *mtmp) char buf[BUFSZ]; if (!gc.context.travel && !gc.context.run) - return ECMD_TIME | dopay(); + if (canspotmon(mtmp) && mtmp->isshk) + return ECMD_TIME | dopay(); if (mtmp->mtame) /* see 'additional considerations' above */ monflee(mtmp, rnd(6), FALSE, FALSE); From 0c88c91c83d5202d44b87a09a67ae2ad81fea50c Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 8 Dec 2023 19:12:38 -0800 Subject: [PATCH 65/78] mdlib.c revisited There is a slight change in behavior here when collecting build-time option information. If MAXOPT is too small, collecting will now save MAXOPT lines and then skip anything that should come after. It used to always keep the very last line, each time replacing whatever the previous last line was, but would leak memory if that ever happened. And after yesterday's "fix" it would try to keep that very last line beyond the array bounds. --- src/mdlib.c | 62 +++++++++++++++++------------------------------------ 1 file changed, 20 insertions(+), 42 deletions(-) diff --git a/src/mdlib.c b/src/mdlib.c index 59ca587ae2..f66a1f0e21 100644 --- a/src/mdlib.c +++ b/src/mdlib.c @@ -95,6 +95,10 @@ static void build_savebones_compat_string(void); static int idxopttext, done_runtime_opt_init_once = 0; #define MAXOPT 60 /* 3.7: currently 40 lines get inserted into opttext[] */ static char *opttext[MAXOPT] = { 0 }; +#define STOREOPTTEXT(line) \ + ((void) ((idxopttext < MAXOPT) \ + ? (opttext[idxopttext++] = dupstr(line)) \ + : 0)) char optbuf[COLBUFSZ]; static struct version_info version; static const char opt_indent[] = " "; @@ -735,9 +739,7 @@ opt_out_words( if (word) *word = '\0'; if (*length_p + (int) strlen(str) > COLNO - 5) { - opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < MAXOPT) - idxopttext++; + STOREOPTTEXT(optbuf); Sprintf(optbuf, "%s", opt_indent), *length_p = (int) strlen(opt_indent); } else { @@ -762,9 +764,7 @@ build_options(void) #endif #endif build_savebones_compat_string(); - opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < MAXOPT) - idxopttext++; + STOREOPTTEXT(optbuf); #if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) #if (NH_DEVEL_STATUS == NH_STATUS_BETA) #define STATUS_ARG " [beta]" @@ -776,13 +776,9 @@ build_options(void) #endif /* NH_DEVEL_STATUS == NH_STATUS_RELEASED */ Sprintf(optbuf, "%sNetHack version %d.%d.%d%s\n", opt_indent, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, STATUS_ARG); - opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < MAXOPT) - idxopttext++; + STOREOPTTEXT(optbuf); Sprintf(optbuf, "Options compiled into this edition:"); - opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < MAXOPT) - idxopttext++; + STOREOPTTEXT(optbuf); optbuf[0] = '\0'; length = COLNO + 1; /* force 1st item onto new line */ for (i = 0; i < SIZE(build_opts); i++) { @@ -798,19 +794,13 @@ build_options(void) (i < SIZE(build_opts) - 1) ? "," : "."); opt_out_words(buf, &length); } - opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < MAXOPT) - idxopttext++; + STOREOPTTEXT(optbuf); optbuf[0] = '\0'; winsyscnt = count_and_validate_winopts(); - opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < MAXOPT) - idxopttext++; + STOREOPTTEXT(optbuf); Sprintf(optbuf, "Supported windowing system%s:", (winsyscnt > 1) ? "s" : ""); - opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < MAXOPT) - idxopttext++; + STOREOPTTEXT(optbuf); optbuf[0] = '\0'; length = COLNO + 1; /* force 1st item onto new line */ @@ -842,19 +832,12 @@ build_options(void) #if !defined(MAKEDEFS_C) cnt = 0; - opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < MAXOPT) - idxopttext++; + STOREOPTTEXT(optbuf); optbuf[0] = '\0'; soundlibcnt = count_and_validate_soundlibopts(); - opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < MAXOPT) - idxopttext++; - Sprintf(optbuf, "Supported soundlib%s:", - (soundlibcnt > 1) ? "s" : ""); - opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < MAXOPT) - idxopttext++; + STOREOPTTEXT(optbuf); + Sprintf(optbuf, "Supported soundlib%s:", (soundlibcnt > 1) ? "s" : ""); + STOREOPTTEXT(optbuf); optbuf[0] = '\0'; length = COLNO + 1; /* force 1st item onto new line */ @@ -892,9 +875,7 @@ build_options(void) #endif #endif /* !MAKEDEFS_C */ - opttext[idxopttext] = dupstr(optbuf); - if (idxopttext < MAXOPT) - idxopttext++; + STOREOPTTEXT(optbuf); optbuf[0] = '\0'; #if defined(MAKEDEFS_C) || defined(FOR_RUNTIME) @@ -920,21 +901,18 @@ build_options(void) /* add lua copyright notice; ":TAG:" substitutions are deferred to caller */ for (i = 0; lua_info[i]; ++i) { - opttext[idxopttext] = dupstr(lua_info[i]); - if (idxopttext < MAXOPT) - idxopttext++; + STOREOPTTEXT(lua_info[i]); } } #endif /* MAKEDEFS_C || FOR_RUNTIME */ /* end with a blank line */ - opttext[idxopttext] = dupstr(""); - if (idxopttext < MAXOPT) - idxopttext++; - opttext[MAXOPT - 1] = NULL; + STOREOPTTEXT(""); return; } +#undef STOREOPTTEXT + int case_insensitive_comp(const char *s1, const char *s2) { From 0ef2f15f5124b68f78c1a333b4dfc81dcbc971a5 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 9 Dec 2023 01:31:08 -0500 Subject: [PATCH 66/78] check tty in can_set_perm_invent During very early startup, Windows may not have loaded the tty window procs yet, and it is running with safeprocs. It will eventually load the tty stuff. If the currently operating window port fails in can_set_perm_invent(), try the check for WC_PERM_INVENT again explicitly on the tty windowport. --- include/extern.h | 4 ++++ src/options.c | 13 ++++++++++--- src/windows.c | 28 +++++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/include/extern.h b/include/extern.h index 7f0e72aaa4..cb0234696e 100644 --- a/include/extern.h +++ b/include/extern.h @@ -3410,6 +3410,10 @@ extern void choose_windows(const char *); void addto_windowchain(const char *s); void commit_windowchain(void); #endif +#ifdef TTY_GRAPHICS +extern boolean check_tty_wincap(unsigned long); +extern boolean check_tty_wincap2(unsigned long); +#endif extern boolean genl_can_suspend_no(void); extern boolean genl_can_suspend_yes(void); extern char genl_message_menu(char, int, const char *); diff --git a/src/options.c b/src/options.c index a3c9f16889..fabb8a96cb 100644 --- a/src/options.c +++ b/src/options.c @@ -5155,9 +5155,16 @@ can_set_perm_invent(void) * and is about to be changed to True. */ uchar old_perminv_mode = iflags.perminv_mode; - - if (!(windowprocs.wincap & WC_PERM_INVENT)) - return FALSE; /* should never happen */ + if (!(windowprocs.wincap & WC_PERM_INVENT)) { +#ifdef TTY_GRAPHICS +#ifdef TTY_PERM_INVENT + /* check tty, not necessarily the active window port; + windows early startup can still be set to safeprocs */ + if (!check_tty_wincap(WC_PERM_INVENT)) +#endif +#endif + return FALSE; /* should never happen */ + } if (iflags.perminv_mode == InvOptNone) iflags.perminv_mode = InvOptOn; diff --git a/src/windows.c b/src/windows.c index 7f9d28d7e6..dfcf4e168b 100644 --- a/src/windows.c +++ b/src/windows.c @@ -59,6 +59,10 @@ extern void trace_procs_init(int); extern void *trace_procs_chain(int, int, void *, void *, void *); #endif +#if defined(WINCHAIN) || defined(TTY_GRAPHICS) +static struct win_choices *win_choices_find(const char *s); +#endif + static void def_raw_print(const char *s); static void def_wait_synch(void); static boolean get_menu_coloring(const char *, int *, int *); @@ -222,7 +226,29 @@ def_wait_synch(void) return; } -#ifdef WINCHAIN +#ifdef TTY_GRAPHICS +boolean +check_tty_wincap(unsigned long wincap) +{ + struct win_choices *wc = win_choices_find("tty"); + + if (wc) + return ((wc->procs->wincap & wincap) == wincap); + return FALSE; +} + +boolean +check_tty_wincap2(unsigned long wincap2) +{ + struct win_choices *wc = win_choices_find("tty"); + + if (wc) + return ((wc->procs->wincap2 & wincap2) == wincap2); + return FALSE; +} +#endif + +#if defined(WINCHAIN) || defined(TTY_GRAPHICS) static struct win_choices * win_choices_find(const char *s) { From 1ceb9d2d91fe58b942a812f16aa9828e18d80823 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sat, 9 Dec 2023 12:43:37 +0200 Subject: [PATCH 67/78] Show menu when paying items ... and have more than 1 billed item, and using non-traditional menustyle. I opted to add an extra field to the bill struct, because that made the code cleaner. Breaks saves and bones. --- doc/fixes3-7-0.txt | 1 + include/mextra.h | 1 + include/patchlevel.h | 2 +- src/shk.c | 76 ++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 73 insertions(+), 7 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 9280ea463b..4e4a690b83 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1321,6 +1321,7 @@ change vrock and hezrou from red to green, adjust vrock tile to have green change wolf and werewolf to grey, warg to black change [master] mind flayer, the Wizard, and the riders to bright magenta walking into a shopkeeper tries to pay the bill +show billed items in a menu when paying with non-traditional menustyle Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/include/mextra.h b/include/mextra.h index c88505916a..13ba7f2540 100644 --- a/include/mextra.h +++ b/include/mextra.h @@ -113,6 +113,7 @@ struct epri { struct bill_x { unsigned bo_id; boolean useup; + boolean queuedpay; long price; /* price per unit */ long bquan; /* amount used up */ }; diff --git a/include/patchlevel.h b/include/patchlevel.h index fca6e09580..79d5b0fd96 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -17,7 +17,7 @@ * Incrementing EDITLEVEL can be used to force invalidation of old bones * and save files. */ -#define EDITLEVEL 93 +#define EDITLEVEL 94 /* * Development status possibilities. diff --git a/src/shk.c b/src/shk.c index 7968bcd021..7627449cf0 100644 --- a/src/shk.c +++ b/src/shk.c @@ -45,6 +45,7 @@ static long set_cost(struct obj *, struct monst *); static const char *shk_embellish(struct obj *, long); static long cost_per_charge(struct monst *, struct obj *, boolean); static long cheapest_item(struct monst *); +static int menu_pick_pay_items(struct monst *); static int dopayobj(struct monst *, struct bill_x *, struct obj **, int, boolean); static long stolen_container(struct obj *, struct monst *, long, boolean); @@ -1382,6 +1383,56 @@ cheapest_item(struct monst *shkp) return gmin; } +/* show items on your bill in a menu, and ask which to pay. + returns the number of entries selected. */ +static int +menu_pick_pay_items(struct monst *shkp) +{ + struct eshk *eshkp = ESHK(shkp); + winid win; + anything any; + menu_item *pick_list = (menu_item *) 0; + int i, j, n, clr = NO_COLOR; + char buf[BUFSZ]; + + any = cg.zeroany; + win = create_nhwindow(NHW_MENU); + start_menu(win, MENU_BEHAVE_STANDARD); + + for (n = 0; n < eshkp->billct; n++) { + struct obj *otmp; + register struct bill_x *bp = &(eshkp->bill_p[n]); + + bp->queuedpay = FALSE; + + /* find the object on one of the lists */ + if ((otmp = bp_to_obj(bp)) != 0) { + /* if completely used up, object quantity is stale; + restoring it to its original value here avoids + making the partly-used-up code more complicated */ + if (bp->useup) + otmp->quan = bp->bquan; + Sprintf(buf, "%s%s", + bp->useup ? "(used up) " : "", + doname(otmp)); + any.a_int = n + 1; /* +1: avoid 0 */ + add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, buf, + MENU_ITEMFLAGS_NONE); + } + } + + end_menu(win, "Pay which items?"); + n = select_menu(win, PICK_ANY, &pick_list); + destroy_nhwindow(win); + + for (j = 0; j < n; ++j) { + i = pick_list[j].item.a_int - 1; /* -1: reverse +1 above */ + eshkp->bill_p[i].queuedpay = TRUE; + } + free(pick_list); + return n; +} + /* the #pay command */ int dopay(void) @@ -1635,6 +1686,7 @@ dopay(void) /* now check items on bill */ if (eshkp->billct) { register boolean itemize; + boolean queuedpay = FALSE; int iprompt; umoney = money_cnt(gi.invent); @@ -1651,12 +1703,19 @@ dopay(void) return ECMD_OK; } - /* this isn't quite right; it itemizes without asking if the - * single item on the bill is partly used up and partly unpaid */ - iprompt = (eshkp->billct > 1 ? ynq("Itemized billing?") : 'y'); - itemize = (iprompt == 'y'); - if (iprompt == 'q') - goto thanks; + if (flags.menu_style != MENU_TRADITIONAL && eshkp->billct > 1) { + if (!menu_pick_pay_items(shkp)) + return ECMD_OK; + queuedpay = TRUE; + itemize = FALSE; + } else { + /* this isn't quite right; it itemizes without asking if the + * single item on the bill is partly used up and partly unpaid */ + iprompt = (eshkp->billct > 1 ? ynq("Itemized billing?") : 'y'); + itemize = (iprompt == 'y'); + if (iprompt == 'q') + goto thanks; + } for (pass = 0; pass <= 1; pass++) { tmp = 0; @@ -1664,6 +1723,11 @@ dopay(void) struct obj *otmp; register struct bill_x *bp = &(eshkp->bill_p[tmp]); + if (queuedpay && !bp->queuedpay) { + tmp++; + continue; + } + /* find the object on one of the lists */ if ((otmp = bp_to_obj(bp)) != 0) { /* if completely used up, object quantity is stale; From 252e661b72dea29d619135e4556bac61f8715b24 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sat, 9 Dec 2023 13:24:50 +0200 Subject: [PATCH 68/78] Prioritize paying shopkeeper next to you even if multiple are detected --- doc/fixes3-7-0.txt | 1 + src/shk.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 4e4a690b83..7e5d658d3e 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1322,6 +1322,7 @@ change wolf and werewolf to grey, warg to black change [master] mind flayer, the Wizard, and the riders to bright magenta walking into a shopkeeper tries to pay the bill show billed items in a menu when paying with non-traditional menustyle +prioritize paying shopkeeper next to you even if multiple are detected Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/shk.c b/src/shk.c index 7627449cf0..df462debfa 100644 --- a/src/shk.c +++ b/src/shk.c @@ -1442,7 +1442,7 @@ dopay(void) struct monst *nxtm, *resident; long ltmp; long umoney; - int pass, tmp, sk = 0, seensk = 0; + int pass, tmp, sk = 0, seensk = 0, nexttosk = 0; boolean paid = FALSE, stashed_gold = (hidden_gold(TRUE) > 0L); gm.multi = 0; @@ -1454,16 +1454,21 @@ dopay(void) for (shkp = next_shkp(fmon, FALSE); shkp; shkp = next_shkp(shkp->nmon, FALSE)) { sk++; - if (ANGRY(shkp) && next2u(shkp->mx, shkp->my)) + if (next2u(shkp->mx, shkp->my)) { + /* next to an irate shopkeeper? prioritize that */ + if (nxtm && ANGRY(nxtm)) + continue; + nexttosk++; nxtm = shkp; + } if (canspotmon(shkp)) seensk++; if (inhishop(shkp) && (*u.ushops == ESHK(shkp)->shoproom)) resident = shkp; } - if (nxtm) { /* Player should always appease an */ - shkp = nxtm; /* irate shk standing next to them. */ + if (nxtm && nexttosk == 1) { + shkp = nxtm; goto proceed; } From 9529e3f5927e6d7cacbed959036e039b7c923c95 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 9 Dec 2023 04:21:25 -0800 Subject: [PATCH 69/78] augment paying shk via menu Allow 'm p' to pay via menu when menustyle is traditional and to pay via the old sequence when it's combination, full, or partial. Also revise the "Itemized billing?" prompt to accept 'm' as well as 'ynq'. Answering 'm' will switch from the old sequence to the menu (whether you got to that prompt via m-less 'p' for traditional or 'm p' for other styles). --- src/cmd.c | 4 ++-- src/shk.c | 61 ++++++++++++++++++++++++++++++++----------------------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index 268224887e..b8c9bdc975 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 cmd.c $NHDT-Date: 1684791777 2023/05/22 21:42:57 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.677 $ */ +/* NetHack 3.7 cmd.c $NHDT-Date: 1702123758 2023/12/09 12:09:18 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.694 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2645,7 +2645,7 @@ struct ext_func_tab extcmdlist[] = { { '\0', "panic", "test panic routine (fatal to game)", wiz_panic, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL }, { 'p', "pay", "pay your shopping bill", - dopay, 0, NULL }, + dopay, CMD_M_PREFIX, NULL }, { '|', "perminv", "scroll persistent inventory display", doperminv, IFBURIED | GENERALCMD | NOFUZZERCMD, NULL }, { ',', "pickup", "pick up things at the current location", diff --git a/src/shk.c b/src/shk.c index df462debfa..f6396d6518 100644 --- a/src/shk.c +++ b/src/shk.c @@ -1412,7 +1412,7 @@ menu_pick_pay_items(struct monst *shkp) making the partly-used-up code more complicated */ if (bp->useup) otmp->quan = bp->bquan; - Sprintf(buf, "%s%s", + Snprintf(buf, sizeof buf, "%s%s", bp->useup ? "(used up) " : "", doname(otmp)); any.a_int = n + 1; /* +1: avoid 0 */ @@ -1421,7 +1421,7 @@ menu_pick_pay_items(struct monst *shkp) } } - end_menu(win, "Pay which items?"); + end_menu(win, "Pay for which items?"); n = select_menu(win, PICK_ANY, &pick_list); destroy_nhwindow(win); @@ -1442,7 +1442,7 @@ dopay(void) struct monst *nxtm, *resident; long ltmp; long umoney; - int pass, tmp, sk = 0, seensk = 0, nexttosk = 0; + int pass, tmp, sk = 0, seensk = 0; boolean paid = FALSE, stashed_gold = (hidden_gold(TRUE) > 0L); gm.multi = 0; @@ -1454,21 +1454,16 @@ dopay(void) for (shkp = next_shkp(fmon, FALSE); shkp; shkp = next_shkp(shkp->nmon, FALSE)) { sk++; - if (next2u(shkp->mx, shkp->my)) { - /* next to an irate shopkeeper? prioritize that */ - if (nxtm && ANGRY(nxtm)) - continue; - nexttosk++; + if (ANGRY(shkp) && next2u(shkp->mx, shkp->my)) nxtm = shkp; - } if (canspotmon(shkp)) seensk++; if (inhishop(shkp) && (*u.ushops == ESHK(shkp)->shoproom)) resident = shkp; } - if (nxtm && nexttosk == 1) { - shkp = nxtm; + if (nxtm) { /* Player should always appease an */ + shkp = nxtm; /* irate shk standing next to them. */ goto proceed; } @@ -1691,7 +1686,7 @@ dopay(void) /* now check items on bill */ if (eshkp->billct) { register boolean itemize; - boolean queuedpay = FALSE; + boolean queuedpay = FALSE, via_menu; int iprompt; umoney = money_cnt(gi.invent); @@ -1708,19 +1703,35 @@ dopay(void) return ECMD_OK; } - if (flags.menu_style != MENU_TRADITIONAL && eshkp->billct > 1) { - if (!menu_pick_pay_items(shkp)) - return ECMD_OK; - queuedpay = TRUE; - itemize = FALSE; - } else { - /* this isn't quite right; it itemizes without asking if the - * single item on the bill is partly used up and partly unpaid */ - iprompt = (eshkp->billct > 1 ? ynq("Itemized billing?") : 'y'); - itemize = (iprompt == 'y'); - if (iprompt == 'q') - goto thanks; - } + via_menu = (flags.menu_style != MENU_TRADITIONAL); + /* allow 'm p' to request a menu for menustyle:traditional; + for other styles, it will do the opposite; that doesn't make + a whole lot of sense for a 'request-menu' prefix, but otherwise + it would simply be reduncant and there wouldn't be any way to + skip the menu when hero owes for multiple items */ + if (iflags.menu_requested) + via_menu = !via_menu; + /* this will loop for a second iteration iff not initially using a + menu and player answers 'm' to custom ynq prompt */ + do { + if (via_menu && eshkp->billct > 1) { + if (!menu_pick_pay_items(shkp)) + return ECMD_OK; + queuedpay = TRUE; + itemize = FALSE; + via_menu = FALSE; /* reset so that we don't loop */ + } else { + /* this isn't quite right; it itemizes without asking if the + single item on bill is partly used up and partly unpaid */ + iprompt = (eshkp->billct < 2) ? 'y' + : yn_function("Itemized billing?", + "ynq m", 'q', TRUE); + itemize = (iprompt == 'y'); + if (iprompt == 'q') + goto thanks; + via_menu = (iprompt == 'm'); + } + } while (via_menu); for (pass = 0; pass <= 1; pass++) { tmp = 0; From 2996e42b79a64509ad285946d0a5cd19d1189e78 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sat, 9 Dec 2023 16:06:07 +0200 Subject: [PATCH 70/78] Redo my clobbered commit --- src/shk.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/shk.c b/src/shk.c index f6396d6518..81668c4fdf 100644 --- a/src/shk.c +++ b/src/shk.c @@ -1442,7 +1442,7 @@ dopay(void) struct monst *nxtm, *resident; long ltmp; long umoney; - int pass, tmp, sk = 0, seensk = 0; + int pass, tmp, sk = 0, seensk = 0, nexttosk = 0; boolean paid = FALSE, stashed_gold = (hidden_gold(TRUE) > 0L); gm.multi = 0; @@ -1454,16 +1454,21 @@ dopay(void) for (shkp = next_shkp(fmon, FALSE); shkp; shkp = next_shkp(shkp->nmon, FALSE)) { sk++; - if (ANGRY(shkp) && next2u(shkp->mx, shkp->my)) + if (next2u(shkp->mx, shkp->my)) { + /* next to an irate shopkeeper? prioritize that */ + if (nxtm && ANGRY(nxtm)) + continue; + nexttosk++; nxtm = shkp; + } if (canspotmon(shkp)) seensk++; if (inhishop(shkp) && (*u.ushops == ESHK(shkp)->shoproom)) resident = shkp; } - if (nxtm) { /* Player should always appease an */ - shkp = nxtm; /* irate shk standing next to them. */ + if (nxtm && nexttosk == 1) { + shkp = nxtm; goto proceed; } From 70c21cda51ddcb317694e6f09b5adb7950265f35 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 9 Dec 2023 12:07:00 -0500 Subject: [PATCH 71/78] alternative make target using Lua's mirror In the rare event that make fetch-lua is not working because the primary Lua site is not available, provide another target make fetch-lua-mirror that uses the official lua mirror site documented at: https://www.lua.org/mirrors.html --- sys/unix/Makefile.top | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/unix/Makefile.top b/sys/unix/Makefile.top index 48d4803e1a..ac03adfa30 100644 --- a/sys/unix/Makefile.top +++ b/sys/unix/Makefile.top @@ -310,6 +310,13 @@ dofiles-nodlb: # # This is not part of the dependency build hierarchy. # It requires an explicit "make fetch-Lua". + +LUA_URL=www.lua.org/ftp + +fetch-lua-mirror: LUA_URL :=www.tecgraf.puc-rio.br/lua/mirror/ftp +fetch-lua-mirror: fetch-Lua + @true + fetch-lua: fetch-Lua @true @@ -321,7 +328,7 @@ fetch-Lua: shac="$$shac1 -a 256"; elif [ ! -z $$shac2 ]; then \ shac=$$shac2; else echo "CAUTION: no way to check integrity"; \ fi; \ - curl -R -O https://www.lua.org/ftp/lua-$(LUA_VERSION).tar.gz && \ + curl -R -O https://$(LUA_URL)/lua-$(LUA_VERSION).tar.gz && \ if [ ! -z "$$shac" ]; then \ echo Checking integrity with $$shac; \ $$shac -w -c ../submodules/CHKSUMS < lua-$(LUA_VERSION).tar.gz; \ @@ -334,7 +341,7 @@ fetch-Lua: fetch-lua-http: ( mkdir -p lib && cd lib && \ - curl -R -O http://www.lua.org/ftp/lua-$(LUA_VERSION).tar.gz && \ + curl -R -O http://$(LUA_URL)/lua-$(LUA_VERSION).tar.gz && \ tar zxf lua-$(LUA_VERSION).tar.gz && \ rm -f lua-$(LUA_VERSION).tar.gz ) From 8b821d0e00058144c577ef1c9c90c7d246e4ef13 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 9 Dec 2023 12:11:27 -0500 Subject: [PATCH 72/78] follow-up for Lua mirror target Use a variable --- sys/unix/Makefile.top | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/unix/Makefile.top b/sys/unix/Makefile.top index ac03adfa30..7155dc8f9c 100644 --- a/sys/unix/Makefile.top +++ b/sys/unix/Makefile.top @@ -311,9 +311,10 @@ dofiles-nodlb: # This is not part of the dependency build hierarchy. # It requires an explicit "make fetch-Lua". -LUA_URL=www.lua.org/ftp +LUA_URL :=www.lua.org/ftp +LUA_URL_MIRROR :=www.tecgraf.puc-rio.br/lua/mirror/ftp -fetch-lua-mirror: LUA_URL :=www.tecgraf.puc-rio.br/lua/mirror/ftp +fetch-lua-mirror: LUA_URL :=$(LUA_URL_MIRROR) fetch-lua-mirror: fetch-Lua @true From 31717fe2276b0cb53a733116b2ac43557f66fa53 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 10 Dec 2023 03:21:52 -0800 Subject: [PATCH 73/78] fix github issue #1170 - trapped without a trap Issue reported by mkuoppal: drum of earthquake triggers a sanity check warning which the fuzzer escalated to panic. Analysis by entrez. If a pit gets created next to a pool or moat or lava, liquid might flow there and replace the pit. But the drum of earthquake code assumed that the pit was still there. If there was a monster there and it wasn't levitating or flying and it wasn't killed by the liquid, it got marked as trapped even though the pit was gone. 'sanity_check' noticed. With difficulty I was able to reproduce the impossible warning before the fix, but the are a bunch of random factors at play. After the fix I can't reproduce it again, but that's not a guarantee that it's actually fixed. The analysis seems correct though and the fix is based on dealing with that. Closes #1170 --- doc/fixes3-7-0.txt | 5 +++++ src/dig.c | 25 +++++++++++++++++++------ src/music.c | 13 ++++++++----- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 7e5d658d3e..eb8fa876bb 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1323,6 +1323,11 @@ change [master] mind flayer, the Wizard, and the riders to bright magenta walking into a shopkeeper tries to pay the bill show billed items in a menu when paying with non-traditional menustyle prioritize paying shopkeeper next to you even if multiple are detected +avoid impossible "trapped without a trap (fmon)" from 'sanity_check' when a + drum of earthquake made a pit at a monster's spot and pit creation + caused adjacent pool/moat/lava to flood that spot; if a non-floater, + non-flyer monster survived that it got marked as trapped even though + flooding deleted the trap Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/dig.c b/src/dig.c index 17fba710ae..a6a1f98f51 100644 --- a/src/dig.c +++ b/src/dig.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 dig.c $NHDT-Date: 1596498156 2020/08/03 23:42:36 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.142 $ */ +/* NetHack 3.7 dig.c $NHDT-Date: 1702206282 2023/12/10 11:04:42 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.204 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -747,19 +747,32 @@ digactualhole(coordxy x, coordxy y, struct monst *madeby, int ttyp) DISABLE_WARNING_FORMAT_NONLITERAL /* - * Called from dighole(), but also from do_break_wand() - * in apply.c. + * Called from dighole(); also from do_break_wand() in apply.c + * and do_earthquake() in music.c. */ void -liquid_flow(coordxy x, coordxy y, schar typ, struct trap *ttmp, - const char *fillmsg) +liquid_flow( + coordxy x, coordxy y, + schar typ, + struct trap *ttmp, + const char *fillmsg) { struct obj *objchain; struct monst *mon; boolean u_spot = u_at(x, y); + /* caller should have changed levl[x][y].typ to POOL, MOAT, or LAVA */ + if (!is_pool_or_lava(x, y)) { + if (iflags.sanity_check) { + impossible("Insane liquid_flow(%d,%d,%s,%s).", x, y, + ttmp ? trapname(ttmp->ttyp, TRUE) : "no trap", + fillmsg ? fillmsg : "no mesg"); + } + return; + } + if (ttmp) - (void) delfloortrap(ttmp); + (void) delfloortrap(ttmp); /* will untrap monster is one is here */ /* if any objects were frozen here, they're released now */ unearth_objs(x, y); diff --git a/src/music.c b/src/music.c index 2703f2f0af..a1f4b60862 100644 --- a/src/music.c +++ b/src/music.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 music.c $NHDT-Date: 1646688067 2022/03/07 21:21:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.77 $ */ +/* NetHack 3.7 music.c $NHDT-Date: 1702206294 2023/12/10 11:04:54 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.101 $ */ /* Copyright (c) 1989 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ @@ -337,8 +337,11 @@ do_earthquake(int force) wand of digging if you alter this sequence. */ filltype = fillholetyp(x, y, FALSE); if (filltype != ROOM) { - levl[x][y].typ = filltype; /* flags set via doormask */ + set_levltyp(x, y, filltype); /* levl[x][y] = filltype; */ liquid_flow(x, y, filltype, chasm, (char *) 0); + /* liquid_flow() deletes trap, might kill mtmp */ + if ((chasm = t_at(x, y)) == NULL) + break; /* from switch, not loop */ } mtmp = m_at(x, y); /* (redundant?) */ @@ -353,8 +356,8 @@ do_earthquake(int force) break; /* from switch, not loop */ } - /* We have to check whether monsters or player - falls in a chasm... */ + /* We have to check whether monsters or hero falls into a + new pit.... Note: if we get here, chasm is non-Null. */ if (mtmp) { if (!is_flyer(mtmp->data) && !is_clinger(mtmp->data)) { boolean m_already_trapped = mtmp->mtrapped; @@ -427,7 +430,7 @@ do_earthquake(int force) exercise(A_DEX, TRUE); else selftouch((Upolyd && (slithy(gy.youmonst.data) - || nolimbs(gy.youmonst.data))) + || nolimbs(gy.youmonst.data))) ? "Shaken, you" : "Falling down, you"); } From aa5ad3e37ea502722e99e06ac451a80787530223 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sun, 10 Dec 2023 17:32:47 +0200 Subject: [PATCH 74/78] Split tip container menu function --- src/pickup.c | 117 +++++++++++++++++++++++++++++---------------------- 1 file changed, 66 insertions(+), 51 deletions(-) diff --git a/src/pickup.c b/src/pickup.c index 7b77811165..01e2721033 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -41,6 +41,7 @@ static void explain_container_prompt(boolean); static int traditional_loot(boolean); static int menu_loot(int, boolean); static int tip_ok(struct obj *); +static int choose_tip_container_menu(void); static struct obj *tipcontainer_gettarget(struct obj *, boolean *); static int tipcontainer_checks(struct obj *, struct obj *, boolean); static char in_or_out_menu(const char *, struct obj *, boolean, boolean, @@ -3376,6 +3377,67 @@ tip_ok(struct obj *obj) return GETOBJ_DOWNPLAY; } +/* show a menu of containers under hero, + and one extra entry for choosing an inventory. + returns ECMD_CANCEL if menu was canceled, + ECMD_TIME if a container was picked, + otherwise returns ECMD_OK. */ +static int +choose_tip_container_menu(void) +{ + int n, i; + winid win; + anything any; + menu_item *pick_list = (menu_item *) 0; + struct obj dummyobj, *otmp; + int clr = NO_COLOR; + + any = cg.zeroany; + win = create_nhwindow(NHW_MENU); + start_menu(win, MENU_BEHAVE_STANDARD); + + for (otmp = gl.level.objects[u.ux][u.uy], i = 0; otmp; + otmp = otmp->nexthere) + if (Is_container(otmp)) { + ++i; + any.a_obj = otmp; + add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, + clr, doname(otmp), MENU_ITEMFLAGS_NONE); + } + if (gi.invent) { + add_menu_str(win, ""); + any.a_obj = &dummyobj; + /* use 'i' for inventory unless there are so many + containers that it's already being used */ + i = (i <= 'i' - 'a' && !flags.lootabc) ? 'i' : 0; + add_menu(win, &nul_glyphinfo, &any, i, 0, ATR_NONE, + clr, "tip something being carried", + MENU_ITEMFLAGS_SELECTED); + } + end_menu(win, "Tip which container?"); + n = select_menu(win, PICK_ONE, &pick_list); + destroy_nhwindow(win); + /* + * Deal with quirk of preselected item in pick-one menu: + * n == 0 => picked preselected entry, toggling it off; + * n == 1 => accepted preselected choice via SPACE or RETURN; + * n == 2 => picked something other than preselected entry; + * n == -1 => cancelled via ESC; + */ + otmp = (n <= 0) ? (struct obj *) 0 : pick_list[0].item.a_obj; + if (n > 1 && otmp == &dummyobj) + otmp = pick_list[1].item.a_obj; + if (pick_list) + free((genericptr_t) pick_list); + if (otmp && otmp != &dummyobj) { + tipcontainer(otmp); + return ECMD_TIME; + } + if (n == -1) + return ECMD_CANCEL; + return ECMD_OK; +} + /* #tip command -- empty container contents onto floor */ int dotip(void) @@ -3412,57 +3474,10 @@ dotip(void) !flags.verbose ? "a container" : (boxes > 1) ? "one" : "it"); if (!check_capacity(buf) && able_to_loot(cc.x, cc.y, FALSE)) { if (boxes > 1) { - /* use menu to pick a container to tip */ - int n, i; - winid win; - anything any; - menu_item *pick_list = (menu_item *) 0; - struct obj dummyobj, *otmp; - int clr = NO_COLOR; - - any = cg.zeroany; - win = create_nhwindow(NHW_MENU); - start_menu(win, MENU_BEHAVE_STANDARD); - - for (cobj = gl.level.objects[cc.x][cc.y], i = 0; cobj; - cobj = cobj->nexthere) - if (Is_container(cobj)) { - ++i; - any.a_obj = cobj; - add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, - clr, doname(cobj), MENU_ITEMFLAGS_NONE); - } - if (gi.invent) { - add_menu_str(win, ""); - any.a_obj = &dummyobj; - /* use 'i' for inventory unless there are so many - containers that it's already being used */ - i = (i <= 'i' - 'a' && !flags.lootabc) ? 'i' : 0; - add_menu(win, &nul_glyphinfo, &any, i, 0, ATR_NONE, - clr, "tip something being carried", - MENU_ITEMFLAGS_SELECTED); - } - end_menu(win, "Tip which container?"); - n = select_menu(win, PICK_ONE, &pick_list); - destroy_nhwindow(win); - /* - * Deal with quirk of preselected item in pick-one menu: - * n == 0 => picked preselected entry, toggling it off; - * n == 1 => accepted preselected choice via SPACE or RETURN; - * n == 2 => picked something other than preselected entry; - * n == -1 => cancelled via ESC; - */ - otmp = (n <= 0) ? (struct obj *) 0 : pick_list[0].item.a_obj; - if (n > 1 && otmp == &dummyobj) - otmp = pick_list[1].item.a_obj; - if (pick_list) - free((genericptr_t) pick_list); - if (otmp && otmp != &dummyobj) { - tipcontainer(otmp); - return ECMD_TIME; - } - if (n == -1) - return ECMD_OK; + int res; + /* pick one container via menu or ... */ + if ((res = choose_tip_container_menu()) != ECMD_OK) + return res; /* else pick-from-gi.invent below */ } else { for (cobj = gl.level.objects[cc.x][cc.y]; cobj; cobj = nobj) { From e0f591bc49d5ea6d1b3d083b8f8e73c39638a273 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 10 Dec 2023 10:42:01 -0500 Subject: [PATCH 75/78] fixes3-7-0.txt entry for pull request 1155 --- doc/fixes3-7-0.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index eb8fa876bb..379d06d213 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -2583,6 +2583,7 @@ add new options 'nopick_dropped' and 'pickup_stolen' options to avoid auto-pickup of items dropped by hero and to auto-pickup things previously stolen from hero if moved upon while autopickup is On; both bypass pickup_types and autopickup_exceptions (pr #1140 by entrez) +fix msg_window:combination and TTY getlin() ^P (pr #1155 by entrez) Code Cleanup and Reorganization From c2802dba2de05b478c95656b22abb9912e9704f0 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sun, 10 Dec 2023 20:10:22 +0200 Subject: [PATCH 76/78] Demons cannot be frightened by showing them their reflection From xnethack by copperwater . --- doc/fixes3-7-0.txt | 1 + src/apply.c | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 379d06d213..0aca9b3fa7 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1328,6 +1328,7 @@ avoid impossible "trapped without a trap (fmon)" from 'sanity_check' when a caused adjacent pool/moat/lava to flood that spot; if a non-floater, non-flyer monster survived that it got marked as trapped even though flooding deleted the trap +demons cannot be frightened by showing them their reflection Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/apply.c b/src/apply.c index a7875da6d6..017082e071 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1144,6 +1144,7 @@ use_mirror(struct obj *obj) if (!tele_restrict(mtmp)) (void) rloc(mtmp, RLOC_MSG); } else if (!is_unicorn(mtmp->data) && !humanoid(mtmp->data) + && !is_demon(mtmp->data) && (!mtmp->minvis || perceives(mtmp->data)) && rn2(5)) { boolean do_react = TRUE; From f3408b87badd91b8dd784dbc9f21f5467ed80d89 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Mon, 11 Dec 2023 03:03:23 +0000 Subject: [PATCH 77/78] A new HP regeneration formula The new formula is: (xlevel + Con)% chance of regenerating 1 hp each turn. This formula has been extensively playtested throughout the whole game (including two ascensions). The intention is to make late- game combat more interesting: early game the HP regeneration rate is potentially slightly faster but not significantly changed, but in the midgame and lategame is substantially slower because there is no longer a big regeneration boost once the character's xlevel is in the double digits. With the new formula, I'm finding that my characters have to heal with potions (rather than by waiting) in places that they never had to before (e.g. lower Dungeons, and upper Gehennom), which in turn means that fighting efficiently is now more important than it was before. (In fact, in one of the games I wished for potions of full healing on Astral for safety, although I think I would still have won without.) It's also generally the case that you can no longer regenerate "mid-fight": you need to disengage in order to heal up. This made the game more fun as it meant that escape items became more relevant, and I was using a greater range of items throughout the game than I normally would. The ring of regeneration has also been slightly buffed: it now heals an extra 1hp per turn unconditionally (rather than becoming less effective as the character levels). In both my test ascensions, I found a ring of regeneration, but intentionally refrained from using it in order to ensure that the new HP regeneration rate would be tolerable even without one. --- doc/fixes3-7-0.txt | 3 ++- src/allmain.c | 22 ++++------------------ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 0aca9b3fa7..69eb14bba5 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1317 $ $NHDT-Date: 1701500708 2023/12/02 07:05:08 $ +$NHDT-Branch: (unknown) $:$NHDT-Revision: 1.1339 $ $NHDT-Date: 1702264272 2023/12/11 03:11:12 $ General Fixes and Modified Features ----------------------------------- @@ -1329,6 +1329,7 @@ avoid impossible "trapped without a trap (fmon)" from 'sanity_check' when a non-flyer monster survived that it got marked as trapped even though flooding deleted the trap demons cannot be frightened by showing them their reflection +HP regeneration formula has changed, primarily to be less fast in the endgame Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/allmain.c b/src/allmain.c index dbe9b0fe7d..f0bf8e8e6c 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -605,24 +605,10 @@ regen_hp(int wtcap) once u.mh reached u.mhmax; that may have been convenient for the player, but it didn't make sense for gameplay...] */ if (u.uhp < u.uhpmax && (encumbrance_ok || U_CAN_REGEN())) { - if (u.ulevel > 9) { - if (!(gm.moves % 3L)) { - int Con = (int) ACURR(A_CON); - - if (Con <= 12) { - heal = 1; - } else { - heal = rnd(Con); - if (heal > u.ulevel - 9) - heal = u.ulevel - 9; - } - } - } else { /* u.ulevel <= 9 */ - if (!(gm.moves % (long) ((MAXULEV + 12) / (u.ulevel + 2) + 1))) - heal = 1; - } - if (U_CAN_REGEN() && !heal) - heal = 1; + heal = (u.ulevel + (int)ACURR(A_CON)) > rn2(100); + + if (U_CAN_REGEN()) + heal += 1; if (Sleepy && u.usleep) heal++; From a7db78f7d6f60ec07086a04d980de9fa45f4064a Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 10 Dec 2023 22:09:26 -0800 Subject: [PATCH 78/78] fix #K4060 - "you walk quietly" while riding Donning elven boots while riding and not already stealthy, you'd get the message "you walk quietly" when not walking at all. Instead of just changing the message, make riding a non-flying steed block stealth. Riding a flying steed (or one you take aloft with an amulet of flying) does not. It would have been quite a bit simpler to have made riding anything block stealth, but the hard part is done. --- doc/fixes3-7-0.txt | 3 ++- include/extern.h | 1 + include/prop.h | 14 ++++++------- include/youprop.h | 7 ++++++- src/do_wear.c | 23 +++++++++++++------- src/insight.c | 14 +++++++++---- src/mon.c | 2 ++ src/polyself.c | 11 +++++++++- src/steed.c | 52 +++++++++++++++++++++++++++++++++++++++++----- src/trap.c | 16 ++------------ 10 files changed, 103 insertions(+), 40 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 69eb14bba5..a7dbffed36 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1326,10 +1326,11 @@ prioritize paying shopkeeper next to you even if multiple are detected avoid impossible "trapped without a trap (fmon)" from 'sanity_check' when a drum of earthquake made a pit at a monster's spot and pit creation caused adjacent pool/moat/lava to flood that spot; if a non-floater, - non-flyer monster survived that it got marked as trapped even though + non-flyer monster survived that, it got marked as trapped even though flooding deleted the trap demons cannot be frightened by showing them their reflection HP regeneration formula has changed, primarily to be less fast in the endgame +riding negates stealth unless the steed is flying Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/include/extern.h b/include/extern.h index cb0234696e..1c7f2e5e43 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2792,6 +2792,7 @@ extern void exercise_steed(void); extern void kick_steed(void); extern void dismount_steed(int); extern void place_monster(struct monst *, coordxy, coordxy); +extern void poly_steed(struct monst *, struct permonst *); extern boolean stucksteed(boolean); /* ### symbols.c ### */ diff --git a/include/prop.h b/include/prop.h index 1d4e3ee112..57f07b9985 100644 --- a/include/prop.h +++ b/include/prop.h @@ -1,4 +1,4 @@ -/* NetHack 3.7 prop.h $NHDT-Date: 1596498555 2020/08/03 23:49:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.22 $ */ +/* NetHack 3.7 prop.h $NHDT-Date: 1702274027 2023/12/11 05:53:47 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.24 $ */ /* Copyright (c) 1989 Mike Threepoint */ /* NetHack may be freely redistributed. See license for details. */ @@ -129,14 +129,14 @@ struct prop { long intrinsic; /* Timed properties */ #define TIMEOUT 0x00ffffffL /* Up to 16 million turns */ - /* Permanent properties */ -#define FROMEXPER 0x01000000L /* Gain/lose with experience, for role */ -#define FROMRACE 0x02000000L /* Gain/lose with experience, for race */ +/* Permanent properties */ +#define FROMEXPER 0x01000000L /* Gain/lose with experience, for role */ +#define FROMRACE 0x02000000L /* Gain/lose with experience, for race */ #define FROMOUTSIDE 0x04000000L /* By corpses, prayer, thrones, etc. */ -#define INTRINSIC (FROMOUTSIDE | FROMRACE | FROMEXPER) +#define INTRINSIC (FROMOUTSIDE | FROMRACE | FROMEXPER) /* Control flags */ -#define FROMFORM 0x10000000L /* Polyd; conferred by monster form */ -#define I_SPECIAL 0x20000000L /* Property is controllable */ +#define FROMFORM 0x10000000L /* Polyd; conferred by monster form */ +#define I_SPECIAL 0x20000000L /* Property is controllable */ }; /*** Definitions for backwards compatibility ***/ diff --git a/include/youprop.h b/include/youprop.h index c41fdba489..b9cfcec752 100644 --- a/include/youprop.h +++ b/include/youprop.h @@ -1,4 +1,4 @@ -/* NetHack 3.7 youprop.h $NHDT-Date: 1596498577 2020/08/03 23:49:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.32 $ */ +/* NetHack 3.7 youprop.h $NHDT-Date: 1702274029 2023/12/11 05:53:49 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.44 $ */ /* Copyright (c) 1989 Mike Threepoint */ /* NetHack may be freely redistributed. See license for details. */ @@ -200,6 +200,7 @@ #define HStealth u.uprops[STEALTH].intrinsic #define EStealth u.uprops[STEALTH].extrinsic +/* BStealth has FROMOUTSIDE set if mounted on non-flying steed */ #define BStealth u.uprops[STEALTH].blocked #define Stealth ((HStealth || EStealth) && !BStealth) @@ -384,6 +385,10 @@ * Some pseudo-properties. */ +/* the code will needs lots of updating to use this so leave it commented +#define Riding (u.usteed != NULL) +*/ + /* unconscious() includes u.usleep but not is_fainted(); the multi test is redundant but allows the function calls to be skipped most of the time */ #define Unaware (gm.multi < 0 && (unconscious() || is_fainted())) diff --git a/src/do_wear.c b/src/do_wear.c index 1b3f4450a0..da99bae3b7 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -85,7 +85,9 @@ on_msg(struct obj *otmp) } /* putting on or taking off an item which confers stealth; - give feedback and discover it iff stealth state is changing */ + give feedback and discover it iff stealth state is changing; + stealth is blocked by riding unless hero+steed fly (handled with + BStealth by mount and dismount routines) */ static void toggle_stealth( @@ -101,7 +103,7 @@ toggle_stealth( && !BStealth) { /* stealth blocked by something */ if (obj->otyp == RIN_STEALTH) learnring(obj, TRUE); - else + else /* discover elven cloak or elven boots */ makeknown(obj->otyp); if (on) { @@ -112,7 +114,13 @@ toggle_stealth( else You("walk very quietly."); } else { - You("sure are noisy."); + boolean riding = (u.usteed != NULL); + + You("%s%s are noisy.", riding ? "and " : "sure", + riding ? x_monnam(u.usteed, ARTICLE_YOUR, (char *) NULL, + (SUPPRESS_SADDLE | SUPPRESS_HALLUCINATION), + FALSE) + : ""); } } } @@ -123,10 +131,11 @@ toggle_stealth( hero is able to see self (or sense monsters); for timed, 'obj' is Null and this is only called for the message */ void -toggle_displacement(struct obj *obj, - long oldprop, /* prop[].extrinsic, with obj->owornmask - stripped by caller */ - boolean on) +toggle_displacement( + struct obj *obj, + long oldprop, /* prop[].extrinsic, with obj->owornmask + stripped by caller */ + boolean on) { if (on ? gi.initial_don : gc.context.takeoff.cancelled_don) return; diff --git a/src/insight.c b/src/insight.c index ea32037683..2055689b15 100644 --- a/src/insight.c +++ b/src/insight.c @@ -1455,7 +1455,7 @@ attributes_enlightenment( { static NEARDATA const char if_surroundings_permitted[] = " if surroundings permitted"; - int ltmp, armpro; + int ltmp, armpro, warnspecies; char buf[BUFSZ]; /*\ @@ -1566,9 +1566,10 @@ attributes_enlightenment( : "certain monsters"); you_are(buf, ""); } - if (Warn_of_mon && gc.context.warntype.speciesidx >= LOW_PM) { + warnspecies = gc.context.warntype.speciesidx; + if (Warn_of_mon && warnspecies >= LOW_PM) { Sprintf(buf, "aware of the presence of %s", - makeplural(mons[gc.context.warntype.speciesidx].pmnames[NEUTRAL])); + makeplural(mons[warnspecies].pmnames[NEUTRAL])); you_are(buf, from_what(WARN_OF_MON)); } if (Undead_warning) @@ -1630,8 +1631,13 @@ attributes_enlightenment( you_are("visible", from_what(-INVIS)); if (Displaced) you_are("displaced", from_what(DISPLACED)); - if (Stealth) + if (Stealth) { you_are("stealthy", from_what(STEALTH)); + } else if (BStealth && (HStealth || EStealth)) { + Sprintf(buf, " steathy%s", + (BStealth == FROMOUTSIDE) ? " if not mounted" : ""); + enl_msg(You_, "would be", "would have been", buf, ""); + } if (Aggravate_monster) enl_msg("You aggravate", "", "d", " monsters", from_what(AGGRAVATE_MONSTER)); diff --git a/src/mon.c b/src/mon.c index a00489ab8b..1938814ea2 100644 --- a/src/mon.c +++ b/src/mon.c @@ -5054,6 +5054,8 @@ newcham( } } } + if (mtmp == u.usteed) + poly_steed(mtmp, olddata); return 1; } diff --git a/src/polyself.c b/src/polyself.c index 8d17f19321..1c7dbc0c71 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 polyself.c $NHDT-Date: 1681429658 2023/04/13 23:47:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.197 $ */ +/* NetHack 3.7 polyself.c $NHDT-Date: 1702274031 2023/12/11 05:53:51 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.204 $ */ /* Copyright (C) 1987, 1988, 1989 by Ken Arromdee */ /* NetHack may be freely redistributed. See license for details. */ @@ -133,6 +133,15 @@ float_vs_flight(void) BLevitation |= I_SPECIAL; else BLevitation &= ~I_SPECIAL; + + /* riding blocks stealth unless hero+steed fly, so a change in flying + might cause a change in stealth */ + if (u.usteed) { + if (!Flying && !Levitation) + BStealth |= FROMOUTSIDE; + else + BStealth &= ~FROMOUTSIDE; + } gc.context.botl = TRUE; } diff --git a/src/steed.c b/src/steed.c index 1db6b2db56..75229ff323 100644 --- a/src/steed.c +++ b/src/steed.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 steed.c $NHDT-Date: 1671838909 2022/12/23 23:41:49 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.108 $ */ +/* NetHack 3.7 steed.c $NHDT-Date: 1702274036 2023/12/11 05:53:56 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.115 $ */ /* Copyright (c) Kevin Hugo, 1998-1999. */ /* NetHack may be freely redistributed. See license for details. */ @@ -226,8 +226,10 @@ mount_steed( return (FALSE); } - if (Upolyd && (!humanoid(gy.youmonst.data) || verysmall(gy.youmonst.data) - || bigmonst(gy.youmonst.data) || slithy(gy.youmonst.data))) { + if (Upolyd && (!humanoid(gy.youmonst.data) + || verysmall(gy.youmonst.data) + || bigmonst(gy.youmonst.data) + || slithy(gy.youmonst.data))) { You("won't fit on a saddle."); return (FALSE); } @@ -269,6 +271,7 @@ mount_steed( pline("%s is not saddled.", Monnam(mtmp)); return (FALSE); } + ptr = mtmp->data; if (touch_petrifies(ptr) && !Stone_resistance) { char kbuf[BUFSZ]; @@ -354,6 +357,13 @@ mount_steed( if (uwep && is_pole(uwep)) gu.unweapon = FALSE; u.usteed = mtmp; + if (!Flying && !Levitation) { + boolean was_stealthy = Stealth != 0; + + BStealth |= FROMOUTSIDE; + if (was_stealthy) + You("aren't stealthy anymore."); + } remove_monster(mtmp->mx, mtmp->my); teleds(mtmp->mx, mtmp->my, TELEDS_ALLOW_DRAG); gc.context.botl = TRUE; @@ -631,9 +641,14 @@ dismount_steed( if (repair_leg_damage) heal_legs(1); - /* Release the steed and saddle */ - u.usteed = 0; + /* Release the steed */ + u.usteed = (struct monst *) NULL; u.ugallop = 0L; + if (BStealth) { + BStealth &= ~FROMOUTSIDE; + if (Stealth) + You("seem less noisy now."); + } if (u.utraptype == TT_BEARTRAP || u.utraptype == TT_PIT @@ -817,6 +832,33 @@ maybewakesteed(struct monst* steed) finish_meating(steed); } +/* steed has taken on a new shape */ +void +poly_steed( + struct monst *steed, + struct permonst *oldshape) +{ + if (!can_saddle(steed) || !can_ride(steed)) { + /* removing of no longer wearable saddle was handled during the + shape change (newcham -> mon_break_armor -> m_lose_armor) */ + dismount_steed(DISMOUNT_POLY); + } else { + char buf[BUFSZ]; + + Strcpy(buf, x_monnam(steed, ARTICLE_YOUR, (char *) 0, + SUPPRESS_SADDLE, FALSE)); + if (oldshape != steed->data) + (void) strsubst(buf, "your ", "your new "); + You("adjust yourself in the saddle on %s.", buf); + + /* riding blocks stealth unless hero+steed fly */ + if (!Flying && !Levitation) + BStealth |= FROMOUTSIDE; + else + BStealth &= ~FROMOUTSIDE; + } +} + /* decide whether hero's steed is able to move; doesn't check for holding traps--those affect the hero directly */ boolean diff --git a/src/trap.c b/src/trap.c index 3bd83449c0..7baf41b34a 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 trap.c $NHDT-Date: 1699640827 2023/11/10 18:27:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.554 $ */ +/* NetHack 3.7 trap.c $NHDT-Date: 1702274034 2023/12/11 05:53:54 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.559 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2923,20 +2923,8 @@ steedintrap(struct trap *trap, struct obj *otmp) break; case POLY_TRAP: if (!resists_magm(steed) && !resist(steed, WAND_CLASS, 0, NOTELL)) { - struct permonst *mdat = steed->data; - + /* newcham() will probably end up calling poly_steed() */ (void) newcham(steed, (struct permonst *) 0, NC_SHOW_MSG); - if (!can_saddle(steed) || !can_ride(steed)) { - dismount_steed(DISMOUNT_POLY); - } else { - char buf[BUFSZ]; - - Strcpy(buf, x_monnam(steed, ARTICLE_YOUR, (char *) 0, - SUPPRESS_SADDLE, FALSE)); - if (mdat != steed->data) - (void) strsubst(buf, "your ", "your new "); - You("adjust yourself in the saddle on %s.", buf); - } } steedhit = TRUE; break;