class PTS
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :transition_time # transition time of weather
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@transition_time = 5
# Create Seasonal Weather Data [Map ID][Season][Weather Type]
# Percentage chance for each type of weather (must add to 100%)
@weather_data = []
@weather_data[1] = [[50, 5, 0, 45], [25, 50, 25], [25, 20, 20, 0, 10, 25],
[25, 15, 10, 10, 0, 0, 10, 15, 10, 5]]
# Create variables for weather? method
@perminence_factor = 10
@weather_same = 0
@weather_type = weather?
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if @total_min != $game_system.timer / Graphics.frame_rate
weather
end
$game_system.game_system_update
end
#--------------------------------------------------------------------------
# * Update Weather
#--------------------------------------------------------------------------
def weather
if @total_min % 60 == 0 or @indoors != @inside
@weather = @inside ? 0 : weather?
type = @weather
power = @inside ? 0 : 10 + rand(15) + @weather_same * 5
if power > 50 then power = 50 end
duration = @inside ? 0 : @transition_time * @speed * Graphics.frame_rate
$game_screen.weather(type, power, duration)
end
end
#--------------------------------------------------------------------------
# * Determine Weather Type
#--------------------------------------------------------------------------
def weather?
weather = 0
unless @weather_data[$game_map.map_id] == nil
# Create short forms for variables
percent = @weather_data[$game_map.map_id][season?][@weather]
pf = @perminence_factor
w = @weather
# Randomize Weather
n = rand(100)
total = 0
while w > 0
total += @weather_data[$game_map.map_id][season?][w]
w -= 1
end
add_sub = total < n ? true : false
if add_sub
n -= rand(percent / pf + percent % pf * 2 / pf)
else
n += rand(percent / pf + percent % pf * 2 / pf)
end
for i in @weather_data[$game_map.map_id][season?]
unless i == nil
n -= i
if n > 0 then weather += 1 else break end
else
break
end
end
end
if weather == 0
@weather_same = 0
else
if weather == @weather and @weather != nil
@weather_same += 1
else
@weather_same = 0
end
end
return weather
end
#--------------------------------------------------------------------------
# * Determine the season
#--------------------------------------------------------------------------
def season?
case @month
when 0 .. 1
season = 0
when 2
season = @days < 20 ? 0 : 1
when 3 .. 4
season = 1
when 5
season = @days < 21 ? 1 : 2
when 6 .. 7
season = 2
when 8
season = @days < 23 ? 2 : 3
when 9 .. 10
season = 3
when 11
season = @days < 21 ? 3 : 0
when 12 .. 13
season = 0
end
if season != @season and @season != nil
change_tilesets (season)
end
return season
end
end
class Game_System
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias game_system_update update
def update
$pts.update
end
end
class Scene_Title
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
alias scene_title_command_new_game command_new_game
def command_new_game
scene_title_command_new_game
# Create Progressive Time System Object
$pts = PTS.new
end
end
class Scene_Save
#--------------------------------------------------------------------------
# * Write Save Data
# file : write file object (opened)
#--------------------------------------------------------------------------
alias scene_save_write_save_data write_save_data
def write_save_data(file)
scene_save_write_save_data(file)
Marshal.dump($pts, file)
end
end
class Scene_Load
#--------------------------------------------------------------------------
# * Read Save Data
# file : file object for reading (opened)
#--------------------------------------------------------------------------
alias scene_load_read_save_data read_save_data
def read_save_data(file)
scene_load_read_save_data(file)
$pts = Marshal.load(file)
# Change Screen Tone
$game_screen.start_tone_change($pts.tone?, 0)
# Immediately redraw Sprite_Timer and Sprite_PTS
end
end