Allowing quests to have multiple solutions

I have a really quest system which is built around the observer pattern: there’s a Quest class whose only job is to act as a container for Objectives, a base Objective class that only contains an virtual bool IsComplete() function, and a bunch of Objective child classes which override IsComplete in different ways to represent the wide variety of logical conditions a quest might want you to satisfy.

Up till now I’ve maintained two arrays of objectives for each quest: one array contains all of the mandatory objectives that must be completed to finish the quest (“kill the orc general”), and the other array contains optional objectives that yield additional rewards, but don’t need to be finished in order to resolve the quest (“kill 5 orc warriors”).

I would like to make this a bit less linear, and allow you to complete a quest in different ways, or by combining objectives in novel orders (e.g. “kill the orc general” OR “kill the human general” OR “negotiate a truce” OR “kill the orc general” AND “kill the human general”). I could see allowing multiple different objectives to finish a quest by giving each one some EndsQuest bool, but I am completely stuck on how I could go about combining the same objectives in different combinations- am I missing something obvious?

See every quest as an independant quest and a reward for each.
Most of the quests will have as a reward another quest.

Use a “Quest” class, a virtual “Reward” base class and a virtual “QuestFinishEvent” base class

  • Quest is used to store quest datas for the player and a function “QuestCompleted”
  • Quest have one or multiple Rewards (ex: another quest and an item)
  • Reward will have a least “QuestReward” and a “ItemReward” sub classes
  • QuestFinishEvent is something very specific for each event you want to have to finish a quest.
  • You may have severals generic QuestFinishEvent “Kill Enemy”, “Go somewhere”, “Have items”…
  • Make an array in Quest of all his QuestFinishEvent and use a delegate into QuestFinishEvent to call QuestCompleted.
  • Disable all QuestFinishEvent concerned when a quest ended.
  • QuestFinishEvent may contains the reward since it depend on how the quest end.
  • QuestFinishEvent can contains more than one reward too.

If you want a very large and complete quest system, I suggest you to check if you can create your own nodal system for that.

Oh that’s interesting, so set the entire thing up as a formal node graph instead of the much simpler setup I was describing? That’s a neat idea, thanks for the suggestion :slight_smile:

A multi-branching quest can be complex, that’s why a nodal graph can make it easier to edit it.
By a nodal graph I just imagine connecting a quest to different events then to another quest.
Anyway, the logic I suggested is solving your problem since it can be way more versatile.

I see what you mean, that is much more flexible- thanks for the idea!