• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Simple Zone Weather

Status
Not open for further replies.
Level 30
Joined
Jun 11, 2017
Messages
993
I have simple weather system, that spawns weather in zones (map, divided by regions). I use loop to spawn in all zone regions, but message about happened weather shows, however weather isn't.
Question is: how I can show weather?
Post trigger below:
  • Events
    • Time - ForestTimer expires
  • Conditions
    • ForestWeatherIsOn Not equal to True
  • Actions
    • Trigger - Turn off (This trigger)
    • -------- [I]Randomize Weather Effect[/I] --------
    • Set VariableSet ForestWeatherRandom = (Random integer number between 10 and 100)
    • -------- [I]Nothing[/I] --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • ForestWeatherRandom Less than 75
      • Then - Actions
        • Game - Display to (All players) the text: [SYSTEM] Forest - N...
        • -------- Clear Weather Random Data --------
        • Set VariableSet ForestTimerTime = 0
        • Set VariableSet ForestWeatherRandom = 0
        • -------- Randomize New Weather Time --------
        • Set VariableSet ForestTimerTime = (Random integer number between 280 and 360)
        • -------- Start New Timer --------
        • Countdown Timer - Start ForestTimer as a One-shot timer that will expire in (Real(ForestTimerTime)) seconds
        • -------- Enable Weather Trigger --------
        • Trigger - Turn on (This trigger)
        • -------- Remove From Trigger Queue --------
        • Trigger - Remove (This trigger) from the trigger queue
      • Else - Actions
        • -------- [I]Light Rain[/I] --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ForestWeatherRandom Greater than 75
            • ForestWeatherRandom Less than 84
          • Then - Actions
            • Game - Display to (All players) the text: [SYSTEM] Forest - L...
            • -------- Create Weather Effects & Forest is on --------
            • For each (Integer A) from 1 to 11, do (Actions)
              • Loop - Actions
                • Environment - Create at ForestWeather[(Integer A)] the weather effect Lordaeron Rain (Light)
                • Set VariableSet ForestWeatherSFX[(Integer A)] = (Last created weather effect)
                • Environment - Turn (Last created weather effect) On
            • Set VariableSet ForestWeatherIsOn = True
            • -------- Clear Weather Random Data --------
            • Set VariableSet ForestTimerTime = 0
            • Set VariableSet ForestWeatherRandom = 0
            • -------- Randomize New Weather Time --------
            • Set VariableSet ForestTimerTime = (Random integer number between 70 and 150)
            • -------- Start New Timer --------
            • Countdown Timer - Start ForestTimer as a One-shot timer that will expire in (Real(ForestTimerTime)) seconds
            • -------- Enable Weather Remover --------
            • Trigger - Turn on WeatherSystem DisableForest 01 <gen>
            • Trigger - Remove (This trigger) from the trigger queue
          • Else - Actions
            • -------- [I]Heavy Rain[/I] --------
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ForestWeatherRandom Greater than 84
                • ForestWeatherRandom Less than 96
              • Then - Actions
                • Game - Display to (All players) the text: [SYSTEM] Forest - H...
                • -------- Create Weather Effects & Forest is on --------
                • For each (Integer A) from 1 to 11, do (Actions)
                  • Loop - Actions
                    • Environment - Create at ForestWeather[(Integer A)] the weather effect Lordaeron Rain (Heavy)
                    • Set VariableSet ForestWeatherSFX[(Integer A)] = (Last created weather effect)
                    • Environment - Turn (Last created weather effect) On
                • Set VariableSet ForestWeatherIsOn = True
                • -------- Clear Weather Random Data --------
                • Set VariableSet ForestTimerTime = 0
                • Set VariableSet ForestWeatherRandom = 0
                • -------- Randomize New Weather Time --------
                • Set VariableSet ForestTimerTime = (Random integer number between 50 and 100)
                • -------- Start New Timer --------
                • Countdown Timer - Start ForestTimer as a One-shot timer that will expire in (Real(ForestTimerTime)) seconds
                • -------- Enable Weather Remover --------
                • Trigger - Turn on WeatherSystem DisableForest 01 <gen>
                • Trigger - Remove (This trigger) from the trigger queue
              • Else - Actions
                • -------- [I]Moon Lights[/I] --------
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • ForestWeatherRandom Greater than or equal to 96
                    • IsNight Equal to True
                  • Then - Actions
                    • Game - Display to (All players) the text: [SYSTEM] Forest - M...
                    • -------- Create Weather Effects & Forest is on --------
                    • For each (Integer A) from 1 to 11, do (Actions)
                      • Loop - Actions
                        • Environment - Create at ForestWeather[(Integer A)] the weather effect Rays Of Moonlight
                        • Set VariableSet ForestWeatherSFX[(Integer A)] = (Last created weather effect)
                        • Environment - Turn (Last created weather effect) On
                    • Set VariableSet ForestWeatherIsOn = True
                    • -------- Clear Weather Random Data --------
                    • Set VariableSet ForestTimerTime = 0
                    • Set VariableSet ForestWeatherRandom = 0
                    • -------- Randomize New Weather Time --------
                    • Set VariableSet ForestTimerTime = (Random integer number between 25 and 70)
                    • -------- Start New Timer --------
                    • Countdown Timer - Start ForestTimer as a One-shot timer that will expire in (Real(ForestTimerTime)) seconds
                    • -------- Enable Weather Remover --------
                    • Trigger - Turn on WeatherSystem DisableForest 01 <gen>
                    • Trigger - Remove (This trigger) from the trigger queue
                  • Else - Actions
And trigger about removing weather:
  • Events
    • Time - ForestTimer expires
  • Conditions
    • ForestWeatherIsOn Equal to True
  • Actions
    • Trigger - Turn off (This trigger)
    • -------- *Disable & Remove Weather Effect --------
    • For each (Integer A) from 1 to 11, do (Actions)
      • Loop - Actions
        • Environment - Remove ForestWeatherSFX[(Integer A)]
    • -------- [I]Disable Forest Boolean[/I] --------
    • Set VariableSet ForestWeatherIsOn = False
    • -------- [I]Reset Weather Intergers[/I] --------
    • Set VariableSet ForestTimerTime = 0
    • Set VariableSet ForestWeatherRandom = 0
    • -------- [I]Randomize Weather Timer[/I] --------
    • Set VariableSet ForestTimerTime = (Random integer number between 280 and 360)
    • -------- [I]Start Weather Timer & Enable Trigger[/I] --------
    • Countdown Timer - Start ForestTimer as a One-shot timer that will expire in (Real(ForestTimerTime)) seconds
    • Trigger - Turn on WeatherSystem SelectForest 01 <gen>
    • Trigger - Remove (This trigger) from the trigger queue
 
Level 30
Joined
Jun 11, 2017
Messages
993
Remove Weather Trigger is turned off initially.
And I wonder: is this a Reforged Graphic issue or not?
Because in others regions, that doesn't used in weather systems, I use region weather (selected in region menu) and those weather are shown.
But spawned - not.
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
I was messing around with weather on Reforged a while ago and I ran into a lot of issues. I remember it not working the way I expected and I had to disable + clear any existing weather before creating new ones - although my memory is a bit foggy. My code was done in C# but it's not hard to read if you know Lua/Jass:
When you type the name of a weather effect like "rain" this function runs and sets the weather across the map. If you type an empty string "" it resets and clears any existing weather. I contain the weather effects in a List, similar to how you use an Array to contain yours.
vJASS:
        private static void SetWeather(string text)
        {
            if (text == "")
            {
                foreach (var we in weatherList)
                {
                    EnableWeatherEffect(we, false);
                    RemoveWeatherEffect(we);
                }
                weatherList.Clear();
                return;
            }
            weathereffect weather = null;
            switch (text)
            {
                case "rain": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("RAlr")); break;
                case "light rain": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("RAlr")); break;
                case "heavy rain": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("RAhr")); break;
                case "snow": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("SNhs")); break;
                case "light snow": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("SNls")); break;
                case "heavy snow": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("SNhs")); break;
                case "blizzard": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("SNbs")); break;
                case "wind": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("WOlw")); break;
                case "light wind": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("WOlw")); break;
                case "heavy wind": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("WOcw")); break;
                case "sunlight": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("LRaa")); break;
                case "moonlight": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("LRma")); break;
                case "red fog": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("FDrh")); break;
                case "green fog": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("FDgh")); break;
                case "blue fog": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("FDbh")); break;
                case "white fog": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("FDwh")); break;
            }
            if (weather == null) { return; }
            EnableWeatherEffect(weather, true);
            weatherList.Add(weather);
        }
I remember certain weather effects working once and then never again after that. Fog was especially broken, and I don't think most of the fogs even worked. Combining multiple weather effects caused problems as well.

Anyway, regarding your system, maybe try disabling the Weather effect before Removing it. Also, make sure that both triggers aren't running at the same time when the timer expires. I know your Booleans are there to prevent that, but just make sure. Lastly, I feel like you could remove a lot of random stuff from those triggers. I don't see why you need to Turn off any triggers, remove anything from the trigger queue, and reset any Integer variables. None of those things need to happen as far as I can tell.
 
Level 30
Joined
Jun 11, 2017
Messages
993
I was messing around with weather on Reforged a while ago and I ran into a lot of issues. I remember it not working the way I expected and I had to disable + clear any existing weather before creating new ones - although my memory is a bit foggy. My code was done in C# but it's not hard to read if you know Lua/Jass:
vJASS:
        private static void SetWeather(string text)
        {
            if (text == "")
            {
                foreach (var we in weatherList)
                {
                    EnableWeatherEffect(we, false);
                    RemoveWeatherEffect(we);
                }
                weatherList.Clear();
                return;
            }
            weathereffect weather = null;
            switch (text)
            {
                case "rain": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("RAlr")); break;
                case "light rain": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("RAlr")); break;
                case "heavy rain": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("RAhr")); break;
                case "snow": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("SNhs")); break;
                case "light snow": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("SNls")); break;
                case "heavy snow": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("SNhs")); break;
                case "blizzard": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("SNbs")); break;
                case "wind": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("WOlw")); break;
                case "light wind": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("WOlw")); break;
                case "heavy wind": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("WOcw")); break;
                case "sunlight": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("LRaa")); break;
                case "moonlight": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("LRma")); break;
                case "red fog": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("FDrh")); break;
                case "green fog": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("FDgh")); break;
                case "blue fog": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("FDbh")); break;
                case "white fog": weather = AddWeatherEffect(GetPlayableMapRect(), FourCC("FDwh")); break;
            }
            EnableWeatherEffect(weather, true);
            weatherList.Add(weather);
        }
I remember certain weather effects working once and then never again after that. Fog was especially broken, and I don't think most of the fogs even worked. Combining multiple weather effects caused problems as well.

Anyway, regarding your system, maybe try disabling the Weather effect before Removing it. Also, make sure that bother triggers aren't running at the same time when the timer expires. I know your Booleans are there to prevent that, but just make sure. Lastly, I feel like you could remove a lot of random stuff from those triggers. I don't see why you need to Turn off any triggers, remove anything from the trigger queue, and reset any Integer variables. None of those things need to happen as far as I can tell.
Thanks for reply!
I agree with you, but currently I founded issue in my loop - using (Interger A) doesn't work for weather and it doesn't spawn at all.
So I tweaked system with adding new int value, that used in loop and resets after loop.

But I have encountered timer issue. Even I turn off my spawn weather trigger and restart timer, it seems that weather immediately destroyed, ignoring my boolean value.
Currently I use another timer, and it seems that helped it.

EDIT: About (Interger A) in loop - right now in forest a heavy rain started, and I didin't changed loop as I told before. Stranger Things indeed.
Maybe problem was in timer?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
Thanks for reply!
I agree with you, but currently I founded issue in my loop - using (Interger A) doesn't work for weather and it doesn't spawn at all.
So I tweaked system with adding new int value, that used in loop and resets after loop.

But I have encountered timer issue. Even I turn off my spawn weather trigger and restart timer, it seems that weather immediately destroyed, ignoring my boolean value.
Currently I use another timer, and it seems that helped it.

EDIT: About (Interger A) in loop - right now in forest a heavy rain started, and I didin't changed loop as I told before. Stranger Things indeed.
Maybe problem was in timer?
It's useful to use unique unique Loop variables instead of IntegerA/B, I've heard bad things about those and since they're global variables they can be changed globally from any trigger. Better safe than sorry I suppose.

I would combine your two triggers into one and manage it like this:
  • Untitled Trigger 001
    • Events
      • Time - ForestTimer expires
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ForestWeatherIsOn Equal to True
        • Then - Actions
          • -------- Clear existing weather and start timer again. --------
          • Set VariableSet ForestWeatherIsOn = False
          • Countdown Timer - Start ForestTimer as a One-shot timer that will expire in (Random real number between 280.00 and 360.00) seconds
        • Else - Actions
          • -------- Create new weather and start timer again. --------
          • Set VariableSet ForestWeatherIsOn = True
          • Countdown Timer - Start ForestTimer as a One-shot timer that will expire in (Random real number between 280.00 and 360.00) seconds
 
Level 30
Joined
Jun 11, 2017
Messages
993
It's useful to use unique unique Loop variables instead of IntegerA/B, I've heard bad things about those and since they're global variables they can be changed globally from any trigger. Better safe than sorry I suppose.

I would combine your two triggers into one and manage it like this:
  • Untitled Trigger 001
    • Events
      • Time - ForestTimer expires
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ForestWeatherIsOn Equal to True
        • Then - Actions
          • -------- Clear existing weather and start timer again. --------
          • Set VariableSet ForestWeatherIsOn = False
          • Countdown Timer - Start ForestTimer as a One-shot timer that will expire in (Random real number between 280.00 and 360.00) seconds
        • Else - Actions
          • -------- Create new weather and start timer again. --------
          • Set VariableSet ForestWeatherIsOn = True
          • Countdown Timer - Start ForestTimer as a One-shot timer that will expire in (Random real number between 280.00 and 360.00) seconds
Do I need to DestroyTimer() each time I call function or not?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
And one more question - do I need to DestroyTimer(udg_mytimer) each time a function works or not?
No, if you use DestroyTimer() on ForestTimer it will be deleted permanently and this function will stop working:
  • Countdown Timer - Start ForestTimer as a One-shot timer that will expire in (Random real number between 280.00 and 360.00) seconds

A GUI timer variable creates a single timer upon being initialized which can be used again and again.

No new timer objects are ever created so you aren't going to leak anything, therefore destroying it is unnecessary.
 
Last edited:
Level 30
Joined
Jun 11, 2017
Messages
993
No, if you use DestroyTimer() on ForestTimer it will be deleted permanently and this function will stop working:
  • Countdown Timer - Start ForestTimer as a One-shot timer that will expire in (Random real number between 280.00 and 360.00) seconds

A GUI timer variable creates a single timer upon being initialized which can be used again and again. No new timer objects are ever created so you aren't going to leak anything.
Thanks!
Because I've started to think that my timers was completly deleted after I used next:
Lua:
DestroyTimer(udg_ForestTimer)
Firstly I thought that I need to do it each time to prevent timer bugs, but essentially broked my system :D

Anyway, thank you alot!
 
Status
Not open for further replies.
Top