Using the QuestManager Plugin

This tutorial will cover the basics of creating set quests for your games using the QuestManager plugin.

Download the source files for this example

In the example you collect coins by moving left and right using the A and D keys. There are two active quests, one to collect $20 and another to collect $50. When each of these is completed, the ‘Quest Completed’ sign is shown and the text in the top right of the game changes to show the new quest description.

Downloading and Adding the Plugin

Download the QuestManager plugin from here. One you have it installed, unzip the folder to the location of your game. We recommend containing all your plugins within a plugin folder. Inside the folder you will find two js files, a readme.txt and an example folder. Read through the readme.txt file to get an overview of the plugin. We will be using the questManager-1.0.0.js file for our game as it contains the plugin. There is also a minified version of the plugin if you prefer.

To add the plugin to our game we need to add it as a script to our html file.

We also need to add the plugin to our game’s options variable. Here we specify that we are using one plugin which is called ‘QuestManager’, which corresponds to the unique name located inside the plugin. This will boot the plugin and add it to our game so we can access it easily.

Now that we have added our plugin let’s look at how to use it.

What is a quest?

A quest is usually a set task that a player controlled character may complete in order to progress through the game or receive a reward. A quest, in Kiwi, takes one of two forms, a number quest or a boolean quest. Number quests are given a starting value and are completed when the current value reaches a specific number. These can be used in any number of ways, from trying to get a certain score, collect a number of items, kill all the enemies on the map etc. Boolean quests are either completed or not completed, and is completed when the value is set to the specific value, either true or false. These quests can be used for completing levels, defeating bosses, meeting characters, found a specific item etc.

Creating Quests

Quests can be created using the createQuest function. By default quests are set to uncompleted and non active, however the other properties: id, type, objective, current and a description, need to be set on creation. The id, a unique string, will be used to access this quest from the manager later on. We will also need to specify whether this is a number or a boolean quest by passing either ‘number’ or ‘boolean’ through as the typeVar. A starting and end value are also specified on creation, either in number or boolean form. Lastly a description string is specified. This can be used to tell the player how to complete the quest.

Starting Quests

Quests are not started by default, as their active property is set to false. Therfore to begin a quest use the startQuest function of the questManager. This can be done at the start of the game, for your main quests, or at any time during your game, for quests that begin later on. This allows you to create your quests all at once but be able to choose when to set them to active as the game progresses.

Updating Quests

Quests can never be completed unless they are updated and the values are changed. Quests can be updated every frame or when an event occurs. To update a quest call the updateQuest on the questManager and pass through the id of the quest to be updated, and a new value. Number quests will add the value specified to the current value of the quest, whilst boolean quests will change the current value to the given value.

Completing Quests

Quests are automatically completed when the quest is updated and the value set to the objectiveValue. Nothing happens when a quest is completed, but you can check to see if the quest has been completed using the checkCompleted function. Therefore in your update loop, you can check if the quest has been completed, and if so, do a certain task, such as reward the player, or begin a new level.

Active Quests

Quests are only set to active once they have been started using the startQuest function. This property is used to check whether or not a quest is in progress. Once complete, the active property is set back to false, as the quest is no longer in progress. Check the current active state of a quest by using the checkActive function. You can use this is your games to determine actions dependent on what the current quest is, npcs talking to you in game, for example.

Share the joy

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">