Getting Quest Info linked to a conversation
-
- Posts: 18
- Joined: Fri Jan 01, 2021 2:59 pm
Getting Quest Info linked to a conversation
Hi Tony and Happy new Year
First, I wanted to thank you for the tool you created for us, it takes some time to actually make it work, but the results are really good I've been looking for something specific, but I was not able to find it (I must be blind!)
So here is the issue:
I wanted to know if it is possible to get the status of a quest after a conversation ended.
For example, I have a conv. with an NPC, at the end I want to be able to get what was the last conversation played, check if this is linked to a quest and check the status of the quest (to be able to execute something).
I am doing it in c# and I plug my script on the Alert popup BP (which shows up when the conversation ends).
Thanks.
Laurel.
First, I wanted to thank you for the tool you created for us, it takes some time to actually make it work, but the results are really good I've been looking for something specific, but I was not able to find it (I must be blind!)
So here is the issue:
I wanted to know if it is possible to get the status of a quest after a conversation ended.
For example, I have a conv. with an NPC, at the end I want to be able to get what was the last conversation played, check if this is linked to a quest and check the status of the quest (to be able to execute something).
I am doing it in c# and I plug my script on the Alert popup BP (which shows up when the conversation ends).
Thanks.
Laurel.
Re: Getting Quest Info linked to a conversation
Hi Laurel,
In C#, you can use an OnConversationEnd method, check DialogueManager.lastConversationStarted, and use QuestLog to check the quest state. For example, put something like this on the Dialogue Manager or one of the conversation's participants:
If you can't put the script on the Dialogue Manager or one of the conversation participants, hook into the DialogueManager.instance.conversationEnded C# event instead.
You can also do many things without having to write any C# code. Example:
In C#, you can use an OnConversationEnd method, check DialogueManager.lastConversationStarted, and use QuestLog to check the quest state. For example, put something like this on the Dialogue Manager or one of the conversation's participants:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class CheckQuestAtConversationEnd : MonoBehaviour
{
[QuestPopup] public string quest; //<--Set in inspector.
void OnConversationEnd(Transform actor)
{
Debug.Log("This conversation just ended: " + DialogueManager.lastConversationStarted);
if (QuestLog.GetQuestState(quest) == QuestState.Success)
{
DialogueManager.ShowAlert(quest + " is in the success state.");
}
}
}
You can also do many things without having to write any C# code. Example:
-
- Posts: 18
- Joined: Fri Jan 01, 2021 2:59 pm
Re: Getting Quest Info linked to a conversation
Hi Tony,
Thanks for the quick answer!
So I was able to make your suggestion work in my setup (I actually had something similar but I had to write the quest name in the inspector), using your [QuestPopup] is much better .
But If I wanted to automatically retrieve (by code) the quest string value from the last conversation without picking the Quest value from the inspector, would it be possible?
I wanted to have a class that could listen and do something when a new quest is enabled and / or something different when a quest is a success (play audio sound for example).
PS:
btw, when I do this:
I don't get the localized version of the variables questName and msg (which is another variable). I just get a new string value because the final result is a full variable name that doesn't exist in the translation database (I get it).
But, using the lua scripting in the conversation tab works (using the alert variable).
So I was also wondering is there a way to get the new translated message from the code example? (because I use string1 + string2)
Thanks in advance!
Thanks for the quick answer!
So I was able to make your suggestion work in my setup (I actually had something similar but I had to write the quest name in the inspector), using your [QuestPopup] is much better .
But If I wanted to automatically retrieve (by code) the quest string value from the last conversation without picking the Quest value from the inspector, would it be possible?
I wanted to have a class that could listen and do something when a new quest is enabled and / or something different when a quest is a success (play audio sound for example).
PS:
btw, when I do this:
Code: Select all
DialogueManager.ShowAlert(questName + "\n" + msg);
But, using the lua scripting in the conversation tab works (using the alert variable).
So I was also wondering is there a way to get the new translated message from the code example? (because I use string1 + string2)
Thanks in advance!
Re: Getting Quest Info linked to a conversation
Yes. Add an OnQuestStateChange() method to your script:laurelhach wrote: ↑Sat Jan 02, 2021 10:06 amIf I wanted to automatically retrieve (by code) the quest string value from the last conversation without picking the Quest value from the inspector, would it be possible?
Code: Select all
void OnQuestStateChange(string quest)
{
Debug.Log(quest + " changed to state: " + QuestLog.CurrentQuestState(quest));
}
You can use DialogueManager.GetLocalizedText:laurelhach wrote: ↑Sat Jan 02, 2021 10:06 ambtw, when I do this:I don't get the localized version of the variables questName and msg (which is another variable). I just get a new string value because the final result is a full variable name that doesn't exist in the translation database (I get it).Code: Select all
DialogueManager.ShowAlert(questName + "\n" + msg);
But, using the lua scripting in the conversation tab works (using the alert variable).
So I was also wondering is there a way to get the new translated message from the code example? (because I use string1 + string2)
Code: Select all
DialogueManager.ShowAlert(DialogueManager.GetLocalizedText(questName) + "\n" + DialogueManager.GetLocalizedText(msg));
-
- Posts: 18
- Joined: Fri Jan 01, 2021 2:59 pm
Re: Getting Quest Info linked to a conversation
Hi Tony,
Thanks for the detailled information.
I have one last question, I've noticed that the groups for quests don't get translated.
I'm not sure if this is on my side.
If I click on the quest/items section and select the quest, I can see all the translations in the Inspector in the group section (and I checked Use Groups). But playing the game, I only get the english name / default name.
PS: I use I2 Loc. and the conversations and the tracker translation are working (but not the alert, as I'm using your guideline).
Thanks for the detailled information.
I have one last question, I've noticed that the groups for quests don't get translated.
I'm not sure if this is on my side.
If I click on the quest/items section and select the quest, I can see all the translations in the Inspector in the group section (and I checked Use Groups). But playing the game, I only get the english name / default name.
PS: I use I2 Loc. and the conversations and the tracker translation are working (but not the alert, as I'm using your guideline).
Re: Getting Quest Info linked to a conversation
Hi,
Oops, that's a bug. No idea how that slipped by for so long. Here's a patch:
DS_QuestLogWindowPatch_2021-01-03.unitypackage
Oops, that's a bug. No idea how that slipped by for so long. Here's a patch:
DS_QuestLogWindowPatch_2021-01-03.unitypackage
-
- Posts: 18
- Joined: Fri Jan 01, 2021 2:59 pm
Re: Getting Quest Info linked to a conversation
Happy to help! Thanks for letting me know about the bug.