Substituting text / phrases / nodes at runtime
Posted: Wed Oct 14, 2020 9:22 pm
Hi Tony,
This isn't fully thought through yet, as I wanted to check what's possible before going too far down a certain route. So please bear with me.
As part of the game I'm developing, I want to be able to provide variations in the narrative, so that the player can run the same story but different things might happen, and different choices will be triggered depending on what's happened.
A a simple example...The player enters a cave. They can go left or right. They choose left. Reaching the next node causes a process to run to determine what happens (e.g. the node is marked as "variable outcome" somehow). Certain parameters will be passed into the process to restrict the options.
In this example, when the player arrives at the node, the scenario will be picked randomly from a list, such as:
1. Find an item
2. Find a deceased thing
3. Find an alive thing
Let's say the random number is (2) - and the player will find a deceased thing.
Now, the text shown will be procedurally generated by combining things from a "dictionary" of different phrases (originating from a base phrase template) to vary what actually happens.
Base Phrase: You see {deceased figure}{leaning_against}{location.wall}.
Then, another random number generator would build the phrase.
1. You see {the body of a dead elf}{slumped against}{the rough wall of the cave} (if location = cave)
2. You see {the desiccated corpse of a dwarf}{almost hidden, backed up into a crevice in the rock} (if location = cave)
If the location was a forest instead of a cave, different text would be triggered - e.g.
3. You see {a recently deceased elven scout}{pinned to the tree by a number of spears} (if location = forest)
Based on what is found, this will trigger different choices. So, for a deceased thing the choices might be:
1. Loot the body (outcomes: find an item (randomly selected); if "iswithcompanion" is true, then trigger love/hate change)
2. Bury the body (outcome: if "iswithcompanion is true, then trigger love/hate change (e.g. respect)
3. Loot the body and then bury it
4. Ignore the body
Once this "interlude" is over, the player will then resume the pre-constructed narrative.
I am using the Dialogue System to run the main stories in the game. So I would like to find a way to incorporate this kind of thing into the system. Would you be able to provide some guidance on how I could look to do this? (or if there's anything similar already). I'm thinking I can build up a "database" (maybe via scriptable objects) of possible things which would be combined in different ways - and certain options are linked together. So finding the dead body will then have a 50% of producing certain loot, or alternatively might trigger a quest (e.g. to find who killed them).
There will be hundreds and hundreds of variations (based on scenarios, locations and other variables), so I can't see that it's feasible to create dialogues for each combination of things in advance. So I'm hoping it will be possible to find a way to "inject" elements into the dialogue somehow. Thinking about it, maybe one option would be to write a script that produces hundreds of dialogues when initialising, and then divert the player to a random (but appropriate) dialogue before bringing them back to continue the main dialogue. This feels a bit "inelegant" though, so I'm wondering if you can see a better way.
Any ideas?
Thanks
Pete
This isn't fully thought through yet, as I wanted to check what's possible before going too far down a certain route. So please bear with me.
As part of the game I'm developing, I want to be able to provide variations in the narrative, so that the player can run the same story but different things might happen, and different choices will be triggered depending on what's happened.
A a simple example...The player enters a cave. They can go left or right. They choose left. Reaching the next node causes a process to run to determine what happens (e.g. the node is marked as "variable outcome" somehow). Certain parameters will be passed into the process to restrict the options.
In this example, when the player arrives at the node, the scenario will be picked randomly from a list, such as:
1. Find an item
2. Find a deceased thing
3. Find an alive thing
Let's say the random number is (2) - and the player will find a deceased thing.
Now, the text shown will be procedurally generated by combining things from a "dictionary" of different phrases (originating from a base phrase template) to vary what actually happens.
Base Phrase: You see {deceased figure}{leaning_against}{location.wall}.
Then, another random number generator would build the phrase.
1. You see {the body of a dead elf}{slumped against}{the rough wall of the cave} (if location = cave)
2. You see {the desiccated corpse of a dwarf}{almost hidden, backed up into a crevice in the rock} (if location = cave)
If the location was a forest instead of a cave, different text would be triggered - e.g.
3. You see {a recently deceased elven scout}{pinned to the tree by a number of spears} (if location = forest)
Based on what is found, this will trigger different choices. So, for a deceased thing the choices might be:
1. Loot the body (outcomes: find an item (randomly selected); if "iswithcompanion" is true, then trigger love/hate change)
2. Bury the body (outcome: if "iswithcompanion is true, then trigger love/hate change (e.g. respect)
3. Loot the body and then bury it
4. Ignore the body
Once this "interlude" is over, the player will then resume the pre-constructed narrative.
I am using the Dialogue System to run the main stories in the game. So I would like to find a way to incorporate this kind of thing into the system. Would you be able to provide some guidance on how I could look to do this? (or if there's anything similar already). I'm thinking I can build up a "database" (maybe via scriptable objects) of possible things which would be combined in different ways - and certain options are linked together. So finding the dead body will then have a 50% of producing certain loot, or alternatively might trigger a quest (e.g. to find who killed them).
There will be hundreds and hundreds of variations (based on scenarios, locations and other variables), so I can't see that it's feasible to create dialogues for each combination of things in advance. So I'm hoping it will be possible to find a way to "inject" elements into the dialogue somehow. Thinking about it, maybe one option would be to write a script that produces hundreds of dialogues when initialising, and then divert the player to a random (but appropriate) dialogue before bringing them back to continue the main dialogue. This feels a bit "inelegant" though, so I'm wondering if you can see a better way.
Any ideas?
Thanks
Pete