Restart quest in GTA like game.
-
- Posts: 5
- Joined: Thu Jan 18, 2024 10:37 am
Restart quest in GTA like game.
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.
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)
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));
-
- Posts: 5
- Joined: Thu Jan 18, 2024 10:37 am
Re: Restart quest in GTA like game.
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.
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?
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>();
}
}
Re: Restart quest in GTA like game.
What happens when you use your custom button?
Are there any errors or warnings in the Console window?
Are there any errors or warnings in the Console window?
-
- Posts: 5
- Joined: Thu Jan 18, 2024 10:37 am
Re: Restart quest in GTA like game.
No, nothing just happens
Re: Restart quest in GTA like game.
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.
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.
-
- Posts: 5
- Joined: Thu Jan 18, 2024 10:37 am
Re: Restart quest in GTA like game.
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.
No worries! If there's still an issue, just let me know. It sounds like you found the issue and resolved it.
-
- Posts: 5
- Joined: Thu Jan 18, 2024 10:37 am
Re: Restart quest in GTA like game.
Yes, I looked into my old code and immediately realized what the problem was. My bad.