Ravi Mohan's Blog

Thursday, September 29, 2005

SourceDiving into Nethack

Manoj's recent post woke sleeping demons and they compelled me to fiddle with nethack.After winning the game(ascending in nethackspeak) a year ago, I forced myself to leave the best game in the world aside and get on with life.

This time though I wanted to hack the game a bit.So I downloaded the source version and started fiddling with it. The idea was to create a couple of new characters. For 20 year old code, the nethack source code is certainly well laid out. After years of OO coding it takes a while for the brain to adjust to C 's intricacies. The codebase has a fairly simple structure and once you wrap your head around all the #ifdefs, hacking becomes easier(though never really easy).

I've added a new dungeon(called the TWI level :-P) peopled by some new monsters. Manoj the VC throws gold around in abandon. Owen and Fiona, the Canadian Tourist Monsters attack you with blinding cameras and throw gobi manchurian at you, Rajesh the bookseller hits you with new books and steals gold from you.Naresh the Organizer randomly teleports you into several ASCI conference dungeons. And if this doesn't strike you as particularly funny, don't worry. These are all inside jokes that makes sense in my world.

Now I'm trying to add a new player class -the Ninja - combining about 70% of the Samurai's fighting skills with about 80% stealth of the Rogue with a few Monk spells. The "logic distributed all over the place" nature of C makes this difficult.If the code base was of a well factored OO design or the authors had used a language like Lisp, these changes would be trivial.(If anyone has a year or so of time to port nethack, let me know).

Having said that though , I wish "real world" software was as much fun to modify.

You will have to excuse me now. My Wizard character just ran out of spell points in the Gnomish Mines, with a horde of nasty gnomes and Giant Ants descending on him.Ravi the Wizard broke his Wand Of Light but managed to inscribe "Elbereth" on the floor and the power of that word is keeping the monsters away as the mana slowly builds up. However there is a Werewolf who just entered the Dungeon and morphed into human form Nethack Lore says such humanoids are not impressed with this protection spell.

Deep Trouble.

To add to all this there's a nymph waiting to seduce me and steal my Magic Cloak and a Floating Eye watching impassively....

3 comments:

Anonymous said...

Ravi,
Can you please create a version of Nethack with me and some of my friends from college as monsters? and a specialised dungeon? please please please :-)

Ravi said...

Sure thing. Why not? Even better, I'll teach you how to do it. Knowing your friends, this is a recipe for havoc! Still...

Anonymous said...

Well… Now there exists a real OO coded Nethack-like: Crawl. In many point of view, it’s even better than Nethack!