Monday, March 4, 2013

"oh the beauties of C type declarations"

If you can figure out what I'm referencing in the title, you win a FREE download of the original nethack-3.4.3 source code from www.nethack.org!

...

As I mentioned in a previous post, the psion role is one of the motivations for making a nethack/slashem variant in the first place; the other being, why not?  Basically, the dominate ability will allow a player (or a psion) to willfully control another monster.

When you dominate a monster, you get to control it's moves and actions for, say, 25 turns, plus or minus some random amount.  I realize this can be too powerful in many ways, like walking a tough monster into lava to get rid of it, causing a nymph to drop your precious magicbane, or potentially, having a dominated monster on the astral plane zap a wand of teleport at pestilence to get him away from you.

Anyway, I've had some page views since I shamelessly (shamefully really) plugged my blog on the nethackwiki, so I'm hoping you guys can give me some suggestions.  For example, I can't decide whether to make it a technique or a HIGH level enchant spell.  On one hand, a technique makes sense if I want to restrict it to psions.  On the other hand, do I want to restrict it to psions?  And on the third hand, in implementing the dominate power, I will allow for the possibility of dominating more than one monster at a time.  There is a problem with the third hand though; it will slow down game play... no travel, no run, etc, because you have to control each dominate monster (plus yourself) individually, each step of the way, one step at a time...

Monsters would have a chance to resist, and there'd probably have to be monsters on the no-dominate list--shopkeepers and temple priests, special quest folk--but you'd definitely get a bonus against foocubi.

I've been hacking around the already hacked to death slashem code (I'm very guilty of returning early in functions as a shortcut, but does a function really need 30 return statements?).  I'm pretty close to a functional dominate within the current slashem code, but after going through monmove.c, I decided I need to re-prioritize.

The current game engine cannot support the dominate ability (as I envision it) without gross hacks and workarounds.  Originally I figured I could steal some of the polyself.c code and use gotos in the moveloop in allmain.c; in other words, gross, gross, despicable hacks.

This is about the state it was in when I decided to re-prioritize (the cursor to the northwest is just to show that it's a selection thing.  Nothing new there.  Eventually I'm going to move the cursor over to the kitten):




And then I moved him to the left... or tried.  The kitten is actually one place to the left, but I didn't get the screen drawing/updating working before I temporarily pushed the dominate implementation to the back burner.


Since I plan on restructuring parts of the code anyway, I'm going to do restructuring in parallel with hacking around with new ideas because the current code is too rigid at present for what I want to do with it.

I plan on breaking apart some of the monolithic functions into several more modular functions. The overall goal of the restructuring is to separate the game engine from, well, everything else (items, monsters, roles, races, etc).  I want to keep the interfaces to the game engine as uniform as possible for player and monster alike.  The hope is to make it easier to add new items, monsters, roles, races, and entire systems (bards, music, anyone?) to the game.

Also, a robust interface to monster strategy could pave the way for experimenting with alternative strategies, like monster AI-based strategies, or evolving/adapting strategies.  I will make this a future blog post, because I also have ideas for in-game evolution of both monster strategy and, well, monster creation.  What do you get when you cross a yellow dragon with a silver dragon?  A gold dragon egg.

Anyway, I'm going to start with techniques because that's already a pretty self contained system. Instead of the nearly 1000 line-long switch statement, I'm going to remake the tech struct to contain a function pointer to a function that handles that particular technique's effects.  I figure function-call overhead vs. switch statement efficiency isn't going to make a difference in a turn-based, user-land game.

Besides, who doesn't like to bask in the beauties of C type declarations.

11 comments:

  1. The Orginal Source Code is already free ,
    I Really Would like The source code of Your Variant, So I Could Examine it, Playtest it ,
    Do some portpatching, Etc...

    ReplyDelete
  2. Hey, thanks, I really appreciate that.

    Do you want the hacked slashem code (slashed hackem code?) as it stands now or do you want me to post links to the restructured code in increments as I restructure it? The "brainstorming" code as it stands now isn't very intuitive... I haven't _fully_ implemented some of the new ideas, especially regarding the Psion. For example, if PSION is defined in config.h, then the monk role is the psion, but it is still listed as "monk" in the starting screen. Don't use the dominate technique because it's broken as all hell (comment out #define DOMINATE in config.h) The psychokinesis is not finished either, so you might want to comment out #define PSYCHOKINESIS in config.h. The psions intrinsics (like detect monsters, and clairvoyance at first level) are too powerful, so if you want, you can comment out #define PSION, once again, in config.h.

    I think the Kobold starting race is almost done, it replaces the orc, and, unfortunately, since I moved on to other stuff, it is treated like an orc in most cases (canibalism and sacrificing own race).

    But, the Jedi stuff is pretty much fully implemented now, though I still want to change the quest a bit (storm troopers are generated with great zeal. Too much zeal for me). Chaotic Jedi treat all lit lightsabers as bloodthirsty, like Stormbringer, so be careful.

    I'll find a way to throw a link to the source on the blog now. It may be somewhat specific to Arch Linux, but I assume everything should be okay if you run the appropriate setup.sh script... Y'know what? I'll shut up now; it sounds like you know perfectly well what you're doin'.

    ReplyDelete
  3. It doesn't seem like blogspot will let me upload files to the blog, so if you want, shoot me an email (gregory.fedynyshyn@gmail.com) and I'll send it your way.

    ReplyDelete
  4. My emails to your address keep getting bounced. Not just because of the attachment, since one of my emails just contained the diff, no executables. I'm looking into another way to get you the code.

    ReplyDelete
  5. Okay try https://docs.google.com/file/d/0B7oiSGh7Lg0lanVkUHowTUMyaUU/edit?usp=sharing

    Let me know if it doesn't work.

    ReplyDelete
    Replies
    1. i Tried Compiling IT To Play-test it And
      This Message Popped up
      tar:Exiting with failure status due to previous errors

      Delete
  6. That's a decompression error, not a compilation error, and I think google is to blame. They make sending executables (.bat files for setup on Windows machines in this case) a pain in the ass. I uploaded the source elsewhere: http://temp-share.com/show/dPf3L53tW

    On what system are you compiling? I am developing on Arch Linux so there might be certain options in config.h that could screw up compilation on your system.

    ReplyDelete
  7. I am Using Cygwin On Windows 7 pc
    I'll See If It Will Get To The Compiling With
    This Alternate Copy

    ReplyDelete
  8. Now it wont Recognize The File

    ReplyDelete
  9. I have no idea what "newmall" is. A grep of the code and header files doesn't show anything about a newmall.

    You'll need to run the appropriate setup script, which should be in sys/winnt (I _assume_. I think Win 7 is built on top of the WinNT kernel) and I guess that will take care of some of the Makefiles. I don't run windows because development is a nightmare on it, as you are experiencing.

    It's just a standard gzipped tar file. Peazip should be able to unzip it (google it, it's open source and available for windows). I just unzipped it on my own machine and it worked fine.

    ReplyDelete