Giving Quest via Code does not reset the Time Accepted count when game is restart?

Announcements, support questions, and discussion for Quest Machine.
Post Reply
Tenzho
Posts: 3
Joined: Wed Dec 22, 2021 5:03 am

Giving Quest via Code does not reset the Time Accepted count when game is restart?

Post by Tenzho »

Hi, I have come across a weird behaviour from Quest Machine.

Basically I have a Quest Giver Manager, that gives the player a quest manually via code. It only has the Quest Giver component, and my custom Quest Giver Manager script something like this:

Code: Select all

using PixelCrushers.QuestMachine;
using Sirenix.OdinInspector;
using UnityEngine;

public class QuestGiverManager : MonoBehaviour
{
    private QuestGiver _questGiver;
    [SerializeField] private string _questerIdToGive = "Player";
    [SerializeField] private Quest _questToAdd;

    [Button]
    private void GiveQuest()
    {

        _questGiver = GetComponent<QuestGiver>();
        _questGiver.GiveQuestToQuester(_questToAdd, _questerIdToGive);
    }
}
When I start the game in unity and run the Method GiveQuest(), it works for the first time.

But, when I stop and play the game again, the quest is automatically deleted from the QuestGiver's quest list. I found out that this is because the timesAccepted of the Quest is saved in the system and it will only work again if increase the "Max Times" of the quest to a high amount, OR I reset the timesAccepted of the quest manually like this:

Code: Select all

    private void OnEnable()
    {
        _questToAdd.timesAccepted = 0;
    }
Is it intended to be working like this, as I figure the timesAccepted of a quest should be save manually in the save file?
User avatar
Tony Li
Posts: 20632
Joined: Thu Jul 18, 2013 1:27 pm

Re: Giving Quest via Code does not reset the Time Accepted count when game is restart?

Post by Tony Li »

That's the intent. If the quest's Max Times is 1 and you give the quest to the player, you can't give it again.

In the next QM version, as an alternative to setting Max Times to a high value you can tick an "Infinite" checkbox.
Post Reply