Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # The random Weather Chanche out of 100.
- RANDOM_WEATHER_CHANCHE=50
- #["","Rain","Storm","Snow","Sandstorm","Sunny","HeavyRain","Blizzard"]]
- #===============================================================================
- # * Method which will check whether the weather needs a change
- # depending on season + location.
- #===============================================================================
- def weatherNeedsChange?(weather)
- val=rand(100)
- case $PokemonGlobal.season[0]
- when "Spring" || "Autumn"
- # Rain
- return true if (weather==1 && val>90)
- # Storm
- return true if (weather==2 && val>90)
- # Snow
- return true if (weather==3 && val>25)
- # Sandstorm
- return true if (weather==4 && val>90)
- # Sunny
- return true if (weather==5 && val>90)
- # HeavyRain
- return true if (weather==6 && val>90)
- # Blizzard
- return true if (weather==7 && val>25)
- when "Summer"
- # Rain
- return true if (weather==1 && val>25)
- # Storm
- return true if (weather==2 && val>25)
- # Snow
- return true if (weather==3 && val>5)
- # Sandstorm
- return true if (weather==4 && val>95)
- # Sunny
- return true if (weather==5 && val>95)
- # HeavyRain
- return true if (weather==6 && val>25)
- # Blizzard
- return true if (weather==7 && val>5)
- # when "Winter"
- # Rain
- return true if (weather==1 && val>90)
- # Storm
- return true if (weather==2 && val>90)
- # Snow
- return true if (weather==3 && val>95)
- # Sandstorm
- return true if (weather==4 && val>5)
- # Sunny# Sunny
- return true if (weather==5 && val>5)
- # HeavyRain
- return true if (weather==6 && val>90)
- # Blizzard
- return true if (weather==7 && val>95)
- end
- # None
- return true if (weather==nil && val>RANDOM_WEATHER_CHANCHE)
- return false
- end
- #===============================================================================
- # * Creating and returning random weather depending on season + location.
- #===============================================================================
- def randomWeather
- environment=pbGetEnvironment
- weather=[0,250,50,50,0,300,100,0] if isSeason?("Spring") || isSeason?("Autumn")
- weather=[0,50,50,0,0,600,50,0] if isSeason?("Summer")
- weather=[0,100,50,500,0,50,100,100] if isSeason?("Winter")
- # Changing weather chanches depending on the environment.
- if environment==PBEnvironment::Grass ||
- environment==PBEnvironment::TallGrass ||
- environment==PBEnvironment::Rock
- weather[4]=0
- weather[7]=0
- elsif environment==PBEnvironment::MovingWater ||
- environment==PBEnvironment::StillWater
- weather[4]=0
- elsif environment==PBEnvironment::Sand
- weather[1]/=4
- weather[2]/=4
- weather[3]/=4
- weather[4]+=750
- weather[5]+=250
- weather[6]/=4
- weather[7]/=4
- elsif environment==PBEnvironment::Underwater ||
- environment==PBEnvironment::Cave
- return nil
- end
- # Calculating the chanches + returning weather depending on chanche.
- rand_num=0
- for i in 0...weather.length
- rand_num+=weather[i]
- end
- randVal=rand(rand_num)
- minVal=0 ; maxVal=0
- for i in 0...weather.length
- weather[i].round
- maxVal+=weather[i]
- if randVal>minVal && randVal<maxVal
- return [i,100]
- else
- minVal+=weather[i]
- end
- end
- return nil
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement