Quests Conditions applying only once?

Announcements, support questions, and discussion for Quest Machine.
Post Reply
NicoMozes
Posts: 22
Joined: Sun Jun 05, 2022 4:18 am

Quests Conditions applying only once?

Post by NicoMozes »

Good morning Toni,
I hope you are well!

I am trying to set some farming quests to be dependent on the time of the day. A mission to plant some crops, that can only be offered by the quest Giver, when a Lua Variable TimeOfDay is = to an int between 0 and 3. (0 = morning, 1 = Midday, 2 = Evening, 3 = Night)

I have the code done to update this variable at runtime, and its all good, however, the mission availability is not working as intended.

I have the mission with the following condition:
Lua Variable TimeOfDay == 1.

The game state begins with TimeOfDay at 0. I click a button to fast forward time to the next slot, and I update the variable at this point via script:
DialogueLua.SetVariable("TimeOfDay", desiredTime);

This updates correctly. The quest becomes grantable and all good.

The problem comes when the time moves again, the variable TimeOfDay has changed, but the quest remains grantable.

Is there a better way to do this? To make quests dependent on the time of the day?

JFI im using Azure Dynamic Sky for the time and weather.

Thanks for the help as always!
Nico
User avatar
Tony Li
Posts: 20735
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quests Conditions applying only once?

Post by Tony Li »

Hi,

When a quest's offer conditions become true, the quest marks itself as offerable and then stops monitoring the offer conditions -- so it won't know that it's past the time when it can offer the quest.

Here are a couple of ideas:

- Since you're using the Dialogue System, check it in a Dialogue System conversation. When the player interacts with the NPC, start a DS conversation. Check the Lua variable and branch accordingly.

- Or make a subclass of QuestGiver and use it for this NPC. Override GetOfferableQuests(). Call base.GetOfferableQuests(). Then loop through each of the quests. Set the quest state to WaitingToStart. Then call its quest.offerConditionSet.StartChecking(quest.BecomeOfferable) method. Then check if the quest is still offerable. If not, remove it from the offerableQuests list. One catch here: This only works if your quests use offer conditions that immediately check their conditions when told to StartChecking. If the quest's offer conditions wait for a message from the message system, it of course won't receive that message again, so it won't become offerable.

- Or, perhaps simpler, override GetOfferableQuests(). Instead of setting quests to WaitingToStart and re-running StartChecking, just check the quest's offerConditionSet for Lua conditions. If it has any, use Lua.IsTrue to check if the Lua condition is still true. If it's false, remove the quest from the offerableQuests list.
NicoMozes
Posts: 22
Joined: Sun Jun 05, 2022 4:18 am

Re: Quests Conditions applying only once?

Post by NicoMozes »

Hi Toni,

Ok thanks for the info and the couple of Ideas.

I will look into it : )

Cheers,
Nico
User avatar
Tony Li
Posts: 20735
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quests Conditions applying only once?

Post by Tony Li »

Glad to help!
Post Reply