Schoeny Quest Engine

Schoeny Quest Engine is an engine which makes it easy for you to implement any sort of quest for your game in GameMaker:Studio 2. Quests can also include rewards.
– Easy to implement
– Completely script-based
4 types of quests you can implement:
– Item: Check whether a certain number of items have been collected
– Boolean: Checks whether a variable has been set to true
– Tracker: Check whether a certain number has been reached
– Parent: Add other quests to a parent quest
Each quest is given a unique ID number. Store this in a variable if you want to keep track of a certain quest.
Scripts to know
quest_setup() Initializes the quest engine.
quests_save([filename]) Saves all quests to a file. A custom filename is optional.
quests_load([filename]) Loads all quests from a file. A custom filename is optional.
quest_exists(questID) Checks whether a quest currently exists (and is not yet completed).
quest_is_completed(questID) Checks whether a quest has been completed.
Current Quests (non-completed quests) quest_get_name() - Returns the name of a quest quest_get_type() - Returns the type of a quest (i.e. questTypes.PARENT, questTypes.ITEM, etc.) quest_get_description() - Returns the description of a quest
Completed Quests quest_completed_get_name() - Returns the name of a completed quest quest_completed_get_type() - Returns the type of a completed quest quest_completed_get_description() - Returns the description of a completed quest
quest_add_item(name, item, num, description, rewards, [quest_id], [parent_quest_id], [main_quest]) Creates an Item Quest. Returns a quest ID. name - Name of the quest item - Item to be obtained for the quest num - Number of this item to be obtained description - A description of the quest rewards - Use the ds_list returned from quest_reward_create() [quest_id] - (Optional) Specify a custom quest ID for the quest (Default: -1) [parent_quest_id] - (Optional) If a subquest, specify the ID of the parent quest (Default: -1) [main_quest] - (Optional) Specify whether a main quest (Default: false)
quest_item_get_item(questID) Returns the item to be obtained for the quest.
quest_item_get_num(questID) Returns the number of items required to complete the quest.
quest_item_get_current_num(questID) Returns the number of items obtained thus far.
quest_completed_item_get_item(questID) Returns the item obtained for a completed quest.
quest_completed_item_get_num(questID) Returns the number of items obtained for a completed quest.
quest_add_boolean(name, description, rewards, [quest_id], [parent_quest], [main_quest]) Creates a Boolean Quest. Returns a quest ID. name - Name of the quest description - A description of the quest rewards - Use the ds_list returned from quest_reward_create() [quest_id] - (Optional) Specify a custom quest ID for the quest (Default: -1) [parent_quest] - (Optional) If a subquest, specify the ID of the parent quest (Default: -1) [main_quest] - (Optional) Specify whether a main quest (Default: false)
quest_boolean_get(questID) Returns the value of the quest's boolean variable (true/false).
quest_boolean_set(questID, value) Sets the value of the quest's boolean variable as either true or false.
quest_add_tracker(name, max, description, rewards, [quest_id], [parent_quest], [main_quest]) Creates a Tracker Quest. Returns a quest ID. name - Name of the quest max - The number that the counter must reach to complete the quest description - A description of the quest rewards - Use the ds_list returned from quest_reward_create() [quest_id] - (Optional) Specify a custom quest ID for the quest (Default: -1) [parent_quest] - (Optional) If a subquest, specify the ID of the parent quest (Default: -1) [main_quest] - (Optional) Specify whether a main quest (Default: false)
quest_tracker_get(questID) Returns the current value of the quest's counter.
quest_tracker_get_total(questID) Returns the maximum value that must be reached to complete the quest.
quest_tracker_set(questID, value) Sets the current value of the quest's counter.
quest_tracker_add(questID, value) Adds value to the current value of the quest's counter.
quest_completed_tracker_get_total(questID) Returns the maximum value that was reached to complete the quest.
quest_add_parent([questID]) Creates a parent quest. [questID] - (Optional) Specify a custom quest ID
quest_add_parent_add(parent_quest, quest_id, [pos]) Adds a quest to a parent quest as a subquest. parent_quest - The quest ID of the parent quest to be given a subquest quest_id - The quest ID of the subquest to be added [pos] - (Optional) The position in the list of subtests to add the quest
quest_parent_get_current(questID) Returns the quest ID of the current active subquest.
quest_parent_get_progress(questID) Returns the number of subquests completed in the parent quest.
quest_parent_get_total(questID) Returns the total number of subquests in the parent quest.
Setting up
quest_setup();You will also want an object that will run the following every step, or whenever most convenient.
quest_check_all();
Creating a quest
var quest_item = quest_add_item("Find Coconuts", items.COCONUT, 25, "Find 25 coconuts for the old lady.", -1); var quest_tracker = quest_add_item("Kill Some Skellies", 5, "Kill 5 skeletons.", -1); quest_add_boolean("Help Joey", "Help little Joey find his lost mouse.", -1, mainQuests.HELP_JOEY, -1, true);If you don’t want to give a reward for completing a quest, simply put -1 for that argument, as seen above.
Creating a parent quest
var parent = quest_add_parent(); var subquest1 = quest_add_boolean("Help Joey", "Help little Joey find his lost mouse.", -1, -1, parent); var subquest2 = quest_add_boolean("Guide Joey", "Help little Joey get back home before dark.", -1, -1, parent); quest_add_parent_add(subquest1, parent); quest_add_parent_add(subquest2, parent);
Rewards
In order to implement rewards, a few steps must be taken:
- In quest_setup(), add any desired rewards types to the rewardTypes enum.
- In quest_reward_give(), add your code for how each reward type will be given.
Your custom rewards can now be used in quests!
Creating a reward
A reward is made up of 2 different variables: its type and its data.
The data variable could potentially hold anything, from an integer to an array, so long as quest_reward_give() is able to handle that data properly according to the reward type.
Below is an example of how to create a reward which increases the game score by 200 points.
var reward = quest_reward_create(rewardTypes.SCORE, 200);
Multiple rewards can be packed into one reward, so long as they follow the pattern of type, data, type, data as shown below:
var reward = quest_reward_create(rewardTypes.SCORE, 200, rewardTypes.ITEM, [item.POTION, 3], rewardTypes.ITEM, [item.TORCH, 1]);
And below is how you would add a created reward to a quest:
quest_add_boolean("Help Joey", "Help little Joey find his lost mouse.", reward, mainQuests.HELP_JOEY, -1, true);
And that’s all there is to it! If you have any questions or concerns please let me know on Twitter: @JaredSchoeny