Varying interaction responses

Adventure games involve heavy use of Interactions, which are run when the player clicks on a Hotspot. If the player clicks repeatedly on a Hotspot, we may wish for the response to vary each time.

A well-known example of this occurs in Sam & Max Hit the Road, whereby the first response to picking up a non-grabbable item is "I can't pick that up.". Further attempts to do so cause Sam to respond with "No really, I can't pick that up!", and ever-more desparate pleas to ignore the item.

We can recreate this behaviour in AC. Let's start with a typical Hotspot that already has an Interaction defined. For help on getting started with Hotspots and Interactions, see this tutorial.

Our Hotspot's Use Interaction contains a single Dialogue: Play speech Action:

In order for repeated clicks to issue a different response, we're going to want to play a different speech Action each time. To do this, we can use the Variable: Run sequence Action. This Action can be given any number of output sockets, and it will redirect the ActionList flow to a different socket each time it's run.

We can create a new Variable: Run sequence Action by right-clicking in empty space inside the ActionList Editor, and choosing Add new Action. Change its type to Variable: Run sequence, and then click its cog menu (in the top-right corner) and choose Move to front:

Click Auto-arrange in the ActionList Editor's top toolbar to move the speech Action out of the way, and we can now get a good look at the Variable: Run sequence Action, which is now the ActionList's first Action:

We'll make our Interaction have three different possible responses from the Player character, so set the # of possible values field to 3. For now, uncheck Save sequence value?, and you'll see that the Action now has three output sockets:

Create two more Dialogue: Play speech Actions - which will be played when the Interaction is run repeatedly - and redirect the Variable: Run sequence Action's outputs to run our three speech Actions:

Run the scene and test things out by clicking the Hotspot multiple times. For the first three times, the Player will say something different. For four or more times, the Player will repeat their last phrase - in the example above, "Are you listening? I told you I can't pick that up!".

If we wish, we can have these responses run on a loop - so that the fourth click causes the responses to start over with the first line again. To do this, check Run on a loop? in the Variable: Run sequence Action.

Now let's make so that the state of these responses are stored in save game data. Otherwise, the Player can leave and re-enter the scene, click the Hotspot, and be given the first response again.

To do this, re-check the Save sequence value? option. We'll then need to assign an Integer variable that will be used to store the record of which response was last given.

This variable can come from anywhere, but here we'll make use of a Local variable. If you're working with an ActionList asset instead of a scene-based Interaction, though, use a Global variable instead, so that it's not scene-dependent.

Either way, set the Action's new Variable source field accordingly - here, we're setting it to Local.

We now need to assign an Integer variable to store the data in. While we could now go to the Variables Manager to create one, it's easier to have AC automatically create one for us. To do this, click the cog icon just underneath the Variable source field, and then choose Auto-create new Local variable:

This will bring up a new window where we can name the Variable before creating it. Give it an appropriate name, and click Create variable.

This variable will now be assigned in the Action, as well as listed in the Variables Manager:

With this variable assigned, the state of the sequence will now be stored in save data.