Overboard! has a bunch of systems running underneath it; but it makes a lot of use of ink patterns. A good pattern can let you quickly write up an interactive scene with a particular kind of flow to it, without having to design from scratch each time!
This post is about handling dynamic conversations.
Say you approach a game character - in this case, the scheming, vicious Lady Armstrong. You want to engage them in conversation, but each player might have different ideas about what kind of conversation they want to have.
How do we ensure the game keeps offering interesting and useful options, without turning Lady H into a vending machine, and while keeping the scene varied in pace?
We use a pattern here we call a conversation distributor.
It's a system which divides up options into different categories, and then attempts to spread them out, and to interleave them with physical actions (including "walking away"), so the player always has an interesting choice to make, despite the content itself being very dynamic.
Here's a playable ink source for the conversation between Lady Armstrong and the player over drinks in the restaurant in Overboard! The file is a stripped-down version of the one in game (if you've played the game, you'll know there's something else you can be doing during this scene!) but it demonstrates the structure. You can download that file and play directly in inky.
So how does it work?
The heart of the distributor is the core action hub. This uses threads to insert a block of choices in order of priority. First: reactions to the last thing said, secondly: physical actions in the world; thirdly, conversation gambits; lastly, fallback choices which ensure the player doesn't run out of actions.
Each of these threads then has its own logic to ensure it offers the right choices, and only the right number. In particular, we ensure each block (other than the reaction block) can only offer one choice.
After each action/conversation has been run, the flow loops back to an "NPC's turn" block.
This offers ways for the NPC to initiate conversations of their own, and react to what's just been said, and to fill in gaps if there's a pause in conversation.
These use the default option system, to pick the first line that's valid in the current context.
The "npc turn" block also allows other things to happen (like the steward bringing a drink, or in the full version in Overboard!, to check if the end of the game should be occurring).
So the game trades between "my turn" and "your turn", looking to keep the conversation going (using reactions), or pausing it if you've done a lot of talking (the "chattiness" variable controls this).
And best of all, because the main code is a distributor, the actual content is written in "buckets". So if you need to add a new line, you just put it into the appropriate bucket, and the code will pick it up and use it, with no additional wiring required!
(By the way, Overboard! is now out on itch.io if that's your thing.)