Page 1 of 1

Restart quest in GTA like game.

Posted: Thu Jan 18, 2024 11:21 am
by RoachComrad
Hi, I'm making a GTA like game using Quest Machines and Dialogue Systems. In the process of starting and completing quests, everything goes fine: a dialogue with the NPC begins, he gives the quest, but if the player dies or fails the quest, I need the whole process to start again: dialogue, start of the quest, etc. The quest must never be failed and must be started over again until it is completed. I'm sure there must be an easy way to do this, but I can't figure it out myself. Please, help!

Re: Restart quest in GTA like game.

Posted: Thu Jan 18, 2024 4:52 pm
by Tony Li
Hi,

How to handle quest failure:
In the Failure node's True state > Actions list, you can use SetQuestNodeState actions to reset all of the quest nodes to Inactive. Then set the Start node to Active. This will restart the quest.

How to handle death:
When the player dies, remove all quests that are still active (so the player needs to pick them up again from the quest giver) or reset them to their initial states. To remove all quests that are still active: (example)

Code: Select all

var journal = QuestMachine.GetQuestJournal();
var activeQuests = journal.questList.FindAll(quest => quest.GetState() == QuestState.Active);
activeQuests.ForEach(quest => journal.DeleteQuest(quest));

Re: Restart quest in GTA like game.

Posted: Mon Feb 12, 2024 10:39 am
by RoachComrad
Thanks for the help, I figured out the previous problem, but I suddenly had another one... In the game I have both Quest givers and NPCs with whom I can talk using the Dialogue system. To start a conversation, I use a custom button to which I assign my method.

Code: Select all

public class DialogueInteract : MonoBehaviour
{
    [SerializeField] private bool isNPC = false;
    private DialogueSystemTrigger startDialogueTrigger;
    private QuestGiver questGiver;

    private void OnEnable()
    {
        SelectComponents();
        
    }

    public void StartDialogue()
    {
        
        if (isNPC)
        {
            Debug.Log("Dialogue");
            startDialogueTrigger.OnUse();
            
        }
        else
        {
            Debug.Log("Quest");
            questGiver.StartDialogueWithPlayer();
            
        }

    }

    private void SelectComponents()
    {
        if (isNPC)
        {
            startDialogueTrigger = GetComponent<DialogueSystemTrigger>();

        }
        else
        {
            questGiver = GetComponent<QuestGiver>();
        }


    }
Everything worked fine until I started doing a quest where I needed to talk to an NPC. I thought it was enough to add a Dialogue Actor component to the NPC and assign it to the quest nodes.. and it works if I use the default E button on the keyboard, but my custom button does not start the dialogue anymore. Please tell me what am I missing?

Re: Restart quest in GTA like game.

Posted: Mon Feb 12, 2024 10:55 am
by Tony Li
What happens when you use your custom button?

Are there any errors or warnings in the Console window?

Re: Restart quest in GTA like game.

Posted: Mon Feb 12, 2024 11:22 am
by RoachComrad
No, nothing just happens

Re: Restart quest in GTA like game.

Posted: Mon Feb 12, 2024 11:42 am
by Tony Li
Hi,

Does your custom button call your script's StartDialogue() method? If so, then something should happen in the Console -- either "Dialogue", "Quest", or a warning or error message.

Re: Restart quest in GTA like game.

Posted: Tue Feb 13, 2024 7:41 am
by RoachComrad
I'm sorry, it's my mistake. I used to block conversations with NPCs during missions, but it was so long ago that I forgot about it..

Re: Restart quest in GTA like game.

Posted: Tue Feb 13, 2024 9:00 am
by Tony Li
No worries! If there's still an issue, just let me know. It sounds like you found the issue and resolved it.

Re: Restart quest in GTA like game.

Posted: Tue Feb 13, 2024 10:15 am
by RoachComrad
Yes, I looked into my old code and immediately realized what the problem was. My bad.