Calculating Score using Quest Machine

Announcements, support questions, and discussion for Quest Machine.
Post Reply
Mchia_Soo
Posts: 72
Joined: Sun Jun 30, 2019 11:59 pm

Calculating Score using Quest Machine

Post by Mchia_Soo »

Hello! I am developing a game where the player will accept the quest from a person to answer True/False from the NPCs' questions and the scores will display on the HUD text.

Is there any way to calculate and display the score, instead of display how many questions that have been answered?

Also, is it possible to display the answered question in the Journal?

For now, I am using Dialogue System for the dialogues and planning to use Quest Machine for the quests function in my game. I am watching the tutorial videos while doing these. Do I have to follow step by step, starting from the 1st video of Quest Machine, or I can straightaway follow the Dialogue System Integration tutorial video?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Calculating Score using Quest Machine

Post by Tony Li »

Hi,

I recommend watching Quest Machine tutorial videos 1-4 first. Then you can jump to tutorial 6 (Dialogue System integration).

You can record the score in a Dialogue System variable. (You can record it anywhere, such as in a custom script, but I think a Dialogue System variable is an easy place to record it.)

When the player answers a question correctly, in your Quest Machine quest use a Lua Quest Action to add to the variable. (See page 7 of the Dialogue System Integration PDF.)

In your journal UI content, use Dialogue System Text Quest Content in place of Body Text Quest Content. Inside the text, use [var=variable] where variable is the name of your Dialogue System variable. This will show the value of the variable. (See the top of page 8 of the Dialogue System Integration PDF.)
Mchia_Soo
Posts: 72
Joined: Sun Jun 30, 2019 11:59 pm

Re: Calculating Score using Quest Machine

Post by Mchia_Soo »

I have watched the tutorial videos as well as the demo scene and have tried to apply the same functions of demo scene in my game. However, the dialogue system seems to be changed somewhere I do not know.

1. In the Conversation tab, player will reply "Thank you!" as the sign of accepting quest. The moment when the player leaves the Quest Giver, HUD displays "Return to Quest Giver" in which it is supposed display the score.

2. When the player goes back to the Quest Giver, before talking to other NPCs (to answer their questions), the Quest Giver is supposed to tell the player the marks of answering correctly, but she says, "You have completed the mission", and the game just ends like that, without starting the game. :lol:

3. After the game ends, the UI display is not the one I set in Dialogue Manager, it;s the Quest Machine Default UI. Other UIs are fine, this is the only UI that is having problem.
You can record the score in a Dialogue System variable. (You can record it anywhere, such as in a custom script, but I think a Dialogue System variable is an easy place to record it.)

When the player answers a question correctly, in your Quest Machine quest use a Lua Quest Action to add to the variable. (See page 7 of the Dialogue System Integration PDF.)

In your journal UI content, use Dialogue System Text Quest Content in place of Body Text Quest Content. Inside the text, use [var=variable] where variable is the name of your Dialogue System variable. This will show the value of the variable. (See the top of page 8 of the Dialogue System Integration PDF.)
Btw, I haven't tried on using Lua Quest Action and Dialogue System Text Quest Content, perhaps, I apply on my game after these problems got solved.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Calculating Score using Quest Machine

Post by Tony Li »

Hi,
Can you please send an example unitypackage or project to tony (at) pixelcrushers.com? It will help me understand where you are in the setup steps.
Mchia_Soo wrote: Fri Jul 12, 2019 6:26 am1. In the Conversation tab, player will reply "Thank you!" as the sign of accepting quest. The moment when the player leaves the Quest Giver, HUD displays "Return to Quest Giver" in which it is supposed display the score.
Does the quest node have a quest condition that listens for the "Discussed Quest" message? If so, try changing this to "Discuss Quest".
Mchia_Soo wrote: Fri Jul 12, 2019 6:26 am2. When the player goes back to the Quest Giver, before talking to other NPCs (to answer their questions), the Quest Giver is supposed to tell the player the marks of answering correctly, but she says, "You have completed the mission", and the game just ends like that, without starting the game. :lol:
It sounds like the quest node conditions need to be adjusted. If you can send me an example, I will be able to provide more specific answers.
Mchia_Soo wrote: Fri Jul 12, 2019 6:26 am3. After the game ends, the UI display is not the one I set in Dialogue Manager, it;s the Quest Machine Default UI. Other UIs are fine, this is the only UI that is having problem.
Do you want to show the Dialogue System's dialogue UI? If so, are you using the Dialogue System Conversation Quest Content?
Mchia_Soo wrote: Fri Jul 12, 2019 6:26 amBtw, I haven't tried on using Lua Quest Action and Dialogue System Text Quest Content, perhaps, I apply on my game after these problems got solved.
I think you may need to take care of the other issues first.
Mchia_Soo
Posts: 72
Joined: Sun Jun 30, 2019 11:59 pm

Re: Calculating Score using Quest Machine

Post by Mchia_Soo »

Hello Tony!

First of all, thank you so much for the fast response. I am sorry that I could not send to you any part of my project due to PNC. Hope you understand it.

Finally everything is settled after I did a new version of my project, where I applied Quest Machine before Dialogue System. At first, HUD still displays "Return to Quest Giver". There was no changes when I changed the "Discussed Quest" to "Discuss Quest", so I changed it back and at the meantime, I changed the counter value mode from "At most" to "At least". Surprisingly, it works well! As for now, I still don't understand why it has to be "At least" not "At most".

The UI worked fine after I did a new version of my project. Also, I have applied the Lua Quest Action and Dialogue System Text Quest Content on my game. Both of them are working fine now.

Just wondering, is it possible to display the questions in the journal one by one, after someone mentions the questions?

Thanks again Tony for the help!
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Calculating Score using Quest Machine

Post by Tony Li »

Hi,
Mchia_Soo wrote: Tue Jul 16, 2019 4:05 amJust wondering, is it possible to display the questions in the journal one by one, after someone mentions the questions?
Yes. Add each one as a separate quest node. After someone mentions a question, set the quest node from Inactive to Active. (Or to True, depending on when/how you want it to appear.) The quest journal will show the content for each quest node based on its state.
Mchia_Soo
Posts: 72
Joined: Sun Jun 30, 2019 11:59 pm

Re: Calculating Score using Quest Machine

Post by Mchia_Soo »

All is working well. Thanks again!

Would like to know, does this line of code have any error?
[lua ((GetQuestNodeState("GatherReq", "greet" == "active")) and (Variable["TotalReq"] >= 4))]

I have rechecked it on the Manual, supposed there is no error, but when I ran the game, this error (figure below) came out.
02.PNG
02.PNG (21.55 KiB) Viewed 2489 times
I wanted to set that particular quest node active, where the alert text will display to ask the player to go to the Quest Giver after the mission is completed.

Anything that I have missed out in order to solve this error?
Mchia_Soo
Posts: 72
Joined: Sun Jun 30, 2019 11:59 pm

Re: Calculating Score using Quest Machine

Post by Mchia_Soo »

Can I do an IF-ELSE statement using Lua code and apply it in the Condition/Script of the Dialogue System?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Calculating Score using Quest Machine

Post by Tony Li »

Hi,

It's missing a parenthesis:

(GetQuestNodeState("GatherReq", "greet" == "active"))

should be:

(GetQuestNodeState("GatherReq", "greet") == "active"))
Mchia_Soo wrote: Mon Jul 22, 2019 4:45 am Can I do an IF-ELSE statement using Lua code and apply it in the Condition/Script of the Dialogue System?
You can use if..then..else..end in the Script field.

For the Conditions field, you cannot use 'if'. You can use and/or as described on Lua's Ternary Operator page.

For example, the condition below checks if MyQuest is already successful. If so, it returns true/false if the player has 3+ apples. If MyQuest is not already successful, it returns true/false if the player has 10+ apples:

(CurrentQuestState("MyQuest") == "success") and (Variable["numApples"] >= 3) or (Variable["numApples"] >= 10)
Post Reply