A quick and simple question

Openworld

Villager
Member
Joined
Jan 14, 2018
Messages
10
Reaction score
0
First Language
English
Primarily Uses
N/A
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
 

Rhaeami

The Sleepy-Eyed One
Veteran
Joined
Jun 2, 2014
Messages
252
Reaction score
178
First Language
English
Primarily Uses
RMVXA
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. :kaoswt2:
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
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.
 

Openworld

Villager
Member
Joined
Jan 14, 2018
Messages
10
Reaction score
0
First Language
English
Primarily Uses
N/A
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. :kaoswt2:
thanks...this is a total lifesaver
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,050
Messages
1,018,548
Members
137,835
Latest member
yetisteven
Top