Trying to set a random weather event across all maps (other than indoors)

I'm trying to create a random weather event that changes every in-game hour or so that spans across all maps in the game other than indoors. I've followed a few tutorials but they seem to only set it up to work on a single map so it's basically a common event that goes:

RandomWeatherVariable set to a random number between 1-4
Wait 900
RandomWeatherVariable set to a random number between 1-4
Wait 900

and that gets repeated a few times. I haven't tested it but I've read comments saying that the "wait" timer will reset if you move to a different map so if the player keeps switching maps before the 900 frames are up, the weather won't change unless the player stays on a specific map. My goal is to make the weather change every in game hour or two (haven't decided on the frequency yet) across all outdoor maps in the game. From my understanding, the best way to do that would be to set a variable to 900, then subtract -1 from that variable and then set it to reroll that random number variable once that variable reaches 0. I've tried it in multiple different ways but haven't gotten it to work. I think my last attempt I tried doing something like this (going off of memory because I erased it because I wanted to start from scratch and try again):

RandomWeatherVariable set to a random number between 1-4
Label:Start
Set WeatherTimeVariable to 900
Loop
WeatherTimerVariable-1
If WeatherTimerVariable = 0
RandomWeatherVariable set to a random number between 1-4
Jump To Label: Start
Break Loop

Obviously this is dumb and completely wrong because it didn't work because it would start a weather effect for two seconds then switch as if it's rerolling too quickly. That's why I tried to make it jump to the label under the initial reroll at the top so that it would immediately roll a random number for weather on loading the game.
Try something like this:
Spoiler: event example
◆If:Indoors Area is ON ◆Comment:Indoors! ◆Set Weather Effect:None, 1 frame ◆ :Else ◆If:Weather Timer = 0 ◆Comment:Change weather and reset timer ◆Control Variables:#0016 Weather Type = Random 1..4 ◆If:Weather Type = 1 ◆Set Weather Effect:Storm, 5, 60 frames ◆ :Else ◆If:Weather Type = 2 ◆Set Weather Effect:Rain, 5, 60 frames ◆ :Else ◆Set Weather Effect:None, 60 frames ◆ :End ◆ :End ◆Control Variables:#0015 Weather Timer = 150 ◆ :End ◆Comment:Start waiting for weather to change ◆Loop ◆If:Weather Timer = 0 ◆Comment:Wait complete! ◆Break Loop ◆ :Else ◆Comment:Update timer and check again in 6 frames. ◆Control Variables:#0015 Weather Timer -= 1 ◆Wait:6 frames ◆ :End ◆ :Repeat Above ◆ :End
The wait is necessary because otherwise you'll end up doing all the loops in one frame (which may well cause your game to slow down noticably). You also need to actually update the weather, e.g. by calling another common event that uses the Set Weather Effect command.

Parallel events automatically trigger on any frame when they are active and not already running, so the jump to label stuff is not needed. 👋

Edit: I put the starting stuff in a branch, so that the timer doesn't reset every time you visit a new map (which was the whole point).
That is awesome, thanks so much! Works like a charm.

The only thing I need to fix now is the BGS not changing so abruptly. I have rain BGS playing during the rain weather events and when the weather switches, it ends quite abruptly and is sort of jarring. I know there's a Fadeout BGS. Would that work if it's placed right before the "Break Loop" command? An issue I can foresee with that though is if it rerolls rain again, the rain sound may fade out and then back in which would be kind of odd also. For context, I have a separate weather common event that uses VisuStella's Weather plugin depending on which random weather variable is pulled. So right now the weather common events essentially look like this:

If RandomWeatherVariable = 1
Play BGS Rain2 (20, 100, 0 )
Plugin Command : VisuMZ_2_WeatherEffects, WATER: Rain
If RandomWeatherVariable = 2
Play BGS Storm1 (20, 100, 0 )
Plugin Command : VisuMZ_2_WeatherEffects, WATER: Storm
Etc.

Also, if I decide to switch the weather out daily instead of hourly, how much different would that event be? I have fishing mechanics and want some fish to only be available during rain and it may be frustrating for the player to not know how long it's going to rain and feel rushed to stop what they're doing and run to the river and fish while the rain is going on, so it might be more agreeable to keep the same weather for the entire day. I'm using a Day/Night plugin by CAZ that implements a minutes and hours variable.
That is awesome, thanks so much! Works like a charm.
Great! 😂

I have rain BGS playing during the rain weather events and when the weather switches, it ends quite abruptly and is sort of jarring.
Yea...by default there is only one BGS channel, so to achieve a cross-fade I think you'd need to make separate BGS tracks for each possible combination, e.g. Rain -> Storm, Storm -> Rain, etc. Alternatively, you could look for a plugin that offers multiple simultaneous BGS tracks, e.g. MUSH Audio Engine.

An issue I can foresee with that though is if it rerolls rain again, the rain sound may fade out and then back in which would be kind of odd also.
Before rerolling the weather type, you could store the current value in another variable. Then after rerolling, only fade out the BGS if the type has changed?

Also, if I decide to switch the weather out daily instead of hourly, how much different would that event be?
I'm guessing it would just affect the initial value for the timer? If you have a "day start" event then you could scrap the whole Parallel setup and just update the weather when the day starts.

I have fishing mechanics and want some fish to only be available during rain and it may be frustrating for the player to not know how long it's going to rain
This is more of a design/interface question. You want the player to know something, so consider ways to communicate that information, e.g. a HUD element of some kind. If it seems like more hassle than it's worth, consider simplifying the mechanic~
Hey, back again. I did decide that I wanted the weather to change daily, and I've used the knowledge you provided me to try to script it myself and it partially works, but I'm having two main problems.
-When I go indoors and the indoors switch is on, the weather does stop which is what I wanted, but it doesn't do so on the cherry blossom weather event.
-During the rain event, the BGS of rain is very glitchy almost like it's looping the start of the BGS over and over for some reason.
-I'm trying to get my Cherry blossom event to only occur during the day (or before 18:00). There is a variable for hours that go from 0-24 before resetting back to 0 once it hits 24 in the day/night cycle plugin I'm using. Maybe it would be easier to use that Hours variable, but I'm not sure.

Here's the current common event set up I'm using. I also have a current separate common event that just is set to reroll the random weather variable whenever the NewDay switch gets triggered. I have the New Day switch get turned on in the Day/Night cycle common event then turned right back off after waiting for 5 frames.

Spoiler: Current Common Event
Code:
◆If:Indoors is ON
  ◆Set Weather Effect:None, 1 frame
  ◆
:Else
  ◆If:Season = 1
    ◆If:Month Day ≤ 2
      ◆Control Switches:#0004 Storm = OFF
      ◆Control Switches:#0005 Rain = OFF
      ◆Play BGS:Clock (0, 100, 0)
      ◆Set Weather Effect:None, 1 frame
      ◆
    :Else
      ◆If:Month Day ≥ 3
        ◆If:RandomWeatherVariable ≤ 50
          ◆Control Variables:#0008 RandomWeather2 = Random 1..4
          ◆If:RandomWeather2 = 4
            ◆Control Switches:#0004 Storm = ON
            ◆Control Switches:#0005 Rain = ON
            ◆If:Indoors is ON
              ◆Play BGS:Clock (0, 100, 0)
              ◆Set Weather Effect:None, 1 frame
              ◆
            :Else
              ◆Play BGS:Storm1 (20, 100, 0)
              ◆Plugin Command:VisuMZ_2_WeatherEffects, WATER: Storm
              :              :Main Settings =
              :              :Power = 5
              :              :Duration = 60
              :              :Wait For Completion? = false
              :              :Layer Settings =
              :              :Layer(s) = ["1"]
              :              :Upper/Lower? = upper
              :              :Customization =
              :              :Custom Settings = {"sprite:struct":"{\"lifespan:num\":\"28\…
              ◆
            :End
            ◆
          :Else
            ◆Control Switches:#0004 Storm = OFF
            ◆Control Switches:#0005 Rain = ON
            ◆If:Indoors is ON
              ◆Play BGS:Clock (0, 100, 0)
              ◆Set Weather Effect:None, 1 frame
              ◆
            :Else
              ◆Play BGS:Rain2 (20, 100, 0)
              ◆Plugin Command:VisuMZ_2_WeatherEffects, WATER: Rain
              :              :Main Settings =
              :              :Power = 5
              :              :Duration = 60
              :              :Wait For Completion? = false
              :              :Layer Settings =
              :              :Layer(s) = ["1"]
              :              :Upper/Lower? = upper
              :              :Customization =
              :              :Custom Settings = {"sprite:struct":"{\"lifespan:num\":\"36\…
              ◆
            :End
            ◆
          :End
          ◆
        :Else
          ◆Control Variables:#0008 RandomWeather2 = Random 1..4
          ◆If:RandomWeather2 = 4
            ◆Control Switches:#0004 Storm = OFF
            ◆Control Switches:#0005 Rain = OFF
            ◆Control Variables:#0009 DayNightWeatherTimer = 300
            ◆If:Indoors is ON
              ◆Set Weather Effect:None, 1 frame
              ◆Loop
                ◆If:DayNightWeatherTimer = 0
                  ◆Break Loop
                  ◆
                :Else
                  ◆Control Variables:#0009 DayNightWeatherTimer -= 1
                  ◆Wait:6 frames
                  ◆
                :End
                ◆
              :Repeat Above
              ◆
            :Else
              ◆Play BGS:Clock (0, 100, 0)
              ◆Plugin Command:VisuMZ_2_WeatherEffects, WIND: Cherry Blossoms
              :              :Main Settings =
              :              :Power = 5
              :              :Duration = 60
              :              :Wait For Completion? = false
              :              :Layer Settings =
              :              :Layer(s) = ["1"]
              :              :Upper/Lower? = upper
              :              :Customization =
              :              :Custom Settings = {"sprite:struct":"{\"lifespan:num\":\"180…
              ◆Loop
                ◆If:DayNightWeatherTimer = 0
                  ◆Break Loop
                  ◆
                :Else
                  ◆Control Variables:#0009 DayNightWeatherTimer -= 1
                  ◆Wait:6 frames
                  ◆
                :End
                ◆
              :Repeat Above
              ◆Set Weather Effect:None, 1 frame
              ◆
            :End
            ◆
          :Else
            ◆Control Switches:#0004 Storm = OFF
            ◆Control Switches:#0005 Rain = OFF
            ◆Play BGS:Clock (0, 100, 0)
            ◆Set Weather Effect:None, 1 frame
            ◆
          :End
          ◆
        :End
        ◆
      :End
      ◆
    :End
    ◆
  :End
  ◆
:End
OK, so you determine the per-day weather group as one of the following:
  • 1/4 storm, 3/4 rain;
  • 1/4 none, 3/4 blossom.
Then you reroll the subtype (e.g. storm/rain) whenever this event gets called?

Note that the first branch checks if "Indoors is ON". That means the switch is OFF for everything in the else branch. When designing longer events like this, it can help to make the branches first and check the logic before adding content. Comments can help, too~

You may want to try to get the system working in a new project, with no plugins (or the minimum for your idea). Then, once it seems OK there, port it into your actual project. Working without plugins can make debugging much simpler! 👋

-When I go indoors and the indoors switch is on, the weather does stop which is what I wanted, but it doesn't do so on the cherry blossom weather event.
So...when the weather is cherry blossoms and you go indoors, there are blossoms falling indoors? Double-check that the "Indoors" switch is getting turned on before calling the event.

I also notice you use the default Set Weather Effect event command for no weather, but a plugin command for the other types. Maybe the plugin has its own "Weather: None" command.

I see you've got some kind of timeout on the blossom weather...you're not using that "DayNightWeatherTimer" variable anywhere else, right? I'm not sure why you'd want to abruptly shut off the blossoms after 30 seconds (300 x 6 frames).

-During the rain event, the BGS of rain is very glitchy almost like it's looping the start of the BGS over and over for some reason.
Sounds like a timing issue. Check to see if you're calling this event too often.

-I'm trying to get my Cherry blossom event to only occur during the day (or before 18:00). There is a variable for hours that go from 0-24 before resetting back to 0 once it hits 24 in the day/night cycle plugin I'm using. Maybe it would be easier to use that Hours variable, but I'm not sure.
If you want the blossom weather to only proc under a certain condition, you can add a "time of day" branch, e.g. replacing the random branch or nested inside it.

If one of your current plugins offers a variable that tells you exactly what game hour it is, and you want to check that value, I don't see why you wouldn't use that plugin's variable. 😅
Thanks so much, it seems to be working perfectly now! I'm sure as I get deeper into development, I'll find a bug or two because I missed something, but for now it looks perfect! :LZScheeze:

Thanks so much for being patient with me and helping me figure this out. This is my first game I'm developing and it's been so much fun but also very stressful as I learn the ropes, and I've always been the worst at asking for help so it's something that I've had to learn is okay to do. Thanks again, I really mean it.
Great, you're welcome! Happy RPG Making~ 😂

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-set-a-random-weather-event-across-all-maps-other-than-indoors.159561/