Action hooks

Movement hooks

Character hooks

Combat hooks

Monster hooks

Object hooks

Trap hooks

God hooks

Quest hooks

Building hooks

Wilderness hooks

Chatter

BucketMan: This is useful! Thank you. Any chance we could include the variable names passed to the hook functions as well?

NerdanelVampire: I didn't know hooks had that property... I'm going to visit my parents now, but I'll look into the variable thing.

NerdanelVampire: I looked into it, and it looks like variable names are not passed, but rather their order. For example, you could call the boolean variable you can call through GAME_START new, new_game (which appears to be its "true name"), or i_like_ponies and it would all work the same. Also, since this is C, you should be able to call any number of variables up to the hook total, but if you are only interested in the variable #3 you must first mention variables #1 and #2 even if you aren't going to use them because otherwise things will get messed up.

ShrikeDeCil: I'd be more interested in knowing the number & type of the variables - not their names. (And that's what I took BucketMan to be asking about really). IOW, these are a sort of 'function', and knowing that HOOK_HARDCODED_MAX is going to have one unsigned int passed (is it? I don't know where to look!) is the goal. Sure, I can _call_ it i_like_ponies, but there are always places where you get a string when you were expecting an int, or an int instead of a boolean. Or the HOOK passes two - the first being the boolean, and the second being a count. Or something. Where are you finding the hook definitions anyway?

NerdanelVampire: Go to the source directory and do (if you're on a sensible operating system):

grep -A1 process_hooks\(HOOK *

I love grep.

One example from among the snippets that appear:

cmd1.c: if (process_hooks(HOOK_MOVE_PRE, "(d,d,d,d,d,d)", y, x, tmp + 1, 
cmd1.c-                                   do_pickup, run, disarm))

I have figured out that "d" is double and "s" is short. "O" appears when there are pointers. But when there are things like "tmp + 1", I have no idea what that's supposed to be about.

Unlike a strongly typed language like C++, C is lax about types, and lua isn't typed at all. I can't say I particularly like that.

DarkGod: d=number, s=string, O=object, M=monster. As for C it's as typed as C++ IIRC, and lua is typed, but it's the values that are typed not the variables

AnonymousHero: Just a nitpick: C++ is more strongly typed than C. (There is actually some valid C code which cannot compiled without changes using a C++ compiler.)

ShrikeDeCil: Added what I could gather from Nerandel's trick with grep above to the text. That included two more hooks -

Several of the hooks seem to be accessed in several different ways?

EtMarc: There are also a bunch of hooks who are processed by process_hooks_ret() instead. They return some value.

Module Developers Discussion/Module Writing How-To Guides/The grand list of hooks (last edited 2008-03-02 17:19:05 by EtMarc)