Advertisement
neonblack

Unique Transfers V1.0

Jul 17th, 2012
927
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.03 KB | None | 0 0
  1. ###--------------------------------------------------------------------------###
  2. #  Unique Transfers 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 - 7.17.2012                                                            #
  22. #   Rewrote map transitions portion                                            #
  23. #  V0.1 - 6.25.2012                                                            #
  24. #   Wrote and debugged main script                                             #
  25. ###--------------------------------------------------------------------------###
  26.  
  27. ###--------------------------------------------------------------------------###
  28. #      Compatibility:                                                          #
  29. #  Alias       - Scene_Battle: start                                           #
  30. #  Overwrites  - Scene_Map: perform_battle_transition, pre_transfer,           #
  31. #                           post_transfer                                      #
  32. #  New Objects - Scene_Base: custom_transition, custom_transfers,              #
  33. #                            get_trans_image                                   #
  34. ###--------------------------------------------------------------------------###
  35.  
  36. ###--------------------------------------------------------------------------###
  37. #      Instructions:                                                           #
  38. #  Place this script in the "Materials" section of the scripts above main.     #
  39. #  This script overwrites how transitions are handled when changing maps and   #
  40. #  when entering battle.  This script requires some customization to work      #
  41. #  properly as well as some custom graphics.  Be sure to read each config      #
  42. #  option before using.                                                        #
  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. module CP        # Do not                                                      #
  52. module TRANSFERS #  change these.                                              #
  53. #                                                                              #
  54. ###-----                                                                -----###
  55. # The folder that stores all the transfer images.  Change this is you want to  #
  56. # add a new folder.  All folders go within the "Graphics" folder.              #
  57. FOLDER = "System" # Default = "System"                                         #
  58. #                                                                              #
  59. # Set if the screen is wiped to black before battle.  If this is set to false  #
  60. # the screen will change directly to the battle screen using the transition    #
  61. # much like in RPG Maker XP.                                                   #
  62. BATTLE_WIPE = true # Default = true                                            #
  63. #                                                                              #
  64. # An array containing the names of all the custom battle transfers.  This      #
  65. # array MUST have at least one entry.  Be sure to surround each entry in       #
  66. # quotes and seperate them with a comman, ie. ["Battle1", "Battle2"].          #
  67. BATTLE =[ "BattleStart", ]
  68. #                                                                              #
  69. # Set if you want to use custom map transfers.  If this is set to false, the   #
  70. # last few options don't matter.                                               #
  71. MAP_TRANSFERS = false # Default = false                                        #
  72. #                                                                              #
  73. # Choose if you want to wipe the map when transferring maps.  If this option   #
  74. # is set to false transfers will go right from one map to the next without a   #
  75. # black screen.  Also if it is set to false, only "TRANSFER_IN" transitions    #
  76. # are used.                                                                    #
  77. MAP_WIPE = true # Default = true                                               #
  78. #                                                                              #
  79. # This array contains the transitions to use when erasing the map.  This array #
  80. # must be set up the same way as the battle array above.  If this blank, the   #
  81. # default fade effect is used.                                                 #
  82. TRANSFER_OUT =[]
  83. #                                                                              #
  84. # This array contains the transfers for re-drawing the screen after a map      #
  85. # transfer.  It follows the same rules as the other two above.  If blank, the  #
  86. # default fade effect is used.                                                 #
  87. TRANSFER_IN =[]
  88. #                                                                              #
  89. ###--------------------------------------------------------------------------###
  90.  
  91.  
  92. ###--------------------------------------------------------------------------###
  93. #  The following lines are the actual core code of the script.  While you are  #
  94. #  certainly invited to look, modifying it may result in undesirable results.  #
  95. #  Modify at your own risk!                                                    #
  96. ###--------------------------------------------------------------------------###
  97.  
  98. end
  99. end
  100.  
  101. $imported = {} if $imported.nil?
  102. $imported["CP_TRANSITION"] = 1.0
  103.  
  104. class Scene_Base  ## Calls the transition change.  Kinda pointless I guess.
  105.   def custom_transition(*args)
  106.     Graphics.transition(*args)
  107.   end
  108.  
  109.   def custom_transfers(key)  ## Gets the full name of the transfer image.
  110.     folder = CP::TRANSFERS::FOLDER
  111.     image = get_trans_image(key)
  112.     trans = "Graphics/" + folder + "/" + image
  113.     return trans
  114.   end
  115.  
  116.   def get_trans_image(key)  ## Gets the transfer image file.
  117.     max = 0
  118.     case key
  119.     when :battle
  120.       total = CP::TRANSFERS::BATTLE.size  ## Sets up random number grabbing.
  121.       max = rand(total) if total > 1
  122.       image = CP::TRANSFERS::BATTLE[max]
  123.     when :mapout
  124.       total = CP::TRANSFERS::TRANSFER_OUT.size
  125.       max = rand(total) if total > 1
  126.       image = CP::TRANSFERS::TRANSFER_OUT[max]
  127.     when :mapin
  128.       total = CP::TRANSFERS::TRANSFER_IN.size
  129.       max = rand(total) if total > 1
  130.       image = CP::TRANSFERS::TRANSFER_IN[max]
  131.     end
  132.     return image
  133.   end
  134. end
  135.  
  136. class Scene_Map < Scene_Base
  137.   def perform_battle_transition
  138.     if CP::TRANSFERS::BATTLE_WIPE  ## Changes the battle transition for wipe.
  139.       trans = custom_transfers(:battle)
  140.       custom_transition(60, trans, 100)
  141.     end
  142.     Graphics.freeze
  143.   end
  144.  
  145.   def pre_transfer  ## The pre-transfer method.
  146.     @map_name_window.close  ## Below gets checks in transfer anims early.
  147.     frz = (CP::TRANSFERS::MAP_TRANSFERS && !CP::TRANSFERS::TRANSFER_IN.empty?)
  148.     if (CP::TRANSFERS::MAP_TRANSFERS && !CP::TRANSFERS::TRANSFER_OUT.empty?) ||
  149.         !CP::TRANSFERS::MAP_WIPE
  150.       Graphics.freeze  ## Freeze the screen to normal.
  151.       if CP::TRANSFERS::MAP_WIPE  ## Ignore unless map should be wiped.
  152.         gw = Graphics.width  ## Width and height for later used.
  153.         gh = Graphics.height
  154.         @clear_screen = Sprite.new  ## Create a blank sprite.
  155.         @clear_screen.z = 500
  156.         @clear_screen.bitmap = Bitmap.new(gw, gh)
  157.         if $game_temp.fade_type == 1  ## Sets the sprite's colour.
  158.           cl = Color.new(255, 255, 255)
  159.         else
  160.           cl = Color.new(0, 0, 0)
  161.         end
  162.         @clear_screen.bitmap.fill_rect(0, 0, gw, gh, cl)
  163.         trans = custom_transfers(:mapout)  ## Get the transition name.
  164.         custom_transition(fadeout_speed, trans, 100)  ## Perform transition.
  165.         Graphics.freeze if frz  ## Freeze the screen for custom transitions.
  166.         fadeout(1)  ## Actually darken the screen.
  167.         @clear_screen.dispose  ## Destroy the sprite.
  168.       end
  169.     else  ## Normal processing.
  170.       case $game_temp.fade_type
  171.       when 0
  172.         fadeout(fadeout_speed)
  173.       when 1
  174.         white_fadeout(fadeout_speed)
  175.       end
  176.       Graphics.freeze if frz  ## An added freeze for transitions.
  177.     end
  178.   end
  179.  
  180.   def post_transfer  ## Post transfer processing overwrite.
  181.     if CP::TRANSFERS::MAP_TRANSFERS && !CP::TRANSFERS::TRANSFER_IN.empty?
  182.       Graphics.wait(fadein_speed / 2) if CP::TRANSFERS::MAP_WIPE
  183.       fadein(1)  ## Create the normal screen.
  184.       trans = custom_transfers(:mapin)  ## Get transfer name.
  185.       custom_transition(fadein_speed, trans, 100)  ## Perform transfer.
  186.     else  ## Normal processing.
  187.       case $game_temp.fade_type
  188.       when 0
  189.         Graphics.wait(fadein_speed / 2)
  190.         fadein(fadein_speed)
  191.       when 1
  192.         Graphics.wait(fadein_speed / 2)
  193.         white_fadein(fadein_speed)
  194.       end
  195.     end
  196.     @map_name_window.open
  197.   end
  198. end
  199.  
  200. class Scene_Battle < Scene_Base
  201.   alias cp_battle_trans start unless $@
  202.   def start  ## Alias for XP style battle transitions.
  203.     cp_battle_trans
  204.     unless CP::TRANSFERS::BATTLE_WIPE
  205.       trans = custom_transfers(:battle)
  206.       custom_transition(60, trans, 100)
  207.     end
  208.   end
  209. end
  210.  
  211.  
  212. ###--------------------------------------------------------------------------###
  213. #  End of script.                                                              #
  214. ###--------------------------------------------------------------------------###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement