Since my last Dynamic Weather release (1.3), I've been working on, what I'm calling a Progressive Climate. It's an entirely scripted weather climate that makes for a more natural progression of weather types, and is something I've wanted for Dynamic Weather since I started work on it. I'm really quite excited that I got it working at all and from a modding/scripting perspective it's something of an achievement (well, for me at least) !
Dynamic Weather 1.4 was only supposed to have a few new weather types and some touching up of the current ones. But, I'm guessing this will be Dynamic Weather 2.0, since there are around 40 weather types (including about a dozen fogged up versions that will only appear in the DC Ruins) and the whole thing just works differently. :nod:
A cool thing I discovered while developing this script was that because of its rather extensive use of globals, was that the current weather type was saved along with your game save, so that when you later returned to the game the same weather was active. Using globals also means that it's a cinch to change the weather volatility (which also now has an element of randomness to it) in the console.
Anyway, for a little taster I'm gonna spew out some code excerpts for your perusal...
if gWeatherGroup == 1 ; Clear
set fRandomPercentValue to getRandomPercent ; (get next weather group)
if fRandomPercentValue < 50
set gWeatherGroup to 1 ; Clear
elseif fRandomPercentValue >= 40 && fRandomPercentValue < 90
set gWeatherGroup to 2 ; LightCloud
elseif fRandomPercentValue >= 90
set gWeatherGroup to 8 ; Sandstorm
endif
elseif gWeatherGroup == 2 ; LightCloud
set fRandomPercentValue to getRandomPercent ; (get next weather group)
if fRandomPercentValue < 30
set gWeatherGroup to 1 ; Clear
elseif fRandomPercentValue >= 30 && fRandomPercentValue < 60
set gWeatherGroup to 2 ; LightCloud
elseif fRandomPercentValue >= 60 && fRandomPercentValue < 90
set gWeatherGroup to 3 ; WastelandCloudy
elseif fRandomPercentValue >= 90
set gWeatherGroup to 8 ; Sandstorm
endif
elseif gWeatherGroup == 3 ; WastelandCloudy
set fRandomPercentValue to getRandomPercent ; (get next weather group)
if fRandomPercentValue < 25
set gWeatherGroup to 2 ; LightCloud
elseif fRandomPercentValue >= 25 && fRandomPercentValue < 50
set gWeatherGroup to 3 ; WastelandCloudy
elseif fRandomPercentValue >= 50 && fRandomPercentValue < 75
set gWeatherGroup to 4 ; LightRain
elseif fRandomPercentValue >= 75
set gWeatherGroup to 5 ; UrbanCloudy
endif
elseif gWeatherGroup == 4 ; LightRain
set fRandomPercentValue to getRandomPercent ; (get next weather group)
if fRandomPercentValue < 33
set gWeatherGroup to 3 ; WastelandCloudy
elseif fRandomPercentValue >= 33 && fRandomPercentValue < 66
set gWeatherGroup to 4 ; LightRain
elseif fRandomPercentValue >= 66
set gWeatherGroup to 7 ; Rain
endif
elseif gWeatherGroup == 5 ; UrbanCloudy
set fRandomPercentValue to getRandomPercent ; (get next weather group)
if fRandomPercentValue < 40
set gWeatherGroup to 3 ; WastelandCloudy
elseif fRandomPercentValue >= 40 && fRandomPercentValue < 65
set gWeatherGroup to 5 ; UrbanCloudy
elseif fRandomPercentValue >= 65 && fRandomPercentValue < 90
set gWeatherGroup to 6 ; Overcast
elseif fRandomPercentValue >= 90
set gWeatherGroup to 8 ; Sandstorm
endif
set fRandomPercentValue to 5.0/99 * getRandomPercent ; (get random weather)
elseif gWeatherGroup == 6 ; Overcast
set fRandomPercentValue to getRandomPercent ; (get next weather group)
if fRandomPercentValue < 40
set gWeatherGroup to 5 ; UrbanCloudy
elseif fRandomPercentValue >= 40 && fRandomPercentValue < 70
set gWeatherGroup to 6 ; Overcast
elseif fRandomPercentValue >= 70
set gWeatherGroup to 7 ; Rain
endif
elseif gWeatherGroup == 7 ; Rain
set fRandomPercentValue to getRandomPercent ; (get next weather group)
if fRandomPercentValue < 30
set gWeatherGroup to 4 ; LightRain
elseif fRandomPercentValue >= 30 && fRandomPercentValue < 60
set gWeatherGroup to 6 ; Overcast
elseif fRandomPercentValue >= 60
set gWeatherGroup to 7 ; Rain
endif
elseif gWeatherGroup == 8 ; Sandstorm
if GetIsCurrentWeather 0DWSandStorm != 1 && GetIsCurrentWeather 0DWSandStorm2 != 1
setWeather 0DWSandStorm 1
elseif GetIsCurrentWeather 0DWSandStorm == 1
setWeather 0DWSandStorm2 1
set fRandomPercentValue to getRandomPercent ; (get next weather group)
if fRandomPercentValue < 30
set gWeatherGroup to 3 ; WastelandCloudy
elseif fRandomPercentValue >= 30 && fRandomPercentValue < 60
set gWeatherGroup to 5 ; UrbanCloudy
elseif fRandomPercentValue >= 60
set gWeatherGroup to 6 ; Overcast
endif
endif
endif
Basically, these are the bits of code that determine what the next weather "group" will be (ie, the really interesting bits - I've pulled out all the SetWeather stuff here, for clarity). Weather groups are made up of weather types with similar cloud textures.
So, starting out with a Clear weather type/group, when it is time for a weather change, the script sets a weather type and randomly picks the next weather group, so that we end up with a progression like: Clear > LightCloud > WastelandCloudy > UrbanCloudy > Overcast, etc. At any point along the progression the climate can revert to a previous weather group, or (depending on weather group/type) skew off to the Rain or Sandstorm groups.
The way I have it set up at the moment, is that upon installing the mod, the script sets the current weather type/group to WastelandClear / Clear - ie, the default weather you see outside Vault 101, Megaton etc. I suppose this could just as well be made to be a random weather type... :shrug:
From a modding/scripting perspective I'd be interested to hear any thoughts on the values that I've chosen, because in testing, the script had the habit of not progressing very far from Clear. During one test it took, literally, days to get some cloud cover or a sandstorm. Then on another test, it was a matter of hours before it was raining... I'm guessing that's because of the value checks on getRandomPercent I've chosen in the first (Clear) weather group, but then at the same time the Wasteland is a bit of desert, so it should be sunny? :shrug:
Once it does get going though, it is pretty awesome and so much less random than using Chance values in a normal Climate like I've used previously. :nod:
What all this does mean however, is that you can no longer create your own custom climate, like you could previously with my Climate Overrider plugin. But, some small voices in the back of head keep whispering "menus, menus, make a menu..." Please make them stop!
Anyway, thats about all I have to say at the moment ! :twirl:
~Xeph'