Random Events

In the level I'm working on there are 4 sprites that appear as "enemies" (no combat you just run). What I am trying to do is when you walk into the room I want it to do a random number generation (0-100) where the corresponding number activates one of the four to appear and chase you.

The issue is trying to make this work with the separate events and sprites. I tried doing it with pages but they only have the option of "if lower than variable" which wont work because if it randomizes 100 then all four will appear and chase you. 

Tried conditional branches, but I'm not sure how to make it trigger an event with a separate sprite, only a common event which does not allow me to generate a sprite.

Any help would be fantastic, willing to use events and scripts if you have recommendations.
lol - why would you generate a random number between 0 and 100 if you only want to activate one of 4 events?

Give each event 3 pages. First page will have no condition and whatever the "default" commands are, if there are any. Second page will have "if variable is equal to or greater than" with a different number for each one (1, 2, 3, 4), and the "approach player" autonomous move route or whatever commands you need to run (if it's just approach player, you do NOT need to set this to parallel process). Third page will have "if variable is equal to or greater than" with the number that activates the NEXT event, and will have the default commands.

So event 1 will have a page with no conditions, a page with "var >= 1" and a page with "var >= 2"

Event 2 will have a page with no conditions, a page with "var >= 2" and a page with "var >= 3"

Event 4 only needs 2 pages, since there will be no ">= 5"

Then add a parallel process event that does this:

Code:
Script: $game_variables[id] = rand(4) + 1Erase Event
where id is the variable id that you're using in the conditions (no leading zeros)
Wouldn't control variables operand random 1-4 work just as well?
Yes, you're right, it would. And it would be the easier way to go.


When I did a script call, I was still thinking along the lines of the original request (1-100, which would then need to be converted to one of the 4 events to be activated).

Original thread: https://forums.rpgmakerweb.com/threads/random-events.42421/