Jukka's Nethack modifications and utilities

reclist

3.6.6 patches:  born-moves

Notice: Nethack 3.6.6 has been released in March 2020 and it is available at https://www.nethack.org.
Many of my older patches are obsolete with it, because the functionality of them is nowadays included in the devteam version. And some others I just haven't bothered to check for 3.6.6-compatibility. Some of the unchecked ones can be found by scrolling down this page, as the last version I tried.

Latest change (August 2020): Moved the pages to another site, added showborn+logmoves for 3.6.6.

Reclist

Reclist 3.4.0 works with Nethack 3.6.6 even though it warns about the version. The separate source is updated for 3.6 but the .zip packet still contains old stuff. I haven't yet checked the other utilities in the .zip packet, but they should work since the record and logfile format hasn't changed.

Reclist is a utility that can be used to view the Nethack RECORD file formatted, much the same way as you see it when the game ends or when you use 'nethack -s'.
Like with 'nethack -s', you can choose to view the entire record file or just one username or one character role. But there are some more switches to view a certain character race, role or alignment, or just games that ended before a certain date or after a certain date.
You can also see the dates when the games ended and you can view other files with the same format, for example the logfile. You can even pipe the output of some other utility to be viewed with reclist, and pipe the reclist output to some pager. And reclist calculates the average score of the viewed entries.
It understands the file formats of Nethack versions at least from 3.1.0 to 3.6.6.

Mergrec is another little utility that can be used to merge two nethack 3.3 record files together.

Logsrt reads the logfile, sorts it in descending order by the scores, and prints it out that way.

Author: Jukka Lahtinen
Downloads: reclist.c (30 KB) The C source
  recls340.zip (170 KB) A packet containing the C source and MS-DOS and OS/2 exe files for reclist, mergrec and logsrt and some reclist documentation. This version of reclist still gives a version warning about the 3.6.0 files, but works.

Some patches for the game (Nethack 3.6.6):

Showborn & logmoves

This combines the "logmoves" and "showborn" patches I used to have as two separate diffs in earlier game versions. "Showborn" may be controlled with OPTIONS=showborn in your configuration file, but I did not add a corresponding option for "logmoves". If you don't like the moves being added to logfile and record, you can just remove or comment out the #define LOGMOVES from include/config.h and compile without it.

"Showborn" will optionally add the number of each monster species created after the number of them killed, if the number is different.
No born counter is shown for species with no killed individuals, or for those species with all born individuals killed.
Notice that the counter of monsters born does NOT count creatures that were not created in that particular game, but loaded from a bones file. Also, when some monster gets polymorphed or "grows up", it affects the born counter of the monster type it was created as, not the type it was killed as. These differences make it possible for the kill count of some monster type to be higher than the born count.
In older versions the showborn patch also added wizard-mode command #showkills but with 3.6.6 the #vanquished commad does the same thing.

"Logmoves" will make the game append the number of moves in curly braces at the end of the record and logfile entries, so you can see how many moves the game took. It also appends a "{wiz}" or "{exp}" tag if the game was played in wizard or explore mode. The game will treat it as addition to the text string telling what killed you (or why the game otherwise ended), so the patch will NOT invalidate your existing record and logfile, not even existing bones and save files! (Keeping the existing files was the reason why I put the additional information where it is.)

Download: born-moves-366.diff (6930 B)
Affected files: dat/opthelp, doc/Guidebook.mn, doc/Guidebook.tex, doc/Guidebook.txt, include/config.h, include/flag.h, src/end.c, src/options.c, src/topten.c, util/makedefs.c
Bones / save files: NOT affected.

Other Nethack patches can be found at http://bilious.alt.org/ .

You can find some information about compiling the game at the Nethack wiki http://nethackwiki.com/wiki/Compiling and about patching at the wiki http://nethackwiki.com/wiki/Patching


Old Stuff: 3.6.0 Patches

makedefs, dump, logmoves, showborn,

Makedefs (3.6.0 version 28.12.2015)

This will let you see most of these patches listed with the #version (or alt-v or meta-v on some platforms) command, when they are compiled in.

Author: Jukka Lahtinen
Download: makedefs-360.diff (541 B)
Affected file: util/makedefs.c
Bones / save files: NOT affected.

Dump character information (3.6.0 version updated 4.6.2016, obsolete with 3.6.6)

The "dump character" patch will make the game write your character's inventory, kill list, conduct information and intrinsics (everything it lists on the screen and some more) to a file when the game ends. Some of this information is only written if you also view it on the screen, some regardless of that. Please read the README file dump-360.README for more information.
The showborn patch is also included in the dump patch for covenience, because the two patches may conflict with each other and I don't want to maintain separate versions because of that any more.
In wizard mode there is also an additional command #showkills that can be used to view the kill list when a wizard mode game is still going on.
Another additional wizard mode and explore mode feature is a prompt for updating the logfile, so you can avoid cluttering the log with tests.

You should add in your include/config.h
#define DUMP_LOG
#define DUMPMSGS 20
to activate all the features of the dump patch and to define the number of latest messages to print in the dump file. (They are included in this diff, but you may have other changes in the file that prevent the patch utility from automatically adding them.)
To activate the showborn patch, add
#define SHOW_BORN

Authors: Tom Friedetzky, Jukka Lahtinen, Darshan Shaligram
Download: dump-360.diff    (74 KB)
Affected files: include/decl.h, include/extern.h, include/flag.h, src/botl.c, src/cmd.c, src/decl.c, src/display.c, src/dungeon.c, src/end.c, src/hacklib.c, src/invent.c src/options.c, src/pline.c, src/spell.c, src/topten.c, src/weapon.c, win/tty/wintty.c, util/makedefs.c, dat/opthelp, dat/wizhelp, doc/Guidebook.*
Bones / save files: NOT affected.

Showborn (3.6.0 version 28.12.20115)

The "showborn" patch will optionally add the number of each monster species created after the number of them killed, if the number is different. No born counter is shown for species with no killed individuals, or for those species with all born individuals killed.
It also adds the wizard mode extended command #showkills that lets you see the kill counters of each monster race as you see them when the game ends.

Notice that the counter of monsters born does NOT count creatures that were not created in that particular game, but loaded from a bones file. Also, when some monster gets polymorphed or "grows up", it affects the born counter of the monster type it was created as, not the type it was killed as. These differences make it possible for the kill count of some monster type to be higher than the born count.

The showborn patch is now also included in the dump patch.

Download and apply the patch and add the definition
#define SHOW_EXTINCT
#define SHOW_BORN
somewhere in your include/config.h to compile the features in.
You also need to turn the "showborn" option on to actually show the born counters. Use the 'O' option in the game or edit your configuration file.

Authors:  Wingnut, Jukka Lahtinen
Download: showborn-360.diff (7.6 KB) if you don't have and don't want to install the dump patch. Notice that the dump patch can't be installed automatically with the patch utility after this.
Affected files: include/flag.h, src/cmd.c, src/end.c, src/options.c, dat/opthelp, dat/wizhelp, doc/Guidebook.*
Bones / save files: NOT affected.

Record the number of moves (3.6.0-checked 28.12.2015)

The "logmoves" patch will make the game append the number of moves in curly braces at the end of the record and logfile entries, so you can see how many moves the game took. It also appends a "{wiz}" or "{exp}" tag if the game was played in wizard or explore mode. The game will treat it as addition to the text string telling what killed you (or why the game otherwise ended), so the patch will NOT invalidate your existing record and logfile, not even existing bones and save files! (Keeping the existing files was the reason why I put the additional information where it is.)
Apply the patch and add
#define LOG_MOVES
somewhere in include/config.h

Author: Jukka Lahtinen
Download: logmoves-360.diff (1.5 KB)
Affected file: src/topten.c
Bones / save files: NOT affected.

Even older stuff: 3.4.3 Patches

These patches have been used with 3.4.3 but not checked for compatibility or relevance with 3.6.0.

Patches for all platforms

A combination of my 3.4.3 patches (updated 2.2.2014)

This is a monolithic diff that includes all the patches I used with 3.4.3.

Authors: several.. patches collected together by Jukka Lahtinen
Download: nh343jl.diff (199 KB)

Color Hp monitor (updated 16.7.2003)

This patch colors the Hp monitor at the status line with the tty interface. If your Hp is lower than maxhp but more than 2/3 of max, it is shown green. If it is less than that, but more than 1/3 of max, it is yellow. If it is less than 1/3 of max, the color is red. And with values less than 1/10 of max, it is highlighted, blinking or whatever your screen shows with the ATR_BLINK attribute.

#define HPMON in include/config.h to activate the patch.

Author: Ralph Churchill
Download: hpmon.diff (2 KB)
Affected file: src/botl.c
Bones / save files: NOT affected.

No quitters in record file! (3.4.3-checked 13.12.2003)

With this patch you can prevent quit games from getting in to your record file. However, they will be logged to the logfile. You may also choose not to have wizard and explore mode games logged in the logfile.

#define FORGET_QUITTER in include/config.h or to keep quitters out of the record file and
#define PROMPT_LOGEXP to be prompted about logging wizard and explore mode games.

Author: Jukka Lahtinen
Download: forgetquit.diff
Affected file: src/end.c, src/topten.c
Bones / save files: NOT affected.

Explore mode at death (3.4.3-updated 13.12.2003)

Do you often wish that when your character dies, you would have an option to continue the game in explore mode to peek what MIGHT have happened?
This patch will prompt you for going to explore mode, if you die and no bones file is created. If you answer yes, it will first update the logfile, and possibly the record file (after all, it was a fair game until that point), and after that it switches the game to explore mode.
Since I feel that continuing when a bones file was generated would not be a good idea (many people would consider it cheating, because you may get information of that level and monsters that were there, that you did not know when you died), I decided that it will not be allowed.
Calculating your score before switching to explore mode requires, in some situations, some actions that are not COMPLETELY undone in the diff, like paying your debt to shopkeepers, so the switch might not always happen exactly the same way it does when you use the X command before getting the final blow. But I did it as close as I could.

NOTICE: If you have installed the version 1.0 of the dump patch, you should edit src/end.c slightly before installing this patch: Go to the done(how) function, find the label "die:" and move the line "program_state.something_worth_saving = 0;" and the comment above it to above the #ifdef DUMP_LOG block that grabs the screen dump. (Or back out the dump patch and reinstall the current version, if you prefer doing that.) I changed that to the version 1.1 of the dump patch, but the first version was downloadable for a while, so it is possible that you may have installed it.

Apply the patch, add
#define DEATH_EXPLORE
in include/config.h and compile. Then, add
OPTIONS=death_explore
in your configuration file, and upon death you are prompted for going on in explore mode.

Author: Jukka Lahtinen
Download: dthexp-343.diff (7.5 KB) if you don't have other patches and don't intend to install the dump and paranoid patches. Notice that installing those patches after that will take some manual work.
  dthexp-343d.diff (7.5 KB) if you have the dump and paranoid patches installed
Affected files: include/flag.h, src/cmd.c, src/end.c, src/options.c, dat/opthelp, doc/Guidebook.*
Bones / save files: NOT affected.

Window edge (located elsewhere)

This patch adds a new configuration option 'win_edge' that allows you to define whether the menu and text-windows in TTY mode are left or right aligned.

Author: Pasi Kallinen
Download: http://bilious.alt.org/~paxed/nethack/nh343-winedge.diff
Affected files: include/flag.h, src/options.c, win/tty/wintty.c
Bones / save files: NOT affected.

Item categories (located elsewhere)

This patch adds item categories I (unidentified), r (known to be rustprone) and P (just picked up) to menus so you can quickly drop them.

You need to #define ITEMCAT (for categories I and r) and ITEMCAT_JP (for category P) to compile the patch in and turn on the added option like_swimming for category r to be shown.

Author: Stanislav Traykov
Download: http://nh.gmuf.com/#itemcat
Affected files: dat/opthelp, doc/Guidebook.*, include/extern.h, include/flag.h, include/hack.h, include/objclass.h, include/obj.h, src/do.c, src/invent.c, src/options.c, src/pickup.c,
Bones / save files: NOT affected.

Credit cloning (3.4.3-updated 19.7.2004)

(NOT included in nh343jl.diff)

This patch will prevent credit cloning.

Gold on shop floors are free and one does not get credit by dropping gold in a shop. Credit is bought from a shopkeeper by (p)aying when you don't owe anything. If you already have credit in a shop and try to pay when you don't owe anything you are asked if you want your credit money back. If you don't want then you are asked if you want to buy more credit.

Author: Topi Linkala (nes@iki.fi)
Download: shop_credit.diff
Affected files: include/config.h, include/extern.h, src/dokick.c, src/pickup.c, src/shk.c
Bones / save files: NOT affected.

Aoy_container (3.4.3-updated 19.7.2004)

(NOT included in nh343jl.diff)

This patch allows the insertion of Amulet of Yendor, Candelabrum of Invocation, Bell of Opening and Book of Dead into a container. It also prevents naming these items.

Naming of Amulet of Yendor or unknown fake is a major insult against your original god and minor insult if your god is not the original one. Naming of known fake Amulets are permitted.

If you carry a container containg one of those items or your Quest Artifact everything should work as if they were in your inventory, except you wont get the benefits from your Quest Artifact.

When a monster has in its inventory a container containing one of those five items and has nothing better to do, then it will take the most valued item out of that container and if that container contains no other valued items drop it.

Pet won't pick up a container that contains the Amulet of Yendor.

Author: Topi Linkala (nes@iki.fi)
Download: aoycont.diff (the patch itself)
aoycont.txt (technical information)
Affected files: include/dungeon.h, include/extern.h, include/hack.h, src/apply.c, src/bones.c, src/dig.c, src/do.c, src/do_name.c, src/dogmove.c, src/dokick.c, src/dothrow.c, src/end.c, src/fountain.c, src/invent.c, src/lock.c, src/makemon.c, src/mklev.c, src/mkobj.c, src/monmove.c, src/mthrowu.c, src/objnam.c, src/pickup.c, src/potion.c, src/pray.c, src/rumors.c, src/shk.c, src/sp_lev.c, src/spell.c, src/steal.c, src/timeout.c, src/trap.c, src/uhitm.c, src/wizard.c, src/write.c, src/zap.c
Bones / save files: Bones not affected. Save files from an unpatched game work with the patch, but games saved with a patched version will cause confusion if loaded to an unpatched game if the Amulet or some of the invocation items is in a container. So take them out before saving if you plan to continue without this patch.

Owned artifacts (updated 5.11.2012)

(Not included in nh343jl.diff)

This patch enables owned artifacts. If you wish for an artifact there is a chance that the owner of that artifact arrives with the artifact and starts to fight with you. Have fun.

Author: Topi Linkala (nes@iki.fi)
Download: ownedarti.diff
Affected files: include/config.h, src/mplayer.c, src/objnam.c
Bones / save files: NOT affected.

Platform-dependent patches

Bones directory

Unmodified Nethack 3.4.3 supports a separate bones directory on some platforms, but not on some others. The necessary changes to add the support depends on which platform you use.

Single-user systems and others with a common config file (3.4.3-checked 13.12.2003)

The official NT binary version shows a list of variable playground locations with the O command, with directories defined in the config file. But the OS/2 and msdos versions compiled from the official sources without changes do NOT show them or use the directory settings from the config file. So I just examined how files.c determines whether the locations list is shown or not, and what are the relevant differencies between include/os2conf.h and include/ntconf.h.

I didn't extract a diff for this, instead I just explain what to edit to do this:
Depending on your platform, add these lines to os2conf.h, pcconf.h or whatever is the right *conf.h in the include directory:

#define NOCWD_ASSUMPTIONS
#define PC_LOCKING
#define HLOCK "NHPERM"
On OS/2, maybe also on some other non-microsoft version, you'll probably also have to edit sys/share/pcunix.c. Change the lines 11 and 15 from
#if defined(WIN32) || defined(MSDOS)
to
#if defined(WIN32) || defined(MSDOS) || defined(PC_LOCKING)
I have successfully used this in OS/2 with Nethack from 3.3.1 to 3.4.3 and Philipp Lucas tested it with at least 3.3.1 in msdos, and I suppose it also works for most others like that.
Affected files: include/*conf.h, sys/share/pcunix.c
Bones / save files: NOT affected. But remember to move the bones files when necessary.
Unix-like systems (3.4.3-checked 19.12.2003)

The Unix version has directory names hardcoded for security reasons and to prevent cheating by users without root privileges, and they can't be changed by the config file settings. This patch will make bones to be read and written in a "bones" subdirectory under the directory where you have the level lock files and the save subdirectory. (Either the playground directory or some other directory that you have defined as VARDIR.)
After applying the patch, make sure there is a subdirectory "bones" in the same directory as the "save" directory, and with the same user, group and permissions. The diff changes sys/unix/Makefile.top to do this with the install target, but I know that many people will not copy their makefiles from sys/unix again (after configuring it to their needs once), and many people don't make the install target again..

Author: Jukka Lahtinen
Download: bonesdir.diff
Affected files: src/files.c, sys/unix/Makefile.top
Bones / save files: NOT affected. But remember to make sure the bones directory exists with the right permissions and move the bones there.

Linux-specific stuff

The alt key with Linux (3.4.3-checked 18.12.2003)

To get the alt key working on Linux console the same way as it does in the msdos, os2 and win32s versions, you don't need to even recompile the game, just edit your /usr/games/nethack (it's a shell script that starts the actual game).
Note: this works for the text consoles, but don't expect it to do anything useful in xterm or other X11 command windows. The conditionals for the TERM environment are meant to check that you are really on a console, not in an xterm or some other X window. If you see something else instead of "linux" when you use the command echo $TERM , change the condition accordingly.

Near the end you will find a line
		exec $HACK "$@" $MAXNROFPLAYERS
Add these setmetamode commands around it and remove the exec keyword:
#		Alt-key as 'meta'
		if [ "$TERM" == "linux" ]
		    then setmetamode meta > /dev/null
		fi
		$HACK "$@" $MAXNROFPLAYERS
#		Change alt key back
		if [ "$TERM" == "linux" ]
		    then setmetamode esc > /dev/null
		fi

Before editing the actual file, you may like to try these commands from the command line before and after playing, without the /dev/null redirction, to make sure they work on your system. I have successfully used it with Redhat Linux versions from 4.1 to 9.0 and Fedora 1-10, kernels up to 2.6.27, but I can't guarantee it to work for everybody.
The script comes from sys/unix/nethack.sh in the source tree, so if you compiled your game yourself, you'll probably want to make the same change there to avoid the need to do it again after the next compilation(s).

Author: Jukka Lahtinen
Affected file: sys/unix/nethack.sh (/usr/games/nethack)
Bones / save files: NOT affected.

Separate configurations for console and X11 (edited 19.12.2003)

Do you want to play the game both on console and X11? And use the windowtype:x11 when you play on X11, and possibly other different settings, but don't like always editing your .nethackrc in between?
This is another little thing that you can do without recompiling the game, just editing the /usr/games/nethack script, like the alt key fix. Load the script (/usr/games/nethack) in your favorite text editor, and add these lines somewhere to be executed before the actual game starts:
if [ -n "$DISPLAY"  -a  -f $HOME/.nethackrc.x11 ] ; then
     NETHACKOPTIONS=$HOME/.nethackrc.x11
fi
And copy your .nethackrc as .nethackrc.x11 (in your home directory). Then, whenever you start the script from xterm, it will use .nethackrc.x11 as the configuration file if it exists, otherwise it will use .nethackrc as before. If you use an icon in X11 to start the game, you will probably need to check the "Run in terminal" box in the launcher properties. If you compile the game again, the script is overwritten, so you'll probably want to add the same lines to sys/unix/nethack.sh in the source tree.
Another option is to leave the /usr/games/nethack script as it is, and just add a wrapper script that sets NETHACKOPTIONS and calls the original script. I actually had done it that way before trying to set it conditionally in the normal starting script. This is how my /usr/games/nhx script looks like:
#!/bin/sh
if [ -n "$DISPLAY"  -a  -f $HOME/.nethackrc.x11 ] ; then
    NETHACKOPTIONS=$HOME/.nethackrc.x11
fi
exec nethack "$@"
So, if I want to play with the x11 options, I start the game with 'nhx' instead of 'nethack'. And I have configured my Nethack icon to start with /usr/games/nhx too.

Old stuff no more documented on this page

The sortloot, paranoid, message type, helplessness reasons, menucolor, splittable #adjust patches are obsolete for 3.6.0, because now their functionality has been included in the official version.


Valid HTML 4.0! (validation)

This page is viewable With Any Browser