Speech: Choices
Section 4.C.1.B
Last updated
Section 4.C.1.B
Last updated
This subsection details setting up speech with branching dialogue paths that can be selected by the player. This can be simple Yes/No questions, or entire dialogue trees without any right or wrong answers.
Setting Up Choices
The simplest way to set up speech with choice selections is to present the player with a list of choices where there can only be one right answer. Here's an example of such a set up:
When this is triggered, a set of choices are set up. This is entered as an array which contains an ID for this specific set of choices, an index for what the correct choice should be, followed by a series of strings which act as the possible choices the player must pick from. These choices must be set up before the "speech" or "text" Command Keys which present these choices are called. Then, the text which presents these choices must be entered as an array, where :Choices
is placed within this array, wherever it is that you want those choices to appear during the speaker's speech.
In the example provided, the opponent will present the player with a question - "Does Tuesday come after Monday?" The player is then presented with two choices - "Yes" and "No." Because this particular set of choices does have only one correct answer ("Yes"), the index for this choice is set within "setChoices". Since "Yes" is the first choice in this list, the index for this is set as 1. When the player selects a choice that matches this stored index, a little chime will play to indicate that they made the correct choice. If the player selects a choice that doesn't match this stored index, a buzzer sound will play to indicate that they made an incorrect choice.
Choices With Reactions
If you want the speaker to react to the player's selected choice, you can tweak how you enter your choices to allow for this. This is done by setting the possible choices to a hash instead of a series of strings, where each possible choice is paired with a particular line of dialogue that will be used as the speaker's reaction to that choice. Let's modify the previous example to demonstrate this:
Here, we've set up different responses that the speaker will have whether the player selects "Yes" or "No." This will allow your speakers to interact with the player's decision immediately upon selection, instead of abruptly leaving off screen. There may be scenarios in which there is no reason for the speaker to have any reaction to the player's choice, so which way you set up your choices depends on the scenario.
Choices With Consequences
Ok, so now we know how to make the player select a choice, and we also know how to make the speaker react to the player's choice. But how do we make something happen when a choice is made? For this, we need to rely on other Trigger Keys.
Consequences for the Right Choice
If you want to trigger something to happen after the player selects the correct choice, this can be done by utilizing the "ChoiceRight" Trigger Key. This key must include a trigger extension that matches the ID that was entered for this specific set of choices. For example, the ID used in the examples above was set as :weekday
. This ID can be whatever you want, as long as it's a symbol and unique from any other ID used for a set of choices in the hash. If we combine this with our Trigger Key, we get "ChoiceRight_weekday", which is the key we need to make something happen in response to the player making the right choice for this set of questions. Let's add this to our example to make something happen:
By adding "ChoiceRight_weekday" to our midbattle hash, we can now set up any effects we want to trigger whenever the player selects the correct choice for the set of questions with the :weekday
ID. For this example, I've set it up so that selecting the correct choice raises the Speed stat of the player's Pokemon at index 0 by two stages.
Consequences for the Wrong Choice
You may also set separate consequences which trigger whenever the player makes an incorrect choice. This is handled similarly to how consequences for a correct choice is set up, the only difference is that you would use the Trigger Key "ChoiceWrong" instead of "ChoiceRight". Continuing our example, let's add a consequence to the player selecting the wrong choice when presented with the :weekday
choices, which would use the Trigger Key "ChoiceWrong_weekday".
With this addition, I've set it up so that selecting an incorrect choice lowers the Speed stat of the player's Pokemon at index 0 by two stages. So now when the player is presented with this particular question, they will be rewarded for selecting the correct choice, and punished for selecting an incorrect one.
Branching Choices
What if you want to set up a list of choices that don't have any particular right or wrong answer, but simply result in different outcomes based on the decisions made? This can also be done in a similar fashion. However, instead of setting an index for a correct choice, we can simply set this as nil
.
In this example, the player is asked by the speaker to select their favorite type of weather among three different choices. Because this question has no right or wrong answer, the index for the "correct" choice for this set of questions is simply set to nil.
However, if we want something to trigger based on the player's selection, we can no longer use the "ChoiceRight" or "ChoiceWrong" Trigger Keys. Instead, we can simply use the "Choice" Trigger Key, which requires two extensions. The first extension needs to be the ID used for this set of choices, like before. The ID used here is set as :weather
, so we would combine this to get "Choice_weather". Secondly, we need to indicate the index of the specific choice made where we want something to trigger. For example, if you want something to trigger when the player selects "Rainy!", then the resulting Trigger Key would look like "Choice_weather_2", since "Rainy!" is the second choice in this list of choices. Here's an example which trigger different outcomes based on each possible choice the player can make:
In this example, the player's choice determines which weather condition is set. If they pick "Sunny!", then the weather is changed to Sun. If they pick "Rainy!", then the weather is changed to Rain. Finally, if they pick "Snowy!", then the weather is changed to Hail.