Does a Topic know which Actor is the one who asked?

If I’m inside a Topic I can use the term “getActor()” to refer to the actor who is the one responding to the request, like so:

Let’s say there’s a dealer in a cardgame. This dealer responds to the command “ask dealer for card” with the following in its Topic code:

My problem is that while I can find a way to refer to the askee, I can’t refer to the asker. There seems to be no equivalent to the “getActor()” construct that means “getActorWhoTalkedToMe()”.

I considered using gActor, but I very strongly suspect that by the time this code runs, the asker’s turn is over and gActor is now the NPC.

I could just hardcode it to be the player, but then I can’t have an NPC issue the “ask dealer for card” command and have it work, meaning I can’t implement a blackjack table at which you join other NPC players, and all of you can ask the dealer for a card.

gActor should work for this - it’s set to the actor performing the current command. Actions don’t use up an NPC’s turn; action handling runs separately from turn taking.

So when person A asks person B about a topic, person B gives the response while it’s still person A’s turn regardless of whether person A is the player or an NPC? Is that what you’re saying?

Or are you saying that there’s no such thing as an NPC’s turn at all. That only the player’s actions are a “turn”?

Imagine three actors around the table:
actor 1 - the dealer.
actor 2 - an NPC player.
actor 3 - you, the human player.

When you (actor 3) issue the command “ask dealer about hit” or “ask dealer for card”, gActor() will be you even during the dealer’s Topic response.

But when the NPC player (actor 2) issues the same command, will gActor() still be pointing at you instead of at actor 2? (Because NPCs don’t get their own turns and all the actions they ever issue are always issued on YOUR turn).

It sort of matters for how I try to design this.

Method 1 - Implement a command to “hit me” that works independently of the conversation system, bypassing the topic/response system altogether. NPC players call the command directly instead of talking to the dealer. The player can access the command directly too, or can use an ask/topic response that executes that code when the player asks the dealer for a card.

Method 1 is what I have to do if NPCs don’t get their own turns and therefore gActor() will never be an NPC so NPC actors can’t really talk to other actors and have the responses work right.

Method 2 - The “hit me” code is only triggered by the ask/topic system. NPC actors and the player both trigger the code the same way, by asking the dealer for the hit.

Method 2 is cleaner, I think, but may be ultimately impossible.

Method 2 is more or less the default.

Actors have a takeTurn() method that gives them a chance to act on their own. You can control whether this turn comes before or after the player’s turn, though I forget exactly how. During a given entity’s turn, whether PC or NPC, if that entity initiates an action, it will be the gActor.

For players the action gets created by processing text input. For NPCs it happens as a result of newActorAction() or nestedActorAction(), perhaps invoked during takeTurn(). (More About Actions has some notes on this.)

Actors can be involved in another character’s actions without losing their turn. Making it so they act only if they haven’t reacted or responded to another actor is possible, but requires a bit more work.

Thanks for the response. It’s most helpful.