Spawning events next to each other

Hi all,

I am using visustella events movement core to spawn events in random locations marked with regions.
Is there any way once I have spawned an event to a random location I can spawn a 2nd event next to that event? Or how I workaround by moving an existing event next to the spawned one if that makes sense.

I am using location variables and get location info but can't get my head around how to set it up for other events.

Thanks
Greetings @Rkyfat,

Try this:

spawn pic.png


Fill out the rest of the spawn details per your requirements.

Happy game making,
-Niniann
Perfect thank you!
Hi, I have another slight problem with this. Whilst the the events spawn next to the event (as I needed) when I spawn the original event they spawn next to the original event not the spawned event...if that makes sense! How do I get the ID of the spawned event to assign the coordinates to as outlined above?
Hi, I have another slight problem with this. Whilst the the events spawn next to the event (as I needed) when I spawn the original event they spawn next to the original event not the spawned event...if that makes sense! How do I get the ID of the spawned event to assign the coordinates to as outlined above?
Hello again!

I'm not entirely sure I follow. When you spawn the original event, can't you simply give it the exact coordinates you want it to spawn at? I'm not certain what you mean by "the original event spawns next to the original event".

If you want a third event to spawn adjacent to the second event, just get the coordinates of the second event into the variables the same way you do when you get the coordinates for the first event, just have the target of the variable collection be event #2.
Hello again!

I'm not entirely sure I follow. When you spawn the original event, can't you simply give it the exact coordinates you want it to spawn at? I'm not certain what you mean by "the original event spawns next to the original event".

If you want a third event to spawn adjacent to the second event, just get the coordinates of the second event into the variables the same way you do when you get the coordinates for the first event, just have the target of the variable collection be event #2.
Hi, thanks for coming back. I probably could have been clearer! The original event I want to spawn in from a different map. I then want to use the above you provided to spawn another event next to it. The issue I am having is I can't locate the ID of the 1st spawn event to set the x, y coordinates against. Using 'this event' doesn't seem to work.

I have found a workaround by placing multiple events of the 1st event on the map and using conditional event to set them to a random position. I can then spawn the 2nd event per above next to them. However, would still be useful to know how I get the event ID of a spawned event as using conditional event to set random positions is a lot of lines!

Hope that makes more sense and happy to provide screenshots etc if that would help
I have found a workaround by placing multiple events of the 1st event on the map and using conditional event to set them to a random position. I can then spawn the 2nd event per above next to them. However, would still be useful to know how I get the event ID of a spawned event as using conditional event to set random positions is a lot of lines!
If the spawner was someone else's that was not VisuStella you could look at what code structure it was using to store the spawned events and just get the last entry. Otherwise, you'll need to do something like a autorun/parallel first page of the spawned event to make it store its own event ID in a variable then self switch to the next page. Or maybe VisuStella comes with a script in their spawner to do that.
I think I understand now, so the issue is because you're transferring Event A from Map B to Map A, you can't get the coordinates of Event A.

As AquaEcho said, you could just have Event A store its own event ID into a variable beforehand, and then reference that variable for your spawn events on Map A. However, I'm not sure that will work if you're transferring an event between maps unless you ensure that there is no duplicate event id on Map A?

If you want to try it, I believe the code you would need would be:

$gameVariables.setValue([your variable number here no brackets], $gameMap.event([your event's id here no brackets]).eventId())

Here is an example without the extra words:

$gameVariables.setValue(1, $gameMap.event(1).eventId())

Autorun this on the first page of your event on Map B and it should store it's id into a variable. Remember to put a self switch after this script to move to a different page.


Personally, I would recommend you simply not transfer Event A between maps, and just create a new "Event A" on Map A that has the information you need it to have. What is special about the event on Map B that you cannot make an event on Map A with the same art that will fulfill the same function? You can use the code above to store that eventID and roll from there.

If you do it this way, you can easily access the ID of the event and not have to go through as much work to make events referencing it to function.

Original thread: https://forums.rpgmakerweb.com/threads/spawning-events-next-to-each-other.165142/