| 09-12-2008, 02:12 AM | #1 | |
Random weather script
By moyack. 2008. I did this as a request: a code that changes randomly the weather from normal to a rainy day. Due to its configurability and easy to use (just copy it to your map and it will work) I'll post it to the public. Now the current version allows multiple types of weathers and with a few functions you can achieve very nice weather effect transitions. How the script works? The script initializes a timer with a random duration (configurable via globals), and it will change from no weather to a weather environment. if you use the minimalistic version, it will turn on and off in a random way the specified weather. If you use the Standard version, it will do the same but with a set of weathers configured previously. this preconfiguration can be done at map init or at game time... there's no limitation. Credits and Acknowledgments Greetings to Syntic_Arrow for doing the request. Credits to Ammorth for the suggestion of weights to implement randomness Gives credits when you use it... How to install:
Standard version:
Minimalistic version. Only manages one type of weather:// Random weather changer, by moyack. 2008. scope RandomWeather initializer init globals private constant integer Rain = 'RAhr' //Set the weather type that you want to use... private constant real MinDur = 15. // minimum time that we have to wait between weathers private constant real MaxDur = 35. // maximum time that we have to wait between weathers private weathereffect W private boolean IsRain = false endglobals private function Loop takes nothing returns nothing local timer t = GetExpiredTimer() set IsRain = not IsRain call EnableWeatherEffect(W, IsRain) call PauseTimer(t) call TimerStart(t, GetRandomReal(MinDur, MaxDur), false, function Loop) set t = null endfunction private function init takes nothing returns nothing set W = AddWeatherEffect(GetWorldBounds(), Rain) call TimerStart(CreateTimer(), GetRandomReal(MinDur, MaxDur), false, function Loop) endfunction endscope Weather RawCodes:globals // Weather Type Constants constant integer Ashenvale_Rain_Heavy = 'RAhr' constant integer Ashenvale_Rain_Light = 'RAlr' constant integer Dalaran_Shield = 'MEds' constant integer Dungeon_Blue_Fog_Heavy = 'FDbh' constant integer Dungeon_Blue_Fog_Light = 'FDbl' constant integer Dungeon_Green_Fog_Heavy = 'FDgh' constant integer Dungeon_Green_Fog_Light = 'FDgl' constant integer Dungeon_Red_Fog_Heavy = 'FDrh' constant integer Dungeon_Red_Fog_Light = 'FDrl' constant integer Dungeon_White_Fog_Heavy = 'FDwh' constant integer Dungeon_White_Fog_Light = 'FDwl' constant integer Lordaeron_Rain_Heavy = 'RLhr' constant integer Lordaeron_Rain_Light = 'RLlr' constant integer Northrend_Blizzard = 'SNbs' constant integer Northrend_Snow_Heavy = 'SNhs' constant integer Northrend_Snow_Light = 'SNls' constant integer Outland_Wind_Heavy = 'WOcw' constant integer Outland_Wind_Light = 'WOlw' constant integer Rays_Of_Light = 'LRaa' constant integer Rays_Of_Moonlight = 'LRma' constant integer Wind_Heavy = 'WNcw' // End Weather type Constants... endglobals |
| 09-12-2008, 04:29 AM | #2 |
Seems a little simple..... |
| 09-12-2008, 04:30 AM | #3 |
One thing: I would put where you can find the rawcode of weather (because I sure don't know). EDIT: That's why this is a script, not a system. |
| 09-13-2008, 01:18 AM | #4 |
What darkwulfv said, as adjusting this to snow or fog or whatever (or multiple weathers at random times if so) would be great. |
| 09-13-2008, 05:51 AM | #5 |
"Random Rain" is a bit misleading since it could work for any kind of weather. I say add support for all types of weather, enabling/disabling specific weather types, and setting the relative frequency of each. |
| 09-14-2008, 02:47 PM | #6 |
Ok, I'll add a function which will set the chances that a weather could happen. call SetWeatherChance('RAhr', 0.15) // it will have a 15% chance that a rain happens... |
| 09-14-2008, 07:08 PM | #7 |
I would instead use a weight, as calling: JASS:call SetWeatherChance('RAIN', 1.00) call SetWeatherChance('SNOW', 1.00) wouldn't work out very well. JASS:call SetWeatherChance('RAIN', 8) call SetWeatherChance('SNOW', 3) rain = 8/(8+3) = 72.7% snow = 3/(8+3) = 27.3% |
| 09-15-2008, 12:00 AM | #8 | |
Quote:
I've added the weathers (20 in total) and I'm coding the calculation part. As soon as I have them ready, I'll post the updated version. |
| 09-16-2008, 07:05 AM | #9 |
change of weather with all map (if it big) can cause a lag, i shared a map on regions and create weathereffect timed in each region |
| 09-18-2008, 01:42 AM | #10 |
Code updated. Comments are appreciated. |
| 09-18-2008, 01:54 AM | #11 | |
There is one issue with this script which is not adressed in the setup. The issue is not with the script itself but with the game engine. Read the bottem of this post for the info: http://www.wc3campaigns.net/showthread.php?t=91176 Quote:
|
| 09-18-2008, 02:44 AM | #12 | |
Quote:
|
| 09-18-2008, 03:44 AM | #13 |
Its not an issue with effects being displayed, it that you can't create 2 effects of the same "style" on the same grid piece. The only way around this is to remove and then create the new style. The problem with this is that it re-introduces lag caused by weather creation. |
| 09-18-2008, 07:36 AM | #14 |
Link some game affect to weather type (i prefer linked list of linked struct, soo you will able to set more then one effect per weather). Add preload functions, weather lag a lot on first call. Also add some way to call weather locally (turn on\off for single player). |
| 09-18-2008, 08:56 PM | #15 |
Yes, turn the thing into a non-minimalist monster. I think linking to effect is interesting but it raises the scope of the initial idea too much, perhaps for a new system, I actually made that one day for TTOR and reused it in my arena, so I might end up releasing a weather system one day. Either way, I don't like this idea too much, but as an utility for those guys that want to have random weather in their map, I guess it is fine, approved. |
