Quests and Milestones - jackdarker/TwineTest GitHub Wiki
We might need a way to keep track of our ongoing quests.
I setup a system like this:
- I have a collection of quests
- each quest has an ID (a unique name) and a name
- each quest has a collection of milestones
- a milestone has an ID (a number but could also be a name) and a description what the player needs to do
- the milestone also has a condition-check that needs to have a custom function assigned; this function will be triggered by the questsystem to check if the milestone is fullfilled and what is the next milestone-ID
- the condition-check will be evaluated whenever the 'tick'-function is called (whenever a passage is entered) thus requiring no manual checking each quest in each passage
- additionally there is the possibility to progress the quest state with a 'forceQuestMilestone' because it can be though to write a good conditional check
- milestone and quest also have a hidden-callback that can be used to hide them from the player
- a questlist-passage can be shown to display the ongoing or finished quests (unless they are hidden)
So we have:
- some simple Quest & Milestone-Object
- a QuestDefinition that needs to be hardcoded in the game, setting up all possible quests, their milestones and condition-check-functions
- a questManager-Object that operates on the QuestDefinition
- because the save system cannot restore objects with dynamic assigned functions, there is a helper-object 'questData' that stores the actual active Ids; only that will be used for persistance instead of the whole questManager
- after initing a new game or reloading a savegame, the questmanager needs to get hold of the questDefiniton as also the questData
With this system we can setup branching quests. But how about milestone that consist of multiple sub-milestones that need to be fullfilled or that are exclusive?
f.e.
- get entrance to the castle
- defeat the guard
and - pick the doorlock
or - climb above the wall unseen
- defeat the guard
Actually you can write a condition-check that does and/or evaluation like above. But since the milestone-text is statical defind in questDefinition, the text cannot be modified (you cannot display that the guard was already defeated). You could however split this up into 3 quests (but that is tedious):
- mainQuest: get into the castle somehow; has condition-check if quest1 or quest2 is finished
- quest1.MS1: climb above the wall unseen; condition check if you are inside the castle or mainQuest has already continued to next milestone
- quest2.MS1: defeat the guard;condition check if guard defeated or mainQuest has already continued to next milestone
- quest2.MS2: pick lock;condition check if you are inside the castle or mainQuest has already continued to next milestone