Advertisement
Guest User

Untitled

a guest
Aug 30th, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.34 KB | None | 0 0
  1. # The random Weather Chanche out of 100.
  2. RANDOM_WEATHER_CHANCHE=50
  3.  
  4.  
  5. #["","Rain","Storm","Snow","Sandstorm","Sunny","HeavyRain","Blizzard"]]
  6. #===============================================================================
  7. # * Method which will check whether the weather needs a change
  8. #  depending on season + location.
  9. #===============================================================================
  10. def weatherNeedsChange?(weather)
  11.   val=rand(100)
  12.   case $PokemonGlobal.season[0]
  13.   when "Spring" || "Autumn"
  14.     # Rain
  15.     return true if (weather==1 && val>90)
  16.     # Storm
  17.     return true if (weather==2 && val>90)
  18.     # Snow
  19.     return true if (weather==3 && val>25)
  20.     # Sandstorm
  21.     return true if (weather==4 && val>90)
  22.     # Sunny
  23.     return true if (weather==5 && val>90)
  24.     # HeavyRain
  25.     return true if (weather==6 && val>90)
  26.     # Blizzard
  27.     return true if (weather==7 && val>25)
  28.   when "Summer"
  29.     # Rain
  30.     return true if (weather==1 && val>25)
  31.     # Storm
  32.     return true if (weather==2 && val>25)
  33.     # Snow
  34.     return true if (weather==3 && val>5)
  35.     # Sandstorm
  36.     return true if (weather==4 && val>95)
  37.     # Sunny
  38.     return true if (weather==5 && val>95)
  39.     # HeavyRain
  40.     return true if (weather==6 && val>25)
  41.     # Blizzard
  42.     return true if (weather==7 && val>5)
  43. #  when "Winter"
  44.     # Rain
  45.     return true if (weather==1 && val>90)
  46.     # Storm
  47.     return true if (weather==2 && val>90)
  48.     # Snow
  49.     return true if (weather==3 && val>95)
  50.     # Sandstorm
  51.     return true if (weather==4 && val>5)
  52.     # Sunny# Sunny
  53.     return true if (weather==5 && val>5)
  54.     # HeavyRain
  55.     return true if (weather==6 && val>90)
  56.     # Blizzard
  57.     return true if (weather==7 && val>95)
  58.   end
  59.   # None
  60.   return true if (weather==nil && val>RANDOM_WEATHER_CHANCHE)
  61.   return false
  62. end
  63.  
  64.  
  65. #===============================================================================
  66. # * Creating and returning random weather depending on season + location.
  67. #===============================================================================
  68. def randomWeather
  69.   environment=pbGetEnvironment
  70.   weather=[0,250,50,50,0,300,100,0] if isSeason?("Spring") || isSeason?("Autumn")
  71.   weather=[0,50,50,0,0,600,50,0] if isSeason?("Summer")
  72.   weather=[0,100,50,500,0,50,100,100] if isSeason?("Winter")
  73.   # Changing weather chanches depending on the environment.
  74.   if environment==PBEnvironment::Grass ||
  75.      environment==PBEnvironment::TallGrass ||
  76.      environment==PBEnvironment::Rock
  77.     weather[4]=0
  78.     weather[7]=0
  79.   elsif environment==PBEnvironment::MovingWater ||
  80.         environment==PBEnvironment::StillWater
  81.     weather[4]=0
  82.   elsif environment==PBEnvironment::Sand
  83.     weather[1]/=4
  84.     weather[2]/=4
  85.     weather[3]/=4
  86.     weather[4]+=750
  87.     weather[5]+=250
  88.     weather[6]/=4
  89.     weather[7]/=4
  90.   elsif environment==PBEnvironment::Underwater ||
  91.         environment==PBEnvironment::Cave
  92.     return nil
  93.   end
  94.   # Calculating the chanches + returning weather depending on chanche.
  95.   rand_num=0
  96.   for i in 0...weather.length
  97.     rand_num+=weather[i]
  98.   end
  99.   randVal=rand(rand_num)
  100.   minVal=0 ; maxVal=0
  101.   for i in 0...weather.length
  102.     weather[i].round
  103.     maxVal+=weather[i]
  104.     if randVal>minVal && randVal<maxVal
  105.       return [i,100]
  106.     else
  107.       minVal+=weather[i]
  108.     end
  109.   end
  110.   return nil
  111. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement