gAction Tracing

Here’s a nice little puzzle. At what point in the command execution cycle (and yes, I looked in that article in the Tech Manual, and it doesn’t seem to have this information) is gAction reset to nil?

It seems to happen before daemons are run. I’m attempting to bypass the running of a daemon when gActionIn(AskAbout, TellAbout) … and it doesn’t work. That test always returns false, so the daemon runs anyhow. I can only conclude that at some point gAction is being reset to nil.

I’ve been able to kludge around it by setting a flag in the afterAction for the me object and then testing the value of the flag in the code for the daemon, but that’s a bit messy. Is the value of the most recent action stored anywhere even after gAction is reset to nil?

I don’t know the exact point at which gAction is set to nil, but I’m pretty sure you’re right that it’s before any daemoms are run. I also don’t know of anywhere where the last action is stored as standard. In my current WIP I do roughly what you’ve tried, namely add a lastAction property to the me object and then modify Action thus:

modify Action
        if(gActor == me && !isImplicit && !ofKind(SystemAction))
            me.lastAction = self;

You may or may not want to include the check for excluding the storing of implicit actions depending what you want to use the stored information for.

Storing the complete action in this way (rather than just setting a flag) allows you to get at the complete set of details about the immediate past action (I’m using it in connection with a series of ExtraHints, of the kind we put in Mrs Pepper’s Nasty Secret), for which purpose I also defined a number of convenient macros:

Hopefully there’s something here you can adapt for your own use.

– Eric

Thanks, Eric. That’s much more thorough, and may prove to have other uses as my game develops. All I’m needing to do at the moment is check for AskAbout and TellAbout.

I’m using your Scenes.t extension (and by the way, you didn’t put a byline in the code comments … such modesty!) rather than an AgendaItem. An AgendaItem will pause if the NPC is in conversation, but a daemon won’t. Hence the need to check for those actions.