Random Events

That1GuyAgain

Villager
Member
Joined
May 5, 2015
Messages
7
Reaction score
0
First Language
English
Primarily Uses
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.
 

Shaz

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

Dalamar

Veteran
Veteran
Joined
Apr 29, 2013
Messages
370
Reaction score
61
First Language
English
Primarily Uses
RMMV
Wouldn't control variables operand random 1-4 work just as well?
 

Shaz

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

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top