#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# Refer to "$game_temp" for the instance of this class.
#==============================================================================
class game_temp
attr_accessor :game_time
alias old_init initialize
def initialize
old_init
@game_time = Game_Time.new
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class scene_map
alias old_update update
def update
old_update
$game_temp.game_time.update
end
end
#==============================================================================
# ** Game_Time
#------------------------------------------------------------------------------
# This class performs all processing related to in-game time and season.
# Refer to "$game_temp.weather_control" for the instance of this class.
#==============================================================================
class Game_Time
#--------------------------------------------------------------------------
# * Seasonal Color Tones
#--------------------------------------------------------------------------
module Time_Tones
Spring_Hourly_Tones = [
Tone.new(-127, -108, -58, 80), #+#--> Begin Full Nighttime (12:00am)
Tone.new(-127, -108, -58, 80), #| (01:00am)
Tone.new(-127, -108, -58, 80), #| (02:00am)
Tone.new(-127, -108, -58, 80), #+#<-- End Full Nighttime (03:00am)
Tone.new(-107, -98, -51, 60), # (04:00am)
Tone.new(-87, -88, -45, 40), # (05:00am)
Tone.new(-67, -78, -38, 20), #=#>-< Sunrise (06:00am)
Tone.new(-56, -65, -32, 17), # (07:00am)
Tone.new(-45, -52, -25, 13), # (08:00am)
Tone.new(-33, -39, -19, 10), # (09:00am)
Tone.new(-22, -26, -13, 7), # (10:00am)
Tone.new(-11, -13, -7, 4), # (11:00am)
Tone.new(0, 0, 0, 0), #+#--> Begin Full Daylight (12:00pm)
Tone.new(0, 0, 0, 0), #| (01:00pm)
Tone.new(0, 0, 0, 0), #| (02:00pm)
Tone.new(0, 0, 0, 0), #| (03:00pm)
Tone.new(0, 0, 0, 0), #| (04:00pm)
Tone.new(0, 0, 0, 0), #+#<-- End Full Daylight (05:00pm)
Tone.new(-17, -22, -27, 20), # (06:00pm)
Tone.new(-47, -68, -78, 45), #=#>-< Sunset (07:00pm)
Tone.new(-87, -98, -68, 70), # (08:00pm)
Tone.new(-127, -108, -58, 80), #+#--> Begin Full Nighttime (09:00pm)
Tone.new(-127, -108, -58, 80), #| (10:00pm)
Tone.new(-127, -108, -58, 80) #+#<-- End Full Nighttime (11:00pm)
]
Summer_Hourly_Tones = [
Tone.new(-117, -108, -58, 80), #+#--> Begin Full Nighttime (12:00am)
Tone.new(-117, -108, -58, 80), #| (01:00am)
Tone.new(-117, -108, -58, 80), #| (02:00am)
Tone.new(-117, -108, -58, 80), #+#<-- End Full Nighttime (03:00am)
Tone.new(-94, -90, -59, 62), # (04:00am)
Tone.new(-70, -73, -59, 43), # (05:00am)
Tone.new(-47, -55, -60, 25), #=#>-< Sunrise (06:00am)
Tone.new(-38, -45, -53, 21), # (07:00am)
Tone.new(-28, -34, -46, 17), # (08:00am)
Tone.new(-19, -24, -38, 12), # (09:00am)
Tone.new(-9, -14, -31, 8), # (10:00am)
Tone.new(1, -4, -24, 4), # (11:00am)
Tone.new(10, 7, -17, 0), #+#--> Begin Full Daylight (12:00pm)
Tone.new(10, 7, -17, 0), #| (01:00pm)
Tone.new(10, 7, -17, 0), #| (02:00pm)
Tone.new(10, 7, -17, 0), #| (03:00pm)
Tone.new(10, 7, -17, 0), #| (04:00pm)
Tone.new(10, 7, -17, 0), #+#<-- End Full Daylight (05:00pm)
Tone.new(-6, -20, -25, 10), # (06:00pm)
Tone.new(-22, -75, -65, 40), #=#>-< Sunset (07:00pm)
Tone.new(-83, -92, -62, 65), # (08:00pm)
Tone.new(-117, -108, -58, 80), #+#--> Begin Full Nighttime (09:00pm)
Tone.new(-117, -108, -58, 80), #| (10:00pm)
Tone.new(-117, -108, -58, 80) #+#<-- End Full Nighttime (11:00pm)
]
Autumn_Hourly_Tones = [
Tone.new(-105, -120, -50, 80), #+#--> Begin Full Nighttime (12:00am)
Tone.new(-105, -120, -50, 80), #| (01:00am)
Tone.new(-105, -120, -50, 80), #| (02:00am)
Tone.new(-105, -120, -50, 80), #+#<-- End Full Nighttime (03:00am)
Tone.new(-88, -100, -43, 63), # (04:00am)
Tone.new(-72, -80, 37, 47), # (05:00am)
Tone.new(-55, -60, -30, 30), #=#>-< Sunrise (06:00am)
Tone.new(-46, -56, -26, 27), # (07:00am)
Tone.new(-37, -52, -22, 23), # (08:00am)
Tone.new(-27, -47, -17, 20), # (09:00am)
Tone.new(-18, -43, -13, 17), # (10:00am)
Tone.new(-9, -39, -9, 14), # (11:00am)
Tone.new(0, -35, -5, 10), #+#--> Begin Full Daylight (12:00pm)
Tone.new(0, -35, -5, 10), #| (01:00pm)
Tone.new(0, -35, -5, 10), #| (02:00pm)
Tone.new(0, -35, -5, 10), #| (03:00pm)
Tone.new(0, -35, -5, 10), #| (04:00pm)
Tone.new(0, -35, -5, 10), #+#<-- End Full Daylight (05:00pm)
Tone.new(-15, -45, -25, 15), # (06:00pm)
Tone.new(-40, -65, -50, 30), #=#>-< Sunset (07:00pm)
Tone.new(-85, -100, -50, 65), # (08:00pm)
Tone.new(-105, -120, -50, 80), #+#--> Begin Full Nighttime (09:00pm)
Tone.new(-105, -120, -50, 80), #| (10:00pm)
Tone.new(-105, -120, -50, 80) #+#<-- End Full Nighttime (11:00pm)
]
Winter_Hourly_Tones = [
Tone.new(-135, -145, -100, 190), #+#--> Begin Full Nighttime (12:00am)
Tone.new(-135, -145, -100, 190), #| (01:00am)
Tone.new(-135, -145, -100, 190), #| (02:00am)
Tone.new(-135, -145, -100, 190), #+#<-- End Full Nighttime (03:00am)
Tone.new(-118, -132, -85, -178), # (04:00am)
Tone.new(-101, -118, -70, -163), # (05:00am)
Tone.new(-85, -105, -55, 150), #=#>-< Sunrise (06:00am)
Tone.new(-73, -92, -46, 140), # (07:00am)
Tone.new(-60, -78, -37, 130), # (08:00am)
Tone.new(-48, -65, -27, 120), # (09:00am)
Tone.new(-35, -52, -18, 110), # (10:00am)
Tone.new(-23, -39, -9, 100), # (11:00am)
Tone.new(-10, -25, 0, 90), #+#--> Begin Full Daylight (12:00pm)
Tone.new(-10, -25, 0, 90), #| (01:00pm)
Tone.new(-10, -25, 0, 90), #| (02:00pm)
Tone.new(-10, -25, 0, 90), #| (03:00pm)
Tone.new(-10, -25, 0, 90), #| (04:00pm)
Tone.new(-10, -25, 0, 90), #+#<-- End Full Daylight (05:00pm)
Tone.new(-30, -55, -25, 115), # (06:00pm)
Tone.new(-80, -110, -65, 150), #=#>-< Sunset (07:00pm)
Tone.new(-115, -130, -90, 180), # (08:00pm)
Tone.new(-135, -145, -100, 190), #+#--> Begin Full Nighttime (09:00pm)
Tone.new(-135, -145, -100, 190), #| (10:00pm)
Tone.new(-135, -145, -100, 190) #+#<-- End Full Nighttime (11:00pm)
]
end
#--------------------------------------------------------------------------
# * Time System Names
#--------------------------------------------------------------------------
module Time_Names
Weekdays = [
"Sunday",
"Monday",
"Tuesady",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
]
Months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
Seasons = [
"spring",
"summer",
"autumn",
"winter"
]
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# set @time to 0. @time is used in the update function.
@time = 0
end
#--------------------------------------------------------------------------
# * Object Update
#--------------------------------------------------------------------------
def update
# Set now to the current time on the computer clock
now = Time.now
# Set @current time to the current minute on the computer clock
@current_time = now.min
# If @time does not equal the current minute
if @time != @current_time
# Set the tone of the screen for the current time
set_time_tone
# Set @time to equal @current time.
@time = @current_time
end
end
#--------------------------------------------------------------------------
# * Change Screen Tone to Match Current Time
#--------------------------------------------------------------------------
def set_time_tone
# Set now to the current time on the computer clock
now = Time.now
# Set hour to the current hour on the computer clock
hour = now.hour
# Set minute to the current minute on the computer clock
minute = now.min
# If the current season is Spring or the Wet Season
if current_season(1) == 1
# Set tone to the current hour's tone for Spring
tone = Time_Tones::Spring_Hourly_Tones[hour]
# Set next_hour_tone to the next hour's tone for Spring
next_hour_tone = Time_Tones::Spring_Hourly_Tones[(hour+1)%24]
# If the current season is Summer or the Dry Season
elsif current_season(1) == 2
# Set tone to the current hour's tone for Summer
tone = Time_Tones::Summer_Hourly_Tones[hour]
# Set next_hour_tone to the next hour's tone for Summer
next_hour_tone = Time_Tones::Summer_Hourly_Tones[(hour+1)%24]
# If the current season is Autumn
elsif current_season(1) == 3
# Set tone to the current hour's tone for Autumn
tone = Time_Tones::Autumn_Hourly_Tones[hour]
# Set next_hour_tone to the next hour's tone for Autumn
next_hour_tone = Time_Tones::Autumn_Hourly_Tones[(hour+1)%24]
# If the current season is Winter
elsif current_season(1) == 4
# Set tone to the current hour's tone for Winter
tone = Time_Tones::Winter_Hourly_Tones[hour]
# Set next_hour_tone to the next hour's tone for Winter
next_hour_tone = Time_Tones::Winter_Hourly_Tones[(hour+1)%24]
end
# Set the color tones to the correct tones for the current minute
tone_red = (minute*(next_hour_tone.red-tone.red)/60.0)+tone.red
tone_green = (minute*(next_hour_tone.green-tone.green)/60.0)+tone.green
tone_blue = (minute*(next_hour_tone.blue-tone.blue)/60.0)+tone.blue
tone_gray = (minute*(next_hour_tone.gray-tone.gray)/60.0)+tone.gray
# If there are clouds in the sky,
# Set @current_tone to the current time's tone
@current_tone = Tone.new(tone_red, tone_green, tone_blue, tone_gray)
# If the map was just opened,
if @open_map == true
# If the tone is being overridden,
if @tone_override == true
# If the tone is not being overridden,
else
# Immediately set the screen to the current time's tone
$game_screen.start_tone_change(@current_tone, 0)
# Set @open_map to false
@open_map = false
end
# If the tone is being overridden,
elsif @tone_override == true
# If the tone is not being overridden or the map isn't opening,
else
# Set the screen to the current time's tone over a period of one minute
$game_screen.start_tone_change(@current_tone, 2400)
end
end
#--------------------------------------------------------------------------
# * Define Current Day
#--------------------------------------------------------------------------
def current_day(result)
# Set now to current computer time
now = Time.now
# Set day to current day of the week
day = now.strftime('%w')
# Set day2 to the current day of the month
day2 = now.strftime('%d')
# If weekday number is requested,
if result == 1
# Return the number of the current weekday
return day.to_i
# If the current day of the month is requested,
elsif result == 2
# Return the current day of the month
return day2.to_i
# If current weekday is requested,
elsif result == 3
# Return current weekday's name using the Time_Names module
return Time_Names::Weekdays[day.to_i]
end
end
#--------------------------------------------------------------------------
# * Define Current Month
#--------------------------------------------------------------------------
def current_month(result)
# Set now to the current computer time
now = Time.now
# Set month to the current month of the year
month = now.strftime('%m')
# If the month's number is requested,
if result == 1
# Return the number of the current month
return month.to_i
# If the current month's name is requested,
elsif result == 2
# Return the current month's name using the Time_Names module
return Time_Names::Months[month.to_i]
end
end
#--------------------------------------------------------------------------
# * Define Current Season
#--------------------------------------------------------------------------
def current_season(result)
# Set now to current time
now = Time.now
# Set day to the current day of the month
day = now.strftime('%d')
# Set month to the current month of the year
month = now.strftime('%m')
# If the current lattitude is in the northern temperate zone,
# If it is January or February,
if month.to_i <= 2
# Set season to winter
season = 4
# If it is before the 20th of March,
elsif month.to_i == 3 and day.to_i < 20
# Set season to winter
season = 4
# If it is or is after the 20th of March,
elsif month.to_i == 3 and day.to_i >= 20
# Set season to spring
season = 1
# If it is April or May,
elsif month.to_i == 4 or month.to_i == 5
# Set season to spring
season = 1
# If it is before the 20th of June,
elsif month.to_i == 6 and day.to_i < 20
# Set season to spring
season = 1
# If it is or is after the 20th of June,
elsif month.to_i == 6 and day.to_i >= 20
# Set season to summer
season = 2
# If it is July or August,
elsif month.to_i == 7 or month.to_i == 8
# Set season to summer
season = 2
# If it is before the 22nd of September,
elsif month.to_i == 9 and day.to_i < 22
# Set season to summer
season = 2
# If it is or is after the 22nd of September,
elsif month.to_i == 9 and day.to_i >= 22
# Set season to autumn
season = 3
# If it is October or November,
elsif month.to_i == 10 or month.to_i == 11
# Set season to autumn
season = 3
# If it is beofore the 21st of December,
elsif month.to_i >= 12 and day.to_i < 21
# Set season to autumn
season = 3
# If it is or is after the 21st of December,
elsif month.to_i >= 12 and day.to_i >= 21
# Set season to winter
season = 4
end
# If the current season's number is requested,
if result == 1
# Return the number of the current season, in order from Spring -> Winter
if season == 1
return 1
elsif season == 2
return 2
elsif season == 3
return 3
elsif season == 4
return 4
end
# If the name of the current season is requested,
elsif result = 2
# Return the name of the current season, using the Time_Names module
return Time_Names::Seasons[season]
end
end
#--------------------------------------------------------------------------
# * Initialize Map Tone
#--------------------------------------------------------------------------
def open_map
# Set @open_map to true and change the screen tone
@open_map = true
set_time_tone
end
#--------------------------------------------------------------------------
# * Override Time Tone
#--------------------------------------------------------------------------
def tone_override(result)
# Set @tone_override to true or false, based on method call
@tone_override = result
end
end