Page 1 of 1
Activate conversation entry from any point on event
Posted: Thu Sep 05, 2019 8:53 am
by Deadcow
Imagine text quest represented as a huge dialogue tree. There a lots of entries, where player health might be decreased. I've got node tree called "Dead" and I'd like this node to activated when health is 0, regardless of current active entry.
One way to do this is to add links from all entries where hp is decreased to "Dead" entry with condition, but I wonder if there some way to activate it by some event automatically?
I handle dialogues mostly via code. I bind some custom Lua functions to Dialogue System to get or set current hp, items etc, so I imagine there should be some way to get current conversation, find entry named "Dead" and set it active if there is any... Is it possible?
Re: Activate conversation entry from any point on event
Posted: Thu Sep 05, 2019 9:21 am
by Tony Li
Yes. I'll describe two approaches: one using scripting, one without scripting.
I've debated adding an "Any State" like in Mecanim, but like with Mecanim it could cause performance issues if Any State links to a lot of nodes with Conditions, since it would need to evaluate these nodes' Conditions every time. So I haven't added this. If enough people really want it, I'll add it.
Without scripting, you can set up something that stops the conversation if health is 0. Add another Dialogue System Trigger set to OnConversationEnd with a Condition that checks if health is 0. If so, Add Action > Start Conversation and specify a starting entry ID. The downside of this approach is that you need to stop the conversation and restart it at the "Dead" node.
With scripting, you can keep the same conversation active. Call
DialogueManager.conversationModel.
GetState(entry), passing it a DialogueEntry. This returns a ConversationState, which you can then pass to
DialogueManager.conversationController.
GotoState(state).
Re: Activate conversation entry from any point on event
Posted: Fri Sep 06, 2019 5:52 am
by Deadcow
Okay, second option fits the best, but I wonder how to find needed entry from current Conversation?
Well actually it's easy to get entry from Conversation, but I was unable to find the way to get current Conversation, considering that conversation initially started by string id. I browsed api for DialogueManager, ConversationState, ConversationModel and ditn't found a way to get current Conversation
Re: Activate conversation entry from any point on event
Posted: Fri Sep 06, 2019 8:03 am
by Deadcow
Oh I found DialogueManager.MasterDatabase.GetConversation() method, should do the trick. Thanks! I'll try it now
Re: Activate conversation entry from any point on event
Posted: Fri Sep 06, 2019 11:46 am
by Tony Li
Sounds good. If you run into any issues, just let me know.