On Quest State change (String)

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
OscarS
Posts: 17
Joined: Mon Jul 17, 2023 1:47 pm

On Quest State change (String)

Post by OscarS »

Hi,

I implemented my own "UI Quest" in which all quests are on a vertical layout group. I managed to get the quest info from the QuestLog class. But now, I want to add a new Quest to the list when it is assigned from the dialogues(it is already implemented), so I'm trying to read from my script when a Quest has changed state to "active". I tried using the "Event system component" to call my function with the "On Quest State Change (string) ". But I can't manage to get the "string" from the Quest Event. When the Quest is active, it calls my function but without the string.

How can I read the "quest string" from the quest that has changed its state?

Thanks in advance for the attention!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: On Quest State change (String)

Post by Tony Li »

Hi,

Select the dynamic version. For example, assuming your script method is named UpdateQuestUI(string):

dynamicEvent.png
dynamicEvent.png (79.42 KiB) Viewed 386 times

Alternatively, if your script is in the Dialogue Manager's hierarchy, you can use an OnQuestStateChange(string questName) method instead of Dialogue Entry Events.
OscarS
Posts: 17
Joined: Mon Jul 17, 2023 1:47 pm

Re: On Quest State change (String)

Post by OscarS »

Hi Tony,
thanks a lot for the reply. Everything works fine. But now I have a new question. When the game loads, I want all the Active/Succes Quests to load on the UI. I have a script that reads all of them and then instantiates the prefab quest container in place.

I tried calling this function on the "On load End()" Save system Event, but when I did that, it only created a quest that is active on a new game, but not the active quests from the save file. But, when I "load" the game again it creates the quests on the UI correctly. I tried loading the quests with a button and I noticed that it works fine. So my conclusion is that for some reason calling the Script to load the quests on the UI on the "On Load End()" event seems to be too soon and that the save system needs time to load the data.

I think this can be solved by using a "loading" screen and giving some time to let the data load, but I'm not sure how much time to let the game load. Is there some way to know when the game is totally loaded? I'm using "SaveSystem.LoadFromSlot(1);"

Or maybe there is a better approach to make sure I can use "QuestLog.GetAllQuests();" to get the Quests.

Thanks in advance.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: On Quest State change (String)

Post by Tony Li »

Hi,

You could hook into the SaveSystem.saveDataApplied C# event, but why not make a Saver script instead? (See: How To: Write Custom Savers.)
Post Reply