#-------------------------------------------------------------------------------
#Harvest Moon style Variable Based Calendar and Weather System
#Author: Selchar
#Version 2.1
#-------------------------------------------------------------------------------
=begin
This is an attempt to make an easy to use yet customizable calendar system
similar to what can be found in Harvest Moon games. It's come a long say since
the initial release, as I've remade the whole thing to make it easier to
understand and customizable. Instructions are down below in the customization
area.
#-------------------------------------------------------------------------------
#Map/Tileset Note Tags
#-------------------------------------------------------------------------------
The following can be used in either map note boxes, or tileset note boxes.
<stop_time> - Maps with this tag will disable time.
<no_tone> - Maps with this tag will use the default done setting.
<inside_map> - Maps with this tag will not show weather effects, but
will have background sound volume will be divided by 3
<no_weather> - Maps with this tag will not show weather or use said weather's
background sound.
#-------------------------------------------------------------------------------
#Scriptcalls
#-------------------------------------------------------------------------------
All scriptcalls begin with HM_SEL::
next_day - This scriptcall will transition the day forward to the
nearest 6 AM.
next_day(x) - It also allows for an optional argument to select what
time of the day you will arrive at.
show_tint - This scriptcall should be used after manually changing
the time variable, to re-adjust the tone settings needed.
show_weather - This scriptcall should be used after manually adjusting
the Weather variable.
festivalcheck(x) - This scriptcall will return true if day x of the year is
flagged for a festival.
tomorrow_festival? - This scriptcall will return true if tomorrow is flagged
as a festival.
exact_time(h, m) - Returns true if it is the specified time.
Example: HM_SEL::exact_time(22, 10) is true at 10:10 PM
hour_range(a, b) - Returns true if the current hour is within the range.
Example: HM_SEL::hour_range(9, 21) is false before 9 AM
and after 9 PM, otherwise is true.
week_range(a, b) - Same as hour_range except for days.
=end
#-------------------------------------------------------------------------------
#Customization Begin
#-------------------------------------------------------------------------------
module HM_SEL
#What variables will be used
MIN = 11 #Minute Variable
HOUR = 12 #Hour variable, actual/military time. 0 = 12 AM, 13 = 1 PM
DAYA = 13 #Day of the Week variable, 1 for Monday, 7 for Sunday
DAYB = 14 #Day of the Month variable, you can find a use for it I'm sure.
DAYC = 15 #Day of the Year variable, used for festival day checks.
MONTH = 16 #Month Variable
YEAR = 17 #Year Variable
WEATHA = 18 #Current Weather
WEATHB = 19 #Tomorrow's Weather
#Used to determine if the currend day is flagged as a festival. 0 means it's
#a normal day, and you can set different values for different days in the
#FESTIVALDAYS hash below.
FESTIVAL_VAR = 20
#Switches that can be used for extra control. Set to 0 if you don not wish
#to use them.
STOP_TIME = 0
NO_TONE = 0
INSIDE_SWITCH = 0
DISABLE_WEATHER = 0
FRAMES_TIL_UPDATE = 60 #How quickly time updates, 60 roughly = 1 second
MINUTE_CYCLE = 1 #How many minutes pass per update
DAYS_IN_MONTH = {
#Month => Days,
1 => 30,
2 => 30,
3 => 30,
4 => 30,
#Add more for more months.
}#Please do not remove
#Want a common event to run at a specific time? Add it below in the shown format!
#Note, you can only have 1 common event per hour.
COMMON_EVENTS = {
#Hour => [Minute, ID],
6 => [0, 1], #Midnight
}#Please do not remove
#Hash used for flagging special days of the year. All days will be 0 by
#default. Day refers to the day of the year, Variable is what number you
#want to associate with said day for eventing purposes.
FESTIVALDAYS = {
#Day => Variable,
1 => 0,
2 => 1,
}#Please do not remove
TONE_DEFAULT = Tone.new(0,0,0,0)
TONES = {
=begin
#orignal tone changes
#Hour => Tone Settings(Red, Green, Blue, Grey)
0 => Tone.new(-125,-125,0,125),
1 => Tone.new(-125,-125,0,125),
2 => Tone.new(-125,-125,0,125),
3 => Tone.new(-125,-125,0,125),
4 => Tone.new(-75,-75,0,50),
5 => Tone.new(-75,-75,0,50),
11 => Tone.new(45,45,0,-25),
12 => Tone.new(45,45,0,-25),
13 => Tone.new(45,45,0,-25),
14 => Tone.new(45,45,0,-25),
18 => Tone.new(-50,-50,0,25),
19 => Tone.new(-50,-50,0,25),
20 => Tone.new(-50,-50,0,25),
21 => Tone.new(-75,-100,0,75),
22 => Tone.new(-75,-100,0,75),
23 => Tone.new(-75,-100,0,75),
=end
0 => Tone.new(-70,-70,0,70),
1 => Tone.new(-70,-70,0,70),
2 => Tone.new(-70,-70,0,70),
3 => Tone.new(-70,-70,0,70),
4 => Tone.new(-55,-55,0,55),
5 => Tone.new(-40,-40,0,40),
6 => Tone.new(-20,-20,0,20),
7 => Tone.new(-10,-10,0,10),
8 => Tone.new(0,0,0,0),
17 => Tone.new(20,-20,-20,0),
18 => Tone.new(40,-40,-40,0),
19 => Tone.new(40,-40,-40,0),
20 => Tone.new(-40,-50,-10,30),
21 => Tone.new(-70,-70,0,70),
22 => Tone.new(-70,-70,0,70),
23 => Tone.new(-70,-70,0,70),
}
WEATHER = {
#Month => [Odds, Weather, BGS, Volume, Pitch]
1 => [55, :rain, "Rain", 95, 100],
2 => [45, :rain, "Rain", 95, 100],
3 => [60, :rain, "Rain", 95, 100],
4 => [60, :snow, "Wind", 75, 100],
}
#The following methods are used as condions for determining whether or not to
#use this script's effect. Feel free to add/remove conditions as you see fit.
def self.time_stop?
#EXAMPLES
#Stops time at 11 PM
#return true if $game_variables[HOUR] == 23
#Stops time if not moving
#return true if $game_player.movable?
return true if $game_switches[STOP_TIME]
return true if $game_message.visible == true #Stop time during messages.
return true if $game_map.interpreter.running? #Stop time running events.
return true if $game_map.map.stop_time
return true if $game_map.tileset.stop_time
return false
end
def self.no_tone?
return true if $game_switches[NO_TONE]
return true if $game_map.map.no_tone
return true if $game_map.tileset.no_tone
return false
end
def self.inside?
return true if $game_switches[INSIDE_SWITCH]
return true if $game_map.map.inside_map
return true if $game_map.tileset.inside_map
return false
end
def self.no_weather?
return true if $game_switches[DISABLE_WEATHER]
return true if $game_map.map.no_weather
return true if $game_map.tileset.no_weather
return false
end
#This determines what the variables will be at the start of the game.
def self.init_var
if $game_variables[DAYA] == 0 #Ignore this
$game_variables[DAYA] = 1 #1 = Monday, 7 = Sunday
$game_variables[DAYB] = 1 #Day of the month
$game_variables[DAYC] = 1 #Day of the year
$game_variables[MONTH] = 1 #Starting month
$game_variables[YEAR] = 1 #Starting year
$game_variables[WEATHA] = 1 #Initial weather.
$game_variables[WEATHB] = 1 #1 = Sun, 2 = Rain, 3 = Snow
$game_variables[HOUR] = 6 #1 = Monday, 7 = Sunday
show_tint
show_weather
end
end
end
#-------------------------------------------------------------------------------
#Customization End
#-------------------------------------------------------------------------------
#Beow is the core of the script. It should be easy to understand, tho there
#is little reason to change anything, feel free to look around.
#===============================================================================
$sel_time_frame = 0
module HM_SEL
def self.prog_minute #Minute's End
$sel_time_frame = 0
$game_variables[MIN] += MINUTE_CYCLE
#Checks Common Event Hash
call_common_event
end
def self.prog_hour #Hour's End
$game_variables[MIN] = 0
$game_variables[HOUR] += 1
show_tint
end
def self.prog_day #Day's End
$game_variables[HOUR] = 0
$game_variables[DAYA] += 1
$game_variables[DAYB] += 1
$game_variables[DAYC] += 1
#Week's end
$game_variables[DAYA] = 1 if $game_variables[DAYA] == 8
#Month's end
if $game_variables[DAYB] > DAYS_IN_MONTH[$game_variables[MONTH]]
$game_variables[DAYB] = 1
$game_variables[MONTH] += 1
end
#Year's end
if $game_variables[MONTH] > DAYS_IN_MONTH.size
$game_variables[DAYC] = 1
$game_variables[MONTH] = 1
$game_variables[YEAR] += 1
end
#Shift Weather
weather_manager
if festivalcheck($game_variables[DAYC])
$game_variables[FESTIVAL_VAR] = FESTIVALDAYS[$game_variables[DAYC]]
else
$game_variables[FESTIVAL_VAR] = 0
end
end
#-----------------------------------------------------------------------------
#Start of Time Manager--------------------------------------------------------
#-----------------------------------------------------------------------------
def self.time_manager
unless time_stop?
init_var
if $sel_time_frame == FRAMES_TIL_UPDATE
prog_minute
prog_hour if $game_variables[MIN] >= 60
prog_day if $game_variables[HOUR] >= 24 && $game_variables[MIN] == 0
end
$sel_time_frame += 1
end
end
#-----------------------------------------------------------------------------
def self.call_common_event
hour = $game_variables[HOUR]
minute = $game_variables[MIN]
#Corrects time if minute is 60
if minute == 60
hour += 1
minute = 0
end
hour = 0 if hour == 24
if COMMON_EVENTS[hour] != nil
if COMMON_EVENTS[hour].at(0) == minute
$game_temp.reserve_common_event(COMMON_EVENTS[hour].at(1))
end
end
end
#-----------------------------------------------------------------------------
#=#Tone Related-----------------------------------------------------------------
#-----------------------------------------------------------------------------
def self.show_tint(dura = 60)
hour = $game_variables[HOUR];hour = 0 if hour == 24
t = TONES[hour] unless no_tone?
t = TONE_DEFAULT if t == nil
$game_map.screen.start_tone_change(t, dura)
end
#-----------------------------------------------------------------------------
#=#Weather Related--------------------------------------------------------------
#-----------------------------------------------------------------------------
def self.weather_manager
$game_variables[WEATHA] = $game_variables[WEATHB]
t_weather = 1
unless tomorrow_festival?
random_number = 1 + rand(100)
odds = WEATHER[$game_variables[MONTH]]
if random_number <= odds[0]
case odds[1]
when :rain
t_weather = 2
when :snow
t_weather = 3
when :storm
t_weather = 4
end
end
end
$game_variables[WEATHB] = t_weather
show_weather
end
def self.show_weather(dura = 300)
unless no_weather?
temp = WEATHER[$game_variables[MONTH]]
unless inside?
case $game_variables[WEATHA]
when 1 #Sun
$game_map.screen.change_weather(:none, 0, dura)
Audio.bgs_stop
else
$game_map.screen.change_weather(temp[1], 5, dura)
RPG::BGS.new(temp[2], temp[3], temp[4]).play
end
else #Inside
$game_map.screen.change_weather(:none, 0, 0)
case $game_variables[WEATHA]
when 1 #Sun
Audio.bgs_stop
else
RPG::BGS.new(temp[2], temp[3]/3, temp[4]).play
end
end
else
$game_map.screen.change_weather(:none, 0, 120)
Audio.bgs_stop
end
end
#-----------------------------------------------------------------------------
#=#Scriptcalls------------------------------------------------------------------
#-----------------------------------------------------------------------------
def self.next_day(temp_hour = 6)
$sel_time_frame = 0
case $game_variables[HOUR]
when 0...temp_hour
$game_variables[MIN] = 0
$game_variables[HOUR] = temp_hour
else
prog_day
$game_variables[MIN] = 0
$game_variables[HOUR] = temp_hour
show_tint
end
end
def self.festivalcheck(day)
return false if FESTIVALDAYS[day] == nil
return false if FESTIVALDAYS[day] == 0
return true
end
def self.tomorrow_festival?
return festivalcheck($game_variables[DAYC] + 1)
end
def self.exact_time(hour, min)
if $game_variables[HOUR] == hour && $game_variables[MIN] == min
return true
else
return false
end
end
def self.hour_range(hour_a, hour_b)
if $game_variables[HOUR] >= hour_a && $game_variables[HOUR < hour_b]
return true
else
return false
end
end
def self.week_range(day_a, day_b)
if $game_variables[DAYA] >= day_a && $game_variables[DAYA] < day_b
return true
else
return false
end
end
end
#-------------------------------------------------------------------------------
#Auto Weather/Tone change during transfers just before Fade-In
#-------------------------------------------------------------------------------
class Scene_Map < Scene_Base
alias :sel_time_post_transfer :post_transfer
def post_transfer
HM_SEL::show_tint(0)
HM_SEL::show_weather(0)
sel_time_post_transfer
end
alias :hm_sel_update :update
def update
hm_sel_update
HM_SEL::time_manager
end
end
#-------------------------------------------------------------------------------
#Map Note Tags Begin============================================================
#-------------------------------------------------------------------------------
class Game_Map
attr_accessor :map
end
class RPG::Map
def stop_time
if @stop_time.nil?
if @note =~ /<stop_time>/i
@stop_time = true
else
@stop_time = false
end
end
@stop_time
end
def no_tone
if @no_tone.nil?
if @note =~ /<no_tone>/i
@no_tone = true
else
@no_tone = false
end
end
@no_tone
end
def inside_map
if @inside_map.nil?
if @note =~ /<inside_map>/i
@inside_map = true
else
@inside_map = false
end
end
@inside_map
end
def no_weather
if @no_weather.nil?
if @note =~ /<no_weather>/i
@no_weather = true
else
@no_weather = false
end
end
@no_weather
end
end
class RPG::Tileset
def stop_time
if @stop_time.nil?
if @note =~ /<stop_time>/i
@stop_time = true
else
@stop_time = false
end
end
@stop_time
end
def no_tone
if @no_tone.nil?
if @note =~ /<no_tone>/i
@no_tone = true
else
@no_tone = false
end
end
@no_tone
end
def inside_map
if @inside_map.nil?
if @note =~ /<inside_map>/i
@inside_map = true
else
@inside_map = false
end
end
@inside_map
end
def no_weather
if @no_weather.nil?
if @note =~ /<no_weather>/i
@no_weather = true
else
@no_weather = false
end
end
@no_weather
end
end
#-------------------------------------------------------------------------------
#End of File
#-------------------------------------------------------------------------------