Random Event Positions

This script allows you to randomize an event's position when you enter the

map. Regions are used to designate the tiles where an event can appear.



Download

Get it at Hime Works!

Installation

Place this script below Materials and above Main

Usage

To designate an event page where the event's position is randomized, create

a comment and write

<random position region: x type>For some region ID xThe type determines when position randomization occurs

start - only once: when the event is first createdinit - whenever the event is createdpage - whenever you change to that pageIf that page is active when the map is loaded, then the event will be randomlymoved to a tile in that region.

This is applied to events on a per-page basis, so you may need to add the

comment to multiple pages.

It's like you're reading my mind. This fits perfectly in my game. I'll try it out tomorrow but I'm already thankful for it 🙂
Really great! Does the comment need to be at the beginning of the page? or doesn't it matter where it is as long as it is executable?

For example, if I had a conditional statement in the event page I might do something like:

if condition is true   Comment: <random event position: 1>else   Comment: <random event position: 2>endifIs that possible? or would I have to use multiple pages for that to work?
@light it doesn't behave like a script call I believe, so if anything you would have a conditional that switches pages to the correct position, quite possibly an external autorun/parallel process event or common event.
Really great! Does the comment need to be at the beginning of the page? or doesn't it matter where it is as long as it is executable?


Is that possible? or would I have to use multiple pages for that to work?
The comment appears anywhere on the page.


You will need multiple pages if you want to use conditions. My comment parser is not smart enough to evaluate conditional branch commands.
The comment appears anywhere on the page.

You will need multiple pages if you want to use conditions. My comment parser is not smart enough to evaluate conditional branch commands.
Ok. Noted. 🙂 Will use multiple pages for that 🙂
Updated script with an extra argument to the comment

<random position region: 3><random position region: 3 init><random position region: 3 page>If you write page, the position is randomized whenever you change to that page.If you write init, or don't write anything at all, it will just be randomized only when the event is created.
Not sure why I'm getting this error:
 

Line 172: NoMethodError occurred.

undefined method: 'random_position?' for nil:NilClass

Seems to only happen when there's an autorun on the map.

EDIT: Wow, that is really really weird. It works fine in a new project.

I deleted every custom script on my current project, and it still gives me that error.

Edit2: on further review, even with a clean game it does not work if any event has a condition.
Thought that issue was addressed before but maybe I took it out when I updated.


The issue has been resolved.
Works perfectly, thanks so much Tsuki! I couldn't get it to work at first. During debugging I found out that the comment call has to be separate from any other comment calls from different scripts.
I think unless the script is explicitly deleting the comment after parsing, there should not be an issue. Some of my comment-parsing scripts do actually delete the comment after I'm done with it...which now seems like a bad idea.
Perfection comes through iteration I suppose haha. At least we exposed something here
is there a way to make this script also randomize the map the event could appear in?

If there is, can the map randomization be between selected maps? (Randomized map ID's 1, 4, 6, 8 and 10)
No, this script assumes events are static and are fixed to the map they are created on in the editor.
I thought so. Thanks though.
The "types" are not working for me and are returning errors.
I've fixed the issue.
I've fixed the issue.
So now it runs once, then returns to the events original position with no argument or init.

On page it continues to randomize. I'm assuming this is how it's intended and is perfect for my monsters!

Now I just need to figure out how to do the random position once, and have it remember that position for stationary objects. This could be a future update idea perhaps 😛

Thanks for your help and prompt responce Hime!
I will add a way to only do the randomization once.


It will probably be a type called "start" or something, since "init" is called everytime you load the map which may not be desirable.
I will add a way to only do the randomization once.

It will probably be a type called "start" or something, since "init" is called everytime you load the map which may not be desirable.
The key would be saving that first time random position without having to set 3 variables for each event! 😛

Again thanks from a fellow Torontonian lol (well etobicoke but that counts)

Original thread: https://forums.rpgmakerweb.com/threads/random-event-positions.12176/