Jumping directly to DialogueEntry via ID #, while mid-conversation?
Jumping directly to DialogueEntry via ID #, while mid-conversation?
Hi Tony! Hope you are doing well!
TL;DR: If a conversation is already active, is there a way to jump directly to a DialogueEntry if I know its ID#?
My Situation: My game is 2 player online co-op. The "host" player is the one that controls the conversation, and I just want it to be replicated on the non-host players side. Instead of sending network-messages from the host to the non-host every time "continue" is pressed (which could possibly get out of sync and never recover, if there are issues), what I'd like to do is for the host player to send the ID# of the DialogueEntry every time it progresses to a new DialogueEntry in the conversation.
So on the non-host player's end, they would initially get a network-message to start the Conversation. Then every time the host-player progresses, the non-host player would receive a network-message with the DialogueEntry ID# that the host progressed to.
Is there a built-in way for an active conversation to go directly to that DialogueEntry, given the ID#? I poked around in the code for a while and couldn't find it.
Thanks a lot for the help!
TL;DR: If a conversation is already active, is there a way to jump directly to a DialogueEntry if I know its ID#?
My Situation: My game is 2 player online co-op. The "host" player is the one that controls the conversation, and I just want it to be replicated on the non-host players side. Instead of sending network-messages from the host to the non-host every time "continue" is pressed (which could possibly get out of sync and never recover, if there are issues), what I'd like to do is for the host player to send the ID# of the DialogueEntry every time it progresses to a new DialogueEntry in the conversation.
So on the non-host player's end, they would initially get a network-message to start the Conversation. Then every time the host-player progresses, the non-host player would receive a network-message with the DialogueEntry ID# that the host progressed to.
Is there a built-in way for an active conversation to go directly to that DialogueEntry, given the ID#? I poked around in the code for a while and couldn't find it.
Thanks a lot for the help!
Re: Jumping directly to DialogueEntry via ID #, while mid-conversation?
Hi,
Use the C# method DialogueManager.conversationController.GotoState(). Example:
Related examples that might be relevant: How To: Interrupt Conversation
Use the C# method DialogueManager.conversationController.GotoState(). Example:
Code: Select all
// Jump the active conversation to a specific conversation ID and entry ID:
var entry = DialogueManager.masterDatabase.GetDialogueEntry(conversationID, entryID);
var state = DialogueManager.conversationModel.GetState(entry);
DialogueManager.conversationController.GotoState(state);
Re: Jumping directly to DialogueEntry via ID #, while mid-conversation?
Thanks so much for the help Tony!Tony Li wrote: ↑Wed Sep 28, 2022 9:34 pm Hi,
Use the C# method DialogueManager.conversationController.GotoState(). Example:
Related examples that might be relevant: How To: Interrupt ConversationCode: Select all
// Jump the active conversation to a specific conversation ID and entry ID: var entry = DialogueManager.masterDatabase.GetDialogueEntry(conversationID, entryID); var state = DialogueManager.conversationModel.GetState(entry); DialogueManager.conversationController.GotoState(state);
I have two quick follow-up questions if you don't mind
![Wink ;)](./images/smilies/icon_e_wink.gif)
1) For the host-player who needs to notify the non-host player every time they progress to a new DialogueEntry, would the best place for me to inject some custom code be at ConversationController.GoToState(ConversationState state)? Seems like that function is being called every time I progress through a conversation.
Edit: Hmm, I can't seem to reference my code from within ConversationController.cs. Is that something with AssemblyDefinitions possibly?
![Confused :?](./images/smilies/icon_e_confused.gif)
2) If I am in the ConversationState.GoToState(ConversationState state) function, and thus have that "state", how can I get the DialogueEntryID for that state, so that I can send that ID to the non-host player? Is that possible?
Figured that one out the moment after I posted it, lol, sorry! (state.subtitle.dialogueEntry.id)
Thanks again!!
Re: Jumping directly to DialogueEntry via ID #, while mid-conversation?
Looks like you already have a solution, but I would use an OnConversationLine() method in a script on the host.
Re: Jumping directly to DialogueEntry via ID #, while mid-conversation?
Thanks again Tony! I see how the "Conversation Messages" work now, so I ended up making good use of themTony Li wrote: ↑Thu Sep 29, 2022 8:05 am Looks like you already have a solution, but I would use an OnConversationLine() method in a script on the host.
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
Re: Jumping directly to DialogueEntry via ID #, while mid-conversation?
Hey Tony, another related follow-up question if you don't mind
![Smile :)](./images/smilies/icon_e_smile.gif)
In my conversations, I often have "pass-through" entries which just have "Continue()" in the Sequencer so it automatically goes to the next entry. Also on a few rare occasions I'll have a couple commands in the Sequencer with the final one being a "Continue()@XXX".
On my non-host player, I would like to block ANY "Continue()" sequence commands from being processed. So the non-host player will sit at any dialogueEntry regardless of whether it has "Continue()" in the sequence even if it doesn't have any actual dialogue text. I ONLY want it to go to another dialogueEntry when it receives a network-message to do so.
I'm having difficulty figuring out where to inject my code to block the "Continue()" getting processed. I believe there are multiple places that might process it:
1) I see that ConversationView.cs has "ShouldShowSubtitle(Subtitle subtitle)" which checks if the sequence is solely "Continue()", and then I assume if so, it goes directly to the next dialogueEntry? I tried adding my check for "IS_NETWORKED_NONHOST" here, but despite the logs showing my "(2) ShouldShowSubtitle resulted in true" log, the conversation still proceeded to the next dialogueEntry immediately/automatically. Maybe it is automatically 'continuing' because of a check further down the road in the processing?
Code: Select all
private bool ShouldShowSubtitle(Subtitle subtitle)
{
if ((subtitle != null) && (settings != null) && (settings.subtitleSettings != null))
{
if (DialogueManager.IS_NETWORKED_NONHOST == false && (subtitle.formattedText.noSubtitle || //ADDED NONHOST CHECK
string.Equals(subtitle.sequence, "None()") || string.Equals(subtitle.sequence, "None();") ||
string.Equals(subtitle.sequence, "Continue()") || string.Equals(subtitle.sequence, "Continue();")))
{
Debug.Log("(1) ShouldShowSubtitle resulted in false");
return false;
}
if ((subtitle.speakerInfo.characterType == CharacterType.NPC) && settings.GetShowNPCSubtitlesDuringLine())
{
Debug.Log("(2) ShouldShowSubtitle resulted in true");
return true;
}
if ((subtitle.speakerInfo.characterType == CharacterType.PC) && settings.GetShowPCSubtitlesDuringLine())
{
Debug.Log("(3) ShouldShowSubtitle resulted in settings check");
return !(_lastModeWasResponseMenu && settings.GetSkipPCSubtitleAfterResponseMenu());
}
}
Debug.Log("(4) ShouldShowSubtitle resulted in default false");
return false;
}
Is there any universal way I could block Continue() from working at all, so that the non-host only traverses a conversation from receiving network-messages that call GoTo(state)? (Note: I do want the non-host to process any 'Script' functions, even on these pass-through dialogueEntries)
P.S. Another way I thought might potentially work would be to have a function for "OnConversationLine(Subtitle subtitle)" callback that simply removes any occurances of Continue() directly from the subtitle.sequence. Would you advise for or against that?
Thanks a lot for the help, and hope it wasn't too confusing!
Re: Jumping directly to DialogueEntry via ID #, while mid-conversation?
I was going to suggest using an OnConversationLine(Subtitle) method to remove Continue() from sequences. Alternatively, you could use the method to set the entire sequence to "None()" on the other client and assume that network synchronization will handle whatever the primary client is causing to happen in the game.
Re: Jumping directly to DialogueEntry via ID #, while mid-conversation?
Thank you Tony, making great progress!Tony Li wrote: ↑Tue Oct 04, 2022 4:20 pm I was going to suggest using an OnConversationLine(Subtitle) method to remove Continue() from sequences. Alternatively, you could use the method to set the entire sequence to "None()" on the other client and assume that network synchronization will handle whatever the primary client is causing to happen in the game.
Re: Jumping directly to DialogueEntry via ID #, while mid-conversation?
Thanks again Tony, everything is working great so far, so I think I have my final question!Tony Li wrote: ↑Tue Oct 04, 2022 4:20 pm I was going to suggest using an OnConversationLine(Subtitle) method to remove Continue() from sequences. Alternatively, you could use the method to set the entire sequence to "None()" on the other client and assume that network synchronization will handle whatever the primary client is causing to happen in the game.
![Laughing :lol:](./images/smilies/icon_lol.gif)
I'm using the built-in Script command for setting Variables during a conversation. On the Host-Player, I'm trying to figure out where I can inject some code so that I can send an RPC to the Non-Host-Player any time the "Variable" Script command is called.
I saw that there is some example code that is similar to what I'm looking to do (LuaNetworkCommands.cs) but we do stuff like 'increment a Number variable by 1" when using the built-in "Variable" script command, which doesn't seem possible with custom made commands -> so I'm hoping to just find the right spot to 'intercept' the built-in "Variable" Script command and send an RPC to the Non-Host-Player there.
Does that seem possible? I was having trouble finding where the built-in "Variable" script's execution code is.
Thanks for all the help!!