# Random Weather Generator
# Broken Wire
# Version: 3.0
# Date: 1/28/07
module BSR
# Constructer Event ID
CONSTRUCT_ID = 1
# Region IDs ####Please do not edit, though you may add to the list!
ALL = 'All'
PLAINS = 'Plains'
FOREST = 'Forest'
DESERT = 'Desert'
ARCTIC = 'Arctic'
OCEAN = 'Ocean'
# Weather Hash
WEATHER = {
ALL => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19],
PLAINS => [1, 2, 4, 5], FOREST => [1, 2, 4, 5, 6, 7, 8, 9],
DESERT => [18], ARCTIC => [3, 16], OCEAN => [1, 2, 4, 5]
}
end
class Scene_Map
#Aliases
alias brkn_init initialize
alias brkn_updt update
#Init
def initialize
@weather_on = true
@weather = [0, 0] #Current weather [type, power]
@memorized = [0, 0] #Memorized weather data [type, power]
@fade_active = false
@rage_actice = false
@count = 0 #Count value for update method
end
# Memorize Weather
def memorize_weather
if !memorized?
@memorized[0] = @weather[0]
@memorized[1] = @weather[1]
@weather[0] = 0
@weather[1] = 0
$game_screen.weather(@weather[0], @weather[1], 0)
end
end
# Memorized?
def memorized?
if @memorized[0] != nil
return true
end
return false
end
# Restore Weather
def restore_weather
if memorized?
@weather[0] = @memorized[0]
@weather[1] = @memorized[1]
@memorized[0] = 0
@memorized[1] = 0
$game_screen.weather(@weather[0], @weather[1], 0)
end
end
# Enragen the Weather
def rage_weather
power = @weather[1] + rand(10)
$game_screen.weather(@weather[0], power, rand(19) + 1)
if rand(5) > 3
@rage_active = true
else
@rage_active = false
end
update
end
# Fade the Weather
def fade_weather
power = @weather[1] - rand(10)
$game_screen.weather(@weather[0], power, rand(19) + 1)
if rand(5) > 3
@fade_active = true
else
@fade_active = false
end
update
end
# Update
def update
# Update regularly
brkn_updt
if @weather_on == true
if memorized?
restore_weather
end
types = []
# Fade Weather
if @fade_active == true
fade_weather
# Rage Weather
elsif @rage_active == true
rage_weather
end
event = $game_map.events[CONSTRUCT_ID]
unless event.erased
unless event.list.nil?
event.list.each do |event_command|
if event_command.code == 108 && event_command.code == 408
line0 = event_command.parameters[0]
#Weather Update
if line0.include?(BSR::ALL)
@count = (@count + 1) % 1400
if @count == (rand(99) + 1) + 100 and @fade_active == false and @rage_active == false
#use special Fade or Rage features here if weather_type != 0
if $game_screen.weather_type != 0
if $game_screen.power? > 25
@fade_active = true #Make the weather fade out a little.
update
elsif $game_screen.power? <= 25
@rage_active = true #Make the weather get heavier/harsher
update
end
end
#Otherwise, create a random weather effect at low power!
$game_screen.weather(rand(BRW::WEATHER.keys.size - 1) + 1, rand(10), rand(9) + 1)
end
elsif line0.include?(BSR::PLAINS)
@count = (@count + 1) % 1400
if @count == (rand(99) + 1) + 100 and @fade_active == false and @rage_active == false
plains = BSR::WEATHER[BSR::PLAINS].values
#use special Fade or Rage features here if weather_type != 0
if $game_screen.weather_type != 0
if $game_screen.power? > 25
@fade_active = true #Make the weather fade out a little.
update
elsif $game_screen.power? <= 25
@rage_active = true #Make the weather get heavier/harsher
update
end
end
#Otherwise, create a random weather effect at low power!
n_weather = plains[rand(plains.size - 1)]
$game_screen.weather(n_weather, rand(10), rand(9) + 1)
end
elsif line0.include?(BSR::FOREST)
@count = (@count + 1) % 1400
if @count == (rand(99) + 1) + 100 and @fade_active == false and @rage_active == false
forest = BSR::WEATHER[BSR::FOREST].values
#use special Fade or Rage features here if weather_type != 0
if $game_screen.weather_type != 0
if $game_screen.power? > 25
@fade_active = true #Make the weather fade out a little.
update
elsif $game_screen.power? <= 25
@rage_active = true #Make the weather get heavier/harsher
update
end
end
#Otherwise, create a random weather effect at low power!
n_weather = forest[rand(forest.size - 1)]
$game_screen.weather(n_weather, rand(10), rand(9) + 1)
end
elsif line0.include?(BSR::DESERT)
@count = (@count + 1) % 1400
if @count == (rand(99) + 1) + 100 and @fade_active == false and @rage_active == false
desert = BSR::WEATHER[BSR::DESERT].values
#use special Fade or Rage features here if weather_type != 0
if $game_screen.weather_type != 0
if $game_screen.power? > 25
@fade_active = true #Make the weather fade out a little.
update
elsif $game_screen.power? <= 25
@rage_active = true #Make the weather get heavier/harsher
update
end
end
#Otherwise, create a random weather effect at low power!
n_weather = desert[rand(desert.size - 1)]
$game_screen.weather(n_weather, rand(10), rand(9) + 1)
end
elsif line0.include?(BSR::ARCTIC)
@count = (@count + 1) % 1400
if @count == (rand(99) + 1) + 100 and @fade_active == false and @rage_active == false
arctic = BSR::WEATHER[BSR::ARCTIC].values
#use special Fade or Rage features here if weather_type != 0
if $game_screen.weather_type != 0
if $game_screen.power? > 25
@fade_active = true #Make the weather fade out a little.
update
elsif $game_screen.power? <= 25
@rage_active = true #Make the weather get heavier/harsher
update
end
end
#Otherwise, create a random weather effect at low power!
n_weather = arctic[rand(arctic.size - 1)]
$game_screen.weather(n_weather, rand(10), rand(9) + 1)
end
elsif line0.include?(BSR::OCEAN)
@count = (@count + 1) % 1400
if @count == (rand(99) + 1) + 100 and @fade_active == false and @rage_active == false
ocean = BSR::WEATHER[BSR::OCEAN].values
#use special Fade or Rage features here if weather_type != 0
if $game_screen.weather_type != 0
if $game_screen.power? > 25
@fade_active = true #Make the weather fade out a little.
update
elsif $game_screen.power? <= 25
@rage_active = true #Make the weather get heavier/harsher
update
end
end
#Otherwise, create a random weather effect at low power!
n_weather = ocean[rand(ocean.size - 1)]
$game_screen.weather(n_weather, rand(10), rand(9) + 1)
end
end
end
end
end
elsif @weather_on == false
memorize_weather
end
end
end
class Game_Screen
alias brkn_init initialize
def initialize
@power = 0
brkn_init
end
def weather(type, power, duration)
@weather_type_target = type
if @weather_type_target != 0
@weather_type = @weather_type_target
@power = power
end
if @weather_type_target == 0
@weather_max_target = 0.0
else
@weather_max_target = (power + 1) * 4.0
end
@weather_duration = duration
if @weather_duration == 0
@weather_type = @weather_type_target
@weather_max = @weather_max_target
end
end
def power?
return @power
end
end