How to create random Weather?

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,139
It's a custom script (aka writing by yourself Jass code line in GUI), and im sure you know how to remove leaks, thus you should know for what are custom script for, and because of it i guess its not hard for you to use them for weather now =)
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,139
Man you had right, Pharaoh_ did a little mistake.. there aren't any weather-effect type variables at all..

However here is Weather System created by me (it's neaby completely made of custom script, because system is basicaly Jass.. - had a bit problem removing BJs, because I don't work with Weather triggers ofen), credits to Pharaoh_ for first version:

EDIT Improved version:
  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set udg_WeatherHash = InitHashtable()
      • -------- Weather Library --------
      • Custom script: set udg_Weather[1] = 'RAhr'
      • Custom script: set udg_Weather[2] = 'RAlr'
      • Custom script: set udg_Weather[3] = 'MEds'
      • Custom script: set udg_Weather[4] = 'FDbh'
      • Custom script: set udg_Weather[5] = 'FDbl'
      • Custom script: set udg_Weather[6] = 'FDgh'
      • Custom script: set udg_Weather[7] = 'FDgl'
      • Custom script: set udg_Weather[8] = 'FDrh'
      • Custom script: set udg_Weather[9] = 'FDrl'
      • Custom script: set udg_Weather[10] = 'FDwh'
      • Custom script: set udg_Weather[11] = 'FDwl'
      • Custom script: set udg_Weather[12] = 'RLhr'
      • Custom script: set udg_Weather[13] = 'RLlr'
      • Custom script: set udg_Weather[14] = 'SNbs'
      • Custom script: set udg_Weather[15] = 'SNhs'
      • Custom script: set udg_Weather[16] = 'SNls'
      • Custom script: set udg_Weather[17] = 'WOcw'
      • Custom script: set udg_Weather[18] = 'WOlw'
      • Custom script: set udg_Weather[19] = 'LRaa'
      • Custom script: set udg_Weather[20] = 'LRma'
      • Custom script: set udg_Weather[21] = 'WNcw'
      • -------- End of Library --------
      • Set Random_Integer = (Random integer number between 1 and 21)
      • Custom script: call SaveInteger(udg_WeatherHash, GetHandleId(bj_mapInitialPlayableArea), StringHash("weather"), udg_Random_Integer)
      • Custom script: set udg_Weather_Effect = AddWeatherEffect(bj_mapInitialPlayableArea, udg_Weather[udg_Random_Integer])
      • Environment - Turn Weather_Effect On
  • Random Weather
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set Random_Integer = (Random integer number between 1 and 21)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If- Conditions
          • Random_Integer Not equal to (Load (Key weather) of (Key (Playable map area)) from WeatherHash)
        • Then - Actions
          • Custom script: call RemoveWeatherEffect (udg_Weather_Effect)
          • Custom script: set udg_Weather_Effect = AddWeatherEffect(bj_mapInitialPlayableArea, udg_Weather[udg_Random_Integer])
          • Environment - Turn Weather_Effect On
          • Custom script: call SaveInteger(udg_WeatherHash, GetHandleId(bj_mapInitialPlayableArea), StringHash("weather"), udg_Random_Integer)
        • Else - Actions
Here you got a test map. Remember to customize periodic, I've set it to 5 sec for testing purposes.
EDIT: New version testmap attached.
 

Attachments

  • WeatherSystem.w3x
    12.7 KB · Views: 159
Last edited:

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,139
library WeatherType

globals
constant integer WEATHER_ASHENVALE_HEAVY_RAIN = 'RAhr'
constant integer WEATHER_ASHENVALE_LIGHT_RAIN = 'RAlr'
constant integer WEATHER_DALARAN_SHIELD = 'MEds'
constant integer WEATHER_DUNGEON_HEAVY_BLUE_FOG = 'FDbh'
constant integer WEATHER_DUNGEON_LIGHT_BLUE_FOG = 'FDbl'
constant integer WEATHER_DUNGEON_HEAVY_GREEN_FOG = 'FDgh'
constant integer WEATHER_DUNGEON_LIGHT_GREEN_FOG = 'FDgl'
constant integer WEATHER_DUNGEON_HEAVY_RED_FOG = 'FDrh'
constant integer WEATHER_DUNGEON_LIGHT_RED_FOG = 'FDrl'
constant integer WEATHER_DUNGEON_HEAVY_WHITE_FOG = 'FDwh'
constant integer WEATHER_DUNGEON_LIGHT_WHITE_FOG = 'FDwl'
constant integer WEATHER_LORDAERON_HEAVY_RAIN = 'RLhr'
constant integer WEATHER_LORDARON_LIGHT_RAIN = 'RLlr'
constant integer WEATHER_NORTHREND_BLIZZARD = 'SNbs'
constant integer WEATHER_NORTHREND_HEAVY_SNOW = 'SNhs'
constant integer WEATHER_NORTHREND_LIGHT_SNOW = 'SNls'
constant integer WEATHER_OUTLAND_HEAVY_WIND = 'WOcw'
constant integer WEATHER_OUTLAND_LIGHT_WIND = 'WOlw'
constant integer WEATHER_RAY_OF_LIGHT = 'LRaa'
constant integer WEATHER_RAY_OF_MOONLIGHT = 'LRma'
constant integer WEATHER_HEAVY_WIND = 'WNcw'
endglobals

endlibrary

From thehelper. Pharaoh_ have already posted it.
 

Dr Super Good

Spell Reviewer
Level 62
Joined
Jan 18, 2005
Messages
27,007
From battlenet. Just log in, it will automatically update the game to the lattest verison.

Sorry to say but when i copied the trigger over to my map it kept coming up with an error saying that it expected variables for the different kinds of weather.
You are using JNGP right? As the tags used in the extract are Vjass and so need jass helper to precompile them down to proper jass WC3 can use.
 
Level 6
Joined
Jun 18, 2011
Messages
159
Someone just posted this in my last thread. Its JNGP (JASS NewGen Pack) with an updated jasshelper, so you don't have to update it manually.

Edit: I was questioning how to configure the files because I was having problems, but I believe it works without any manipulation of files.
 
Last edited:
Level 8
Joined
Apr 23, 2010
Messages
312
Here's a completely GUI weather system I use. Don't really care if you use it or not but i figure I might as well put it up in this thread for people who are strictly GUI users.

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Environment - Create at (Playable map area) the weather effect Northrend Snow (Light)
      • Set Weather_we[0] = (Last created weather effect)
      • Environment - Turn (Last created weather effect) Off
      • Environment - Create at (Playable map area) the weather effect Northrend Snow (Heavy)
      • Set Weather_we[1] = (Last created weather effect)
      • Environment - Turn (Last created weather effect) Off
      • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Heavy)
      • Set Weather_we[2] = (Last created weather effect)
      • Environment - Turn (Last created weather effect) Off
      • Environment - Create at (Playable map area) the weather effect Northrend Blizzard
      • Set Weather_we[3] = (Last created weather effect)
      • Environment - Turn (Last created weather effect) Off
  • Change Weather
    • Events
      • Time - Every (90.00 + (Random real number between 0.00 and 90.00)) seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 3, do (Actions)
        • Loop - Actions
          • Environment - Turn Weather_we[(Integer A)] Off
      • Environment - Turn Weather_we[(Random integer number between 0 and 3)] On
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,139
That trigger is totaly inefficient. It requires 3x21 = 63 lines for input Weather library, and while removing existing effect you have to run through all the indexes again.
If someone uses 1-3 weather types it wouldn't be so bad, but for larger amounts better write few custom scripts.
My GUi script can be improved by using bj_mapInitialPlayableArea instead of GetPlayableMapRect().

Uploaded newer version of system. If anyone wants, I can add Jass version too.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 62
Joined
Jan 18, 2005
Messages
27,007
Time - Every (90.00 + (Random real number between 0.00 and 90.00)) seconds of game time
Oh dear... Someone seems to have forgoten (or not realised) that arguments for events are evaluated only when the event constructor is called. As such it will have a predictable perodic time every map session but that period would be random between map sessions.
 
Level 8
Joined
Apr 23, 2010
Messages
312
Oh, I see. So there is no way to make it a random time interval? Integer and real variables don't work for periodic time events so the only way I see to make it random would be to make a countdown timer that no one can see. Think that would work?
 
Top