Home
Sitemap
Site News
Downloads
FAQ
Contact
• Basic Tutorials •
Maps
The Database
Events
Graphic Resources
• More Advanced Tutorials •
Maps
Events
The Database
Event Systems
• RGSS •
Script Fixes
Script Systems
• Other •
Using RMXP
Mini Tutorials
Miscellaneous
• Reference •
Reference

In this tutorial you will learn...

• How to make battles happen only in certain places
• A bit about using terrain tags


Hello again, and welcome to my Battles in the Grass tutorial! In this tutorial, I am going to tell you how to make random battles only happen at certain places in a map, rather like the systems seen in the epic Pokémon games. In this tutorial, we're also going to be looking at terrain tags a bit, and learning how those can be used for different things. So, without further ado, let's get going!

For this event system, you will need:
ê A common event
ê A switch
ê Two variables

Note: If you want to have a battle system where the troop is random also, you will need another variable. See my Random Troops tutorial for details on how to do this.

To start off, get yourself a large, clear map where you have space to walk around and space to put some grass where you can have the battles. Now, before we start with the eventing, we need to make a change in the database. So, go into the database and click onto the tilesets tab. Find the tileset that you would like to use for your map, and find the tiles that you would like to have random battles in when you stand on them. For me, I am going to use the grass tiles in the Woods tileset, here…



I probably won't use the little tufts, but I will use the large grass tiles. So, once we know which tiles we're going to use, we need to set the terrain tag. Unless you've done some experimenting of your own or read some of my other tutorials, you probably won't have used terrain tags before. So, click on to the button at the bottom of the list of tileset properties, and you'll see zeroes over all the tiles. Now, we want to set the terrain tag on our grass to something other than zero, so for the sake of simplicity, we'll set the terrain tag of all the grass pieces to 1. Okay? Here's what it should look like…



Okay, now we've done that, we can start doing some eventing. So, go to your common events tab, and create a blank pane, calling the common event Random Battles or something similar. Set the trigger to parallel; we want the common event to be running and checking the terrain tag all the time. Set the condition switch to a switch called Random Battles. Okay? Your page should look like this…



Right, now we can get on to the event commands. So, we have set the terrain tag so that it changes when the player is standing on a grass tile - but how do we use this within an event? If you've read my other tutorials involving terrain tags, you'll know that we can control a variable to be the players terrain tag. So, insert a control variables command and set it to a variable called Terrain Tag, and set the operand to being Player's Terrain Tag. See the screenshot below…



Okay? Now, when we've done that, we need to tell the event what to do when the player is standing on the grass - I.e. the terrain tag is equal to 1. Any ideas how to go about this? Yup - conditional branches. So, insert a conditional branch checking whether the variable Terrain Tag is equal to 1, and you can uncheck the 'when conditions don't apply' box. Your event now should look something like the following…



And that is how to do a basic terrain tag check. When you've got that, we obviously need to insert in the commands that will execute when the player is standing on the terrain tag - I.e. in the grass. You might think that we can just add in a Battle Processing command now - but hang on, we don't want our player to run into battle when he / she's standing still! So, we need to add in a conditional branch with the conditions being if Button is being pressed. Now, you might not have used this command before; it's on the fourth page within the conditional branch command, right at the bottom. I find it easiest to do them in order, so start with Button Down being pressed, like so…



With these branches, make sure that you uncheck the 'when conditions don't apply' box - to save space! Now we need to do the same for the other direcions. This time, we don't need to embed the conditional branches because we want the system to act on whichever condition matches first. So, below the bottom of the branch that you've just inserted, add in another conditional branch checking whether Button Left is being pressed, then below that, Button Right, and below that, button Up. Your event should now look like this…



You might think that we can put in a Battle Processing command now - but remember, this is a random battle system - and we don't want the player continually in battle whenever they press a directional button! So, we need a way of making the battles happen only every now and then, and we're going to do it using the good old random variable command. So, inside one of your button conditional branches insert a control variable command and set it to change a variable called Random Battle Chance, and set it to a random value between 0 and around 200. I find that this allows sufficient time between running into a battle, but makes them quite frequent. Copy and paste that into each button conditional branch, like so…



Okay, we're nearly there! After the control variable command, we obviously need to put in commands stating what happens when the random variable reaches the specific value. So, insert another conditional branch (last one now!) checking whether the variable Random Battle Chance is equal to 1 (you can choose any value between 0 and 199 that takes your fancy here), and make sure that the 'when conditions don't apply' box is unchecked. Now, in that conditional branch, we can add in the Battle Processing command. In case you've not used this, this is on the third page of event commands, right at the top. When you click on it, you'll get this box…



Now, this is pretty self-explanitory really - the troop is which set of enemies you'd like to make your player face, and the checkboxes below set whether something special should happen if the player escapes or loses. In our case, we want the battle just to function like a normal, random battle, so we're going to check the Can Escape box, but leave the other one blank (this will switch to the game over screen if the player loses, like normal). When we've inserted that, the command will have two branches - If Win, and If Escape. But because we don't want anything extra special to happen, we can just leave these both blank (unless you want something to happen). And we're done! We just need to copy and paste the Battle Processing command into the other conditional branches, and we're finished. Your final list of event commands should look like this…



And that's it! We're ready to try out our system. Bear in mind, however, that we'll have to find some way of turning on the switch before the system will work. You could do this in the beginning cutscene of your game so that the battles work for the rest of the game - but it's useful for turning off the random battles when you don't want them. If you want a mini-tutorial on how to get random troops for this system, then check out the Random Troops mini tutorial, and if you want to know how to turn on a switch automatically at game startup, then check out my Automatic Switches tutorial.

Congratulations; you've successfully made a selective random battle system! I'll see you in the next tutorial!

:: << Previous Tutorial ::      :: Home ::      :: Skip Ahead to Tutorial VI >> ::

RPG Maker XP © 2005 Enterbrain Inc.           © 2004 Xiph. Org Foundation           Ruby © 1993 - 2003 Yukihiro Matsumoto
This site, including images and textual content, were created by and belong to me.
© 2006 - 2011 All rights reserved.

This website and tutorials have all been written in my free time (what there is of it!), and hosting can be rather costly, so any donations are very gratefully received - no matter how small - even if you can spare 50p I would be grateful!