i’m using GamePreRoutine() to do some global ‘before’ processing (i need to disable some NPC interactions under certain conditions). but NPC command actions (i.e. “john, take the book”) completely bypass GamePreRoutine().
i’ve noticed that even when turning on the debug command ‘actions’, NPC commands are completely ignored as well.
where can i interdict an NPC command before it’s been processed?
It’s the same as the Inform 6 standard library, so you’ll find it documented in the DM4, specifically section 18.
You need to create an orders routine and, within that routine, add action handlers for any action that you want the NPC to handle, the same as you would for before, after and life routines.
Here’s a slightly more complicated example than the one in the DM4. The first test is needed if you have multiple actors, otherwise, you can ignore it.
orders
[;
if (player == self)
rfalse;
Drop:
print (name)self;
if (noun notin self)
" doesn't have ", (the)noun, ".";
move noun to location;
" drops ", (the)noun, ".";
Take:
print (name)self;
if (noun in self)
" already has ", (the)noun, ".";
if (noun has scenery or static)
" says, ~You must be freakin' kidding.~";
move noun to self;
" takes ", (the)noun, ".";
NotUnderstood:
print_ret (name)self, " says, ~What are you talking about?~";
],
The above code is from a work in progress and hasn’t been extensively tested, although it seems to work as intended.
Under normal circumstances, you shouldn’t need to use GamePreRoutine(), though your circumstances might not be “normal”.
yes, i can do this on a per-NPC basis. but i was asking if there’s a global way to ‘catch’ these actions sooner. it just seems odd that NPC commands seem to bypass GamePreRoutine() entirely.
PunyInform (and Inform 6) first calls the player’s ‘order’ routine (if any), where you can disallow certain actions by returning true. If the player’s ‘order’ routine doesn’t stop NPC commands, then the NPC’s ‘order’ routine is called. Note that the legacy ‘life’ property (described in DM4) is also supported, but it is better to use the new ‘order’ routines.