Advertisement
TheSixth

Bugfixes for Selchar's Calendar and Weather System

Dec 10th, 2016
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.56 KB | None | 0 0
  1. #===============================================================================
  2. # * [ACE] Bugfixes for Selchar's Calendar and Weather System
  3. #===============================================================================
  4. # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
  5. # * Version: 1.0
  6. # * Updated: 11/12/2016
  7. # * Requires: Selchar's Calendar and Weather System
  8. #-------------------------------------------------------------------------------
  9. # * < Change Log >
  10. #-------------------------------------------------------------------------------
  11. # * Version 1.0 (11/12/2016)
  12. #   - Initial release.
  13. #-------------------------------------------------------------------------------
  14. # * < Description >
  15. #-------------------------------------------------------------------------------
  16. # * This script fixes the incorrect time calculation in
  17. #   Selchar's Calendar and Weather script.
  18. # * Moves the common event calls to the end of the time update method, so you
  19. #   can use accurate time/variable checks in your common events if needed.
  20. # * Automatically generates the correct "day in year" value for the variable.
  21. #   Doing this manually is a pain if you want to start your game somewhere
  22. #   not at the start of the year.
  23. # * Adds a new, working script call to jump to a specific time.
  24. #   If the time is already passed on the current day, it jumps to the specified
  25. #   time on the next day.
  26. #   Got an option to skip time based common events and jump straight to the
  27. #   specified time. If you choose to not skip the common events, the time will
  28. #   stop if a common event is triggered somewhere between the time of running
  29. #   the script call and the specified time destination automatically.
  30. #-------------------------------------------------------------------------------
  31. # * < Script Calls >
  32. #-------------------------------------------------------------------------------
  33. # * To jump to a specific time, use this script call:
  34. #
  35. #     HM_SEL.jump_to_time(hour,minute,skip_flag)
  36. #
  37. #   Replace hour with the hour you want to jump to. Values: 0 - 23.
  38. #   Default value: 6.
  39. #
  40. #   Replace minute with the minute you want to jump to. Values: 0 - 59.
  41. #   Default value: 0.
  42. #  
  43. #   Replace skip_flag with:
  44. #   true = Skips time based common events during this script call.
  45. #   false = Time based common events will break the forced time progression
  46. #           automatically if they trigger.
  47. #   The default value: true.
  48. #
  49. #   If you omit any of the arguments, their default value will be loaded!
  50. #
  51. #   Examples:
  52. #
  53. #     HM_SEL.jump_to_time(18,24,false)
  54. #   Jumps to 18:24. If that time already passed on the current day, skips to
  55. #   the same time on the next day.
  56. #   If there would be a time based common event during this forced time
  57. #   progression, the time will stop the moment it would trigger.
  58. #
  59. #     HM_SEL.jump_to_time(0,0)
  60. #   Jumps to midnight.
  61. #   Time based common events will be skipped with this script call.
  62. #
  63. #   NOTE:
  64. #   The script call "next_day" and "next_day(x)" from Selchar's script will
  65. #   NOT work anymore, so don't use that!
  66. #   This one does the same but with more options, and hey, this one works! :P
  67. #-------------------------------------------------------------------------------
  68. # * < Installation >
  69. #-------------------------------------------------------------------------------
  70. # * Place this scipt right below
  71. #   Selchar's Harvest Moon style Variable Based Calendar and Weather System
  72. #   (wow, what a long name o.o) script but above any addons for it!
  73. #-------------------------------------------------------------------------------
  74. # * < Compatibility Info >
  75. #-------------------------------------------------------------------------------
  76. # * No known incompatibilities.
  77. #-------------------------------------------------------------------------------
  78. # * < Known Issues >
  79. #-------------------------------------------------------------------------------
  80. # * No known issues.
  81. #-------------------------------------------------------------------------------
  82. # * < Terms of Use >
  83. #-------------------------------------------------------------------------------
  84. # * Free to use for whatever purposes you want.
  85. # * Credit me (Sixth) in your game, pretty please! :P
  86. # * Posting modified versions of this script is allowed as long as you notice me
  87. #   about it with a link to it!
  88. #===============================================================================
  89. $imported = {} if $imported.nil?
  90. $imported["SixthHMSelFix"] = true
  91. #===============================================================================
  92. # Settings:
  93. #===============================================================================
  94. module HM_SEL
  95.   #-----------------------------------------------------------------------------
  96.   # Starting Time and Date Settings:
  97.   #-----------------------------------------------------------------------------
  98.   # From now on, you will need to set the starting time and date here.
  99.   # This setting will not be loaded from Selchar's script anymore!
  100.   #
  101.   # Do NOT change the "DAYC" variable setting!
  102.   # That will be automatically calculated for you based on the starting date
  103.   # you set.
  104.   #-----------------------------------------------------------------------------
  105.   def self.init_var
  106.     if $game_variables[DAYA] == 0    # Don't change this line!
  107.       $game_variables[MIN]    = 10   # Starting minute
  108.       $game_variables[HOUR]   = 18   # Starting hour
  109.       $game_variables[DAYA]   = 7    # Weekday: 1 = Monday, ... 7 = Sunday
  110.       $game_variables[DAYB]   = 25   # Day of the month
  111.       $game_variables[MONTH]  = 4    # Starting month
  112.       $game_variables[YEAR]   = 1978 # Starting year
  113.       $game_variables[WEATHA] = 1    # Initial weather. 1: Sun, 2: Rain, 3: Snow
  114.       $game_variables[WEATHB] = 1    # Next day weather.
  115.       $game_variables[DAYC] =   get_days_passed # Day of the year - Don't change!
  116.       show_tint     # Don't change this line!
  117.       show_weather  # Don't change this line!
  118.     end
  119.   end
  120. #===============================================================================
  121. # End of settings! O.o
  122. #===============================================================================
  123.  
  124.   def self.time_manager
  125.     init_var
  126.     unless time_stop?
  127.       if $sel_time_frame == FRAMES_TIL_UPDATE
  128.         prog_minute
  129.       end
  130.       $sel_time_frame += 1
  131.     end
  132.   end
  133.  
  134.   def self.prog_minute(skip=false)
  135.     $sel_time_frame = 0
  136.     tint_flag = false
  137.     weather_flag = false
  138.     # Increase time:
  139.     $game_variables[MIN] += $game_variables[MINUTE_CYCLE]
  140.     # End of hour check:
  141.     while $game_variables[MIN] >= 60
  142.       tint_flag = true
  143.       $game_variables[MIN] -= 60
  144.       $game_variables[HOUR] += 1
  145.       # End of day check:
  146.       if $game_variables[HOUR] >= 24
  147.         weather_flag = true
  148.         $game_variables[HOUR] = 0
  149.         $game_variables[DAYA] += 1 # Weekday
  150.         $game_variables[DAYB] += 1 # Day of Month
  151.         $game_variables[DAYC] += 1 # Day of Year
  152.         $game_variables[DAYA] = 1 if $game_variables[DAYA] == 8 # Fix weekday
  153.         # End of month check:
  154.         if $game_variables[DAYB] > DAYS_IN_MONTH[$game_variables[MONTH]]
  155.           $game_variables[DAYB] = 1
  156.           $game_variables[MONTH] += 1
  157.           # End of year check:
  158.           if $game_variables[MONTH] > DAYS_IN_MONTH.size
  159.             $game_variables[MONTH] = 1
  160.             $game_variables[YEAR] += 1
  161.             $game_variables[DAYC] = 1
  162.           end
  163.         end
  164.       end
  165.     end
  166.     # No idea what is this for, but setting festival day, I guess:
  167.     if festivalcheck($game_variables[DAYC])
  168.       $game_variables[FESTIVAL_VAR] = FESTIVALDAYS[$game_variables[DAYC]]
  169.     else
  170.       $game_variables[FESTIVAL_VAR] = 0
  171.     end
  172.     # Tint stuffs:
  173.     show_tint if tint_flag
  174.     # Weather stuffs:
  175.     weather_manager if weather_flag
  176.     # Common event check:
  177.     call_common_event unless skip
  178.   end
  179.  
  180.   # Automatically calculates the correct day in the year.
  181.   # Setting this up manually can be annoying.
  182.   def self.get_days_passed
  183.     tdays = 0
  184.     DAYS_IN_MONTH.each do |mid,total|
  185.       next unless $game_variables[MONTH] > mid
  186.       tdays += total
  187.     end
  188.     tdays += $game_variables[DAYB]
  189.     return tdays
  190.   end
  191.  
  192.   def self.call_common_event
  193.     hour = $game_variables[HOUR]
  194.     min = $game_variables[MIN]
  195.     if COMMON_EVENTS[hour] != nil
  196.       if COMMON_EVENTS[hour][0] == min
  197.         $game_temp.reserve_common_event(COMMON_EVENTS[hour][1])
  198.       end
  199.     end
  200.   end
  201.  
  202.   def self.show_tint(dura = 60)
  203.     hour = $game_variables[HOUR]
  204.     t = TONES[hour] unless no_tone?
  205.     t = TONE_DEFAULT if t.nil?
  206.     $game_map.screen.start_tone_change(t, dura)
  207.   end
  208.  
  209.   # New script call to jump to a specific time.
  210.   # This one actually works, unlike HM_SEL.next_day, so use this one instead!
  211.   # You can skip time based common events if you want.
  212.   # If you won't skip them, whenever one is triggered, this script call will
  213.   # stop the forced time progression to execute it!
  214.   def self.jump_to_time(thour=6,tmin=0,cmev=true)
  215.     $sel_time_frame = 0
  216.     old_prog_val = $game_variables[MINUTE_CYCLE]
  217.     $game_variables[MINUTE_CYCLE] = 1
  218.     until $game_variables[HOUR] == thour && $game_variables[MIN] == tmin
  219.       prog_minute(cmev) # Forced time progression.
  220.       break if $game_temp.common_event_reserved? # Break if common event!
  221.     end
  222.     $game_variables[MINUTE_CYCLE] = old_prog_val
  223.   end
  224.  
  225. end
  226. #==============================================================================
  227. # !!END OF SCRIPT - OHH, NOES!!
  228. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement