Imported quest machine, already had dialogue system

Announcements, support questions, and discussion for Quest Machine.
User avatar
Tony Li
Posts: 20734
Joined: Thu Jul 18, 2013 1:27 pm

Re: Imported quest machine, already had dialogue system

Post by Tony Li »

Do you see a "Jump To Entry ID" field at all, like this?
jumpToEntryID.png
jumpToEntryID.png (19.4 KiB) Viewed 3651 times

In your StartConversationQuestAction.cs script, is line 20 (or thereabouts):

Code: Select all

[SerializeField] private bool m_specifyEntryID = false;
hipsterdufus
Posts: 95
Joined: Thu Aug 12, 2021 6:39 pm

Re: Imported quest machine, already had dialogue system

Post by hipsterdufus »

Yes I was unable to click on it for some reason. I think something was corrupted because after I created a new quest and deleted and reimported some things it started working (not sure which fixed it).

I think I'm starting to get a hang of the system finally I just have a few more questions:

I'm using my own save system. For the dialogue system I'm just outputting the entire system as a string (there's a nice method for that) and saving that to a file myself. Can I do something similar for quest machine?

My player (with a quest journal). Gets destroyed and recreated when changing scenes and loses quests. In this case does it make sense to create a separate quest journal that persists across scenes? My game is single player.

For quest givers, I see that the quest gets moved out of the quest giver component when the player accepts it. When the player moves out and back to the scene, the quest list is repopulated (maybe because my quest journal was cleared out?).

These quest objects on the giver and quest journal components aren't actually being copied right? They're just references to the single quest asset in the quest database?

When I call questGiver.StartDialogue() does it trigger based on the quest node's settings or quest's settings? Wondering how those 2 levels interact.

How can I listen for my own event system events instead of the quest machine's event system to progress a quest?
User avatar
Tony Li
Posts: 20734
Joined: Thu Jul 18, 2013 1:27 pm

Re: Imported quest machine, already had dialogue system

Post by Tony Li »

hipsterdufus wrote: Sat Sep 30, 2023 11:34 pmI'm using my own save system. For the dialogue system I'm just outputting the entire system as a string (there's a nice method for that) and saving that to a file myself. Can I do something similar for quest machine?
DS and QM use the same save system. If you're using this method to save DS:

Code: Select all

string s = PersistentDataManager.GetSaveData();
You'll instead want to use these steps:
  • Add a Save System component to the Dialogue Manager or Quest Machine, or its own GameObject. There should be only one.
  • Add a Dialogue System Saver component to the Dialogue Manager and set a unique Key such as "ds".
  • For QM: Inspect the Quest Journal component's Save Settings section. Set a unique Key such as "journal" and tick Include In Saved Games.
  • Use this method instead of PersistentDataManager.GetSaveData():

    Code: Select all

    string s = PixelCrushers.SaveSystem.Serialize(PixelCrushers.SaveSystem.RecordSavedGameData());
hipsterdufus wrote: Sat Sep 30, 2023 11:34 pmMy player (with a quest journal). Gets destroyed and recreated when changing scenes and loses quests. In this case does it make sense to create a separate quest journal that persists across scenes? My game is single player.
Using the DS+QM save system as described above will take care of it.
hipsterdufus wrote: Sat Sep 30, 2023 11:34 pmFor quest givers, I see that the quest gets moved out of the quest giver component when the player accepts it. When the player moves out and back to the scene, the quest list is repopulated (maybe because my quest journal was cleared out?).
Exactly. You can also set up the NPC's Quest Giver component to be included in save data if you want to record info like the number of times the NPC has given a quest.
hipsterdufus wrote: Sat Sep 30, 2023 11:34 pmThese quest objects on the giver and quest journal components aren't actually being copied right? They're just references to the single quest asset in the quest database?
No, they use instances in memory so each instance can have its own data. But they're not copied on disk or anything like that. In saved games, they're saved in a compact byte format that only saves the minimum data needed such as the quest state and node states.
hipsterdufus wrote: Sat Sep 30, 2023 11:34 pmWhen I call questGiver.StartDialogue() does it trigger based on the quest node's settings or quest's settings? Wondering how those 2 levels interact.
QuestGiver identifies which quests it can talk about. If there's only one quest, it shows dialogue about that quest. If there are multiple, it shows a menu. When showing dialogue about a quest, the Quest Giver compiles a list of quest content. If the quest is offerable, the list contains the Offer Text. If the quest is active or done, the list contains the main info's Dialogue Text from the current state (e.g. Active state) and the Dialogue Text from all of the nodes' current states. You can control the order in which the nodes add their Dialogue Text by moving them up and down in the Node Order reorderable list at the bottom of the main info inspector.
hipsterdufus wrote: Sat Sep 30, 2023 11:34 pmHow can I listen for my own event system events instead of the quest machine's event system to progress a quest?
I recommend looking at MessageQuestCondition.cs. You can write a similar quest condition for your own event system. To do this, duplicate QuestConditionTemplate.cs, move the duplicate into your own scripts folder, rename it, and fill in your code where the comments indicate.
hipsterdufus
Posts: 95
Joined: Thu Aug 12, 2021 6:39 pm

Re: Imported quest machine, already had dialogue system

Post by hipsterdufus »

I've done the steps to save the data, is there anything special I need to do to make the quest journal and giver components pick up the saved data? Right now, when I load a save slot I just call PersistentDataManager.ApplySaveData(s); to load the dialogue db (the string now contains the quest machine stuff). When I enter a scene with a quest giver does it automatically pull its data from this PersistentDataManager?

Should each quest giver component have its own save key in the save settings?

I am still seeing the quest giver re-populating its quests when I re-enter the scene even though my persisted journal keeps the quests. I suppose it doesn't really matter since the offer conditions are no longer met the dialogue is still effectively the same but I thought it would be saving now.
User avatar
Tony Li
Posts: 20734
Joined: Thu Jul 18, 2013 1:27 pm

Re: Imported quest machine, already had dialogue system

Post by Tony Li »

Hi,

Instead of:

Code: Select all

string s = PersistentDataManager.GetSaveData();
and:

Code: Select all

PersistentDataManager.ApplySaveData(s);
Use: (with "using PixelCrushers;" at top of script)

Code: Select all

string s = SaveSystem.Serialize(SaveSystem.RecordSavedGameData());
and:

Code: Select all

SaveSystem.ApplySavedGameData(SaveSystem.Deserialize<SavedGameData>(s));
hipsterdufus
Posts: 95
Joined: Thu Aug 12, 2021 6:39 pm

Re: Imported quest machine, already had dialogue system

Post by hipsterdufus »

Thanks, I was seeing an error on load about the lua having a syntax error and this seems to have fixed it. But the quest journal and quest givers don't seem to be loading their data automatically. Do I have to manually trigger that? Also, when I accept a quest the quest HUD appears and when I start a new save or load another save it remains even though the Journal is showing no quests and I called SaveSystem.ResetGameState();.
User avatar
Tony Li
Posts: 20734
Joined: Thu Jul 18, 2013 1:27 pm

Re: Imported quest machine, already had dialogue system

Post by Tony Li »

Hi,

Make sure the quest journal and quest entry component's Save Settings are configured to be included in saved games and have unique keys. See the Player GameObject in QM's Demo for an example.
hipsterdufus
Posts: 95
Joined: Thu Aug 12, 2021 6:39 pm

Re: Imported quest machine, already had dialogue system

Post by hipsterdufus »

Not really sure what's wrong, everything looks fine in the inspector. For some reason SaveSystem.ResetGameState(); doesn't clear my journal component's quests. The HUD quest persists across saves. I think I got the journal quests to clear once by loading another save with no quests but the quest still remained in the HUD for some reason.
User avatar
Tony Li
Posts: 20734
Joined: Thu Jul 18, 2013 1:27 pm

Re: Imported quest machine, already had dialogue system

Post by Tony Li »

Hi,

That may be a bug. Please let me know if this patch fixes the SaveSystem.ResetGameStart() issue.

QM_Patch_2023-10-01.unitypackage
hipsterdufus
Posts: 95
Joined: Thu Aug 12, 2021 6:39 pm

Re: Imported quest machine, already had dialogue system

Post by hipsterdufus »

That works, it seems like the Journal state is correct now. Is there something similar needed for QuestGivers? Doesn't seem like they save their quest list state.

How do I refresh the HUD after calling ApplySavedGameData()? I'm calling journal.RepaintUIs() but the HUD only seems to appear when I accept the quest and then it doesn't go away. Could be my fault cause I was messing with the HUD UI a bit.
Post Reply