Quest System

Hey all, I’m quite stuck on implementing a second quest without doing a hacky method. Here’s what I’ve got so far:

https://hatebin.com/pqmnsavghc
https://hatebin.com/essorairju
https://hatebin.com/ketkqkmntq
https://hatebin.com/vcawgteqny
https://hatebin.com/ofcmqstvpv

I’ve made Scriptable Objects for each quest, and a SO for the on-screen UI to display the quest. This is all hooked up with OnTriggerEnter(s) on the QuestGiver.cs script. It works great! However, I can’t understand how to make this dynamic in adding subsequent quests.
There has to be a way, or a better way to do this, but so far I can only think of making a new trigger zone for each quest, and making a new similar, but different, script for each quest - which obviously defeats the whole purpose the SOs in the first place really.

I’ve watched quite a few tutorials on this and read articles, but none have resonated with me in terms of what I’ve created so far. It may be that I need to erase all this and start fresh, but hopefully someone can guide me.

Well I guess if all your quests are identical, they could all fit into a single SO structure.

But I think perhaps something like this would yield more-usable results… and this is just to kinda of give you an idea of how I am thinking of orthogonal pieces of the puzzle.

A quest would consist of:

  • a series of tasks (1 to end)
  • a completion reward (item given, some flag unlocked, special animation, etc)

I’ll only address the task, leave the reward part unspoken:

A basic QuestTask could perhaps be only doable, or both doable and fail-able (might be two separate object types, or just have a boolean?)

Each task would have a completion notification, and possibly a fail notification

The quest itself would monitor triggering of that success/fail state within each task, and advance to the next task (or fail the quest)

So you could make a generic Task object that has an interface to handle the above. You wouldn’t make any of these, but you would make these:

You might have a “go here” variety of task object, triggerable by a script on a collider that sets the “yeah, you got here!” flag in that task.

You might have an “obtain this item” variety of task object, triggerable by your inventory gaining such an object

You might have a “talk to this guy” variety of task, triggerable as a step in a custom dialog branch only accessible once the task is taken

You might have a silent task object that simply sets a flag somewhere that unlocks fresh dialog, or spawns fresh NPCs to talk to, etc.

So the quest would be kind of the “script runner” and step it along through the list of tasks.

  • Go to the mill just after midnight
  • talk to the miller
  • go see the blacksmith
  • obtain the Amulet of Special Milling
  • return it to the miller.
  • earn 20,000 gold and all the cheesy bread sticks you can stomach

etc.

Thanks, Kurt. You’re always a help around here. I’m thinking even simpler than you have explained here. I just want to get the basics of a “quest system” implemented, that’s at least a bit dynamic in terms of being able to add to it in the future as I continue to learn more. My goal for this project is to have some kill quests and some fetch quests, such as:

  1. Go to trigger zone, quest UI dialogue appears, accept quest, quest objective UI appears. The quest itself is to shoot a target 10 times.
  2. Turn in prior quest at the same trigger zone, new quest appears following the same steps above. The quest itself would be to find a certain object, when you walk into the trigger that has that object, you could press a button to set that object inactive, but trigger a bool saying you have the object (as I don’t have an actual inventory system).

I have the first quest working perfectly, but I’m missing how to add subsequent quests with the code/format that I have.