Posted April 09, 2023 by HeavensGates
Welcome back to the continuation of our Questing system!
We've been hard at work on the quest system, which is one of the more complicated features of our game. We want this to be truly modular and customizable so a lot of different features are necessary to make it complete. In this tutorial, we'll be focusing on how to progress quests by interacting with non-player characters (NPCs). As a note, I won't be going into the details of the dialogue system, as you can find that on our GitHub if you're curious!
To make this happen, we had to do some significant refactoring of our existing code. We made a lot of changes to streamline the quest manager and separate its tasks. Now, a separate script assigns tasks to other scripts based on the quest objective. In our previous tutorial, we covered an item objective, where we checked if the player had enough of a specific item in their inventory.
But here's where it gets really interesting. We needed to find a way for an NPC to know when a player has a quest that is tied to them. So, we created an NPC spawner. This allowed us to create a data set that holds all the information of a specific NPC and build it with that information. This drastically reduces the chances of user error when creating an NPC.
The component that spawns the npc and the data that it holds
Now, if you take a look at our NPCs, you'll notice that each one has a unique ID, which is crucial for our quest system. With this ID, we can easily reference an NPC and determine if they are tied to a quest. Additionally, the quest now also contains the dialogue that represents the quest. For example, in our example quest for gathering mushrooms, the dialogue would be something like "Here are the mushrooms" when the player hands them over.
A quest that now can hold an NPC's information as well as what they say for the quest
And voila! The quest progresses. In this example, we simply complete the quest when the player hands over the mushrooms. However, you might notice in the video below that we don't yet have a contextual setup to determine whether the player already has the quest or not and the NPC responding accordingly, but we'll be covering that in one of our next updates. So, stay tuned for more!
And that's a wrap on part three of our quest system tutorial. We hope this has provided you with some inspiration for your own future quest system. If you have any questions, feel free to ask in the comments below!