MZ Making events visible based on RNG

Hi,

I've seen this done in other games but don't know where to begin wrapping my head around sample code or what to search for.

I have a working time-of-day and calendar system in my game, and have been running through progression checks recently to get ready to have friends alpha test it. The problem is, the player should be able to interact with various characters as they change position on the screen because of progression variable and time-of-day variable checks. Normally this would be run of the mill stuff like the presence or position of shopkeepers and the like.

In this instance, I want to be able to check if, on map entry, events A, B, C or D are chosen to appear at four different locations (it can be single or multiple events/sprites so long as the switch or variable logic is consistent, or even none of them) but only one of the four, if multiple events match multiple trigger criteria to appear and be visible/interactable. I already know how to do this based on my time system (so events can only show up after a certain variable 'day' is over a certain value, and if the variable 'hour' is between two values using nested conditional branches, and checking a third variable for progression in the game) and how to roll an RNG variable, but want to simplify the concept as much as possible and minimize troubleshooting because I have to re-use the code on just about every map in the game for minor repeatable events. I want a template ready for when I have sprites and assets for these events to play and to flag them in Visustella's compass plug-in appropriately.

I just wanted to check my thinking out loud to prevent soft-locks, performance issues, or events failing to check for one anothers' presence. If my thinking is correct it would be better to code 'dice' and then worry about conditional branches for each outcome and using else statements to re-roll the dice if trigger criterion fail, but break the loop entirely when one event succeeds... and then need to determine if it's better off to put this check in a common event for performance reasons.
Use a variable instead of a switch to make those events appear. Don't get a new random until the next time of day comes; use a switch to store whether you've already checked for the current time of day.

Original thread: https://forums.rpgmakerweb.com/threads/making-events-visible-based-on-rng.178951/