Home > Tutorials > RPG Maker VX > How to build Fetch Quest
How to build Fetch Quest 
This event allows you to have NPCs that send you on fetch quests for multiple items.
The event will look like this (~ are used for indentations for a clearer understanding of nested conditions):
-- --
Text: If you bring me 10 Stuff I'll do something neat!
Show choices: yes, no
~ : When [Yes]
~~ Loop
~~~ Conditional branch: [Stuff] in inventory
~~~~ Control variables: [0001] +=1
~~~~ Change items: [Stuff], -1
~~~~ Else
~~~~~ Conditional branch: variable [0001] >= 10
~~~~~~ Text: You have enough stuff!
~~~~~~ Control variables: [0001] -=10
~~~~~~ Change items: [Stuff], + Variable [0001]
~~~~~~ INSERT NEAT STUFF HAPPENING HERE
~~~~~~ Break Loop
~~~~~~~ Else
~~~~~~~~ Text: You don't have enough stuff!
~~~~~~~~ Change items: [Stuff}, + Variables[0001]
~~~~~~~~ Break Loop
~~~~~ Branch End
~~~ Branch End
~~Repeat Above
~: When [No]
~~ Text: Yeah, whatever.
~Branch End
-- --
What this event does is run a loop whenever it finds the right item in your inventory. When it finds the item, it removes it, adds 1 to a variable, then reruns the logic. If it finds the item again, it keeps going, adding 1 to the variable for each item it takes away. This gives you a total of how many of that item you had in your inventory.
Once the above process runs through all your items or just doesn't find any, it checks to see how many of that item were counted in the variable.
If you have the right number, you're shown some text to the affirmative. The script subtracts the number of items the NPC needs from the total items he took, then gives the rest back to you. At this point, you can insert whatever you want the NPC to do after he has the right number of items. Then the loop is broken and the event ends.
If you do not have the right number, you're shown some text that tells you to gather more. If you had items that were counted up, they are given back to you. If you didn't have any of the right item to take, nothing is given back to you since you had nothing to begin with (you bum!). Then the loop is broken and the event ends.
Follow this step by step process to create your event.
1. Create a new event with the action button trigger
2. Choose a collection dude graphic
3. Insert, Show Text
@>If you bring me 10 things I'll do something neat.
4. Insert, Choice
5. Within the yes option of the choice, insert a loop.
6. In the loop, insert a conditional branch if the item is in the inventory.
7. In this conditional branch, insert a control variable +1. (this will count up how many of the item you have in your inventory)
8. While still in the conditional branch, insert change items, -1 item. (don't worry, you'll get these back)
9. In the else statement of the first conditional branch, make a second conditional branch with a requirements that the variable is greater than or equal to 10.
10. In this second conditional statement, insert show text
@>You have enough items!
11. In the second conditional statement, insert control variable -10 (this subtracts the number you need from the number of the item you actually have in your inventory)
12. In the second conditional statement, insert change items +variable (however many extra items you had in your inventory over the required number are now added back)
14. In the second conditional statement, insert a break loop.
15. Wonder what happened to step 13.
16. In the second conditional statement, under else, insert show text:
@> You don't have enough.
17. In the second conditional statement, under else, insert change items +variable (this just adds all the items back if you didn't meet the necessary number)
18. In the second conditional statement, under else, insert a break loop.
19. Watch the bunny dance. Go bunny go! :bunny:
Now test your game, collect some stuff, and see what happens.
|
|
Details
|
|
Tutorial:
|
How to build Fetch Quest |
|
Date Listed:
|
2008-06-08 |
|
Author:
|
Mr_E_Man
|
|
Total Hits:
|
7731 |
|
|