#==============================================================================
# +++ MOG - Battleback EX (v1.3) +++
#==============================================================================
# By Moghunter
# [url]http://www.atelier-rgss.com/[/url]
#==============================================================================
# Adiciona efeitos animados nos battlebacks.
#==============================================================================
# ● UTILIZAÇÃO
#==============================================================================
# Use os códigos abaixo através do comando chamar script.
# NOTA - Os códigos podem ser usados no meio da batalha.
#
# bb1( TYPE, POWER 1, POWER 2)
# bb2( TYPE, POWER 1, POWER 2)
#
# TYPE = 0 or 1
#
# 0 = Efeito slide
# 1 = Efeito wave
#
# POWER 1
#
# Velocidade de deslize na horizontal no efeito SLIDE.
# Area de distorção no efeito WAVE. (de 0 a 9)
#
# POWER 2
#
# Velocidade de deslize na vertical no efeito SLIDE.
# Velocidade de distorção do efeito WAVE. (de 0 a 9)
#
# Exemplo(EG)
#
# bb1(0,2,5)
# bb2(1,10,8)
#
#==============================================================================
# ● Cancelar o Efeito.
#==============================================================================
# Para cancelar o efeito use o código abaixo.
#
# bb1(nil)
# bb2(nil)
#
#==============================================================================
#==============================================================================
# ● Histórico (Version History)
#==============================================================================
# v 1.3 - Corrigido o erro de travar a tela quando não se define um battleback.
# v 1.2 - Opção de mudar a imagem e o efeito do battleback no meio da batalha.
# - Efeito de fade entre os battlebacks.
#
# v 1.1 - Opção de definir o tamanho do battleback.
# - Melhor compatibilidade.
#==============================================================================
module MOG_BATTLEBACK_EX
#Definição da resolução do jogo.
BB_SCREEN_SIZE = [544,416]
end
#==============================================================================
# ■ Game Temp
#==============================================================================
class Game_Temp
attr_accessor :bb_fade_duration
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_bb_ex_initialize_temp initialize
def initialize
@bb_fade_duration = [0 , true]
mog_bb_ex_initialize_temp
end
end
#==============================================================================
# ■ Game System
#==============================================================================
class Game_System
attr_accessor :bb1
attr_accessor :bb2
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_bb_ex_initialize initialize
def initialize
@bb1 = []
@bb2 = []
mog_bb_ex_initialize
end
end
#==============================================================================
# ■ Spriteset Battle
#==============================================================================
class Spriteset_Battle
include MOG_BATTLEBACK_EX
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_bb_ex_initialize initialize
def initialize
$game_temp.bb_fade_duration = [0,false]
@bb1 = []
@bb2 = []
mog_bb_ex_initialize
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
alias mog_bb_ex_update update
def update
update_battleback_transition
mog_bb_ex_update
end
#--------------------------------------------------------------------------
# ● Update Battleback Transition
#--------------------------------------------------------------------------
def update_battleback_transition
return if $game_temp.bb_fade_duration[0] == 0
if $game_temp.bb_fade_duration[1]
$game_temp.bb_fade_duration = [0 , false]
refresh_bb_ex
@back1_sprite.opacity = 255 if @back1_sprite != nil
@back2_sprite.opacity = 255 if @back2_sprite != nil
end
$game_temp.bb_fade_duration[0] -= 1
case $game_temp.bb_fade_duration[0]
when 129..256
@back1_sprite.opacity -= 2 if @back1_sprite != nil
@back2_sprite.opacity -= 2 if @back2_sprite != nil
when 1..128
if $game_temp.bb_fade_duration[0] == 128
refresh_bb_ex
@back1_sprite.opacity = 0 if @back1_sprite != nil
@back2_sprite.opacity = 0 if @back2_sprite != nil
end
@back1_sprite.opacity += 2 if @back1_sprite != nil
@back2_sprite.opacity += 2 if @back2_sprite != nil
when 0
@back1_sprite.opacity = 255 if @back1_sprite != nil
@back2_sprite.opacity = 255 if @back2_sprite != nil
end
end
#--------------------------------------------------------------------------
# ● Refresh Battleback EX
#--------------------------------------------------------------------------
def refresh_bb_ex
dispose_bb1_ex
dispose_bb2_ex
create_battleback1
create_battleback2
end
#--------------------------------------------------------------------------
# ● Create_Battleback1
#--------------------------------------------------------------------------
alias mog_bbex_create_battleback1 create_battleback1
def create_battleback1
if !$game_system.bb1.empty?
create_bb1_ex
return
end
mog_bbex_create_battleback1
end
#--------------------------------------------------------------------------
# ● Create_battleback2
#--------------------------------------------------------------------------
alias mog_bbex_create_battleback2 create_battleback2
def create_battleback2
if !$game_system.bb2.empty?
create_bb2_ex
return
end
mog_bbex_create_battleback2
end
#--------------------------------------------------------------------------
# ● Dispose BB1 EX
#--------------------------------------------------------------------------
def dispose_bb1_ex
return if @back1_sprite == nil
@back1_sprite.bitmap.dispose rescue nil
@back1_sprite.dispose
end
#--------------------------------------------------------------------------
# ● Dispose BB2 EX
#--------------------------------------------------------------------------
def dispose_bb2_ex
return if @back2_sprite == nil
@back2_sprite.bitmap.dispose rescue nil
@back2_sprite.dispose
end
#--------------------------------------------------------------------------
# ● Create BB 1 EX
#--------------------------------------------------------------------------
def create_bb1_ex
dispose_bb1_ex
$game_system.bb1[0] = 0 if $game_system.bb1[0] > 1
$game_system.bb1[1] = 0 if $game_system.bb1[1] == nil
$game_system.bb1[2] = 0 if $game_system.bb1[2] == nil
@bb1_name = battleback1_name
if @bb1_name == nil
@back1_sprite = Sprite.new(@viewport1)
@back1_sprite.bitmap = battleback1_bitmap
@back1_sprite.z = 0
center_sprite(@back1_sprite)
return
end
case $game_system.bb1[0]
when 0
@back1_sprite = Plane.new(@viewport1)
@back1_sprite.bitmap = battleback1_bitmap
when 1
@back1_sprite = Sprite.new(@viewport1)
range = ($game_system.bb1[1] + 1) * 10
range = 500 if range > 500
speed = ($game_system.bb1[2] + 1) * 1000
speed = 1000 if speed > 1000
@back1_sprite.x = -range
@back1_sprite.wave_amp = range
@back1_sprite.wave_length = BB_SCREEN_SIZE[0]
@back1_sprite.wave_speed = speed
@back1_sprite.bitmap = Bitmap.new(BB_SCREEN_SIZE[0] + (range * 2),BB_SCREEN_SIZE[1])
@back1_sprite.bitmap.stretch_blt(@back1_sprite.bitmap.rect, battleback1_bitmap, battleback1_bitmap.rect)
end
@back1_sprite.z = 0
@bb1 = $game_system.bb1
end
#--------------------------------------------------------------------------
# ● Create BB 2 EX
#--------------------------------------------------------------------------
def create_bb2_ex
dispose_bb2_ex
$game_system.bb2[0] = 0 if $game_system.bb2[0] > 1
$game_system.bb2[1] = 0 if $game_system.bb2[1] == nil
$game_system.bb2[2] = 0 if $game_system.bb2[2] == nil
@bb2_name = battleback2_name
if @bb2_name == nil
@back2_sprite = Sprite.new(@viewport1)
@back2_sprite.bitmap = battleback2_bitmap
@back2_sprite.z = 1
center_sprite(@back2_sprite)
return
end
case $game_system.bb2[0]
when 0
@back2_sprite = Plane.new(@viewport1)
@back2_sprite.bitmap = battleback2_bitmap
when 1
@back2_sprite = Sprite.new(@viewport1)
range = ($game_system.bb2[1] + 1) * 10
range = 500 if range > 500
speed = ($game_system.bb2[2] + 1) * 100
speed = 1000 if speed > 1000
@back2_sprite.x = -range
@back2_sprite.wave_amp = range
@back2_sprite.wave_length = BB_SCREEN_SIZE[0]
@back2_sprite.wave_speed = speed
@back2_sprite.bitmap = Bitmap.new(BB_SCREEN_SIZE[0] + (range * 2),BB_SCREEN_SIZE[1])
@back2_sprite.bitmap.stretch_blt(@back2_sprite.bitmap.rect, battleback2_bitmap, battleback2_bitmap.rect)
end
@back2_sprite.z = 1
@bb2 = $game_system.bb2
end
#--------------------------------------------------------------------------
# ● Update Battleback1
#--------------------------------------------------------------------------
alias mog_battleback_ex_update_battleback1 update_battleback1
def update_battleback1
if @bb1_name == nil
@back1_sprite.update
return
end
if !@bb1.empty?
case @bb1[0]
when 0
@back1_sprite.ox += @bb1[1]
@back1_sprite.oy += @bb1[2]
else
@back1_sprite.update
end
return
end
mog_battleback_ex_update_battleback1
end
#--------------------------------------------------------------------------
# ● Update Battleback2
#--------------------------------------------------------------------------
alias mog_battleback_ex_update_battleback2 update_battleback2
def update_battleback2
if @bb2_name == nil
@back2_sprite.update
return
end
if !@bb2.empty?
case @bb2[0]
when 0
@back2_sprite.ox += @bb2[1]
@back2_sprite.oy += @bb2[2]
else
@back2_sprite.update
end
return
end
mog_battleback_ex_update_battleback2
end
end
#==============================================================================
# ■ Game Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● BB1
#--------------------------------------------------------------------------
def bb1(type = 0 , power = 0 , power2 = 0)
if type == nil or type < 0
$game_system.bb1.clear
else
$game_system.bb1 = [type, power, power2]
end
$game_temp.bb_fade_duration[0] = 256 if SceneManager.scene_is?(Scene_Battle)
end
#--------------------------------------------------------------------------
# ● BB2
#--------------------------------------------------------------------------
def bb2(type = 0 , power = 0 , power2 = 0)
if type == nil or type < 0
$game_system.bb2.clear
else
$game_system.bb2 = [type, power, power2]
end
$game_temp.bb_fade_duration = [256, false] if SceneManager.scene_is?(Scene_Battle)
end
end
#==============================================================================
# ■ Game Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● Change_Battleback
#--------------------------------------------------------------------------
alias mog_bbex_change_battleback change_battleback
def change_battleback(battleback1_name, battleback2_name)
mog_bbex_change_battleback(battleback1_name, battleback2_name)
$game_temp.bb_fade_duration = [256, false] if SceneManager.scene_is?(Scene_Battle)
end
end
$mog_rgss3_battlebackex = true