adv3Lite: When AgendaItems Happen

I have an NPC with an AgendaItem. She’s following the player around like a little puppy-dog, and this AgendaItem is set to fire the first time she sees a specific object. Unfortunately, it’s firing on the turn AFTER she sees the object. If the player immediately travels through the location where the object is visible, immediately arriving in another location, the NPC will appear to be reacting to something in the room that they’ve just left.

This is very bad. I need the AgendaItem to fire in the same turn when she can see the object.

I expect I can manage it by getting rid of the AgendaItem entirely and turning the needed text and code into a roomAfterAction or something. But the whole purpose of AgendaItems, from a design standpoint, is that one shouldn’t have to scatter the NPC’s agenda items all over the place. They should be found in a nice tidy block of code.

So my question is, is there a way to set up an AgendaItem so that it fires THIS turn rather than NEXT turn?

I don’t have time to look at this in depth right now, but your problem rings a bell in that (a) I think I’ve seem something like it before and (b) I suspect you’d get the same problem in adv3. The problem arises because things (I mean the cycle of events at the end of a turn) have to happen in some particular order, and there will inevitably be some cases where that order doesn’t do what a game author wants. I don’t this is soluble by changing the order of events since that would simply create other problem cases that didn’t suit the new order.

But, off the top of my head, I think there is a solution in game code you could try, and that’s to add the following to the definition of the ActorState your sidekick NPC is in while she’s following the PC around:

   arrivingTurn() { getActor.executeAgenda(); }

Let me know if that fixes your problem before I try looking at anything else.

I think that will work. This NPC has a few other AgendaItems, so I may find undesired side effects later, but for now that seems to work.