Advertisement
EduAlves

Mog BattleBack Ex

Nov 9th, 2016
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 29.20 KB | None | 0 0
  1. #==============================================================================
  2. # +++ MOG - Battleback EX (v2.3) +++
  3. #==============================================================================
  4. # By Moghunter
  5. # https://atelierrgss.wordpress.com/
  6. #==============================================================================
  7. # Adiciona efeitos animados nos battlebacks e camadas infinitas.
  8. #==============================================================================
  9. # ● UTILIZAÇÃO
  10. #==============================================================================
  11. # Use os códigos abaixo através do comando chamar script.
  12. # NOTA - Os códigos podem ser usados no meio da  batalha.
  13. #
  14. # bb(LAYER_ID ,EFFECT ,POWER A, POWER B , BLENDY_TYPE , SCREEN_Z, FADE_SPEED )
  15. #
  16. # TYPE = 0...4
  17. #
  18. # 0 = Efeito slide
  19. # 1 = Efeito wave
  20. # 2 = Normal
  21. # 3 = Battleback animado por frames.
  22. # 4 = Perspective (Battle Camera)
  23. #
  24. # POWER 1  
  25. #
  26. # Velocidade de deslize na horizontal no efeito SLIDE.
  27. # Area de distorção no efeito WAVE. (de 0 a 20)
  28. #
  29. # POWER 2
  30. #
  31. # Velocidade de deslize na vertical no efeito SLIDE.
  32. # Velocidade de distorção do efeito WAVE.
  33. # Velocidade de animação no efeito 2.
  34. #
  35. # BLENDY_TYPE  (Opcional)
  36. # Efeito de blendy de 0 a 2
  37. #
  38. # SCREEN_Z (Opcional)
  39. # Posição Z da camada. (Valores acima de 100 ficam acima dos battlers)
  40. #
  41. # FADE_SPEED Opcional (Opcional)
  42. # Velocidade de Fade. (0 = Desativar)
  43. #
  44. #
  45. # Exemplo.
  46. #
  47. # bb(1,1,20,20)
  48. #
  49. #==============================================================================
  50. # ● Cancelar o Efeito.
  51. #==============================================================================
  52. # Para cancelar o efeito use o código abaixo.
  53. #
  54. # bb_clear
  55. #
  56. #==============================================================================
  57. # Efeito de animação por frames. (Efeito tipo 3)
  58. #==============================================================================
  59. # Para ativar o efeito de animação por frames é necessário ter e nomear os
  60. # arquivos da seguinte forma.
  61. #
  62. # Picture_Name.png  (A imagem que deve ser escolhida no comando do evento.)
  63. # Picture_Name0.png
  64. # Picture_Name1.png
  65. # Picture_Name2.png
  66. # Picture_Name3.png
  67. # Picture_Name4.png
  68. # ...
  69. #==============================================================================
  70. # DEFININDO MULTIPLAS CAMADAS (Acima de 2 camadas - Padrão)
  71. #==============================================================================
  72. # Para ativar camadas extras utilize o código abaixo.
  73. #
  74. # bb_name(LAYER_ID ,FILE_NAME)
  75. #
  76. # LAYER_ID   = ID da Camada
  77. # FILE_NAME  = Nome do arquivo
  78. #
  79. # Exemplo
  80. #
  81. #
  82. # bb_name(1,"BlueSky")
  83. # bb_name(2,"Fog_03")
  84. # bb_name(3,"Grassland_01B")
  85. # bb_name(4,"Fog_02")
  86. # ...
  87. #
  88. #==============================================================================
  89. # ● Histórico (Version History)
  90. #==============================================================================
  91. # v 2.3 - Adição do modo perspective.
  92. # v 2.2 - Compatibilidade com MOG Battle Camera.
  93. # v 2.1 - Melhoria no sistema de bitmap.
  94. # v 2.0 - Função do Battleback Animado por frames.
  95. #==============================================================================
  96. module MOG_BATTLEBACK_EX
  97.   # Definição da posição Z do Battleback (Apenas para ajustes de compatibilidade)
  98.   # É possível modificar o valor no meio do jogo usando o código abaixo.
  99.   #
  100.   # bb_screen_z(X)
  101.   #
  102.   SCREEN_Z = 0
  103. end
  104.  
  105. $imported = {} if $imported.nil?
  106. $imported[:mog_battleback_ex] = true
  107.  
  108. #==============================================================================
  109. # ■ Game Temp
  110. #==============================================================================
  111. class Game_Temp
  112.    
  113.   attr_accessor :bb_fade_duration
  114.  
  115.   #--------------------------------------------------------------------------
  116.   # ● Initialize
  117.   #--------------------------------------------------------------------------            
  118.   alias mog_bb_ex_initialize_temp initialize
  119.   def initialize
  120.       @bb_fade_duration = [0 , true]
  121.       mog_bb_ex_initialize_temp
  122.   end  
  123.  
  124. end  
  125. #==============================================================================
  126. # ■ Game System
  127. #==============================================================================
  128. class Game_System
  129.  
  130.   attr_accessor :bb_data
  131.   attr_accessor :bb_name
  132.   attr_accessor :bb_screen_z
  133.  
  134.   #--------------------------------------------------------------------------
  135.   # ● Initialize
  136.   #--------------------------------------------------------------------------          
  137.   alias mog_bb_ex_initialize initialize
  138.   def initialize
  139.       @bb_data = [] ; @bb_name = [] ; @bb_screen_z = MOG_BATTLEBACK_EX::SCREEN_Z
  140.       mog_bb_ex_initialize
  141.   end  
  142.  
  143. end
  144.  
  145. #==============================================================================
  146. # ■ Spriteset Battle
  147. #==============================================================================
  148. class Spriteset_Battle
  149.  
  150.   #--------------------------------------------------------------------------
  151.   # ● Initialize
  152.   #--------------------------------------------------------------------------    
  153.   alias mog_bb_ex_initialize initialize
  154.   def initialize
  155.       $game_temp.bb_fade_duration = [0,false] ; @back_sprite_ex = []
  156.       @bba_bitmap = [] ; @bba_frames = [] ; @bb_data = []
  157.       mog_bb_ex_initialize
  158.       create_battleback_ex
  159.       update
  160.   end  
  161.  
  162.   #--------------------------------------------------------------------------
  163.   # ● Create Battkeback EX
  164.   #--------------------------------------------------------------------------    
  165.   def create_battleback_ex
  166.       $game_system.bb_name.each_with_index do |bb, index|
  167.       create_bbex_sprite(bb, index) if bb != nil and !bb.empty?
  168.       end      
  169.   end
  170.  
  171.   #--------------------------------------------------------------------------
  172.   # ● Dispose
  173.   #--------------------------------------------------------------------------    
  174.   alias mog_bb_exm_dispose dispose
  175.   def dispose
  176.       dispose_battleback_ex
  177.       mog_bb_exm_dispose
  178.   end
  179.  
  180.   #--------------------------------------------------------------------------
  181.   # ● Dispose Batleback1
  182.   #--------------------------------------------------------------------------    
  183.   alias mog_bb_ex_dispose_battleback1 dispose_battleback1
  184.   def dispose_battleback1
  185.       mog_bb_ex_dispose_battleback1
  186.       dispose_battleback_ex ; dispose_sprites_a(0)
  187.   end
  188.  
  189.   #--------------------------------------------------------------------------
  190.   # ● Dispose Batleback2
  191.   #--------------------------------------------------------------------------    
  192.   alias mog_bb_ex_dispose_battleback2 dispose_battleback2
  193.   def dispose_battleback2
  194.       mog_bb_ex_dispose_battleback2
  195.       dispose_sprites_a(1)
  196.   end  
  197.  
  198.   #--------------------------------------------------------------------------
  199.   # ● Dispose Battleback
  200.   #--------------------------------------------------------------------------    
  201.   def dispose_battleback_ex
  202.       return if @back_sprite_ex == nil
  203.       @back_sprite_ex.compact.each_with_index {|sprite,index|
  204.       sprite.bitmap.dispose rescue nil ; sprite.dispose; dispose_sprites_a(index)}  
  205.   end  
  206.  
  207.   #--------------------------------------------------------------------------
  208.   # ● Disposes Sprites A
  209.   #--------------------------------------------------------------------------          
  210.   def dispose_sprites_a(type)
  211.       @bba_bitmap[type].each {|sprite| sprite.dispose } if @bba_bitmap[type]
  212.       @bba_bitmap[type] = nil
  213.   end  
  214.  
  215.   #--------------------------------------------------------------------------
  216.   # ● Update
  217.   #--------------------------------------------------------------------------  
  218.   alias mog_bb_ex_update update
  219.   def update
  220.       update_battleback_transition
  221.       mog_bb_ex_update
  222.   end
  223.  
  224.   #--------------------------------------------------------------------------
  225.   # ● Update Battleback Transition
  226.   #--------------------------------------------------------------------------        
  227.   def update_battleback_transition
  228.       @back_sprite_ex.each_with_index {|sprite,index| update_battleback_ex(index,@back1_sprite.opacity) }
  229.       return if $game_temp.bb_fade_duration[0] == 0
  230.       if $game_temp.bb_fade_duration[1]
  231.          $game_temp.bb_fade_duration = [0 , false] ; refresh_bb_ex
  232.          @back1_sprite.opacity = 255 if @back1_sprite != nil
  233.       end  
  234.       $game_temp.bb_fade_duration[0] -= 1
  235.       case $game_temp.bb_fade_duration[0]
  236.            when 129..300
  237.               @back1_sprite.opacity -= 2 if @back1_sprite != nil
  238.            when 1..128
  239.               if $game_temp.bb_fade_duration[0] == 128
  240.                  refresh_bb_ex
  241.                  @back1_sprite.opacity = 0 if @back1_sprite != nil
  242.               end  
  243.               @back1_sprite.opacity += 2 if @back1_sprite != nil
  244.            else    
  245.               @back1_sprite.opacity = 255 if @back1_sprite != nil
  246.       end      
  247.       @back2_sprite.opacity = @back1_sprite.opacity if @back2_sprite != nil
  248.   end  
  249.  
  250.   #--------------------------------------------------------------------------
  251.   # ● Refresh Battleback EX
  252.   #--------------------------------------------------------------------------          
  253.   def refresh_bb_ex  
  254.       dispose_battleback1 ; dispose_battleback2 ; dispose_battleback_ex
  255.       create_battleback1 ; create_battleback2 ; create_battleback_ex
  256.   end    
  257.  
  258.   #--------------------------------------------------------------------------
  259.   # ● Create_Battleback1
  260.   #--------------------------------------------------------------------------
  261.   def create_battleback1
  262.       dispose_sprites_a(0) ; @bb_data[0] = [] if @bb_data[0] == nil
  263.       $game_system.bb_data[0] = [] if $game_system.bb_data[0] == nil
  264.       if !$game_system.bb_data[0].empty? ; create_bb1_ex ; return ; end
  265.       c_normal_sprite(0)  
  266.   end
  267.  
  268.   #--------------------------------------------------------------------------
  269.   # ● Create_battleback2
  270.   #--------------------------------------------------------------------------
  271.   def create_battleback2
  272.       dispose_sprites_a(1) ; @bb_data[1] = [] if @bb_data[1] == nil
  273.       $game_system.bb_data[1] = [] if $game_system.bb_data[1] == nil
  274.       if !$game_system.bb_data[1].empty? ; create_bb2_ex ; return ; end
  275.       c_normal_sprite(1)  
  276.   end
  277.  
  278.   #--------------------------------------------------------------------------
  279.   # ● Dispose BB EX
  280.   #--------------------------------------------------------------------------    
  281.   def dispose_bb_ex(type)
  282.       sprite = set_current_battleback(type)
  283.       return if sprite == nil
  284.       sprite.bitmap.dispose rescue nil ; sprite.dispose ; sprite = nil
  285.       dispose_sprites_a(type)
  286.   end    
  287.    
  288.   #--------------------------------------------------------------------------
  289.   # ● Set Current Battleback
  290.   #--------------------------------------------------------------------------    
  291.   def set_current_battleback(type)
  292.       return @back1_sprite if type == 0
  293.       return @back2_sprite if type == 1
  294.       return @back_sprite_ex[type] if type >= 2    
  295.   end
  296.  
  297.   #--------------------------------------------------------------------------
  298.   # ● Set Current BB Name
  299.   #--------------------------------------------------------------------------    
  300.   def set_current_bb_name(type)
  301.       return battleback1_name if type == 0
  302.       return battleback2_name if type == 1
  303.       return $game_system.bb_name[type] if type >= 2
  304.   end
  305.  
  306.   #--------------------------------------------------------------------------
  307.   # ● Set Current Bitmap
  308.   #--------------------------------------------------------------------------    
  309.   def set_current_bitmap(type)
  310.       return battleback1_bitmap if type == 0
  311.       return battleback2_bitmap if type == 1
  312.       if type >= 2
  313.          if @back_sprite_ex[type].bitmap == nil
  314.             return Cache.battleback2($game_system.bb_name[type])
  315.          else  
  316.             return @back_sprite_ex[type].bitmap
  317.          end  
  318.       end
  319.   end      
  320.  
  321.   #--------------------------------------------------------------------------
  322.   # ● Create BB 1 EX
  323.   #--------------------------------------------------------------------------  
  324.   def create_bb1_ex
  325.       clear_base_bb_ex(0)
  326.       if set_current_bb_name(0) == nil ; c_normal_sprite(0) ; return ; end
  327.       @bb_data1_oxy = [0,0]  
  328.       case $game_system.bb_data[0][0]
  329.           when 0
  330.             @back1_sprite = Plane.new(@viewport1)
  331.             @back1_sprite.bitmap = battleback1_bitmap  
  332.             stretch_battleback(@back1_sprite) if $imported[:mog_battle_camera]
  333.           when 1  
  334.             @back1_sprite = Sprite.new(@viewport1) ; set_bb_wave(0)
  335.             center_sprite_wave(@back1_sprite,0)
  336.           when 2              
  337.             @back1_sprite = Sprite.new(@viewport1)
  338.             set_animated_bb(0,@back1_sprite, battleback1_bitmap,$game_system.bb_data[0][1])            
  339.             center_sprite(@back1_sprite)
  340.           else ; c_normal_sprite(0)
  341.       end
  342.       @bb_data[0] = $game_system.bb_data[0] ; set_data_misc(0)
  343.       @back1_sprite.z = $game_system.bb_screen_z + @bb_data[0][4]
  344.       @back1_sprite.blend_type = @bb_data[0][3]
  345.       if $imported[:mog_battle_camera]
  346.          @bb_data1_oxy[0] = (@back1_sprite.bitmap.width - Graphics.width) / 2
  347.          @bb_data1_oxy[1] = (@back1_sprite.bitmap.width - Graphics.width) / 2
  348.       end  
  349.   end
  350.  
  351.   #--------------------------------------------------------------------------
  352.   # ● Create BB 2 EX
  353.   #--------------------------------------------------------------------------    
  354.   def create_bb2_ex
  355.       clear_base_bb_ex(1)    
  356.       if set_current_bb_name(1) == nil ; c_normal_sprite(1) ; return ; end    
  357.       @bb_data2_oxy = [0,0]      
  358.       case $game_system.bb_data[1][0]
  359.           when 0
  360.             @back2_sprite = Plane.new(@viewport1)
  361.             @back2_sprite.bitmap = battleback2_bitmap
  362.             stretch_battleback(@back2_sprite) if $imported[:mog_battle_camera]
  363.           when 1  
  364.             @back2_sprite = Sprite.new(@viewport1) ; set_bb_wave(1)
  365.             center_sprite_wave(@back2_sprite,1)
  366.           when 2  
  367.             @back2_sprite = Sprite.new(@viewport1)
  368.             set_animated_bb(1,@back2_sprite,battleback2_bitmap,$game_system.bb_data[1][1])
  369.             center_sprite(@back2_sprite)
  370.           else ; c_normal_sprite(1)
  371.           end    
  372.       @bb_data[1] = $game_system.bb_data[1] ; set_data_misc(1)
  373.       @back2_sprite.z = 1 + $game_system.bb_screen_z  + @bb_data[1][4]
  374.       @back2_sprite.blend_type = @bb_data[1][3]
  375.       if $imported[:mog_battle_camera]
  376.          @bb_data2_oxy[0] = (@back2_sprite.bitmap.width - Graphics.width) / 2
  377.          @bb_data2_oxy[1] = (@back2_sprite.bitmap.height - Graphics.width) / 2
  378.       end  
  379.   end
  380.    
  381.   #--------------------------------------------------------------------------
  382.   # ● Create BB EX Sprite
  383.   #--------------------------------------------------------------------------    
  384.   def create_bbex_sprite(bb, index)
  385.       @bb_data_oxy = [] if @bb_data_oxy == nil
  386.       @bb_data[index] = [] if @bb_data[index] == nil
  387.       @bb_data_oxy[index] = [0,0]
  388.       $game_system.bb_data[index] = [] if $game_system.bb_data[index] == nil  
  389.       clear_base_bb_ex(index)        
  390.       case $game_system.bb_data[index][0]
  391.           when 0
  392.             @back_sprite_ex[index] = Plane.new(@viewport1)
  393.             @back_sprite_ex[index].bitmap = Cache.battleback2($game_system.bb_name[index])      
  394.             stretch_battleback(@back_sprite_ex[index]) if $imported[:mog_battle_camera]
  395.           when 1  
  396.             @back_sprite_ex[index] = Sprite.new(@viewport1)
  397.             @back_sprite_ex[index].bitmap = Cache.battleback2($game_system.bb_name[index])  
  398.             set_bb_wave(index) ; center_sprite_wave(@back_sprite_ex[index],index)
  399.           when 2  
  400.             @back_sprite_ex[index] = Sprite.new(@viewport1)
  401.             set_animated_bb(index,@back_sprite_ex[index],set_current_battleback(index),$game_system.bb_data[index][1])
  402.             center_sprite(@back_sprite_ex[index])
  403.           else
  404.             @back_sprite_ex[index] = Sprite.new(@viewport1)
  405.             set_bitmap_background(@back_sprite_ex[index],index)
  406.        end    
  407.       @bb_data[index] = $game_system.bb_data[index] ; set_data_misc(index)
  408.       @back_sprite_ex[index].z = index + $game_system.bb_screen_z + @bb_data[index][4]
  409.       @back_sprite_ex[index].blend_type = @bb_data[index][3]
  410.       if $imported[:mog_battle_camera]
  411.          @bb_data_oxy[index][0] = (@back_sprite_ex[index].bitmap.width - Graphics.width) / 2
  412.          @bb_data_oxy[index][1] = (@back_sprite_ex[index].bitmap.height - Graphics.height) / 2
  413.       end  
  414.   end  
  415.  
  416.   #--------------------------------------------------------------------------
  417.   # * Move Sprite to Screen Center
  418.   #--------------------------------------------------------------------------
  419.   def center_sprite_wave(sprite,index)
  420.     sprite.ox = sprite.bitmap.width / 2
  421.     sprite.oy = sprite.bitmap.height / 2
  422.     sprite.x = Graphics.width / 2
  423.     sprite.y = Graphics.height / 2
  424.   end  
  425.  
  426.   #--------------------------------------------------------------------------
  427.   # ● Set Data Misc
  428.   #--------------------------------------------------------------------------    
  429.   def set_data_misc(index)
  430.       @bb_data[index][5] = 0
  431.       @bb_data[index][6] = 0    
  432.       opm =  @bb_data[index][10] > 0 ? @bb_data[index][10] : 1
  433.       @bb_data[index][7] = 255 / opm
  434.       @bb_data[index][8] = 0
  435.       @bb_data[index][9] = 255  
  436.   end
  437.      
  438.   #--------------------------------------------------------------------------
  439.   # ● C Normal Sprite
  440.   #--------------------------------------------------------------------------  
  441.   def c_normal_sprite(type)
  442.       @back1_sprite = Sprite.new(@viewport1) if type == 0
  443.       @back2_sprite = Sprite.new(@viewport1) if type == 1
  444.       sprite = type == 0 ? @back1_sprite : @back2_sprite
  445.       set_bitmap_background(sprite,type)
  446.   end      
  447.  
  448.   #--------------------------------------------------------------------------
  449.   # ● Set Bitmap Background
  450.   #--------------------------------------------------------------------------  
  451.   def set_bitmap_background(sprite,type)
  452.       sprite_bitmap = set_current_bitmap(type)
  453.       bw = sprite_bitmap.width < Graphics.width ? Graphics.width : sprite_bitmap.width
  454.       bh = sprite_bitmap.height < Graphics.height ? Graphics.height : sprite_bitmap.height
  455.       sprite.bitmap = Bitmap.new(bw,bh)
  456.       sprite.bitmap.stretch_blt(sprite.bitmap.rect, sprite_bitmap, sprite_bitmap.rect)
  457.       sprite.z = type ; center_sprite(sprite)
  458.   end  
  459.      
  460.   #--------------------------------------------------------------------------
  461.   # ● Clear Base BB EX
  462.   #--------------------------------------------------------------------------    
  463.   def clear_base_bb_ex(type)
  464.       if $game_system.bb_data[type] == nil or $game_system.bb_data[type].empty?
  465.          $game_system.bb_data[type] = [0,0,0,0,0,0,0,0,0,0,0]
  466.       end  
  467.       dispose_sprites_a(type)
  468.       return if $game_system.bb_data[type] == nil or $game_system.bb_data[type].empty?
  469.       $game_system.bb_data[type][0] = 0 if $game_system.bb_data[type][0] > 3
  470.       $game_system.bb_data[type][1] = 0 if $game_system.bb_data[type][1] == nil
  471.       $game_system.bb_data[type][2] = 0 if$game_system.bb_data[type][2] == nil    
  472.   end
  473.  
  474.   #--------------------------------------------------------------------------
  475.   # ● Set bb Wave
  476.   #--------------------------------------------------------------------------    
  477.   def set_bb_wave(type)
  478.       bb_data = $game_system.bb_data[type]
  479.       if $imported[:mog_battle_camera]
  480.          range = range = (bb_data[1] + 1) * 5 ; range = 500 if range > 500
  481.          rxy = [Graphics.width * camera_range / 100,Graphics.height * camera_range / 100]
  482.       else
  483.          range = (bb_data[1] + 1) * 5 ; range = 500 if range > 500
  484.          rxy = [0,0]
  485.       end
  486.       speed = (bb_data[2] + 1) * 100 ; speed = 1000 if speed > 1000
  487.       sprite = set_current_battleback(type)
  488.       sprite_bitmap = set_current_bitmap(type)
  489.       sprite.x = -range
  490.       sprite.wave_amp = range
  491.       sprite.wave_length = Graphics.width
  492.       sprite.wave_speed = speed        
  493.       sprite.bitmap = Bitmap.new(Graphics.width + rxy[0] + (range * 2),Graphics.height + rxy[1])
  494.       sprite.bitmap.stretch_blt(sprite.bitmap.rect, sprite_bitmap, sprite_bitmap.rect)
  495.   end  
  496.  
  497.   #--------------------------------------------------------------------------
  498.   # ● Set Animated BB
  499.   #--------------------------------------------------------------------------    
  500.   def set_animated_bb(type,sprite,sprite_bitmap,speed)
  501.       @bba_bitmap[type] = [] ; @bba_frames[type] = [0,0,speed]
  502.       for index in 0..999
  503.         if type == 0
  504.            @bba_bitmap[type].push(Cache.battleback1(set_current_bb_name(type) + index.to_s)) rescue nil
  505.          else
  506.            @bba_bitmap[type].push(Cache.battleback2(set_current_bb_name(type) + index.to_s)) rescue nil
  507.         end
  508.         break if @bba_bitmap[type][index] == nil
  509.       end
  510.       if @bba_bitmap[type].size <= 1
  511.          @bba_bitmap[type] = nil ; @bba_frames[type] = nil
  512.          sprite.bitmap = set_current_bitmap(type) ; return
  513.       end  
  514.       refresh_bb_anime(type,sprite)  
  515.   end
  516.  
  517.   #--------------------------------------------------------------------------
  518.   # ● Update Background An
  519.   #--------------------------------------------------------------------------    
  520.   def update_background_an(type,sprite)
  521.       return if @bba_frames[type] == nil
  522.       @bba_frames[type][1] += 1
  523.       refresh_bb_anime(type,sprite) if @bba_frames[type][1] >= @bba_frames[type][2]
  524.   end
  525.  
  526.   #--------------------------------------------------------------------------
  527.   # ● Refresh BB anime
  528.   #--------------------------------------------------------------------------    
  529.   def refresh_bb_anime(type,sprite)
  530.       sprite.bitmap = @bba_bitmap[type][@bba_frames[type][0]]
  531.       @bba_frames[type][0] += 1 ; @bba_frames[type][1] = 0
  532.       @bba_frames[type][0] = 0 if @bba_frames[type][0] >= @bba_bitmap[type].size
  533.   end
  534.  
  535.   #--------------------------------------------------------------------------
  536.   # ● Update BB Scroll
  537.   #--------------------------------------------------------------------------
  538.   def update_bb_scroll(index)
  539.       @bb_data[index][5] += @bb_data[index][1]
  540.       @bb_data[index][6] += @bb_data[index][2]
  541.       @bb_data[index][5] = 0 if @bb_data[index][5] >= 99999999
  542.       @bb_data[index][6] = 0 if @bb_data[index][6] >= 99999999
  543.   end  
  544.  
  545.   #--------------------------------------------------------------------------
  546.   # ● Update Opacity EX
  547.   #--------------------------------------------------------------------------
  548.   def update_bb_opacity(index,sprite)
  549.       @bb_data[index][6] += 1
  550.       return if @bb_data[index][6] < @bb_data[index][5]
  551.       @bb_data[index][6] = 0 ; @bb_data[index][8] += 1
  552.       case @bb_data[index][8]
  553.         when 0..@bb_data[index][10]
  554.            @bb_data[index][9] -= @bb_data[index][7]
  555.         when @bb_data[index][10]..(-1 + @bb_data[index][10] * 2)
  556.            @bb_data[index][9] += @bb_data[index][7]
  557.         else
  558.            @bb_data[index][9] = 255 ; @bb_data[index][8] = 0
  559.       end
  560.       sprite.opacity = @bb_data[index][9]
  561.   end  
  562.  
  563.   #--------------------------------------------------------------------------
  564.   # ● Update Battleback1
  565.   #--------------------------------------------------------------------------
  566.   def update_battleback1
  567.       if !@bb_data[0].empty?
  568.           case @bb_data[0][0]
  569.              when 0
  570.                update_bb_scroll(0)
  571.                @back1_sprite.ox = @bb_data[0][5] + @bb_data1_oxy[0]
  572.                @back1_sprite.oy = @bb_data[0][6] + @bb_data1_oxy[1]
  573.              when 2 ; update_background_an(0,@back1_sprite)
  574.              when 3 ; bb_camera_effect(@back1_sprite,0)
  575.              else ; @back1_sprite.update
  576.           end
  577.           return
  578.       end    
  579.       @back1_sprite.update
  580.   end
  581.  
  582.   #--------------------------------------------------------------------------
  583.   # ● Update Battleback2
  584.   #--------------------------------------------------------------------------
  585.   def update_battleback2
  586.       if !@bb_data[1].empty?
  587.          case @bb_data[1][0]
  588.              when 0
  589.                 update_bb_scroll(1)
  590.                 @back2_sprite.ox = @bb_data[1][5] + @bb_data2_oxy[0]
  591.                 @back2_sprite.oy = @bb_data[1][6] + @bb_data1_oxy[1]
  592.              when 2 ; update_background_an(1,@back2_sprite)
  593.              when 3 ; bb_camera_effect(@back2_sprite,1)
  594.              else ; @back2_sprite.update
  595.          end
  596.          return    
  597.       end      
  598.       @back2_sprite.update
  599.   end
  600.  
  601.   #--------------------------------------------------------------------------
  602.   # ● Update Battleback EX
  603.   #--------------------------------------------------------------------------
  604.   def update_battleback_ex(index,opacity)
  605.       return if @back_sprite_ex[index].nil? or @back_sprite_ex[index].disposed?
  606.       if @bb_data[index][10] > 0 and $game_temp.bb_fade_duration[0] == 0
  607.          update_bb_opacity(index,@back_sprite_ex[index])
  608.       else
  609.          @back_sprite_ex[index].opacity = opacity if opacity != nil
  610.       end
  611.       if !@bb_data[index].empty?
  612.           case @bb_data[index][0]
  613.              when 0
  614.                update_bb_scroll(index)
  615.                @back_sprite_ex[index].ox = @bb_data[index][5] + @bb_data_oxy[index][0]
  616.                @back_sprite_ex[index].oy = @bb_data[index][6] + @bb_data_oxy[index][1]
  617.              when 2 ; update_background_an(index,@back_sprite_ex[index])  
  618.              when 3 ; bb_camera_effect(@back_sprite_ex[index],index)
  619.              else ; @back_sprite_ex[index].update
  620.           end
  621.           return
  622.       end    
  623.       @back_sprite_ex[index].update      
  624.   end  
  625.  
  626.   #--------------------------------------------------------------------------
  627.   # ● BB Camera Effect
  628.   #--------------------------------------------------------------------------
  629.   def bb_camera_effect(sprite,index)
  630.       bx = [[@bb_data[index][1], 100].min, -100].max
  631.       by = [[@bb_data[index][2], 100].min, -100].max
  632.       vx = @viewport1.ox * bx / 100
  633.       vy = @viewport1.oy * by / 100
  634.       sprite.ox = (sprite.bitmap.width / 2) -@viewport1.ox + vx
  635.       sprite.oy = (sprite.bitmap.height / 2) -@viewport1.oy  + vy
  636.   end
  637.  
  638. end
  639.  
  640. #==============================================================================
  641. # ■ Game Interpreter
  642. #==============================================================================
  643. class Game_Interpreter
  644.  
  645.   #--------------------------------------------------------------------------
  646.   # ● BB
  647.   #--------------------------------------------------------------------------      
  648.   def bb(id ,type = 0 , power = 0 , power2 = 0, blend_type = 0, screen_z = 0,a_fade = 0)
  649.       return if id <= 0
  650.       id -= 1 if [1,2].include?(id)
  651.       $game_system.bb_data[id] = [] if $game_system.bb_data[id] == nil
  652.       if (type == nil or type < 0) ; $game_system.bb_data[id].clear
  653.       else ; $game_system.bb_data[id] = [type, power, power2,blend_type, screen_z,
  654.                                          0,0,0,0,0,a_fade]
  655.       end  
  656.       $game_temp.bb_fade_duration[0] = 256 if SceneManager.scene_is?(Scene_Battle)
  657.   end
  658.  
  659.   #--------------------------------------------------------------------------
  660.   # ● BB Name
  661.   #--------------------------------------------------------------------------      
  662.   def bb_name(id,name = "")
  663.       if name == nil ; $game_system.bb_name[id].clear rescue nil ; return ; end    
  664.       return if id <= 0
  665.       if [1,2].include?(id)
  666.          $game_map.change_battleback_name(id,name) ; return
  667.       end
  668.       $game_system.bb_name[id] = name
  669.   end
  670.  
  671.   #--------------------------------------------------------------------------
  672.   # ● BB Clear
  673.   #--------------------------------------------------------------------------      
  674.   def bb_clear
  675.       $game_system.bb_data.clear
  676.       $game_system.bb_name.clear
  677.   end
  678.  
  679.   #--------------------------------------------------------------------------
  680.   # ● BB Screen Z
  681.   #--------------------------------------------------------------------------      
  682.   def bb_screen_z(value)
  683.       $game_system.bb_screen_z = value
  684.   end  
  685.  
  686. end  
  687.  
  688. #==============================================================================
  689. # ■ Game Map
  690. #==============================================================================
  691. class Game_Map
  692.  
  693.   #--------------------------------------------------------------------------
  694.   # * Change Battle Background
  695.   #--------------------------------------------------------------------------
  696.   def change_battleback_name(type,battleback_name)
  697.       @battleback1_name = battleback_name if type == 1
  698.       @battleback2_name = battleback_name if type == 2
  699.       $game_temp.bb_fade_duration = [256, false] if SceneManager.scene_is?(Scene_Battle)
  700.   end  
  701.  
  702.   #--------------------------------------------------------------------------
  703.   # ● Change_Battleback
  704.   #--------------------------------------------------------------------------  
  705.    alias mog_bbex_change_battleback change_battleback
  706.    def change_battleback(battleback1_name, battleback2_name)
  707.        mog_bbex_change_battleback(battleback1_name, battleback2_name)
  708.        $game_temp.bb_fade_duration = [256, false] if SceneManager.scene_is?(Scene_Battle)
  709.    end
  710.  
  711. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement