A companion character
Some experiences are built around one relationship rather than an adventure: a friend who travels with the player, a mentor they check in with, a rival they can’t stop arguing with. This recipe uses conversations as the heart of the experience and lets the story move along around them.
The pieces:
- The player’s character is the story’s lead.
- The companion is a second character in the same world instance, brought into each story as supporting cast.
- Conversations are where the player and companion talk. Ending one applies its effects, including changes to their relationship.
- The world instance remembers the relationship, so the next story starts where the last one left off.
1. Create the player’s character and the companion
Section titled “1. Create the player’s character and the companion”In an instance you’ve already created, create two characters. The brief is a good place to describe who the companion is to the player:
curl --request POST "https://api.hiddendoor.co/experience/v1/instances/$INSTANCE_ID/characters" \ -H "Authorization: Bearer $HD_API_KEY" \ -H 'Content-Type: application/json' \ --data '{ "name": "Brindle", "highConcept": "A talking badger who complains about everything and follows Mallow anyway", "brief": "Has known Mallow for years. Grumbles, gives good advice, and never admits to worrying." }'Keep each entity.id. In this recipe, Mallow (79a3af39-c171-4dfb-b51b-5a684f61525d) is the lead and Brindle (c1a8dd94-21d2-4b9c-a417-ed5cb1325cda) is the companion.
2. Bring the companion into each story
Section titled “2. Bring the companion into each story”When you generate story options, put the companion in the supporting cast, and use playerIdea to point the story at the relationship:
{ "setup": { "playerCharacterId": "79a3af39-c171-4dfb-b51b-5a684f61525d", "entityIds": ["c1a8dd94-21d2-4b9c-a417-ed5cb1325cda"], "modifierNames": [] }, "playerIdea": "A quiet day at the workshop turns into an argument about whether to help a stranger."}Start one of the returned options with the same setup.
3. Talk whenever the companion is there
Section titled “3. Talk whenever the companion is there”When the player wants to talk, open a conversation with the companion. openingIntent sets up what the conversation is about:
curl --request POST \ "https://api.hiddendoor.co/experience/v1/instances/$INSTANCE_ID/stories/$STORY_ID/conversations" \ -H "Authorization: Bearer $HD_API_KEY" \ -H 'Content-Type: application/json' \ --data '{ "target": { "mode": "character", "entityId": "c1a8dd94-21d2-4b9c-a417-ed5cb1325cda", "openingIntent": "Ask Brindle why they really came along" } }'Send the player’s lines as messages, and offer the returned suggestions if the player is stuck. When windingDown turns true, let the conversation come to a natural close; when resolved is true, end it. The response’s events show what the conversation changed, such as an UPDATE_RELATIONSHIP event.
Two story rules shape the rhythm:
- The companion has to be present and able to talk. Check the story and entity state before offering a conversation, or look for an action suggestion with
talkToEntityIdset to the companion. - Each character can be spoken to once per turn. Between conversations, let the story move on with a story action, which can be as small as “Walk with Brindle to the edge of the village”.
4. Carry the relationship forward
Section titled “4. Carry the relationship forward”When the story ends, complete it. The companion already belonged to the instance, so it’s kept automatically. Read the companion’s entity to see where things stand: sourceRelationships and targetRelationships hold its relationships with other characters, each with a type and a description.
Start the next story with the same lead and companion, and with the finished story as contextStoryId, so it picks up from what happened between them.