Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Create a Quest Using Variables

Status
Not open for further replies.
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.
  • create a new event
  • create an npc
  • create dialogue
  • use self switches
  • use conditional branches
Tutorial

  • 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]
  • 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]
  • 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]
Congratulations! You have successfully created a quest using variables. I hope this tutorial was helpful to you.
 
Very nice
G4N Approved!
Hopefully this'll lower the number of people posting
'lol klkt thng 4 qst'
actually not hopefully... definitely.
You're not on the list anymore...
 

Anonymous

Guest

There is a somewhat simpler way to do that last event:
Code:
>Conditional Branch: Variable [0001]: 5 Apples == 5
  > Text: Farmers Wife:  blah blah blah congrats
  > Control Self Switch: B = ON
: Else
  > Control Variables: [0002] Remaining Apples = 5
  > Control Variables: [0002] Remaining Apples -= Variable [0001: 5 Apples]
  > Text: You need \v[1] more apples.
: Branch End

Same concept, but slightly quicker to implement and edit later.
 
Thanks. I'm actually a little unsure of how to control variables within variables. I've updated the first post with your alternate method.

**EDIT**
Let me see if I understand this. You created a second variable and set it to a constant of 5 (the total number of apples needed). You then subtracted variable 1 to get the number of apples that still need to be collected.
 
There's still a way using only one variable...

what you have to do is initiate de variable with 5, and subtract, instead of increase it...

and then you place this event
Code:
> Control Variables: Variable [0001: 5 Apples] -= 5
> Control Variables: Variable [0001: 5 Apples] *=  -1
> Conditional Branch: Variable [0001: 5 apples] == 0
     > Text: Famer's wife: blah blah congrats
:    Else
     > Text: You need \V[1] more apples...
:    Branch end

this way you spend a bit less memory in the event... It's usefull in the future...
 
Okay, so you're saying to start with 5 and then subtract one apple each time a player collects the apple? So, if a player finds 2 apples, the variable would be 3 because that's how many apples are left. But then, if I'm understanding this correctly, 5 gets subtracted from 3 to get -2, which is then multiplied by -1 to get a positive value of 2. But wouldn't the 2 represent the number of apples that are collected and not how many are still needed? And then wouldn't changing the variables affect the number of apples that were actually collected?

With any task, there is more than one way to accomplish it. If you are reading this, use whatever method makes the most sense to you.
 
ops... wrong code hehehe

I was trying first to do it from the variable beeing increased, but it didn't work and I forgot to recriate the code... ¬¬

here you are
Code:
> Conditional Branch: Variable [0001: 5 apples] == 0
     > Text: Famer's wife: blah blah congrats
:    Else
     > Text: You need \V[1] more apples...
:    Branch end
 
Oh. Your way is actually much easier. I'll update the first post when I have time. It might be a while because I would have to edit the directions, update the screens and upload a new demo.
 
Very very nice :) im very new to this and that showed me a lot about switches and how to change things in my heros items and everything else

To someone as new as i am to it that was very helpfull! :D
Thank you!

I guess the only thing i would like to ask is that when i upload the apple to the characters folder it only shows up with a small white box i cant make the box big enough when i up load it to get the full apple all i get is a small red box .. i know its right under my noses but could i maybe get a little help with it please :) thanks!
 
I see :D thank you very much .. been checking to see if someone would say anything about that haha .. thanks a lot for helping me to understand how to use that a little better .. :)
 

Jason

Awesome Bro

No problem :)
Also, The Seeker, if you'd like some Tutorials, I have a few tutorials I posted, search for 'A Few Tutorials' by me, they might help you abit.
 
I do everything on page one and when I start the game
A. The farmer's wife is already on page 3 of the events
B. The apple graphics are not there
C. I start the quest, pick up the apples, graphics stay and farmer's wife does not read me picking them up.


P.S. Your demo link is broken...
 
A. Make sure that you check the condition switches on the left side of the event page. Refer to the example screens. If the farmer's wife is on page three, I'm guessing that the condition switch has not been checked.
B. Copy and paste the graphic that jbrist posted into your character sets folder using your material base.
C. Again, make sure that the condition switches have been checked.

I tried the demo link and it is still up.

All I can say is to look at the example screens and recreate what I had posted.
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top