Guest User

Untitled

a guest
Jul 23rd, 2014
235
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #===============================================================================
  2. # ***TPS-Addon: Tints for Periods***
  3. #
  4. # Author: eugene222 (Evgenij)
  5. # Version: 1.2
  6. # Date: 21.05.2014
  7. # Requires: Time and Period System V. 1.2 by eugene222
  8. #===============================================================================
  9. # Changelog:
  10. #
  11. # 04.04.2014 - V. 1.0-alpha1 - script created
  12. # 05.04.2014 - V. 1.0 - released the script
  13. # 09.04.2014 - V. 1.1 - made this compatible with Core V. 1.1
  14. # 21.05.2014 - V. 1.2 - tints for phases added
  15. #
  16. #===============================================================================
  17. # Terms of Use:
  18. # You can use this script for free and commercial projects as long as you give
  19. # credits.
  20. #===============================================================================
  21. # Beschreibung:
  22. # Tints for periods.
  23. #
  24. # Scriptcalls:
  25. # $game_time.stop_tint # stop automatic tints
  26. # $game_time.resume_tint # resume automatic tints
  27. #
  28. #===============================================================================
  29. module TPS_TINT
  30. #-----------------------------------------------------------------------------
  31. # Use Battle Tints?
  32. #-----------------------------------------------------------------------------
  33. TONE_BATTLE = true
  34. #-----------------------------------------------------------------------------
  35. # FADE TIME FOR TINTS (in Frames)
  36. #-----------------------------------------------------------------------------
  37. FADE_TIME = 60
  38.  
  39. #-----------------------------------------------------------------------------
  40. DEFAULT = { # Diese Zeile nicht verändern!
  41. #-----------------------------------------------------------------------------
  42. # THE DEFAULT TINTS
  43. #-----------------------------------------------------------------------------
  44.  
  45. :morning => Tone.new( -51, -34, -17, 68),
  46. :forenoon => Tone.new( -51, -34, -17, 68),
  47. :noon => Tone.new( 0,0,0,0),
  48. :afternoon => Tone.new( 0, -17, -34, 0),
  49. :evening => Tone.new( 0, -34, -68, 34),
  50. :night => Tone.new( -102, -85, -34, 85),
  51.  
  52. #-----------------------------------------------------------------------------
  53. } # Diese Zeile nicht verändern!
  54. #-----------------------------------------------------------------------------
  55.  
  56.  
  57. #-----------------------------------------------------------------------------
  58. # If you use the Addon: Phases and Weather you can overwrite the default tints
  59. # for your custom phases
  60. # - When more than one phase is active and get its own tint, the tint for the
  61. # phase with the highest priority will be taken (the priority is definable
  62. # in the other Addon)
  63. #-----------------------------------------------------------------------------
  64. PHASES = {
  65.  
  66. #-----------------------------------------------------------------------
  67. # Overwrite some tints for winter.
  68. #-----------------------------------------------------------------------
  69. :winter => {
  70.  
  71. :noon => Tone.new( -5, 0, 15, 15),
  72. :afternoon => Tone.new( -15, -5, 20, 25),
  73. :evening => Tone.new( -80, -85, -34, 51),
  74.  
  75. },
  76. }
  77. end
  78. #===============================================================================
  79. # END OF CONFIG
  80. #===============================================================================
  81. $imported ||= {}
  82. $imported[:e222_tps_tints] = 1.2
  83. unless $imported[:e222_tps_core]
  84. msgbox("\"TBS-Addon: Tints for Periods\" requires the \"TBS-Core\" script.\n"+
  85. "The \"TBS-Core\" script must be placed above the addon script.")
  86. exit
  87. end
  88. #===============================================================================
  89. # Game_Time
  90. # aliased methods: initialize, post_set_period
  91. # new methods: stop_tint, resume_tint
  92. #===============================================================================
  93. class Game_Time
  94. #-----------------------------------------------------------------------------
  95. attr_reader :tint_screen
  96. #-----------------------------------------------------------------------------
  97. # Initialize
  98. #-----------------------------------------------------------------------------
  99. alias :tps_tint_reinitialize_e222 :reinitialize
  100. #-----------------------------------------------------------------------------
  101. def reinitialize
  102. tps_tint_reinitialize_e222
  103. @tint_screen = true if @tint_screen.nil?
  104. @tint_picture = true if @tint_picture.nil?
  105. @tone_phases ||= []
  106. end
  107. #-----------------------------------------------------------------------------
  108. # Initialize Period
  109. #-----------------------------------------------------------------------------
  110. alias :tps_tint_initialize_period_e222 :initialize_period
  111. #-----------------------------------------------------------------------------
  112. def initialize_period
  113. tps_tint_initialize_period_e222
  114. refresh_map_tone(0)
  115. initialize_tone_phases
  116. end
  117. #-----------------------------------------------------------------------------
  118. # Refresh Period
  119. #-----------------------------------------------------------------------------
  120. alias :tps_tint_refresh_period_e222 :refresh_period
  121. #-----------------------------------------------------------------------------
  122. def refresh_period
  123. tps_tint_refresh_period_e222
  124. case SceneManager.scene
  125. when Scene_Map
  126. refresh_map_tone(TPS_TINT::FADE_TIME)
  127. when Scene_Battle
  128. refresh_battle_tone(TPS_TINT::FADE_TIME)
  129. end
  130. end
  131. #-----------------------------------------------------------------------------
  132. # Refresh Map Tone
  133. #-----------------------------------------------------------------------------
  134. def refresh_map_tone(fade_time)
  135. return unless SceneManager.scene_is?(Scene_Map)
  136. $game_map.indoor? ? refresh_indoor_tone : refresh_outdoor_tone(fade_time)
  137. end
  138. #-----------------------------------------------------------------------------
  139. # Refresh Indoor Tone
  140. #-----------------------------------------------------------------------------
  141. def refresh_indoor_tone
  142. $game_map.set_screen_tone(Tone.new(0,0,0,0), 0)
  143. end
  144. #-----------------------------------------------------------------------------
  145. # Refresh Outdoor Tone
  146. #-----------------------------------------------------------------------------
  147. def refresh_outdoor_tone(fade_time)
  148. return unless @tint_screen
  149. return unless @tint_picture
  150. $game_map.set_screen_tone(get_tone, fade_time)
  151. end
  152. #-----------------------------------------------------------------------------
  153. # Refresh Battle Tone
  154. #-----------------------------------------------------------------------------
  155. def refresh_battle_tone(fade_time)
  156. return if $game_map.indoor? || !TPS_TINT::TONE_BATTLE || !@tint_screen
  157. $game_troop.set_screen_tone(get_tone, fade_time)
  158. end
  159. #-----------------------------------------------------------------------------
  160. # Sort Active Phases
  161. #-----------------------------------------------------------------------------
  162. if Game_Time.instance_methods.include?(:sort_active_phases)
  163. alias :tps_tint_sap_e222 :sort_active_phases
  164. #---------------------------------------------------------------------------
  165. def sort_active_phases
  166. tps_tint_sap_e222
  167. initialize_tone_phases
  168. end
  169. #---------------------------------------------------------------------------
  170. end
  171. #=============================================================================
  172. # For Phases and Weather Addon:
  173. #=============================================================================
  174.  
  175. #-----------------------------------------------------------------------------
  176. # Initialize Tone Phases
  177. #-----------------------------------------------------------------------------
  178. def initialize_tone_phases
  179. return unless $imported[:e222_tps_phases]
  180. tint_phases = TPS_TINT::PHASES
  181. @tone_phases = tint_phases.select {|k, v| tone_phase?(k)}.keys
  182. @tone_phases.sort_by! {|k| TPS_PHASES::CONDITIONS[k][:priority]}
  183. end
  184. #-----------------------------------------------------------------------------
  185. # Tone Phase
  186. #-----------------------------------------------------------------------------
  187. def tone_phase
  188. return @tone_phases.last
  189. end
  190. #-----------------------------------------------------------------------------
  191. # Tone Phase ?
  192. #-----------------------------------------------------------------------------
  193. def tone_phase?(key)
  194. return TPS_PHASES::CONDITIONS[key] && phase_active?(key)
  195. end
  196. #-----------------------------------------------------------------------------
  197. # Get Tone
  198. #-----------------------------------------------------------------------------
  199. def get_tone
  200. if $imported[:e222_tps_phases] && tone_phase
  201. return phase_tone if phase_tone
  202. return TPS_TINT::DEFAULT[@current_period]
  203. else
  204. return TPS_TINT::DEFAULT[@current_period]
  205. end
  206. end
  207. #-----------------------------------------------------------------------------
  208. # Phase Tone
  209. #-----------------------------------------------------------------------------
  210. def phase_tone
  211. return TPS_TINT::PHASES[tone_phase][@current_period]
  212. end
  213. #-----------------------------------------------------------------------------
  214. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  215. # Tint Script Calls:
  216. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  217. #-----------------------------------------------------------------------------
  218. # Stop Tint
  219. #-----------------------------------------------------------------------------
  220. def stop_tint
  221. @tint_screen = false
  222. @tint_picture = false
  223. end
  224. #-----------------------------------------------------------------------------
  225. # Resume Tine
  226. #-----------------------------------------------------------------------------
  227. def resume_tint
  228. @tint_screen = true
  229. @tint_picture = true
  230. refresh_period
  231. end
  232. #-----------------------------------------------------------------------------
  233. end
  234. #===============================================================================
  235. # Game_Troop
  236. # new method: set_screen_tone
  237. #===============================================================================
  238. class Game_Troop
  239. #-----------------------------------------------------------------------------
  240. # Set Screen Tone
  241. #-----------------------------------------------------------------------------
  242. def set_screen_tone(tone, fade_time)
  243. screen.start_tone_change(tone, fade_time)
  244. end
  245. #-----------------------------------------------------------------------------
  246. end
  247. #===============================================================================
  248. # Window_TimePopUp
  249. # new method: set_screen_tone
  250. #===============================================================================
  251. class Game_Map
  252. #-----------------------------------------------------------------------------
  253. # Set Screen Tone
  254. #-----------------------------------------------------------------------------
  255. def set_screen_tone(tone, fade_time)
  256. screen.start_tone_change(tone, fade_time)
  257. end
  258. #-----------------------------------------------------------------------------
  259. end
  260. #===============================================================================
  261. # SCRIPT END
  262. #===============================================================================
RAW Paste Data