[RM2K3] [RM2K] PLACING EVENT RANDOMLY
Posts
Pages:
1
Let's say that you're looking for something. would it be harder, if that things location changed every time you need to find it? so what I'm saying is that an event will move positions every time you enter the map. But i don't have the slightest idea how to even start this. help
I figure it would need two things. One is "Set Event Location". The other would be the ability to randomize variables via "Control Variables". I'm fairly sure the latter can be done with those engines, but not-so-much the former. It's been a while, and neither of these engines are installed so I can't double-check.
Anyway, the sub-thought I'm having here is that you set one variable between 0 and one less than the map's width (this would be the x position), and another between 0 and one less the the map's height (this would be the y position). Once that's done, use "Set Event Location" and specify the event's location with those variables. This event-code would probably have to be some kind of parallel process that probably has to be enabled/disabled with a switch.
Though, this process does not take into account areas that are blocked off, or otherwise inaccessible. So, it might not be the solution you're looking for?
Anyway, the sub-thought I'm having here is that you set one variable between 0 and one less than the map's width (this would be the x position), and another between 0 and one less the the map's height (this would be the y position). Once that's done, use "Set Event Location" and specify the event's location with those variables. This event-code would probably have to be some kind of parallel process that probably has to be enabled/disabled with a switch.
Though, this process does not take into account areas that are blocked off, or otherwise inaccessible. So, it might not be the solution you're looking for?
ahh, thank you kindly. but how would one go about that? I'm still a newb to "move variable to location" and those types of commands. (Probably why it hasn't been working)
But my question is can you zone where they spawn? because if you can, it will leave me with more design choices.
But my question is can you zone where they spawn? because if you can, it will leave me with more design choices.
You might want to get the Terrain ID of where you're going to spawn this item first, before you do Set Event Location. If the Terrain ID is a passable square, it's liable that the player can get to it.
Set Terrain IDs in the Tileset tab of the Database.
Set Terrain IDs in the Tileset tab of the Database.
Ok Is there a tutorial on how to use these (I'm lost) I got the change the Terrain id of the tilesets to another one so when I have the coding (If it's technically called that.) they will spawn there. but how to get to that point. sorry, I'm so dumb :P
You're not dumb; it's kind of complicated.
The first step is:
In the database, designate the terrain IDs of tileset tiles. Or, if you're using Terrain ID to determine battle backgrounds, and you don't want to change any of the IDs that you already set up, just take note of the Terrain IDs on the tiles that the player can step on.
The second step is:
Go to your map. Make sure the tiles you can walk on are all accessible. (For example, don't use tiles that you built a fence around.)
The third step is:
Set up a new event to Auto-Start when the player enters the map. Inside this event, set a variable to a random number between 0 and the coordinates of the maximum width of the map. If your map is 64 tiles wide, then this range would be 0 to 64. This will be your random X coordinate. Next, take another variable, and do the same thing for the height of the map. That will be your random Y coordinate. Now, do the Get Terrain ID command using those two variables, the random X and the random Y. The result will be placed in a third variable of your choosing.
The fourth step is:
Now, you have to check to see if the terrain ID of that result is one of the ones that the player can access. Do this with a Conditional Branch. (If there's more than one kind of terrain that the player can walk on, make a Conditional Branch for each one.) Each Conditional Branch should essentially say, "if that Terrain ID result matches this number (of the terrain ID that I know that the player can walk on), then..."
The fifth step is:
If even one of them match, then, it found it! Inside each Conditional Branch's block, do a "Set Event Location" for the item event, using that random X coordinate and random Y coordinate that you set at the beginning. Then, set a switch that stops the Auto-Start. (Make a second page for this Auto-Start event that is just completely blank, with no Auto-Start there. Put this stopping switch in the trigger conditions.)
If the Terrain ID of the randomly-selected coordinates doesn't match any walkable terrain IDs, then the Auto-Start event will repeat until it finds one. This will usually be completed instantly, or so fast that you can hardly notice.
The first step is:
In the database, designate the terrain IDs of tileset tiles. Or, if you're using Terrain ID to determine battle backgrounds, and you don't want to change any of the IDs that you already set up, just take note of the Terrain IDs on the tiles that the player can step on.
The second step is:
Go to your map. Make sure the tiles you can walk on are all accessible. (For example, don't use tiles that you built a fence around.)
The third step is:
Set up a new event to Auto-Start when the player enters the map. Inside this event, set a variable to a random number between 0 and the coordinates of the maximum width of the map. If your map is 64 tiles wide, then this range would be 0 to 64. This will be your random X coordinate. Next, take another variable, and do the same thing for the height of the map. That will be your random Y coordinate. Now, do the Get Terrain ID command using those two variables, the random X and the random Y. The result will be placed in a third variable of your choosing.
The fourth step is:
Now, you have to check to see if the terrain ID of that result is one of the ones that the player can access. Do this with a Conditional Branch. (If there's more than one kind of terrain that the player can walk on, make a Conditional Branch for each one.) Each Conditional Branch should essentially say, "if that Terrain ID result matches this number (of the terrain ID that I know that the player can walk on), then..."
The fifth step is:
If even one of them match, then, it found it! Inside each Conditional Branch's block, do a "Set Event Location" for the item event, using that random X coordinate and random Y coordinate that you set at the beginning. Then, set a switch that stops the Auto-Start. (Make a second page for this Auto-Start event that is just completely blank, with no Auto-Start there. Put this stopping switch in the trigger conditions.)
If the Terrain ID of the randomly-selected coordinates doesn't match any walkable terrain IDs, then the Auto-Start event will repeat until it finds one. This will usually be completed instantly, or so fast that you can hardly notice.
You know, if you wanna make it a bit simpler for yourself, you could pick, say, 5-10 different spots for the event to appear and have it change based on a randomised variable each time you enter the room.
Not that a fully randomised event is too hard (as explained above), but this way you have a sort of idea where the event will appear and can plan around that, whilst still giving a general randomised feel for the player.
Not that a fully randomised event is too hard (as explained above), but this way you have a sort of idea where the event will appear and can plan around that, whilst still giving a general randomised feel for the player.
I would also suggest what Liberty suggested if you're having too much trouble with the system that was proposed beforehand.
author=Zachary_Braun
The fourth step is:
Now, you have to check to see if the terrain ID of that result is one of the ones that the player can access. Do this with a Conditional Branch. (If there's more than one kind of terrain that the player can walk on, make a Conditional Branch for each one.) Each Conditional Branch should essentially say, "if that Terrain ID result matches this number (of the terrain ID that I know that the player can walk on), then..."
Ok, I have a question I have it set but I'm confused on how to do the Conditional branch. so I have this for image ref
so what do I do? do i set a constant number or select my variable
Also, the light area is where i want the things to spawn. and my map is 20 by 30
author=Liberty
You know, if you wanna make it a bit simpler for yourself, you could pick, say, 5-10 different spots for the event to appear and have it change based on a randomised variable each time you enter the room.
Not that a fully randomised event is too hard (as explained above), but this way you have a sort of idea where the event will appear and can plan around that, whilst still giving a general randomised feel for the player.
How would I start? or go about it? I'm so sorry I'm fairly new to the complex parts of RPG maker.
author=creature129author=LibertyHow would I start? or go about it? I'm so sorry I'm fairly new to the complex parts of RPG maker.
You know, if you wanna make it a bit simpler for yourself, you could pick, say, 5-10 different spots for the event to appear and have it change based on a randomised variable each time you enter the room.
Not that a fully randomised event is too hard (as explained above), but this way you have a sort of idea where the event will appear and can plan around that, whilst still giving a general randomised feel for the player.
I think this might involve swapping places with blank events and the event whose location you want to randomize. The exact process of going about this in the specified engines, however, is a but fuzzy to me. ;_;
author=creature129
Ok, I have a question I have it set but I'm confused on how to do the Conditional branch. so I have this for image ref
so what do I do? do i set a constant number or select my variable
Also, the light area is where i want the things to spawn. and my map is 20 by 30
Hi creature,
In the first picture you showed me, the two variables weren't set to a random number. This is the important part. In the Variable Operations, there should be an option for setting a random number. Set it to 0-20 for the X and 0-30 for the Y.
In the second picture, you have to check to see whether the variable "Store" is holding the terrain ID that you want. This is a Constant number. A Constant number is a number that doesn't change; it's the opposite of a variable. I don't know which terrain IDs you've set, so this part is up to you. It could be 1, or 5, or 8. Whatever you've set that light part to be.
However, the light part you are showing me in the screenshot of your map is rather small. You could do Liberty's suggestion and just have the event appear at one of only a few places, since the area is so small. The suggestion I gave you is for when you want to hide an item in a huge field.
Additionally, the light area seems to be out of reach. There is a small piece of wall separating it from the rest of the map. Is that light area a window? Keep in mind that the player will need to be right next to an event in order to touch it. This means that you would need to have another event beneath the item that appears on the wall. This would make it possible for the player to interact with something that is out of reach. In this case, this event that appears on the wall would contain all of the logic; the item that appears in the light area would just be a graphic.
I'd like to help out this. So just to clarify, please tell me where you want the item to spawn randomly.
author=LordBlueRouge
I'd like to help out this. So just to clarify, please tell me where you want the item to spawn randomly.
The rectangle.
But Zachary, I will try it out and see what happens. Then come back with the results.
OK,
I'm quickly throwing something together in rpgmaker for ya, and I'll come back with the instruction. But just to clarify one last time:
You want an item to randomly appear in the rectangle of the room...

The reason why I ask is because. the rectangle is 70 spaces, including the 5 spaces at the top that's, 75 spaces the item could appear in total.
Let me know whether you want it to be 70 or 75 places and I'll follow through with the quick tutorial.
I'm quickly throwing something together in rpgmaker for ya, and I'll come back with the instruction. But just to clarify one last time:
You want an item to randomly appear in the rectangle of the room...

The reason why I ask is because. the rectangle is 70 spaces, including the 5 spaces at the top that's, 75 spaces the item could appear in total.
Let me know whether you want it to be 70 or 75 places and I'll follow through with the quick tutorial.
author=LordBlueRouge
OK,I'm quickly throwing something together in rpgmaker for ya, and I'll come back with the instruction. But just to clarify one last time:
You want an item to randomly appear in the rectangle of the room...
The reason why I ask is because. the rectangle is 60 spaces, including the 5 spaces at the top that's, 65 spaces the item could appear in total.
Let me know whether you want it to be 60 or 65 places and I'll follow through with the quick tutorial.
mius the wall's and the bench so
All you'd have to do for what I was talking about is make an event in each location you want the randomised event to be. Then you have a variable that changes each time you go into that room (Variable - Random number between 0-10 for example).
If that Variable = 0 then none of the events are turned on. If it equals one, then one of the events is turned on (you can do this with the page function of an event). If it equals two, the first event is blank but the second is on instead.
It's extremely easy. Lemme get some image examples (and it should be doable in every RM engine).
So this is the room in question.
I've only set up two events, but imagine that each dirt square has the same type of event.
Now this is the event that teleports you into this room.
As you can see it has the basic teleporting commands as well as a variable command. As the green text says, that variable command picks a number at random from 0-10 and which number it picks determines which page each of those events on the map show.
This is a closer look at how to set up the randomised variable. It's pretty simple. You give the variable a name so that you know which one it is, then make sure it's type is Set and let it pick between the numbers you want. In this case 0 to 10.
Each of the events on the map look like this to start with. They basically have 11 pages (this one has one extra for a reason I'll get into in a moment) and each one is like this, except that the number changes in the variable check, going higher each page. It HAS to be set from lowest to highest as the engine will only read the page that is highest and 'turned on'.
Basically, what happens is that when a number is picked, the page corresponding to that number is turned on, like a switch with more than two (on/off) settings. So it just says "turn page x on for us" and then runs what's on that page, but if you have both number 1 and 5 turned on, only page 5 will show as it's the highest in a row.
So if you have it set back to front, with the first page being set to 10 and page 11 being set to 0, because they check for x or higher variable number, it'd go "oh, 4 is set to on. But page 3 is after page 4 so we'll turn that on too. And page 2 is after 3, so we'll turn that on as well. And page 1 is after 2, so that gets turned on. And page 0 is after 1, so that's on now as well."
Basically it likes to count upwards, so just make sure your smaller numbers are on the left-most/smaller numbered pages and it should work just fine.
ANYWAY
Now we have an event with 11 pages. Pick a page that you want to have something on. Maybe you want an NPC to turn up in the fist dirt spot when the variable is set to 6. So you go to the page that corresponds with the number 6 and put in the eventing for the NPC there.
Like so:
Maybe you want a monster to appear in another event when the variable is set to 3, so you make the eventing on that page for that event.
Like so. Notice that these are two different events (name in top-left corner of them).
Now what if you want the same spot used for something else when a different number is rolled? You can do that. You can have, say, one event have three different occurrences based on which numbers are rolled. So you could have an NPC, a monster and a chest appear in one event, but only when certain numbers are rolled.
Oh, but what about chests? They have to stay open and get taken, right? And they need to show that as a graphic too!
Now we have a chest on the second event when the number 2 is rolled. Notice the switch is set to toggle? This will turn it on. What does that do? Well, you just copy this page and paste it straight after this one (just use the Copy Page and Paste Page commands at the top of the event page) and then do this:
Now the event has 12 pages instead of 11. That extra page basically just checks to see if that particular switch is on or off when the random variable is equal to 2 in this particular event. If it is on, it shows this page. If it is off, it shows the other page.
If you want to be able to grab a chest more than once, you can just toggle that switch off in the teleport event when you leave the room. Easy!
Hopefully this gives you a good idea of how easy it can be to make a room seem randomised with events, but really not be.
If that Variable = 0 then none of the events are turned on. If it equals one, then one of the events is turned on (you can do this with the page function of an event). If it equals two, the first event is blank but the second is on instead.
It's extremely easy. Lemme get some image examples (and it should be doable in every RM engine).
So this is the room in question.

I've only set up two events, but imagine that each dirt square has the same type of event.
Now this is the event that teleports you into this room.

As you can see it has the basic teleporting commands as well as a variable command. As the green text says, that variable command picks a number at random from 0-10 and which number it picks determines which page each of those events on the map show.

This is a closer look at how to set up the randomised variable. It's pretty simple. You give the variable a name so that you know which one it is, then make sure it's type is Set and let it pick between the numbers you want. In this case 0 to 10.

Each of the events on the map look like this to start with. They basically have 11 pages (this one has one extra for a reason I'll get into in a moment) and each one is like this, except that the number changes in the variable check, going higher each page. It HAS to be set from lowest to highest as the engine will only read the page that is highest and 'turned on'.
Basically, what happens is that when a number is picked, the page corresponding to that number is turned on, like a switch with more than two (on/off) settings. So it just says "turn page x on for us" and then runs what's on that page, but if you have both number 1 and 5 turned on, only page 5 will show as it's the highest in a row.
So if you have it set back to front, with the first page being set to 10 and page 11 being set to 0, because they check for x or higher variable number, it'd go "oh, 4 is set to on. But page 3 is after page 4 so we'll turn that on too. And page 2 is after 3, so we'll turn that on as well. And page 1 is after 2, so that gets turned on. And page 0 is after 1, so that's on now as well."
Basically it likes to count upwards, so just make sure your smaller numbers are on the left-most/smaller numbered pages and it should work just fine.
ANYWAY
Now we have an event with 11 pages. Pick a page that you want to have something on. Maybe you want an NPC to turn up in the fist dirt spot when the variable is set to 6. So you go to the page that corresponds with the number 6 and put in the eventing for the NPC there.
Like so:

Maybe you want a monster to appear in another event when the variable is set to 3, so you make the eventing on that page for that event.

Like so. Notice that these are two different events (name in top-left corner of them).
Now what if you want the same spot used for something else when a different number is rolled? You can do that. You can have, say, one event have three different occurrences based on which numbers are rolled. So you could have an NPC, a monster and a chest appear in one event, but only when certain numbers are rolled.
Oh, but what about chests? They have to stay open and get taken, right? And they need to show that as a graphic too!

Now we have a chest on the second event when the number 2 is rolled. Notice the switch is set to toggle? This will turn it on. What does that do? Well, you just copy this page and paste it straight after this one (just use the Copy Page and Paste Page commands at the top of the event page) and then do this:

Now the event has 12 pages instead of 11. That extra page basically just checks to see if that particular switch is on or off when the random variable is equal to 2 in this particular event. If it is on, it shows this page. If it is off, it shows the other page.
If you want to be able to grab a chest more than once, you can just toggle that switch off in the teleport event when you leave the room. Easy!
Hopefully this gives you a good idea of how easy it can be to make a room seem randomised with events, but really not be.
author=creature129
minus the wall's and the bench so
Okay, since it's a rectangle, this makes things infinitely easier, but keep in mind this won't apply to every situation and will change depending on the type of range of the area, you want the item to appear in.
What you'll need for this is:
2 Events*
2 Variables
*(I'm assuming you're also using an item that the player will acquire, that will function as an event, with this, so that will be the second event, so I've named that event "random item" for this tutorial)
1)What you first want to do is find the coordinates of where you want the item to be in RPGMAKER
This can be done by switching to the event layer and selecting an area with your mouse.
The coordinates can be found the bottom right corner of RPGMAKER:
Now, because the area you want to spawn the item in, is a rectangle, you'll want to find the maximum coordinates of this area, for x and y:
so for x, you'll want the item to spawn between coordinates 3 - 17
and for y, you'll want the item to spawn between coordinates 5 - 9

So x: 3 - 17
and y: 5 - 9
these are the numbers you're going to use when creating your variable operation
2)So, Create a Parallel Process Event: (This is the event that will randomly spawn the item)
Create an x variable, Call it "random item x coord" - set it to randomly choose numbers between 3 - 17:

Now, create a y variable, Call it "random item y coord" - set it to randomly choose numbers between 5 - 9:

Now here's where the magic happens:
3)Create a "Set Event Location" Command:

for "Event": Choose the item/event that you want to spawn. i.e. "random item"
for "Location" Select "Variable"
for "Map X" Select the variable you made for X: i.e. "random item x coord"
for "Map Y" Select the variable you made for Y: i.e. "random item y coord"
Now, to get the item/event to stop spawning, you will want to add an "Erase Event" Command.
Here's what your "random-spawning-location" event should look like once you're finished with it:

Now, for the most part, this tutorial is complete - how your item functions and how the player acquires it, is another tutorial entirely - but generally you'll want to stick to using switches to turn off item accessibility, as that's what professional jrpg developers have used for years as a way to keep track of treasure chests, etc.
But just to clarify, I've added a video, just to show what this random-item-spawn should look like, once you completed these series of commands, in practice - the last part of the video, is just to show what happens if you remove the Erase Event command.
Please let me know, if you were able to to get this work on your end, creature129 ❤
Ok, one more thing. sorry, I should have said this earlier. But. I'm using multiple events, sometimes they overlap one another. Is that fixable or not.
Yes, you should be able to use multiple events in the same area.
You just have to make a set of XY variables for each item you want to randomise.
After the variables of the first item are randomised and the item is placed, you randomise the next set of XY variables in turn.
You randomise the X variable of the second item and compare it to the X variable of the first item via a conditional branch.
If the variables are the same, you randomise the X variable of the second item again, until they are different.
You can achieve this by putting the conditional branch and renewed randomising inside of a loop. With the conditional branch set to break the loop once the X variables of both items are not the same.
You follow the same steps for the Y variable.
Here's an image of how the end result should look like:
I hope this helps!
You just have to make a set of XY variables for each item you want to randomise.
After the variables of the first item are randomised and the item is placed, you randomise the next set of XY variables in turn.
You randomise the X variable of the second item and compare it to the X variable of the first item via a conditional branch.
If the variables are the same, you randomise the X variable of the second item again, until they are different.
You can achieve this by putting the conditional branch and renewed randomising inside of a loop. With the conditional branch set to break the loop once the X variables of both items are not the same.
You follow the same steps for the Y variable.
Here's an image of how the end result should look like:

I hope this helps!
Pages:
1



















