In the game world, the term “quests” can be described as tasks which the player can accomplish in order to get further in the game and receive some kind of the reward. All the tutorials can be seen as the mandatory quests. The quest is able to contain the list of the single tasks, but for simplicity, there is only one task per quest.
Tasks are usually defined by the game designers and are described through the unlocking requirement, goals or completion requirements and rewards. In some cases, it is great to provide the task cancellation requirements.
There are some requirements of making the questing system. The first one is unlocking requirement. This kind of thing is mainly based on the game state or player progress. It is stated that the simples requirement s level or XP, but it is also very common to chain unlocking of the quest to the resource or the certain interaction.
The first one is cancellation requirement. Please avoid some basic quests when the player is too advanced. If you introduce the quest for the beginners, you will set the unlocking requirements in the way that advanced player will also met. However, you do not want the advanced players to do the basic tasks.
The third one is completion requirement. Those include game state based and Ad-hoc actions. For instance, you are building the farming game and you have the quest based on apples. In the game state based one, the quest is complicated, when the player have 2000 apples. If all the apples are consumable resource, the player would have to stop consuming it and keep harvesting apples until she or he has 2000 of it.
How do you implement the quest system with ECS? Some people believe that data can be divided into three categories. The first one is configuration, the second one is the game state, and the third one is runtime data. In case of quests, you need to use all three of those categories. The definition of the quest itself is stored as the configuration. Apparently, In progress, done and Canceled quests are stored as the game state.
At the game initialization, you would go through the configuration and make the set of “pending” and “in progress” quests, according to the quests already persisted in the game state. You can also check if you can store the new quests as canceled. At the runtime, you need the set of recreatibe systems, that will monitor the relevant parts of the game state and transform the pending quests to unlocked and if possible to in progress. Please take a note that every quest based on ad-hoc actions will have the components storing the progress. You need another set of reactive systems that monitor the game state and user interactions in order to complete the quest or at least change the quest progress in case of ad-hoc actions. When the quest moves to done, this one will be persisted in the game state.