Restart quest in GTA like game.

Announcements, support questions, and discussion for Quest Machine.
Post Reply
RoachComrad
Posts: 5
Joined: Thu Jan 18, 2024 10:37 am

Restart quest in GTA like game.

Post 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!
User avatar
Tony Li
Posts: 20632
Joined: Thu Jul 18, 2013 1:27 pm

Re: Restart quest in GTA like game.

Post 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));
RoachComrad
Posts: 5
Joined: Thu Jan 18, 2024 10:37 am

Re: Restart quest in GTA like game.

Post 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?
User avatar
Tony Li
Posts: 20632
Joined: Thu Jul 18, 2013 1:27 pm

Re: Restart quest in GTA like game.

Post by Tony Li »

What happens when you use your custom button?

Are there any errors or warnings in the Console window?
RoachComrad
Posts: 5
Joined: Thu Jan 18, 2024 10:37 am

Re: Restart quest in GTA like game.

Post by RoachComrad »

No, nothing just happens
User avatar
Tony Li
Posts: 20632
Joined: Thu Jul 18, 2013 1:27 pm

Re: Restart quest in GTA like game.

Post 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.
RoachComrad
Posts: 5
Joined: Thu Jan 18, 2024 10:37 am

Re: Restart quest in GTA like game.

Post 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..
User avatar
Tony Li
Posts: 20632
Joined: Thu Jul 18, 2013 1:27 pm

Re: Restart quest in GTA like game.

Post 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.
RoachComrad
Posts: 5
Joined: Thu Jan 18, 2024 10:37 am

Re: Restart quest in GTA like game.

Post by RoachComrad »

Yes, I looked into my old code and immediately realized what the problem was. My bad.
Post Reply