What Action Is This? (adv3lite)

Here’s a tricky one. I need to know if the current action is the player giving an order to an NPC. Unfortunately, that doesn’t seem to be an action. When I use ‘debug actions’ and type ‘joe, go north’, no action is listed. Not even when it’s an order that the NPC has a CommandTopic for and is willing to carry out. And indeed, scrolling through the list of Actions in the LRM doesn’t reveal any obvious candidate.

I need to know this because if the player’s action is not this (or one or two other things, such as Examine), I need to use afterAction() to turn off a Fuse. If the player’s command is, for instance, ‘joe, pick up the tennis ball’, I need to know it. But it doesn’t matter what the actual commanded action is – the player could try instructing Joe to do any number of things – ‘joe, jump’, ‘joe, undress’ – I don’t care. Any of those actions should NOT turn off the fuse, so knowing what particular action Joe was commanded to undertake won’t help. I need to know what the PC’s action was in giving the order, so that afterAction() can be coded accordingly.

When you give an order to an NPC the library bypasses the normal action handling, so there isn’t any current action which means giving an order to an NPC.

However, you can fake it (or make it happen) with the following code:

CommandAction: Action
    actionCommanded = nil
    actorCommanded = nil

modify Actor
        gAction = CommandAction;
        gAction.actionCommanded = action;
        gAction.actorCommanded = self;

This would then let you test for gActionIs(CommandAction) in your afterAction() method to see if the player had given an order to an NPC. You could also look at gAction.actorCommanded at this point to check which NPC the order had been given to. Note, however, that gAction wouldn’t take on these values while the NPC was obeying or refusing the command; they’d only become available at the afterAction() stage.