#==============================================================================
# ■ 出招更换战斗背景效果 By 绿发的Eclair v1.1
#
# 部分商业游戏的魔法特技使用时战斗背景会变成各种各样华丽的图片，配合上华丽的魔
# 法效果甚至可以造成一种浑然一体的美感效果，大红心~~
# 用RM模拟了~~~
# 使用方法：在数据库中添加属性，名字格式为 背景更换，背景的名字
# 带有这个属性的战斗行动在执行时会将战斗背景渐变更换为Battleback文件夹里面
# 一个叫“背景的名字”的图片，当然名字可以自定。
# 一定要用英文逗号分割 背景更换 和 要更换的背景名字哦~不然会出错的~~~
# 这个脚本使用了三次alias，如果说在这部分存在一些迷惑的话勉强可以做范例吧~~
# 除去防御时候换背景的BUG....另外将更换背景的步骤放在显示敌人动画那里了~~~
# 看起来会更舒服一些呢~~
# 祝您玩得愉快哦~
#==============================================================================
#==============================================================================
# ■ Spriteset_Battle
#------------------------------------------------------------------------------
# 　处理战斗画面的活动块的类。本类在 Scene_Battle 类
# 的内部使用。
#==============================================================================
class Spriteset_Battle
  attr_accessor :battleback_realname  
  attr_accessor :battleback_sprite
  alias cat_miaomiao initialize
  def initialize
    @battleback_realname = $game_temp.battleback_name
    cat_miaomiao
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    # 刷新角色的活动块 (对应角色的替换)
    @actor_sprites[0].battler = $game_party.actors[0]
    @actor_sprites[1].battler = $game_party.actors[1]
    @actor_sprites[2].battler = $game_party.actors[2]
    @actor_sprites[3].battler = $game_party.actors[3]
    # 战斗背景的文件名与现在情况有差异的情况下
    if @battleback_name != @battleback_realname
      @battleback_name = @battleback_realname
      if @battleback_sprite.bitmap != nil and @battleback_realname == $game_temp.battleback_name
        @battleback_sprite.bitmap.dispose
      end
      if @battleback_name != nil
      @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
      @battleback_sprite.src_rect.set(0, 0, 640, 320)
    end
    end
    # 刷新战斗者的活动块
    for sprite in @enemy_sprites + @actor_sprites
      sprite.update
    end
    # 刷新天气图形
    @weather.type = $game_screen.weather_type
    @weather.max = $game_screen.weather_max
    @weather.update
    # 刷新图片活动块
    for sprite in @picture_sprites
      sprite.update
    end
    # 刷新计时器活动块
    @timer_sprite.update
    # 设置画面的色调与震动位置
    @viewport1.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake
    # 设置画面的闪烁色
    @viewport4.color = $game_screen.flash_color
    # 刷新显示端口
    @viewport1.update
    @viewport2.update
    @viewport4.update
  end
end
#==============================================================================
# ■ Scene_Battle (分割定义 4)
#------------------------------------------------------------------------------
# 　处理战斗画面的类。
#==============================================================================
class Scene_Battle
  #--------------------------------------------------------------------------
  # ● 刷新画面 (主回合步骤 4 : 对像方动画)
  #--------------------------------------------------------------------------
  alias kiss_cat update_phase4_step4
  def update_phase4_step4
  @use = []
    @use = @active_battler.element_set if @active_battler.current_action.kind == 0 and @active_battler.current_action.basic == 0
    if @active_battler.current_action.kind == 1 
    @use = $data_skills[@active_battler.current_action.skill_id].element_set
    end
    if @active_battler.current_action.kind == 2
    @use = $data_items[@active_battler.current_action.item_id].element_set
  end
    for i in @use
    if $data_system.elements[i].split(/,/)[0] == "背景更换"
      for j in 0...10
        @spriteset.battleback_sprite.opacity -= 25
        Graphics.update
      end
    @spriteset.battleback_realname = $data_system.elements[i].split(/,/)[1]
     @spriteset.update
      for j in 0...10
        @spriteset.battleback_sprite.opacity += 25
        Graphics.update
      end
    break
  end
end
    kiss_cat
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (主回合步骤 6 : 刷新)
  #--------------------------------------------------------------------------
  alias touch_cat update_phase4_step6
  def update_phase4_step6
    if @spriteset.battleback_realname != $game_temp.battleback_name
      for j in 0...10
        @spriteset.battleback_sprite.opacity -= 25
        Graphics.update
      end
    @spriteset.battleback_realname =  $game_temp.battleback_name
     @spriteset.update
      for j in 0...10
        @spriteset.battleback_sprite.opacity += 25
        Graphics.update
      end
      end
    touch_cat
  end
end
