Advertisement
neonblack

Slo-mo Script V1.0 (vx)

Mar 21st, 2012
732
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.43 KB | None | 0 0
  1. ###--------------------------------------------------------------------------###
  2. #  Slo-mo script                                                               #
  3. #  Version 1.0                                                                 #
  4. #                                                                              #
  5. #      Credits:                                                                #
  6. #  Original code by: Neonblack                                                 #
  7. #  Modified by:                                                                #
  8. #                                                                              #
  9. #  This work is licensed under the Creative Commons Attribution-NonCommercial  #
  10. #  3.0 Unported License. To view a copy of this license, visit                 #
  11. #  http://creativecommons.org/licenses/by-nc/3.0/.                             #
  12. #  Permissions beyond the scope of this license are available at               #
  13. #  http://cphouseset.wordpress.com/liscense-and-terms-of-use/.                 #
  14. #                                                                              #
  15. #      Contact:                                                                #
  16. #  NeonBlack - neonblack23@live.com (e-mail) or "neonblack23" on skype         #
  17. ###--------------------------------------------------------------------------###
  18.  
  19. ###--------------------------------------------------------------------------###
  20. #      Revision information:                                                   #
  21. #  V1.0 - 10.29.2011                                                           #
  22. #   Wrote and debugged main script                                             #
  23. ###--------------------------------------------------------------------------###
  24.  
  25. ###--------------------------------------------------------------------------###
  26. #      Compatibility:                                                          #
  27. #  Alias       - Game_System: initialize, update                               #
  28. #                Sprite_Character: update                                      #
  29. #                Scene_Map: perform_battle_transition                          #
  30. #                Scene_Menu: initialize                                        #
  31. #  New Classes - Game_FrameRate                                                #
  32. #  New Objects - Game_FrameRate: initialize, update, glitch_test               #
  33. ###--------------------------------------------------------------------------###
  34.  
  35. ###--------------------------------------------------------------------------###
  36. #      Instructions:                                                           #
  37. #  Place this script in the "Materials" section of the scripts above main.     #
  38. #  This script is pretty much plug and play with a few options available to    #
  39. #  change below.  Using the script is as simple as changing a single           #
  40. #  variable.  To enter slo-mo, simply change the pre-defined variable.         #
  41. #  Since changing the framerate affects pretty much everything on screen and   #
  42. #  everything in an event, caution is advised when using this script.          #
  43. ###--------------------------------------------------------------------------###
  44.  
  45. ###--------------------------------------------------------------------------###
  46. #      Config:                                                                 #
  47. #  These are the default values used by several of the functions in the        #
  48. #  script.  You may change these values as you find your game requires in      #
  49. #  order to give the player a better playing experience based on your game.    #
  50. #                                                                              #
  51. # The default variable used for the frame rate.  Changing this variable at     #
  52. # any time in game will result in a modified frame rate.                       #
  53. SET_FPS_VARIABLE = 27 # Default = 27                                           #
  54. #                                                                              #
  55. # The default "slow" value.  While the framerate is this value or below, all   #
  56. # events on screen change to "add" blending mode to make slo-mo mode a little  #
  57. # more fancy.  Set this value to 9 or below to disable it.                     #
  58. SLOMO_BLEND_EFFECT = 30 # Default = 30                                         #
  59. #                                                                              #
  60. # The default min and max values for FPS.  These limit what your min and max   #
  61. # values can be in game to prevent large scale bugs.  Even if you set them     #
  62. # higher or lower, the RGSS2 core engine cannot use frame rates lower than 10  #
  63. # or higher than 120.                                                          #
  64. LIMIT_FPS_MAX = 60 # Default = 60                                              #
  65. LIMIT_FPS_MIN = 30 # Default = 30                                              #
  66. #                                                                              #
  67. ###--------------------------------------------------------------------------###
  68.  
  69.  
  70. ###--------------------------------------------------------------------------###
  71. #  The following lines are the actual core code of the script.  While you are  #
  72. #  certainly invited to look, modifying it may result in undesirable results.  #
  73. #  Modify at your own risk!                                                    #
  74. ###--------------------------------------------------------------------------###
  75.  
  76.  
  77. # New class  -  Controls the framerate in game if it is changed by a controller.
  78. class Game_FrameRate
  79.   def initialize
  80.     # Nothing here!  Is that even allowed?  In any case, this is a placeholder.
  81.   end
  82.  
  83.   def update
  84.     new_fps = $game_variables[SET_FPS_VARIABLE]
  85.     new_fps = 60 if new_fps < 10
  86.     new_fps = glitch_test(new_fps)
  87.     if not $scene.is_a?(Scene_Battle) && $scene != Scene_Menu
  88.       Graphics.frame_rate = new_fps if Graphics.frame_rate != new_fps
  89.     end
  90.     $game_variables[SET_FPS_VARIABLE] = new_fps
  91.   end
  92.  
  93. # New object  -  Called by the "update" object.  Used to check the new FPS
  94. #                value and limit it if needed.
  95.   def glitch_test(fps)
  96.     fps = LIMIT_FPS_MAX if fps > LIMIT_FPS_MAX
  97.     fps = LIMIT_FPS_MIN if fps < LIMIT_FPS_MIN
  98.     return fps
  99.   end
  100. end
  101.  
  102. class Game_System
  103. # Alias method  -  Used to initialize frame rate.
  104.   alias initialize_with_framerate initialize
  105.   def initialize
  106.     $cp_framerate = Game_FrameRate.new
  107.     initialize_with_framerate
  108.   end
  109.  
  110. # Alias method  -  Used to update the frame rate.
  111.   alias update_with_framerate update
  112.   def update
  113.     update_with_framerate
  114.     $cp_framerate.update
  115.   end
  116. end
  117.  
  118. class Sprite_Character < Sprite_Base
  119. # Alias method  -  Used to change sprite blending.
  120.   alias update_with_framerate update
  121.   def update
  122.     update_with_framerate
  123.     self.blend_type = Graphics.frame_rate <= SLOMO_BLEND_EFFECT ? 1 : 0
  124.   end
  125. end
  126.  
  127. class Scene_Map < Scene_Base
  128. # Alias method  -  Used to return the framerate to 60 in battle.
  129.   alias perform_battle_transition_with_framerate perform_battle_transition
  130.   def perform_battle_transition
  131.     Graphics.frame_rate = 60
  132.     perform_battle_transition_with_framerate
  133.   end
  134. end
  135.  
  136. class Scene_Menu < Scene_Base
  137. # Alias method  -  Used to return the framerate to 60 in the menu.
  138.   alias initialize_with_framerate initialize
  139.   def initialize(menu_index = 0)
  140.     Graphics.frame_rate = 60
  141.     initialize_with_framerate(menu_index)
  142.   end
  143. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement