Gw Temp


Tutorial - 'Event Location Within A Radius' by Guest

An item about RPGMaker 2000 posted on


Need to set an event location with in a certain radius? This tutorial is the one you need!


-This was made on RPG Maker 2003, though it could be easily reversed onto RPG Maker 2000.
-Also, although this tutorial seems long, it'll actually only take a couple minutes to make, if not, less.

Hello all, this is my first tutorial... so lets get crack'en!

In this tutorial, I'm going to teach you how to set an event's location to a random spot within a certain radius.
This can be simple, or complicated. If you just want a flat, rectangular area for your radius, then its going to be relatively simple. But, if you want to have a irregular polygon-shaped figure, with possible spaces within that the space can't land on, then it may get to be a little bit complicated. But first, lets start by making a simple test map to do this on.

Lets make a map with dimensions of 20 by 16. Put a fence on the outside perimeter, and every space inside is subject to be chosen for the space's landing.

Now make an event called 'Space' and set it on the fence somewhere, or just any area where the hero can't touch, and set it to Below Hero with no image. Make the event start on Touched By Hero. You If you want the space to be hidden, don't give it an image. can give it an image if you'd like to, it would make it much more easier for testing purposesto find it if you did.

Now lets make a new event and call it "Space Setter"(Lol, it's not a very good name, but hey, its testing! =D). Set its starting conditions to Auto Start. Make two variables, call them Space X and Space Y. Now, since we are trying to make the space appear in the area within the fence, we want it to appear within these four x/y coordinates: 1,1(top left corner), 18,1(top right corner), 1,14(bottom left corner), and 18,14(bottom right corner). Go to variable operations and select Space X, and make it Set Equal to Random Number Between 1-18. Go to variable operations again and select Space Y, and make it Set Equal to Random Number Between 1-14. Next, make a Change Event Location, and make it change the Space event to the variables Space X and Space Y. After that, make a switch called Go Find It and check it as ON. Finally, make a new page on that code and check the switch Go Find It as ON in the Preconditions, and set it to Action Key.

Now its time to code the Space event so that when you step on it, it resets itself to a new place. This one is real simple, just put a Switch Operations in the code and have it turn ON the switch Go Find It. Make sure the Space event is set to Touched By Hero.

-------------------- Additional Stuff! --------------------

To make sure that when the space will not be placed in the exact same spot as it was before when it resets itself, we will make two more variables, call them Temp X and Temp Y. In the space for the code, before the Switch Operations, make a variable operations and Set Temp X to the Space's X coordinate, and Set Temp Y to the Space's Y coordinate. Again, make sure you put these two lines of code BEFORE the Switch Operations code.

Now go back into the Space Setter event and add a label before ALL of the code, so it's the very first line. Directly after the two lines of code that set the x and y coordinates and before the command that changes the events location, add a fork condition and set its condtions to Space X = Temp X. Make another fork inside of that fork condition and set its conditions to Space Y = Temp Y. Inside of that fork, put a Jump to Label command and have it jump to label 1. There, now it will NOT be placed on the same space twice, and since you were standing on that space too, it wont spawn under you either.

Care to add some more additional stuff? How about making spaces WITHIN the area that the Space event CAN NOT land on?
For instance, lets make one tile that is a WATER tile, or anything else that you can't step on, and put it on the space with the coordinates of 3,4(x,y). Now go back into the Space event's code and put a new fork condition after the first one, and have its conditions set to Space X = 3, and another fork within that fork and have its conditions set to Space Y = 4. Within the second fork, make another Jump to Label command and have it jump to label 1.

If you want to add additional space events, do the exact same thing to the second one, perhaps copy and paste, but change the Go Find It switch to Go Find It2 just for the second or something like that. Also, change the Space X and Space Y to Space2 X and Space2 Y just for the second one as well. You don't have to change the Temp X and Temp Y, afterall, they are only temporary. Finally, make another 2 sets of fork conditions checking to see if the second one has spawned on top of the first one, and if the x and y coordinates of both match, then have it jump to label 1 again - do this for both of them.

There, thats all there is to it, and if you want to play a sample version with more complex areas within the radius that the Spaces cannot be places on, then try this:

Hopefully this link works, just highlight it and copy and paste it into the address bar.