A quick and simple question

I'm new to VX Ace and I was wondering how to set an event to automatically respawn in a random location each time you interact with it. For example, I'm planning on making a large open world game with crafting, mining ore, collecting vegetables, and collecting herbs to make potions, etc. I plan on having these events scattered over the map and the goal is for the player to walk up and collect the mushroom (or whatever) and then when they interact with the event again it will respawn in a random location.

So far I have a mushroom event scripted, but I ran into a slight problem. The event respawns randomly once and then once you find that random respawn it will never change locations again. The player can just infinitely interact with the event and keep getting mushrooms. Is there any way to fix this? I'm hoping for a non-plugin solution if that is possible...THANKS SO MUCH in advance. I've been trying to fix this for a while...

Here's my small event script.
upload_2018-1-30_0-14-52.png
Not sure about a non script solution, but try this
https://yanflychannel.wordpress.com/rmvxa/utility-scripts/spawn-event/
or
look at these
https://www.rpgmakercentral.com/topic/14720-random-event-positions/
https://www.rpgmakercentral.com/topic/8177-xs-random-event-positions/
I can't see how your mushroom scripted event works to get the X/Y variables, but if it were me I would go with a semi-random system, which is what most of the big open world games actually do to make sure it never spawns in a wall or something. My personal solution would be heavy on copy-pasting, but script-free:


Set up an event at each of your potential spawn points, wherein the first page is Blank and non-interactive, but the second page is your Mushroom event. Mushroom Event 001, Mushroom Event 002, etc. Give that second page a condition that a switch is on - MSwitch001, MSwitch002, etc. You'd have to manually assign the switches so that event 1 uses switch 1, and so on.

Each mushroom event would, upon granting you a mushroom, run a common event wherein you generate a random number equal to the number of events you want to be able to handle - let's say, 50 or so - then uses IF cases to turn on the switch equal to the result. If RandomNumber == 5, turn on MSwitch005. Remember to turn OFF all 50 switches before doing this, so that only one of them winds up being ON in the end. As soon as the switches turn off, the mushroom you're looking at will vanish, and another will appear as ITS switch is triggered.

If you want to be fancy, you can add an additional IF case to check that the resulting number isn't equal to whichever event actually gave you the most recent mushroom - I'd do it by having a separate checker variable set up so each of those copy-pasted Mushroom events sets it to their own number, so that you could ask If Checker != 5, turn on MSwitch005, and stick the whole thing in a loop until it randomly picks something other than that most recent event's number. Or you could skip this step and accept that the player has a 1/50 chance of getting a bonus mushroom!


It's a bit of a brute-force method, but most things will be if you avoid scripting. If you want to use this method and find anything confusing, let me know. 😅
You are moving it to a new location based on the values in those variables. If those variables never change, then will keep respawning, but in the same location. You need to do something to change the variables.

Also, please use meaningful thread titles. Everyone who posts here has (or thinks they have) "a quick and simple question". It's very helpful to the people looking at threads if they can see what the question is about without having to go in to it.
I can't see how your mushroom scripted event works to get the X/Y variables, but if it were me I would go with a semi-random system, which is what most of the big open world games actually do to make sure it never spawns in a wall or something. My personal solution would be heavy on copy-pasting, but script-free:


Set up an event at each of your potential spawn points, wherein the first page is Blank and non-interactive, but the second page is your Mushroom event. Mushroom Event 001, Mushroom Event 002, etc. Give that second page a condition that a switch is on - MSwitch001, MSwitch002, etc. You'd have to manually assign the switches so that event 1 uses switch 1, and so on.

Each mushroom event would, upon granting you a mushroom, run a common event wherein you generate a random number equal to the number of events you want to be able to handle - let's say, 50 or so - then uses IF cases to turn on the switch equal to the result. If RandomNumber == 5, turn on MSwitch005. Remember to turn OFF all 50 switches before doing this, so that only one of them winds up being ON in the end. As soon as the switches turn off, the mushroom you're looking at will vanish, and another will appear as ITS switch is triggered.

If you want to be fancy, you can add an additional IF case to check that the resulting number isn't equal to whichever event actually gave you the most recent mushroom - I'd do it by having a separate checker variable set up so each of those copy-pasted Mushroom events sets it to their own number, so that you could ask If Checker != 5, turn on MSwitch005, and stick the whole thing in a loop until it randomly picks something other than that most recent event's number. Or you could skip this step and accept that the player has a 1/50 chance of getting a bonus mushroom!


It's a bit of a brute-force method, but most things will be if you avoid scripting. If you want to use this method and find anything confusing, let me know. 😅
thanks...this is a total lifesaver
Thanks 🙂 I'll make sure to check these out!

Original thread: https://forums.rpgmakerweb.com/threads/a-quick-and-simple-question.90627/