Random chance events?

Howdy all!
I’ve been trying to figure out a way to create random chance events (not battles) so I can create a sort of dream mechanic in my game. Some events will have a higher chance of occurring than others. Does anyone have any idea how I could pull this off?
All advice would be appreciated!
Game Mechanics is for general discussion of mechanics. If you're looking for broader ideas on how to make this system work well, this can stay. But if you're looking for technical advice on how to actually implement it in the engine, it needs to be moved to the correct support forum, which would require knowing which engine you are using.
Game Mechanics is for general discussion of mechanics. If you're looking for broader ideas on how to make this system work well, this can stay. But if you're looking for technical advice on how to actually implement it in the engine, it needs to be moved to the correct support forum, which would require knowing which engine you are using.
I’m using MV! I’m trying to find out how to actually implement this, so I’ll make sure to move this to the proper category. Thank you for your help!
Nah, I moved it for you.
One: Create an Autorun event that sets the a 'time' variable to 0, and sets a second variable to a random number to represent the number of seconds it needs to wait before an event happens. Then the event switches to an autorun event that increments the 'time' variable by one and then waits for 60 frames, and then checks if it is larger than your 'time until something happens variable.
If it is, it sets the 'time' back to zero, and generates a third 'choose which event' Variable, that then gets checked against a set of conditional if statements to see which event plays.
create random chance events
Depending on what "random chance event" actually means... if you're talking about an event that will execute on a map upon the player entering it (sometimes), then you can accomplish that just with the variable control event command combined with having events with a variable "greater than" event trigger to do your things.

I used such a mechanic to allow for certain maps to spawn particular enemies (visible enemies on the map) with a low % chance.
sounds like all you need is 1 random variable and a series of if statements checking what the variable is.

control variable random 1-100
if variable greater than 80 (20% chance)
> do ... (result 1)
> exit event process (prevent following lines from also running)
if variable greater than 65 (15% chance)(will only run this line if its between 66 an 80)
> do ... (result 2)
> exit event process
if greater 50 (15% chance again)
> result 3
> exit
if greater 40 (10% chance)
.... you should get the idea by now
Depending on what "random chance event" actually means... if you're talking about an event that will execute on a map upon the player entering it (sometimes), then you can accomplish that just with the variable control event command combined with having events with a variable "greater than" event trigger to do your things.

I used such a mechanic to allow for certain maps to spawn particular enemies (visible enemies on the map) with a low % chance.
That is a good idea! I think it may work with what I'm trying to accomplish.
I should have been more descriptive on what I'm exactly trying to do, so It's probably best that I explain sooner than later!

Basically, the player character will interact with a bed, and it will ask the player whether they wish to sleep or not. When the player confirms they want to sleep, there will be a chance that the player will receive a dream. Some dreams will be rarer than others. The most likely outcome of the interaction would be no dream at all. After the player has woken up, their MP and HP will be fully replenished.
I hope that better explains what I'm going for, I apologize for not specifying earlier.
I think Tiamat’s suggestion would be the simplest solution in your case. You could randomize the variable when interacting with the bed, then use the conditional branch to determine if a dream occurs and then what that dream is. No need for any auto run events that way
That is a good idea! I think it may work with what I'm trying to accomplish.
I should have been more descriptive on what I'm exactly trying to do, so It's probably best that I explain sooner than later!

Basically, the player character will interact with a bed, and it will ask the player whether they wish to sleep or not. When the player confirms they want to sleep, there will be a chance that the player will receive a dream. Some dreams will be rarer than others. The most likely outcome of the interaction would be no dream at all. After the player has woken up, their MP and HP will be fully replenished.
I hope that better explains what I'm going for, I apologize for not specifying earlier.
Ahh, yeah well that is pretty much the way I'd think you should do it.

Event Commands > Control Variables > (pick a variable) > Random > between 1-100
Spoiler: screenshot for clarification
1621516405568.png

then in your actual sleepytime event, just add extra pages that would trigger the dreams or however that works, and set the extra pages to have an event trigger that maps to the same variable with a number that represents the chance
Spoiler: another screenshot for clarification
1621516559511.png

A couple things to note about this pattern:
- higher page numbers take priority over lower page numbers, so be sure to order your page conditions accordingly.
- in the variable event trigger, I wrote 80, but its actually the inverse % chance based on the setup (20% chance) because when we control the variable, we ask it to pick a random number between 1-100, and in the trigger we're saying "if its greater than or equal to 80", which... well, logic dictates that would be about 20% chance.
greater/equal 80 would be 21%. just greater then 80 would be 20%. ((81-100) gotta think of 80 in this case as being the number 0, you dont count 0 when your counting to 20)
greater/equal 80 would be 21%.
The concept remains the same, but you are correct. The math breaks down to 21 based on the way I described it, my mistake.
sounds like all you need is 1 random variable and a series of if statements checking what the variable is.

control variable random 1-100
if variable greater than 80 (20% chance)
> do ... (result 1)
> exit event process (prevent following lines from also running)
if variable greater than 65 (15% chance)(will only run this line if its between 66 an 80)
> do ... (result 2)
> exit event process
if greater 50 (15% chance again)
> result 3
> exit
if greater 40 (10% chance)
.... you should get the idea by now
I hope it's alright if I piggyback off this thread, since I tried to follow this method to get some random events...

But I did follow your instruction to set up random events, in my case I want them to happen randomly while walking around the world map. I think I have it working, but for some reason they fire off constantly.
I set up a basic RNG variable to control the percentage of events, and another to control which event happens. And a parallel event on the map to check and fire the events when the RNG is greater than 40 (which should give a 10% chance of happening, but it's not).

I've attached an image of how I have it set up, but obviously something went wrong with the way I implemented it. It's not pictured in there either, but I did add "exit" after each event, but it doesn't do anything.
On the bright side, it does pick a random event from the pool, so that works at least.
parallel event like this you will need a wait line.
the event is running 60 times per second as is.
if want it to only happen once every 10 seconds you would need a wait 600 frames
parallel event like this you will need a wait line.
the event is running 60 times per second as is.
if want it to only happen once every 10 seconds you would need a wait 600 frames
I want it to have a 10% chance per step on the map, not every 10 seconds. I seemed to have fixed it though. Just had to turn off the parallel event (which was left over from something else), and add a reference to the event on my event that tracks player movement.

I do have to say that setting the event to fire when the RNG is greater than 40 (or the opposite) doesn't seem to be a 10% chance of it happening. That'd be closer to 40% I feel like. I'm not sure where 10% is coming from in that older post. Is it because all those other events fire first?
if your using random 1-100 and > 40 it would be 60%. > 90 would be 10%.
for your thing it might be better to just use RNG 1-10 and if result = 1 do stuff.
1-100 is more used for when have multipul possible results from 1 RNG roll, like a mining outcrop with 6 different items that all have different % gather chance

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