Create a Quest Using Variables
http://i145.photobucket.com/albums/r228 ... enshot.png[/IMG]
Many thanks to Ccoa and Nidhogg for helping me fine tune this tutorial.
Purpose
A very common quest found in games involves having the player find a certain number of items or kill a certain number of monsters. This tutorial will provide a step-by-step guide on how to create this type of quest.
Demo
Prior Knowledge Needed
You will need to have some working knowledge on how to do the following in order to proceed with this tutorial.
Congratulations! You have successfully created a quest using variables. I hope this tutorial was helpful to you.
http://i145.photobucket.com/albums/r228 ... enshot.png[/IMG]
Many thanks to Ccoa and Nidhogg for helping me fine tune this tutorial.
Purpose
A very common quest found in games involves having the player find a certain number of items or kill a certain number of monsters. This tutorial will provide a step-by-step guide on how to create this type of quest.
Demo
Prior Knowledge Needed
You will need to have some working knowledge on how to do the following in order to proceed with this tutorial.
- create a new event
- create an npc
- create dialogue
- use self switches
- use conditional branches
- The first step is to decide what type of quest you would like to create. In this tutorial, we will be creating a quest in which the player must collect 5 apples.
- Before the player can begin collecting apples, he needs to be given the quest. To do this, create a new event. Select a character npc to assign the quest. Make up dialogue.
- I have selected a farmer's wife to give the quest. When the player talks to her, she will ask the player to collect 5 apples. *Okay, here is where variables come into play. After you assign the quest, click on control variables on the first page of event commands. Select an empty slot and name the variable.
- I chose variable 1 and named it 5 Apples. The name doesn't matter but it should be something that allows you to remember what it was used for. If you just name it "quest", you might forget which quest it was referring to.
- You then want to click on set (found under operation) and constant 5 (found under operand.) "5" is the total number of apples needed. As the player collects apples, we will count down to 0. When the player reaches 0, the player would have collected all 5 apples. This is outlined in detail later.
- After you have created a new variable, you will also need to create a switch. Pick a switch and name it. I selected switch 1 and named it "Apple Quest". Turn on this switch. This will prevent the player from collecting apples prematurely.
- Last, but not least, turn on self switch A. This is so that the farmer's wife will not give you the quest again when you talk to her.
http://i145.photobucket.com/albums/r228/yisuz/1.png[/IMG]
http://i145.photobucket.com/albums/r228/yisuz/2.png[/IMG]
http://i145.photobucket.com/albums/r228/yisuz/2.png[/IMG]
- After you create the quest, you need to set it up in the game. For this tutorial, I am only using one map. You can actually have the apples spread out over several different maps.
- To set up the quest, you will need 5 apple events. To make things simpler, you can create one apple event and just copy and paste 4 more.
- So, create an event with an apple graphic. I used the one that came standard with rmxp. It was in the icons folder so I had to export it, turn it into a charset and then import it into my characters folder. Basically, the only graphics that you can use with an event are from your character's folder or the current tileset. That is another tutorial for another day.
- After you have set up the apple graphic, set up a conditional event. Make the condition that the apple quest switch is on. If the apple quest is on, set it up so that the player receives the apple. You can add a music or sound effect and text. You also have the option of adding an apple to the player's inventory. Use the change items command to do this.
- It's variable time again. Go back into control variables and select the one you had previously named 5 Apples. Instead of set, click on the bubble next to Subtract. Instead of constant 5, set it to constant 1. This will subtract 1 apple from the 5 that you need. Refer to the example screen to see how I set this up.
- Also, you'll need to use another self-switch so that you can't get the apple again. And the second event page should have no graphic. Otherwise, the apple graphic will still be there even after you have collected it.
- Now what if the apple quest is off? Under the "else" statement, you can add text. I added the following: "It's an apple." This is in place so that the player cannot collect any apples until after the farmer's wife had given the quest.
http://i145.photobucket.com/albums/r228/yisuz/3.png[/IMG]
http://i145.photobucket.com/albums/r228/yisuz/4.png[/IMG]
http://i145.photobucket.com/albums/r228/yisuz/4.png[/IMG]
- After you have created 1 apple event, copy it and paste 4 more wherever you want.
- Now, you may be wondering, how will the farmer's wife know when I have collected 5 apples? That's where step 4 comes in.
- Remember the farmer's wife who gave you the quest? Go back to her. We are now going to work in the second events page using conditional branches.
- First, make sure that self switch A is a condtion for this event.
- Now, you have to set up a conditional event. I created two to keep things grammatically correct. You'll see what I mean later.
- Okay, set up a conditional event that the 5 Apple variable is equal to 0. Remember how we subtracted a variable of 1 for each time the player collected an apple? If the player collects 5 apples, and one is subtracted each time, then the variable should reach 0 when all is said and done.
- If this condition is met, the farmer's wife can thank the player and reward him. If you had chosen to add apples to the item inventory, make sure you subtract them from the inventory using the change items command. At this point, you need to also turn on self switch B.
- Then, you need to create a 3rd event page with a condition that self switch B is on. Keep the farmer's wife graphic. It would be weird if she suddenly disappeared after you completed the quest. Then, if the player decided to talk to the farmer's wife after already have completed the quest, she could thank the player again.
- Now, let's take a look at page 2 again. Remember I said that I had created two conditional events? Under the else statment, create another conditional branch. This time, set up a conditional event that the apple variable is equal to one. If this condition is met, the farmer's wife will say: "You still need 1 apple." If I had not included this step, the farmer's wife would have said: "You still need 1 apples."
- Under the final "else" statement, input the following: "You still need \v[1] apples." The "\v[1]" checks the number in variable one. So if you start with a constant of 5 and have collected 3 apples, 3 gets subtracted from 5. Then you should be left with 2. In that case, the farmer's wife would say: "You still need 2 apples."
http://i145.photobucket.com/albums/r228/yisuz/5.png[/IMG]
http://i145.photobucket.com/albums/r228/yisuz/6.png[/IMG]
http://i145.photobucket.com/albums/r228/yisuz/6.png[/IMG]