Hi,
I'm implementing a mechanic in my game where some dialogues are timed and on timeout it triggers a specific response.
Maybe I can use the "low", "below normal" to "high" parameter to define which response will be triggered.
But how do I trigger it ? I know I have to set timeout to custom, and use the OnConversationTimeout() method. But how do I trigger the response ?
Thanks.
Scripted response on timeout
Re: Scripted response on timeout
Hi,
You probably don't want to use priority levels (BelowNormal, AboveNormal, etc.) because only the highest priority level with available nodes will be used.
In your OnConversationTimeout() method, you can examine the current list of responses (DialogueManager.currentConversationState.pcResponses). You could add a custom field to your dialogue entry template to specify what to do on timeout. If the field is set, you can use its content to decide what to do.
You probably don't want to use priority levels (BelowNormal, AboveNormal, etc.) because only the highest priority level with available nodes will be used.
In your OnConversationTimeout() method, you can examine the current list of responses (DialogueManager.currentConversationState.pcResponses). You could add a custom field to your dialogue entry template to specify what to do on timeout. If the field is set, you can use its content to decide what to do.
-
- Posts: 24
- Joined: Fri Mar 13, 2020 1:30 pm
Re: Scripted response on timeout
Ok thanks, so with a custom field on my response nodes I can specify which one will be triggered on timeout.
But how do I trigger the response?
For example, if I have a character that says to the player: "Give me your money now!"
The player can answer 1: "Here, that's all I have", 2: "My... my money?", 3: "Or I can alert the cops just over there"
He has 5 seconds and on time out, the game automatically selects the response 2: "My... my money?".
So on the node "Give me your money now!" I can set a bool "isTimed" true, and on 2: "My... my money?" I can set the custom field that says it's the time out response.
Then in my script, I check if the bool is timed and if it is I fire some animations (to let the player know that this is timed) and on timeout check for the custom field and activate this response and some more animations (to show him he wasn't quick enough and what response got triggered).
But how do I trigger the response?
For example, if I have a character that says to the player: "Give me your money now!"
The player can answer 1: "Here, that's all I have", 2: "My... my money?", 3: "Or I can alert the cops just over there"
He has 5 seconds and on time out, the game automatically selects the response 2: "My... my money?".
So on the node "Give me your money now!" I can set a bool "isTimed" true, and on 2: "My... my money?" I can set the custom field that says it's the time out response.
Then in my script, I check if the bool is timed and if it is I fire some animations (to let the player know that this is timed) and on timeout check for the custom field and activate this response and some more animations (to show him he wasn't quick enough and what response got triggered).
Re: Scripted response on timeout
Hi,
Set "isTimed" on "My... my money?".
In the "Give me your money now!" node, add SetTimeout(5) to the Sequence field. To make the sequence also play the Dialogue Manager's Default Sequence, also include {{default}}. Example:
Set "isTimed" on "My... my money?".
In the "Give me your money now!" node, add SetTimeout(5) to the Sequence field. To make the sequence also play the Dialogue Manager's Default Sequence, also include {{default}}. Example:
- Sequence: SetTimeout(5); {{default}}
Code: Select all
void OnConversationTimeout()
{
foreach (Response response in DialogueManager.currentConversationState.pcResponses)
{
if (Field.LookupBool(response.destinationEntry.fields, "isTimed"))
{
DialogueManager.standardDialogueUI.OnClick(response);
return;
}
}
}
-
- Posts: 24
- Joined: Fri Mar 13, 2020 1:30 pm
Re: Scripted response on timeout
Thanks again for the help.
So the "DialogueManager.standardDialogueUI.OnClick(response);" is not available for me, it does not find standardDialogueUI, and if I put it like "DialogueManager.DialogueUI.OnClick()" it does not find any OnClick() method.
Also, can I access the timeout value ? And the time passed ? So I can know how much time is left before timeout, so I can time stuff.
So the "DialogueManager.standardDialogueUI.OnClick(response);" is not available for me, it does not find standardDialogueUI, and if I put it like "DialogueManager.DialogueUI.OnClick()" it does not find any OnClick() method.
Also, can I access the timeout value ? And the time passed ? So I can know how much time is left before timeout, so I can time stuff.
-
- Posts: 24
- Joined: Fri Mar 13, 2020 1:30 pm
Re: Scripted response on timeout
Never mind the first issue: I wrote
"(DialogueManager.dialogueUI as StandardDialogueUI).OnClick(responseToTrigger);"
instead and it seems to works.
"(DialogueManager.dialogueUI as StandardDialogueUI).OnClick(responseToTrigger);"
instead and it seems to works.
Re: Scripted response on timeout
Hi,
The DialogueManager.standardDialogueUI property was added in a recent version. If you're using an older version, this property won't be present, so the way you did it is perfect.
The menu's current time passed is handled internally. But you can check the timer's slider value:
The DialogueManager.standardDialogueUI property was added in a recent version. If you're using an older version, this property won't be present, so the way you did it is perfect.
DialogueManager.displaySettings.GetResponseTimeout() returns the timeout value.ProvencalG wrote: ↑Tue Jul 13, 2021 10:36 amAlso, can I access the timeout value ? And the time passed ? So I can know how much time is left before timeout, so I can time stuff.
The menu's current time passed is handled internally. But you can check the timer's slider value:
Code: Select all
var ui = DialogueManager.dialogueUI as StandardDialogueUI; //(Use standardDialogueUI property in v2.2.18+)
var timerSlider = ui.conversationUIElements.defaultMenuPanel.timerSlider;