Hacking the nethack wand of wishing

I admit it, I'm a geek. I love video games. However, as much as I love modern video games, the old UNIX style character mode games will always hold a special place in my heart. These games lacked sound and graphics ... but made up for it with outstanding gameplay.

One of my all time favorites is NETHACK and its derivatives.

In this game, you play a dungeon adventurer that goes deep into a dungeon to retrieve an artifact (the Amulet of Yendor) for your GOD. It's vaguely similar to an excellent game from Atari called GAUNTLET.

One of the items in the game is called a "wand of wishing." If you zap this wand, and assuming you have decent luck, you're granted a wish of some item. The wand in invaluable in that it allows you to basically solve issues you may have in the games. (e.g. if you cannot cross a large body of water, simply wish for an amulet of flying). The wand comes changed with 1-3 "zaps" with each zap giving you a wish. Once the charges are exhausted, the wand is useless.

There's also another item in the game called a "Scroll of Charging". which as you might expect allows you to "recharge" some item in your inventory, including the wand of wishing.

With this, one could theoretically get infinite wishes as you could wish for scrolls of charging, then charge the wand of wishing, then wish for more scrolls of charging.

To prevent this. The devs added additional logic on the wand of wishing to only allow it to be charged one. Additional charges would cause it to explode..

I never liked this, and found that disabling this code to cause the wand to explode was, in fact, quite easy.

With that, if you are curious, here's the code modification to allow wands of wishing to be charged more than once in NETHACK/SLASHEN and it's derivatives.

I tested this mod on Slashem-0.0.7E7F3 but it should work on all derivatives.

Download the source code (You must download the source. Getting precompiled binaries won't work):

You can get nethack source from here.: https://nethack.org/download/3.6.7/nethack-367-src.tgz

You can get the slashem source from here: https://sourceforge.net/projects/slashem/files/slashem-source/0.0.7E7F3/se007e7f3.tar.gz/download

Unpack source code, then edit file src/read.c

Goto Line 364 and find this block of code:

if (n > 0 && (obj->otyp == WAN_WISHING ||
                    (n * n * n > rn2(7*7*7)))) {        /* recharge_limit */
                Your("%s vibrates violently, and explodes!",xname(obj));
                wand_explode(obj, FALSE);
                return;
            }

Then comment out the wand_explode and return statements.

if (n > 0 && (obj->otyp == WAN_WISHING ||
                    (n * n * n > rn2(7*7*7)))) {        /* recharge_limit */
               Your("%s vibrates violently, and explodes!",xname(obj));
                 /* wand_explode(obj, FALSE);
                return; */

            }

Then recomplile. You can now enjoy infinite wishes...