CHeck variables on Quest status change

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

CHeck variables on Quest status change

Post by nathanj »

Hi Tony

Is there a way to have Variable values read when a quest state is changed?

Say my player has three firewood items in their inventory (the corresponding variable value for firewood in Dialogue System is 3). So if my quest requires the player collect three firewood items they would already have that number in their inventory. However, because I am using the Dialogue System Trigger set to "On Use" and is registered every time an item is added to the inventory there is nothing to check the variable value on start. The player either needs to drop an item and add it back to their collection or add more items to their collection. At the moment when the quest starts it says 3 or 3 firewood collected but the quest is not set to complete because the counted needs an "On Use" message.

My apologies if there is an obvious answer for this but is there some type of global command that can check variable values on all quest changes, or at least when set to active?

Thanks again,

Nathan
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: CHeck variables on Quest status change

Post by Tony Li »

Hi Nathan,

Can you copy that Dialogue System Trigger and change the copy's trigger dropdown to "On Start"?

Or set up another Dialogue System Trigger set to "On Start" that sends "OnUse" messages to every GameObject that has an "OnUse" trigger?
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Re: CHeck variables on Quest status change

Post by nathanj »

Hey Tony

I just realised that I still haven't resolved this issue. :roll:

I'm not sure that the DST On Start is the way to approach this. My apologies though if I am mistaken.

I'm pretty sure that my wording caused some confusion. When I said
However, because I am using the Dialogue System Trigger set to "On Use" and is registered every time an item is added to the inventory there is nothing to check the variable value on start
I meant when the quest starts, not when the item is generated.

Basically, is there a way to send a universal message for Quest State change, in a way similar to "Conversation Start" and "Conversation End"

Nathan
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: CHeck variables on Quest status change

Post by Tony Li »

Hi Nathan,

I'll approach this from two directions.

Checking Before Activating:
You could check the firewood variable before activating the quest. If the player already has enough firewood, immediately set the quest to success instead of active.

Events:
There are two ways you could use events:

1. In the Dialogue System Trigger that activates the firewood quest, add an OnExecute() UnityEvent action. Point this to the DialogueSystemTrigger.OnUse method of another Dialogue System Trigger that's configured like this:
  • Trigger set to OnUse.
  • Condition checks if the firewood variable is >= 3 and the quest is active.
  • If so, a Set Quest State action sets the quest to success.
So the first Dialogue System Trigger will set the quest active and then invoke the second Dialogue System Trigger. The second Dialogue System Trigger will check the firewood variable and possibly set the quest to success.

2. Alternatively, the Dialogue System Events component has a section for quest events. The On Quest State Change event has a dynamic option that can pass the quest name. To do the same thing in a script, you can write a script that has an OnQuestStateChange method. This method receives the quest name.

If you want to use Dialogue System Events, you could:
  • Add a Dialogue System Trigger component to some GameObject.
    - Set the Trigger to OnUse.
    - Set the Condition to check if the firewood variable is >= 3.
    - If so, add an action to set the quest to success.
  • Add a Dialogue System Events component to the Dialogue Manager. Point the On Quest State Change event to your Dialogue System Trigger's DialogueSystemTrigger.OnUse method.
Post Reply