Advertisement
neonblack

Old Style Battlebacks

Jan 8th, 2013
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.18 KB | None | 0 0
  1. ###-----------------------------------------------------------------------------
  2. #  Old (VX) Battleback script v1.0
  3. #  Created by Neon Black
  4. #  V0.1 - 7.7.2012 - Original alpha version
  5. #  V1.0 - 1.8.2013 - Version created for release
  6. #  Created for both commercial and non-commercial use as long as credit is
  7. #  given to Neon Black.
  8. ###-----------------------------------------------------------------------------
  9.  
  10. module CP             # Do not
  11. module OLD_BATTLEBACK #  change these.
  12.  
  13. # The switch to disable the changes this script makes entirely.  While this
  14. # switch is on, the default battlebacks are used.
  15. DISABLE_SWITCH = 79
  16.  
  17. # This sets the colour offset of the battleback.  Use this to darken or
  18. # lighten the battleback as you see fit.
  19. COLOR_SET = Color.new(16, 16, 16, 128)
  20.  
  21. # Determines if events are shown in the background image.  The default
  22. # behaviour of this is "false".
  23. EVENTS_IN_BACKGROUND = true
  24.  
  25. # The percentage to stretch the battleback by.  Read as a percentage.  Set it
  26. # to 100 to prevent it from stretching.
  27. STRETCH_X = 110
  28. STRETCH_Y = 110
  29.  
  30. # Set if phasing and the radial blur are used.  VX Ace uses radial blur but NO
  31. # phasing if no battleback is defined by a map while VX uses both phasing and
  32. # radial blur by default.
  33. USE_PHASING = true
  34. USE_RADIAL = true
  35.  
  36. # The battlefloor image settings.  First is the name of the battlefloor image
  37. # which must be placed in the "Graphics/System" folder.  Second is the Y
  38. # position of the image on the screen which can be adjusted to move the image
  39. # up or down.  Finally is the opacity of the image.
  40. BATTLEFLOOR = "BattleFloor"
  41. BF_Y_OFFSET = Graphics.height - 120
  42. BF_OPACITY = 128
  43.  
  44. # The amplitude, length, and speed of the phasing option.  Amp is the
  45. # distance of the horizontal movement from the edges of the screen.  Length is
  46. # the distance vertically between each part of the wave, and speed is how
  47. # quickly the phasing effect moves.
  48. WAVE_AMP = 8
  49. WAVE_LENGTH = 240
  50. WAVE_SPEED = 120
  51.  
  52. # The angle and division of the radial blur.  Angle is how far it is rotated
  53. # clockwise while division is the number of times the image is copied before
  54. # reaching the angle.  This is time consuming by the system.
  55. BLUR_ANGLE = 90
  56. BLUR_DIVISION = 12
  57.  
  58. ###--------------------------------------------------------------------------###
  59. #  The following lines are the actual core code of the script.  While you are  #
  60. #  certainly invited to look, modifying it may result in undesirable results.  #
  61. #  Modify at your own risk!                                                    #
  62. ###--------------------------------------------------------------------------###
  63.  
  64.  
  65. end
  66. end
  67.  
  68. $imported = {} if $imported == nil
  69. $imported["CP_OLD_BATTLEBACK"] = 1.0
  70.  
  71. class Spriteset_Battle
  72.   include CP::OLD_BATTLEBACK
  73.  
  74.   ## Does radial blur and phasing.
  75.   def radial_blur(sprite)
  76.     sprite.bitmap.radial_blur(BLUR_ANGLE, BLUR_DIVISION)
  77.   end
  78.  
  79.   def phasing(sprite)
  80.     sprite.wave_amp = WAVE_AMP
  81.     sprite.wave_length = WAVE_LENGTH
  82.     sprite.wave_speed = WAVE_SPEED
  83.   end
  84.  
  85.   ## Creates the blurred background image.
  86.   alias cp_old_bb1 create_battleback1
  87.   def create_battleback1
  88.     return cp_old_bb1 if $game_switches[DISABLE_SWITCH]
  89.     @back1_sprite = Sprite.new(@viewport1)
  90.     @back1_sprite.bitmap = create_blurry_background_bitmap
  91.     @back1_sprite.color.set(COLOR_SET)
  92.     radial_blur(@back1_sprite) if USE_RADIAL
  93.     phasing(@back1_sprite) if USE_PHASING
  94.     @back1_sprite.z = 0
  95.     center_sprite(@back1_sprite)
  96.   end
  97.  
  98.   ## Creates the floor shadow or other floor image.
  99.   alias cp_old_bb2 create_battleback2
  100.   def create_battleback2
  101.     return cp_old_bb2 if $game_switches[DISABLE_SWITCH]
  102.     @back2_sprite = Sprite.new(@viewport1)
  103.     @back2_sprite.bitmap = Cache.system(BATTLEFLOOR)
  104.     @back2_sprite.opacity = BF_OPACITY
  105.     @back2_sprite.z = 1
  106.     center_sprite(@back2_sprite)
  107.     @back2_sprite.y = BF_Y_OFFSET
  108.   end
  109.  
  110.   ## Sends back a blurred background image.
  111.   alias cp_old_bbb create_blurry_background_bitmap
  112.   def create_blurry_background_bitmap
  113.     return cp_old_bbb if $game_switches[DISABLE_SWITCH]
  114.     if EVENTS_IN_BACKGROUND && !$BTEST  ## Determines what kind of image to use.
  115.       source = Scene_Map.pre_battle_scene
  116.     elsif !$BTEST
  117.       source = SceneManager.background_bitmap
  118.     else
  119.       source =  Cache.battleback1(battleback1_name)
  120.     end
  121.     bitmap = Bitmap.new((source.width * STRETCH_X) / 100,
  122.                         (source.height * STRETCH_Y) / 100)
  123.     bitmap.stretch_blt(bitmap.rect, source, source.rect)
  124.     bitmap
  125.   end
  126. end
  127.  
  128. ## Stores a background with events that can be grabbed by the battle sprites.
  129. class Scene_Map < Scene_Base
  130.   @@pre_battle_scene = Bitmap.new(1, 1)
  131.   def self.pre_battle_scene; return @@pre_battle_scene; end
  132.  
  133.   alias cp_pre_battle pre_battle_scene
  134.   def pre_battle_scene
  135.     SceneManager.snapshot_for_background
  136.     @@pre_battle_scene = SceneManager.background_bitmap.clone
  137.     cp_pre_battle
  138.   end
  139. end
  140.  
  141. ###--------------------------------------------------------------------------###
  142. #  End of script.                                                              #
  143. ###--------------------------------------------------------------------------###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement