设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1150|回复: 8
打印 上一主题 下一主题

[已经过期] 萌新求教,关于该横版战斗脚本的问题

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2547
在线时间
210 小时
注册时间
2018-8-8
帖子
105
跳转到指定楼层
1
发表于 2018-9-20 10:07:17 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
#==============================================================================
# ■ Sideview Ver100
#------------------------------------------------------------------------------
#  サイドビューバトラーを管理するクラスです。
#==============================================================================
class SideView
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数 
  #--------------------------------------------------------------------------
  attr_accessor   :x                    # 画面X座標
  attr_accessor   :y                    # 画面Y座標
  attr_accessor   :z                    # 画面Z座標
  attr_accessor   :h                    # 高さ座標
  attr_accessor   :j                    # ジャンプ座標
  attr_accessor   :c                    # カーブ座標
  attr_accessor   :ox                   # 横原点
  attr_accessor   :oy                   # 縦原点
  attr_accessor   :oy_adjust            # 縦原点補正
  attr_accessor   :angle                # 回転角度
  attr_accessor   :zoom_x               # 横の拡大率
  attr_accessor   :zoom_y               # 縦の拡大率
  attr_accessor   :pattern_w            # セル横位置(矩形内)
  attr_accessor   :pattern_h            # セル縦位置(矩形内)
  attr_accessor   :sx                   # セル横位置(画像全体)
  attr_accessor   :sy                   # セル縦位置(画像全体)
  attr_accessor   :pattern_type         # セル更新タイプ
  attr_accessor   :pattern_time         # セル更新間隔
  attr_accessor   :graphic_name         # バトラー画像ファイル名
  attr_accessor   :graphic_file_index   # バトラー画像ファイル名インデックス
  attr_accessor   :graphic_index        # バトラー画像インデックス
  attr_accessor   :cw                   # セル横矩形
  attr_accessor   :ch                   # セル縦矩形
  attr_accessor   :shadow_visible       # 影表示
  attr_accessor   :weapon_visible       # 武器表示
  
  attr_accessor   :wait                 # 次の動作待ち時間
  attr_accessor   :weapon_index         # 表示中の武器画像インデックス配列
  attr_accessor   :weapon_end           # 武器アニメ終了フラグ
  attr_accessor   :force_action         # 強制アクション
  attr_accessor   :target_battler       # ターゲットバトラー情報
  attr_accessor   :second_targets       # セカンドターゲット情報
  attr_accessor   :m_a_targets          # アニメ飛ばしターゲット情報
  attr_accessor   :individual_targets   # 個別処理ターゲットバトラー情報
  attr_accessor   :effect_data          # エフェクトデータ
  attr_accessor   :anime_id             # アニメID配列
  attr_accessor   :anime_move_id        # 飛ばしアニメID配列
  attr_accessor   :mirror               # 反転フラグ
  attr_accessor   :opacity              # 透明度
  attr_accessor   :opacity_data         # 透明度操作情報
  attr_accessor   :set_damage           # バトルシーンでのダメージ処理
  attr_accessor   :m_a_data             # アニメ飛ばし情報
  attr_accessor   :m_a_starter          # アニメ飛ばし開始ターゲット情報
  attr_accessor   :action_end           # バトルシーンでの行動終了
  attr_accessor   :damage_anime_data    # ダメージ戦闘アニメのデータ
  attr_accessor   :anime_no_mirror      # 戦闘アニメの反転禁止フラグ
  attr_accessor   :anime_horming        # 戦闘アニメのホーミングフラグ
  attr_accessor   :anime_camera_zoom    # 戦闘アニメがカメラに合わせて拡大縮小するか
  attr_accessor   :anime_plus_z         # 戦闘アニメZ座標補正
  attr_accessor   :derivation_skill_id  # スキル派生ID
  attr_accessor   :immortal             # 不死身フラグ
  attr_accessor   :mirage               # 残像データ
  attr_accessor   :balloon_data         # ふきだしデータ
  attr_accessor   :timing               # 別バトラーからのタイミングデータ
  attr_accessor   :timing_targets       # タイミングデータを渡す別バトラー
  attr_accessor   :color_set            # 色調変更データ
  attr_accessor   :color                # 色調データ
  attr_accessor   :change_up            # 画像変更フラグ
  attr_accessor   :hit                  # 被攻撃回数
  attr_accessor   :add_state            # 何度も付加ステートの表示を防ぐフラグ
  attr_accessor   :counter_id           # カウンター時のスキルID
  attr_accessor   :reflection_id        # 魔法反射時のアニメID
  attr_accessor   :result_damage        # ターン終了時のHP変動データ
  attr_accessor   :active               # 行動権
  attr_accessor   :anime_off            # 戦闘アニメ消去
  attr_accessor   :command_action       # コマンドアクションフラグ
   
  attr_accessor   :base_x               # 初期位置 X座標
  attr_accessor   :base_y               # 初期位置 Y座標
  attr_accessor   :base_h               # 初期位置 高さ座標
  attr_accessor   :max_pattern_w        # セルの横分割数
  attr_accessor   :max_pattern_h        # セルの縦分割数
  
  attr_reader     :collapse             # コラプスフラグ
  attr_reader     :picture              # ピクチャ表示フラグ
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(battler)
    @battler = battler
    reset
  end
  #--------------------------------------------------------------------------
  # ● 初期化
  #--------------------------------------------------------------------------
  def reset
    @x = 0
    @y = 0
    @z = 0
    @h = 0
    @j = 0
    @c = 0
    @jump = []
    @curve = []
    @ox = 0
    @oy = 0
    @oy_adjust = 0
    @z_plus = 0
    @move_time = 0
    @angle = 0
    @angle_time = 0
    @zoom_x = 1
    @zoom_y = 1
    @zoom_time = 0
    @pattern_w = 0
    @pattern_h = 0
    @sx = 0
    @sy = 0
    @pattern_type = 0
    @pattern_time = 0
    @pattern_rest_time = 0
    @graphic_name = ""
    @graphic_file_index = ""
    @graphic_index = 0
    @cw = 0
    @ch = 0
    @shadow_visible = false
    @weapon_visible = true
   
    @wait = 0
    @weapon_index = []
    @weapon_end = true
    @full_action = []
    @action = []
    @force_action = ""
    @target_battler = []
    @second_targets = []
    @individual_targets = []
    @m_a_targets = []
    @effect_data = []
    @anime_id = []
    @anime_move_id = []
    @opacity = 255
    @opacity_data = []
    @set_damage = false
    @m_a_data = []
    @m_a_starter = []
    @action_end = false
    @damage_anime_data = []
    @anime_no_mirror = false
    @anime_horming = false
    @anime_camera_zoom = false
    @anime_plus_z = true
    @derivation_skill_id = 0
    @immortal = false
    @mirage = []
    @play_data = []
    @balloon_data = []
    @picture = false
    @timing = []
    @timing_targets = []
    @color_set = []
    @color = []
    @change_up = false
    @non_motion = false
    @graphics_change = false
    @hit = []
    @add_state = []
    @collapse = false
    @counter_id = 0
    @reflection_id = 0
    @result_damage = [0,0]
    @active = false
    @anime_off = false
    @command_action = false
   
    @base_x = 0
    @base_y = 0
    @base_z = 0
    @base_h = 0
    @max_pattern_w = 0
    @max_pattern_h = 0
    @pattern_kind = 0
    @pattern_count = 0
    @move_time = 0
    @mirror = false
    @battler.set_graphic(@pre_change_data[0], @pre_change_data[1], @pre_change_data[2], @pre_change_data[3]) if @pre_change_data != nil
    @pre_change_data = nil
  end  
  #--------------------------------------------------------------------------
  # ● セットアップ
  #--------------------------------------------------------------------------
  def setup(bitmap_width, bitmap_height, first_action_flag)
    reset if first_action_flag
    set_data
    set_base_position if !@graphics_change
    set_graphics(bitmap_width, bitmap_height)
    set_target
    setup_graphics_change if @graphics_change
    first_battler_anime_set if first_action_flag
  end  
  #--------------------------------------------------------------------------
  # ● バトラーデータ取得
  #--------------------------------------------------------------------------
  def set_data
    return if @battler == nil
    if @battler.actor?
      @graphic_name = @battler.character_name
      @graphic_index = @battler.character_index
    else
      @graphic_name = @battler.battler_name
      @graphic_index = 0
    end
    @max_pattern_w = max_pattern[0]
    @max_pattern_h = max_pattern[1]
  end
  #--------------------------------------------------------------------------
  # ● ベース座標をセット data = [X軸, Y軸, H軸]  moment_set…瞬間配置
  #--------------------------------------------------------------------------
  def set_base_position(moment_set = true)
    mirroring_reset
    if @battler.actor?
      data = N03::ACTOR_POSITION[@battler.index].dup
      @base_x = data[0] * 100 if !@mirror
      @base_x = (Graphics.width - data[0]) * 100 if @mirror
    else
      data = [@battler.screen_x, @battler.screen_y, 0].dup
      @base_x = data[0] * 100 if !$sv_camera.mirror
      @base_x = (Graphics.width - data[0]) * 100 if $sv_camera.mirror
    end
    @base_y = data[1] * 100
    @base_h = data[2] * 100
    @base_z = @y
    return if !moment_set
    @x = @base_x
    @y = @base_y
    @z = @base_z
  end
  #--------------------------------------------------------------------------
  # ● グラフィックデータ取得
  #--------------------------------------------------------------------------
  def set_graphics(bitmap_width, bitmap_height)
    sign = @graphic_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = bitmap_width / @max_pattern_w
      @ch = bitmap_height / @max_pattern_h
    elsif @max_pattern_w == 1 && @max_pattern_h == 1
      @cw = bitmap_width
      @ch = bitmap_height
    else
      @cw = bitmap_width / (@max_pattern_w * 4)
      @ch = bitmap_height / (@max_pattern_h * 2)
    end
    @ox = @cw / 2
    @oy = @ch
    @sx = (@graphic_index % 4 * @max_pattern_w + @pattern_w) * @cw
    @sy = (@graphic_index / 4 * @max_pattern_h + @pattern_h) * @ch
  end
  #--------------------------------------------------------------------------
  # ● ターゲットをセット
  #--------------------------------------------------------------------------
  def set_target(target = nil)
    @target_battler = target
    @target_battler = [@battler] if target == nil
    @second_targets = @target_battler
  end
  #--------------------------------------------------------------------------
  # ● 画像変更用のセットアップ
  #--------------------------------------------------------------------------
  def setup_graphics_change
    @graphics_change = false
    @sx = (@graphic_index % 4 * @max_pattern_w + @pattern_w) * @cw
    @sy = (@graphic_index / 4 * @max_pattern_h + @pattern_h) * @ch
  end  
  #--------------------------------------------------------------------------
  # ● 戦闘開始時の待機アニメ画像データ取得
  #--------------------------------------------------------------------------
  def first_battler_anime_set
    loop do
      update
      break if @action_data == nil
      break if @action_data[0] == "pose"
      break if @action_data[0] == "move" && @action_data[8] != ""
      break if @full_action == []
    end
    start_action(first_action) if @battler.movable?
  end
  #--------------------------------------------------------------------------
  # ● アクション開始
  #--------------------------------------------------------------------------
  def start_action(kind = nil)
    return if @event_fix && $game_troop.interpreter.running?
    # ウェイト中の場合キャンセル
    return @wait -= 1 if @wait > 0 && kind == nil
    action_setup(false) if kind != nil
    set_action(kind)
    @action = kind if @action == nil
    # 行動配列が無い場合は行動終了処理へ移行
    action_terminate if @action == nil
    # 次のアクション決定
    @action_data = N03::ACTION[@action]
    next_action
  end
  #--------------------------------------------------------------------------
  # ● 行動パラメータの初期化
  #--------------------------------------------------------------------------
  def action_setup(reset = true)
    @event_fix = false
    @set_damage = false
    @action_end = false
    @balloon_data = []
    @loop_act = []
    angle_reset if reset
    zoom_reset if reset
    opacity_reset if reset
    @curve = []
    @c = 0
    convert_jump
  end  
  #--------------------------------------------------------------------------
  # ● 行動終了処理
  #--------------------------------------------------------------------------
  def action_terminate
    @mirage = [] if @mirage_end
    mirroring_reset
    @picture = false
    @individual_targets = []
    action_setup if @active
    action_setup(false) if !@active
    # 待機アクションへ移行
    stand_by_action if !@non_motion
    # 戦闘行動のアクティブ権を終了
    next_battler
  end  
  #--------------------------------------------------------------------------
  # ● 新しいアクション内容の決定
  #--------------------------------------------------------------------------
  def set_action(kind = nil)
    full_act = N03::FULLACTION[kind]
    @full_action = full_act.dup if full_act != nil
    @action = @full_action.shift
    # 参照したアクションがフルアクションであれば全体のアクションを統合
    full_act2 = N03::FULLACTION[@action]
    @full_action = full_act2.dup + @full_action if full_act2 != nil
  end
  #--------------------------------------------------------------------------
  # ● 次のアクションへ
  #--------------------------------------------------------------------------
  def next_action
    @wait = 0
    # ショートカット確認
    eval(@action) if @action != nil && @action_data == nil && N03::FULLACTION[@action] == nil
    # ウエイト設定
    @wait = @action.to_i if @wait == 0 && @action_data == nil
    @wait = rand(@wait.abs + 1) if @wait < 0
    # アクション開始
    action_play
  end
  #--------------------------------------------------------------------------
  # ● 待機アクションへ移行
  #--------------------------------------------------------------------------
  def stand_by_action
    # 通常待機に
    stand_by_act = normal
    # HPが1/4でピンチアクションに
    stand_by_act = pinch if @battler.hp <= @battler.mhp / 4
    # ステートチェック
    stand_by_act = state(@battler.states[0].id) if @battler.states[0] != nil && state(@battler.states[0].id) != nil
    # コマンドチェック
    stand_by_act = command if @command_action && command != nil
    set_action(stand_by_act)
    @action = stand_by_act if @action == nil
  end
  #--------------------------------------------------------------------------
  # ● 強制アクション開始
  #--------------------------------------------------------------------------
  def start_force_action
    return if @active
    start_action(@force_action)
    @force_action = ""
  end  
  #--------------------------------------------------------------------------
  # ● アクション追加
  #--------------------------------------------------------------------------
  def add_action(kind)
    @full_action.push(kind)
  end  
  #--------------------------------------------------------------------------
  # ● アクションの挿入
  #--------------------------------------------------------------------------
  def unshift_action(kind)
    @full_action.unshift(kind)
  end  
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    # アクション開始
    start_action
    # 強制アクション開始
    start_force_action if @force_action != ""
    # アニメパターン更新
    update_pattern
    # 移動更新
    update_move
    # 回転更新
    update_angle if @angle_time != 0
    # 拡大縮小更新
    update_zoom if @zoom_time != 0
    # 透明度更新
    update_opacity if @opacity_data != []
  end
  #--------------------------------------------------------------------------
  # ● アニメパターン更新
  #--------------------------------------------------------------------------
  def update_pattern
    return @pattern_rest_time -= 1 if @pattern_rest_time != 0
    return if @max_pattern_w == 1 && @max_pattern_h == 1
    @pattern_rest_time = @pattern_time
    # 再生開始・終了セル位置を取得
    if @pattern_kind > 0 # 通常再生中
      @pattern_start = 0
      @pattern_end = @max_pattern_w - 1
    elsif @pattern_kind < 0 # 逆転再生中
      @pattern_start = @max_pattern_w - 1
      @pattern_end = 0
    end
    # 片道の再生が終了
    @pattern_count += 1 if @pattern_w == @pattern_end && @pattern_kind != 0
    # ループ処理
    case @pattern_type.abs
    when  1,3 # 片道
      @pattern_kind =  0 if @pattern_count != 0 && @pattern_type ==  1
      @pattern_kind =  0 if @pattern_count != 0 && @pattern_type == -1
      @pattern_kind =  1 if @pattern_count != 0 && @pattern_type ==  3
      @pattern_kind = -1 if @pattern_count != 0 && @pattern_type == -3
      @pattern_w = @pattern_start - @pattern_kind if @pattern_count != 0 && @pattern_type.abs == 3
      @pattern_count = 0
    when  2,4 # 往復
      @pattern_kind = -1 if @pattern_count == 1 && @pattern_type ==  2
      @pattern_kind =  1 if @pattern_count == 1 && @pattern_type == -2
      @pattern_kind =  0 if @pattern_count == 2 && @pattern_type ==  2
      @pattern_kind =  0 if @pattern_count == 2 && @pattern_type == -2
      @pattern_kind = -1 if @pattern_count == 1 && @pattern_type ==  4
      @pattern_kind =  1 if @pattern_count == 1 && @pattern_type == -4
      @pattern_kind =  1 if @pattern_count == 2 && @pattern_type ==  4
      @pattern_kind = -1 if @pattern_count == 2 && @pattern_type == -4
      @pattern_count = 0 if @pattern_count == 2
    end
    # セル更新
    @pattern_w += 1 * @pattern_kind
    @sx = (@graphic_index % 4 * @max_pattern_w + @pattern_w) * @cw
  end
  #--------------------------------------------------------------------------
  # ● 移動の更新
  #--------------------------------------------------------------------------
  def update_move
    @z = @y / 100 + @z_plus
    return if @move_time == 0
    target_position_set if @horming_move
    @x = (@x * (@move_time - 1) + @target_x) / @move_time
    @y = (@y * (@move_time - 1) + @target_y) / @move_time
    @h = (@h * (@move_time - 1) + @target_h) / @move_time if @move_h != nil
    @c += @curve[@move_time - 1] if @curve[@move_time - 1] != nil
    @j += @jump[@move_time - 1] if @jump[@move_time - 1] != nil
    @move_time -= 1
    convert_jump if @move_time == 0
  end
  #--------------------------------------------------------------------------
  # ● 移動目標の更新
  #--------------------------------------------------------------------------
  def target_position_set
    target_position = N03.get_targets_position(@move_targets, @horming_move)
    @target_x = target_position[0] + @move_x
    @target_y = target_position[1] + @move_y
    @target_h = target_position[2] + @move_h if @move_h != nil
  end  
  #--------------------------------------------------------------------------
  # ● 回転更新
  #--------------------------------------------------------------------------
  def update_angle
    @angle += @angling
    @angle_time -= 1
    return if @angle_time != 0
    return angle_reset if @angle_data[4] == 0
    angling(@angle_data) if @angle_data[4] == 2
  end  
  #--------------------------------------------------------------------------
  # ● 拡大縮小更新
  #--------------------------------------------------------------------------
  def update_zoom
    @zoom_x += @zooming_x
    @zoom_y += @zooming_y
    @zoom_time -= 1
    return if @zoom_time != 0
    return zoom_reset if @zoom_data[4] == 0
    zooming(@zoom_data) if @zoom_data[4] == 2
  end
  #--------------------------------------------------------------------------
  # ● 透明度更新
  #--------------------------------------------------------------------------
  def update_opacity
    @opacity += @opacity_data[2]
    @opacity_data[0] -= 1
    return if @opacity_data[0] != 0
    return if !@opacity_data[5]
    @opacity_data[2] *= -1
    @opacity_data[0] = @opacity_data[1]
  end
  #--------------------------------------------------------------------------
  # ● アクション実行
  #--------------------------------------------------------------------------
  def action_play
    return if @action_data == nil
    action = @action_data[0]
    # バトラー反転の場合
    return mirroring                    if action == "mirror"
    # 残像の場合
    return mirage_set                   if action == "mirage"
    # 回転の場合  
    return angling                      if action == "angle"
    # 拡大縮小の場合  
    return zooming                      if action == "zoom"
    # 透明度操作の場合  
    return set_opacity                  if action == "opacity"
    # バトラーアニメの場合
    return battler_anime                if action == "pose"
    # 移動の場合
    return move                         if action == "move"
    # 武器アニメの場合
    return weapon_anime([@action_data]) if action == "wp"
    # アニメ飛ばしの場合
    return move_anime                   if action == "m_a"
    # 戦闘シーン通信の場合(コラプス)
    return set_play_data                if action == "collapse" or action == "no_collapse"
    # データベース戦闘アニメ表示の場合  
    return battle_anime                 if action == "anime"
    # カメラワークの場合
    return camera                       if action == "camera"
    # 画面のシェイクの場合
    return shake                        if action == "shake"
    # 画面色調変更の場合
    return color_effect                 if action == "color"
    # トランジションの場合
    return transition                   if action == "ts"
    # ふきだしアニメ表示の場合  
    return balloon_anime                if action == "balloon"
    # ピクチャ表示の場合
    return picture_set                  if action == "pic"
    # ステート操作の場合
    return state_set                    if action == "sta"
    # FPS変更の場合
    return fps                          if action == "fps"
    # バトラー画像変更の場合  
    return graphics_change              if action == "change"
    # スキル派生の場合  
    return derivating_skill             if action == "der"
    # BGM/BGS/SE演奏の場合  
    return sound                        if action == "sound"
    # ムービー再生の場合  
    return movie                        if action == "movie"
    # ゲームスイッチ操作の場合  
    return switches                     if action == "switch"
    # ゲーム変数操作の場合  
    return variable                     if action == "variable"
    # 条件分岐(ゲームスイッチ)の場合
    return nece_1                       if action == "n_1"
    # 条件分岐(ゲーム変数)の場合
    return nece_2                       if action == "n_2"
    # 条件分岐(ステート)の場合
    return nece_3                       if action == "n_3"
    # 条件分岐(スキル)の場合
    return nece_4                       if action == "n_4"
    # 条件分岐(パラメータ)の場合
    return nece_5                       if action == "n_5"
    # 条件分岐(装備)の場合
    return nece_6                       if action == "n_6"
    # 条件分岐(スクリプト)の場合
    return nece_7                       if action == "n_7"
    # セカンドターゲット操作の場合  
    return second_targets_set           if action == "s_t"
    # コモンイベント呼び出しの場合  
    return call_common_event            if action == "common"
    # 戦闘アニメ消去の場合  
    return @anime_off = true            if action == "anime_off"
    # 強制戦闘終了の場合  
    return BattleManager.process_abort  if action == "battle_end"
    # 画面固定の場合  
    return Graphics.freeze              if action == "graphics_freeze"
    # ダメージアニメの場合  
    return damage_anime                 if action == "damage_anime"
    # 武器消去の場合  
    return @weapon_visible = false      if action == "weapon_off"
    # 武器消去解除の場合  
    return @weapon_visible = true       if action == "weapon_on"
    # 待機キャンセルの場合
    return @non_motion = true           if action == "non_motion"
    # 待機キャンセル解除の場合
    return @non_motion = false          if action == "non_motion_cancel"
    # 初期位置変更の場合
    return change_base_position         if action == "change_base_position"
    # 初期位置変更解除の場合
    return set_base_position(false)     if action == "set_base_position"
    # 強制アクションの場合  
    return force_act                    if action == "force_action"
    # 強制アクションの場合 (セカンドターゲット)
    return force_act2                   if action == "force_action2"
    # 個別開始の場合
    return individual_start             if action == "individual_start"
    # 個別終了の場合
    return individual_end               if action == "individual_end"
    # ループ開始の場合
    return loop_start                   if action == "loop_start"
    # ループ終了の場合
    return loop_end                     if action == "loop_end"
    # 自分のみ更新の場合
    return only_action_on               if action == "only_action_on"
    # 自分のみ更新解除の場合
    return only_action_off              if action == "only_action_off"
    # 次の行動者へ移行の場合
    return next_battler                 if action == "next_battler"
    # 画像変更フラグの場合
    return set_change                   if action == "set_change"
    # スクリプト操作の場合   
    return eval(@action_data[0])
  end
  #--------------------------------------------------------------------------
  # ● バトラー反転実行
  #--------------------------------------------------------------------------
  def mirroring
    @mirror = !@mirror
  end  
  #--------------------------------------------------------------------------
  # ● 反転初期化
  #--------------------------------------------------------------------------
  def mirroring_reset
    @mirror = false
    mirroring if [email protected]? && N03::ENEMY_MIRROR
    mirroring if $sv_camera.mirror
  end  
  #--------------------------------------------------------------------------
  # ● 残像実行
  #--------------------------------------------------------------------------
  def mirage_set
    @mirage = @action_data.dup
    @mirage_end = @mirage[3]
    @mirage = [] if @mirage[1] == 0
  end  
  #--------------------------------------------------------------------------
  # ● 回転実行
  #--------------------------------------------------------------------------
  def angling(data = @action_data)
    @angle_data = data.dup
    @oy = @ch / 2
    @oy_adjust = @ch * 50
    @angle_time = data[1]
    start_angle = data[2] * N03.mirror_num(@mirror)
    end_angle = data[3] * N03.mirror_num(@mirror)
    # 時間が0以下なら即座に最終角度へ
    @angle_time = 1 if @angle_time <= 0
    # 回転時間から1フレームあたりの角度を出す
    @angling = (end_angle - start_angle) / @angle_time
    # 割り切れない余りを初期角度に
    @angle = (end_angle - start_angle) % @angle_time + start_angle
  end
  #--------------------------------------------------------------------------
  # ● 回転初期化
  #--------------------------------------------------------------------------
  def angle_reset
    @oy = @ch
    @angle = @angle_time = @oy_adjust = 0
  end  
  #--------------------------------------------------------------------------
  # ● 拡大縮小実行
  #--------------------------------------------------------------------------
  def zooming(data = @action_data)
    @zoom_data = data.dup
    @zoom_time = data[1]
    start_zoom_x = data[2][0]
    start_zoom_y = data[2][1]
    end_zoom_x = data[3][0]
    end_zoom_y = data[3][1]
    # 時間が0以下なら即座に最終サイズへ
    @zoom_time = 1 if @zoom_time <= 0
    # 拡大縮小時間から1フレームあたりの拡大縮小率を出す
    @zooming_x = (end_zoom_x - start_zoom_x) / @zoom_time
    @zooming_y = (end_zoom_y - start_zoom_y) / @zoom_time
    # 開始サイズに
    @zoom_x = start_zoom_x
    @zoom_y = start_zoom_y
  end  
  #--------------------------------------------------------------------------
  # ● 拡大縮小初期化
  #--------------------------------------------------------------------------
  def zoom_reset
    @zoom_x = @zoom_y = 1
    @zoom_time = 0
  end  
  #--------------------------------------------------------------------------
  # ● バトラー透明度操作
  #--------------------------------------------------------------------------
  def set_opacity
    data = @action_data.dup
    @opacity = data[2]
    opacity_move = (data[3] - data[2])/ data[1]
    @opacity_data = [data[1], data[1], opacity_move, data[4], data[5], data[6]]
    @wait = data[1] if data[7]
    @wait *= 2 if data[6] && data[7]
  end
  #--------------------------------------------------------------------------
  # ● 透明度操作初期化
  #--------------------------------------------------------------------------
  def opacity_reset
    @opacity = 255
    @opacity = 0 if @battler.hidden?
    @opacity_data = []
  end
  #--------------------------------------------------------------------------
  # ● バトラーアニメ実行
  #--------------------------------------------------------------------------
  def battler_anime(anime_data = nil)
    anime_data = @action_data.dup if anime_data == nil
    @graphic_file_index = anime_data[1] if !graphic_fix
    @pattern_h = anime_data[2]
    @pattern_w = anime_data[3]
    @pattern_h = 0 if @max_pattern_w == 1
    @pattern_w = 0 if @max_pattern_h == 1
    @pattern_type = anime_data[4]
    @pattern_time = anime_data[5]
    @pattern_rest_time = anime_data[5]
    @pattern_count = 0
    @pattern_kind = 1
    @pattern_kind = -1 if @pattern_type < 0
    @pattern_kind = 0 if @pattern_type == 0
    @sx = (@graphic_index % 4 * @max_pattern_w + @pattern_w) * @cw
    @sy = (@graphic_index / 4 * @max_pattern_h + @pattern_h) * @ch
    @z_plus = anime_data[6]
    @wait = set_anime_wait if anime_data[7]
    @shadow_visible = anime_data[8]
    weapon_anime(anime_data)
  end
  #--------------------------------------------------------------------------
  # ● アニメウエイト計算
  #--------------------------------------------------------------------------
  def set_anime_wait
    if @pattern_type > 0
      pattern_time_a = @max_pattern_w - @pattern_w.abs
    elsif @pattern_type < 0
      pattern_time_a = @pattern_w.abs + 1
    else
      return @pattern_time if @pattern_type == 0
    end
    case @pattern_type
    when 1,-1, 3,-3
      return pattern_time_a * @pattern_time
    when 2,-2, 4,-4
      return pattern_time_a * @pattern_time + (@max_pattern_w - 2) * @pattern_time
    end
  end  
  #--------------------------------------------------------------------------
  # ● 移動実行
  #--------------------------------------------------------------------------
  def move
    @move_targets = N03.get_targets(@action_data[1].abs, @battler)
    return if @move_targets == []
    @move_targets = [@battler] if @action_data[1].abs == 7
    @move_x = @action_data[2] * 100 * N03.mirror_num(@mirror)
    @move_y = @action_data[3] * 100
    @move_h = @action_data[4] * 100 if @action_data[4] != nil
    @move_h = nil if @action_data[4] == nil
    battler_anime(N03::ACTION[@action_data[8]].dup) if N03::ACTION[@action_data[8]] != nil
    @horming_move = true
    @horming_move = false if @action_data[1] < 0 or @action_data[1].abs == 7
    target_position_set
    target_position = [@target_x, @target_y, @target_z]
    distanse_move = @action_data[5] > 0
    @move_time = N03.distanse_calculation(@action_data[5].abs, target_position, [@x, @y, @z], distanse_move)
    @wait = @move_time
    curve
    jump
    @move_time = 1 if @move_time == 0
    @horming_move = false if !@move_targets or @move_targets.include?(@battler)
    update_move if @move_time == 1
  end  
  #--------------------------------------------------------------------------
  # ● カーブ実行
  #--------------------------------------------------------------------------
  def curve
    @c = 0
    return if @action_data[6] == 0
    @curve = N03.parabola([@action_data[6], -@action_data[6]], @move_time, 100, 4)
  end  
  #--------------------------------------------------------------------------
  # ● ジャンプ実行
  #--------------------------------------------------------------------------
  def jump
    convert_jump
    return if @action_data[7] == [0,0]
    @jump = N03.parabola(@action_data[7].dup, @move_time, 100)
  end  
  #--------------------------------------------------------------------------
  # ● J座標(ジャンプ高度)をH座標に変換
  #--------------------------------------------------------------------------
  def convert_jump
    @h += @j
    @j = 0
    @jump = []
  end  
  #--------------------------------------------------------------------------
  # ● データベース戦闘アニメ実行
  #--------------------------------------------------------------------------
  def battle_anime
    data = @action_data.dup
    targets = N03.get_targets(data[2], @battler)
    return if targets == []
    data[8] = !data[8] if @mirror
    @set_damage           = data[5]
    @damage_anime_data[0] = N03.get_attack_anime_id(data[1], @battler)
    @damage_anime_data[1] = data[8]
    @damage_anime_data[2] = data[7]
    @damage_anime_data[3] = data[6]
    @damage_anime_data[4] = data[9]
    @wait = N03.get_anime_time(@damage_anime_data[0]) - 2 if data[4]
    return if @set_damage
    for target in targets do display_anime(targets, target, data) end
  end
  #--------------------------------------------------------------------------
  # ● 武器アニメ開始
  #--------------------------------------------------------------------------
  def weapon_anime(anime_data)
    @weapon_end = true
    for i in 9...anime_data.size
      set_effect_data(anime_data) if anime_data != ""
    end
  end
  #--------------------------------------------------------------------------
  # ● アニメ飛ばし開始
  #--------------------------------------------------------------------------
  def move_anime
    @m_a_starter = []
    @m_a_targets = []
    starters = N03.get_targets(@action_data[2], @battler)
    targets = N03.get_targets(@action_data[3], @battler)
    return if starters == [] or targets == []
    single_start = true if starters != nil && @action_data[2] < 0
    single_start = true if @action_data[1][0] != 0 && $data_animations[N03.get_attack_anime_id(@action_data[1][0], @battler)].position == 3
    starters = [starters[0]] if single_start
    single_end = true if targets != nil && @action_data[3] < 0
    single_end = true if @action_data[1][1] != 0 && $data_animations[N03.get_attack_anime_id(@action_data[1][1], @battler)].position == 3
    targets = [targets[0]] if single_end
    se_flag = true
    for starter in starters
      for target in targets
        data = @action_data.dup
        data[17] = se_flag
        @effect_data.push(data)
        @m_a_targets.push(target)
        @m_a_starter.push(starter)
        se_flag = false
      end
    end  
  end
  #--------------------------------------------------------------------------
  # ● スプライトセット通信
  #--------------------------------------------------------------------------
  def set_effect_data(data = @action)
    action_data = N03::ACTION[data]
    return if action_data == nil
    @effect_data.push(action_data.dup)
  end
  #--------------------------------------------------------------------------
  # ● 戦闘シーン通信のデータを格納
  #--------------------------------------------------------------------------
  def set_play_data(data = @action_data)
    @play_data = data.dup
  end
  #--------------------------------------------------------------------------
  # ● 戦闘アニメの表示
  #--------------------------------------------------------------------------
  def display_anime(targets, target, data)
    return if !N03.first_of_all_screen_anime(data[1], target, targets)
    target.animation_id         = N03.get_attack_anime_id(data[1], @battler)
    target.animation_mirror     = data[8]
    target.sv.anime_horming     = data[3]
    target.sv.anime_camera_zoom = data[6]
    target.sv.anime_no_mirror   = data[7]
    target.sv.anime_plus_z      = data[9]
  end
  #--------------------------------------------------------------------------
  # ● 戦闘アニメ拡張データの初期化
  #--------------------------------------------------------------------------
  def reset_anime_data
    @anime_no_mirror = false
    @anime_horming = false
    @anime_camera_zoom = false
    @timing_targets = []
    @anime_plus_z = true
  end  
  #--------------------------------------------------------------------------
  # ● カメラワーク
  #--------------------------------------------------------------------------
  def camera
    data = @action_data.dup
    N03.camera(@battler, data)
    @wait = data[4] if data[5]
  end  
  #--------------------------------------------------------------------------
  # ● 画面のシェイク
  #--------------------------------------------------------------------------
  def shake
    data = @action_data.dup
    $sv_camera.shake(data[1], data[2], data[3])
    @wait = data[3] if data[4]
  end
  #--------------------------------------------------------------------------
  # ● 画面色調変更
  #--------------------------------------------------------------------------
  def color_effect
    case @action_data[1]
    when 0,1,2,3,4,5
      targets = N03.get_targets(@action_data[1], @battler)
    when 6
      screen = true
    when 7
      targets = [@battler] + @target_battler
    when 8
      screen = true
      targets = $game_troop.members + $game_party.battle_members - [@battler]
    when 9
      screen = true
      targets = $game_troop.members + $game_party.battle_members - [@battler] - @target_battler
    when 10
      screen = true
      targets = $game_troop.members + $game_party.battle_members
    end
    return if screen == nil && targets == []
    for target in targets do target.sv.color_set = @action_data[2] end if targets
    @wait = @action_data[2][4] if @action_data[3]
    return if !screen
    $sv_camera.color_set[1] = @action_data[2]
    $sv_camera.color_set[2] = @action_data[2]
  end  
  #--------------------------------------------------------------------------
  # ● トランジション
  #--------------------------------------------------------------------------
  def transition
    $sv_camera.perform_transition(@action_data)
  end  
  #--------------------------------------------------------------------------
  # ● ふきだしアニメ表示
  #--------------------------------------------------------------------------
  def balloon_anime
    @balloon_data = @action_data.dup
  end  
  #--------------------------------------------------------------------------
  # ● ピクチャ表示
  #--------------------------------------------------------------------------
  def picture_set
    @picture = true
    set_effect_data
  end
  #--------------------------------------------------------------------------
  # ● ステート操作
  #--------------------------------------------------------------------------
  def state_set
    targets = N03.get_targets(@action_data[1], @battler)
    return if targets == []
    case @action_data[2]
    when 1 ; targets = [targets[rand(targets.size)]]
    when 2 ; targets -= @battler if targets.include?(@battler)
    end
    for target in targets
      for id in @action_data[4]
        target.add_state(id) if @action_data[3] == "+"
        target.remove_state(id) if @action_data[3] == "-"
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● FPS変更
  #--------------------------------------------------------------------------
  def fps
    Graphics.frame_rate = @action_data[1]
    start_action
  end
  #--------------------------------------------------------------------------
  # ● バトラー画像変更の場合
  #--------------------------------------------------------------------------
  def graphics_change
    @graphics_change = true
    return @battler.graphics_change(@action_data[3]) if [email protected]?
    @pre_change_data = [@battler.character_name, @battler.character_index, @battler.face_name, @battler.face_index] if @pre_change_data == nil && !@action_data[1]
    if @action_data[4] == []
      face_name = @battler.face_name
      face_index = @battler.face_index
    else
      face_name = @action_data[4][1]
      face_index = @action_data[4][0]
    end
    @battler.set_graphic(@action_data[3], @action_data[2], face_name, face_index)
  end
  #--------------------------------------------------------------------------
  # ● スキル派生
  #--------------------------------------------------------------------------
  def derivating_skill
    # 未修得スキルは派生不可なら
    return if !@action_data[1] && [email protected]_learn?($data_skills[@action_data[3]])
    # コスト不足は派生不可なら
    return if !@action_data[2] && [email protected]_cost_payable?($data_skills[@action_data[3]])
    # 派生
    @derivation_skill_id = @action_data[3]
    # 以降のアクションをキャンセル
    @full_action = []
  end
  #--------------------------------------------------------------------------
  # ● BGM/BGS/SE演奏
  #--------------------------------------------------------------------------
  def sound
    pitch = @action_data[2]
    vol   = @action_data[3]
    name  = @action_data[4]
    case @action_data[1]
    when "se"
      Audio.se_play("Audio/SE/" + name, vol, pitch)
    when "bgm"
      # 名前指定のない場合、現在のBGMを変えないように
      name = RPG::BGM.last.name if @action_data[4] == ""
      Audio.bgm_play("Audio/BGM/" + name, vol, pitch)
    when "bgs"
      name = RPG::BGS.last.name if @action_data[4] == ""
      Audio.bgs_play("Audio/BGS/" + name, vol, pitch)
    end
  end
  #--------------------------------------------------------------------------
  # ● ムービーの再生
  #--------------------------------------------------------------------------
  def movie
    Graphics.play_movie('Movies/' + @action_data[1])
  end
  #--------------------------------------------------------------------------
  # ● ゲームスイッチ操作
  #--------------------------------------------------------------------------
  def switches
    for id in @action_data[1]
      $game_switches[id] = true if id > 0
      $sv_camera.switches[id.abs] = true  if id < 0
    end
    for id in @action_data[2]
      $game_switches[id] = false if id > 0
      $sv_camera.switches[id.abs] = false  if id < 0
    end
    $sv_camera.program_check
  end
  #--------------------------------------------------------------------------
  # ● ゲーム変数操作
  #--------------------------------------------------------------------------
  def variable
    # オペランドチェック
    operand = @action_data[3]
    operand = $game_variables[@action_data[3].abs] if @action_data[3] < 0
    # 変数操作で分岐
    case @action_data[2]
    when 0 ; $game_variables[@action_data[1]] = operand  # 代入
    when 1 ; $game_variables[@action_data[1]] += operand # 加算
    when 2 ; $game_variables[@action_data[1]] -= operand # 減算
    when 3 ; $game_variables[@action_data[1]] *= operand # 乗算
    when 4 ; $game_variables[@action_data[1]] /= operand # 除算
    when 5 ; $game_variables[@action_data[1]] %= operand # 剰余
    end
  end  
  #--------------------------------------------------------------------------
  # ● 条件分岐 (ゲームスイッチ)
  #--------------------------------------------------------------------------
  def nece_1
    judgment = $game_switches[@action_data[1]] == @action_data[2] if @action_data[1] > 0
    judgment = $sv_camera.switches[@action_data[1].abs] == @action_data[2] if @action_data[1] < 0
    action_diverging(judgment, @action_data[3])
  end  
  #--------------------------------------------------------------------------
  # ● 条件分岐 (ゲーム変数)
  #--------------------------------------------------------------------------
  def nece_2
    variable = $game_variables[@action_data[1]]
    num = @action_data[2]
    num = $game_variables[@action_data[2].abs] if num < 0
    case @action_data[3]
    when 0 ; judgment = variable == num
    when 1 ; judgment = variable < num
    when 2 ; judgment = variable > num
    end  
    action_diverging(judgment, @action_data[4])
  end  
  #--------------------------------------------------------------------------
  # ● 条件分岐 (ステート)
  #--------------------------------------------------------------------------
  def nece_3
    targets = N03.get_targets(@action_data[1], @battler)
    return if targets == []
    member_num = @action_data[4]
    member_num = targets.size if @action_data[4] == 0 && targets.size > 1
    hit_count = 0
    miss_count = 0
    for target in targets
      hit_count += 1 if target.state?(@action_data[2])
      miss_count += 1 if !target.state?(@action_data[2])
    end
    case @action_data[3]
    when 0 ; judgment = hit_count >= member_num
    when 1 ; judgment = miss_count >= member_num
    end
    action_diverging(judgment, @action_data[5])
  end  
  #--------------------------------------------------------------------------
  # ● 条件分岐 (スキル)
  #--------------------------------------------------------------------------
  def nece_4
    targets = N03.get_targets(@action_data[1], @battler)
    return if targets == []
    member_num = @action_data[4]
    member_num = targets.size if @action_data[4] == 0 && targets.size > 1
    hit_count = 0
    miss_count = 0
    for target in targets
      hit_count += 1 if target.skill_learn?($data_skills[@action_data[2]]) && target.skill_conditions_met?($data_skills[@action_data[2]])
      miss_count += 1 if !target.skill_learn?($data_skills[@action_data[2]]) or !target.skill_conditions_met?($data_skills[@action_data[2]])
    end
    case @action_data[3]
    when 0 ; judgment = hit_count >= member_num
    when 1 ; judgment = miss_count >= member_num
    end
    action_diverging(judgment, @action_data[5])
  end  
  #--------------------------------------------------------------------------
  # ● 条件分岐 (パラメータ)
  #--------------------------------------------------------------------------
  def nece_5
    targets = N03.get_targets(@action_data[1], @battler)
    return if targets == []
    member_num = @action_data[5]
    member_num = targets.size if @action_data[5] == 0 && targets.size > 1
    hit_count = 0
    for target in targets
      hit_count += 1 if target.comparison_parameter([@action_data[2],@action_data[3],@action_data[4]])
    end
    judgment = hit_count >= member_num
    action_diverging(judgment, @action_data[6])
  end  
  #--------------------------------------------------------------------------
  # ● 条件分岐 (装備)
  #--------------------------------------------------------------------------
  def nece_6
    targets = N03.get_targets(@action_data[1], @battler)
    return if targets == []
    member_num = @action_data[5]
    member_num = targets.size if @action_data[5] == 0 && targets.size > 1
    hit_count = 0
    miss_count = 0
    for target in targets
      hit_count += 1 if target.comparison_equip([@action_data[2],@action_data[3]])
      miss_count += 1 if !target.comparison_equip([@action_data[2],@action_data[3]])
    end
    case @action_data[4]
    when 0 ; judgment = hit_count >= member_num
    when 1 ; judgment = miss_count >= member_num
    end
    action_diverging(judgment, @action_data[6])
  end  
  #--------------------------------------------------------------------------
  # ● 条件分岐 (スクリプト)
  #--------------------------------------------------------------------------
  def nece_7
    judgment = eval(@action_data[2])
    action_diverging(judgment, @action_data[1])
  end  
  #--------------------------------------------------------------------------
  # ● アクション分岐  
  #--------------------------------------------------------------------------
  def action_diverging(judgment, kind)
    result = 0
    if judgment
      result = 1 if kind == 1
      result = 2 if kind == 2
    else
      result = 1 if kind == 0
    end
    # フルアクション終了
    return @full_action = []  if result == 2
    # 次のアクションを除去
    @full_action.shift if result == 1
    set_action
    # 次のアクションを実行
    @action_data = N03::ACTION[@action]
    next_action
  end
  #--------------------------------------------------------------------------
  # ● セカンドターゲット操作
  #--------------------------------------------------------------------------
  def second_targets_set
    targets = N03.get_targets(@action_data[1], @battler)
    for target in targets
      targets.delete(target) if @action_data[2][1] == 1 && target.index != @action_data[2][0]
      targets.delete(target) if @action_data[2][1] == 2 && target.index == @action_data[2][0].abs
      targets.delete(target) if @action_data[3] > 0 && target.id != @action_data[3]
      targets.delete(target) if @action_data[3] < 0 && target.id == @action_data[3].abs
      targets.delete(target) if @action_data[4] > 0 && !target.state?(@action_data[4])
      targets.delete(target) if @action_data[4] < 0 && target.state?(@action_data[4].abs)
      targets.delete(target) if @action_data[5] > 0 && !target.skill_conditions_met?($data_skills[@action_data[5]])
      targets.delete(target) if @action_data[5] < 0 && target.skill_conditions_met?($data_skills[@action_data[5].abs])
      targets.delete(target) if !target.comparison_parameter(@action_data[6])
      targets.delete(target) if !@action_data[7][1].include?(0) && !target.comparison_equip(@action_data[7])
    end
    return @second_targets = [] if targets.size == 0
    case @action_data[8]
    when 1 ; targets = [targets[rand(targets.size)]]
    when 2 ; targets.delete(@battler)
    end
    return @second_targets = [] if targets.size == 0
    @second_targets = targets
    case @action_data[9]
    when 0 ; return
    when 1 ; set_play_data(["second_targets_set"])
    when 2 ; set_play_data(["targets_set"])
    end
    @wait += 1
  end
  #--------------------------------------------------------------------------
  # ● コモンイベント呼び出し
  #--------------------------------------------------------------------------
  def call_common_event
    $game_temp.reserve_common_event(@action_data[1])
    $sv_camera.event = true
    @event_fix = @action_data[2]
  end
  #--------------------------------------------------------------------------
  # ● ダメージアニメ
  #--------------------------------------------------------------------------
  def damage_anime(delay_time = 12)
    anime(N03.get_attack_anime_id(-3, @battler), wait = true)
    action_play
    @wait -= delay_time
    @full_action.unshift("eval('@damage_anime_data = []
    @set_damage = true')")
  end
  #--------------------------------------------------------------------------
  # ● 通常コラプス
  #--------------------------------------------------------------------------
  def normal_collapse
    @collapse = true
    return
  end
  #--------------------------------------------------------------------------
  # ● 初期位置変更
  #--------------------------------------------------------------------------
  def change_base_position
    @base_x = @x
    @base_y = @y
    @base_h = @h
  end  
  #--------------------------------------------------------------------------
  # ● 強制アクション実行
  #--------------------------------------------------------------------------
  def force_act
    target(@full_action.shift)
  end
  #--------------------------------------------------------------------------
  # ● 強制アクション実行 (セカンドターゲット)
  #--------------------------------------------------------------------------
  def force_act2
    target2(@full_action.shift)
  end
  #--------------------------------------------------------------------------
  # ● 個別処理開始
  #--------------------------------------------------------------------------
  def individual_start
    @individual_targets = @target_battler.dup
    @remain_targets = @target_battler.dup
    @target_battler = [@individual_targets[0]]
    # 保持重复部分的动作
    @individual_act = @full_action.dup
  end
  #--------------------------------------------------------------------------
  # ● 個別処理終了
  #--------------------------------------------------------------------------
  def individual_end
    @individual_targets.shift
    for target in @individual_targets
      @individual_targets.shift if target.dead?
    end
    # ターゲットが残っているなら行動リピート
    return @target_battler = @remain_targets if @individual_targets.size == 0
    @full_action = @individual_act.dup
    @target_battler = [@individual_targets[0]]
  end
  #--------------------------------------------------------------------------
  # ● ループ開始
  #--------------------------------------------------------------------------
  def loop_start
    # ループ部分のアクションを保持
    @loop_act = @full_action.dup
  end
  #--------------------------------------------------------------------------
  # ● ループ終了
  #--------------------------------------------------------------------------
  def loop_end
    # 行動リピート
    @full_action = @loop_act.dup if @loop_act != []
  end
  #--------------------------------------------------------------------------
  # ● 次の行動者へ移行
  #--------------------------------------------------------------------------
  def next_battler
    @action_end = true
    @active = false
  end
  #--------------------------------------------------------------------------
  # ● 画像変更フラグ
  #--------------------------------------------------------------------------
  def set_change
    @change_up = true
  end
  #--------------------------------------------------------------------------
  # ● 戦闘シーン通信
  #--------------------------------------------------------------------------
  def play_data
    data = @play_data
    @play_data = []
    return data
  end
  #--------------------------------------------------------------------------
  # ● ショートカットコマンド
  #--------------------------------------------------------------------------
  def anime(anime_id, wait = true)
    @action_data = ["anime",anime_id,1,false,wait,false,true,false]
  end
  def anime_me(anime_id, wait = true)
    @action_data = ["anime",anime_id,0,false,wait,false,true,false]
  end
  def se(file, pitch = 100)
    @action_data = ["sound",  "se", pitch, 100, file]
  end
  def target(act)
    for target in @target_battler do target.sv.force_action = act end
  end
  def target2(act)
    for target in @second_targets do target.sv.force_action = act end
  end
  def delay(time)
    @wait = @battler.index * time
  end
  #--------------------------------------------------------------------------
  # ● バトラーのIDを取得
  #--------------------------------------------------------------------------
  def id
    return @battler.id if @battler.actor?
    return [email protected]
  end
  #--------------------------------------------------------------------------
  # ● 被クリティカルフラグを取得
  #--------------------------------------------------------------------------
  def critical?
    return @battler.result.critical
  end
  #--------------------------------------------------------------------------
  # ● 被回復フラグを取得
  #--------------------------------------------------------------------------
  def recovery?
    recovery = false
    recovery = true if @battler.result.hp_damage < 0
    recovery = true if @battler.result.mp_damage < 0
    recovery = true if @battler.result.tp_damage < 0
    return recovery
  end
  #--------------------------------------------------------------------------
  # ● 被スキルIDを取得
  #--------------------------------------------------------------------------
  def damage_skill_id
    return @damage_skill_id
  end
  #--------------------------------------------------------------------------
  # ● 被アイテムIDを取得
  #--------------------------------------------------------------------------
  def damage_item_id
    return @damage_item_id
  end
  #--------------------------------------------------------------------------
  # ● 装備武器を取得
  #--------------------------------------------------------------------------
  def weapon_id
    return 0 if [email protected][0]
    return @battler.weapons[0].id
  end
  #--------------------------------------------------------------------------
  # ● 装備武器のタイプを取得
  #--------------------------------------------------------------------------
  def weapon_type
    return 0 if [email protected][0]
    return @battler.weapons[0].wtype_id
  end
  #--------------------------------------------------------------------------
  # ● 盾を装備しているか
  #--------------------------------------------------------------------------
  def shield?
    for armor in @battler.armors do return true if armor != nil && armor.etype_id == 1 end
    return false
  end
  #--------------------------------------------------------------------------
  # ● ダメージがあるか
  #--------------------------------------------------------------------------
  def damage_zero?
    return @battler.result.hp_damage == 0 && @battler.result.mp_damage == 0 && @battler.result.tp_damage == 0
  end
  #--------------------------------------------------------------------------
  # ● スキルIDを取得
  #--------------------------------------------------------------------------
  def skill_id
    return @counter_id if @counter_id != 0
    return 0 if @battler.current_action == nil or @battler.current_action.item == nil
    return 0 if @battler.current_action.item.is_a?(RPG::Item)
    return @battler.current_action.item.id
  end
  #--------------------------------------------------------------------------
  # ● スキルのタイプを取得
  #--------------------------------------------------------------------------
  def skill_type
    return 0 if skill_id == 0
    return $data_skills[skill_id].stype_id
  end
  #--------------------------------------------------------------------------
  # ● スキル名を取得
  #--------------------------------------------------------------------------
  def skill_name
    return "" if skill_id == 0
    return $data_skills[skill_id].name
  end
  #--------------------------------------------------------------------------
  # ● アイテムIDを取得
  #--------------------------------------------------------------------------
  def item_id
    return 0 if @battler.current_action == nil or @battler.current_action.item == nil
    return @battler.current_action.item.id
  end
  #--------------------------------------------------------------------------
  # ● 攻撃アクション
  #--------------------------------------------------------------------------
  def attack_action(item)
    return skill_action if item.is_a?(RPG::Skill)
    return item_action
  end
  #--------------------------------------------------------------------------
  # ● ダメージアクションベース
  #--------------------------------------------------------------------------
  def damage_action_base(item)
    @damage_skill_id = 0
    @damage_item_id = 0
    @damage_skill_id = item.id if item.is_a?(RPG::Skill)
    @damage_item_id = item.id if item.is_a?(RPG::Item)
  end  
  #--------------------------------------------------------------------------
  # ● ダメージアクション
  #--------------------------------------------------------------------------
  def damage_action(attacker, item)
    damage_action_base(item)
    act = damage(attacker)
    return if @active
    start_action(act) if act != nil
  end
  #--------------------------------------------------------------------------
  # ● 回避アクション
  #--------------------------------------------------------------------------
  def evasion_action(attacker, item)
    damage_action_base(item)
    act = evasion(attacker)
    return if @active
    start_action(act) if act != nil
  end
  #--------------------------------------------------------------------------
  # ● ミスアクション
  #--------------------------------------------------------------------------
  def miss_action(attacker, item)
    damage_action_base(item)
    act = miss(attacker)
    return if @active
    start_action(act) if act != nil
  end
  #--------------------------------------------------------------------------
  # ● 閃きスクリプト併用処理
  #--------------------------------------------------------------------------
  def flash_action
    return "FLASH"
  end
  
end


#==============================================================================
# ■ module N03
#------------------------------------------------------------------------------
#  サイドビューバトルのモジュールです。
#==============================================================================
module N03
  #--------------------------------------------------------------------------
  # ● バトラーの敵グループを取得
  #--------------------------------------------------------------------------
  def self.get_enemy_unit(battler)
    return $game_troop if battler.actor?
    return $game_party
  end
  #--------------------------------------------------------------------------
  # ● バトラーの味方グループを取得
  #--------------------------------------------------------------------------
  def self.get_party_unit(battler)
    return $game_party if battler.actor?
    return $game_troop
  end
  #--------------------------------------------------------------------------
  # ● 戦闘アニメ時間の取得
  #--------------------------------------------------------------------------
  def self.get_anime_time(anime_id)
    return 0 if anime_id <= 0
    return $data_animations[anime_id].frame_max * 4
  end
  #--------------------------------------------------------------------------
  # ● 攻撃アニメの取得
  #--------------------------------------------------------------------------
  def self.get_attack_anime_id(kind, battler)
    return $data_skills[battler.sv.counter_id].animation_id if kind == -3 && battler.sv.counter_id != 0
    case kind
    when -1 ; anime_id = battler.atk_animation_id1
    when -2 ; anime_id = battler.atk_animation_id2
    when -3
      if battler.current_action != nil
        anime_id = battler.current_action.item.animation_id if battler.current_action.item != nil
      end
    else    ; anime_id = kind
    end
    case anime_id
    when -1 ; anime_id = battler.atk_animation_id1
    when -2 ; anime_id = battler.atk_animation_id2
    end
    return anime_id if anime_id
    return 0
  end  
  #--------------------------------------------------------------------------
  # ● 戦闘アニメデータをセット
  #--------------------------------------------------------------------------
  def self.set_damage_anime_data(targets, target, data)
    return if !first_of_all_screen_anime(data[0], target, targets)
    target.animation_id         = data[0]
    target.animation_mirror     = data[1]
    target.sv.anime_no_mirror   = data[2]
    target.sv.anime_camera_zoom = data[3]
    target.sv.anime_plus_z      = data[4]
  end   
  #--------------------------------------------------------------------------
  # ● ターゲットの取得
  #--------------------------------------------------------------------------
  def self.get_targets(kind, battler)
    case kind.abs
    when 0 ; return [battler].dup
    when 1 ; return battler.sv.target_battler.dup
    when 2 ; return get_enemy_unit(battler).members.dup
    when 3 ; return get_party_unit(battler).members.dup
    when 4 ; return $game_troop.members.dup + $game_party.battle_members.dup
    when 5 ; return battler.sv.second_targets.dup
    end
  end  
  #--------------------------------------------------------------------------
  # ● ターゲットの座標を取得
  #--------------------------------------------------------------------------
  def self.get_targets_position(targets, horming, m_a = nil)
    return [0,0,0] if targets == nil && !$sv_camera.mirror
    return [Graphics.width,0,0] if targets == nil && $sv_camera.mirror
    x = y = h = 0
    for i in 0...targets.size
      x += targets.sv.base_x if !horming
      y += targets.sv.base_y if !horming
      h += targets.sv.base_h if !horming
      x += targets.sv.x if horming
      y += targets.sv.y if horming
      h += targets.sv.h if horming
      y -= targets.sv.ch * 100 if m_a == 0
      y -= targets.sv.ch * 50 if m_a == 1
    end
    return [x / targets.size, y / targets.size, h / targets.size]
  end
  #--------------------------------------------------------------------------
  # ● 速度を時間に変換
  #--------------------------------------------------------------------------
  def self.distanse_calculation(time, target_position, self_position, distanse_move)
    return time if !distanse_move
    distanse_x = self_position[0] - target_position[0]
    distanse_x = target_position[0] - self_position[0] if target_position[0] > self_position[0]
    distanse_y = self_position[1] - target_position[1]
    distanse_y = target_position[1] - self_position[1] if target_position[1] > self_position[1]
    if self_position[2] != nil && target_position[2] != nil
      distanse_h = self_position[2] - target_position[2]
      distanse_h = target_position[2] - self_position[2] if target_position[2] > self_position[2]
    else
      distanse_h = 0
    end
    distanse = [distanse_x, distanse_y, distanse_h].max
    return distanse / (time * 100) + 1
  end
  #--------------------------------------------------------------------------
  # ● 放物線移動計算
  #--------------------------------------------------------------------------
  def self.parabola(data, time, size, type = 1)
    move_data = data
    move_data[0] *= size
    move_data[1] *= size
    move = []
    move_d = []
    for i in 0...time / 2
      move = move_data[0]
      move_d = move_data[1]
      move_data[0] = move_data[0] * type / (1 + type)
      move_data[1] = move_data[1] * type / (1 + type)
    end
    move = move + move_d.reverse!
    move.reverse!
    adjust = move.inject(0) {|result, item| result + item }
    move[move.size - 1] += adjust if data[0] == data[1] && adjust != 0
    move.unshift(0) if time % 2 != 0
    return move
  end
  #--------------------------------------------------------------------------
  # ● 反転値
  #--------------------------------------------------------------------------
  def self.mirror_num(mirror)
    return 1 if !mirror
    return -1
  end  
  #--------------------------------------------------------------------------
  # ● カメラワーク
  #--------------------------------------------------------------------------
  def self.camera(battler, data)
    battler = $game_party.battle_members[0] if !battler
    cx = data[2][0] * 100
    cy = data[2][1] * 100
    return $sv_camera.move(cx, cy, data[3], data[4], true) if data[1] == 6
    targets = self.get_targets(data[1], battler)
    return if targets == nil or targets == []
    position = self.get_targets_position(targets, true)
    $sv_camera.move(position[0], position[1] - position[2], data[3], data[4], false)
  end
  #--------------------------------------------------------------------------
  # ● コラプス禁止
  #--------------------------------------------------------------------------
  def self.immortaling
    # 全員に不死身付与
    for member in $game_party.battle_members + $game_troop.members
      # イベント操作等で不死身設定になっていたら解除を無効にするフラグを立てる
      member.sv.immortal = true if member.state?(N03::IMMORTAL_ID)
      member.add_state(N03::IMMORTAL_ID)
    end
    return true
  end  
  #--------------------------------------------------------------------------
  # ● コラプス許可
  #--------------------------------------------------------------------------
  def self.unimmortaling
    # 全員の不死身化解除(イベント等で不死身設定がされていれば除く)
    for member in $game_party.battle_members + $game_troop.members
      next if member.dead?
      # 不死身ステートが行動中に解除されていた場合、解除無効を解除
      member.sv.immortal = false if !member.state?(N03::IMMORTAL_ID) && member.sv.immortal
      next member.sv.immortal = false if member.sv.immortal
      member.remove_state(N03::IMMORTAL_ID)
      next if member.hp != 0
      member.add_state(1)
      member.perform_collapse_effect
      member.sv.action_terminate
    end
    return false
  end  
  #--------------------------------------------------------------------------
  # ● スキル派生
  #--------------------------------------------------------------------------
  def self.derived_skill(battler)
    battler.force_action(battler.sv.derivation_skill_id, -2)
    BattleManager.unshift_action_battlers(battler)
  end
  #--------------------------------------------------------------------------
  # ● ダメージの作成
  #--------------------------------------------------------------------------
  def self.set_damage(battler, hp_damage, mp_damage)
    battler.result.hp_damage = hp_damage
    battler.result.mp_damage = mp_damage
  end
  #--------------------------------------------------------------------------
  # ● ターゲット生死確認
  #--------------------------------------------------------------------------
  def self.targets_alive?(targets)
    return false if targets == []
    for target in targets do return true if !target.dead? end
    return false
  end
  #--------------------------------------------------------------------------
  # ● ターゲットをセカンドターゲットへ
  #--------------------------------------------------------------------------
  def self.s_targets(battler)
    battler.sv.target_battler = battler.sv.second_targets
    return battler.sv.second_targets
  end  
  #--------------------------------------------------------------------------
  # ● セカンドターゲットをターゲットへ
  #--------------------------------------------------------------------------
  def self.targets_set(battler)
    battler.sv.second_targets = battler.current_action.make_targets.compact
    battler.sv.target_battler = battler.sv.second_targets
  end  
  #--------------------------------------------------------------------------
  # ● 戦闘アニメ実行判定 (対象:画面時は最初のターゲットのみアニメ実行)
  #--------------------------------------------------------------------------
  def self.first_of_all_screen_anime(anime_id, target, targets)
    anime = $data_animations[anime_id]
    return false if !anime
    return true if anime.position != 3
    return false if anime.position == 3 && target != targets[0]
    targets.delete(target)
    target.sv.timing_targets = targets
    return true
  end
  #--------------------------------------------------------------------------
  # ● 戦闘不能付加攻撃か
  #--------------------------------------------------------------------------
  def self.dead_attack?(battler, item)
    for state in battler.atk_states
      return true if state == battler.death_state_id
    end
    for effect in item.effects
      return true if effect.code == 21 && effect.data_id == battler.death_state_id
    end
    return false
  end
end

#==============================================================================
# ■ Sprite_Weapon
#------------------------------------------------------------------------------
#  ウエポン表示用のスプライトです。
#==============================================================================
class Sprite_Weapon < Sprite_Base
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数 
  #--------------------------------------------------------------------------
  attr_reader   :index                       # ウエポン画像配列のインデックス
  attr_reader   :battler                     # 画像が参照しているバトラー
  attr_reader   :move_time                   # 画像が目標に到達するまでの時間
  attr_reader   :through                     # 貫通フラグ
  attr_reader   :action_end                  # 武器アクション終了フラグ
  attr_reader   :action_end_cancel                  # 武器アクション終了フラグ
  attr_reader   :hit_position                # 画像が目標に到達した時の座標
  attr_accessor :hit_anime_id                # 画像が目標に到達した時のアニメID
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(viewport, index, battler)
    super(viewport)
    @index = index
    @battler = battler
    @position_x = @position_y = 0
    @o = 0
    @real_x = @real_y = 0
    @mirror = @battler.sv.mirror
    reset
    set_action
  end
  #--------------------------------------------------------------------------
  # ● 初期化
  #--------------------------------------------------------------------------
  def reset
    @z_plus = 0
    @weapon_data = []
    @move_data = []
    @move_x = 0
    @move_y = 0
    @orbit = []
    @through = false
    @distanse_move = false
    @weapon_width = 0
    @weapon_height = 0
    @anime_time = 0
    @anime_position = 1
    @move_time = 0
    @hit_anime_id = 0
    @move_anime = true
    @action_end = false
    @action_end_cancel = false
    reset_position
  end  
  #--------------------------------------------------------------------------
  # ● アクションをセット
  #--------------------------------------------------------------------------
  def set_action
    return if @battler.sv.effect_data == []
    weapon_anime if @battler.sv.effect_data[0][0] == "wp"
    move_anime if @battler.sv.effect_data[0][0] == "m_a"
    @battler.sv.effect_data.shift
  end
  #--------------------------------------------------------------------------
  # ● 武器アニメ実行
  #--------------------------------------------------------------------------
  def weapon_anime
    @weapon_data = @battler.sv.effect_data[0].dup
    set_graphics
    set_ox
    set_weapon_move
  end
  #--------------------------------------------------------------------------
  # ● アニメ移動実行
  #--------------------------------------------------------------------------
  def move_anime
    @move_data = @battler.sv.effect_data[0].dup
    # ターゲットを取得
    @target_battler = [@battler.sv.m_a_targets.shift]
    @target_battler = N03.get_targets(@move_data[3], @battler) if @move_data[3] < 0
    set_move
    return if @move_data[16] == ""
    weapon_data = N03::ACTION[@move_data[16]]
    return if weapon_data == nil
    @weapon_data = weapon_data.dup
    set_graphics
    set_ox
    set_weapon_move
  end
  #--------------------------------------------------------------------------
  # ● 武器画像を取得
  #--------------------------------------------------------------------------  
  def set_graphics
    # 武器に依存しない画像設定がある場合
    if @weapon_data[13] != ""
      self.bitmap = Cache.character(@weapon_data[13]).dup
      @weapon_width = self.bitmap.width
      @weapon_height = self.bitmap.height
      return
    end
    # 武器を取得
    weapon = @battler.weapons[0]
    # 逆手装備を取得
    if @weapon_data[10]
      weapon = nil
      for armor in @battler.armors do break weapon = armor if armor.is_a?(RPG::Armor) && armor.etype_id == 1 end
      weapon = @battler.weapons[1] if !weapon
    end  
    # 武器がなければ処理をキャンセル
    return if weapon == nil
    # インデックスを取得
    file_index = @weapon_data[12]
    # アイコンを利用するなら
    if @weapon_data[1] == 0
      icon_index = weapon.icon_index
      self.bitmap = Cache.system("Iconset" + file_index).dup
      self.src_rect.set(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
      @weapon_width = @weapon_height = 24
    # 独自画像指定
    else
      file_name = @battler.sv.weapon_graphic(weapon.id, weapon.wtype_id) if weapon.is_a?(RPG::Weapon)
      file_name = @battler.sv.shield_graphic(weapon.id, weapon.atype_id) if weapon.is_a?(RPG::Armor)
      self.bitmap = Cache.character(file_name + file_index).dup
      @weapon_width = self.bitmap.width
      @weapon_height = self.bitmap.height
      return if @weapon_data[1] == 1
      # 2003仕様の武器アニメ
      @weapon_width /= @battler.sv.max_pattern[0]
    end
  end
  #--------------------------------------------------------------------------
  # ● 画像の原点を取得
  #--------------------------------------------------------------------------  
  def set_ox
    # 反転時は設定を逆に
    if @mirror
      case @weapon_data[6]
      when 1 ; @weapon_data[6] = 2 # 左上→右上に
      when 2 ; @weapon_data[6] = 1 # 右上→左上に
      when 3 ; @weapon_data[6] = 4 # 左下→右下に
      when 4 ; @weapon_data[6] = 3 # 右下→左下に
      end
    end
    # 原点を設定
    case @weapon_data[6]
    when 0 # 中心
      self.ox = @weapon_width / 2
      self.oy = @weapon_height / 2
    when 1 # 左上
      self.ox = 0
      self.oy = 0
    when 2 # 右上
      self.ox = @weapon_width
      self.oy = 0
    when 3 # 左下
      self.ox = 0
      self.oy = @weapon_height
    when 4 # 右下
      self.ox = @weapon_width
      self.oy = @weapon_height
    when 5 # バトラーと同じ
      self.ox = @weapon_width / 2
      self.oy = @weapon_height
    end
  end  
  #--------------------------------------------------------------------------
  # ● バトラーの座標を取得
  #--------------------------------------------------------------------------  
  def set_battler_position
    @position_x = @battler.sv.x + @weapon_data[3][0] * N03.mirror_num(@mirror) * 100
    @position_y = (@battler.sv.y - @battler.sv.h - @battler.sv.j - @battler.sv.c - @battler.sv.oy_adjust) + @weapon_data[3][1] * 100
    reset_position
  end
  #--------------------------------------------------------------------------
  # ● 座標を初期化
  #--------------------------------------------------------------------------  
  def reset_position
    @real_x = @position_x / 100
    @real_y = @position_y / 100
    @real_zoom_x = 1
    @real_zoom_y = 1
  end
  #--------------------------------------------------------------------------
  # ● 戦闘アニメを表示
  #--------------------------------------------------------------------------  
  def set_animation(anime_id)
    return if $data_animations[anime_id] == nil
    @anime_position = $data_animations[anime_id].position
    @horming = true
    @horming = false if @anime_position == 3
    @anime_camera_zoom = true
    @anime_no_mirror = false
    start_animation($data_animations[anime_id], @mirror)
    timings = $data_animations[anime_id].timings
  end
  #--------------------------------------------------------------------------
  # ● ヒット時の戦闘アニメ実行
  #--------------------------------------------------------------------------  
  def set_hit_animation(position_data, hit_anime_id, target)
    return if $data_animations[hit_anime_id] == nil
    @real_x = position_data[0]
    @real_y = position_data[1]
    @position_x = position_data[0] * 100
    @position_y = position_data[1] * 100
    self.z = position_data[2]
    @z_plus = 1000
    @action_end = false
    @horming = true
    set_animation(hit_anime_id)
    @anime_time = $data_animations[hit_anime_id].frame_max * 4
    @timing_targets = [target]
    @move_time = @hit_anime_id = 0
    @weapon_data = []
  end
  #--------------------------------------------------------------------------
  # ● タイミングバトラー追加
  #--------------------------------------------------------------------------  
  def timing_battler_set(target)
    @timing_targets.push(target)
  end
  #--------------------------------------------------------------------------
  # ● 武器の動きを取得
  #--------------------------------------------------------------------------  
  def set_weapon_move
    # 開始位置を取得
    set_battler_position if @move_time == 0
    @z_plus = 50 if @z_plus == 0 && @weapon_data[9]
    self.z = @battler.sv.z + @z_plus
    # 反転処理
    @mirror = !@mirror if @weapon_data[7]
    self.mirror = @mirror
    # 更新パターンをセット
    set_pattern
    @max_pattern = 2 if @max_pattern == 1
    # 動きを計算
    @weapon_move_data = []
    @weapon_angle_data = []
    @weapon_zoom_data = []
    num = N03.mirror_num(@mirror)
    for i in 0...@max_pattern
      move_data_x = @weapon_data[2][0] * num * 100 * i / (@max_pattern - 1)
      move_data_y = @weapon_data[2][1] * 100 * i / (@max_pattern - 1)
      move_angle = @weapon_data[4] * num + (@weapon_data[5] * num - @weapon_data[4] * num) * i / (@max_pattern - 1)
      move_zoom_x = 1 + (@weapon_data[8][0] - 1) * i / (@max_pattern - 1)
      move_zoom_y = 1 + (@weapon_data[8][1] - 1) * i / (@max_pattern - 1)
      @weapon_move_data.push([move_data_x, move_data_y])
      @weapon_angle_data.push(move_angle)
      @weapon_zoom_data.push([move_zoom_x, move_zoom_y])
    end
  end  
  #--------------------------------------------------------------------------
  # ● 更新パターン
  #--------------------------------------------------------------------------
  def set_pattern
    if @weapon_data[11] == -1
      return @max_pattern = @battler.sv.max_pattern[0] if @battler.sv.pattern_type != 0
      @count = @battler.sv.pattern_time
      @max_count = @battler.sv.pattern_time
      @max_pattern = @battler.sv.max_pattern[0]
      @repeat = false
    else
      @count = @weapon_data[11][0]
      @max_count = @weapon_data[11][0]
      @max_pattern = @weapon_data[11][1]
            @repeat = @weapon_data[11][2]
    end
    @pattern = 0
  end
  #--------------------------------------------------------------------------
  # ● 移動実行
  #--------------------------------------------------------------------------
  def set_move
    # 戦闘アニメを取得
    set_animation(@move_data[1][0]) if $data_animations[@move_data[1][0]] != nil && $data_animations[@move_data[1][0]].position != 3
    @anime_camera_zoom = @move_data[13]
    @loop = @move_data[14]
    @loop = false if @move_data[1][0] == 0
    @anime_no_mirror = @move_data[15]
    @se_flag = @move_data[17]
    # 開始位置を取得
    start_position
    @z_plus = 1000 if @move_data[9]
    # ターゲットバトラー画像にこのアニメのSEとタイミング設定を反映させる
    @timing_targets = @target_battler
    # 座標計算
    @move_x = @move_data[5][0] * 100 * N03.mirror_num(@mirror)
    @move_y = @move_data[5][1] * 100
    # 時間計算か速度計算か
    @distanse_move = true if @move_data[6] > 0
    @move_time = @move_data[6].abs
    # 時間0の場合、アニメが設定されていればアニメ表示時間に合わせる
    if @move_time == 0
      @move_time = $data_animations[@move_data[1][0]].frame_max * 4 if $data_animations[@move_data[1][0]]
      @move_time = 1 if !$data_animations[@move_data[1][0]]
      @distanse_move = false
    end
    # 貫通タイプの場合
    @through = true if @move_data[7] == 1
    @auto_through_flag = false
    @auto_through_flag = true if @move_data[7] == 0
    # ターゲット座標計算
    if @target_battler == nil
      @target_x = @move_x * 100
      @target_x = (Graphics.width - @move_x) * 100 if @mirror
      @target_y = @move_y * 100
    else
      move_data_set
    end
    # ターゲットに到達するまでの時間を計算
    @move_time = distanse_calculation(@move_time, @target_x, @target_y)
    # 円軌道計算
    orbit
    # バトラーのウエイト設定
    @battler.sv.wait = @move_time - 1 if @move_data[10][0]
    @move_horming = @move_data[12]
  end  
  #--------------------------------------------------------------------------
  # ● 速度を時間に変換
  #--------------------------------------------------------------------------
  def distanse_calculation(time, target_x, target_y)
    return time if !@distanse_move
    distanse_x = @position_x - @target_x
    distanse_x = @target_x - @position_x if @target_x > @position_x
    distanse_y = @position_y - @target_y
    distanse_y = @target_y - @position_y if @target_y > @position_y
    distanse = [distanse_x, distanse_y].max
    return distanse / (time * 100) + 1
  end
  #--------------------------------------------------------------------------
  # ● 移動目標の更新
  #--------------------------------------------------------------------------
  def move_data_set
    return if @target_battler == nil
    position = N03.get_targets_position(@target_battler, true, @anime_position)
    @target_x = position[0] + @move_x
    @target_y = position[1] - position[2] + @move_y
  end
  #--------------------------------------------------------------------------
  # ● 開始位置を計算
  #--------------------------------------------------------------------------
  def start_position
    starter = [@battler.sv.m_a_starter.shift]
    starter = N03.get_targets(@move_data[2], @battler) if @move_data[2] < 0
    position = [0, 0]
    position = N03.get_targets_position(starter, true, @anime_position) if starter != nil
    @position_x = position[0] + @move_data[4][0] * 100
    @position_y = position[1] + position[2] + @move_data[4][1] * 100
    @position_z = @position_y
  end  
  #--------------------------------------------------------------------------
  # ● 円軌道計算
  #--------------------------------------------------------------------------
  def orbit
    orbit_data = @move_data[8].dup
    orbit_data[0] *= 100
    orbit_data[1] *= 100
    orbit_d = []
    for i in 0...@move_time / 2
      @orbit = orbit_data[0]
      orbit_data[0] /= 2
      orbit_d = orbit_data[1]
      orbit_data[1] /= 2
    end
    @orbit = @orbit + orbit_d.reverse!
    @orbit.reverse!
  end  
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    update_hit_anime if @anime_time != 0
    update_move if @move_time != 0
    update_weapon_move if @weapon_data != []
    update_position
    update_color
    self.visible = @battler.sv.weapon_visible
    super
  end
  #--------------------------------------------------------------------------
  # ● ヒット時の戦闘アニメ
  #--------------------------------------------------------------------------
  def update_hit_anime
    @anime_time -= 1
    @action_end = true if @anime_time == 0
  end
  #--------------------------------------------------------------------------
  # ● 移動の更新
  #--------------------------------------------------------------------------
  def update_move
    move_data_set if @move_horming && !@hit_position
    through_set(@move_time, @target_x, @target_y) if @move_time == 1 && !@hit_position
    @o += @orbit[@move_time - 1] if @orbit[@move_time - 1] != nil
    @position_x = (@position_x * (@move_time - 1) + @target_x) / @move_time
    @position_y = (@position_y * (@move_time - 1) + @target_y) / @move_time + @o
    reset_position
    set_animation(@move_data[1][0]) if @loop && !animation?
    @move_time -= 1
    return if @move_time != 0
    @action_end = true if !@action_end_cancel
  end
  #--------------------------------------------------------------------------
  # ● 武器の動きを更新
  #--------------------------------------------------------------------------
  def update_weapon_move
    pattern = update_pattern
    set_battler_position if @move_time == 0 && !@action_end_cancel
    @real_x = @position_x / 100 + @weapon_move_data[pattern][0] / 100
    @real_y = @position_y / 100 + @weapon_move_data[pattern][1] / 100
    @real_zoom_x = @weapon_zoom_data[pattern][0]
    @real_zoom_y = @weapon_zoom_data[pattern][1]
    self.angle = @weapon_angle_data[pattern]
    self.src_rect.set(@weapon_width * pattern, 0, @weapon_width, @weapon_height) if @weapon_data[1] == 2
  end
  #--------------------------------------------------------------------------
  # ● パターンを更新
  #--------------------------------------------------------------------------
  def update_pattern
    return @battler.sv.pattern_w if @count == nil
    @count -= 1
    return @pattern if @count != 0
    @count = @max_count
    @pattern += 1
    if !@repeat && @pattern == @max_pattern
      @pattern = @max_pattern - 1
    elsif @pattern == @max_pattern
      @pattern = 0
    end
    return @pattern
  end
  #--------------------------------------------------------------------------
  # ● 座標を更新
  #--------------------------------------------------------------------------
  def update_position
    self.x = (@real_x - $sv_camera.x) * $sv_camera.convert / 1000
    self.y = (@real_y - $sv_camera.y) * $sv_camera.convert / 1000
    self.x += $sv_camera.sx / 100 unless @battler.sv.h != 0 && @weapon_data != []
    self.y += $sv_camera.sy / 100 unless @battler.sv.h != 0 && @weapon_data != []
    self.z = @battler.sv.z + @z_plus - 10
    self.zoom_x = @real_zoom_x * $sv_camera.zoom
    self.zoom_y = @real_zoom_y * $sv_camera.zoom
    self.opacity = @battler.sv.opacity if @battler.sv.opacity_data[4]
  end
  #--------------------------------------------------------------------------
  # ● 貫通の処理
  #--------------------------------------------------------------------------
  def through_set(time, target_x, target_y)
    @hit_anime_id = N03.get_attack_anime_id(@move_data[1][1], @battler)
    @battler.sv.wait = N03.get_anime_time(@hit_anime_id) if @move_data[10][1]
    moving_x = (target_x / 100 - @position_x / 100) / time
    moving_y = (target_y / 100 - @position_y / 100) / time
    goal_x = $sv_camera.max_left - 100 if moving_x < 0
    goal_x = Graphics.width + $sv_camera.max_right + 100 if moving_x > 0
    goal_y = $sv_camera.max_top - 100 if moving_y < 0
    goal_y = Graphics.height + $sv_camera.max_bottom + 100 if moving_y > 0
    if goal_x == nil &&  goal_y == nil
      time = 0
      reset_position
    else
      time = move_calculation(moving_x, moving_y, goal_x, goal_y)
    end
    target_x = @position_x + moving_x * time * 100
    target_y = @position_y + moving_y * time * 100
    @pre_data = [time, target_x, target_y]
    @battler.sv.m_a_data.push([@move_data[11], @target_battler, @index, @auto_through_flag, []])
    @action_end_cancel = true
    @hit_position = [@real_x, @real_y, self.z]
  end  
  #--------------------------------------------------------------------------
  # ● 到達時間試算
  #--------------------------------------------------------------------------
  def move_calculation(moving_x, moving_y, goal_x, goal_y)
    move_x = @position_x / 100
    move_y = @position_y / 100
    time = 0
    loop do
      move_x += moving_x
      move_y += moving_y
      time += 1
      return time if moving_x < 0 && move_x < goal_x
      return time if moving_x > 0 && move_x > goal_x
      return time if moving_y < 0 && move_y < goal_y
      return time if moving_y > 0 && move_y > goal_y
    end
  end   
  #--------------------------------------------------------------------------
  # ● ミス時に消える処理から貫通処理に変換
  #--------------------------------------------------------------------------
  def through_change
    @action_end_cancel = false
    @through = true
    @move_time = @pre_data[0]
    @target_x = @pre_data[1]
    @target_y = @pre_data[2]
    @pre_data = nil
  end  
  #--------------------------------------------------------------------------
  # ● SE とフラッシュのタイミング処理
  #--------------------------------------------------------------------------
  def animation_process_timing(timing)
    return if !@timing_targets
    se_flag = true
    se_flag = @se_flag if @se_flag != nil
    for target in @timing_targets
      target.sv.timing.push([se_flag, timing.dup])
      se_flag = false if @animation.position == 3
    end  
  end
  #--------------------------------------------------------------------------
  # ● 色調の更新
  #--------------------------------------------------------------------------
  def update_color
    return if @battler.sv.color == []
    self.color.set(@battler.sv.color[0], @battler.sv.color[1], @battler.sv.color[2], @battler.sv.color[3])
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    super
    self.bitmap.dispose if self.bitmap != nil
  end
end

#==============================================================================
# ■ Sprite_Battle_Picture
#------------------------------------------------------------------------------
#  ピクチャ表示用のスプライトです。
#==============================================================================
class Sprite_Battle_Picture < Sprite
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数 
  #--------------------------------------------------------------------------
  attr_accessor   :action_end           # 終了フラグ
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(viewport = nil)
    super(viewport)
    @action_end = false
    self.ox = 0
  end
  #--------------------------------------------------------------------------
  # ● セット
  #--------------------------------------------------------------------------
  def set(battler)
    @battler = battler
    @data = @battler.sv.effect_data.shift
    @time = @data[4]
    @mirror = $sv_camera.mirror
    @mirror = false if !@data[8]
    self.opacity = @data[6][0]
    @s_x = @data[2][0] if @data[2] != []
    @s_x = Graphics.width - @data[2][0]  if @data[2] != [] && @mirror
    @s_y = @data[2][1] if @data[2] != []
    @e_x = @data[3][0] if @data[3] != []
    @e_x = Graphics.width - @data[3][0] if @data[3] != [] && @mirror
    @e_y = @data[3][1] if @data[3] != []
    @s_x = self.x if @data[2] == []
    @s_y = self.y if @data[2] == []
    @e_x = self.x if @data[3] == []
    @e_y = self.y if @data[3] == []
    self.x = @s_x
    self.y = @s_y
    return @action_end = true if @time == 0
    @move_x = (@e_x * 1.0 - @s_x) / @time
    @move_y = (@e_y * 1.0 - @s_y) / @time
    self.z = @data[5]
    return set_plane(battler) if @data[7] != []
    self.bitmap = Cache.picture(@data[9]) if !bitmap or @data[9] != ""
    return @action_end = true if !bitmap
    self.mirror = @mirror
    self.ox = self.bitmap.width if @mirror
  end
  #--------------------------------------------------------------------------
  # ● プレーン移行
  #--------------------------------------------------------------------------
  def set_plane(battler)
    @viewport = Viewport.new(@data[2][0],@data[2][1],@data[7][0],@data[7][1]) if !@viewport
    viewport = @viewport
    @plane = Plane.new(viewport) if !@plane
    @plane.bitmap = Cache.picture(@data[9]) if [email protected] or @data[9] != ""
    return @action_end = true if [email protected]
    @plane.ox = @data[7][0]
    @plane.oy = @data[7][1]
    @plane.opacity = @data[6][0]
    @move_x = @remain_move[0] if @data[2] == @data[3]
    @move_y = @remain_move[1] if @data[2] == @data[3]
    @remain_move = [@move_x, @move_y]
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    @action_end = true if [email protected]
    return if @time == 0
    return if @action_end
    @time -= 1
    return plane_update if @plane
    super
    self.x += @move_x
    self.y += @move_y
    self.opacity += @data[6][1]
    return if @time != 1
    self.x = @e_x
    self.y = @e_y
    @time = 0
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def plane_update
    @plane.ox += @move_x
    @plane.oy += @move_y
    @plane.opacity += @data[6][1]
    @time = @data[4] if @time == 0
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    bitmap.dispose if bitmap
    @plane.dispose if @plane
    @viewport.dispose if @viewport
    super
  end
end

#==============================================================================
# ■ Sprite_Back_Picture
#------------------------------------------------------------------------------
#  周期ピクチャ用のスプライトです。
#==============================================================================
class Sprite_Back_Picture < Plane
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数 
  #--------------------------------------------------------------------------
  attr_accessor   :action_end           # 終了フラグ
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(viewport = nil, index)
    super(viewport)
    @index = index
    @real_x = 0
    @real_y = 0
    @real_opacity = 0
    @move_x = 0
    @move_y = 0
    @move_opacity = 0
    @time = 0
    @switche = 0
    @action_end = false
  end
  #--------------------------------------------------------------------------
  # ● セットアップ
  #--------------------------------------------------------------------------
  def setup(data)
    self.bitmap = Cache.picture(data[9])
    self.z = data[6]
    @switche = data[1]
    mirror = $sv_camera.mirror
    mirror = false if !data[8]
    @move_x = data[3][0]
    @move_x *= -1 if mirror
    @move_y = data[3][1]
    @time = data[4]
    @time = -1 if @time == 0
    @real_opacity = (data[5][0] + 1) * 100
    @move_opacity = data[5][1]
    @start_opacity = data[5][0]
    @shake_ok = data[7]
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    update_picture if @time != 0
    self.ox = $sv_camera.x - @real_x
    self.oy = $sv_camera.y - @real_y
    if @shake_ok
      self.ox -= $sv_camera.sx / 100
      self.oy -= $sv_camera.sy / 100
    end
    self.ox *= $sv_camera.zoom
    self.oy *= $sv_camera.zoom
    self.zoom_x = @zoom_x * $sv_camera.zoom
    self.zoom_y = @zoom_y * $sv_camera.zoom
    self.opacity = @real_opacity / 100
    @move_opacity *= -1 if self.opacity == 255 or self.opacity <= @start_opacity
    @switche
    @action_end = true if @switche > 0 && !$game_switches[@switche]
    @action_end = true if @switche < 0 && !$sv_camera.switches[@switche.abs]
  end
  #--------------------------------------------------------------------------
  # ● ピクチャの更新
  #--------------------------------------------------------------------------
  def update_picture
    @real_x += @move_x / 100
    @real_y += @move_y / 100
    @real_x = 0 if @real_x >= self.bitmap.width or @real_x <= -self.bitmap.width
    @real_y = 0 if @real_y >= self.bitmap.height or @real_y <= -self.bitmap.height
    @zoom_x = 1
    @zoom_y = 1
    @real_opacity += @move_opacity
    @time -= 1
    @time = -1 if @time < -100
  end
end

#==============================================================================
# ■ Sprite_Back_Picture
#------------------------------------------------------------------------------
#  ダメージ表示のスプライトです。
#==============================================================================
class Sprite_Damage < Sprite
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数 
  #--------------------------------------------------------------------------
  attr_reader   :action_end                  # POP終了フラグ
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(viewport = nil, battler)
    super(viewport)
    @battler = battler
    @time = 0
    return @action_end = true if !@battler
    @direction = -1
    @direction *= -1 if @battler.actor?
    @direction *= -1 if $sv_camera.mirror
    set_state
    set_damage
    update
  end
  #--------------------------------------------------------------------------
  # ● ステート表示
  #--------------------------------------------------------------------------
  def set_state
    return if !N03::STATE_POP
    states = @battler.result.added_state_objects
    states.delete($data_states[@battler.death_state_id]) if @battler.result.hp_damage != 0
    return if states == []
    return if @battler.sv.add_state == @battler.result.added_state_objects
    @battler.sv.add_state = states.dup
    @st = []
    @st_base = []
    for i in 0...states.size
      @st = Sprite.new
      bitmap_state(@st, states)
      @st_base = []
      @st_base[0] = @direction * (-20 + 5 * i) + @battler.sv.x / 100
      @st_base[1] = -40 - @state_height * i + (@battler.sv.y - @battler.sv.h - @battler.sv.j - @battler.sv.oy_adjust)/ 100
      @st.z = 1000 + i
      @st.opacity = 0
    end
    @time = @pop_time = 80
  end   
  #--------------------------------------------------------------------------
  # ● ステート画像
  #--------------------------------------------------------------------------
  def bitmap_state(state, state_object)
    name = state_object.name
    state.bitmap = Cache.system("Iconset").dup
    state.src_rect.set(state_object.icon_index % 16 * 24, state_object.icon_index / 16 * 24, 24, 24)
    @state_height = 24
  end
  #--------------------------------------------------------------------------
  # ● ダメージ表示
  #--------------------------------------------------------------------------
  def hit_count
    for i in [email protected]
      if @battler.sv.hit == nil
        @hit = i
        return @battler.sv.hit = @hit
      end
    end
    @hit = @battler.sv.hit.size
    @battler.sv.hit.push(@hit)
  end  
  #--------------------------------------------------------------------------
  # ● ダメージ表示
  #--------------------------------------------------------------------------
  def set_damage
   return @action_end = true if !N03::DAMAGE_POP
    hp_damage = nil
    mp_damage = nil
    tp_damage = nil
    hp_damage = @battler.result.hp_damage if @battler.result.hp_damage != 0
    hp_damage = @battler.result.hp_drain  if @battler.result.hp_drain  != 0
    mp_damage = @battler.result.mp_damage if @battler.result.mp_damage != 0
    mp_damage = @battler.result.mp_drain  if @battler.result.mp_drain  != 0
    tp_damage = @battler.result.tp_damage if @battler.result.tp_damage != 0
    dam_arr   = [hp_damage, mp_damage, tp_damage]
    if dam_arr.compact.size == 0 || !dam_arr.compact.any? { |x| x != 0 }
      @action_end = true if @st == nil
      return # ステートだけPOPする設定を考慮して@action_endは返さない
    end
    hit_count
    cou = 0
    dam_arr.each_with_index { |damage, index|
      next if damage.nil?
      next unless damage != 0
      file = N03::DAMAGE_PLUS if damage > 0
      file = N03::DAMAGE_MINUS if damage < 0
      #--------------------------------------#
      # Start toggle showing HP/MP/TP images.#
      #--------------------------------------#
      if N03::SHOW_MP_IMAGE == true
      add_file = N03::DAMAGE_MP if index == 1
    end
      if N03::SHOW_TP_IMAGE == true
      add_file = N03::DAMAGE_TP if index == 2
    end
      if N03::SHOW_HP_IMAGE == true
      add_file = N03::DAMAGE_HP if index == 0
    end
      #--------------------------------------#
      # End toggle showing HP/MP/TP images.  #
      #--------------------------------------#
      adjust_x = N03::DAMAGE_ADJUST
      @num ||= []
      @num_base ||= []
      damage = damage.abs
      max_num = damage.to_s.size
      max_num += 1 if add_file != nil
      for i in 0...max_num
        ri = @num.size
        @num[ri] = Sprite.new
        if add_file != nil && i == max_num - 1
          @num[ri].bitmap = Cache.system(add_file)
          cw = (damage % (10 * 10 ** i))/(10 ** i)
          sw = 0 if sw == nil
        else
          @num[ri].bitmap = Cache.system(file)
          cw = (damage % (10 * 10 ** i))/(10 ** i)
          sw = @num[ri].bitmap.width / 10
          @num[ri].src_rect.set(cw * sw, 0, sw, @num[ri].bitmap.height)
        end
        @num_base[ri] = []
        @num_base[ri][0] = (sw + adjust_x) * i * -1 + (@battler.sv.x / 100)
        @num_base[ri][1] =  -(@num[ri].bitmap.height / 3) - i * 2 - @hit * 2 - cou * @num[ri].bitmap.height + (@battler.sv.y - @battler.sv.h - @battler.sv.j - @battler.sv.oy_adjust)/ 100
        @num_base[ri][0] -= @num[ri].bitmap.width / 2 - adjust_x if add_file != nil && i == max_num - 1
        @num[ri].z = 1000 + i + @hit * 10
      end
      cou += 1
    }
    @time = @pop_time = 80
  end

  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    return if @time == 0
    for i in [email protected] do update_state_move(@st, i) end if @st != nil
    for i in [email protected] do update_num_move(@num, i) end if @num != nil
    @time -= 1
    @action_end = true if @time == 0
  end
  #--------------------------------------------------------------------------
  # ● ステート画像の更新
  #--------------------------------------------------------------------------
  def update_state_move(state, index)
    min = @pop_time - index * 2
    case @time
    when min-15..min
      @st_base[index][0] += @direction
      state.opacity += 25
    when min-80..min-50
      @st_base[index][0] += @direction
      state.opacity -= 25
    end
    state.x = (@st_base[index][0] - $sv_camera.x) * $sv_camera.zoom
    state.y = (@st_base[index][1] - $sv_camera.y) * $sv_camera.zoom
  end
  #--------------------------------------------------------------------------
  # ● 数値の更新
  #--------------------------------------------------------------------------
  def update_num_move(num, index)
    min = @pop_time - index * 2
    case @time
    when min-1..min
      @num_base[index][0] += @direction * @hit
      @num_base[index][1] -= 5 + @hit * 2
    when min-3..min-2
      @num_base[index][0] += @direction * @hit
      @num_base[index][1] -= 4 + @hit * 2
    when min-6..min-4
      @num_base[index][0] += @direction
      @num_base[index][1] -= 3 + @hit * 2
    when min-14..min-7
      @num_base[index][0] += @direction
      @num_base[index][1] += 2
    when min-17..min-15
      @num_base[index][1] -= 2 + @hit * 2
    when min-23..min-18
      @num_base[index][1] += 1
    when min-27..min-24
      @num_base[index][1] -= 1
    when min-30..min-28
      @num_base[index][1] += 1
    when min-33..min-31
      @num_base[index][1] -= 1
    when min-36..min-34
      @num_base[index][1] += 1
    end
    num.x = (@num_base[index][0] - $sv_camera.x) * $sv_camera.zoom
    num.y = (@num_base[index][1] - $sv_camera.y) * $sv_camera.zoom
    num.opacity = 256 - (12 - @time) * 32
    num.visible = false if @time == 0
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    @battler.sv.hit[@hit] = nil if @hit
    bitmap.dispose if bitmap
    for i in [email protected] do @num.dispose end if @num != nil
    for i in [email protected] do @st.dispose end if @st != nil
    super
  end
end

#==============================================================================
# ■ Window_Skill_name
#------------------------------------------------------------------------------
#  スキル名を表示するウィンドウです。
#==============================================================================
class Window_Skill_name < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(text)
    super(0, 0, Graphics.width, line_height + standard_padding * 2)
    draw_text(4, 0, Graphics.width - 64, line_height,text, 1)
  end
end

#==============================================================================
# ■ Spriteset_Sideview
#------------------------------------------------------------------------------
#  サイドビュー独自のスプライトをまとめたクラスです。
#==============================================================================
class Spriteset_Sideview
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(viewport)
    @viewport = viewport
    @weapons = []
    @pictures = []
    @back_pic = []
    @damage = []
    $sv_camera.setup
    N03.camera(nil, N03::BATTLE_CAMERA["回合前镜头"].dup)
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    update_battler_data
    update_damage
    update_pictures
    update_back_pic
    update_weapons
  end  
  #--------------------------------------------------------------------------
  # ● バトラーデータの更新
  #--------------------------------------------------------------------------
  def update_battler_data
    for battler in $game_party.battle_members + $game_troop.members
      weapon_end(battler) if battler.sv.weapon_end
      next if battler.sv.effect_data == []
      for effect_data in battler.sv.effect_data do set_effects(battler, effect_data) end
    end
  end
  #--------------------------------------------------------------------------
  # ● ダメージ画像の更新
  #--------------------------------------------------------------------------
  def update_damage
    for i in [email protected]
      next if @damage == nil
      @damage.update if @damage != nil
      next if !@damage.action_end
      @damage.dispose
      @damage = nil
    end
  end
  #--------------------------------------------------------------------------
  # ● ピクチャアクションの更新
  #--------------------------------------------------------------------------
  def update_pictures
    for i in [email protected]
      next if @pictures == nil
      @pictures.update if @pictures != nil
      next if !@pictures.action_end
      @pictures.dispose
      @pictures = nil
    end
  end
  #--------------------------------------------------------------------------
  # ● 周期ピクチャの更新
  #--------------------------------------------------------------------------
  def update_back_pic
    set_back_pic if $sv_camera.program_picture != []
    for i in 0...@back_pic.size
      next if @back_pic == nil
      @back_pic.update if @back_pic != nil
      next if !@back_pic.action_end
      @back_pic.dispose
      @back_pic = nil
    end
  end
  #--------------------------------------------------------------------------
  # ● 武器アクションの更新
  #--------------------------------------------------------------------------
  def update_weapons
    for i in [email protected]
      next if @weapons == nil
      @weapons.update if @weapons != nil
      next if !@weapons.action_end
      @weapons.dispose
      @weapons = nil
    end
  end
  #--------------------------------------------------------------------------
  # ● ダメージ実行
  #--------------------------------------------------------------------------
  def set_damage_pop(target)
    for i in [email protected]
      next if @damage[1] != nil
      return @damage[1] = Sprite_Damage.new(@viewport, target)
    end
    @damage.push(Sprite_Damage.new(@viewport, target))
  end
  #--------------------------------------------------------------------------
  # ● 周期ピクチャ実行
  #--------------------------------------------------------------------------
  def set_back_pic
    for data in $sv_camera.program_picture
      if @back_pic[data[2]] != nil
        @back_pic[data[2]].dispose
        @back_pic[data[2]] = nil
      end
      @back_pic[data[2]] = Sprite_Back_Picture.new(@viewport, data[2])
      @back_pic[data[2]].setup(data)
    end
    $sv_camera.program_picture = []
  end
  #--------------------------------------------------------------------------
  # ● エフェクト開始
  #--------------------------------------------------------------------------
  def set_effects(battler, effect_data)
    case effect_data[0]
    when "pic" ; set_pictures(battler, effect_data)
    when  "wp" ; set_weapons(battler,  true)
    when "m_a" ; set_weapons(battler, false)
    end
  end
  #--------------------------------------------------------------------------
  # ● ピクチャアクション実行
  #--------------------------------------------------------------------------
  def set_pictures(battler, effect_data)
    @pictures[effect_data[1]] = Sprite_Battle_Picture.new if @pictures[effect_data[1]] == nil
    @pictures[effect_data[1]].set(battler)
  end
  #--------------------------------------------------------------------------
  # ● 武器アクション実行
  #--------------------------------------------------------------------------
  def set_weapons(battler, weapon_flag, test = true)
    for i in [email protected]
      next if @weapons != nil
      @weapons = Sprite_Weapon.new(@viewport, i, battler)
      battler.sv.weapon_index.push(i) if weapon_flag
      return i
    end
    @weapons.push(Sprite_Weapon.new(@viewport, @weapons.size, battler))
    battler.sv.weapon_index.push(@weapons.size - 1) if weapon_flag
    return @weapons.size - 1
  end
  #--------------------------------------------------------------------------
  # ● バトラーの武器アクション終了
  #--------------------------------------------------------------------------
  def weapon_end(battler)
    battler.sv.weapon_end = false
    for index in battler.sv.weapon_index
      weapon_index = battler.sv.weapon_index.shift
      @weapons[weapon_index].dispose if @weapons[weapon_index] != nil
      @weapons[weapon_index] = nil
    end
    battler.sv.weapon_index.compact!
  end  
  #--------------------------------------------------------------------------
  # ● ヒット時の戦闘アニメ実行
  #--------------------------------------------------------------------------
  def set_hit_animation(battler, weapon_index, hit_targets, miss)
    weapon = @weapons[weapon_index]
    for target in hit_targets
      next @weapons[@hit_index].timing_battler_set(target) if @hit_index != nil
      @hit_index = set_weapons(battler, false, false)
      @weapons[@hit_index].set_hit_animation(weapon.hit_position, weapon.hit_anime_id, target)
    end
    @hit_index = nil
    if !weapon.through && !miss
      @weapons[weapon_index].dispose
      @weapons[weapon_index] = nil
    else
      @weapons[weapon_index].through_change
    end
  end
  #--------------------------------------------------------------------------
  # ● サイドビューデータの初期化
  #--------------------------------------------------------------------------
  def reset_sideview
    $sv_camera.reset
    for member in $game_troop.members + $game_party.battle_members do member.sv.reset end
  end  
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    dispose_effects(@weapons)
    dispose_effects(@pictures)
    dispose_effects(@back_pic)
    dispose_effects(@damage)
    reset_sideview
  end
  #--------------------------------------------------------------------------
  # ● エフェクト画像の解放
  #--------------------------------------------------------------------------
  def dispose_effects(effects)
    for i in 0...effects.size
      effects.dispose if effects != nil
      effects = nil
    end
  end
end


#==============================================================================
# ■ Sprite_Battle_Back
#------------------------------------------------------------------------------
#  戦闘背景用のスプライトです。
#==============================================================================
class Sprite_Battle_Back < Plane
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(viewport = nil, index, battleback_name)
    super(viewport)
    @index = index
    if @index == 1
      data = N03::FLOOR1_DATA[battleback_name]
      data = N03::FLOOR1_DATA["默认Battlebacks1"] if data == nil
    elsif @index == 2
      data = N03::FLOOR2_DATA[battleback_name]
      data = N03::FLOOR2_DATA["默认Battlebacks2"] if data == nil
    end   
    data = data.dup
    @adjust_position = data[0]
    @zoom_x = data[1][0] / 100.0
    @zoom_y = data[1][1] / 100.0
    @shake_on = data[2]
    $game_switches[data[3]] = true if data[3] > 0
    $sv_camera.switches[data[3].abs] = true if data[3] < 0
    reset_scroll
    reset_back_data(battleback_name)
  end
  #--------------------------------------------------------------------------
  # ● 背景スクロールを初期化
  #--------------------------------------------------------------------------
  def reset_scroll
    @scroll_x = 0
    @scroll_y = 0
    @move_x = 0
    @move_y = 0
  end
  #--------------------------------------------------------------------------
  # ● 背景データを初期化
  #--------------------------------------------------------------------------
  def reset_back_data(battleback_name)
    @back_data = []
    @active_data = ["scroll",0, @move_x, @move_y, false, battleback_name,""]
    start_back_data(@active_data)
  end  
  #--------------------------------------------------------------------------
  # ● 背景画像のセッティング
  #--------------------------------------------------------------------------
  def set_graphics(new_bitmap)
    self.bitmap = new_bitmap
    @base_x = (self.bitmap.width * @zoom_x - Graphics.width) / 2 + @adjust_position[0]
    @base_y = (self.bitmap.height * @zoom_y - Graphics.height) / 2 + @adjust_position[1]
    # 限界座標を取得
    max_top =  0
    max_bottom = self.bitmap.height * @zoom_y - Graphics.height
    max_left = 0
    max_right = self.bitmap.width * @zoom_x - Graphics.width
    exist = true
    exist = false if self.bitmap.height == 32 && self.bitmap.width == 32
    $sv_camera.setting(@index, [max_top, max_bottom, max_left, max_right, @base_x, @base_y,exist])
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    return if !bitmap
    update_back_data
    update_scroll unless @move_x == 0 && @move_y == 0
    update_color
    update_position
    update_back_adjust if @bt_back != nil
    create_back_adjust if @bt_back == nil && !@active_data[10] && @scroll_x == 0 && @scroll_y == 0
  end
  #--------------------------------------------------------------------------
  # ● 背景データを更新
  #--------------------------------------------------------------------------
  def update_back_data
    delete = true if @active_data[1] > 0 && !$game_switches[@active_data[1]]
    delete = true if @active_data[1] < 0 && !$sv_camera.switches[@active_data[1].abs]
    return if !delete
    for i in 0...@back_data.size
      @back_data = nil if @back_data[1] > 0 && !$game_switches[@back_data[1]]
      @back_data = nil if @back_data[1] < 0 && !$sv_camera.switches[@back_data[1].abs]
    end
    @back_data.compact!
    next_back_data
  end
  #--------------------------------------------------------------------------
  # ● 次の背景データをセット
  #--------------------------------------------------------------------------
  def next_back_data
    @back_data.delete(@active_data[11]) if @active_data[11] != nil
    @back_data.push(@active_data[11]) if @active_data[11] != nil
    @active_data = nil
    data = @back_data.pop
    @back_data = [@active_data] if @back_data.size == 0
    start_back_data(data)
  end  
  #--------------------------------------------------------------------------
  # ● 背景データを実行
  #--------------------------------------------------------------------------
  def start_back_data(data)
    return if back_data_remain(data)
    bt_back_dispose
    pre_active_data = @active_data
    @active_data[8] = [@back_name, @move_x, @move_y, @scroll_x, @scroll_y] if @active_data != nil
    @back_data.push(@active_data)     if @active_data != nil
    @active_data = data.dup
    @active_data[5] = @back_name      if @active_data[5] == ""
    @active_data[9] = set_back_adjust if @active_data[9] == nil
    back_data_scroll_on               if @active_data[8] == nil && @active_data[9][0] == false
    set_remain_back_data              if @active_data[8] != nil
    create_back(@active_data[5])      if @active_data[9][0] == false
    create_back_adjust                if @active_data[10]
    @active_data[11] = pre_active_data if pre_active_data && @active_data[7] == false
  end  
  #--------------------------------------------------------------------------
  # ● 背景データの保留
  #--------------------------------------------------------------------------
  def back_data_remain(data)
    remain = false
    remain = true if data[6] != "" && @active_data != nil && @active_data[9] != nil && @active_data[9][0] != false
    remain = true if @active_data != nil && @active_data[7] == false
    return remain if !remain
        @remain = true
    @back_data.push(data)
    return remain
  end  
  #--------------------------------------------------------------------------
  # ● 背景変更補正データをセット
  #--------------------------------------------------------------------------
  def set_back_adjust
    bt_adjust = []
    sign = -1
    if @active_data[6] == ""
      reset_scroll if @active_data[3][0] == 0 &&  @active_data[3][1] == 0
      bt_adjust = [false,false,0,0]
      return bt_adjust
    elsif @move_x != 0 or @active_data[3][0] != 0
      sign = 1 if @move_x < 0
      bt_adjust[0] = [self.bitmap.width * @zoom_x * sign, 0]
      bt_adjust[1] = [self.bitmap.width * @zoom_x * sign * 2, 0]
    elsif @move_y != 0 or @active_data[3][1] != 0
      sign = 1 if @move_y < 0
      bt_adjust[0] = [0, self.bitmap.height * @zoom_y * sign]
      bt_adjust[1] = [0, self.bitmap.height * @zoom_y * sign * 2]
    else
      reset_scroll if @active_data[3][0] == 0 &&  @active_data[3][1] == 0
      bt_adjust = [false,false,0,0]
      return bt_adjust
    end
    bt_adjust[2] = [bt_adjust[0][0], bt_adjust[0][1]]
    return bt_adjust
  end
  #--------------------------------------------------------------------------
  # ● 背景スクロールデータを実行
  #--------------------------------------------------------------------------
  def back_data_scroll_on
    mirror = $sv_camera.mirror
    mirror = false if !@active_data[4]
    @move_x = @active_data[3][0]
    @move_x *= -1 if mirror
    @move_y = @active_data[3][1]
  end
  #--------------------------------------------------------------------------
  # ● 保持している背景データを実行
  #--------------------------------------------------------------------------
  def set_remain_back_data
    return back_data_scroll_on if @move_x != 0 or @move_y != 0
    create_back(@active_data[8][0])
    @move_x    = @active_data[8][1]
    @move_y    = @active_data[8][2]
    @scroll_x  = @active_data[8][3]
    @scroll_y  = @active_data[8][4]
  end  
  #--------------------------------------------------------------------------
  # ● 背景画像の作成
  #--------------------------------------------------------------------------
  def create_back(back_name)
    return if back_name == @back_name or back_name == ""
    self.bitmap = Cache.battleback1(back_name) if @index == 1
    self.bitmap = Cache.battleback2(back_name) if @index == 2
    @back_name = back_name
  end  
  #--------------------------------------------------------------------------
  # ● 背景変更補正画像の作成
  #--------------------------------------------------------------------------
  def create_back_adjust
    return if @active_data[9][0] == false
    @active_data[10] = true
    mirror = $sv_camera.mirror
    mirror = false if !@active_data[4]
    @bt_back = []
    @bt_back[0] = Sprite.new(viewport)
    @bt_back[0].bitmap = Cache.battleback1(@active_data[6]) if @index == 1
    @bt_back[0].bitmap = Cache.battleback2(@active_data[6]) if @index == 2
    @bt_back[0].mirror = mirror
    @bt_back[1] = Sprite.new(viewport)
    @bt_back[1].bitmap = Cache.battleback1(@active_data[5]) if @index == 1
    @bt_back[1].bitmap = Cache.battleback2(@active_data[5]) if @index == 2
    @bt_back[1].mirror = mirror
  end
  #--------------------------------------------------------------------------
  # ● 背景スクロールの更新
  #--------------------------------------------------------------------------
  def update_scroll
    @scroll_x += @move_x
    @scroll_y += @move_y
    @scroll_x = 0 if @scroll_x / 100 >= self.bitmap.width * @zoom_x or @scroll_x / 100 <= -self.bitmap.width * @zoom_x
    @scroll_y = 0 if @scroll_y / 100 >= self.bitmap.height * @zoom_y or @scroll_y / 100 <= -self.bitmap.height * @zoom_y
  end
  #--------------------------------------------------------------------------
  # ● 色調変更の更新
  #--------------------------------------------------------------------------
  def update_color
    color_set if $sv_camera.color_set[@index] != nil
    return if @color_data == nil
    @color_data[4] -= 1
    if @color_data[4] == 0 && @color_data[5] != 0
      @color_data[4] = @color_data[5]
      @color_data[5] = 0
      @color_data[6] = [0,0,0,0]
    elsif @color_data[4] == 0
      @remain_color_data = @color_data
      return @color_data = nil
    end  
    for i in 0..3
      @color_data = (@color_data * (@color_data[4] - 1) + @color_data[6]) / @color_data[4]
    end  
    self.color.set(@color_data[0], @color_data[1], @color_data[2], @color_data[3])
  end
  #--------------------------------------------------------------------------
  # ● 座標の更新
  #--------------------------------------------------------------------------
  def update_position
    self.ox = $sv_camera.x + @base_x - @scroll_x / 100
    self.oy = $sv_camera.y + @base_y - @scroll_y / 100
    self.ox -= $sv_camera.sx / 100 if @shake_on
    self.oy -= $sv_camera.sy / 100 if @shake_on
    self.zoom_x = @zoom_x * $sv_camera.zoom
    self.zoom_y = @zoom_y * $sv_camera.zoom
    self.ox *= $sv_camera.zoom
    self.oy *= $sv_camera.zoom
    self.z = @index * 10
  end
  #--------------------------------------------------------------------------
  # ● 背景変更補正画像を更新
  #--------------------------------------------------------------------------
  def update_back_adjust
    @active_data[9][0][0] = 0 if @scroll_x == 0
    @active_data[9][0][1] = 0 if @scroll_y == 0
    @active_data[9][1][0] -= @active_data[9][2][0] if @scroll_x == 0
    @active_data[9][1][1] -= @active_data[9][2][1] if @scroll_y == 0
    for i in 0...@bt_back.size
      @bt_back.x = -self.ox + @active_data[9][0] * $sv_camera.zoom
      @bt_back.y = -self.oy + @active_data[9][1] * $sv_camera.zoom
      @bt_back.zoom_x = self.zoom_x
      @bt_back.zoom_y = self.zoom_y
      @bt_back.z = self.z + 1
      @bt_back.color.set(@color_data[0], @color_data[1], @color_data[2], @color_data[3]) if @color_data != nil
    end
    back_data_scroll_on if @active_data[9][0][0] == 0 && @active_data[9][0][1] == 0
    return unless @active_data[9][1][0] == 0 && @active_data[9][1][1] == 0
    bt_back_dispose
    create_back(@active_data[5])
    @active_data[9][0] = false
    next_back_data if @remain && @back_data.size != 1
    @remain = false
  end
  #--------------------------------------------------------------------------
  # ● 色調変更
  #--------------------------------------------------------------------------
  def color_set
    set = $sv_camera.color_set[@index]
    $sv_camera.color_set[@index] = nil
    set[4] = 1 if set[4] == 0
    @remain_color_data = [0,0,0,0] if @remain_color_data == nil
    @color_data = @remain_color_data
    @color_data[4] = set[4]
    @color_data[5] = set[5]
    @color_data[6] = set
  end
  #--------------------------------------------------------------------------
  # ● 背景変更補正画像の解放
  #--------------------------------------------------------------------------
  def bt_back_dispose
    for i in 0...@bt_back.size do @bt_back.dispose end if @bt_back != nil
    @bt_back = nil
  end  
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    bitmap.dispose if bitmap
    bt_back_dispose
    super
  end
end  
  
#==============================================================================
# ■ Battle_Camera
#------------------------------------------------------------------------------
#  戦闘カメラやバトルプログラムを扱うクラスです。
#==============================================================================
class Battle_Camera
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数 
  #--------------------------------------------------------------------------
  attr_reader   :sx                 # シェイクX座標
  attr_reader   :sy                 # シェイクY座標
  attr_reader   :max_top            # 上限界座標
  attr_reader   :max_bottom         # 下限界座標
  attr_reader   :max_left           # 左限界座標
  attr_reader   :max_right          # 右限界座標
  attr_accessor :switches           # サイドビュー専用スイッチ
  attr_accessor :color_set          # 色調変更データ
  attr_accessor :wait               # 戦闘シーンの強制ウエイト
  attr_accessor :win_wait           # 戦闘勝利前のウエイト
  attr_accessor :mirror             # 画面反転フラグ
  attr_accessor :program_scroll     # バトルプログラム 背景の自動スクロール
  attr_accessor :program_picture    # バトルプログラム 周期ピクチャ
  attr_accessor :event              # コモンイベント呼び出し
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    @switches = []
    @max_data = []
    @color_set = []
    @wait = 0
    @win_wait = false
    @mirror = false
    @event = false
    setup
  end
  #--------------------------------------------------------------------------
  # ● カメラX座標
  #--------------------------------------------------------------------------
  def x
    return @x / 100
  end
  #--------------------------------------------------------------------------
  # ● カメラY座標
  #--------------------------------------------------------------------------
  def y
    return @y / 100
  end
  #--------------------------------------------------------------------------
  # ● ズーム率
  #--------------------------------------------------------------------------
  def zoom
    return @zoom * 0.001
  end
  #--------------------------------------------------------------------------
  # ● ズーム率による座標変換
  #--------------------------------------------------------------------------
  def convert
    return @zoom
  end
  #--------------------------------------------------------------------------
  # ● カメラセットアップ
  #--------------------------------------------------------------------------
  def setup
    @x = 0
    @y = 0
    @sx = 0
    @sy = 0
    @zoom = 1000
    @time = 0
    @shake_time = 0
    program_setup
  end
  #--------------------------------------------------------------------------
  # ● カメラ初期化
  #--------------------------------------------------------------------------
  def reset
    @switches = []
    @max_data = []
    @color_set = []
    @wait = 0
    @win_wait = false
    @mirror = false
    program_setup(false)
  end  
  #--------------------------------------------------------------------------
  # ● バトルプログラムのセットアップ
  #--------------------------------------------------------------------------
  def program_setup(check = true)
    @played_program  = []
    @program_switch  = []
    @program_sound   = []
    @program_scroll  = []
    @program_se      = []
    @program_shake   = []
    @program_color   = []
    @program_picture = []
    @program_base = N03::BATTLE_PROGRAM.values.dup
    program_check if check
  end  
  #--------------------------------------------------------------------------
  # ● バトルプログラムのチェック
  #--------------------------------------------------------------------------
  def program_check
    for data in @program_base
      if program_start?(data) && !@played_program.include?(data)
        @played_program.push(data.dup)
        @program_scroll.push(data.dup)  if data[0] == "scroll"
        @program_picture.push(data.dup) if data[0] == "kpic"
        start_sound(data.dup)           if data[0] == "sound"
        start_program_switch(data.dup)  if data[0] == "switch"
        start_program_se(data.dup)      if data[0] == "keep_se"
        start_program_shake(data.dup)   if data[0] == "keep_sk"
        start_program_color(data.dup)   if data[0] == "keep_c"
      else
        @played_program.delete(data)  if !program_start?(data)
        @program_scroll.delete(data)  if data[0] == "scroll"
        @program_picture.delete(data) if data[0] == "kpic"
        @program_switch.delete(data)  if data[0] == "switch"
        @program_sound.delete(data)   if data[0] == "sound"
        @program_se.delete(data)      if data[0] == "keep_se"
        @program_shake.delete(data)   if data[0] == "keep_sk"
        @program_color.delete(data)   if data[0] == "keep_c"
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● バトルプログラムの開始
  #--------------------------------------------------------------------------
  def program_start?(data)
    start = false
    start = true if $game_switches[data[1].abs] && data[1] > 0
    start = true if @switches[data[1].abs] && data[1] < 0
    return start
  end  
  #--------------------------------------------------------------------------
  # ● バトルプログラム スイッチ操作の開始
  #--------------------------------------------------------------------------
  def start_program_switch(data)
    data[4] = data[4] + rand(data[5] + 1)
    data[4] = 1 if data[4] <= 0
    @program_switch.push(data)
  end
  #--------------------------------------------------------------------------
  # ● スイッチ操作の更新
  #--------------------------------------------------------------------------
  def update_program_switch
    for data in @program_switch
      data[4] -= 1
      next @program_switch.delete(data) if data[1] > 0 && !$game_switches[data[1]]
      next @program_switch.delete(data) if data[1] < 0 && !@switches[data[1].abs]
      next if data[4] != 0
      for id in data[2]
        $game_switches[id] = true if id > 0
        @switches[id.abs] = true  if id < 0
      end
      for id in data[3]
        $game_switches[id] = false if id > 0
        @switches[id.abs] = false  if id < 0
      end
      @program_switch.delete(data)
      program_check
    end  
  end
  #--------------------------------------------------------------------------
  # ● バトルプログラム BGM/BGSの開始
  #--------------------------------------------------------------------------
  def start_sound(data)
    @program_sound.push(data)
    name = data[5]
    case data[2]
    when "se"
      Audio.se_play("Audio/SE/" + name, data[4], data[3])
    when "bgm"
      name = RPG::BGM.last.name if data[5] == ""
      Audio.bgm_play("Audio/BGM/" + name, data[4], data[3])
    when "bgs"
      name = RPG::BGS.last.name if data[5] == ""
      Audio.bgs_play("Audio/BGS/" + name, data[4], data[3])
    end
  end
  #--------------------------------------------------------------------------
  # ● バトルプログラム 周期SEの開始
  #--------------------------------------------------------------------------
  def start_program_se(data)
    data[3] = [data[2], data[3]]
    data[2] = data[3][0] + rand(data[3][1] + 1)
    @program_se.push(data)
    Audio.se_play("Audio/SE/" + data[7], data[5], data[4]) if data[6]
  end
  #--------------------------------------------------------------------------
  # ● 周期SEの更新
  #--------------------------------------------------------------------------
  def update_program_se
    for data in @program_se
      data[2] -= 1
      next @program_se.delete(data) if data[1] > 0 && !$game_switches[data[1]]
      next @program_se.delete(data) if data[1] < 0 && !@switches[data[1].abs]
      next if data[2] != 0
      Audio.se_play("Audio/SE/" + data[7], data[5], data[4])
      data[2] = data[3][0] + rand(data[3][1] + 1)
    end  
  end
  #--------------------------------------------------------------------------
  # ● バトルプログラム 周期シェイクの開始
  #--------------------------------------------------------------------------
  def start_program_shake(data)
    data[3] = [data[2], data[3]]
    data[2] = data[3][0] + rand(data[3][1] + 1)
    @program_shake.push(data)
    shake(data[4], data[5], data[6]) if data[7]
  end
  #--------------------------------------------------------------------------
  # ● 周期シェイクの更新
  #--------------------------------------------------------------------------
  def update_program_shake
    for data in @program_shake
      data[2] -= 1
      next @program_shake.delete(data) if data[1] > 0 && !$game_switches[data[1]]
      next @program_shake.delete(data) if data[1] < 0 && !@switches[data[1].abs]
      next if data[2] != 0
      shake(data[4], data[5], data[6])
      data[2] = data[3][0] + rand(data[3][1] + 1)
    end  
  end
  #--------------------------------------------------------------------------
  # ● バトルプログラム 周期色調変更の開始
  #--------------------------------------------------------------------------
  def start_program_color(data)
    data[3] = [data[2], data[3]]
    data[2] = data[3][0] + rand(data[3][1] + 1)
    data[7] = true if data[4] == 0 or data[4] == 4
    case data[4]
    when 1   ;data[4] = $game_troop.members
    when 2   ;data[4] = $game_party.battle_members
    when 3,4 ;data[4] = $game_troop.members + $game_party.battle_members
    else ;data[4] = []
    end
    @program_color.push(data)
    return if !data[6]
    for target in data[4] do target.sv.color_set = data[5] end if data[4] != []
    @color_set[1] = data[5] if data[7]
    @color_set[2] = data[5] if data[7]
  end
  #--------------------------------------------------------------------------
  # ● 周期色調変更の更新
  #--------------------------------------------------------------------------
  def update_program_color
    for data in @program_color
      data[2] -= 1
      next @program_color.delete(data) if data[1] > 0 && !$game_switches[data[1]]
      next @program_color.delete(data) if data[1] < 0 && !@switches[data[1].abs]
      next if data[2] != 0
      for target in data[4] do target.sv.color_set = data[5] end if data[4] != []
      @color_set[1] = data[5] if data[7]
      @color_set[2] = data[5] if data[7]
      data[2] = data[3][0] + rand(data[3][1] + 1)
    end
  end
  #--------------------------------------------------------------------------
  # ● トランジション実行
  #--------------------------------------------------------------------------
  def perform_transition(data)
    Graphics.transition(data[2], "Graphics/Pictures/" + data[3], data[1])
  end  
  #--------------------------------------------------------------------------
  # ● 背景からカメラの限界値を取得  data = [max_top, max_bottom, max_left, max_right]
  #--------------------------------------------------------------------------
  def setting(index, data)
    @max_data[index - 1] = data
    return if index != 2
    setup
    # カメラの中心座標
    @center_x     = (Graphics.width / 2 + N03::CAMERA_POSITION[0]) * 100
    @center_y     = (Graphics.height / 2 + N03::CAMERA_POSITION[1]) * 100
    # 上下左右の移動限界距離
    @max_top    = [@max_data[0][5], @max_data[1][5]].min * -1
    @max_bottom = [@max_data[0][1], @max_data[1][1]].min + @max_top
    @max_left   = [@max_data[0][4], @max_data[1][4]].min  * -1
    @max_right  = [@max_data[0][3], @max_data[1][3]].min + @max_left
    exist_data = @max_data[0] if !@max_data[1][6]
    exist_data = @max_data[1] if !@max_data[0][6]
    @max_top    = exist_data[5] * -1        if exist_data != nil
    @max_bottom = exist_data[1] + @max_top  if exist_data != nil
    @max_left   = exist_data[4] * -1        if exist_data != nil
    @max_right  = exist_data[3] + @max_left if exist_data != nil
    @max_top = @max_bottom = @max_left = @max_right = 0 if !@max_data[1][6] && !@max_data[0][6]
    @max_width    = @max_right - @max_left + Graphics.width
    @max_height   = @max_bottom - @max_top + Graphics.height
    # ズームアウト限界値
    max_zoom_x    = 100 * Graphics.width / @max_width
    max_zoom_y    = 100 * Graphics.height / @max_height
    @max_zoom_out = [max_zoom_x, max_zoom_y].max
  end
  #--------------------------------------------------------------------------
  # ● カメラ移動
  #--------------------------------------------------------------------------
  def move(target_x, target_y, zoom, time, screen = true)
    # 戦闘背景以上のサイズまでズームアウトしないよう調整
    @target_zoom = [zoom * 0.01, @max_zoom_out * 0.01].max
    target_x *= -1 if screen && @mirror
    # ズーム分の中心座標補正
    if screen && @target_zoom != 1
      target_x = target_x + @center_x
      target_y = target_y + @center_y
    end
    adjust_x = @center_x * (@target_zoom - 1) / (@target_zoom ** 2 - @target_zoom)
    adjust_y = @center_y * (@target_zoom - 1) / (@target_zoom ** 2 - @target_zoom)
    adjust_x = 0 if adjust_x.nan?
    adjust_y = 0 if adjust_y.nan?
    adjust_x = @center_x if !screen && adjust_x == 0
    adjust_y = @center_y if !screen && adjust_y == 0
    @target_x = target_x - adjust_x.to_i
    @target_y = target_y - adjust_y.to_i
    @target_zoom = (@target_zoom * 1000).to_i
    @zoom = @zoom.to_i
    limit_test
    # 時間0の場合は即実行
    return @time = time.abs if time != 0
    @time = 1
    update
  end
  #--------------------------------------------------------------------------
  # ● 限界座標の試算
  #--------------------------------------------------------------------------
  def limit_test
    new_width = @max_width * @target_zoom / 1000
    new_height = @max_height * @target_zoom / 1000
    new_max_right = @max_right - (@max_width - new_width)
    new_max_bottom = @max_bottom - (@max_height - new_height)
    # 画面の移動先が限界の場合、限界座標をセット
    if @target_x < @max_left * 100
      @target_x = @max_left * 100
    end
    if @target_x > new_max_right * 100
      @target_x = new_max_right * 100
    end
    if @target_y < @max_top * 100
      @target_y = @max_top * 100
    end
    if @target_y > new_max_bottom * 100
      @target_y = new_max_bottom * 100
    end
  end
  #--------------------------------------------------------------------------
  # ● 画面のシェイク
  #--------------------------------------------------------------------------
  def shake(power, speed, time)
    @shake_x = power[0] * 100
    @shake_y = power[1] * 100
    @power_time_base = @power_time = speed
    @shake_time = time
    update_shake
  end
  #--------------------------------------------------------------------------
  # ● シェイクの更新
  #--------------------------------------------------------------------------
  def update_shake
    @sx = (@sx * (@power_time - 1) + @shake_x) / @power_time
    @sy = (@sy * (@power_time - 1) + @shake_y) / @power_time
    @power_time -= 1
    @shake_time -= 1
    return @sx = @sy = 0 if @shake_time == 0
    return if @power_time != 0
    @power_time = @power_time_base
    @shake_x = @shake_x * -4 / 5
    @shake_y = @shake_y * -4 / 5
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    update_shake if @shake_time != 0
    update_program
    return if @time == 0
    @x = (@x * (@time - 1) + @target_x) / @time
    @y = (@y * (@time - 1) + @target_y) / @time
    @zoom = (@zoom * (@time - 1) + @target_zoom) / @time
    @time -= 1
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update_program
    update_program_switch if @program_switch != []
    update_program_se     if @program_se != []
    update_program_shake  if @program_shake != []
    update_program_color  if @program_color != []
  end
end

#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  バトル画面の処理を行うクラスです。
#==============================================================================
class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● フレーム更新(基本)
  #--------------------------------------------------------------------------
  alias update_basic_scene_battle_n03 update_basic
  def update_basic
    update_basic_scene_battle_n03
    $sv_camera.update
    $sv_camera.wait = N03::TURN_END_WAIT + 1 if $sv_camera.win_wait
    camera_wait
  end
  #--------------------------------------------------------------------------
  # ● カメラウェイト
  #--------------------------------------------------------------------------
  def camera_wait
    process_event if $sv_camera.event
    $sv_camera.event = false if $sv_camera.event
    while $sv_camera.wait != 0
      Graphics.update
      Input.update
      update_all_windows
      $game_timer.update
      $game_troop.update
      $sv_camera.update
      @spriteset.update
      update_info_viewport
      update_message_open
      $sv_camera.wait -= 1 if $sv_camera.wait > 0
      $sv_camera.wait = 1 if $sv_camera.wait == 0 && @spriteset.effect?
      BattleManager.victory if $sv_camera.win_wait && $sv_camera.wait == 0
    end
  end
  #--------------------------------------------------------------------------
  # ● カメラウェイトのセット
  #--------------------------------------------------------------------------
  def set_camera_wait(time)
    $sv_camera.wait = time
    camera_wait
  end  
  #--------------------------------------------------------------------------
  # ● エフェクト実行が終わるまでウェイト ★再定義
  #--------------------------------------------------------------------------
  def wait_for_effect
  end
  #--------------------------------------------------------------------------
  # ● ターン開始
  #--------------------------------------------------------------------------
  alias turn_start_scene_battle_n03 turn_start
  def turn_start
    turn_start_scene_battle_n03
    N03.camera(nil, N03::BATTLE_CAMERA["回合后镜头"].dup)
  end
  #--------------------------------------------------------------------------
  # ● ターン終了
  #--------------------------------------------------------------------------
  alias turn_end_scene_battle_n03 turn_end
  def turn_end
    turn_end_scene_battle_n03
    for member in $game_troop.members + $game_party.members
      N03.set_damage(member, member.sv.result_damage[0],member.sv.result_damage[1])
      member.sv.result_damage = [0,0]
      @spriteset.set_damage_pop(member) if member.result.hp_damage != 0 or member.result.mp_damage != 0
    end
    set_camera_wait(N03::TURN_END_WAIT)
    N03.camera(nil, N03::BATTLE_CAMERA["回合前镜头"].dup) if $game_party.inputable?
    @log_window.clear
  end
  #--------------------------------------------------------------------------
  # ● スキル/アイテムの使用 ★再定義
  #--------------------------------------------------------------------------
  def use_item
    item = @subject.current_action.item
    display_item(item)
    @subject.use_item(item)
    refresh_status
    @targets = @subject.current_action.make_targets.compact
    @targets = [@subject] if @targets.size == 0
    set_substitute(item)
    for time in item.repeats.times do play_sideview(@targets, item) end
    end_reaction(item)
    display_end_item
  end
  #--------------------------------------------------------------------------
  # ● スキル/アイテム名の表示
  #--------------------------------------------------------------------------
  def display_item(item)
    return @log_window.display_use_item(@subject, item) if N03::BATTLE_LOG
    @log_window.off
    @skill_name_window = Window_Skill_name.new(item.name) unless N03::NO_DISPLAY_SKILL_ID.include?(item.id) && item.is_a?(RPG::Skill)
  end  
  #--------------------------------------------------------------------------
  # ● スキル/アイテム名の表示終了
  #--------------------------------------------------------------------------
  def display_end_item
    @skill_name_window.dispose if @skill_name_window != nil
    @skill_name_window = nil
    set_camera_wait(N03::ACTION_END_WAIT) if @subject.sv.derivation_skill_id == 0
    @log_window.clear if N03::BATTLE_LOG
  end  
  #--------------------------------------------------------------------------
  # ● 反撃/魔法反射/身代わり処理
  #--------------------------------------------------------------------------
  def end_reaction(item)
    end_substitute if @substitute != nil
    set_reflection(item) if @reflection_data != nil
    set_counter_attack if @counter_attacker != nil
  end  
  #--------------------------------------------------------------------------
  # ● 反撃の発動 ★再定義
  #--------------------------------------------------------------------------
  def invoke_counter_attack(target, item)
    return if @subject.sv.counter_id != 0
    @counter_attacker = [] if @counter_attacker == nil
    return apply_item_effects(apply_substitute(target, item), item) if !target.movable?
    @log_window.add_text(sprintf(Vocab::CounterAttack, target.name)) if N03::BATTLE_LOG
    target.sv.counter_id = target.sv.counter_skill_id
    @counter_attacker.push(target)
  end
  #--------------------------------------------------------------------------
  # ● 魔法反射の発動 ★再定義
  #--------------------------------------------------------------------------
  def invoke_magic_reflection(target, item)
    return if @subject.sv.reflection_id != 0
    @log_window.add_text(sprintf(Vocab::MagicReflection, target.name)) if N03::BATTLE_LOG
    target.sv.reflection_id = target.sv.reflection_anime_id
  end
  #--------------------------------------------------------------------------
  # ● 身代わりの適用 ★再定義
  #--------------------------------------------------------------------------
  def apply_substitute(target, item)
    return target if @substitute == nil
    return target if !check_substitute(target, item)
    return @substitute
  end
  #--------------------------------------------------------------------------
  # ● 身代わりセット
  #--------------------------------------------------------------------------
  def set_substitute(item)
    @substitute = N03.get_enemy_unit(@subject).substitute_battler
    return if @substitute == nil
    s_targets = []
    for i in [email protected]
      next if @targets == @substitute
      next if !check_substitute(@targets, item)
      @log_window.add_text(sprintf(Vocab::Substitute, @substitute.name, @targets.name))
      @targets.sv.start_action(@targets.sv.substitute_receiver_start_action)
      s_targets.push(@targets)
      @targets = @substitute
    end
    return @substitute = nil if s_targets == []
    @substitute.sv.set_target(s_targets)
    @substitute.sv.start_action(@substitute.sv.substitute_start_action)
  end  
  #--------------------------------------------------------------------------
  # ● 身代わり終了
  #--------------------------------------------------------------------------
  def end_substitute
    for member in @substitute.sv.target_battler
      member.sv.start_action(member.sv.substitute_receiver_end_action)
    end  
    @substitute.sv.start_action(@substitute.sv.substitute_end_action)
    @substitute = nil
  end
  #--------------------------------------------------------------------------
  # ● 反撃
  #--------------------------------------------------------------------------
  def set_counter_attack
    pre_subject = @subject
    for attacker in @counter_attacker
      @subject = attacker
      item = $data_skills[attacker.sv.counter_skill_id]
      play_sideview([pre_subject], item)
    end
    # 同一カウンター者を考慮してカウンターIDの初期化はアクション後に実行
    for attacker in @counter_attacker do attacker.sv.counter_id = 0 end
    @subject = pre_subject
    @counter_attacker = nil
  end
  #--------------------------------------------------------------------------
  # ● 魔法反射
  #--------------------------------------------------------------------------
  def set_reflection(item)
    @log_window.back_to(1)
    for data in @reflection_data
      @subject.sv.damage_action(@subject, item)
      N03.set_damage_anime_data([@subject], @subject, data)
      apply_item_effects(@subject, item)
      @spriteset.set_damage_pop(@subject)
    end
    set_camera_wait(N03.get_anime_time(@reflection_data[0][0]))
    @reflection_data = nil
  end
  #--------------------------------------------------------------------------
  # ● サイドビューアクション実行
  #--------------------------------------------------------------------------
  def play_sideview(targets, item)
    @subject.sv.set_target(targets)
    return if @subject.sv.attack_action(item) == nil
    return if [email protected]?
    return if item.scope != 9 && item.scope != 10 && !N03.targets_alive?(targets)
    @subject.sv.start_action(@subject.sv.attack_action(item))
    @subject.sv.unshift_action(@subject.sv.flash_action) if @subject.flash_flg
    @subject.sv.active = true
    @subject.sv.command_action = false
    loop do
      update_basic
      data = @subject.sv.play_data
      @targets = N03.s_targets(@subject) if data[0] == "second_targets_set"
      N03.targets_set(@subject)          if data[0] == "targets_set"
      @immortal = N03.immortaling        if data[0] == "no_collapse" && !N03.dead_attack?(@subject, item)
      @immortal = N03.unimmortaling      if data[0] == "collapse"
      next set_move_anime(item)          if @subject.sv.m_a_data != []
      set_damage(item)                   if @subject.sv.set_damage
      break N03.derived_skill(@subject)  if @subject.sv.derivation_skill_id != 0
      break                              if @subject.sv.action_end or @subject.hidden?
    end
    @immortal = N03.unimmortaling        if @immortal
  end
  #--------------------------------------------------------------------------
  # ● ダメージの実行
  #--------------------------------------------------------------------------
  def set_damage(item)
    targets = @targets
    targets = [@subject.sv.individual_targets[0]] if @subject.sv.individual_targets.size != 0
    for target in targets do damage_anime(targets.dup, target, item) end
    @subject.sv.set_damage = false
    @subject.sv.damage_anime_data = []
  end
  #--------------------------------------------------------------------------
  # ● ダメージ戦闘アニメ処理
  #--------------------------------------------------------------------------
  def damage_anime(targets, target, item)
    @log_window.back_to(1) if @log_window.line_number == 5
    return if item.scope != 9 && item.scope != 10 && target.dead?
    @miss = false
    invoke_item(target,item)
    if target.result.missed
      target.sv.miss_action(@subject, item)
      return @miss = true
    elsif target.result.evaded or target.sv.counter_id != 0
      target.sv.evasion_action(@subject, item)
      return @miss = true
    elsif target.sv.reflection_id != 0
      N03.set_damage_anime_data(targets, target, [target.sv.reflection_id, false, false, true])
      target.sv.reflection_id = 0
      @reflection_data = [] if @reflection_data == nil
      return @reflection_data.push([N03.get_attack_anime_id(-3, @subject), false, false, true])
    end
    target.sv.damage_action(@subject, item)
    N03.set_damage(@subject, -target.result.hp_drain, -target.result.mp_drain) if target != @subject
    @spriteset.set_damage_pop(target)
    @spriteset.set_damage_pop(@subject) if target != @subject && @subject.result.hp_damage != 0 #or @subject.result.mp_damage != 0
    N03.set_damage_anime_data(targets, target, @subject.sv.damage_anime_data) if @subject.sv.damage_anime_data != []
  end
  #--------------------------------------------------------------------------
  # ● 飛ばしアニメ処理
  #--------------------------------------------------------------------------
  def set_move_anime(item)
    for data in @subject.sv.m_a_data
      @subject.sv.damage_anime_data = data[4]
      hit_targets = []
      for target in data[1]
        damage_anime(data[1], target, item) if data[0]
        hit_targets.push(target) if !@miss
      end
      @miss = false if !data[3]
      @spriteset.set_hit_animation(@subject, data[2], hit_targets, @miss)
    end
    @subject.sv.set_damage = false
    @subject.sv.m_a_data = []
  end
end

#==============================================================================
# ■ DataManager
#------------------------------------------------------------------------------
#  データベースとゲームオブジェクトを管理するモジュールです。
#==============================================================================
module DataManager
  #--------------------------------------------------------------------------
  # ● 各種ゲームオブジェクトの作成 ★再定義
  #--------------------------------------------------------------------------
  def self.create_game_objects
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_timer         = Game_Timer.new
    $game_message       = Game_Message.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
    $sv_camera          = Battle_Camera.new
  end
end

#==============================================================================
# ■ BattleManager
#------------------------------------------------------------------------------
#  戦闘の進行を管理するモジュールです。
#==============================================================================
module BattleManager
  #--------------------------------------------------------------------------
  # ● エンカウント時の処理 ★再定義
  #--------------------------------------------------------------------------
  def self.on_encounter
    @preemptive = (rand < rate_preemptive)
    @surprise = (rand < rate_surprise && !@preemptive)
    $sv_camera.mirror = @surprise if N03::BACK_ATTACK
  end
  #--------------------------------------------------------------------------
  # ● 勝利の処理 ★再定義
  #--------------------------------------------------------------------------
  def self.process_victory
    $sv_camera.win_wait = true
  end  
  #--------------------------------------------------------------------------
  # ● 勝利
  #--------------------------------------------------------------------------
  def self.victory
    $sv_camera.win_wait = false
    N03.camera(nil, N03::BATTLE_CAMERA["战斗结束镜头"].dup)
    for member in $game_party.members do member.sv.start_action(member.sv.win) if member.movable? end
    play_battle_end_me
    replay_bgm_and_bgs
    $game_message.add(sprintf(Vocab::Victory, $game_party.name))
    display_exp
    gain_gold
    gain_drop_items
    gain_exp
    SceneManager.return
    battle_end(0)
    return true
  end
  #--------------------------------------------------------------------------
  # ● 逃走の処理 ★再定義
  #--------------------------------------------------------------------------
  def self.process_escape
    $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
    success = @preemptive ? true : (rand < @escape_ratio)
    Sound.play_escape
    if success
      process_abort
      for member in $game_party.members do member.sv.start_action(member.sv.escape) if member.movable? end
    else
      @escape_ratio += 0.1
      $game_message.add('\.' + Vocab::EscapeFailure)
      $game_party.clear_actions
      for member in $game_party.members do member.sv.start_action(member.sv.escape_ng) if member.movable? end
    end
    wait_for_message
    return success
  end
  #--------------------------------------------------------------------------
  # ● 次のコマンド入力へ ★再定義
  #--------------------------------------------------------------------------
  def self.next_command
    begin
      if !actor || !actor.next_command
        $game_party.battle_members[@actor_index].sv.command_action = true
        @actor_index += 1
        if @actor_index >= $game_party.members.size
          for member in $game_party.battle_members.reverse
            break member.sv.start_action(member.sv.command_a) if member.inputable?
          end
          return false
        end
      end
    end until actor.inputable?
    actor.sv.start_action(actor.sv.command_b) if actor != nil && actor.inputable?
    if pre_actor
      pre_actor.sv.start_action(pre_actor.sv.command_a) if pre_actor != nil && pre_actor.inputable?
    end
    return true
  end
  #--------------------------------------------------------------------------
  # ● 前のコマンド入力へ ★再定義
  #--------------------------------------------------------------------------
  def self.prior_command
    begin
      if !actor || !actor.prior_command
        $game_party.battle_members[@actor_index].sv.command_action = false
        @actor_index -= 1
        if @actor_index < 0
          for member in $game_party.battle_members
            break member.sv.start_action(member.sv.command_a) if member.inputable?
          end
          return false
        end
      end
    end until actor.inputable?
    actor.make_actions if actor.inputable?
    actor.sv.start_action(actor.sv.command_b) if actor.inputable?
    after_actor.sv.start_action(after_actor.sv.command_a) if after_actor != nil && after_actor.inputable?
    return true
  end
  #--------------------------------------------------------------------------
  # ● コマンド入力前のアクターを取得
  #--------------------------------------------------------------------------
  def self.pre_actor
    return if @actor_index == 0
    $game_party.members[@actor_index - 1]
  end
  #--------------------------------------------------------------------------
  # ● コマンド入力後のアクターを取得
  #--------------------------------------------------------------------------
  def self.after_actor
    $game_party.members[@actor_index + 1]
  end
  #--------------------------------------------------------------------------
  # ● 戦闘行動者を前に追加
  #--------------------------------------------------------------------------
  def self.unshift_action_battlers(battler)
    @action_battlers.unshift(battler)
  end
end  

#==============================================================================
# ■ Game_Battler
#------------------------------------------------------------------------------
#  スプライトや行動に関するメソッドを追加したバトラーのクラスです。
#==============================================================================
class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
    attr_reader   :sv                     # サイドビューデータ
  attr_accessor :flash_flg              # 閃きフラグ
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias initialize_game_battler_n03 initialize
  def initialize
    initialize_game_battler_n03
    @sv = SideView.new(self)
  end
  #--------------------------------------------------------------------------
  # ● 現在の戦闘行動を除去
  #--------------------------------------------------------------------------
  alias remove_current_action_game_battler_n03 remove_current_action
  def remove_current_action
    return @sv.derivation_skill_id = 0 if @sv.derivation_skill_id != 0
    remove_current_action_game_battler_n03
  end
  #--------------------------------------------------------------------------
  # ● ターン終了処理
  #--------------------------------------------------------------------------
  alias on_turn_end_game_battler_n03 on_turn_end
  def on_turn_end
    on_turn_end_game_battler_n03
    @sv.add_state = []
    @sv.result_damage = [@result.hp_damage, @result.mp_damage]
  end
  #--------------------------------------------------------------------------
  # ● パラメータ条件比較 data = [種別, 数値, 判別]
  #--------------------------------------------------------------------------
  def comparison_parameter(data)
    return true if data[0][0] == 0
    kind = data[0]
    num = data[1]
    select = data[2]
    case kind
    when  1 ; par = level
    when  2 ; par = mhp
    when  3 ; par = mmp
    when  4 ; par = hp
    when  5 ; par = mp
    when  6 ; par = tp
    when  7 ; par = atk
    when  8 ; par = self.def
    when  9 ; par = mat
    when 10 ; par = mdf
    when 11 ; par = agi
    when 12 ; par = luk
    end
    if num < 0
      case kind
      when  4 ; num = mhp * num / 100
      when  5 ; num = mmp * num / 100
      when  6 ; num = max_tp * num / 100
      end
      num = num.abs
    end  
    case select
    when  0 ; return par == num
    when  1 ; return par < num
    when  2 ; return par > num
    end
  end
  #--------------------------------------------------------------------------
  # ● 装備条件比較 data = [装備種別, タイプID]
  #--------------------------------------------------------------------------
  def comparison_equip(data)
    kind = data[0]
    items = weapons if kind == 0
    items = armors  if kind == 1
    for item in items
      for id in data[1]
        return true if id > 0 && item.is_a?(RPG::Weapon) && item == $data_weapons[id.abs]
        return true if id > 0 && item.is_a?(RPG::Armor) && item == $data_armors[id.abs]
        return true if id < 0 && item.is_a?(RPG::Weapon) && item.wtype_id == id.abs
        return true if id < 0 && item.is_a?(RPG::Armor) && item.stype_id == id.abs
      end
    end
    return false
  end
  
end  
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  アクターを扱うクラスです。
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader :actor_id                    # ID
  #--------------------------------------------------------------------------
  # ● ID
  #--------------------------------------------------------------------------
  def id
    return @actor_id
  end
  #--------------------------------------------------------------------------
  # ● スプライトを使うか? ★再定義
  #--------------------------------------------------------------------------
  def use_sprite?
    return true
  end
  #--------------------------------------------------------------------------
  # ● ダメージ効果の実行 ★再定義
  #--------------------------------------------------------------------------
  def perform_damage_effect
    return if !N03::ACTOR_DAMAGE
    $game_troop.screen.start_shake(5, 5, 10)
    @sprite_effect_type = :blink
    Sound.play_actor_damage
  end
  
end

#==============================================================================
# ■ Game_Enemy
#------------------------------------------------------------------------------
#  敵キャラを扱うクラスです。
#==============================================================================
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader :enemy_id                    # ID
  #--------------------------------------------------------------------------
  # ● ID
  #--------------------------------------------------------------------------
  def id
    return @enemy_id
  end
  #--------------------------------------------------------------------------
  # ● レベル
  #--------------------------------------------------------------------------
  def level
    return @sv.level
  end
  #--------------------------------------------------------------------------
  # ● ダメージ効果の実行 ★再定義
  #--------------------------------------------------------------------------
  def perform_damage_effect
    return if !N03::ENEMY_DAMAGE
    @sprite_effect_type = :blink
    Sound.play_enemy_damage
  end
  #--------------------------------------------------------------------------
  # ● 武器
  #--------------------------------------------------------------------------
  def weapons
    weapon1 = $data_weapons[@sv.enemy_weapon1_id]
    weapon2 = $data_weapons[@sv.enemy_weapon2_id]
    return [weapon1, weapon2]
  end
  #--------------------------------------------------------------------------
  # ● 防具
  #--------------------------------------------------------------------------
  def armors
    return [$data_armors[@sv.enemy_shield_id]]
  end
  #--------------------------------------------------------------------------
  # ● 二刀流の判定
  #--------------------------------------------------------------------------
  def dual_wield?
    return $data_weapons[@sv.enemy_weapon2_id] != nil
  end
  #--------------------------------------------------------------------------
  # ● バトラー画像変更
  #--------------------------------------------------------------------------
  def graphics_change(battler_name)
    @battler_name = battler_name
  end
  #--------------------------------------------------------------------------
  # ● 通常攻撃 アニメーション ID の取得
  #--------------------------------------------------------------------------
  def atk_animation_id1
    return weapons[0].animation_id if weapons[0]
    return weapons[1] ? 0 : 1
  end
  #--------------------------------------------------------------------------
  # ● 通常攻撃 アニメーション ID の取得(二刀流:武器2)
  #--------------------------------------------------------------------------
  def atk_animation_id2
    return weapons[1] ? weapons[1].animation_id : 0
  end
end

#==============================================================================
# ■ Sprite_Base
#------------------------------------------------------------------------------
#  アニメーションの表示処理を追加したスプライトのクラスです。
#==============================================================================
class Sprite_Base < Sprite
  #--------------------------------------------------------------------------
  # ● アニメーションの座標更新 (ホーミングあり)
  #--------------------------------------------------------------------------
  def update_animation_position_horming
    return if @action_end_cancel
    ani_ox_set if @horming
    camera_zoom = $sv_camera.zoom
    camera_zoom = 1 if @move_anime
    kind = 1
    kind = -1 if @ani_mirror && !@anime_no_mirror
    cell_data = @animation.frames[@animation.frame_max - (@ani_duration + @ani_rate - 1) / @ani_rate].cell_data
    for i in 0..15
      @ani_sprites.x = (@ani_ox + cell_data[i, 1] * kind - $sv_camera.x) * camera_zoom if @ani_sprites != nil && cell_data[i, 1] != nil
      @ani_sprites.y = (@ani_oy + cell_data[i, 2] - $sv_camera.y) * camera_zoom if @ani_sprites != nil && cell_data[i, 2] != nil
    end
  end
  #--------------------------------------------------------------------------
  # ● アニメーション元の座標をセット
  #--------------------------------------------------------------------------
  def ani_ox_set
    if !SceneManager.scene_is?(Scene_Battle)
      @real_x = x
      @real_y = y
    end
    @ani_ox = @real_x - ox + width / 2
    @ani_oy = @real_y - oy + height / 2
    @ani_oy -= height / 2 if @animation.position == 0
    @ani_oy += height / 2 if @animation.position == 2
  end
  #--------------------------------------------------------------------------
  # ● アニメーションの更新
  #--------------------------------------------------------------------------
  alias update_animation_sprite_base_n03 update_animation
  def update_animation
    update_animation_position_horming if animation? && SceneManager.scene_is?(Scene_Battle) && @animation.position != 3
    update_animation_sprite_base_n03
  end
  #--------------------------------------------------------------------------
  # ● アニメーションの原点設定 ★再定義
  #--------------------------------------------------------------------------
  def set_animation_origin
    return ani_ox_set if @animation.position != 3
    if viewport == nil
      @ani_ox = Graphics.width / 2
      @ani_oy = Graphics.height / 2
    else
      @ani_ox = viewport.rect.width / 2
      @ani_oy = viewport.rect.height / 2
    end
  end
  #--------------------------------------------------------------------------
  # ● アニメーションスプライトの設定 ★再定義
  #--------------------------------------------------------------------------
  def animation_set_sprites(frame)
    camera_zoom = 1
    camera_zoom = $sv_camera.zoom if @anime_camera_zoom && @animation.position != 3 && SceneManager.scene_is?(Scene_Battle)
    camera_x = $sv_camera.x
    camera_y = $sv_camera.y
    camera_x = camera_y = 0 if @animation.position == 3 or !SceneManager.scene_is?(Scene_Battle)
    plus_z = 5
    plus_z = 1000 if @animation.position == 3
    plus_z = -17 if @plus_z != nil && @plus_z == false
    plus_z = -self.z + 10 if @plus_z != nil && @plus_z == false && @animation.position == 3
    cell_data = frame.cell_data
    @ani_sprites.each_with_index do |sprite, i|
      next unless sprite
      pattern = cell_data[i, 0]
      if !pattern || pattern < 0
        sprite.visible = false
        next
      end
      sprite.bitmap = pattern < 100 ? @ani_bitmap1 : @ani_bitmap2
      sprite.visible = true
      sprite.src_rect.set(pattern % 5 * 192,
        pattern % 100 / 5 * 192, 192, 192)
      if @ani_mirror && !@anime_no_mirror
        sprite.x = (@ani_ox - cell_data[i, 1] - camera_x) * camera_zoom
        sprite.y = (@ani_oy + cell_data[i, 2] - camera_y) * camera_zoom
        sprite.angle = (360 - cell_data[i, 4])
        sprite.mirror = (cell_data[i, 5] == 0)
      else
        sprite.x = (@ani_ox + cell_data[i, 1] - camera_x) * camera_zoom
        sprite.y = (@ani_oy + cell_data[i, 2] - camera_y) * camera_zoom
        sprite.angle = cell_data[i, 4]
        sprite.mirror = (cell_data[i, 5] == 1)
      end
      sprite.z = self.z + plus_z + i
      sprite.ox = 96
      sprite.oy = 96
      sprite.zoom_x = cell_data[i, 3] * camera_zoom / 100.0
      sprite.zoom_y = cell_data[i, 3] * camera_zoom/ 100.0
      sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
      sprite.blend_type = cell_data[i, 7]
    end
  end
  #--------------------------------------------------------------------------
  # ● 子スプライトフラグ
  #--------------------------------------------------------------------------
  def set(battler, horming, camera_zoom, no_mirror)
    @battler = battler
    @next = true
    self.bitmap = Bitmap.new(@battler.sv.cw, @battler.sv.ch)
    self.ox = bitmap.width / 2
    self.oy = bitmap.height
    @horming = horming
    @anime_camera_zoom = camera_zoom
    @anime_no_mirror = no_mirror
    @battler.sv.reset_anime_data
  end  
  #--------------------------------------------------------------------------
  # ● 子スプライト座標セット
  #--------------------------------------------------------------------------
  def set_position(z, zoom_x, zoom_y, real_x, real_y)
    self.z = z
    self.zoom_x = zoom_x
    self.zoom_y = zoom_y
    @real_x = real_x
    @real_y = real_y
  end
  #--------------------------------------------------------------------------
  # ● 他スプライトへのタイミング処理
  #--------------------------------------------------------------------------
  def other_process_timing(timing)
    se_flag = true
    se_flag = @se_flag if @se_flag != nil
    @battler.sv.timing.push([se_flag, timing.dup])
  end
  #--------------------------------------------------------------------------
  # ● 他バトラーへのタイミング処理
  #--------------------------------------------------------------------------
  def target_battler_process_timing(timing)
    for target in @timing_targets
      target.sv.timing.push([false, timing.dup])
    end  
  end
  #--------------------------------------------------------------------------
  # ● SE とフラッシュのタイミング処理
  #--------------------------------------------------------------------------
  alias animation_process_timing_sprite_base_n03 animation_process_timing
  def animation_process_timing(timing)
    target_battler_process_timing(timing) if @timing_targets && @timing_targets != []
    return other_process_timing(timing) if @next != nil
    animation_process_timing_sprite_base_n03(timing)
  end
  #--------------------------------------------------------------------------
  # ● アニメーションの解放
  #--------------------------------------------------------------------------
  alias dispose_animation_sprite_base_n03 dispose_animation
  def dispose_animation
    dispose_animation_sprite_base_n03
  end
end


#==============================================================================
# ■ Sprite_Battler
#------------------------------------------------------------------------------
#  バトラー表示用のスプライトです。
#==============================================================================
class Sprite_Battler < Sprite_Base
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数 
  #--------------------------------------------------------------------------
  attr_accessor   :removing             # パーティ離脱中
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias initialize_sprite_battler_n03 initialize
  def initialize(viewport, battler = nil)
    initialize_sprite_battler_n03(viewport, battler)
    @real_x = @real_y = 0
    update_bitmap if @battler != nil
  end
  #--------------------------------------------------------------------------
  # ● アニメーションの開始 ★再定義
  #--------------------------------------------------------------------------
  def start_animation(animation, mirror = false)
    return next_animation(animation, mirror) if animation?
    @animation = animation
    if @animation
      @horming = @battler.sv.anime_horming
      @anime_camera_zoom = @battler.sv.anime_camera_zoom
      @anime_no_mirror = @battler.sv.anime_no_mirror
      @timing_targets = @battler.sv.timing_targets
      @plus_z = @battler.sv.anime_plus_z
      @battler.sv.reset_anime_data
      @ani_mirror = mirror
      set_animation_rate
      @ani_duration = @animation.frame_max * @ani_rate + 1
      load_animation_bitmap
      make_animation_sprites
      set_animation_origin
    end
  end
  #--------------------------------------------------------------------------
  # ● 次のアニメを開始
  #--------------------------------------------------------------------------
  def next_animation(animation, mirror)
    @next_anime = [] if @next_anime == nil
    @next_anime.push(Sprite_Base.new(viewport))
    @next_anime[@next_anime.size - 1].set(battler, @battler.sv.anime_horming, @battler.sv.anime_camera_zoom, @battler.sv.anime_no_mirror)
    @next_anime[@next_anime.size - 1].set_position(self.z, self.zoom_x, self.zoom_y, @real_x, @real_y)
    @next_anime[@next_anime.size - 1].start_animation(animation, mirror)
  end
  #--------------------------------------------------------------------------
  # ● 影グラフィック作成
  #--------------------------------------------------------------------------
  def create_shadow
    reset_shadow
    return if @battler.sv.shadow == false
    @shadow = Sprite.new(viewport) if @shadow == nil
    @shadow.bitmap = Cache.character(@battler.sv.shadow)
    @shadow.ox = @shadow.bitmap.width / 2
    @shadow.oy = @shadow.bitmap.height / 2
  end
  #--------------------------------------------------------------------------
  # ● 影グラフィック初期化
  #--------------------------------------------------------------------------
  def reset_shadow
    return if @shadow == nil
    @shadow.dispose
    @shadow = nil
  end  
  #--------------------------------------------------------------------------
  # ● 転送元ビットマップの更新 ★再定義
  #--------------------------------------------------------------------------
  def update_bitmap
    update_bitmap_enemy if [email protected]?
    update_bitmap_actor if @battler.actor?
    update_src_rect if @battler != nil
    update_color if @battler != nil
  end
  #--------------------------------------------------------------------------
  # ● 転送元ビットマップ:エネミー
  #--------------------------------------------------------------------------
  def update_bitmap_enemy
    if @battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue
      @battler_name = @battler.battler_name
      @battler_hue = @battler.battler_hue
      @battler_graphic_file_index = @battler.sv.graphic_file_index
      @graphic_mirror_flag = @battler.sv.graphic_mirror_flag
      self.bitmap = Cache.battler(@battler_name + @battler_graphic_file_index, @battler_hue)
      @battler.sv.setup(self.bitmap.width, self.bitmap.height, @battler_id != @battler.id)
      create_shadow
      init_visibility
      @battler_id = @battler.id
    end
  end  
  #--------------------------------------------------------------------------
  # ● 転送元ビットマップ:アクター
  #--------------------------------------------------------------------------
  def update_bitmap_actor
    if @battler.character_name != @battler_name or @battler.character_index != @battler_index
      @battler_name = @battler.character_name
      @battler_index = @battler.character_index
      @battler_graphic_file_index = @battler.sv.graphic_file_index
      @graphic_mirror_flag = @battler.sv.graphic_mirror_flag
      self.bitmap = Cache.character(@battler_name + @battler_graphic_file_index)
      @battler.sv.setup(self.bitmap.width, self.bitmap.height, @battler_id != @battler.id)
      create_shadow
      init_visibility
      @battler_id = @battler.id
    end
  end
  #--------------------------------------------------------------------------
  # ● 可視状態の初期化 ★再定義
  #--------------------------------------------------------------------------
  def init_visibility
    @battler_visible = @battler.alive?
    @battler_visible = true if @battler.sv.state(1) != "敌人死亡"
    @battler_visible = false if @battler.hidden?
    @battler.sv.opacity = 0 unless @battler_visible
    self.opacity = 0 unless @battler_visible
    self.opacity = 255 if @battler_visible
    @battler.sv.weapon_visible = @battler_visible
  end
  #--------------------------------------------------------------------------
  # ● 転送元矩形の更新
  #--------------------------------------------------------------------------
  def update_src_rect
    return if @battler.sv.collapse
    if @battler_graphic_file_index != @battler.sv.graphic_file_index
      @battler_graphic_file_index = @battler.sv.graphic_file_index
      self.bitmap = Cache.character(@battler_name + @battler_graphic_file_index) if @battler.actor?
      self.bitmap = Cache.battler(@battler_name + @battler_graphic_file_index, @battler_hue) if [email protected]?
      @battler.sv.set_graphics(self.bitmap.width, self.bitmap.height)
    end
    anime_off if @battler.sv.anime_off
    self.src_rect.set(@battler.sv.sx, @battler.sv.sy, @battler.sv.cw, @battler.sv.ch)
    self.opacity = @battler.sv.opacity if @battler_visible
    set_process_timing(@battler.sv.timing) if @battler && @battler.sv.timing != []
  end
  #--------------------------------------------------------------------------
  # ● 位置の更新 ★再定義
  #--------------------------------------------------------------------------
  def update_position
    @real_x = @battler.sv.x / 100
    @real_y = (@battler.sv.y - @battler.sv.h - @battler.sv.j - @battler.sv.c - @battler.sv.oy_adjust)/ 100
    self.x = @real_x - $sv_camera.x
    self.y = @real_y - $sv_camera.y
    self.z = @battler.sv.z - @battler.sv.c / 100
    if @battler.sv.h <= 0
      self.x += $sv_camera.sx / 100
      self.y += $sv_camera.sy / 100
    end  
    self.x *= $sv_camera.zoom
    self.y *= $sv_camera.zoom
  end
  #--------------------------------------------------------------------------
  # ● 原点の更新 ★再定義
  #--------------------------------------------------------------------------
  def update_origin
    return if !bitmap or @battler.sv.collapse
    self.ox = @battler.sv.ox
    self.oy = @battler.sv.oy
    self.angle = @battler.sv.angle
    self.zoom_x = @battler.sv.zoom_x * $sv_camera.zoom
    self.zoom_y = @battler.sv.zoom_y * $sv_camera.zoom
    self.mirror = @battler.sv.mirror if !@graphic_mirror_flag
    self.mirror = [email protected] if @graphic_mirror_flag
  end
  #--------------------------------------------------------------------------
  # ● 影グラフィックの更新
  #--------------------------------------------------------------------------
  def update_shadow
    @shadow.visible = @battler.sv.shadow_visible
    @shadow.opacity = @battler.sv.opacity if @battler.sv.opacity_data[3]
    @shadow.opacity = self.opacity if [email protected]_data[3]
    @shadow.x = @real_x - $sv_camera.x
    @shadow.y = (@battler.sv.y - @battler.sv.c)/ 100 - $sv_camera.y
    @shadow.z = @battler.sv.z - 10
    @shadow.zoom_x = $sv_camera.zoom
    @shadow.zoom_y = $sv_camera.zoom
    @shadow.x += $sv_camera.sx / 100
    @shadow.y += $sv_camera.sy / 100
    @shadow.x *= $sv_camera.zoom
    @shadow.y *= $sv_camera.zoom
    @shadow.color.set(@color_data[0], @color_data[1], @color_data[2], @color_data[3]) if @color_data != nil
  end
  #--------------------------------------------------------------------------
  # ● ふきだしの更新
  #--------------------------------------------------------------------------
  def update_balloon
    if @battler.sv.balloon_data == [] && @balloon
      @balloon_data = []
      @balloon.dispose
      return @balloon = nil
    elsif @battler.sv.balloon_data != [] && @battler.sv.balloon_data != @balloon_data
      @balloon_data = @battler.sv.balloon_data
      @balloon = Sprite.new(self.viewport)
      @balloon.bitmap = Cache.system("Balloon")
      @balloon.zoom_x = @balloon_data[3]
      @balloon.zoom_y = @balloon_data[3]
      @balloon.ox = 32 if @battler.sv.mirror
      @balloon.oy = 16
      @balloon_count = 0
    end
    return if !@balloon
    @balloon.opacity = self.opacity
    @balloon.x = self.x
    @balloon.y = self.y - @battler.sv.ch * $sv_camera.zoom
    @balloon.z = self.z + 20
    @balloon.src_rect.set(32 + @balloon_count / @balloon_data[2] * 32, @balloon_data[1] * 32, 32, 32) if @balloon_count % @balloon_data[2] == 0
    @balloon.color.set(@color_data[0], @color_data[1], @color_data[2], @color_data[3]) if @color_data != nil
    @balloon_count += 1
    @balloon_count = 0 if @balloon_count == @balloon_data[2] * 7
  end
  #--------------------------------------------------------------------------
  # ● 色調変更の更新
  #--------------------------------------------------------------------------
  def update_color
    color_set if @battler.sv.color_set != []
    return if @color_data == nil
    @color_data[4] -= 1
    if @color_data[4] == 0 && @color_data[5] != 0
      @color_data[4] = @color_data[5]
      @color_data[5] = 0
      @color_data[6] = [0,0,0,0]
    elsif @color_data[4] == 0
      @remain_color_data = @color_data
      @battler.sv.color = @color_data.dup
      return @color_data = nil
    end  
    for i in 0..3
      @color_data = (@color_data * (@color_data[4] - 1) + @color_data[6]) / @color_data[4]
    end  
    @battler.sv.color = @color_data.dup
    self.color.set(@color_data[0], @color_data[1], @color_data[2], @color_data[3])
  end
  #--------------------------------------------------------------------------
  # ● 残像の更新
  #--------------------------------------------------------------------------
  def update_mirage
    if @battler.sv.mirage == [] && @mirages
      @mirage_data = []
      for mirage in @mirages do mirage.dispose end
      return @mirages = nil
    elsif @battler.sv.mirage != [] && @battler.sv.mirage != @mirage_data
      @mirage_data = @battler.sv.mirage
      @mirages = []
      for i in 0...@mirage_data[1] do @mirages = Sprite.new(self.viewport) end
      @mirage_count = 0
    end
    return if !@mirages
    @mirage_count += 1
    @mirage_count = 0 if @mirage_count == @mirage_data[2] * @mirages.size
    for i in [email protected]
      mirage_body(@mirages, @mirage_data[4]) if @mirage_count == 1 + i * @mirage_data[2]
    end
  end
  #--------------------------------------------------------------------------
  # ● 残像本体
  #--------------------------------------------------------------------------
  def mirage_body(body, opacity)
    body.bitmap = self.bitmap.dup
    body.x = self.x
    body.y = self.y
    body.ox = self.ox
    body.oy = self.oy
    body.z = self.z - 20
    body.mirror = self.mirror
    body.angle = self.angle
    body.opacity = opacity * self.opacity / 255
    body.zoom_x = self.zoom_x
    body.zoom_y = self.zoom_y   
    body.src_rect.set(@battler.sv.sx, @battler.sv.sy, @battler.sv.cw, @battler.sv.ch)
    body.color.set(@color_data[0], @color_data[1], @color_data[2], @color_data[3]) if @color_data != nil
  end   
  #--------------------------------------------------------------------------
  # ● 次のアニメを更新
  #--------------------------------------------------------------------------
  def update_next_anime
    return if !@next_anime
    for anime in @next_anime
      anime.update
      anime.set_position(self.z, self.zoom_x, self.zoom_y, @real_x, @real_y) if @horming
      anime.dispose if !anime.animation?
      @next_anime.delete(anime) if !anime.animation?
    end  
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias update_sprite_battler_n03 update
  def update
    @battler.sv.update if @battler
    update_sprite_battler_n03
    update_next_anime
    update_shadow  if @battler && @shadow
    update_mirage  if @battler
    update_balloon if @battler
    update_remove if @battler && @removing && @battler.sv.change_up
  end
  #--------------------------------------------------------------------------
  # ● 戦闘アニメ消去
  #--------------------------------------------------------------------------
  def anime_off
    @battler.sv.anime_off = false
    dispose_animation
    for anime in @next_anime do anime.dispose_animation end if @next_anime
  end
  #--------------------------------------------------------------------------
  # ● バトラー入れ替え
  #--------------------------------------------------------------------------
  def remove
    @battler.sv.start_action(@battler.sv.remove_action)
    $sv_camera.wait = 40
    @battler.sv.add_action("eval('set_change')")
    @removing = true
  end
  #--------------------------------------------------------------------------
  # ● バトラー入れ替えの更新
  #--------------------------------------------------------------------------
  def update_remove
    @battler.sv.change_up = false
    @removing = false
    @battler = nil
  end  
  #--------------------------------------------------------------------------
  # ● バトラー加入
  #--------------------------------------------------------------------------
  def join(join_battler)
    $sv_camera.wait = 30
    @battler = join_battler
    @battler_name = @battler.character_name
    @battler_index = @battler.character_index
    @battler_graphic_file_index = @battler.sv.graphic_file_index
    self.bitmap = Cache.character(@battler_name)
    @battler.sv.setup(self.bitmap.width, self.bitmap.height, true)
    create_shadow
    init_visibility
  end
  #--------------------------------------------------------------------------
  # ● 通常の設定に戻す ★再定義
  #--------------------------------------------------------------------------
  def revert_to_normal
    self.blend_type = 0
    self.opacity = 255
  end
  #--------------------------------------------------------------------------
  # ● 崩壊エフェクトの更新
  #--------------------------------------------------------------------------
  alias update_collapse_sprite_battler_n03 update_collapse
  def update_collapse
    return if @battler.sv.state(1) != "敌人死亡"
    update_collapse_sprite_battler_n03
    @battler.sv.weapon_visible = false
  end
  #--------------------------------------------------------------------------
  # ● ボス崩壊エフェクトの更新 ★再定義
  #--------------------------------------------------------------------------
  def update_boss_collapse
    @effect_duration = @battler.sv.ch if @effect_duration >= @battler.sv.ch
    alpha = @effect_duration * 120 / @battler.sv.ch
    self.ox = @battler.sv.cw / 2 + @effect_duration % 2 * 4 - 2
    self.blend_type = 1
    self.color.set(255, 255, 255, 255 - alpha)
    self.opacity = alpha
    self.src_rect.y -= 1
    Sound.play_boss_collapse2 if @effect_duration % 20 == 19
  end
  #--------------------------------------------------------------------------
  # ● 別スプライトからのタイミング処理
  #--------------------------------------------------------------------------
  def set_process_timing(timing_data)
    for data in timing_data
      set_timing(data[0],data[1])
    end
    @battler.sv.timing = []
  end
  #--------------------------------------------------------------------------
  # ● タイミング処理
  #--------------------------------------------------------------------------
  def set_timing(se_flag, data)
    @ani_rate = 4
    data.se.play if se_flag
    case data.flash_scope
    when 1 ;self.flash(data.flash_color, data.flash_duration * @ani_rate)
    when 2 ;viewport.flash(data.flash_color, data.flash_duration * @ani_rate) if viewport
    when 3 ;self.flash(nil, data.flash_duration * @ani_rate)
    end
  end
  #--------------------------------------------------------------------------
  # ● 色調変更
  #--------------------------------------------------------------------------
  def color_set
    set = @battler.sv.color_set
    @battler.sv.color_set= []
    set[4] = 1 if set[4] == 0
    @remain_color_data = [0,0,0,0] if @remain_color_data == nil
    @color_data = @remain_color_data
    @color_data[4] = set[4]
    @color_data[5] = set[5]
    @color_data[6] = set
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  alias dispose_sprite_battler_n03 dispose
  def dispose
    dispose_sprite_battler_n03
    @shadow.dispose if @shadow != nil
    @balloon.dispose if @balloon != nil
    for mirage in @mirages do mirage.dispose end if @mirages != nil
    for anime in @next_anime do anime.dispose end if @next_anime
  end
end


#==============================================================================
# ■ Spriteset_Battle
#------------------------------------------------------------------------------
#  バトル画面のスプライトをまとめたクラスです。
#==============================================================================
class Spriteset_Battle
  #--------------------------------------------------------------------------
  # ● 戦闘背景(床)スプライトの作成 ★再定義
  #--------------------------------------------------------------------------
  def create_battleback1
    @back1_sprite = Sprite_Battle_Back.new(@viewport1, 1, battleback1_name)
    @back1_sprite.set_graphics(battleback1_bitmap) if battleback1_name != nil
    @back1_sprite.z = 0
  end
  #--------------------------------------------------------------------------
  # ● 戦闘背景(壁)スプライトの作成 ★再定義
  #--------------------------------------------------------------------------
  def create_battleback2
    @back2_sprite = Sprite_Battle_Back.new(@viewport1, 2, battleback2_name)
    @back2_sprite.set_graphics(battleback2_bitmap) if battleback2_name != nil
    @back2_sprite.z = 1
  end
  #--------------------------------------------------------------------------
  # ● アクタースプライトの作成 ★再定義
  #--------------------------------------------------------------------------
  def create_actors
    @actor_sprites = []
    for i in 0...$game_party.max_battle_members
      @actor_sprites = Sprite_Battler.new(@viewport1, $game_party.members)
    end
    @effect_sprites = Spriteset_Sideview.new(@viewport1)
  end
  #--------------------------------------------------------------------------
  # ● アクタースプライトの更新 ★再定義
  #--------------------------------------------------------------------------
  def update_actors
    @actor_sprites.each_with_index do |sprite, i|
      sprite_join($game_party.members, sprite) if sprite.battler == nil && sprite.battler != $game_party.members
      sprite.remove if sprite.battler != nil && !sprite.removing && sprite.battler != $game_party.members
      sprite.update
    end
    @effect_sprites.update
    update_program
  end
  #--------------------------------------------------------------------------
  # ● メンバーを加える
  #--------------------------------------------------------------------------
  def sprite_join(member, sprite)
    for sp in @actor_sprites
      sp.update_remove if member == sp.battler && !sp.battler.sv.change_up
    end
    sprite.join(member)
  end
  #--------------------------------------------------------------------------
  # ● バトルプログラムの更新
  #--------------------------------------------------------------------------
  def update_program
    return if $sv_camera.program_scroll == []
    for data in  $sv_camera.program_scroll
      @back1_sprite.start_back_data(data) if data[2] == 1
      @back2_sprite.start_back_data(data) if data[2] == 2
    end
    $sv_camera.program_scroll = []
  end
  #--------------------------------------------------------------------------
  # ● ヒット時の戦闘アニメ実行
  #--------------------------------------------------------------------------
  def set_hit_animation(battler, weapon_index, hit_targets, miss)
    @effect_sprites.set_hit_animation(battler, weapon_index, hit_targets, miss)
  end
  #--------------------------------------------------------------------------
  # ● ダメージPOP
  #--------------------------------------------------------------------------
  def set_damage_pop(target)
    @effect_sprites.set_damage_pop(target)
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  alias dispose_spriteset_battle_n03 dispose
  def dispose
    dispose_spriteset_battle_n03
    @effect_sprites.dispose
  end
  
  
  
end


#==============================================================================
# ■ Window_BattleLog
#------------------------------------------------------------------------------
#  戦闘の進行を実況表示するウィンドウです。
#==============================================================================
class Window_BattleLog < Window_Selectable
  #--------------------------------------------------------------------------
  # ● ウェイト ★再定義
  #--------------------------------------------------------------------------
  def wait
  end
  #--------------------------------------------------------------------------
  # ● ウェイトとクリア ★再定義
  #--------------------------------------------------------------------------
  def wait_and_clear
    $sv_camera.wait = 10
  end
  #--------------------------------------------------------------------------
  # ● 行動結果の表示 ★再定義
  #--------------------------------------------------------------------------
  def display_action_results(target, item)
    if target.result.used
      last_line_number = line_number
      display_critical(target, item)
      display_damage(target, item)
      display_affected_status(target, item)
      display_failure(target, item)
    end
    off if !N03::BATTLE_LOG
  end
  #--------------------------------------------------------------------------
  # ● ウインドウ非表示
  #--------------------------------------------------------------------------
  def off
    @back_sprite.visible = self.visible = false
  end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  イベントコマンドを実行するインタプリタです。
#==============================================================================
class Game_Interpreter
  #--------------------------------------------------------------------------
  # ● スイッチの操作
  #--------------------------------------------------------------------------
  alias command_121_game_interpreter_n03 command_121
  def command_121
    command_121_game_interpreter_n03
    $sv_camera.program_check
  end
end


在下使用这个脚本测试时在战斗界面报错如图


望各位懂脚本的大佬修正一下,多谢。


Lv6.析梦学徒

老鹰

梦石
40
星屑
33407
在线时间
6552 小时
注册时间
2012-5-26
帖子
3178

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

2
发表于 2018-9-20 11:15:54 | 只看该作者
先推荐一个汉化版的
https://rpg.blue/forum.php?mod=v ... B%E6%B1%89%E5%8C%96
虽然没有原发布地址的版本新,缺少了一些附加功能,但是稳定有效

如果还报错请再编辑。
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2547
在线时间
210 小时
注册时间
2018-8-8
帖子
105
3
 楼主| 发表于 2018-9-21 08:43:06 | 只看该作者
显示同一个错误肿么办

点评

问题应该在技能设置的那个基本里,用排除法把出问题的那个技能找出来。  发表于 2018-9-21 09:02
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1971
在线时间
926 小时
注册时间
2015-10-26
帖子
356

开拓者

4
发表于 2018-9-21 09:24:00 | 只看该作者
本帖最后由 踢腿水上飘 于 2018-9-21 10:21 编辑

应该是你把脚本搬到你的工程里的时候,数据库里面的一些设置没有搬过去
你比较一下范例工程和你自己的工程的数据库,状态,技能和动画 还有素材!
该搬的给搬运过去
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
5987
在线时间
597 小时
注册时间
2017-9-27
帖子
251
5
发表于 2018-9-21 10:17:34 | 只看该作者
首先默认设置技能大概130-150,动画设置大概110-130之间。就算不复制,最大上限必须达到。否则就会出现如上错误。
对该脚本不熟悉,建议使用该工程进行制作。
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2547
在线时间
210 小时
注册时间
2018-8-8
帖子
105
6
 楼主| 发表于 2018-9-28 16:28:34 | 只看该作者
直接使用该工程重做后,发现
  1. #==============================================================================
  2. # ■ Sideview Ver100
  3. #------------------------------------------------------------------------------
  4. #  サイドビューバトラーを管理するクラスです。
  5. #==============================================================================
  6. class SideView
  7.   #--------------------------------------------------------------------------
  8.   # ● 公開インスタンス変数 
  9.   #--------------------------------------------------------------------------
  10.   attr_accessor   :x                    # 画面X座標
  11.   attr_accessor   :y                    # 画面Y座標
  12.   attr_accessor   :z                    # 画面Z座標
  13.   attr_accessor   :h                    # 高さ座標
  14.   attr_accessor   :j                    # ジャンプ座標
  15.   attr_accessor   :c                    # カーブ座標
  16.   attr_accessor   :ox                   # 横原点
  17.   attr_accessor   :oy                   # 縦原点
  18.   attr_accessor   :oy_adjust            # 縦原点補正
  19.   attr_accessor   :angle                # 回転角度
  20.   attr_accessor   :zoom_x               # 横の拡大率
  21.   attr_accessor   :zoom_y               # 縦の拡大率
  22.   attr_accessor   :pattern_w            # セル横位置(矩形内)
  23.   attr_accessor   :pattern_h            # セル縦位置(矩形内)
  24.   attr_accessor   :sx                   # セル横位置(画像全体)
  25.   attr_accessor   :sy                   # セル縦位置(画像全体)
  26.   attr_accessor   :pattern_type         # セル更新タイプ
  27.   attr_accessor   :pattern_time         # セル更新間隔
  28.   attr_accessor   :graphic_name         # バトラー画像ファイル名
  29.   attr_accessor   :graphic_file_index   # バトラー画像ファイル名インデックス
  30.   attr_accessor   :graphic_index        # バトラー画像インデックス
  31.   attr_accessor   :cw                   # セル横矩形
  32.   attr_accessor   :ch                   # セル縦矩形
  33.   attr_accessor   :shadow_visible       # 影表示
  34.   attr_accessor   :weapon_visible       # 武器表示
  35.   
  36.   attr_accessor   :wait                 # 次の動作待ち時間
  37.   attr_accessor   :weapon_index         # 表示中の武器画像インデックス配列
  38.   attr_accessor   :weapon_end           # 武器アニメ終了フラグ
  39.   attr_accessor   :force_action         # 強制アクション
  40.   attr_accessor   :target_battler       # ターゲットバトラー情報
  41.   attr_accessor   :second_targets       # セカンドターゲット情報
  42.   attr_accessor   :m_a_targets          # アニメ飛ばしターゲット情報
  43.   attr_accessor   :individual_targets   # 個別処理ターゲットバトラー情報
  44.   attr_accessor   :effect_data          # エフェクトデータ
  45.   attr_accessor   :anime_id             # アニメID配列
  46.   attr_accessor   :anime_move_id        # 飛ばしアニメID配列
  47.   attr_accessor   :mirror               # 反転フラグ
  48.   attr_accessor   :opacity              # 透明度
  49.   attr_accessor   :opacity_data         # 透明度操作情報
  50.   attr_accessor   :set_damage           # バトルシーンでのダメージ処理
  51.   attr_accessor   :m_a_data             # アニメ飛ばし情報
  52.   attr_accessor   :m_a_starter          # アニメ飛ばし開始ターゲット情報
  53.   attr_accessor   :action_end           # バトルシーンでの行動終了
  54.   attr_accessor   :damage_anime_data    # ダメージ戦闘アニメのデータ
  55.   attr_accessor   :anime_no_mirror      # 戦闘アニメの反転禁止フラグ
  56.   attr_accessor   :anime_horming        # 戦闘アニメのホーミングフラグ
  57.   attr_accessor   :anime_camera_zoom    # 戦闘アニメがカメラに合わせて拡大縮小するか
  58.   attr_accessor   :anime_plus_z         # 戦闘アニメZ座標補正
  59.   attr_accessor   :derivation_skill_id  # スキル派生ID
  60.   attr_accessor   :immortal             # 不死身フラグ
  61.   attr_accessor   :mirage               # 残像データ
  62.   attr_accessor   :balloon_data         # ふきだしデータ
  63.   attr_accessor   :timing               # 別バトラーからのタイミングデータ
  64.   attr_accessor   :timing_targets       # タイミングデータを渡す別バトラー
  65.   attr_accessor   :color_set            # 色調変更データ
  66.   attr_accessor   :color                # 色調データ
  67.   attr_accessor   :change_up            # 画像変更フラグ
  68.   attr_accessor   :hit                  # 被攻撃回数
  69.   attr_accessor   :add_state            # 何度も付加ステートの表示を防ぐフラグ
  70.   attr_accessor   :counter_id           # カウンター時のスキルID
  71.   attr_accessor   :reflection_id        # 魔法反射時のアニメID
  72.   attr_accessor   :result_damage        # ターン終了時のHP変動データ
  73.   attr_accessor   :active               # 行動権
  74.   attr_accessor   :anime_off            # 戦闘アニメ消去
  75.   attr_accessor   :command_action       # コマンドアクションフラグ
  76.    
  77.   attr_accessor   :base_x               # 初期位置 X座標
  78.   attr_accessor   :base_y               # 初期位置 Y座標
  79.   attr_accessor   :base_h               # 初期位置 高さ座標
  80.   attr_accessor   :max_pattern_w        # セルの横分割数
  81.   attr_accessor   :max_pattern_h        # セルの縦分割数
  82.   
  83.   attr_reader     :collapse             # コラプスフラグ
  84.   attr_reader     :picture              # ピクチャ表示フラグ
  85.   #--------------------------------------------------------------------------
  86.   # ● オブジェクト初期化
  87.   #--------------------------------------------------------------------------
  88.   def initialize(battler)
  89.     @battler = battler
  90.     reset
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● 初期化
  94.   #--------------------------------------------------------------------------
  95.   def reset
  96.     @x = 0
  97.     @y = 0
  98.     @z = 0
  99.     @h = 0
  100.     @j = 0
  101.     @c = 0
  102.     @jump = []
  103.     @curve = []
  104.     @ox = 0
  105.     @oy = 0
  106.     @oy_adjust = 0
  107.     @z_plus = 0
  108.     @move_time = 0
  109.     @angle = 0
  110.     @angle_time = 0
  111.     @zoom_x = 1
  112.     @zoom_y = 1
  113.     @zoom_time = 0
  114.     @pattern_w = 0
  115.     @pattern_h = 0
  116.     @sx = 0
  117.     @sy = 0
  118.     @pattern_type = 0
  119.     @pattern_time = 0
  120.     @pattern_rest_time = 0
  121.     @graphic_name = ""
  122.     @graphic_file_index = ""
  123.     @graphic_index = 0
  124.     @cw = 0
  125.     @ch = 0
  126.     @shadow_visible = false
  127.     @weapon_visible = true
  128.    
  129.     @wait = 0
  130.     @weapon_index = []
  131.     @weapon_end = true
  132.     @full_action = []
  133.     @action = []
  134.     @force_action = ""
  135.     @target_battler = []
  136.     @second_targets = []
  137.     @individual_targets = []
  138.     @m_a_targets = []
  139.     @effect_data = []
  140.     @anime_id = []
  141.     @anime_move_id = []
  142.     @opacity = 255
  143.     @opacity_data = []
  144.     @set_damage = false
  145.     @m_a_data = []
  146.     @m_a_starter = []
  147.     @action_end = false
  148.     @damage_anime_data = []
  149.     @anime_no_mirror = false
  150.     @anime_horming = false
  151.     @anime_camera_zoom = false
  152.     @anime_plus_z = true
  153.     @derivation_skill_id = 0
  154.     @immortal = false
  155.     @mirage = []
  156.     @play_data = []
  157.     @balloon_data = []
  158.     @picture = false
  159.     @timing = []
  160.     @timing_targets = []
  161.     @color_set = []
  162.     @color = []
  163.     @change_up = false
  164.     @non_motion = false
  165.     @graphics_change = false
  166.     @hit = []
  167.     @add_state = []
  168.     @collapse = false
  169.     @counter_id = 0
  170.     @reflection_id = 0
  171.     @result_damage = [0,0]
  172.     @active = false
  173.     @anime_off = false
  174.     @command_action = false
  175.    
  176.     @base_x = 0
  177.     @base_y = 0
  178.     @base_z = 0
  179.     @base_h = 0
  180.     @max_pattern_w = 0
  181.     @max_pattern_h = 0
  182.     @pattern_kind = 0
  183.     @pattern_count = 0
  184.     @move_time = 0
  185.     @mirror = false
  186.     @battler.set_graphic(@pre_change_data[0], @pre_change_data[1], @pre_change_data[2], @pre_change_data[3]) if @pre_change_data != nil
  187.     @pre_change_data = nil
  188.   end  
  189.   #--------------------------------------------------------------------------
  190.   # ● セットアップ
  191.   #--------------------------------------------------------------------------
  192.   def setup(bitmap_width, bitmap_height, first_action_flag)
  193.     reset if first_action_flag
  194.     set_data
  195.     set_base_position if !@graphics_change
  196.     set_graphics(bitmap_width, bitmap_height)
  197.     set_target
  198.     setup_graphics_change if @graphics_change
  199.     first_battler_anime_set if first_action_flag
  200.   end  
  201.   #--------------------------------------------------------------------------
  202.   # ● バトラーデータ取得
  203.   #--------------------------------------------------------------------------
  204.   def set_data
  205.     return if @battler == nil
  206.     if @battler.actor?
  207.       @graphic_name = @battler.character_name
  208.       @graphic_index = @battler.character_index
  209.     else
  210.       @graphic_name = @battler.battler_name
  211.       @graphic_index = 0
  212.     end
  213.     @max_pattern_w = max_pattern[0]
  214.     @max_pattern_h = max_pattern[1]
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # ● ベース座標をセット data = [X軸, Y軸, H軸]  moment_set…瞬間配置
  218.   #--------------------------------------------------------------------------
  219.   def set_base_position(moment_set = true)
  220.     mirroring_reset
  221.     if @battler.actor?
  222.       data = N03::ACTOR_POSITION[@battler.index].dup
  223.       @base_x = data[0] * 100 if !@mirror
  224.       @base_x = (Graphics.width - data[0]) * 100 if @mirror
  225.     else
  226.       data = [@battler.screen_x, @battler.screen_y, 0].dup
  227.       @base_x = data[0] * 100 if !$sv_camera.mirror
  228.       @base_x = (Graphics.width - data[0]) * 100 if $sv_camera.mirror
  229.     end
  230.     @base_y = data[1] * 100
  231.     @base_h = data[2] * 100
  232.     @base_z = @y
  233.     return if !moment_set
  234.     @x = @base_x
  235.     @y = @base_y
  236.     @z = @base_z
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ● グラフィックデータ取得
  240.   #--------------------------------------------------------------------------
  241.   def set_graphics(bitmap_width, bitmap_height)
  242.     sign = @graphic_name[/^[\!\$]./]
  243.     if sign && sign.include?('
  244. 该代码3452行错误
  245. )
  246.       @cw = bitmap_width / @max_pattern_w
  247.       @ch = bitmap_height / @max_pattern_h
  248.     elsif @max_pattern_w == 1 && @max_pattern_h == 1
  249.       @cw = bitmap_width
  250.       @ch = bitmap_height
  251.     else
  252.       @cw = bitmap_width / (@max_pattern_w * 4)
  253.       @ch = bitmap_height / (@max_pattern_h * 2)
  254.     end
  255.     @ox = @cw / 2
  256.     @oy = @ch
  257.     @sx = (@graphic_index % 4 * @max_pattern_w + @pattern_w) * @cw
  258.     @sy = (@graphic_index / 4 * @max_pattern_h + @pattern_h) * @ch
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # ● ターゲットをセット
  262.   #--------------------------------------------------------------------------
  263.   def set_target(target = nil)
  264.     @target_battler = target
  265.     @target_battler = [@battler] if target == nil
  266.     @second_targets = @target_battler
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ● 画像変更用のセットアップ
  270.   #--------------------------------------------------------------------------
  271.   def setup_graphics_change
  272.     @graphics_change = false
  273.     @sx = (@graphic_index % 4 * @max_pattern_w + @pattern_w) * @cw
  274.     @sy = (@graphic_index / 4 * @max_pattern_h + @pattern_h) * @ch
  275.   end  
  276.   #--------------------------------------------------------------------------
  277.   # ● 戦闘開始時の待機アニメ画像データ取得
  278.   #--------------------------------------------------------------------------
  279.   def first_battler_anime_set
  280.     loop do
  281.       update
  282.       break if @action_data == nil
  283.       break if @action_data[0] == "motion"
  284.       break if @action_data[0] == "move" && @action_data[8] != ""
  285.       break if @full_action == []
  286.     end
  287.     start_action(first_action) if @battler.movable?
  288.   end
  289.   #--------------------------------------------------------------------------
  290.   # ● アクション開始
  291.   #--------------------------------------------------------------------------
  292.   def start_action(kind = nil)
  293.     return if @event_fix && $game_troop.interpreter.running?
  294.     # ウェイト中の場合キャンセル
  295.     return @wait -= 1 if @wait > 0 && kind == nil
  296.     action_setup(false) if kind != nil
  297.     set_action(kind)
  298.     @action = kind if @action == nil
  299.     # 行動配列が無い場合は行動終了処理へ移行
  300.     action_terminate if @action == nil
  301.     # 次のアクション決定
  302.     @action_data = N03::ACTION[@action]
  303.     next_action
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ● 行動パラメータの初期化
  307.   #--------------------------------------------------------------------------
  308.   def action_setup(reset = true)
  309.     @event_fix = false
  310.     @set_damage = false
  311.     @action_end = false
  312.     @balloon_data = []
  313.     @loop_act = []
  314.     angle_reset if reset
  315.     zoom_reset if reset
  316.     opacity_reset if reset
  317.     @curve = []
  318.     @c = 0
  319.     convert_jump
  320.   end  
  321.   #--------------------------------------------------------------------------
  322.   # ● 行動終了処理
  323.   #--------------------------------------------------------------------------
  324.   def action_terminate
  325.     @mirage = [] if @mirage_end
  326.     mirroring_reset
  327.     @picture = false
  328.     @individual_targets = []
  329.     action_setup if @active
  330.     action_setup(false) if !@active
  331.     # 待機アクションへ移行
  332.     stand_by_action if !@non_motion
  333.     # 戦闘行動のアクティブ権を終了
  334.     next_battler
  335.   end  
  336.   #--------------------------------------------------------------------------
  337.   # ● 新しいアクション内容の決定
  338.   #--------------------------------------------------------------------------
  339.   def set_action(kind = nil)
  340.     full_act = N03::FULLACTION[kind]
  341.     @full_action = full_act.dup if full_act != nil
  342.     @action = @full_action.shift
  343.     # 参照したアクションがフルアクションであれば全体のアクションを統合
  344.     full_act2 = N03::FULLACTION[@action]
  345.     @full_action = full_act2.dup + @full_action if full_act2 != nil
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # ● 次のアクションへ
  349.   #--------------------------------------------------------------------------
  350.   def next_action
  351.     @wait = 0
  352.     # ショートカット確認
  353.     eval(@action) if @action != nil && @action_data == nil && N03::FULLACTION[@action] == nil
  354.     # ウエイト設定
  355.     @wait = @action.to_i if @wait == 0 && @action_data == nil
  356.     @wait = rand(@wait.abs + 1) if @wait < 0
  357.     # アクション開始
  358.     action_play
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # ● 待機アクションへ移行
  362.   #--------------------------------------------------------------------------
  363.   def stand_by_action
  364.     # 通常待機に
  365.     stand_by_act = normal
  366.     # HPが1/4でピンチアクションに
  367.     stand_by_act = pinch if @battler.hp <= @battler.mhp / 4
  368.     # ステートチェック
  369.     stand_by_act = state(@battler.states[0].id) if @battler.states[0] != nil && state(@battler.states[0].id) != nil
  370.     # コマンドチェック
  371.     stand_by_act = command if @command_action && command != nil
  372.     set_action(stand_by_act)
  373.     @action = stand_by_act if @action == nil
  374.   end
  375.   #--------------------------------------------------------------------------
  376.   # ● 強制アクション開始
  377.   #--------------------------------------------------------------------------
  378.   def start_force_action
  379.     return if @active
  380.     start_action(@force_action)
  381.     @force_action = ""
  382.   end  
  383.   #--------------------------------------------------------------------------
  384.   # ● アクション追加
  385.   #--------------------------------------------------------------------------
  386.   def add_action(kind)
  387.     @full_action.push(kind)
  388.   end  
  389.   #--------------------------------------------------------------------------
  390.   # ● アクションの挿入
  391.   #--------------------------------------------------------------------------
  392.   def unshift_action(kind)
  393.     @full_action.unshift(kind)
  394.   end  
  395.   #--------------------------------------------------------------------------
  396.   # ● フレーム更新
  397.   #--------------------------------------------------------------------------
  398.   def update
  399.     # アクション開始
  400.     start_action
  401.     # 強制アクション開始
  402.     start_force_action if @force_action != ""
  403.     # アニメパターン更新
  404.     update_pattern
  405.     # 移動更新
  406.     update_move
  407.     # 回転更新
  408.     update_angle if @angle_time != 0
  409.     # 拡大縮小更新
  410.     update_zoom if @zoom_time != 0
  411.     # 透明度更新
  412.     update_opacity if @opacity_data != []
  413.   end
  414.   #--------------------------------------------------------------------------
  415.   # ● アニメパターン更新
  416.   #--------------------------------------------------------------------------
  417.   def update_pattern
  418.     return @pattern_rest_time -= 1 if @pattern_rest_time != 0
  419.     return if @max_pattern_w == 1 && @max_pattern_h == 1
  420.     @pattern_rest_time = @pattern_time
  421.     # 再生開始・終了セル位置を取得
  422.     if @pattern_kind > 0 # 通常再生中
  423.       @pattern_start = 0
  424.       @pattern_end = @max_pattern_w - 1
  425.     elsif @pattern_kind < 0 # 逆転再生中
  426.       @pattern_start = @max_pattern_w - 1
  427.       @pattern_end = 0
  428.     end
  429.     # 片道の再生が終了
  430.     @pattern_count += 1 if @pattern_w == @pattern_end && @pattern_kind != 0
  431.     # ループ処理
  432.     case @pattern_type.abs
  433.     when  1,3 # 片道
  434.       @pattern_kind =  0 if @pattern_count != 0 && @pattern_type ==  1
  435.       @pattern_kind =  0 if @pattern_count != 0 && @pattern_type == -1
  436.       @pattern_kind =  1 if @pattern_count != 0 && @pattern_type ==  3
  437.       @pattern_kind = -1 if @pattern_count != 0 && @pattern_type == -3
  438.       @pattern_w = @pattern_start - @pattern_kind if @pattern_count != 0 && @pattern_type.abs == 3
  439.       @pattern_count = 0
  440.     when  2,4 # 往復
  441.       @pattern_kind = -1 if @pattern_count == 1 && @pattern_type ==  2
  442.       @pattern_kind =  1 if @pattern_count == 1 && @pattern_type == -2
  443.       @pattern_kind =  0 if @pattern_count == 2 && @pattern_type ==  2
  444.       @pattern_kind =  0 if @pattern_count == 2 && @pattern_type == -2
  445.       @pattern_kind = -1 if @pattern_count == 1 && @pattern_type ==  4
  446.       @pattern_kind =  1 if @pattern_count == 1 && @pattern_type == -4
  447.       @pattern_kind =  1 if @pattern_count == 2 && @pattern_type ==  4
  448.       @pattern_kind = -1 if @pattern_count == 2 && @pattern_type == -4
  449.       @pattern_count = 0 if @pattern_count == 2
  450.     end
  451.     # セル更新
  452.     @pattern_w += 1 * @pattern_kind
  453.     @sx = (@graphic_index % 4 * @max_pattern_w + @pattern_w) * @cw
  454.   end
  455.   #--------------------------------------------------------------------------
  456.   # ● 移動の更新
  457.   #--------------------------------------------------------------------------
  458.   def update_move
  459.     @z = @y / 100 + @z_plus
  460.     return if @move_time == 0
  461.     target_position_set if @horming_move
  462.     @x = (@x * (@move_time - 1) + @target_x) / @move_time
  463.     @y = (@y * (@move_time - 1) + @target_y) / @move_time
  464.     @h = (@h * (@move_time - 1) + @target_h) / @move_time if @move_h != nil
  465.     @c += @curve[@move_time - 1] if @curve[@move_time - 1] != nil
  466.     @j += @jump[@move_time - 1] if @jump[@move_time - 1] != nil
  467.     @move_time -= 1
  468.     convert_jump if @move_time == 0
  469.   end
  470.   #--------------------------------------------------------------------------
  471.   # ● 移動目標の更新
  472.   #--------------------------------------------------------------------------
  473.   def target_position_set
  474.     target_position = N03.get_targets_position(@move_targets, @horming_move)
  475.     @target_x = target_position[0] + @move_x
  476.     @target_y = target_position[1] + @move_y
  477.     @target_h = target_position[2] + @move_h if @move_h != nil
  478.   end  
  479.   #--------------------------------------------------------------------------
  480.   # ● 回転更新
  481.   #--------------------------------------------------------------------------
  482.   def update_angle
  483.     @angle += @angling
  484.     @angle_time -= 1
  485.     return if @angle_time != 0
  486.     return angle_reset if @angle_data[4] == 0
  487.     angling(@angle_data) if @angle_data[4] == 2
  488.   end  
  489.   #--------------------------------------------------------------------------
  490.   # ● 拡大縮小更新
  491.   #--------------------------------------------------------------------------
  492.   def update_zoom
  493.     @zoom_x += @zooming_x
  494.     @zoom_y += @zooming_y
  495.     @zoom_time -= 1
  496.     return if @zoom_time != 0
  497.     return zoom_reset if @zoom_data[4] == 0
  498.     zooming(@zoom_data) if @zoom_data[4] == 2
  499.   end
  500.   #--------------------------------------------------------------------------
  501.   # ● 透明度更新
  502.   #--------------------------------------------------------------------------
  503.   def update_opacity
  504.     @opacity += @opacity_data[2]
  505.     @opacity_data[0] -= 1
  506.     return if @opacity_data[0] != 0
  507.     return if !@opacity_data[5]
  508.     @opacity_data[2] *= -1
  509.     @opacity_data[0] = @opacity_data[1]
  510.   end
  511.   #--------------------------------------------------------------------------
  512.   # ● アクション実行
  513.   #--------------------------------------------------------------------------
  514.   def action_play
  515.     return if @action_data == nil
  516.     action = @action_data[0]
  517.     # バトラー反転の場合
  518.     return mirroring                    if action == "mirror"
  519.     # 残像の場合
  520.     return mirage_set                   if action == "mirage"
  521.     # 回転の場合  
  522.     return angling                      if action == "angle"
  523.     # 拡大縮小の場合  
  524.     return zooming                      if action == "zoom"
  525.     # 透明度操作の場合  
  526.     return set_opacity                  if action == "opacity"
  527.     # バトラーアニメの場合
  528.     return battler_anime                if action == "motion"
  529.     # 移動の場合
  530.     return move                         if action == "move"
  531.     # 武器アニメの場合
  532.     return weapon_anime([@action_data]) if action == "wp"
  533.     # アニメ飛ばしの場合
  534.     return move_anime                   if action == "m_a"
  535.     # 戦闘シーン通信の場合(コラプス)
  536.     return set_play_data                if action == "collapse" or action == "no_collapse"
  537.     # データベース戦闘アニメ表示の場合  
  538.     return battle_anime                 if action == "anime"
  539.     # カメラワークの場合
  540.     return camera                       if action == "camera"
  541.     # 画面のシェイクの場合
  542.     return shake                        if action == "shake"
  543.     # 画面色調変更の場合
  544.     return color_effect                 if action == "color"
  545.     # トランジションの場合
  546.     return transition                   if action == "ts"
  547.     # ふきだしアニメ表示の場合  
  548.     return balloon_anime                if action == "balloon"
  549.     # ピクチャ表示の場合
  550.     return picture_set                  if action == "pic"
  551.     # ステート操作の場合
  552.     return state_set                    if action == "sta"
  553.     # FPS変更の場合
  554.     return fps                          if action == "fps"
  555.     # バトラー画像変更の場合  
  556.     return graphics_change              if action == "change"
  557.     # スキル派生の場合  
  558.     return derivating_skill             if action == "der"
  559.     # BGM/BGS/SE演奏の場合  
  560.     return sound                        if action == "sound"
  561.     # ムービー再生の場合  
  562.     return movie                        if action == "movie"
  563.     # ゲームスイッチ操作の場合  
  564.     return switches                     if action == "switch"
  565.     # ゲーム変数操作の場合  
  566.     return variable                     if action == "variable"
  567.     # 条件分岐(ゲームスイッチ)の場合
  568.     return nece_1                       if action == "n_1"
  569.     # 条件分岐(ゲーム変数)の場合
  570.     return nece_2                       if action == "n_2"
  571.     # 条件分岐(ステート)の場合
  572.     return nece_3                       if action == "n_3"
  573.     # 条件分岐(スキル)の場合
  574.     return nece_4                       if action == "n_4"
  575.     # 条件分岐(パラメータ)の場合
  576.     return nece_5                       if action == "n_5"
  577.     # 条件分岐(装備)の場合
  578.     return nece_6                       if action == "n_6"
  579.     # 条件分岐(スクリプト)の場合
  580.     return nece_7                       if action == "n_7"
  581.     # セカンドターゲット操作の場合  
  582.     return second_targets_set           if action == "s_t"
  583.     # コモンイベント呼び出しの場合  
  584.     return call_common_event            if action == "common"
  585.     # 戦闘アニメ消去の場合  
  586.     return @anime_off = true            if action == "anime_off"
  587.     # 強制戦闘終了の場合  
  588.     return BattleManager.process_abort  if action == "battle_end"
  589.     # 画面固定の場合  
  590.     return Graphics.freeze              if action == "graphics_freeze"
  591.     # ダメージアニメの場合  
  592.     return damage_anime                 if action == "damage_anime"
  593.     # 武器消去の場合  
  594.     return @weapon_visible = false      if action == "weapon_off"
  595.     # 武器消去解除の場合  
  596.     return @weapon_visible = true       if action == "weapon_on"
  597.     # 待機キャンセルの場合
  598.     return @non_motion = true           if action == "non_motion"
  599.     # 待機キャンセル解除の場合
  600.     return @non_motion = false          if action == "non_motion_cancel"
  601.     # 初期位置変更の場合
  602.     return change_base_position         if action == "change_base_position"
  603.     # 初期位置変更解除の場合
  604.     return set_base_position(false)     if action == "set_base_position"
  605.     # 強制アクションの場合  
  606.     return force_act                    if action == "force_action"
  607.     # 強制アクションの場合 (セカンドターゲット)
  608.     return force_act2                   if action == "force_action2"
  609.     # 個別開始の場合
  610.     return individual_start             if action == "individual_start"
  611.     # 個別終了の場合
  612.     return individual_end               if action == "individual_end"
  613.     # ループ開始の場合
  614.     return loop_start                   if action == "loop_start"
  615.     # ループ終了の場合
  616.     return loop_end                     if action == "loop_end"
  617.     # 自分のみ更新の場合
  618.     return only_action_on               if action == "only_action_on"
  619.     # 自分のみ更新解除の場合
  620.     return only_action_off              if action == "only_action_off"
  621.     # 次の行動者へ移行の場合
  622.     return next_battler                 if action == "next_battler"
  623.     # 画像変更フラグの場合
  624.     return set_change                   if action == "set_change"
  625.     # スクリプト操作の場合   
  626.     return eval(@action_data[0])
  627.   end
  628.   #--------------------------------------------------------------------------
  629.   # ● バトラー反転実行
  630.   #--------------------------------------------------------------------------
  631.   def mirroring
  632.     @mirror = !@mirror
  633.   end  
  634.   #--------------------------------------------------------------------------
  635.   # ● 反転初期化
  636.   #--------------------------------------------------------------------------
  637.   def mirroring_reset
  638.     @mirror = false
  639.     mirroring if [email protected]? && N03::ENEMY_MIRROR
  640.     mirroring if $sv_camera.mirror
  641.   end  
  642.   #--------------------------------------------------------------------------
  643.   # ● 残像実行
  644.   #--------------------------------------------------------------------------
  645.   def mirage_set
  646.     @mirage = @action_data.dup
  647.     @mirage_end = @mirage[3]
  648.     @mirage = [] if @mirage[1] == 0
  649.   end  
  650.   #--------------------------------------------------------------------------
  651.   # ● 回転実行
  652.   #--------------------------------------------------------------------------
  653.   def angling(data = @action_data)
  654.     @angle_data = data.dup
  655.     @oy = @ch / 2
  656.     @oy_adjust = @ch * 50
  657.     @angle_time = data[1]
  658.     start_angle = data[2] * N03.mirror_num(@mirror)
  659.     end_angle = data[3] * N03.mirror_num(@mirror)
  660.     # 時間が0以下なら即座に最終角度へ
  661.     @angle_time = 1 if @angle_time <= 0
  662.     # 回転時間から1フレームあたりの角度を出す
  663.     @angling = (end_angle - start_angle) / @angle_time
  664.     # 割り切れない余りを初期角度に
  665.     @angle = (end_angle - start_angle) % @angle_time + start_angle
  666.   end
  667.   #--------------------------------------------------------------------------
  668.   # ● 回転初期化
  669.   #--------------------------------------------------------------------------
  670.   def angle_reset
  671.     @oy = @ch
  672.     @angle = @angle_time = @oy_adjust = 0
  673.   end  
  674.   #--------------------------------------------------------------------------
  675.   # ● 拡大縮小実行
  676.   #--------------------------------------------------------------------------
  677.   def zooming(data = @action_data)
  678.     @zoom_data = data.dup
  679.     @zoom_time = data[1]
  680.     start_zoom_x = data[2][0]
  681.     start_zoom_y = data[2][1]
  682.     end_zoom_x = data[3][0]
  683.     end_zoom_y = data[3][1]
  684.     # 時間が0以下なら即座に最終サイズへ
  685.     @zoom_time = 1 if @zoom_time <= 0
  686.     # 拡大縮小時間から1フレームあたりの拡大縮小率を出す
  687.     @zooming_x = (end_zoom_x - start_zoom_x) / @zoom_time
  688.     @zooming_y = (end_zoom_y - start_zoom_y) / @zoom_time
  689.     # 開始サイズに
  690.     @zoom_x = start_zoom_x
  691.     @zoom_y = start_zoom_y
  692.   end  
  693.   #--------------------------------------------------------------------------
  694.   # ● 拡大縮小初期化
  695.   #--------------------------------------------------------------------------
  696.   def zoom_reset
  697.     @zoom_x = @zoom_y = 1
  698.     @zoom_time = 0
  699.   end  
  700.   #--------------------------------------------------------------------------
  701.   # ● バトラー透明度操作
  702.   #--------------------------------------------------------------------------
  703.   def set_opacity
  704.     data = @action_data.dup
  705.     @opacity = data[2]
  706.     opacity_move = (data[3] - data[2])/ data[1]
  707.     @opacity_data = [data[1], data[1], opacity_move, data[4], data[5], data[6]]
  708.     @wait = data[1] if data[7]
  709.     @wait *= 2 if data[6] && data[7]
  710.   end
  711.   #--------------------------------------------------------------------------
  712.   # ● 透明度操作初期化
  713.   #--------------------------------------------------------------------------
  714.   def opacity_reset
  715.     @opacity = 255
  716.     @opacity = 0 if @battler.hidden?
  717.     @opacity_data = []
  718.   end
  719.   #--------------------------------------------------------------------------
  720.   # ● バトラーアニメ実行
  721.   #--------------------------------------------------------------------------
  722.   def battler_anime(anime_data = nil)
  723.     anime_data = @action_data.dup if anime_data == nil
  724.     @graphic_file_index = anime_data[1] if !graphic_fix
  725.     @pattern_h = anime_data[2]
  726.     @pattern_w = anime_data[3]
  727.     @pattern_h = 0 if @max_pattern_w == 1
  728.     @pattern_w = 0 if @max_pattern_h == 1
  729.     @pattern_type = anime_data[4]
  730.     @pattern_time = anime_data[5]
  731.     @pattern_rest_time = anime_data[5]
  732.     @pattern_count = 0
  733.     @pattern_kind = 1
  734.     @pattern_kind = -1 if @pattern_type < 0
  735.     @pattern_kind = 0 if @pattern_type == 0
  736.     @sx = (@graphic_index % 4 * @max_pattern_w + @pattern_w) * @cw
  737.     @sy = (@graphic_index / 4 * @max_pattern_h + @pattern_h) * @ch
  738.     @z_plus = anime_data[6]
  739.     @wait = set_anime_wait if anime_data[7]
  740.     @shadow_visible = anime_data[8]
  741.     weapon_anime(anime_data)
  742.   end
  743.   #--------------------------------------------------------------------------
  744.   # ● アニメウエイト計算
  745.   #--------------------------------------------------------------------------
  746.   def set_anime_wait
  747.     if @pattern_type > 0
  748.       pattern_time_a = @max_pattern_w - @pattern_w.abs
  749.     elsif @pattern_type < 0
  750.       pattern_time_a = @pattern_w.abs + 1
  751.     else
  752.       return @pattern_time if @pattern_type == 0
  753.     end
  754.     case @pattern_type
  755.     when 1,-1, 3,-3
  756.       return pattern_time_a * @pattern_time
  757.     when 2,-2, 4,-4
  758.       return pattern_time_a * @pattern_time + (@max_pattern_w - 2) * @pattern_time
  759.     end
  760.   end  
  761.   #--------------------------------------------------------------------------
  762.   # ● 移動実行
  763.   #--------------------------------------------------------------------------
  764.   def move
  765.     @move_targets = N03.get_targets(@action_data[1].abs, @battler)
  766.     return if @move_targets == []
  767.     @move_targets = [@battler] if @action_data[1].abs == 7
  768.     @move_x = @action_data[2] * 100 * N03.mirror_num(@mirror)
  769.     @move_y = @action_data[3] * 100
  770.     @move_h = @action_data[4] * 100 if @action_data[4] != nil
  771.     @move_h = nil if @action_data[4] == nil
  772.     battler_anime(N03::ACTION[@action_data[8]].dup) if N03::ACTION[@action_data[8]] != nil
  773.     @horming_move = true
  774.     @horming_move = false if @action_data[1] < 0 or @action_data[1].abs == 7
  775.     target_position_set
  776.     target_position = [@target_x, @target_y, @target_z]
  777.     distanse_move = @action_data[5] > 0
  778.     @move_time = N03.distanse_calculation(@action_data[5].abs, target_position, [@x, @y, @z], distanse_move)
  779.     @wait = @move_time
  780.     curve
  781.     jump
  782.     @move_time = 1 if @move_time == 0
  783.     @horming_move = false if !@move_targets or @move_targets.include?(@battler)
  784.     update_move if @move_time == 1
  785.   end  
  786.   #--------------------------------------------------------------------------
  787.   # ● カーブ実行
  788.   #--------------------------------------------------------------------------
  789.   def curve
  790.     @c = 0
  791.     return if @action_data[6] == 0
  792.     @curve = N03.parabola([@action_data[6], -@action_data[6]], @move_time, 100, 4)
  793.   end  
  794.   #--------------------------------------------------------------------------
  795.   # ● ジャンプ実行
  796.   #--------------------------------------------------------------------------
  797.   def jump
  798.     convert_jump
  799.     return if @action_data[7] == [0,0]
  800.     @jump = N03.parabola(@action_data[7].dup, @move_time, 100)
  801.   end  
  802.   #--------------------------------------------------------------------------
  803.   # ● J座標(ジャンプ高度)をH座標に変換
  804.   #--------------------------------------------------------------------------
  805.   def convert_jump
  806.     @h += @j
  807.     @j = 0
  808.     @jump = []
  809.   end  
  810.   #--------------------------------------------------------------------------
  811.   # ● データベース戦闘アニメ実行
  812.   #--------------------------------------------------------------------------
  813.   def battle_anime
  814.     data = @action_data.dup
  815.     targets = N03.get_targets(data[2], @battler)
  816.     return if targets == []
  817.     data[8] = !data[8] if @mirror
  818.     @set_damage           = data[5]
  819.     @damage_anime_data[0] = N03.get_attack_anime_id(data[1], @battler)
  820.     @damage_anime_data[1] = data[8]
  821.     @damage_anime_data[2] = data[7]
  822.     @damage_anime_data[3] = data[6]
  823.     @damage_anime_data[4] = data[9]
  824.     @wait = N03.get_anime_time(@damage_anime_data[0]) - 2 if data[4]
  825.     return if @set_damage
  826.     for target in targets do display_anime(targets, target, data) end
  827.   end
  828.   #--------------------------------------------------------------------------
  829.   # ● 武器アニメ開始
  830.   #--------------------------------------------------------------------------
  831.   def weapon_anime(anime_data)
  832.     @weapon_end = true
  833.     for i in 9...anime_data.size
  834.       set_effect_data(anime_data[i]) if anime_data[i] != ""
  835.     end
  836.   end
  837.   #--------------------------------------------------------------------------
  838.   # ● アニメ飛ばし開始
  839.   #--------------------------------------------------------------------------
  840.   def move_anime
  841.     @m_a_starter = []
  842.     @m_a_targets = []
  843.     starters = N03.get_targets(@action_data[2], @battler)
  844.     targets = N03.get_targets(@action_data[3], @battler)
  845.     return if starters == [] or targets == []
  846.     single_start = true if starters != nil && @action_data[2] < 0
  847.     single_start = true if @action_data[1][0] != 0 && $data_animations[N03.get_attack_anime_id(@action_data[1][0], @battler)].position == 3
  848.     starters = [starters[0]] if single_start
  849.     single_end = true if targets != nil && @action_data[3] < 0
  850.     single_end = true if @action_data[1][1] != 0 && $data_animations[N03.get_attack_anime_id(@action_data[1][1], @battler)].position == 3
  851.     targets = [targets[0]] if single_end
  852.     se_flag = true
  853.     for starter in starters
  854.       for target in targets
  855.         data = @action_data.dup
  856.         data[17] = se_flag
  857.         @effect_data.push(data)
  858.         @m_a_targets.push(target)
  859.         @m_a_starter.push(starter)
  860.         se_flag = false
  861.       end
  862.     end  
  863.   end
  864.   #--------------------------------------------------------------------------
  865.   # ● スプライトセット通信
  866.   #--------------------------------------------------------------------------
  867.   def set_effect_data(data = @action)
  868.     action_data = N03::ACTION[data]
  869.     return if action_data == nil
  870.     @effect_data.push(action_data.dup)
  871.   end
  872.   #--------------------------------------------------------------------------
  873.   # ● 戦闘シーン通信のデータを格納
  874.   #--------------------------------------------------------------------------
  875.   def set_play_data(data = @action_data)
  876.     @play_data = data.dup
  877.   end
  878.   #--------------------------------------------------------------------------
  879.   # ● 戦闘アニメの表示
  880.   #--------------------------------------------------------------------------
  881.   def display_anime(targets, target, data)
  882.     return if !N03.first_of_all_screen_anime(data[1], target, targets)
  883.     target.animation_id         = N03.get_attack_anime_id(data[1], @battler)
  884.     target.animation_mirror     = data[8]
  885.     target.sv.anime_horming     = data[3]
  886.     target.sv.anime_camera_zoom = data[6]
  887.     target.sv.anime_no_mirror   = data[7]
  888.     target.sv.anime_plus_z      = data[9]
  889.   end
  890.   #--------------------------------------------------------------------------
  891.   # ● 戦闘アニメ拡張データの初期化
  892.   #--------------------------------------------------------------------------
  893.   def reset_anime_data
  894.     @anime_no_mirror = false
  895.     @anime_horming = false
  896.     @anime_camera_zoom = false
  897.     @timing_targets = []
  898.     @anime_plus_z = true
  899.   end  
  900.   #--------------------------------------------------------------------------
  901.   # ● カメラワーク
  902.   #--------------------------------------------------------------------------
  903.   def camera
  904.     data = @action_data.dup
  905.     N03.camera(@battler, data)
  906.     @wait = data[4] if data[5]
  907.   end  
  908.   #--------------------------------------------------------------------------
  909.   # ● 画面のシェイク
  910.   #--------------------------------------------------------------------------
  911.   def shake
  912.     data = @action_data.dup
  913.     $sv_camera.shake(data[1], data[2], data[3])
  914.     @wait = data[3] if data[4]
  915.   end
  916.   #--------------------------------------------------------------------------
  917.   # ● 画面色調変更
  918.   #--------------------------------------------------------------------------
  919.   def color_effect
  920.     case @action_data[1]
  921.     when 0,1,2,3,4,5
  922.       targets = N03.get_targets(@action_data[1], @battler)
  923.     when 6
  924.       screen = true
  925.     when 7
  926.       targets = [@battler] + @target_battler
  927.     when 8
  928.       screen = true
  929.       targets = $game_troop.members + $game_party.battle_members - [@battler]
  930.     when 9
  931.       screen = true
  932.       targets = $game_troop.members + $game_party.battle_members - [@battler] - @target_battler
  933.     when 10
  934.       screen = true
  935.       targets = $game_troop.members + $game_party.battle_members
  936.     end
  937.     return if screen == nil && targets == []
  938.     for target in targets do target.sv.color_set = @action_data[2] end if targets
  939.     @wait = @action_data[2][4] if @action_data[3]
  940.     return if !screen
  941.     $sv_camera.color_set[1] = @action_data[2]
  942.     $sv_camera.color_set[2] = @action_data[2]
  943.   end  
  944.   #--------------------------------------------------------------------------
  945.   # ● トランジション
  946.   #--------------------------------------------------------------------------
  947.   def transition
  948.     $sv_camera.perform_transition(@action_data)
  949.   end  
  950.   #--------------------------------------------------------------------------
  951.   # ● ふきだしアニメ表示
  952.   #--------------------------------------------------------------------------
  953.   def balloon_anime
  954.     @balloon_data = @action_data.dup
  955.   end  
  956.   #--------------------------------------------------------------------------
  957.   # ● ピクチャ表示
  958.   #--------------------------------------------------------------------------
  959.   def picture_set
  960.     @picture = true
  961.     set_effect_data
  962.   end
  963.   #--------------------------------------------------------------------------
  964.   # ● ステート操作
  965.   #--------------------------------------------------------------------------
  966.   def state_set
  967.     targets = N03.get_targets(@action_data[1], @battler)
  968.     return if targets == []
  969.     case @action_data[2]
  970.     when 1 ; targets = [targets[rand(targets.size)]]
  971.     when 2 ; targets -= @battler if targets.include?(@battler)
  972.     end
  973.     for target in targets
  974.       for id in @action_data[4]
  975.         target.add_state(id) if @action_data[3] == "+"
  976.         target.remove_state(id) if @action_data[3] == "-"
  977.       end
  978.     end
  979.   end
  980.   #--------------------------------------------------------------------------
  981.   # ● FPS変更
  982.   #--------------------------------------------------------------------------
  983.   def fps
  984.     Graphics.frame_rate = @action_data[1]
  985.     start_action
  986.   end
  987.   #--------------------------------------------------------------------------
  988.   # ● バトラー画像変更の場合
  989.   #--------------------------------------------------------------------------
  990.   def graphics_change
  991.     @graphics_change = true
  992.     return @battler.graphics_change(@action_data[3]) if [email protected]?
  993.     @pre_change_data = [@battler.character_name, @battler.character_index, @battler.face_name, @battler.face_index] if @pre_change_data == nil && !@action_data[1]
  994.     if @action_data[4] == []
  995.       face_name = @battler.face_name
  996.       face_index = @battler.face_index
  997.     else
  998.       face_name = @action_data[4][1]
  999.       face_index = @action_data[4][0]
  1000.     end
  1001.     @battler.set_graphic(@action_data[3], @action_data[2], face_name, face_index)
  1002.   end
  1003.   #--------------------------------------------------------------------------
  1004.   # ● スキル派生
  1005.   #--------------------------------------------------------------------------
  1006.   def derivating_skill
  1007.     # 未修得スキルは派生不可なら
  1008.     return if !@action_data[1] && [email protected]_learn?($data_skills[@action_data[3]])
  1009.     # コスト不足は派生不可なら
  1010.     return if !@action_data[2] && [email protected]_cost_payable?($data_skills[@action_data[3]])
  1011.     # 派生
  1012.     @derivation_skill_id = @action_data[3]
  1013.     # 以降のアクションをキャンセル
  1014.     @full_action = []
  1015.   end
  1016.   #--------------------------------------------------------------------------
  1017.   # ● BGM/BGS/SE演奏
  1018.   #--------------------------------------------------------------------------
  1019.   def sound
  1020.     pitch = @action_data[2]
  1021.     vol   = @action_data[3]
  1022.     name  = @action_data[4]
  1023.     case @action_data[1]
  1024.     when "se"
  1025.       Audio.se_play("Audio/SE/" + name, vol, pitch)
  1026.     when "bgm"
  1027.       # 名前指定のない場合、現在のBGMを変えないように
  1028.       name = RPG::BGM.last.name if @action_data[4] == ""
  1029.       Audio.bgm_play("Audio/BGM/" + name, vol, pitch)
  1030.     when "bgs"
  1031.       name = RPG::BGS.last.name if @action_data[4] == ""
  1032.       Audio.bgs_play("Audio/BGS/" + name, vol, pitch)
  1033.     end
  1034.   end
  1035.   #--------------------------------------------------------------------------
  1036.   # ● ムービーの再生
  1037.   #--------------------------------------------------------------------------
  1038.   def movie
  1039.     Graphics.play_movie('Movies/' + @action_data[1])
  1040.   end
  1041.   #--------------------------------------------------------------------------
  1042.   # ● ゲームスイッチ操作
  1043.   #--------------------------------------------------------------------------
  1044.   def switches
  1045.     for id in @action_data[1]
  1046.       $game_switches[id] = true if id > 0
  1047.       $sv_camera.switches[id.abs] = true  if id < 0
  1048.     end
  1049.     for id in @action_data[2]
  1050.       $game_switches[id] = false if id > 0
  1051.       $sv_camera.switches[id.abs] = false  if id < 0
  1052.     end
  1053.     $sv_camera.program_check
  1054.   end
  1055.   #--------------------------------------------------------------------------
  1056.   # ● ゲーム変数操作
  1057.   #--------------------------------------------------------------------------
  1058.   def variable
  1059.     # オペランドチェック
  1060.     operand = @action_data[3]
  1061.     operand = $game_variables[@action_data[3].abs] if @action_data[3] < 0
  1062.     # 変数操作で分岐
  1063.     case @action_data[2]
  1064.     when 0 ; $game_variables[@action_data[1]] = operand  # 代入
  1065.     when 1 ; $game_variables[@action_data[1]] += operand # 加算
  1066.     when 2 ; $game_variables[@action_data[1]] -= operand # 減算
  1067.     when 3 ; $game_variables[@action_data[1]] *= operand # 乗算
  1068.     when 4 ; $game_variables[@action_data[1]] /= operand # 除算
  1069.     when 5 ; $game_variables[@action_data[1]] %= operand # 剰余
  1070.     end
  1071.   end  
  1072.   #--------------------------------------------------------------------------
  1073.   # ● 条件分岐 (ゲームスイッチ)
  1074.   #--------------------------------------------------------------------------
  1075.   def nece_1
  1076.     judgment = $game_switches[@action_data[1]] == @action_data[2] if @action_data[1] > 0
  1077.     judgment = $sv_camera.switches[@action_data[1].abs] == @action_data[2] if @action_data[1] < 0
  1078.     action_diverging(judgment, @action_data[3])
  1079.   end  
  1080.   #--------------------------------------------------------------------------
  1081.   # ● 条件分岐 (ゲーム変数)
  1082.   #--------------------------------------------------------------------------
  1083.   def nece_2
  1084.     variable = $game_variables[@action_data[1]]
  1085.     num = @action_data[2]
  1086.     num = $game_variables[@action_data[2].abs] if num < 0
  1087.     case @action_data[3]
  1088.     when 0 ; judgment = variable == num
  1089.     when 1 ; judgment = variable < num
  1090.     when 2 ; judgment = variable > num
  1091.     end  
  1092.     action_diverging(judgment, @action_data[4])
  1093.   end  
  1094.   #--------------------------------------------------------------------------
  1095.   # ● 条件分岐 (ステート)
  1096.   #--------------------------------------------------------------------------
  1097.   def nece_3
  1098.     targets = N03.get_targets(@action_data[1], @battler)
  1099.     return if targets == []
  1100.     member_num = @action_data[4]
  1101.     member_num = targets.size if @action_data[4] == 0 && targets.size > 1
  1102.     hit_count = 0
  1103.     miss_count = 0
  1104.     for target in targets
  1105.       hit_count += 1 if target.state?(@action_data[2])
  1106.       miss_count += 1 if !target.state?(@action_data[2])
  1107.     end
  1108.     case @action_data[3]
  1109.     when 0 ; judgment = hit_count >= member_num
  1110.     when 1 ; judgment = miss_count >= member_num
  1111.     end
  1112.     action_diverging(judgment, @action_data[5])
  1113.   end  
  1114.   #--------------------------------------------------------------------------
  1115.   # ● 条件分岐 (スキル)
  1116.   #--------------------------------------------------------------------------
  1117.   def nece_4
  1118.     targets = N03.get_targets(@action_data[1], @battler)
  1119.     return if targets == []
  1120.     member_num = @action_data[4]
  1121.     member_num = targets.size if @action_data[4] == 0 && targets.size > 1
  1122.     hit_count = 0
  1123.     miss_count = 0
  1124.     for target in targets
  1125.       hit_count += 1 if target.skill_learn?($data_skills[@action_data[2]]) && target.skill_conditions_met?($data_skills[@action_data[2]])
  1126.       miss_count += 1 if !target.skill_learn?($data_skills[@action_data[2]]) or !target.skill_conditions_met?($data_skills[@action_data[2]])
  1127.     end
  1128.     case @action_data[3]
  1129.     when 0 ; judgment = hit_count >= member_num
  1130.     when 1 ; judgment = miss_count >= member_num
  1131.     end
  1132.     action_diverging(judgment, @action_data[5])
  1133.   end  
  1134.   #--------------------------------------------------------------------------
  1135.   # ● 条件分岐 (パラメータ)
  1136.   #--------------------------------------------------------------------------
  1137.   def nece_5
  1138.     targets = N03.get_targets(@action_data[1], @battler)
  1139.     return if targets == []
  1140.     member_num = @action_data[5]
  1141.     member_num = targets.size if @action_data[5] == 0 && targets.size > 1
  1142.     hit_count = 0
  1143.     for target in targets
  1144.       hit_count += 1 if target.comparison_parameter([@action_data[2],@action_data[3],@action_data[4]])
  1145.     end
  1146.     judgment = hit_count >= member_num
  1147.     action_diverging(judgment, @action_data[6])
  1148.   end  
  1149.   #--------------------------------------------------------------------------
  1150.   # ● 条件分岐 (装備)
  1151.   #--------------------------------------------------------------------------
  1152.   def nece_6
  1153.     targets = N03.get_targets(@action_data[1], @battler)
  1154.     return if targets == []
  1155.     member_num = @action_data[5]
  1156.     member_num = targets.size if @action_data[5] == 0 && targets.size > 1
  1157.     hit_count = 0
  1158.     miss_count = 0
  1159.     for target in targets
  1160.       hit_count += 1 if target.comparison_equip([@action_data[2],@action_data[3]])
  1161.       miss_count += 1 if !target.comparison_equip([@action_data[2],@action_data[3]])
  1162.     end
  1163.     case @action_data[4]
  1164.     when 0 ; judgment = hit_count >= member_num
  1165.     when 1 ; judgment = miss_count >= member_num
  1166.     end
  1167.     action_diverging(judgment, @action_data[6])
  1168.   end  
  1169.   #--------------------------------------------------------------------------
  1170.   # ● 条件分岐 (スクリプト)
  1171.   #--------------------------------------------------------------------------
  1172.   def nece_7
  1173.     judgment = eval(@action_data[2])
  1174.     action_diverging(judgment, @action_data[1])
  1175.   end  
  1176.   #--------------------------------------------------------------------------
  1177.   # ● アクション分岐  
  1178.   #--------------------------------------------------------------------------
  1179.   def action_diverging(judgment, kind)
  1180.     result = 0
  1181.     if judgment
  1182.       result = 1 if kind == 1
  1183.       result = 2 if kind == 2
  1184.     else
  1185.       result = 1 if kind == 0
  1186.     end
  1187.     # フルアクション終了
  1188.     return @full_action = []  if result == 2
  1189.     # 次のアクションを除去
  1190.     @full_action.shift if result == 1
  1191.     set_action
  1192.     # 次のアクションを実行
  1193.     @action_data = N03::ACTION[@action]
  1194.     next_action
  1195.   end
  1196.   #--------------------------------------------------------------------------
  1197.   # ● セカンドターゲット操作
  1198.   #--------------------------------------------------------------------------
  1199.   def second_targets_set
  1200.     targets = N03.get_targets(@action_data[1], @battler)
  1201.     for target in targets
  1202.       targets.delete(target) if @action_data[2][1] == 1 && target.index != @action_data[2][0]
  1203.       targets.delete(target) if @action_data[2][1] == 2 && target.index == @action_data[2][0].abs
  1204.       targets.delete(target) if @action_data[3] > 0 && target.id != @action_data[3]
  1205.       targets.delete(target) if @action_data[3] < 0 && target.id == @action_data[3].abs
  1206.       targets.delete(target) if @action_data[4] > 0 && !target.state?(@action_data[4])
  1207.       targets.delete(target) if @action_data[4] < 0 && target.state?(@action_data[4].abs)
  1208.       targets.delete(target) if @action_data[5] > 0 && !target.skill_conditions_met?($data_skills[@action_data[5]])
  1209.       targets.delete(target) if @action_data[5] < 0 && target.skill_conditions_met?($data_skills[@action_data[5].abs])
  1210.       targets.delete(target) if !target.comparison_parameter(@action_data[6])
  1211.       targets.delete(target) if !@action_data[7][1].include?(0) && !target.comparison_equip(@action_data[7])
  1212.     end
  1213.     return @second_targets = [] if targets.size == 0
  1214.     case @action_data[8]
  1215.     when 1 ; targets = [targets[rand(targets.size)]]
  1216.     when 2 ; targets.delete(@battler)
  1217.     end
  1218.     return @second_targets = [] if targets.size == 0
  1219.     @second_targets = targets
  1220.     case @action_data[9]
  1221.     when 0 ; return
  1222.     when 1 ; set_play_data(["second_targets_set"])
  1223.     when 2 ; set_play_data(["targets_set"])
  1224.     end
  1225.     @wait += 1
  1226.   end
  1227.   #--------------------------------------------------------------------------
  1228.   # ● コモンイベント呼び出し
  1229.   #--------------------------------------------------------------------------
  1230.   def call_common_event
  1231.     $game_temp.reserve_common_event(@action_data[1])
  1232.     $sv_camera.event = true
  1233.     @event_fix = @action_data[2]
  1234.   end
  1235.   #--------------------------------------------------------------------------
  1236.   # ● ダメージアニメ
  1237.   #--------------------------------------------------------------------------
  1238.   def damage_anime(delay_time = 12)
  1239.     anime(N03.get_attack_anime_id(-3, @battler), wait = true)
  1240.     action_play
  1241.     @wait -= delay_time
  1242.     @full_action.unshift("eval('@damage_anime_data = []
  1243.     @set_damage = true')")
  1244.   end
  1245.   #--------------------------------------------------------------------------
  1246.   # ● 通常コラプス
  1247.   #--------------------------------------------------------------------------
  1248.   def normal_collapse
  1249.     @collapse = true
  1250.     return
  1251.   end
  1252.   #--------------------------------------------------------------------------
  1253.   # ● 初期位置変更
  1254.   #--------------------------------------------------------------------------
  1255.   def change_base_position
  1256.     @base_x = @x
  1257.     @base_y = @y
  1258.     @base_h = @h
  1259.   end  
  1260.   #--------------------------------------------------------------------------
  1261.   # ● 強制アクション実行
  1262.   #--------------------------------------------------------------------------
  1263.   def force_act
  1264.     target(@full_action.shift)
  1265.   end
  1266.   #--------------------------------------------------------------------------
  1267.   # ● 強制アクション実行 (セカンドターゲット)
  1268.   #--------------------------------------------------------------------------
  1269.   def force_act2
  1270.     target2(@full_action.shift)
  1271.   end
  1272.   #--------------------------------------------------------------------------
  1273.   # ● 個別処理開始
  1274.   #--------------------------------------------------------------------------
  1275.   def individual_start
  1276.     @individual_targets = @target_battler.dup
  1277.     @remain_targets = @target_battler.dup
  1278.     @target_battler = [@individual_targets[0]]
  1279.     # リピート部分のアクションを保持
  1280.     @individual_act = @full_action.dup
  1281.   end
  1282.   #--------------------------------------------------------------------------
  1283.   # ● 個別処理終了
  1284.   #--------------------------------------------------------------------------
  1285.   def individual_end
  1286.     @individual_targets.shift
  1287.     for target in @individual_targets
  1288.       @individual_targets.shift if target.dead?
  1289.     end
  1290.     # ターゲットが残っているなら行動リピート
  1291.     return @target_battler = @remain_targets if @individual_targets.size == 0
  1292.     @full_action = @individual_act.dup
  1293.     @target_battler = [@individual_targets[0]]
  1294.   end
  1295.   #--------------------------------------------------------------------------
  1296.   # ● ループ開始
  1297.   #--------------------------------------------------------------------------
  1298.   def loop_start
  1299.     # ループ部分のアクションを保持
  1300.     @loop_act = @full_action.dup
  1301.   end
  1302.   #--------------------------------------------------------------------------
  1303.   # ● ループ終了
  1304.   #--------------------------------------------------------------------------
  1305.   def loop_end
  1306.     # 行動リピート
  1307.     @full_action = @loop_act.dup if @loop_act != []
  1308.   end
  1309.   #--------------------------------------------------------------------------
  1310.   # ● 次の行動者へ移行
  1311.   #--------------------------------------------------------------------------
  1312.   def next_battler
  1313.     @action_end = true
  1314.     @active = false
  1315.   end
  1316.   #--------------------------------------------------------------------------
  1317.   # ● 画像変更フラグ
  1318.   #--------------------------------------------------------------------------
  1319.   def set_change
  1320.     @change_up = true
  1321.   end
  1322.   #--------------------------------------------------------------------------
  1323.   # ● 戦闘シーン通信
  1324.   #--------------------------------------------------------------------------
  1325.   def play_data
  1326.     data = @play_data
  1327.     @play_data = []
  1328.     return data
  1329.   end
  1330.   #--------------------------------------------------------------------------
  1331.   # ● ショートカットコマンド
  1332.   #--------------------------------------------------------------------------
  1333.   def anime(anime_id, wait = true)
  1334.     @action_data = ["anime",anime_id,1,false,wait,false,true,false]
  1335.   end
  1336.   def anime_me(anime_id, wait = true)
  1337.     @action_data = ["anime",anime_id,0,false,wait,false,true,false]
  1338.   end
  1339.   def se(file, pitch = 100)
  1340.     @action_data = ["sound",  "se", pitch, 100, file]
  1341.   end
  1342.   def target(act)
  1343.     for target in @target_battler do target.sv.force_action = act end
  1344.   end
  1345.   def target2(act)
  1346.     for target in @second_targets do target.sv.force_action = act end
  1347.   end
  1348.   def delay(time)
  1349.     @wait = @battler.index * time
  1350.   end
  1351.   #--------------------------------------------------------------------------
  1352.   # ● バトラーのIDを取得
  1353.   #--------------------------------------------------------------------------
  1354.   def id
  1355.     return @battler.id if @battler.actor?
  1356.     return [email protected]
  1357.   end
  1358.   #--------------------------------------------------------------------------
  1359.   # ● 被クリティカルフラグを取得
  1360.   #--------------------------------------------------------------------------
  1361.   def critical?
  1362.     return @battler.result.critical
  1363.   end
  1364.   #--------------------------------------------------------------------------
  1365.   # ● 被回復フラグを取得
  1366.   #--------------------------------------------------------------------------
  1367.   def recovery?
  1368.     recovery = false
  1369.     recovery = true if @battler.result.hp_damage < 0
  1370.     recovery = true if @battler.result.mp_damage < 0
  1371.     recovery = true if @battler.result.tp_damage < 0
  1372.     return recovery
  1373.   end
  1374.   #--------------------------------------------------------------------------
  1375.   # ● 被スキルIDを取得
  1376.   #--------------------------------------------------------------------------
  1377.   def damage_skill_id
  1378.     return @damage_skill_id
  1379.   end
  1380.   #--------------------------------------------------------------------------
  1381.   # ● 被アイテムIDを取得
  1382.   #--------------------------------------------------------------------------
  1383.   def damage_item_id
  1384.     return @damage_item_id
  1385.   end
  1386.   #--------------------------------------------------------------------------
  1387.   # ● 装備武器を取得
  1388.   #--------------------------------------------------------------------------
  1389.   def weapon_id
  1390.     return 0 if [email protected][0]
  1391.     return @battler.weapons[0].id
  1392.   end
  1393.   #--------------------------------------------------------------------------
  1394.   # ● 装備武器のタイプを取得
  1395.   #--------------------------------------------------------------------------
  1396.   def weapon_type
  1397.     return 0 if [email protected][0]
  1398.     return @battler.weapons[0].wtype_id
  1399.   end
  1400.   #--------------------------------------------------------------------------
  1401.   # ● 盾を装備しているか
  1402.   #--------------------------------------------------------------------------
  1403.   def shield?
  1404.     for armor in @battler.armors do return true if armor != nil && armor.etype_id == 1 end
  1405.     return false
  1406.   end
  1407.   #--------------------------------------------------------------------------
  1408.   # ● ダメージがあるか
  1409.   #--------------------------------------------------------------------------
  1410.   def damage_zero?
  1411.     return @battler.result.hp_damage == 0 && @battler.result.mp_damage == 0 && @battler.result.tp_damage == 0
  1412.   end
  1413.   #--------------------------------------------------------------------------
  1414.   # ● スキルIDを取得
  1415.   #--------------------------------------------------------------------------
  1416.   def skill_id
  1417.     return @counter_id if @counter_id != 0
  1418.     return 0 if @battler.current_action == nil or @battler.current_action.item == nil
  1419.     return 0 if @battler.current_action.item.is_a?(RPG::Item)
  1420.     return @battler.current_action.item.id
  1421.   end
  1422.   #--------------------------------------------------------------------------
  1423.   # ● スキルのタイプを取得
  1424.   #--------------------------------------------------------------------------
  1425.   def skill_type
  1426.     return 0 if skill_id == 0
  1427.     return $data_skills[skill_id].stype_id
  1428.   end
  1429.   #--------------------------------------------------------------------------
  1430.   # ● スキル名を取得
  1431.   #--------------------------------------------------------------------------
  1432.   def skill_name
  1433.     return "" if skill_id == 0
  1434.     return $data_skills[skill_id].name
  1435.   end
  1436.   #--------------------------------------------------------------------------
  1437.   # ● アイテムIDを取得
  1438.   #--------------------------------------------------------------------------
  1439.   def item_id
  1440.     return 0 if @battler.current_action == nil or @battler.current_action.item == nil
  1441.     return @battler.current_action.item.id
  1442.   end
  1443.   #--------------------------------------------------------------------------
  1444.   # ● 攻撃アクション
  1445.   #--------------------------------------------------------------------------
  1446.   def attack_action(item)
  1447.     return skill_action if item.is_a?(RPG::Skill)
  1448.     return item_action
  1449.   end
  1450.   #--------------------------------------------------------------------------
  1451.   # ● ダメージアクションベース
  1452.   #--------------------------------------------------------------------------
  1453.   def damage_action_base(item)
  1454.     @damage_skill_id = 0
  1455.     @damage_item_id = 0
  1456.     @damage_skill_id = item.id if item.is_a?(RPG::Skill)
  1457.     @damage_item_id = item.id if item.is_a?(RPG::Item)
  1458.   end  
  1459.   #--------------------------------------------------------------------------
  1460.   # ● ダメージアクション
  1461.   #--------------------------------------------------------------------------
  1462.   def damage_action(attacker, item)
  1463.     damage_action_base(item)
  1464.     act = damage(attacker)
  1465.     return if @active
  1466.     start_action(act) if act != nil
  1467.   end
  1468.   #--------------------------------------------------------------------------
  1469.   # ● 回避アクション
  1470.   #--------------------------------------------------------------------------
  1471.   def evasion_action(attacker, item)
  1472.     damage_action_base(item)
  1473.     act = evasion(attacker)
  1474.     return if @active
  1475.     start_action(act) if act != nil
  1476.   end
  1477.   #--------------------------------------------------------------------------
  1478.   # ● ミスアクション
  1479.   #--------------------------------------------------------------------------
  1480.   def miss_action(attacker, item)
  1481.     damage_action_base(item)
  1482.     act = miss(attacker)
  1483.     return if @active
  1484.     start_action(act) if act != nil
  1485.   end
  1486.   #--------------------------------------------------------------------------
  1487.   # ● 閃きスクリプト併用処理
  1488.   #--------------------------------------------------------------------------
  1489.   def flash_action
  1490.     return "閃き"
  1491.   end
  1492.   
  1493. end


  1494. #==============================================================================
  1495. # ■ module N03
  1496. #------------------------------------------------------------------------------
  1497. #  サイドビューバトルのモジュールです。
  1498. #==============================================================================
  1499. module N03
  1500.   #--------------------------------------------------------------------------
  1501.   # ● バトラーの敵グループを取得
  1502.   #--------------------------------------------------------------------------
  1503.   def self.get_enemy_unit(battler)
  1504.     return $game_troop if battler.actor?
  1505.     return $game_party
  1506.   end
  1507.   #--------------------------------------------------------------------------
  1508.   # ● バトラーの味方グループを取得
  1509.   #--------------------------------------------------------------------------
  1510.   def self.get_party_unit(battler)
  1511.     return $game_party if battler.actor?
  1512.     return $game_troop
  1513.   end
  1514.   #--------------------------------------------------------------------------
  1515.   # ● 戦闘アニメ時間の取得
  1516.   #--------------------------------------------------------------------------
  1517.   def self.get_anime_time(anime_id)
  1518.     return 0 if anime_id <= 0
  1519.     return $data_animations[anime_id].frame_max * 4
  1520.   end
  1521.   #--------------------------------------------------------------------------
  1522.   # ● 攻撃アニメの取得
  1523.   #--------------------------------------------------------------------------
  1524.   def self.get_attack_anime_id(kind, battler)
  1525.     return $data_skills[battler.sv.counter_id].animation_id if kind == -3 && battler.sv.counter_id != 0
  1526.     case kind
  1527.     when -1 ; anime_id = battler.atk_animation_id1
  1528.     when -2 ; anime_id = battler.atk_animation_id2
  1529.     when -3
  1530.       if battler.current_action != nil
  1531.         anime_id = battler.current_action.item.animation_id if battler.current_action.item != nil
  1532.       end
  1533.     else    ; anime_id = kind
  1534.     end
  1535.     case anime_id
  1536.     when -1 ; anime_id = battler.atk_animation_id1
  1537.     when -2 ; anime_id = battler.atk_animation_id2
  1538.     end
  1539.     return anime_id if anime_id
  1540.     return 0
  1541.   end  
  1542.   #--------------------------------------------------------------------------
  1543.   # ● 戦闘アニメデータをセット
  1544.   #--------------------------------------------------------------------------
  1545.   def self.set_damage_anime_data(targets, target, data)
  1546.     return if !first_of_all_screen_anime(data[0], target, targets)
  1547.     target.animation_id         = data[0]
  1548.     target.animation_mirror     = data[1]
  1549.     target.sv.anime_no_mirror   = data[2]
  1550.     target.sv.anime_camera_zoom = data[3]
  1551.     target.sv.anime_plus_z      = data[4]
  1552.   end   
  1553.   #--------------------------------------------------------------------------
  1554.   # ● ターゲットの取得
  1555.   #--------------------------------------------------------------------------
  1556.   def self.get_targets(kind, battler)
  1557.     case kind.abs
  1558.     when 0 ; return [battler].dup
  1559.     when 1 ; return battler.sv.target_battler.dup
  1560.     when 2 ; return get_enemy_unit(battler).members.dup
  1561.     when 3 ; return get_party_unit(battler).members.dup
  1562.     when 4 ; return $game_troop.members.dup + $game_party.battle_members.dup
  1563.     when 5 ; return battler.sv.second_targets.dup
  1564.     end
  1565.   end  
  1566.   #--------------------------------------------------------------------------
  1567.   # ● ターゲットの座標を取得
  1568.   #--------------------------------------------------------------------------
  1569.   def self.get_targets_position(targets, horming, m_a = nil)
  1570.     return [0,0,0] if targets == nil && !$sv_camera.mirror
  1571.     return [Graphics.width,0,0] if targets == nil && $sv_camera.mirror
  1572.     x = y = h = 0
  1573.     for i in 0...targets.size
  1574.       x += targets[i].sv.base_x if !horming
  1575.       y += targets[i].sv.base_y if !horming
  1576.       h += targets[i].sv.base_h if !horming
  1577.       x += targets[i].sv.x if horming
  1578.       y += targets[i].sv.y if horming
  1579.       h += targets[i].sv.h if horming
  1580.       y -= targets[i].sv.ch * 100 if m_a == 0
  1581.       y -= targets[i].sv.ch * 50 if m_a == 1
  1582.     end
  1583.     return [x / targets.size, y / targets.size, h / targets.size]
  1584.   end
  1585.   #--------------------------------------------------------------------------
  1586.   # ● 速度を時間に変換
  1587.   #--------------------------------------------------------------------------
  1588.   def self.distanse_calculation(time, target_position, self_position, distanse_move)
  1589.     return time if !distanse_move
  1590.     distanse_x = self_position[0] - target_position[0]
  1591.     distanse_x = target_position[0] - self_position[0] if target_position[0] > self_position[0]
  1592.     distanse_y = self_position[1] - target_position[1]
  1593.     distanse_y = target_position[1] - self_position[1] if target_position[1] > self_position[1]
  1594.     if self_position[2] != nil && target_position[2] != nil
  1595.       distanse_h = self_position[2] - target_position[2]
  1596.       distanse_h = target_position[2] - self_position[2] if target_position[2] > self_position[2]
  1597.     else
  1598.       distanse_h = 0
  1599.     end
  1600.     distanse = [distanse_x, distanse_y, distanse_h].max
  1601.     return distanse / (time * 100) + 1
  1602.   end
  1603.   #--------------------------------------------------------------------------
  1604.   # ● 放物線移動計算
  1605.   #--------------------------------------------------------------------------
  1606.   def self.parabola(data, time, size, type = 1)
  1607.     move_data = data
  1608.     move_data[0] *= size
  1609.     move_data[1] *= size
  1610.     move = []
  1611.     move_d = []
  1612.     for i in 0...time / 2
  1613.       move[i] = move_data[0]
  1614.       move_d[i] = move_data[1]
  1615.       move_data[0] = move_data[0] * type / (1 + type)
  1616.       move_data[1] = move_data[1] * type / (1 + type)
  1617.     end
  1618.     move = move + move_d.reverse!
  1619.     move.reverse!
  1620.     adjust = move.inject(0) {|result, item| result + item }
  1621.     move[move.size - 1] += adjust if data[0] == data[1] && adjust != 0
  1622.     move.unshift(0) if time % 2 != 0
  1623.     return move
  1624.   end
  1625.   #--------------------------------------------------------------------------
  1626.   # ● 反転値
  1627.   #--------------------------------------------------------------------------
  1628.   def self.mirror_num(mirror)
  1629.     return 1 if !mirror
  1630.     return -1
  1631.   end  
  1632.   #--------------------------------------------------------------------------
  1633.   # ● カメラワーク
  1634.   #--------------------------------------------------------------------------
  1635.   def self.camera(battler, data)
  1636.     battler = $game_party.battle_members[0] if !battler
  1637.     cx = data[2][0] * 100
  1638.     cy = data[2][1] * 100
  1639.     return $sv_camera.move(cx, cy, data[3], data[4], true) if data[1] == 6
  1640.     targets = self.get_targets(data[1], battler)
  1641.     return if targets == nil or targets == []
  1642.     position = self.get_targets_position(targets, true)
  1643.     $sv_camera.move(position[0], position[1] - position[2], data[3], data[4], false)
  1644.   end
  1645.   #--------------------------------------------------------------------------
  1646.   # ● コラプス禁止
  1647.   #--------------------------------------------------------------------------
  1648.   def self.immortaling
  1649.     # 全員に不死身付与
  1650.     for member in $game_party.battle_members + $game_troop.members
  1651.       # イベント操作等で不死身設定になっていたら解除を無効にするフラグを立てる
  1652.       member.sv.immortal = true if member.state?(N03::IMMORTAL_ID)
  1653.       member.add_state(N03::IMMORTAL_ID)
  1654.     end
  1655.     return true
  1656.   end  
  1657.   #--------------------------------------------------------------------------
  1658.   # ● コラプス許可
  1659.   #--------------------------------------------------------------------------
  1660.   def self.unimmortaling
  1661.     # 全員の不死身化解除(イベント等で不死身設定がされていれば除く)
  1662.     for member in $game_party.battle_members + $game_troop.members
  1663.       next if member.dead?
  1664.       # 不死身ステートが行動中に解除されていた場合、解除無効を解除
  1665.       member.sv.immortal = false if !member.state?(N03::IMMORTAL_ID) && member.sv.immortal
  1666.       next member.sv.immortal = false if member.sv.immortal
  1667.       member.remove_state(N03::IMMORTAL_ID)
  1668.       next if member.hp != 0
  1669.       member.add_state(1)
  1670.       member.perform_collapse_effect
  1671.       member.sv.action_terminate
  1672.     end
  1673.     return false
  1674.   end  
  1675.   #--------------------------------------------------------------------------
  1676.   # ● スキル派生
  1677.   #--------------------------------------------------------------------------
  1678.   def self.derived_skill(battler)
  1679.     battler.force_action(battler.sv.derivation_skill_id, -2)
  1680.     BattleManager.unshift_action_battlers(battler)
  1681.   end
  1682.   #--------------------------------------------------------------------------
  1683.   # ● ダメージの作成
  1684.   #--------------------------------------------------------------------------
  1685.   def self.set_damage(battler, hp_damage, mp_damage)
  1686.     battler.result.hp_damage = hp_damage
  1687.     battler.result.mp_damage = mp_damage
  1688.   end
  1689.   #--------------------------------------------------------------------------
  1690.   # ● ターゲット生死確認
  1691.   #--------------------------------------------------------------------------
  1692.   def self.targets_alive?(targets)
  1693.     return false if targets == []
  1694.     for target in targets do return true if !target.dead? end
  1695.     return false
  1696.   end
  1697.   #--------------------------------------------------------------------------
  1698.   # ● ターゲットをセカンドターゲットへ
  1699.   #--------------------------------------------------------------------------
  1700.   def self.s_targets(battler)
  1701.     battler.sv.target_battler = battler.sv.second_targets
  1702.     return battler.sv.second_targets
  1703.   end  
  1704.   #--------------------------------------------------------------------------
  1705.   # ● セカンドターゲットをターゲットへ
  1706.   #--------------------------------------------------------------------------
  1707.   def self.targets_set(battler)
  1708.     battler.sv.second_targets = battler.current_action.make_targets.compact
  1709.     battler.sv.target_battler = battler.sv.second_targets
  1710.   end  
  1711.   #--------------------------------------------------------------------------
  1712.   # ● 戦闘アニメ実行判定 (対象:画面時は最初のターゲットのみアニメ実行)
  1713.   #--------------------------------------------------------------------------
  1714.   def self.first_of_all_screen_anime(anime_id, target, targets)
  1715.     anime = $data_animations[anime_id]
  1716.     return false if !anime
  1717.     return true if anime.position != 3
  1718.     return false if anime.position == 3 && target != targets[0]
  1719.     targets.delete(target)
  1720.     target.sv.timing_targets = targets
  1721.     return true
  1722.   end
  1723.   #--------------------------------------------------------------------------
  1724.   # ● 戦闘不能付加攻撃か
  1725.   #--------------------------------------------------------------------------
  1726.   def self.dead_attack?(battler, item)
  1727.     for state in battler.atk_states
  1728.       return true if state == battler.death_state_id
  1729.     end
  1730.     for effect in item.effects
  1731.       return true if effect.code == 21 && effect.data_id == battler.death_state_id
  1732.     end
  1733.     return false
  1734.   end
  1735. end

  1736. #==============================================================================
  1737. # ■ Sprite_Weapon
  1738. #------------------------------------------------------------------------------
  1739. #  ウエポン表示用のスプライトです。
  1740. #==============================================================================
  1741. class Sprite_Weapon < Sprite_Base
  1742.   #--------------------------------------------------------------------------
  1743.   # ● 公開インスタンス変数 
  1744.   #--------------------------------------------------------------------------
  1745.   attr_reader   :index                       # ウエポン画像配列のインデックス
  1746.   attr_reader   :battler                     # 画像が参照しているバトラー
  1747.   attr_reader   :move_time                   # 画像が目標に到達するまでの時間
  1748.   attr_reader   :through                     # 貫通フラグ
  1749.   attr_reader   :action_end                  # 武器アクション終了フラグ
  1750.   attr_reader   :action_end_cancel                  # 武器アクション終了フラグ
  1751.   attr_reader   :hit_position                # 画像が目標に到達した時の座標
  1752.   attr_accessor :hit_anime_id                # 画像が目標に到達した時のアニメID
  1753.   #--------------------------------------------------------------------------
  1754.   # ● オブジェクト初期化
  1755.   #--------------------------------------------------------------------------
  1756.   def initialize(viewport, index, battler)
  1757.     super(viewport)
  1758.     @index = index
  1759.     @battler = battler
  1760.     @position_x = @position_y = 0
  1761.     @o = 0
  1762.     @real_x = @real_y = 0
  1763.     @mirror = @battler.sv.mirror
  1764.     reset
  1765.     set_action
  1766.   end
  1767.   #--------------------------------------------------------------------------
  1768.   # ● 初期化
  1769.   #--------------------------------------------------------------------------
  1770.   def reset
  1771.     @z_plus = 0
  1772.     @weapon_data = []
  1773.     @move_data = []
  1774.     @move_x = 0
  1775.     @move_y = 0
  1776.     @orbit = []
  1777.     @through = false
  1778.     @distanse_move = false
  1779.     @weapon_width = 0
  1780.     @weapon_height = 0
  1781.     @anime_time = 0
  1782.     @anime_position = 1
  1783.     @move_time = 0
  1784.     @hit_anime_id = 0
  1785.     @move_anime = true
  1786.     @action_end = false
  1787.     @action_end_cancel = false
  1788.     reset_position
  1789.   end  
  1790.   #--------------------------------------------------------------------------
  1791.   # ● アクションをセット
  1792.   #--------------------------------------------------------------------------
  1793.   def set_action
  1794.     return if @battler.sv.effect_data == []
  1795.     weapon_anime if @battler.sv.effect_data[0][0] == "wp"
  1796.     move_anime if @battler.sv.effect_data[0][0] == "m_a"
  1797.     @battler.sv.effect_data.shift
  1798.   end
  1799.   #--------------------------------------------------------------------------
  1800.   # ● 武器アニメ実行
  1801.   #--------------------------------------------------------------------------
  1802.   def weapon_anime
  1803.     @weapon_data = @battler.sv.effect_data[0].dup
  1804.     set_graphics
  1805.     set_ox
  1806.     set_weapon_move
  1807.   end
  1808.   #--------------------------------------------------------------------------
  1809.   # ● アニメ移動実行
  1810.   #--------------------------------------------------------------------------
  1811.   def move_anime
  1812.     @move_data = @battler.sv.effect_data[0].dup
  1813.     # ターゲットを取得
  1814.     @target_battler = [@battler.sv.m_a_targets.shift]
  1815.     @target_battler = N03.get_targets(@move_data[3], @battler) if @move_data[3] < 0
  1816.     set_move
  1817.     return if @move_data[16] == ""
  1818.     weapon_data = N03::ACTION[@move_data[16]]
  1819.     return if weapon_data == nil
  1820.     @weapon_data = weapon_data.dup
  1821.     set_graphics
  1822.     set_ox
  1823.     set_weapon_move
  1824.   end
  1825.   #--------------------------------------------------------------------------
  1826.   # ● 武器画像を取得
  1827.   #--------------------------------------------------------------------------  
  1828.   def set_graphics
  1829.     # 武器に依存しない画像設定がある場合
  1830.     if @weapon_data[13] != ""
  1831.       self.bitmap = Cache.character(@weapon_data[13]).dup
  1832.       @weapon_width = self.bitmap.width
  1833.       @weapon_height = self.bitmap.height
  1834.       return
  1835.     end
  1836.     # 武器を取得
  1837.     weapon = @battler.weapons[0]
  1838.     # 逆手装備を取得
  1839.     if @weapon_data[10]
  1840.       weapon = nil
  1841.       for armor in @battler.armors do break weapon = armor if armor.is_a?(RPG::Armor) && armor.etype_id == 1 end
  1842.       weapon = @battler.weapons[1] if !weapon
  1843.     end  
  1844.     # 武器がなければ処理をキャンセル
  1845.     return if weapon == nil
  1846.     # インデックスを取得
  1847.     file_index = @weapon_data[12]
  1848.     # アイコンを利用するなら
  1849.     if @weapon_data[1] == 0
  1850.       icon_index = weapon.icon_index
  1851.       self.bitmap = Cache.system("Iconset" + file_index).dup
  1852.       self.src_rect.set(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  1853.       @weapon_width = @weapon_height = 24
  1854.     # 独自画像指定
  1855.     else
  1856.       file_name = @battler.sv.weapon_graphic(weapon.id, weapon.wtype_id) if weapon.is_a?(RPG::Weapon)
  1857.       file_name = @battler.sv.shield_graphic(weapon.id, weapon.atype_id) if weapon.is_a?(RPG::Armor)
  1858.       self.bitmap = Cache.character(file_name + file_index).dup
  1859.       @weapon_width = self.bitmap.width
  1860.       @weapon_height = self.bitmap.height
  1861.       return if @weapon_data[1] == 1
  1862.       # 2003仕様の武器アニメ
  1863.       @weapon_width /= @battler.sv.max_pattern[0]
  1864.     end
  1865.   end
  1866.   #--------------------------------------------------------------------------
  1867.   # ● 画像の原点を取得
  1868.   #--------------------------------------------------------------------------  
  1869.   def set_ox
  1870.     # 反転時は設定を逆に
  1871.     if @mirror
  1872.       case @weapon_data[6]
  1873.       when 1 ; @weapon_data[6] = 2 # 左上→右上に
  1874.       when 2 ; @weapon_data[6] = 1 # 右上→左上に
  1875.       when 3 ; @weapon_data[6] = 4 # 左下→右下に
  1876.       when 4 ; @weapon_data[6] = 3 # 右下→左下に
  1877.       end
  1878.     end
  1879.     # 原点を設定
  1880.     case @weapon_data[6]
  1881.     when 0 # 中心
  1882.       self.ox = @weapon_width / 2
  1883.       self.oy = @weapon_height / 2
  1884.     when 1 # 左上
  1885.       self.ox = 0
  1886.       self.oy = 0
  1887.     when 2 # 右上
  1888.       self.ox = @weapon_width
  1889.       self.oy = 0
  1890.     when 3 # 左下
  1891.       self.ox = 0
  1892.       self.oy = @weapon_height
  1893.     when 4 # 右下
  1894.       self.ox = @weapon_width
  1895.       self.oy = @weapon_height
  1896.     when 5 # バトラーと同じ
  1897.       self.ox = @weapon_width / 2
  1898.       self.oy = @weapon_height
  1899.     end
  1900.   end  
  1901.   #--------------------------------------------------------------------------
  1902.   # ● バトラーの座標を取得
  1903.   #--------------------------------------------------------------------------  
  1904.   def set_battler_position
  1905.     @position_x = @battler.sv.x + @weapon_data[3][0] * N03.mirror_num(@mirror) * 100
  1906.     @position_y = (@battler.sv.y - @battler.sv.h - @battler.sv.j - @battler.sv.c - @battler.sv.oy_adjust) + @weapon_data[3][1] * 100
  1907.     reset_position
  1908.   end
  1909.   #--------------------------------------------------------------------------
  1910.   # ● 座標を初期化
  1911.   #--------------------------------------------------------------------------  
  1912.   def reset_position
  1913.     @real_x = @position_x / 100
  1914.     @real_y = @position_y / 100
  1915.     @real_zoom_x = 1
  1916.     @real_zoom_y = 1
  1917.   end
  1918.   #--------------------------------------------------------------------------
  1919.   # ● 戦闘アニメを表示
  1920.   #--------------------------------------------------------------------------  
  1921.   def set_animation(anime_id)
  1922.     return if $data_animations[anime_id] == nil
  1923.     @anime_position = $data_animations[anime_id].position
  1924.     @horming = true
  1925.     @horming = false if @anime_position == 3
  1926.     @anime_camera_zoom = true
  1927.     @anime_no_mirror = false
  1928.     start_animation($data_animations[anime_id], @mirror)
  1929.     timings = $data_animations[anime_id].timings
  1930.   end
  1931.   #--------------------------------------------------------------------------
  1932.   # ● ヒット時の戦闘アニメ実行
  1933.   #--------------------------------------------------------------------------  
  1934.   def set_hit_animation(position_data, hit_anime_id, target)
  1935.     return if $data_animations[hit_anime_id] == nil
  1936.     @real_x = position_data[0]
  1937.     @real_y = position_data[1]
  1938.     @position_x = position_data[0] * 100
  1939.     @position_y = position_data[1] * 100
  1940.     self.z = position_data[2]
  1941.     @z_plus = 1000
  1942.     @action_end = false
  1943.     @horming = true
  1944.     set_animation(hit_anime_id)
  1945.     @anime_time = $data_animations[hit_anime_id].frame_max * 4
  1946.     @timing_targets = [target]
  1947.     @move_time = @hit_anime_id = 0
  1948.     @weapon_data = []
  1949.   end
  1950.   #--------------------------------------------------------------------------
  1951.   # ● タイミングバトラー追加
  1952.   #--------------------------------------------------------------------------  
  1953.   def timing_battler_set(target)
  1954.     @timing_targets.push(target)
  1955.   end
  1956.   #--------------------------------------------------------------------------
  1957.   # ● 武器の動きを取得
  1958.   #--------------------------------------------------------------------------  
  1959.   def set_weapon_move
  1960.     # 開始位置を取得
  1961.     set_battler_position if @move_time == 0
  1962.     @z_plus = 50 if @z_plus == 0 && @weapon_data[9]
  1963.     self.z = @battler.sv.z + @z_plus
  1964.     # 反転処理
  1965.     @mirror = !@mirror if @weapon_data[7]
  1966.     self.mirror = @mirror
  1967.     # 更新パターンをセット
  1968.     set_pattern
  1969.     @max_pattern = 2 if @max_pattern == 1
  1970.     # 動きを計算
  1971.     @weapon_move_data = []
  1972.     @weapon_angle_data = []
  1973.     @weapon_zoom_data = []
  1974.     num = N03.mirror_num(@mirror)
  1975.     for i in 0...@max_pattern
  1976.       move_data_x = @weapon_data[2][0] * num * 100 * i / (@max_pattern - 1)
  1977.       move_data_y = @weapon_data[2][1] * 100 * i / (@max_pattern - 1)
  1978.       move_angle = @weapon_data[4] * num + (@weapon_data[5] * num - @weapon_data[4] * num) * i / (@max_pattern - 1)
  1979.       move_zoom_x = 1 + (@weapon_data[8][0] - 1) * i / (@max_pattern - 1)
  1980.       move_zoom_y = 1 + (@weapon_data[8][1] - 1) * i / (@max_pattern - 1)
  1981.       @weapon_move_data.push([move_data_x, move_data_y])
  1982.       @weapon_angle_data.push(move_angle)
  1983.       @weapon_zoom_data.push([move_zoom_x, move_zoom_y])
  1984.     end
  1985.   end  
  1986.   #--------------------------------------------------------------------------
  1987.   # ● 更新パターン
  1988.   #--------------------------------------------------------------------------
  1989.   def set_pattern
  1990.     if @weapon_data[11] == -1
  1991.       return @max_pattern = @battler.sv.max_pattern[0] if @battler.sv.pattern_type != 0
  1992.       @count = @battler.sv.pattern_time
  1993.       @max_count = @battler.sv.pattern_time
  1994.       @max_pattern = @battler.sv.max_pattern[0]
  1995.       @repeat = false
  1996.     else
  1997.       @count = @weapon_data[11][0]
  1998.       @max_count = @weapon_data[11][0]
  1999.       @max_pattern = @weapon_data[11][1]
  2000.       @repeat = @weapon_data[11][2]
  2001.     end
  2002.     @pattern = 0
  2003.   end
  2004.   #--------------------------------------------------------------------------
  2005.   # ● 移動実行
  2006.   #--------------------------------------------------------------------------
  2007.   def set_move
  2008.     # 戦闘アニメを取得
  2009.     set_animation(@move_data[1][0]) if $data_animations[@move_data[1][0]] != nil && $data_animations[@move_data[1][0]].position != 3
  2010.     @anime_camera_zoom = @move_data[13]
  2011.     @loop = @move_data[14]
  2012.     @loop = false if @move_data[1][0] == 0
  2013.     @anime_no_mirror = @move_data[15]
  2014.     @se_flag = @move_data[17]
  2015.     # 開始位置を取得
  2016.     start_position
  2017.     @z_plus = 1000 if @move_data[9]
  2018.     # ターゲットバトラー画像にこのアニメのSEとタイミング設定を反映させる
  2019.     @timing_targets = @target_battler
  2020.     # 座標計算
  2021.     @move_x = @move_data[5][0] * 100 * N03.mirror_num(@mirror)
  2022.     @move_y = @move_data[5][1] * 100
  2023.     # 時間計算か速度計算か
  2024.     @distanse_move = true if @move_data[6] > 0
  2025.     @move_time = @move_data[6].abs
  2026.     # 時間0の場合、アニメが設定されていればアニメ表示時間に合わせる
  2027.     if @move_time == 0
  2028.       @move_time = $data_animations[@move_data[1][0]].frame_max * 4 if $data_animations[@move_data[1][0]]
  2029.       @move_time = 1 if !$data_animations[@move_data[1][0]]
  2030.       @distanse_move = false
  2031.     end
  2032.     # 貫通タイプの場合
  2033.     @through = true if @move_data[7] == 1
  2034.     @auto_through_flag = false
  2035.     @auto_through_flag = true if @move_data[7] == 0
  2036.     # ターゲット座標計算
  2037.     if @target_battler == nil
  2038.       @target_x = @move_x * 100
  2039.       @target_x = (Graphics.width - @move_x) * 100 if @mirror
  2040.       @target_y = @move_y * 100
  2041.     else
  2042.       move_data_set
  2043.     end
  2044.     # ターゲットに到達するまでの時間を計算
  2045.     @move_time = distanse_calculation(@move_time, @target_x, @target_y)
  2046.     # 円軌道計算
  2047.     orbit
  2048.     # バトラーのウエイト設定
  2049.     @battler.sv.wait = @move_time - 1 if @move_data[10][0]
  2050.     @move_horming = @move_data[12]
  2051.   end  
  2052.   #--------------------------------------------------------------------------
  2053.   # ● 速度を時間に変換
  2054.   #--------------------------------------------------------------------------
  2055.   def distanse_calculation(time, target_x, target_y)
  2056.     return time if !@distanse_move
  2057.     distanse_x = @position_x - @target_x
  2058.     distanse_x = @target_x - @position_x if @target_x > @position_x
  2059.     distanse_y = @position_y - @target_y
  2060.     distanse_y = @target_y - @position_y if @target_y > @position_y
  2061.     distanse = [distanse_x, distanse_y].max
  2062.     return distanse / (time * 100) + 1
  2063.   end
  2064.   #--------------------------------------------------------------------------
  2065.   # ● 移動目標の更新
  2066.   #--------------------------------------------------------------------------
  2067.   def move_data_set
  2068.     return if @target_battler == nil
  2069.     position = N03.get_targets_position(@target_battler, true, @anime_position)
  2070.     @target_x = position[0] + @move_x
  2071.     @target_y = position[1] - position[2] + @move_y
  2072.   end
  2073.   #--------------------------------------------------------------------------
  2074.   # ● 開始位置を計算
  2075.   #--------------------------------------------------------------------------
  2076.   def start_position
  2077.     starter = [@battler.sv.m_a_starter.shift]
  2078.     starter = N03.get_targets(@move_data[2], @battler) if @move_data[2] < 0
  2079.     position = [0, 0]
  2080.     position = N03.get_targets_position(starter, true, @anime_position) if starter != nil
  2081.     @position_x = position[0] + @move_data[4][0] * 100
  2082.     @position_y = position[1] + position[2] + @move_data[4][1] * 100
  2083.     @position_z = @position_y
  2084.   end  
  2085.   #--------------------------------------------------------------------------
  2086.   # ● 円軌道計算
  2087.   #--------------------------------------------------------------------------
  2088.   def orbit
  2089.     orbit_data = @move_data[8].dup
  2090.     orbit_data[0] *= 100
  2091.     orbit_data[1] *= 100
  2092.     orbit_d = []
  2093.     for i in 0...@move_time / 2
  2094.       @orbit[i] = orbit_data[0]
  2095.       orbit_data[0] /= 2
  2096.       orbit_d[i] = orbit_data[1]
  2097.       orbit_data[1] /= 2
  2098.     end
  2099.     @orbit = @orbit + orbit_d.reverse!
  2100.     @orbit.reverse!
  2101.   end  
  2102.   #--------------------------------------------------------------------------
  2103.   # ● フレーム更新
  2104.   #--------------------------------------------------------------------------
  2105.   def update
  2106.     update_hit_anime if @anime_time != 0
  2107.     update_move if @move_time != 0
  2108.     update_weapon_move if @weapon_data != []
  2109.     update_position
  2110.     update_color
  2111.     self.visible = @battler.sv.weapon_visible
  2112.     super
  2113.   end
  2114.   #--------------------------------------------------------------------------
  2115.   # ● ヒット時の戦闘アニメ
  2116.   #--------------------------------------------------------------------------
  2117.   def update_hit_anime
  2118.     @anime_time -= 1
  2119.     @action_end = true if @anime_time == 0
  2120.   end
  2121.   #--------------------------------------------------------------------------
  2122.   # ● 移動の更新
  2123.   #--------------------------------------------------------------------------
  2124.   def update_move
  2125.     move_data_set if @move_horming && !@hit_position
  2126.     through_set(@move_time, @target_x, @target_y) if @move_time == 1 && !@hit_position
  2127.     @o += @orbit[@move_time - 1] if @orbit[@move_time - 1] != nil
  2128.     @position_x = (@position_x * (@move_time - 1) + @target_x) / @move_time
  2129.     @position_y = (@position_y * (@move_time - 1) + @target_y) / @move_time + @o
  2130.     reset_position
  2131.     set_animation(@move_data[1][0]) if @loop && !animation?
  2132.     @move_time -= 1
  2133.     return if @move_time != 0
  2134.     @action_end = true if !@action_end_cancel
  2135.   end
  2136.   #--------------------------------------------------------------------------
  2137.   # ● 武器の動きを更新
  2138.   #--------------------------------------------------------------------------
  2139.   def update_weapon_move
  2140.     pattern = update_pattern
  2141.     set_battler_position if @move_time == 0 && !@action_end_cancel
  2142.     @real_x = @position_x / 100 + @weapon_move_data[pattern][0] / 100
  2143.     @real_y = @position_y / 100 + @weapon_move_data[pattern][1] / 100
  2144.     @real_zoom_x = @weapon_zoom_data[pattern][0]
  2145.     @real_zoom_y = @weapon_zoom_data[pattern][1]
  2146.     self.angle = @weapon_angle_data[pattern]
  2147.     self.src_rect.set(@weapon_width * pattern, 0, @weapon_width, @weapon_height) if @weapon_data[1] == 2
  2148.   end
  2149.   #--------------------------------------------------------------------------
  2150.   # ● パターンを更新
  2151.   #--------------------------------------------------------------------------
  2152.   def update_pattern
  2153.     return @battler.sv.pattern_w if @count == nil
  2154.     @count -= 1
  2155.     return @pattern if @count != 0
  2156.     @count = @max_count
  2157.     @pattern += 1
  2158.     if !@repeat && @pattern == @max_pattern
  2159.       @pattern = @max_pattern - 1
  2160.     elsif @pattern == @max_pattern
  2161.       @pattern = 0
  2162.     end
  2163.     return @pattern
  2164.   end
  2165.   #--------------------------------------------------------------------------
  2166.   # ● 座標を更新
  2167.   #--------------------------------------------------------------------------
  2168.   def update_position
  2169.     self.x = (@real_x - $sv_camera.x) * $sv_camera.convert / 1000
  2170.     self.y = (@real_y - $sv_camera.y) * $sv_camera.convert / 1000
  2171.     self.x += $sv_camera.sx / 100 unless @battler.sv.h != 0 && @weapon_data != []
  2172.     self.y += $sv_camera.sy / 100 unless @battler.sv.h != 0 && @weapon_data != []
  2173.     self.z = @battler.sv.z + @z_plus - 10
  2174.     self.zoom_x = @real_zoom_x * $sv_camera.zoom
  2175.     self.zoom_y = @real_zoom_y * $sv_camera.zoom
  2176.     self.opacity = @battler.sv.opacity if @battler.sv.opacity_data[4]
  2177.   end
  2178.   #--------------------------------------------------------------------------
  2179.   # ● 貫通の処理
  2180.   #--------------------------------------------------------------------------
  2181.   def through_set(time, target_x, target_y)
  2182.     @hit_anime_id = N03.get_attack_anime_id(@move_data[1][1], @battler)
  2183.     @battler.sv.wait = N03.get_anime_time(@hit_anime_id) if @move_data[10][1]
  2184.     moving_x = (target_x / 100 - @position_x / 100) / time
  2185.     moving_y = (target_y / 100 - @position_y / 100) / time
  2186.     goal_x = $sv_camera.max_left - 100 if moving_x < 0
  2187.     goal_x = Graphics.width + $sv_camera.max_right + 100 if moving_x > 0
  2188.     goal_y = $sv_camera.max_top - 100 if moving_y < 0
  2189.     goal_y = Graphics.height + $sv_camera.max_bottom + 100 if moving_y > 0
  2190.     if goal_x == nil &&  goal_y == nil
  2191.       time = 0
  2192.       reset_position
  2193.     else
  2194.       time = move_calculation(moving_x, moving_y, goal_x, goal_y)
  2195.     end
  2196.     target_x = @position_x + moving_x * time * 100
  2197.     target_y = @position_y + moving_y * time * 100
  2198.     @pre_data = [time, target_x, target_y]
  2199.     @battler.sv.m_a_data.push([@move_data[11], @target_battler, @index, @auto_through_flag, []])
  2200.     @action_end_cancel = true
  2201.     @hit_position = [@real_x, @real_y, self.z]
  2202.   end  
  2203.   #--------------------------------------------------------------------------
  2204.   # ● 到達時間試算
  2205.   #--------------------------------------------------------------------------
  2206.   def move_calculation(moving_x, moving_y, goal_x, goal_y)
  2207.     move_x = @position_x / 100
  2208.     move_y = @position_y / 100
  2209.     time = 0
  2210.     loop do
  2211.       move_x += moving_x
  2212.       move_y += moving_y
  2213.       time += 1
  2214.       return time if moving_x < 0 && move_x < goal_x
  2215.       return time if moving_x > 0 && move_x > goal_x
  2216.       return time if moving_y < 0 && move_y < goal_y
  2217.       return time if moving_y > 0 && move_y > goal_y
  2218.     end
  2219.   end   
  2220.   #--------------------------------------------------------------------------
  2221.   # ● ミス時に消える処理から貫通処理に変換
  2222.   #--------------------------------------------------------------------------
  2223.   def through_change
  2224.     @action_end_cancel = false
  2225.     @through = true
  2226.     @move_time = @pre_data[0]
  2227.     @target_x = @pre_data[1]
  2228.     @target_y = @pre_data[2]
  2229.     @pre_data = nil
  2230.   end  
  2231.   #--------------------------------------------------------------------------
  2232.   # ● SE とフラッシュのタイミング処理
  2233.   #--------------------------------------------------------------------------
  2234.   def animation_process_timing(timing)
  2235.     return if !@timing_targets
  2236.     se_flag = true
  2237.     se_flag = @se_flag if @se_flag != nil
  2238.     for target in @timing_targets
  2239.       target.sv.timing.push([se_flag, timing.dup])
  2240.       se_flag = false if @animation.position == 3
  2241.     end  
  2242.   end
  2243.   #--------------------------------------------------------------------------
  2244.   # ● 色調の更新
  2245.   #--------------------------------------------------------------------------
  2246.   def update_color
  2247.     return if @battler.sv.color == []
  2248.     self.color.set(@battler.sv.color[0], @battler.sv.color[1], @battler.sv.color[2], @battler.sv.color[3])
  2249.   end
  2250.   #--------------------------------------------------------------------------
  2251.   # ● 解放
  2252.   #--------------------------------------------------------------------------
  2253.   def dispose
  2254.     super
  2255.     self.bitmap.dispose if self.bitmap != nil
  2256.   end
  2257. end

  2258. #==============================================================================
  2259. # ■ Sprite_Battle_Picture
  2260. #------------------------------------------------------------------------------
  2261. #  ピクチャ表示用のスプライトです。
  2262. #==============================================================================
  2263. class Sprite_Battle_Picture < Sprite
  2264.   #--------------------------------------------------------------------------
  2265.   # ● 公開インスタンス変数 
  2266.   #--------------------------------------------------------------------------
  2267.   attr_accessor   :action_end           # 終了フラグ
  2268.   #--------------------------------------------------------------------------
  2269.   # ● オブジェクト初期化
  2270.   #--------------------------------------------------------------------------
  2271.   def initialize(viewport = nil)
  2272.     super(viewport)
  2273.     @action_end = false
  2274.     self.ox = 0
  2275.   end
  2276.   #--------------------------------------------------------------------------
  2277.   # ● セット
  2278.   #--------------------------------------------------------------------------
  2279.   def set(battler)
  2280.     @battler = battler
  2281.     @data = @battler.sv.effect_data.shift
  2282.     @time = @data[4]
  2283.     @mirror = $sv_camera.mirror
  2284.     @mirror = false if !@data[8]
  2285.     self.opacity = @data[6][0]
  2286.     @s_x = @data[2][0] if @data[2] != []
  2287.     @s_x = Graphics.width - @data[2][0]  if @data[2] != [] && @mirror
  2288.     @s_y = @data[2][1] if @data[2] != []
  2289.     @e_x = @data[3][0] if @data[3] != []
  2290.     @e_x = Graphics.width - @data[3][0] if @data[3] != [] && @mirror
  2291.     @e_y = @data[3][1] if @data[3] != []
  2292.     @s_x = self.x if @data[2] == []
  2293.     @s_y = self.y if @data[2] == []
  2294.     @e_x = self.x if @data[3] == []
  2295.     @e_y = self.y if @data[3] == []
  2296.     self.x = @s_x
  2297.     self.y = @s_y
  2298.     return @action_end = true if @time == 0
  2299.     @move_x = (@e_x * 1.0 - @s_x) / @time
  2300.     @move_y = (@e_y * 1.0 - @s_y) / @time
  2301.     self.z = @data[5]
  2302.     return set_plane(battler) if @data[7] != []
  2303.     self.bitmap = Cache.picture(@data[9]) if !bitmap or @data[9] != ""
  2304.     return @action_end = true if !bitmap
  2305.     self.mirror = @mirror
  2306.     self.ox = self.bitmap.width if @mirror
  2307.   end
  2308.   #--------------------------------------------------------------------------
  2309.   # ● プレーン移行
  2310.   #--------------------------------------------------------------------------
  2311.   def set_plane(battler)
  2312.     @viewport = Viewport.new(@data[2][0],@data[2][1],@data[7][0],@data[7][1]) if !@viewport
  2313.     viewport = @viewport
  2314.     @plane = Plane.new(viewport) if !@plane
  2315.     @plane.bitmap = Cache.picture(@data[9]) if [email protected] or @data[9] != ""
  2316.     return @action_end = true if [email protected]
  2317.     @plane.ox = @data[7][0]
  2318.     @plane.oy = @data[7][1]
  2319.     @plane.opacity = @data[6][0]
  2320.     @move_x = @remain_move[0] if @data[2] == @data[3]
  2321.     @move_y = @remain_move[1] if @data[2] == @data[3]
  2322.     @remain_move = [@move_x, @move_y]
  2323.   end
  2324.   #--------------------------------------------------------------------------
  2325.   # ● フレーム更新
  2326.   #--------------------------------------------------------------------------
  2327.   def update
  2328.     @action_end = true if [email protected]
  2329.     return if @time == 0
  2330.     return if @action_end
  2331.     @time -= 1
  2332.     return plane_update if @plane
  2333.     super
  2334.     self.x += @move_x
  2335.     self.y += @move_y
  2336.     self.opacity += @data[6][1]
  2337.     return if @time != 1
  2338.     self.x = @e_x
  2339.     self.y = @e_y
  2340.     @time = 0
  2341.   end
  2342.   #--------------------------------------------------------------------------
  2343.   # ● フレーム更新
  2344.   #--------------------------------------------------------------------------
  2345.   def plane_update
  2346.     @plane.ox += @move_x
  2347.     @plane.oy += @move_y
  2348.     @plane.opacity += @data[6][1]
  2349.     @time = @data[4] if @time == 0
  2350.   end
  2351.   #--------------------------------------------------------------------------
  2352.   # ● 解放
  2353.   #--------------------------------------------------------------------------
  2354.   def dispose
  2355.     bitmap.dispose if bitmap
  2356.     @plane.dispose if @plane
  2357.     @viewport.dispose if @viewport
  2358.     super
  2359.   end
  2360. end

  2361. #==============================================================================
  2362. # ■ Sprite_Back_Picture
  2363. #------------------------------------------------------------------------------
  2364. #  周期ピクチャ用のスプライトです。
  2365. #==============================================================================
  2366. class Sprite_Back_Picture < Plane
  2367.   #--------------------------------------------------------------------------
  2368.   # ● 公開インスタンス変数 
  2369.   #--------------------------------------------------------------------------
  2370.   attr_accessor   :action_end           # 終了フラグ
  2371.   #--------------------------------------------------------------------------
  2372.   # ● オブジェクト初期化
  2373.   #--------------------------------------------------------------------------
  2374.   def initialize(viewport = nil, index)
  2375.     super(viewport)
  2376.     @index = index
  2377.     @real_x = 0
  2378.     @real_y = 0
  2379.     @real_opacity = 0
  2380.     @move_x = 0
  2381.     @move_y = 0
  2382.     @move_opacity = 0
  2383.     @time = 0
  2384.     @switche = 0
  2385.     @action_end = false
  2386.   end
  2387.   #--------------------------------------------------------------------------
  2388.   # ● セットアップ
  2389.   #--------------------------------------------------------------------------
  2390.   def setup(data)
  2391.     self.bitmap = Cache.picture(data[9])
  2392.     self.z = data[6]
  2393.     @switche = data[1]
  2394.     mirror = $sv_camera.mirror
  2395.     mirror = false if !data[8]
  2396.     @move_x = data[3][0]
  2397.     @move_x *= -1 if mirror
  2398.     @move_y = data[3][1]
  2399.     @time = data[4]
  2400.     @time = -1 if @time == 0
  2401.     @real_opacity = (data[5][0] + 1) * 100
  2402.     @move_opacity = data[5][1]
  2403.     @start_opacity = data[5][0]
  2404.     @shake_ok = data[7]
  2405.   end
  2406.   #--------------------------------------------------------------------------
  2407.   # ● フレーム更新
  2408.   #--------------------------------------------------------------------------
  2409.   def update
  2410.     update_picture if @time != 0
  2411.     self.ox = $sv_camera.x - @real_x
  2412.     self.oy = $sv_camera.y - @real_y
  2413.     if @shake_ok
  2414.       self.ox -= $sv_camera.sx / 100
  2415.       self.oy -= $sv_camera.sy / 100
  2416.     end
  2417.     self.ox *= $sv_camera.zoom
  2418.     self.oy *= $sv_camera.zoom
  2419.     self.zoom_x = @zoom_x * $sv_camera.zoom
  2420.     self.zoom_y = @zoom_y * $sv_camera.zoom
  2421.     self.opacity = @real_opacity / 100
  2422.     @move_opacity *= -1 if self.opacity == 255 or self.opacity <= @start_opacity
  2423.     @switche
  2424.     @action_end = true if @switche > 0 && !$game_switches[@switche]
  2425.     @action_end = true if @switche < 0 && !$sv_camera.switches[@switche.abs]
  2426.   end
  2427.   #--------------------------------------------------------------------------
  2428.   # ● ピクチャの更新
  2429.   #--------------------------------------------------------------------------
  2430.   def update_picture
  2431.     @real_x += @move_x / 100
  2432.     @real_y += @move_y / 100
  2433.     @real_x = 0 if @real_x >= self.bitmap.width or @real_x <= -self.bitmap.width
  2434.     @real_y = 0 if @real_y >= self.bitmap.height or @real_y <= -self.bitmap.height
  2435.     @zoom_x = 1
  2436.     @zoom_y = 1
  2437.     @real_opacity += @move_opacity
  2438.     @time -= 1
  2439.     @time = -1 if @time < -100
  2440.   end
  2441. end

  2442. #==============================================================================
  2443. # ■ Sprite_Back_Picture
  2444. #------------------------------------------------------------------------------
  2445. #  ダメージ表示のスプライトです。
  2446. #==============================================================================
  2447. class Sprite_Damage < Sprite
  2448.   #--------------------------------------------------------------------------
  2449.   # ● 公開インスタンス変数 
  2450.   #--------------------------------------------------------------------------
  2451.   attr_reader   :action_end                  # POP終了フラグ
  2452.   #--------------------------------------------------------------------------
  2453.   # ● オブジェクト初期化
  2454.   #--------------------------------------------------------------------------
  2455.   def initialize(viewport = nil, battler)
  2456.     super(viewport)
  2457.     @battler = battler
  2458.     @time = 0
  2459.     return @action_end = true if !@battler
  2460.     @direction = -1
  2461.     @direction *= -1 if @battler.actor?
  2462.     @direction *= -1 if $sv_camera.mirror
  2463.     set_state
  2464.     set_damage
  2465.     update
  2466.   end
  2467.   #--------------------------------------------------------------------------
  2468.   # ● ステート表示
  2469.   #--------------------------------------------------------------------------
  2470.   def set_state
  2471.     return if !N03::STATE_POP
  2472.     states = @battler.result.added_state_objects
  2473.     states.delete($data_states[@battler.death_state_id]) if @battler.result.hp_damage != 0
  2474.     return if states == []
  2475.     return if @battler.sv.add_state == @battler.result.added_state_objects
  2476.     @battler.sv.add_state = states.dup
  2477.     @st = []
  2478.     @st_base = []
  2479.     for i in 0...states.size
  2480.       @st[i] = Sprite.new
  2481.       bitmap_state(@st[i], states[i])
  2482.       @st_base[i] = []
  2483.       @st_base[i][0] = @direction * (-20 + 5 * i) + @battler.sv.x / 100
  2484.       @st_base[i][1] = -40 - @state_height * i + (@battler.sv.y - @battler.sv.h - @battler.sv.j - @battler.sv.oy_adjust)/ 100
  2485.       @st[i].z = 1000 + i
  2486.       @st[i].opacity = 0
  2487.     end
  2488.     @time = @pop_time = 80
  2489.   end   
  2490.   #--------------------------------------------------------------------------
  2491.   # ● ステート画像
  2492.   #--------------------------------------------------------------------------
  2493.   def bitmap_state(state, state_object)
  2494.     name = state_object.name
  2495.     state.bitmap = Cache.system("Iconset").dup
  2496.     state.src_rect.set(state_object.icon_index % 16 * 24, state_object.icon_index / 16 * 24, 24, 24)
  2497.     @state_height = 24
  2498.   end
  2499.   #--------------------------------------------------------------------------
  2500.   # ● ダメージ表示
  2501.   #--------------------------------------------------------------------------
  2502.   def hit_count
  2503.     for i in [email protected]
  2504.       if @battler.sv.hit[i] == nil
  2505.         @hit = i
  2506.         return @battler.sv.hit[i] = @hit
  2507.       end
  2508.     end
  2509.     @hit = @battler.sv.hit.size
  2510.     @battler.sv.hit.push(@hit)
  2511.   end  
  2512.   #--------------------------------------------------------------------------
  2513.   # ● ダメージ表示
  2514.   #--------------------------------------------------------------------------
  2515.   def set_damage
  2516.     return @action_end = true if !N03::DAMAGE_POP
  2517.     damage = @battler.result.hp_damage if @battler.result.hp_damage != 0
  2518.     damage = @battler.result.hp_drain  if @battler.result.hp_drain  != 0
  2519.     damage = @battler.result.mp_damage if @battler.result.mp_damage != 0
  2520.     damage = @battler.result.mp_drain  if @battler.result.mp_drain  != 0
  2521.     damage = @battler.result.tp_damage if @battler.result.tp_damage != 0
  2522.     if !damage or damage == 0
  2523.       @action_end = true if @st == nil
  2524.       return # ステートだけPOPする設定を考慮して@action_endは返さない
  2525.     end
  2526.     hit_count
  2527.     #@hit = @battler.sv.hit
  2528.     #@battler.sv.hit += 1 if damage != 0
  2529.     file = N03::DAMAGE_PLUS if damage > 0
  2530.     file = N03::DAMAGE_MINUS if damage < 0
  2531.     add_file = N03::DAMAGE_MP if @battler.result.mp_damage != 0
  2532.     add_file = N03::DAMAGE_TP if @battler.result.tp_damage != 0
  2533.     adjust_x = N03::DAMAGE_ADJUST
  2534.     @num = []
  2535.     @num_base = []
  2536.     damage = damage.abs
  2537.     max_num = damage.to_s.size
  2538.     max_num += 1 if add_file != nil
  2539.     for i in 0...max_num
  2540.       @num[i] = Sprite.new
  2541.       if add_file != nil && i == max_num - 1
  2542.         @num[i].bitmap = Cache.system(add_file)
  2543.         cw = (damage % (10 * 10 ** i))/(10 ** i)
  2544.         sw = 0 if sw == nil
  2545.       else
  2546.         @num[i].bitmap = Cache.system(file)
  2547.         cw = (damage % (10 * 10 ** i))/(10 ** i)
  2548.         sw = @num[i].bitmap.width / 10
  2549.         @num[i].src_rect.set(cw * sw, 0, sw, @num[i].bitmap.height)
  2550.       end
  2551.       @num_base[i] = []
  2552.       @num_base[i][0] = (sw + adjust_x) * i * -1 + (@battler.sv.x / 100)
  2553.       @num_base[i][1] =  -(@num[i].bitmap.height / 3) - i * 2 - @hit * 2 + (@battler.sv.y - @battler.sv.h - @battler.sv.j - @battler.sv.oy_adjust)/ 100
  2554.       @num_base[i][0] -= @num[i].bitmap.width / 2 - adjust_x if add_file != nil && i == max_num - 1
  2555.       @num[i].z = 1000 + i + @hit * 10
  2556.     end
  2557.     @time = @pop_time = 80
  2558.   end
  2559.   #--------------------------------------------------------------------------
  2560.   # ● フレーム更新
  2561.   #--------------------------------------------------------------------------
  2562.   def update
  2563.     return if @time == 0
  2564.     for i in [email protected] do update_state_move(@st[i], i) end if @st != nil
  2565.     for i in [email protected] do update_num_move(@num[i], i) end if @num != nil
  2566.     @time -= 1
  2567.     @action_end = true if @time == 0
  2568.   end
  2569.   #--------------------------------------------------------------------------
  2570.   # ● ステート画像の更新
  2571.   #--------------------------------------------------------------------------
  2572.   def update_state_move(state, index)
  2573.     min = @pop_time - index * 2
  2574.     case @time
  2575.     when min-15..min
  2576.       @st_base[index][0] += @direction
  2577.       state.opacity += 25
  2578.     when min-80..min-50
  2579.       @st_base[index][0] += @direction
  2580.       state.opacity -= 25
  2581.     end
  2582.     state.x = (@st_base[index][0] - $sv_camera.x) * $sv_camera.zoom
  2583.     state.y = (@st_base[index][1] - $sv_camera.y) * $sv_camera.zoom
  2584.   end
  2585.   #--------------------------------------------------------------------------
  2586.   # ● 数値の更新
  2587.   #--------------------------------------------------------------------------
  2588.   def update_num_move(num, index)
  2589.     min = @pop_time - index * 2
  2590.     case @time
  2591.     when min-1..min
  2592.       @num_base[index][0] += @direction * @hit
  2593.       @num_base[index][1] -= 5 + @hit * 2
  2594.     when min-3..min-2
  2595.       @num_base[index][0] += @direction * @hit
  2596.       @num_base[index][1] -= 4 + @hit * 2
  2597.     when min-6..min-4
  2598.       @num_base[index][0] += @direction
  2599.       @num_base[index][1] -= 3 + @hit * 2
  2600.     when min-14..min-7
  2601.       @num_base[index][0] += @direction
  2602.       @num_base[index][1] += 2
  2603.     when min-17..min-15
  2604.       @num_base[index][1] -= 2 + @hit * 2
  2605.     when min-23..min-18
  2606.       @num_base[index][1] += 1
  2607.     when min-27..min-24
  2608.       @num_base[index][1] -= 1
  2609.     when min-30..min-28
  2610.       @num_base[index][1] += 1
  2611.     when min-33..min-31
  2612.       @num_base[index][1] -= 1
  2613.     when min-36..min-34
  2614.       @num_base[index][1] += 1
  2615.     end
  2616.     num.x = (@num_base[index][0] - $sv_camera.x) * $sv_camera.zoom
  2617.     num.y = (@num_base[index][1] - $sv_camera.y) * $sv_camera.zoom
  2618.     num.opacity = 256 - (12 - @time) * 32
  2619.     num.visible = false if @time == 0
  2620.   end
  2621.   #--------------------------------------------------------------------------
  2622.   # ● 解放
  2623.   #--------------------------------------------------------------------------
  2624.   def dispose
  2625.     @battler.sv.hit[@hit] = nil if @hit
  2626.     bitmap.dispose if bitmap
  2627.     for i in [email protected] do @num[i].dispose end if @num != nil
  2628.     for i in [email protected] do @st[i].dispose end if @st != nil
  2629.     super
  2630.   end
  2631. end

  2632. #==============================================================================
  2633. # ■ Window_Skill_name
  2634. #------------------------------------------------------------------------------
  2635. #  スキル名を表示するウィンドウです。
  2636. #==============================================================================
  2637. class Window_Skill_name < Window_Base
  2638.   #--------------------------------------------------------------------------
  2639.   # ● オブジェクト初期化
  2640.   #--------------------------------------------------------------------------
  2641.   def initialize(text)
  2642.     super(0, 0, Graphics.width, line_height + standard_padding * 2)
  2643.     draw_text(4, 0, Graphics.width - 64, line_height,text, 1)
  2644.   end
  2645. end

  2646. #==============================================================================
  2647. # ■ Spriteset_Sideview
  2648. #------------------------------------------------------------------------------
  2649. #  サイドビュー独自のスプライトをまとめたクラスです。
  2650. #==============================================================================
  2651. class Spriteset_Sideview
  2652.   #--------------------------------------------------------------------------
  2653.   # ● オブジェクト初期化
  2654.   #--------------------------------------------------------------------------
  2655.   def initialize(viewport)
  2656.     @viewport = viewport
  2657.     @weapons = []
  2658.     @pictures = []
  2659.     @back_pic = []
  2660.     @damage = []
  2661.     $sv_camera.setup
  2662.     N03.camera(nil, N03::BATTLE_CAMERA["ターン開始前"].dup)
  2663.   end
  2664.   #--------------------------------------------------------------------------
  2665.   # ● フレーム更新
  2666.   #--------------------------------------------------------------------------
  2667.   def update
  2668.     update_battler_data
  2669.     update_damage
  2670.     update_pictures
  2671.     update_back_pic
  2672.     update_weapons
  2673.   end  
  2674.   #--------------------------------------------------------------------------
  2675.   # ● バトラーデータの更新
  2676.   #--------------------------------------------------------------------------
  2677.   def update_battler_data
  2678.     for battler in $game_party.battle_members + $game_troop.members
  2679.       weapon_end(battler) if battler.sv.weapon_end
  2680.       next if battler.sv.effect_data == []
  2681.       for effect_data in battler.sv.effect_data do set_effects(battler, effect_data) end
  2682.     end
  2683.   end
  2684.   #--------------------------------------------------------------------------
  2685.   # ● ダメージ画像の更新
  2686.   #--------------------------------------------------------------------------
  2687.   def update_damage
  2688.     for i in [email protected]
  2689.       next if @damage[i] == nil
  2690.       @damage[i].update if @damage[i] != nil
  2691.       next if !@damage[i].action_end
  2692.       @damage[i].dispose
  2693.       @damage[i] = nil
  2694.     end
  2695.   end
  2696.   #--------------------------------------------------------------------------
  2697.   # ● ピクチャアクションの更新
  2698.   #--------------------------------------------------------------------------
  2699.   def update_pictures
  2700.     for i in [email protected]
  2701.       next if @pictures[i] == nil
  2702.       @pictures[i].update if @pictures[i] != nil
  2703.       next if !@pictures[i].action_end
  2704.       @pictures[i].dispose
  2705.       @pictures[i] = nil
  2706.     end
  2707.   end
  2708.   #--------------------------------------------------------------------------
  2709.   # ● 周期ピクチャの更新
  2710.   #--------------------------------------------------------------------------
  2711.   def update_back_pic
  2712.     set_back_pic if $sv_camera.program_picture != []
  2713.     for i in 0...@back_pic.size
  2714.       next if @back_pic[i] == nil
  2715.       @back_pic[i].update if @back_pic[i] != nil
  2716.       next if !@back_pic[i].action_end
  2717.       @back_pic[i].dispose
  2718.       @back_pic[i] = nil
  2719.     end
  2720.   end
  2721.   #--------------------------------------------------------------------------
  2722.   # ● 武器アクションの更新
  2723.   #--------------------------------------------------------------------------
  2724.   def update_weapons
  2725.     for i in [email protected]
  2726.       next if @weapons[i] == nil
  2727.       @weapons[i].update if @weapons[i] != nil
  2728.       next if !@weapons[i].action_end
  2729.       @weapons[i].dispose
  2730.       @weapons[i] = nil
  2731.     end
  2732.   end
  2733.   #--------------------------------------------------------------------------
  2734.   # ● ダメージ実行
  2735.   #--------------------------------------------------------------------------
  2736.   def set_damage_pop(target)
  2737.     for i in [email protected]
  2738.       next if @damage[i] != nil
  2739.       return @damage[i] = Sprite_Damage.new(@viewport, target)
  2740.     end
  2741.     @damage.push(Sprite_Damage.new(@viewport, target))
  2742.   end
  2743.   #--------------------------------------------------------------------------
  2744.   # ● 周期ピクチャ実行
  2745.   #--------------------------------------------------------------------------
  2746.   def set_back_pic
  2747.     for data in $sv_camera.program_picture
  2748.       if @back_pic[data[2]] != nil
  2749.         @back_pic[data[2]].dispose
  2750.         @back_pic[data[2]] = nil
  2751.       end
  2752.       @back_pic[data[2]] = Sprite_Back_Picture.new(@viewport, data[2])
  2753.       @back_pic[data[2]].setup(data)
  2754.     end
  2755.     $sv_camera.program_picture = []
  2756.   end
  2757.   #--------------------------------------------------------------------------
  2758.   # ● エフェクト開始
  2759.   #--------------------------------------------------------------------------
  2760.   def set_effects(battler, effect_data)
  2761.     case effect_data[0]
  2762.     when "pic" ; set_pictures(battler, effect_data)
  2763.     when  "wp" ; set_weapons(battler,  true)
  2764.     when "m_a" ; set_weapons(battler, false)
  2765.     end
  2766.   end
  2767.   #--------------------------------------------------------------------------
  2768.   # ● ピクチャアクション実行
  2769.   #--------------------------------------------------------------------------
  2770.   def set_pictures(battler, effect_data)
  2771.     @pictures[effect_data[1]] = Sprite_Battle_Picture.new if @pictures[effect_data[1]] == nil
  2772.     @pictures[effect_data[1]].set(battler)
  2773.   end
  2774.   #--------------------------------------------------------------------------
  2775.   # ● 武器アクション実行
  2776.   #--------------------------------------------------------------------------
  2777.   def set_weapons(battler, weapon_flag, test = true)
  2778.     for i in [email protected]
  2779.       next if @weapons[i] != nil
  2780.       @weapons[i] = Sprite_Weapon.new(@viewport, i, battler)
  2781.       battler.sv.weapon_index.push(i) if weapon_flag
  2782.       return i
  2783.     end
  2784.     @weapons.push(Sprite_Weapon.new(@viewport, @weapons.size, battler))
  2785.     battler.sv.weapon_index.push(@weapons.size - 1) if weapon_flag
  2786.     return @weapons.size - 1
  2787.   end
  2788.   #--------------------------------------------------------------------------
  2789.   # ● バトラーの武器アクション終了
  2790.   #--------------------------------------------------------------------------
  2791.   def weapon_end(battler)
  2792.     battler.sv.weapon_end = false
  2793.     for index in battler.sv.weapon_index
  2794.       weapon_index = battler.sv.weapon_index.shift
  2795.       @weapons[weapon_index].dispose if @weapons[weapon_index] != nil
  2796.       @weapons[weapon_index] = nil
  2797.     end
  2798.     battler.sv.weapon_index.compact!
  2799.   end  
  2800.   #--------------------------------------------------------------------------
  2801.   # ● ヒット時の戦闘アニメ実行
  2802.   #--------------------------------------------------------------------------
  2803.   def set_hit_animation(battler, weapon_index, hit_targets, miss)
  2804.     weapon = @weapons[weapon_index]
  2805.     for target in hit_targets
  2806.       next @weapons[@hit_index].timing_battler_set(target) if @hit_index != nil
  2807.       @hit_index = set_weapons(battler, false, false)
  2808.       @weapons[@hit_index].set_hit_animation(weapon.hit_position, weapon.hit_anime_id, target)
  2809.     end
  2810.     @hit_index = nil
  2811.     if !weapon.through && !miss
  2812.       @weapons[weapon_index].dispose
  2813.       @weapons[weapon_index] = nil
  2814.     else
  2815.       @weapons[weapon_index].through_change
  2816.     end
  2817.   end
  2818.   #--------------------------------------------------------------------------
  2819.   # ● サイドビューデータの初期化
  2820.   #--------------------------------------------------------------------------
  2821.   def reset_sideview
  2822.     $sv_camera.reset
  2823.     for member in $game_troop.members + $game_party.battle_members do member.sv.reset end
  2824.   end  
  2825.   #--------------------------------------------------------------------------
  2826.   # ● 解放
  2827.   #--------------------------------------------------------------------------
  2828.   def dispose
  2829.     dispose_effects(@weapons)
  2830.     dispose_effects(@pictures)
  2831.     dispose_effects(@back_pic)
  2832.     dispose_effects(@damage)
  2833.     reset_sideview
  2834.   end
  2835.   #--------------------------------------------------------------------------
  2836.   # ● エフェクト画像の解放
  2837.   #--------------------------------------------------------------------------
  2838.   def dispose_effects(effects)
  2839.     for i in 0...effects.size
  2840.       effects[i].dispose if effects[i] != nil
  2841.       effects[i] = nil
  2842.     end
  2843.   end
  2844. end


  2845. #==============================================================================
  2846. # ■ Sprite_Battle_Back
  2847. #------------------------------------------------------------------------------
  2848. #  戦闘背景用のスプライトです。
  2849. #==============================================================================
  2850. class Sprite_Battle_Back < Plane
  2851.   #--------------------------------------------------------------------------
  2852.   # ● オブジェクト初期化
  2853.   #--------------------------------------------------------------------------
  2854.   def initialize(viewport = nil, index, battleback_name)
  2855.     super(viewport)
  2856.     @index = index
  2857.     if @index == 1
  2858.       data = N03::FLOOR1_DATA[battleback_name]
  2859.       data = N03::FLOOR1_DATA["全Battlebacks1"] if data == nil
  2860.     elsif @index == 2
  2861.       data = N03::FLOOR2_DATA[battleback_name]
  2862.       data = N03::FLOOR2_DATA["全Battlebacks2"] if data == nil
  2863.     end   
  2864.     data = data.dup
  2865.     @adjust_position = data[0]
  2866.     @zoom_x = data[1][0] / 100.0
  2867.     @zoom_y = data[1][1] / 100.0
  2868.     @shake_on = data[2]
  2869.     $game_switches[data[3]] = true if data[3] > 0
  2870.     $sv_camera.switches[data[3].abs] = true if data[3] < 0
  2871.     reset_scroll
  2872.     reset_back_data(battleback_name)
  2873.   end
  2874.   #--------------------------------------------------------------------------
  2875.   # ● 背景スクロールを初期化
  2876.   #--------------------------------------------------------------------------
  2877.   def reset_scroll
  2878.     @scroll_x = 0
  2879.     @scroll_y = 0
  2880.     @move_x = 0
  2881.     @move_y = 0
  2882.   end
  2883.   #--------------------------------------------------------------------------
  2884.   # ● 背景データを初期化
  2885.   #--------------------------------------------------------------------------
  2886.   def reset_back_data(battleback_name)
  2887.     @back_data = []
  2888.     @active_data = ["scroll",0, @move_x, @move_y, false, battleback_name,""]
  2889.     start_back_data(@active_data)
  2890.   end  
  2891.   #--------------------------------------------------------------------------
  2892.   # ● 背景画像のセッティング
  2893.   #--------------------------------------------------------------------------
  2894.   def set_graphics(new_bitmap)
  2895.     self.bitmap = new_bitmap
  2896.     @base_x = (self.bitmap.width * @zoom_x - Graphics.width) / 2 + @adjust_position[0]
  2897.     @base_y = (self.bitmap.height * @zoom_y - Graphics.height) / 2 + @adjust_position[1]
  2898.     # 限界座標を取得
  2899.     max_top =  0
  2900.     max_bottom = self.bitmap.height * @zoom_y - Graphics.height
  2901.     max_left = 0
  2902.     max_right = self.bitmap.width * @zoom_x - Graphics.width
  2903.     exist = true
  2904.     exist = false if self.bitmap.height == 32 && self.bitmap.width == 32
  2905.     $sv_camera.setting(@index, [max_top, max_bottom, max_left, max_right, @base_x, @base_y,exist])
  2906.   end
  2907.   #--------------------------------------------------------------------------
  2908.   # ● フレーム更新
  2909.   #--------------------------------------------------------------------------
  2910.   def update
  2911.     return if !bitmap
  2912.     update_back_data
  2913.     update_scroll unless @move_x == 0 && @move_y == 0
  2914.     update_color
  2915.     update_position
  2916.     update_back_adjust if @bt_back != nil
  2917.     create_back_adjust if @bt_back == nil && !@active_data[10] && @scroll_x == 0 && @scroll_y == 0
  2918.   end
  2919.   #--------------------------------------------------------------------------
  2920.   # ● 背景データを更新
  2921.   #--------------------------------------------------------------------------
  2922.   def update_back_data
  2923.     delete = true if @active_data[1] > 0 && !$game_switches[@active_data[1]]
  2924.     delete = true if @active_data[1] < 0 && !$sv_camera.switches[@active_data[1].abs]
  2925.     return if !delete
  2926.     for i in 0...@back_data.size
  2927.       @back_data[i] = nil if @back_data[i][1] > 0 && !$game_switches[@back_data[i][1]]
  2928.       @back_data[i] = nil if @back_data[i][1] < 0 && !$sv_camera.switches[@back_data[i][1].abs]
  2929.     end
  2930.     @back_data.compact!
  2931.     next_back_data
  2932.   end
  2933.   #--------------------------------------------------------------------------
  2934.   # ● 次の背景データをセット
  2935.   #--------------------------------------------------------------------------
  2936.   def next_back_data
  2937.     @back_data.delete(@active_data[11]) if @active_data[11] != nil
  2938.     @back_data.push(@active_data[11]) if @active_data[11] != nil
  2939.     @active_data = nil
  2940.     data = @back_data.pop
  2941.     @back_data = [@active_data] if @back_data.size == 0
  2942.     start_back_data(data)
  2943.   end  
  2944.   #--------------------------------------------------------------------------
  2945.   # ● 背景データを実行
  2946.   #--------------------------------------------------------------------------
  2947.   def start_back_data(data)
  2948.     return if back_data_remain(data)
  2949.     bt_back_dispose
  2950.     pre_active_data = @active_data
  2951.     @active_data[8] = [@back_name, @move_x, @move_y, @scroll_x, @scroll_y] if @active_data != nil
  2952.     @back_data.push(@active_data)     if @active_data != nil
  2953.     @active_data = data.dup
  2954.     @active_data[5] = @back_name      if @active_data[5] == ""
  2955.     @active_data[9] = set_back_adjust if @active_data[9] == nil
  2956.     back_data_scroll_on               if @active_data[8] == nil && @active_data[9][0] == false
  2957.     set_remain_back_data              if @active_data[8] != nil
  2958.     create_back(@active_data[5])      if @active_data[9][0] == false
  2959.     create_back_adjust                if @active_data[10]
  2960.     @active_data[11] = pre_active_data if pre_active_data && @active_data[7] == false
  2961.   end  
  2962.   #--------------------------------------------------------------------------
  2963.   # ● 背景データの保留
  2964.   #--------------------------------------------------------------------------
  2965.   def back_data_remain(data)
  2966.     remain = false
  2967.     remain = true if data[6] != "" && @active_data != nil && @active_data[9] != nil && @active_data[9][0] != false
  2968.     remain = true if @active_data != nil && @active_data[7] == false
  2969.     return remain if !remain
  2970.     @remain = true
  2971.     @back_data.push(data)
  2972.     return remain
  2973.   end  
  2974.   #--------------------------------------------------------------------------
  2975.   # ● 背景変更補正データをセット
  2976.   #--------------------------------------------------------------------------
  2977.   def set_back_adjust
  2978.     bt_adjust = []
  2979.     sign = -1
  2980.     if @active_data[6] == ""
  2981.       reset_scroll if @active_data[3][0] == 0 &&  @active_data[3][1] == 0
  2982.       bt_adjust = [false,false,0,0]
  2983.       return bt_adjust
  2984.     elsif @move_x != 0 or @active_data[3][0] != 0
  2985.       sign = 1 if @move_x < 0
  2986.       bt_adjust[0] = [self.bitmap.width * @zoom_x * sign, 0]
  2987.       bt_adjust[1] = [self.bitmap.width * @zoom_x * sign * 2, 0]
  2988.     elsif @move_y != 0 or @active_data[3][1] != 0
  2989.       sign = 1 if @move_y < 0
  2990.       bt_adjust[0] = [0, self.bitmap.height * @zoom_y * sign]
  2991.       bt_adjust[1] = [0, self.bitmap.height * @zoom_y * sign * 2]
  2992.     else
  2993.       reset_scroll if @active_data[3][0] == 0 &&  @active_data[3][1] == 0
  2994.       bt_adjust = [false,false,0,0]
  2995.       return bt_adjust
  2996.     end
  2997.     bt_adjust[2] = [bt_adjust[0][0], bt_adjust[0][1]]
  2998.     return bt_adjust
  2999.   end
  3000.   #--------------------------------------------------------------------------
  3001.   # ● 背景スクロールデータを実行
  3002.   #--------------------------------------------------------------------------
  3003.   def back_data_scroll_on
  3004.     mirror = $sv_camera.mirror
  3005.     mirror = false if !@active_data[4]
  3006.     @move_x = @active_data[3][0]
  3007.     @move_x *= -1 if mirror
  3008.     @move_y = @active_data[3][1]
  3009.   end
  3010.   #--------------------------------------------------------------------------
  3011.   # ● 保持している背景データを実行
  3012.   #--------------------------------------------------------------------------
  3013.   def set_remain_back_data
  3014.     return back_data_scroll_on if @move_x != 0 or @move_y != 0
  3015.     create_back(@active_data[8][0])
  3016.     @move_x    = @active_data[8][1]
  3017.     @move_y    = @active_data[8][2]
  3018.     @scroll_x  = @active_data[8][3]
  3019.     @scroll_y  = @active_data[8][4]
  3020.   end  
  3021.   #--------------------------------------------------------------------------
  3022.   # ● 背景画像の作成
  3023.   #--------------------------------------------------------------------------
  3024.   def create_back(back_name)
  3025.     return if back_name == @back_name or back_name == ""
  3026.     self.bitmap = Cache.battleback1(back_name) if @index == 1
  3027.     self.bitmap = Cache.battleback2(back_name) if @index == 2
  3028.     @back_name = back_name
  3029.   end  
  3030.   #--------------------------------------------------------------------------
  3031.   # ● 背景変更補正画像の作成
  3032.   #--------------------------------------------------------------------------
  3033.   def create_back_adjust
  3034.     return if @active_data[9][0] == false
  3035.     @active_data[10] = true
  3036.     mirror = $sv_camera.mirror
  3037.     mirror = false if !@active_data[4]
  3038.     @bt_back = []
  3039.     @bt_back[0] = Sprite.new(viewport)
  3040.     @bt_back[0].bitmap = Cache.battleback1(@active_data[6]) if @index == 1
  3041.     @bt_back[0].bitmap = Cache.battleback2(@active_data[6]) if @index == 2
  3042.     @bt_back[0].mirror = mirror
  3043.     @bt_back[1] = Sprite.new(viewport)
  3044.     @bt_back[1].bitmap = Cache.battleback1(@active_data[5]) if @index == 1
  3045.     @bt_back[1].bitmap = Cache.battleback2(@active_data[5]) if @index == 2
  3046.     @bt_back[1].mirror = mirror
  3047.   end
  3048.   #--------------------------------------------------------------------------
  3049.   # ● 背景スクロールの更新
  3050.   #--------------------------------------------------------------------------
  3051.   def update_scroll
  3052.     @scroll_x += @move_x
  3053.     @scroll_y += @move_y
  3054.     @scroll_x = 0 if @scroll_x / 100 >= self.bitmap.width * @zoom_x or @scroll_x / 100 <= -self.bitmap.width * @zoom_x
  3055.     @scroll_y = 0 if @scroll_y / 100 >= self.bitmap.height * @zoom_y or @scroll_y / 100 <= -self.bitmap.height * @zoom_y
  3056.   end
  3057.   #--------------------------------------------------------------------------
  3058.   # ● 色調変更の更新
  3059.   #--------------------------------------------------------------------------
  3060.   def update_color
  3061.     color_set if $sv_camera.color_set[@index] != nil
  3062.     return if @color_data == nil
  3063.     @color_data[4] -= 1
  3064.     if @color_data[4] == 0 && @color_data[5] != 0
  3065.       @color_data[4] = @color_data[5]
  3066.       @color_data[5] = 0
  3067.       @color_data[6] = [0,0,0,0]
  3068.     elsif @color_data[4] == 0
  3069.       @remain_color_data = @color_data
  3070.       return @color_data = nil
  3071.     end  
  3072.     for i in 0..3
  3073.       @color_data[i] = (@color_data[i] * (@color_data[4] - 1) + @color_data[6][i]) / @color_data[4]
  3074.     end  
  3075.     self.color.set(@color_data[0], @color_data[1], @color_data[2], @color_data[3])
  3076.   end
  3077.   #--------------------------------------------------------------------------
  3078.   # ● 座標の更新
  3079.   #--------------------------------------------------------------------------
  3080.   def update_position
  3081.     self.ox = $sv_camera.x + @base_x - @scroll_x / 100
  3082.     self.oy = $sv_camera.y + @base_y - @scroll_y / 100
  3083.     self.ox -= $sv_camera.sx / 100 if @shake_on
  3084.     self.oy -= $sv_camera.sy / 100 if @shake_on
  3085.     self.zoom_x = @zoom_x * $sv_camera.zoom
  3086.     self.zoom_y = @zoom_y * $sv_camera.zoom
  3087.     self.ox *= $sv_camera.zoom
  3088.     self.oy *= $sv_camera.zoom
  3089.     self.z = @index * 10
  3090.   end
  3091.   #--------------------------------------------------------------------------
  3092.   # ● 背景変更補正画像を更新
  3093.   #--------------------------------------------------------------------------
  3094.   def update_back_adjust
  3095.     @active_data[9][0][0] = 0 if @scroll_x == 0
  3096.     @active_data[9][0][1] = 0 if @scroll_y == 0
  3097.     @active_data[9][1][0] -= @active_data[9][2][0] if @scroll_x == 0
  3098.     @active_data[9][1][1] -= @active_data[9][2][1] if @scroll_y == 0
  3099.     for i in 0...@bt_back.size
  3100.       @bt_back[i].x = -self.ox + @active_data[9][i][0] * $sv_camera.zoom
  3101.       @bt_back[i].y = -self.oy + @active_data[9][i][1] * $sv_camera.zoom
  3102.       @bt_back[i].zoom_x = self.zoom_x
  3103.       @bt_back[i].zoom_y = self.zoom_y
  3104.       @bt_back[i].z = self.z + 1
  3105.       @bt_back[i].color.set(@color_data[0], @color_data[1], @color_data[2], @color_data[3]) if @color_data != nil
  3106.     end
  3107.     back_data_scroll_on if @active_data[9][0][0] == 0 && @active_data[9][0][1] == 0
  3108.     return unless @active_data[9][1][0] == 0 && @active_data[9][1][1] == 0
  3109.     bt_back_dispose
  3110.     create_back(@active_data[5])
  3111.     @active_data[9][0] = false
  3112.     next_back_data if @remain && @back_data.size != 1
  3113.     @remain = false
  3114.   end
  3115.   #--------------------------------------------------------------------------
  3116.   # ● 色調変更
  3117.   #--------------------------------------------------------------------------
  3118.   def color_set
  3119.     set = $sv_camera.color_set[@index]
  3120.     $sv_camera.color_set[@index] = nil
  3121.     set[4] = 1 if set[4] == 0
  3122.     @remain_color_data = [0,0,0,0] if @remain_color_data == nil
  3123.     @color_data = @remain_color_data
  3124.     @color_data[4] = set[4]
  3125.     @color_data[5] = set[5]
  3126.     @color_data[6] = set
  3127.   end
  3128.   #--------------------------------------------------------------------------
  3129.   # ● 背景変更補正画像の解放
  3130.   #--------------------------------------------------------------------------
  3131.   def bt_back_dispose
  3132.     for i in 0...@bt_back.size do @bt_back[i].dispose end if @bt_back != nil
  3133.     @bt_back = nil
  3134.   end  
  3135.   #--------------------------------------------------------------------------
  3136.   # ● 解放
  3137.   #--------------------------------------------------------------------------
  3138.   def dispose
  3139.     bitmap.dispose if bitmap
  3140.     bt_back_dispose
  3141.     super
  3142.   end
  3143. end  
  3144.   
  3145. #==============================================================================
  3146. # ■ Battle_Camera
  3147. #------------------------------------------------------------------------------
  3148. #  戦闘カメラやバトルプログラムを扱うクラスです。
  3149. #==============================================================================
  3150. class Battle_Camera
  3151.   #--------------------------------------------------------------------------
  3152.   # ● 公開インスタンス変数 
  3153.   #--------------------------------------------------------------------------
  3154.   attr_reader   :sx                 # シェイクX座標
  3155.   attr_reader   :sy                 # シェイクY座標
  3156.   attr_reader   :max_top            # 上限界座標
  3157.   attr_reader   :max_bottom         # 下限界座標
  3158.   attr_reader   :max_left           # 左限界座標
  3159.   attr_reader   :max_right          # 右限界座標
  3160.   attr_accessor :switches           # サイドビュー専用スイッチ
  3161.   attr_accessor :color_set          # 色調変更データ
  3162.   attr_accessor :wait               # 戦闘シーンの強制ウエイト
  3163.   attr_accessor :win_wait           # 戦闘勝利前のウエイト
  3164.   attr_accessor :mirror             # 画面反転フラグ
  3165.   attr_accessor :program_scroll     # バトルプログラム 背景の自動スクロール
  3166.   attr_accessor :program_picture    # バトルプログラム 周期ピクチャ
  3167.   attr_accessor :event              # コモンイベント呼び出し
  3168.   #--------------------------------------------------------------------------
  3169.   # ● オブジェクト初期化
  3170.   #--------------------------------------------------------------------------
  3171.   def initialize
  3172.     @switches = []
  3173.     @max_data = []
  3174.     @color_set = []
  3175.     @wait = 0
  3176.     @win_wait = false
  3177.     @mirror = false
  3178.     @event = false
  3179.     setup
  3180.   end
  3181.   #--------------------------------------------------------------------------
  3182.   # ● カメラX座標
  3183.   #--------------------------------------------------------------------------
  3184.   def x
  3185.     return @x / 100
  3186.   end
  3187.   #--------------------------------------------------------------------------
  3188.   # ● カメラY座標
  3189.   #--------------------------------------------------------------------------
  3190.   def y
  3191.     return @y / 100
  3192.   end
  3193.   #--------------------------------------------------------------------------
  3194.   # ● ズーム率
  3195.   #--------------------------------------------------------------------------
  3196.   def zoom
  3197.     return @zoom * 0.001
  3198.   end
  3199.   #--------------------------------------------------------------------------
  3200.   # ● ズーム率による座標変換
  3201.   #--------------------------------------------------------------------------
  3202.   def convert
  3203.     return @zoom
  3204.   end
  3205.   #--------------------------------------------------------------------------
  3206.   # ● カメラセットアップ
  3207.   #--------------------------------------------------------------------------
  3208.   def setup
  3209.     @x = 0
  3210.     @y = 0
  3211.     @sx = 0
  3212.     @sy = 0
  3213.     @zoom = 1000
  3214.     @time = 0
  3215.     @shake_time = 0
  3216.     program_setup
  3217.   end
  3218.   #--------------------------------------------------------------------------
  3219.   # ● カメラ初期化
  3220.   #--------------------------------------------------------------------------
  3221.   def reset
  3222.     @switches = []
  3223.     @max_data = []
  3224.     @color_set = []
  3225.     @wait = 0
  3226.     @win_wait = false
  3227.     @mirror = false
  3228.     program_setup(false)
  3229.   end  
  3230.   #--------------------------------------------------------------------------
  3231.   # ● バトルプログラムのセットアップ
  3232.   #--------------------------------------------------------------------------
  3233.   def program_setup(check = true)
  3234.     @played_program  = []
  3235.     @program_switch  = []
  3236.     @program_sound   = []
  3237.     @program_scroll  = []
  3238.     @program_se      = []
  3239.     @program_shake   = []
  3240.     @program_color   = []
  3241.     @program_picture = []
  3242.     @program_base = N03::BATTLE_PROGRAM.values.dup
  3243.     program_check if check
  3244.   end  
  3245.   #--------------------------------------------------------------------------
  3246.   # ● バトルプログラムのチェック
  3247.   #--------------------------------------------------------------------------
  3248.   def program_check
  3249.     for data in @program_base
  3250.       if program_start?(data) && !@played_program.include?(data)
  3251.         @played_program.push(data.dup)
  3252.         @program_scroll.push(data.dup)  if data[0] == "scroll"
  3253.         @program_picture.push(data.dup) if data[0] == "kpic"
  3254.         start_sound(data.dup)           if data[0] == "sound"
  3255.         start_program_switch(data.dup)  if data[0] == "switch"
  3256.         start_program_se(data.dup)      if data[0] == "keep_se"
  3257.         start_program_shake(data.dup)   if data[0] == "keep_sk"
  3258.         start_program_color(data.dup)   if data[0] == "keep_c"
  3259.       else
  3260.         @played_program.delete(data)  if !program_start?(data)
  3261.         @program_scroll.delete(data)  if data[0] == "scroll"
  3262.         @program_picture.delete(data) if data[0] == "kpic"
  3263.         @program_switch.delete(data)  if data[0] == "switch"
  3264.         @program_sound.delete(data)   if data[0] == "sound"
  3265.         @program_se.delete(data)      if data[0] == "keep_se"
  3266.         @program_shake.delete(data)   if data[0] == "keep_sk"
  3267.         @program_color.delete(data)   if data[0] == "keep_c"
  3268.       end
  3269.     end
  3270.   end
  3271.   #--------------------------------------------------------------------------
  3272.   # ● バトルプログラムの開始
  3273.   #--------------------------------------------------------------------------
  3274.   def program_start?(data)
  3275.     start = false
  3276.     start = true if $game_switches[data[1].abs] && data[1] > 0
  3277.     start = true if @switches[data[1].abs] && data[1] < 0
  3278.     return start
  3279.   end  
  3280.   #--------------------------------------------------------------------------
  3281.   # ● バトルプログラム スイッチ操作の開始
  3282.   #--------------------------------------------------------------------------
  3283.   def start_program_switch(data)
  3284.     data[4] = data[4] + rand(data[5] + 1)
  3285.     data[4] = 1 if data[4] <= 0
  3286.     @program_switch.push(data)
  3287.   end
  3288.   #--------------------------------------------------------------------------
  3289.   # ● スイッチ操作の更新
  3290.   #--------------------------------------------------------------------------
  3291.   def update_program_switch
  3292.     for data in @program_switch
  3293.       data[4] -= 1
  3294.       next @program_switch.delete(data) if data[1] > 0 && !$game_switches[data[1]]
  3295.       next @program_switch.delete(data) if data[1] < 0 && !@switches[data[1].abs]
  3296.       next if data[4] != 0
  3297.       for id in data[2]
  3298.         $game_switches[id] = true if id > 0
  3299.         @switches[id.abs] = true  if id < 0
  3300.       end
  3301.       for id in data[3]
  3302.         $game_switches[id] = false if id > 0
  3303.         @switches[id.abs] = false  if id < 0
  3304.       end
  3305.       @program_switch.delete(data)
  3306.       program_check
  3307.     end  
  3308.   end
  3309.   #--------------------------------------------------------------------------
  3310.   # ● バトルプログラム BGM/BGSの開始
  3311.   #--------------------------------------------------------------------------
  3312.   def start_sound(data)
  3313.     @program_sound.push(data)
  3314.     name = data[5]
  3315.     case data[2]
  3316.     when "se"
  3317.       Audio.se_play("Audio/SE/" + name, data[4], data[3])
  3318.     when "bgm"
  3319.       name = RPG::BGM.last.name if data[5] == ""
  3320.       Audio.bgm_play("Audio/BGM/" + name, data[4], data[3])
  3321.     when "bgs"
  3322.       name = RPG::BGS.last.name if data[5] == ""
  3323.       Audio.bgs_play("Audio/BGS/" + name, data[4], data[3])
  3324.     end
  3325.   end
  3326.   #--------------------------------------------------------------------------
  3327.   # ● バトルプログラム 周期SEの開始
  3328.   #--------------------------------------------------------------------------
  3329.   def start_program_se(data)
  3330.     data[3] = [data[2], data[3]]
  3331.     data[2] = data[3][0] + rand(data[3][1] + 1)
  3332.     @program_se.push(data)
  3333.     Audio.se_play("Audio/SE/" + data[7], data[5], data[4]) if data[6]
  3334.   end
  3335.   #--------------------------------------------------------------------------
  3336.   # ● 周期SEの更新
  3337.   #--------------------------------------------------------------------------
  3338.   def update_program_se
  3339.     for data in @program_se
  3340.       data[2] -= 1
  3341.       next @program_se.delete(data) if data[1] > 0 && !$game_switches[data[1]]
  3342.       next @program_se.delete(data) if data[1] < 0 && !@switches[data[1].abs]
  3343.       next if data[2] != 0
  3344.       Audio.se_play("Audio/SE/" + data[7], data[5], data[4])
  3345.       data[2] = data[3][0] + rand(data[3][1] + 1)
  3346.     end  
  3347.   end
  3348.   #--------------------------------------------------------------------------
  3349.   # ● バトルプログラム 周期シェイクの開始
  3350.   #--------------------------------------------------------------------------
  3351.   def start_program_shake(data)
  3352.     data[3] = [data[2], data[3]]
  3353.     data[2] = data[3][0] + rand(data[3][1] + 1)
  3354.     @program_shake.push(data)
  3355.     shake(data[4], data[5], data[6]) if data[7]
  3356.   end
  3357.   #--------------------------------------------------------------------------
  3358.   # ● 周期シェイクの更新
  3359.   #--------------------------------------------------------------------------
  3360.   def update_program_shake
  3361.     for data in @program_shake
  3362.       data[2] -= 1
  3363.       next @program_shake.delete(data) if data[1] > 0 && !$game_switches[data[1]]
  3364.       next @program_shake.delete(data) if data[1] < 0 && !@switches[data[1].abs]
  3365.       next if data[2] != 0
  3366.       shake(data[4], data[5], data[6])
  3367.       data[2] = data[3][0] + rand(data[3][1] + 1)
  3368.     end  
  3369.   end
  3370.   #--------------------------------------------------------------------------
  3371.   # ● バトルプログラム 周期色調変更の開始
  3372.   #--------------------------------------------------------------------------
  3373.   def start_program_color(data)
  3374.     data[3] = [data[2], data[3]]
  3375.     data[2] = data[3][0] + rand(data[3][1] + 1)
  3376.     data[7] = true if data[4] == 0 or data[4] == 4
  3377.     case data[4]
  3378.     when 1   ;data[4] = $game_troop.members
  3379.     when 2   ;data[4] = $game_party.battle_members
  3380.     when 3,4 ;data[4] = $game_troop.members + $game_party.battle_members
  3381.     else ;data[4] = []
  3382.     end
  3383.     @program_color.push(data)
  3384.     return if !data[6]
  3385.     for target in data[4] do target.sv.color_set = data[5] end if data[4] != []
  3386.     @color_set[1] = data[5] if data[7]
  3387.     @color_set[2] = data[5] if data[7]
  3388.   end
  3389.   #--------------------------------------------------------------------------
  3390.   # ● 周期色調変更の更新
  3391.   #--------------------------------------------------------------------------
  3392.   def update_program_color
  3393.     for data in @program_color
  3394.       data[2] -= 1
  3395.       next @program_color.delete(data) if data[1] > 0 && !$game_switches[data[1]]
  3396.       next @program_color.delete(data) if data[1] < 0 && !@switches[data[1].abs]
  3397.       next if data[2] != 0
  3398.       for target in data[4] do target.sv.color_set = data[5] end if data[4] != []
  3399.       @color_set[1] = data[5] if data[7]
  3400.       @color_set[2] = data[5] if data[7]
  3401.       data[2] = data[3][0] + rand(data[3][1] + 1)
  3402.     end
  3403.   end
  3404.   #--------------------------------------------------------------------------
  3405.   # ● トランジション実行
  3406.   #--------------------------------------------------------------------------
  3407.   def perform_transition(data)
  3408.     Graphics.transition(data[2], "Graphics/Pictures/" + data[3], data[1])
  3409.   end  
  3410.   #--------------------------------------------------------------------------
  3411.   # ● 背景からカメラの限界値を取得  data = [max_top, max_bottom, max_left, max_right]
  3412.   #--------------------------------------------------------------------------
  3413.   def setting(index, data)
  3414.     @max_data[index - 1] = data
  3415.     return if index != 2
  3416.     setup
  3417.     # カメラの中心座標
  3418.     @center_x     = (Graphics.width / 2 + N03::CAMERA_POSITION[0]) * 100
  3419.     @center_y     = (Graphics.height / 2 + N03::CAMERA_POSITION[1]) * 100
  3420.     # 上下左右の移動限界距離
  3421.     @max_top    = [@max_data[0][5], @max_data[1][5]].min * -1
  3422.     @max_bottom = [@max_data[0][1], @max_data[1][1]].min + @max_top
  3423.     @max_left   = [@max_data[0][4], @max_data[1][4]].min  * -1
  3424.     @max_right  = [@max_data[0][3], @max_data[1][3]].min + @max_left
  3425.     exist_data = @max_data[0] if !@max_data[1][6]
  3426.     exist_data = @max_data[1] if !@max_data[0][6]
  3427.     @max_top    = exist_data[5] * -1        if exist_data != nil
  3428.     @max_bottom = exist_data[1] + @max_top  if exist_data != nil
  3429.     @max_left   = exist_data[4] * -1        if exist_data != nil
  3430.     @max_right  = exist_data[3] + @max_left if exist_data != nil
  3431.     @max_top = @max_bottom = @max_left = @max_right = 0 if !@max_data[1][6] && !@max_data[0][6]
  3432.     @max_width    = @max_right - @max_left + Graphics.width
  3433.     @max_height   = @max_bottom - @max_top + Graphics.height
  3434.     # ズームアウト限界値
  3435.     max_zoom_x    = 100 * Graphics.width / @max_width
  3436.     max_zoom_y    = 100 * Graphics.height / @max_height
  3437.     @max_zoom_out = [max_zoom_x, max_zoom_y].max
  3438.   end
  3439.   #--------------------------------------------------------------------------
  3440.   # ● カメラ移動
  3441.   #--------------------------------------------------------------------------
  3442.   def move(target_x, target_y, zoom, time, screen = true)
  3443.     # 戦闘背景以上のサイズまでズームアウトしないよう調整
  3444.     @target_zoom = [zoom * 0.01, @max_zoom_out * 0.01].max
  3445.     target_x *= -1 if screen && @mirror
  3446.     # ズーム分の中心座標補正
  3447.     if screen && @target_zoom != 1
  3448.       target_x = target_x + @center_x
  3449.       target_y = target_y + @center_y
  3450.     end
  3451.     adjust_x = @center_x * (@target_zoom - 1) / (@target_zoom ** 2 - @target_zoom)
  3452.     adjust_y = @center_y * (@target_zoom - 1) / (@target_zoom ** 2 - @target_zoom)
  3453.     adjust_x = 0 if adjust_x.nan?
  3454.     adjust_y = 0 if adjust_y.nan?
  3455.     adjust_x = @center_x if !screen && adjust_x == 0
  3456.     adjust_y = @center_y if !screen && adjust_y == 0
  3457.     @target_x = target_x - adjust_x.to_i
  3458.     @target_y = target_y - adjust_y.to_i
  3459.     @target_zoom = (@target_zoom * 1000).to_i
  3460.     @zoom = @zoom.to_i
  3461.     limit_test
  3462.     # 時間0の場合は即実行
  3463.     return @time = time.abs if time != 0
  3464.     @time = 1
  3465.     update
  3466.   end
  3467.   #--------------------------------------------------------------------------
  3468.   # ● 限界座標の試算
  3469.   #--------------------------------------------------------------------------
  3470.   def limit_test
  3471.     new_width = @max_width * @target_zoom / 1000
  3472.     new_height = @max_height * @target_zoom / 1000
  3473.     new_max_right = @max_right - (@max_width - new_width)
  3474.     new_max_bottom = @max_bottom - (@max_height - new_height)
  3475.     # 画面の移動先が限界の場合、限界座標をセット
  3476.     if @target_x < @max_left * 100
  3477.       @target_x = @max_left * 100
  3478.     end
  3479.     if @target_x > new_max_right * 100
  3480.       @target_x = new_max_right * 100
  3481.     end
  3482.     if @target_y < @max_top * 100
  3483.       @target_y = @max_top * 100
  3484.     end
  3485.     if @target_y > new_max_bottom * 100
  3486.       @target_y = new_max_bottom * 100
  3487.     end
  3488.   end
  3489.   #--------------------------------------------------------------------------
  3490.   # ● 画面のシェイク
  3491.   #--------------------------------------------------------------------------
  3492.   def shake(power, speed, time)
  3493.     @shake_x = power[0] * 100
  3494.     @shake_y = power[1] * 100
  3495.     @power_time_base = @power_time = speed
  3496.     @shake_time = time
  3497.     update_shake
  3498.   end
  3499.   #--------------------------------------------------------------------------
  3500.   # ● シェイクの更新
  3501.   #--------------------------------------------------------------------------
  3502.   def update_shake
  3503.     @sx = (@sx * (@power_time - 1) + @shake_x) / @power_time
  3504.     @sy = (@sy * (@power_time - 1) + @shake_y) / @power_time
  3505.     @power_time -= 1
  3506.     @shake_time -= 1
  3507.     return @sx = @sy = 0 if @shake_time == 0
  3508.     return if @power_time != 0
  3509.     @power_time = @power_time_base
  3510.     @shake_x = @shake_x * -4 / 5
  3511.     @shake_y = @shake_y * -4 / 5
  3512.   end
  3513.   #--------------------------------------------------------------------------
  3514.   # ● フレーム更新
  3515.   #--------------------------------------------------------------------------
  3516.   def update
  3517.     update_shake if @shake_time != 0
  3518.     update_program
  3519.     return if @time == 0
  3520.     @x = (@x * (@time - 1) + @target_x) / @time
  3521.     @y = (@y * (@time - 1) + @target_y) / @time
  3522.     @zoom = (@zoom * (@time - 1) + @target_zoom) / @time
  3523.     @time -= 1
  3524.   end
  3525.   #--------------------------------------------------------------------------
  3526.   # ● フレーム更新
  3527.   #--------------------------------------------------------------------------
  3528.   def update_program
  3529.     update_program_switch if @program_switch != []
  3530.     update_program_se     if @program_se != []
  3531.     update_program_shake  if @program_shake != []
  3532.     update_program_color  if @program_color != []
  3533.   end
  3534. end

  3535. #==============================================================================
  3536. # ■ Scene_Battle
  3537. #------------------------------------------------------------------------------
  3538. #  バトル画面の処理を行うクラスです。
  3539. #==============================================================================
  3540. class Scene_Battle < Scene_Base
  3541.   #--------------------------------------------------------------------------
  3542.   # ● フレーム更新(基本)
  3543.   #--------------------------------------------------------------------------
  3544.   alias update_basic_scene_battle_n03 update_basic
  3545.   def update_basic
  3546.     update_basic_scene_battle_n03
  3547.     $sv_camera.update
  3548.     $sv_camera.wait = N03::TURN_END_WAIT + 1 if $sv_camera.win_wait
  3549.     camera_wait
  3550.   end
  3551.   #--------------------------------------------------------------------------
  3552.   # ● カメラウェイト
  3553.   #--------------------------------------------------------------------------
  3554.   def camera_wait
  3555.     process_event if $sv_camera.event
  3556.     $sv_camera.event = false if $sv_camera.event
  3557.     while $sv_camera.wait != 0
  3558.       Graphics.update
  3559.       Input.update
  3560.       update_all_windows
  3561.       $game_timer.update
  3562.       $game_troop.update
  3563.       $sv_camera.update
  3564.       @spriteset.update
  3565.       update_info_viewport
  3566.       update_message_open
  3567.       $sv_camera.wait -= 1 if $sv_camera.wait > 0
  3568.       $sv_camera.wait = 1 if $sv_camera.wait == 0 && @spriteset.effect?
  3569.       BattleManager.victory if $sv_camera.win_wait && $sv_camera.wait == 0
  3570.     end
  3571.   end
  3572.   #--------------------------------------------------------------------------
  3573.   # ● カメラウェイトのセット
  3574.   #--------------------------------------------------------------------------
  3575.   def set_camera_wait(time)
  3576.     $sv_camera.wait = time
  3577.     camera_wait
  3578.   end  
  3579.   #--------------------------------------------------------------------------
  3580.   # ● エフェクト実行が終わるまでウェイト ★再定義
  3581.   #--------------------------------------------------------------------------
  3582.   def wait_for_effect
  3583.   end
  3584.   #--------------------------------------------------------------------------
  3585.   # ● ターン開始
  3586.   #--------------------------------------------------------------------------
  3587.   alias turn_start_scene_battle_n03 turn_start
  3588.   def turn_start
  3589.     turn_start_scene_battle_n03
  3590.     N03.camera(nil, N03::BATTLE_CAMERA["ターン開始後"].dup)
  3591.   end
  3592.   #--------------------------------------------------------------------------
  3593.   # ● ターン終了
  3594.   #--------------------------------------------------------------------------
  3595.   alias turn_end_scene_battle_n03 turn_end
  3596.   def turn_end
  3597.     turn_end_scene_battle_n03
  3598.     for member in $game_troop.members + $game_party.members
  3599.       N03.set_damage(member, member.sv.result_damage[0],member.sv.result_damage[1])
  3600.       member.sv.result_damage = [0,0]
  3601.       @spriteset.set_damage_pop(member) if member.result.hp_damage != 0 or member.result.mp_damage != 0
  3602.     end
  3603.     set_camera_wait(N03::TURN_END_WAIT)
  3604.     N03.camera(nil, N03::BATTLE_CAMERA["ターン開始前"].dup) if $game_party.inputable?
  3605.     @log_window.clear
  3606.   end
  3607.   #--------------------------------------------------------------------------
  3608.   # ● スキル/アイテムの使用 ★再定義
  3609.   #--------------------------------------------------------------------------
  3610.   def use_item
  3611.     item = @subject.current_action.item
  3612.     display_item(item)
  3613.     @subject.use_item(item)
  3614.     refresh_status
  3615.     @targets = @subject.current_action.make_targets.compact
  3616.     @targets = [@subject] if @targets.size == 0
  3617.     set_substitute(item)
  3618.     for time in item.repeats.times do play_sideview(@targets, item) end
  3619.     end_reaction(item)
  3620.     display_end_item
  3621.   end
  3622.   #--------------------------------------------------------------------------
  3623.   # ● スキル/アイテム名の表示
  3624.   #--------------------------------------------------------------------------
  3625.   def display_item(item)
  3626.     return @log_window.display_use_item(@subject, item) if N03::BATTLE_LOG
  3627.     @log_window.off
  3628.     @skill_name_window = Window_Skill_name.new(item.name) unless N03::NO_DISPLAY_SKILL_ID.include?(item.id) && item.is_a?(RPG::Skill)
  3629.   end  
  3630.   #--------------------------------------------------------------------------
  3631.   # ● スキル/アイテム名の表示終了
  3632.   #--------------------------------------------------------------------------
  3633.   def display_end_item
  3634.     @skill_name_window.dispose if @skill_name_window != nil
  3635.     @skill_name_window = nil
  3636.     set_camera_wait(N03::ACTION_END_WAIT) if @subject.sv.derivation_skill_id == 0
  3637.     @log_window.clear if N03::BATTLE_LOG
  3638.   end  
  3639.   #--------------------------------------------------------------------------
  3640.   # ● 反撃/魔法反射/身代わり処理
  3641.   #--------------------------------------------------------------------------
  3642.   def end_reaction(item)
  3643.     end_substitute if @substitute != nil
  3644.     set_reflection(item) if @reflection_data != nil
  3645.     set_counter_attack if @counter_attacker != nil
  3646.   end  
  3647.   #--------------------------------------------------------------------------
  3648.   # ● 反撃の発動 ★再定義
  3649.   #--------------------------------------------------------------------------
  3650.   def invoke_counter_attack(target, item)
  3651.     return if @subject.sv.counter_id != 0
  3652.     @counter_attacker = [] if @counter_attacker == nil
  3653.     return apply_item_effects(apply_substitute(target, item), item) if !target.movable?
  3654.     @log_window.add_text(sprintf(Vocab::CounterAttack, target.name)) if N03::BATTLE_LOG
  3655.     target.sv.counter_id = target.sv.counter_skill_id
  3656.     @counter_attacker.push(target)
  3657.   end
  3658.   #--------------------------------------------------------------------------
  3659.   # ● 魔法反射の発動 ★再定義
  3660.   #--------------------------------------------------------------------------
  3661.   def invoke_magic_reflection(target, item)
  3662.     return if @subject.sv.reflection_id != 0
  3663.     @log_window.add_text(sprintf(Vocab::MagicReflection, target.name)) if N03::BATTLE_LOG
  3664.     target.sv.reflection_id = target.sv.reflection_anime_id
  3665.   end
  3666.   #--------------------------------------------------------------------------
  3667.   # ● 身代わりの適用 ★再定義
  3668.   #--------------------------------------------------------------------------
  3669.   def apply_substitute(target, item)
  3670.     return target if @substitute == nil
  3671.     return target if !check_substitute(target, item)
  3672.     return @substitute
  3673.   end
  3674.   #--------------------------------------------------------------------------
  3675.   # ● 身代わりセット
  3676.   #--------------------------------------------------------------------------
  3677.   def set_substitute(item)
  3678.     @substitute = N03.get_enemy_unit(@subject).substitute_battler
  3679.     return if @substitute == nil
  3680.     s_targets = []
  3681.     for i in [email protected]
  3682.       next if @targets[i] == @substitute
  3683.       next if !check_substitute(@targets[i], item)
  3684.       @log_window.add_text(sprintf(Vocab::Substitute, @substitute.name, @targets[i].name))
  3685.       @targets[i].sv.start_action(@targets[i].sv.substitute_receiver_start_action)
  3686.       s_targets.push(@targets[i])
  3687.       @targets[i] = @substitute
  3688.     end
  3689.     return @substitute = nil if s_targets == []
  3690.     @substitute.sv.set_target(s_targets)
  3691.     @substitute.sv.start_action(@substitute.sv.substitute_start_action)
  3692.   end  
  3693.   #--------------------------------------------------------------------------
  3694.   # ● 身代わり終了
  3695.   #--------------------------------------------------------------------------
  3696.   def end_substitute
  3697.     for member in @substitute.sv.target_battler
  3698.       member.sv.start_action(member.sv.substitute_receiver_end_action)
  3699.     end  
  3700.     @substitute.sv.start_action(@substitute.sv.substitute_end_action)
  3701.     @substitute = nil
  3702.   end
  3703.   #--------------------------------------------------------------------------
  3704.   # ● 反撃
  3705.   #--------------------------------------------------------------------------
  3706.   def set_counter_attack
  3707.     pre_subject = @subject
  3708.     for attacker in @counter_attacker
  3709.       @subject = attacker
  3710.       item = $data_skills[attacker.sv.counter_skill_id]
  3711.       play_sideview([pre_subject], item)
  3712.     end
  3713.     # 同一カウンター者を考慮してカウンターIDの初期化はアクション後に実行
  3714.     for attacker in @counter_attacker do attacker.sv.counter_id = 0 end
  3715.     @subject = pre_subject
  3716.     @counter_attacker = nil
  3717.   end
  3718.   #--------------------------------------------------------------------------
  3719.   # ● 魔法反射
  3720.   #--------------------------------------------------------------------------
  3721.   def set_reflection(item)
  3722.     @log_window.back_to(1)
  3723.     for data in @reflection_data
  3724.       @subject.sv.damage_action(@subject, item)
  3725.       N03.set_damage_anime_data([@subject], @subject, data)
  3726.       apply_item_effects(@subject, item)
  3727.       @spriteset.set_damage_pop(@subject)
  3728.     end
  3729.     set_camera_wait(N03.get_anime_time(@reflection_data[0][0]))
  3730.     @reflection_data = nil
  3731.   end
  3732.   #--------------------------------------------------------------------------
  3733.   # ● サイドビューアクション実行
  3734.   #--------------------------------------------------------------------------
  3735.   def play_sideview(targets, item)
  3736.     @subject.sv.set_target(targets)
  3737.     return if @subject.sv.attack_action(item) == nil
  3738.     return if [email protected]?
  3739.     return if item.scope != 9 && item.scope != 10 && !N03.targets_alive?(targets)
  3740.     @subject.sv.start_action(@subject.sv.attack_action(item))
  3741.     @subject.sv.unshift_action(@subject.sv.flash_action) if @subject.flash_flg
  3742.     @subject.sv.active = true
  3743.     @subject.sv.command_action = false
  3744.     loop do
  3745.       update_basic
  3746.       data = @subject.sv.play_data
  3747.       @targets = N03.s_targets(@subject) if data[0] == "second_targets_set"
  3748.       N03.targets_set(@subject)          if data[0] == "targets_set"
  3749.       @immortal = N03.immortaling        if data[0] == "no_collapse" && !N03.dead_attack?(@subject, item)
  3750.       @immortal = N03.unimmortaling      if data[0] == "collapse"
  3751.       next set_move_anime(item)          if @subject.sv.m_a_data != []
  3752.       set_damage(item)                   if @subject.sv.set_damage
  3753.       break N03.derived_skill(@subject)  if @subject.sv.derivation_skill_id != 0
  3754.       break                              if @subject.sv.action_end or @subject.hidden?
  3755.     end
  3756.     @immortal = N03.unimmortaling        if @immortal
  3757.   end
  3758.   #--------------------------------------------------------------------------
  3759.   # ● ダメージの実行
  3760.   #--------------------------------------------------------------------------
  3761.   def set_damage(item)
  3762.     targets = @targets
  3763.     targets = [@subject.sv.individual_targets[0]] if @subject.sv.individual_targets.size != 0
  3764.     for target in targets do damage_anime(targets.dup, target, item) end
  3765.     @subject.sv.set_damage = false
  3766.     @subject.sv.damage_anime_data = []
  3767.   end
  3768.   #--------------------------------------------------------------------------
  3769.   # ● ダメージ戦闘アニメ処理
  3770.   #--------------------------------------------------------------------------
  3771.   def damage_anime(targets, target, item)
  3772.     @log_window.back_to(1) if @log_window.line_number == 5
  3773.     return if item.scope != 9 && item.scope != 10 && target.dead?
  3774.     @miss = false
  3775.     invoke_item(target,item)
  3776.     if target.result.missed
  3777.       target.sv.miss_action(@subject, item)
  3778.       return @miss = true
  3779.     elsif target.result.evaded or target.sv.counter_id != 0
  3780.       target.sv.evasion_action(@subject, item)
  3781.       return @miss = true
  3782.     elsif target.sv.reflection_id != 0
  3783.       N03.set_damage_anime_data(targets, target, [target.sv.reflection_id, false, false, true])
  3784.       target.sv.reflection_id = 0
  3785.       @reflection_data = [] if @reflection_data == nil
  3786.       return @reflection_data.push([N03.get_attack_anime_id(-3, @subject), false, false, true])
  3787.     end
  3788.     target.sv.damage_action(@subject, item)
  3789.     N03.set_damage(@subject, -target.result.hp_drain, -target.result.mp_drain) if target != @subject
  3790.     @spriteset.set_damage_pop(target)
  3791.     @spriteset.set_damage_pop(@subject) if target != @subject && @subject.result.hp_damage != 0 or @subject.result.mp_damage != 0
  3792.     N03.set_damage_anime_data(targets, target, @subject.sv.damage_anime_data) if @subject.sv.damage_anime_data != []
  3793.   end
  3794.   #--------------------------------------------------------------------------
  3795.   # ● 飛ばしアニメ処理
  3796.   #--------------------------------------------------------------------------
  3797.   def set_move_anime(item)
  3798.     for data in @subject.sv.m_a_data
  3799.       @subject.sv.damage_anime_data = data[4]
  3800.       hit_targets = []
  3801.       for target in data[1]
  3802.         damage_anime(data[1], target, item) if data[0]
  3803.         hit_targets.push(target) if !@miss
  3804.       end
  3805.       @miss = false if !data[3]
  3806.       @spriteset.set_hit_animation(@subject, data[2], hit_targets, @miss)
  3807.     end
  3808.     @subject.sv.set_damage = false
  3809.     @subject.sv.m_a_data = []
  3810.   end
  3811. end

  3812. #==============================================================================
  3813. # ■ DataManager
  3814. #------------------------------------------------------------------------------
  3815. #  データベースとゲームオブジェクトを管理するモジュールです。
  3816. #==============================================================================
  3817. module DataManager
  3818.   #--------------------------------------------------------------------------
  3819.   # ● 各種ゲームオブジェクトの作成 ★再定義
  3820.   #--------------------------------------------------------------------------
  3821.   def self.create_game_objects
  3822.     $game_temp          = Game_Temp.new
  3823.     $game_system        = Game_System.new
  3824.     $game_timer         = Game_Timer.new
  3825.     $game_message       = Game_Message.new
  3826.     $game_switches      = Game_Switches.new
  3827.     $game_variables     = Game_Variables.new
  3828.     $game_self_switches = Game_SelfSwitches.new
  3829.     $game_actors        = Game_Actors.new
  3830.     $game_party         = Game_Party.new
  3831.     $game_troop         = Game_Troop.new
  3832.     $game_map           = Game_Map.new
  3833.     $game_player        = Game_Player.new
  3834.     $sv_camera          = Battle_Camera.new
  3835.   end
  3836. end

  3837. #==============================================================================
  3838. # ■ BattleManager
  3839. #------------------------------------------------------------------------------
  3840. #  戦闘の進行を管理するモジュールです。
  3841. #==============================================================================
  3842. module BattleManager
  3843.   #--------------------------------------------------------------------------
  3844.   # ● エンカウント時の処理 ★再定義
  3845.   #--------------------------------------------------------------------------
  3846.   def self.on_encounter
  3847.     @preemptive = (rand < rate_preemptive)
  3848.     @surprise = (rand < rate_surprise && !@preemptive)
  3849.     $sv_camera.mirror = @surprise if N03::BACK_ATTACK
  3850.   end
  3851.   #--------------------------------------------------------------------------
  3852.   # ● 勝利の処理 ★再定義
  3853.   #--------------------------------------------------------------------------
  3854.   def self.process_victory
  3855.     $sv_camera.win_wait = true
  3856.   end  
  3857.   #--------------------------------------------------------------------------
  3858.   # ● 勝利
  3859.   #--------------------------------------------------------------------------
  3860.   def self.victory
  3861.     $sv_camera.win_wait = false
  3862.     N03.camera(nil, N03::BATTLE_CAMERA["戦闘終了時"].dup)
  3863.     for member in $game_party.members do member.sv.start_action(member.sv.win) if member.movable? end
  3864.     play_battle_end_me
  3865.     replay_bgm_and_bgs
  3866.     $game_message.add(sprintf(Vocab::Victory, $game_party.name))
  3867.     display_exp
  3868.     gain_gold
  3869.     gain_drop_items
  3870.     gain_exp
  3871.     SceneManager.return
  3872.     battle_end(0)
  3873.     return true
  3874.   end
  3875.   #--------------------------------------------------------------------------
  3876.   # ● 逃走の処理 ★再定義
  3877.   #--------------------------------------------------------------------------
  3878.   def self.process_escape
  3879.     $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
  3880.     success = @preemptive ? true : (rand < @escape_ratio)
  3881.     Sound.play_escape
  3882.     if success
  3883.       process_abort
  3884.       for member in $game_party.members do member.sv.start_action(member.sv.escape) if member.movable? end
  3885.     else
  3886.       @escape_ratio += 0.1
  3887.       $game_message.add('\.' + Vocab::EscapeFailure)
  3888.       $game_party.clear_actions
  3889.       for member in $game_party.members do member.sv.start_action(member.sv.escape_ng) if member.movable? end
  3890.     end
  3891.     wait_for_message
  3892.     return success
  3893.   end
  3894.   #--------------------------------------------------------------------------
  3895.   # ● 次のコマンド入力へ ★再定義
  3896.   #--------------------------------------------------------------------------
  3897.   def self.next_command
  3898.     begin
  3899.       if !actor || !actor.next_command
  3900.         $game_party.battle_members[@actor_index].sv.command_action = true
  3901.         @actor_index += 1
  3902.         if @actor_index >= $game_party.members.size
  3903.           for member in $game_party.battle_members.reverse
  3904.             break member.sv.start_action(member.sv.command_a) if member.inputable?
  3905.           end
  3906.           return false
  3907.         end
  3908.       end
  3909.     end until actor.inputable?
  3910.     actor.sv.start_action(actor.sv.command_b) if actor != nil && actor.inputable?
  3911.     if pre_actor
  3912.       pre_actor.sv.start_action(pre_actor.sv.command_a) if pre_actor != nil && pre_actor.inputable?
  3913.     end
  3914.     return true
  3915.   end
  3916.   #--------------------------------------------------------------------------
  3917.   # ● 前のコマンド入力へ ★再定義
  3918.   #--------------------------------------------------------------------------
  3919.   def self.prior_command
  3920.     begin
  3921.       if !actor || !actor.prior_command
  3922.         $game_party.battle_members[@actor_index].sv.command_action = false
  3923.         @actor_index -= 1
  3924.         if @actor_index < 0
  3925.           for member in $game_party.battle_members
  3926.             break member.sv.start_action(member.sv.command_a) if member.inputable?
  3927.           end
  3928.           return false
  3929.         end
  3930.       end
  3931.     end until actor.inputable?
  3932.     actor.make_actions if actor.inputable?
  3933.     actor.sv.start_action(actor.sv.command_b) if actor.inputable?
  3934.     after_actor.sv.start_action(after_actor.sv.command_a) if after_actor != nil && after_actor.inputable?
  3935.     return true
  3936.   end
  3937.   #--------------------------------------------------------------------------
  3938.   # ● コマンド入力前のアクターを取得
  3939.   #--------------------------------------------------------------------------
  3940.   def self.pre_actor
  3941.     return if @actor_index == 0
  3942.     $game_party.members[@actor_index - 1]
  3943.   end
  3944.   #--------------------------------------------------------------------------
  3945.   # ● コマンド入力後のアクターを取得
  3946.   #--------------------------------------------------------------------------
  3947.   def self.after_actor
  3948.     $game_party.members[@actor_index + 1]
  3949.   end
  3950.   #--------------------------------------------------------------------------
  3951.   # ● 戦闘行動者を前に追加
  3952.   #--------------------------------------------------------------------------
  3953.   def self.unshift_action_battlers(battler)
  3954.     @action_battlers.unshift(battler)
  3955.   end
  3956. end  

  3957. #==============================================================================
  3958. # ■ Game_Battler
  3959. #------------------------------------------------------------------------------
  3960. #  スプライトや行動に関するメソッドを追加したバトラーのクラスです。
  3961. #==============================================================================
  3962. class Game_Battler < Game_BattlerBase
  3963.   #--------------------------------------------------------------------------
  3964.   # ● 公開インスタンス変数
  3965.   #--------------------------------------------------------------------------
  3966.   attr_reader   :sv                     # サイドビューデータ
  3967.   attr_accessor :flash_flg              # 閃きフラグ
  3968.   #--------------------------------------------------------------------------
  3969.   # ● オブジェクト初期化
  3970.   #--------------------------------------------------------------------------
  3971.   alias initialize_game_battler_n03 initialize
  3972.   def initialize
  3973.     initialize_game_battler_n03
  3974.     @sv = SideView.new(self)
  3975.   end
  3976.   #--------------------------------------------------------------------------
  3977.   # ● 現在の戦闘行動を除去
  3978.   #--------------------------------------------------------------------------
  3979.   alias remove_current_action_game_battler_n03 remove_current_action
  3980.   def remove_current_action
  3981.     return @sv.derivation_skill_id = 0 if @sv.derivation_skill_id != 0
  3982.     remove_current_action_game_battler_n03
  3983.   end
  3984.   #--------------------------------------------------------------------------
  3985.   # ● ターン終了処理
  3986.   #--------------------------------------------------------------------------
  3987.   alias on_turn_end_game_battler_n03 on_turn_end
  3988.   def on_turn_end
  3989.     on_turn_end_game_battler_n03
  3990.     @sv.add_state = []
  3991.     @sv.result_damage = [@result.hp_damage, @result.mp_damage]
  3992.   end
  3993.   #--------------------------------------------------------------------------
  3994.   # ● パラメータ条件比較 data = [種別, 数値, 判別]
  3995.   #--------------------------------------------------------------------------
  3996.   def comparison_parameter(data)
  3997.     return true if data[0][0] == 0
  3998.     kind = data[0]
  3999.     num = data[1]
  4000.     select = data[2]
  4001.     case kind
  4002.     when  1 ; par = level
  4003.     when  2 ; par = mhp
  4004.     when  3 ; par = mmp
  4005.     when  4 ; par = hp
  4006.     when  5 ; par = mp
  4007.     when  6 ; par = tp
  4008.     when  7 ; par = atk
  4009.     when  8 ; par = self.def
  4010.     when  9 ; par = mat
  4011.     when 10 ; par = mdf
  4012.     when 11 ; par = agi
  4013.     when 12 ; par = luk
  4014.     end
  4015.     if num < 0
  4016.       case kind
  4017.       when  4 ; num = mhp * num / 100
  4018.       when  5 ; num = mmp * num / 100
  4019.       when  6 ; num = max_tp * num / 100
  4020.       end
  4021.       num = num.abs
  4022.     end  
  4023.     case select
  4024.     when  0 ; return par == num
  4025.     when  1 ; return par < num
  4026.     when  2 ; return par > num
  4027.     end
  4028.   end
  4029.   #--------------------------------------------------------------------------
  4030.   # ● 装備条件比較 data = [装備種別, タイプID]
  4031.   #--------------------------------------------------------------------------
  4032.   def comparison_equip(data)
  4033.     kind = data[0]
  4034.     items = weapons if kind == 0
  4035.     items = armors  if kind == 1
  4036.     for item in items
  4037.       for id in data[1]
  4038.         return true if id > 0 && item.is_a?(RPG::Weapon) && item == $data_weapons[id.abs]
  4039.         return true if id > 0 && item.is_a?(RPG::Armor) && item == $data_armors[id.abs]
  4040.         return true if id < 0 && item.is_a?(RPG::Weapon) && item.wtype_id == id.abs
  4041.         return true if id < 0 && item.is_a?(RPG::Armor) && item.stype_id == id.abs
  4042.       end
  4043.     end
  4044.     return false
  4045.   end
  4046.   
  4047. end  
  4048. #==============================================================================
  4049. # ■ Game_Actor
  4050. #------------------------------------------------------------------------------
  4051. #  アクターを扱うクラスです。
  4052. #==============================================================================
  4053. class Game_Actor < Game_Battler
  4054.   #--------------------------------------------------------------------------
  4055.   # ● 公開インスタンス変数
  4056.   #--------------------------------------------------------------------------
  4057.   attr_reader :actor_id                    # ID
  4058.   #--------------------------------------------------------------------------
  4059.   # ● ID
  4060.   #--------------------------------------------------------------------------
  4061.   def id
  4062.     return @actor_id
  4063.   end
  4064.   #--------------------------------------------------------------------------
  4065.   # ● スプライトを使うか? ★再定義
  4066.   #--------------------------------------------------------------------------
  4067.   def use_sprite?
  4068.     return true
  4069.   end
  4070.   #--------------------------------------------------------------------------
  4071.   # ● ダメージ効果の実行 ★再定義
  4072.   #--------------------------------------------------------------------------
  4073.   def perform_damage_effect
  4074.     return if !N03::ACTOR_DAMAGE
  4075.     $game_troop.screen.start_shake(5, 5, 10)
  4076.     @sprite_effect_type = :blink
  4077.     Sound.play_actor_damage
  4078.   end
  4079.   
  4080. end

  4081. #==============================================================================
  4082. # ■ Game_Enemy
  4083. #------------------------------------------------------------------------------
  4084. #  敵キャラを扱うクラスです。
  4085. #==============================================================================
  4086. class Game_Enemy < Game_Battler
  4087.   #--------------------------------------------------------------------------
  4088.   # ● 公開インスタンス変数
  4089.   #--------------------------------------------------------------------------
  4090.   attr_reader :enemy_id                    # ID
  4091.   #--------------------------------------------------------------------------
  4092.   # ● ID
  4093.   #--------------------------------------------------------------------------
  4094.   def id
  4095.     return @enemy_id
  4096.   end
  4097.   #--------------------------------------------------------------------------
  4098.   # ● レベル
  4099.   #--------------------------------------------------------------------------
  4100.   def level
  4101.     return @sv.level
  4102.   end
  4103.   #--------------------------------------------------------------------------
  4104.   # ● ダメージ効果の実行 ★再定義
  4105.   #--------------------------------------------------------------------------
  4106.   def perform_damage_effect
  4107.     return if !N03::ENEMY_DAMAGE
  4108.     @sprite_effect_type = :blink
  4109.     Sound.play_enemy_damage
  4110.   end
  4111.   #--------------------------------------------------------------------------
  4112.   # ● 武器
  4113.   #--------------------------------------------------------------------------
  4114.   def weapons
  4115.     weapon1 = $data_weapons[@sv.enemy_weapon1_id]
  4116.     weapon2 = $data_weapons[@sv.enemy_weapon2_id]
  4117.     return [weapon1, weapon2]
  4118.   end
  4119.   #--------------------------------------------------------------------------
  4120.   # ● 防具
  4121.   #--------------------------------------------------------------------------
  4122.   def armors
  4123.     return [$data_armors[@sv.enemy_shield_id]]
  4124.   end
  4125.   #--------------------------------------------------------------------------
  4126.   # ● 二刀流の判定
  4127.   #--------------------------------------------------------------------------
  4128.   def dual_wield?
  4129.     return $data_weapons[@sv.enemy_weapon2_id] != nil
  4130.   end
  4131.   #--------------------------------------------------------------------------
  4132.   # ● バトラー画像変更
  4133.   #--------------------------------------------------------------------------
  4134.   def graphics_change(battler_name)
  4135.     @battler_name = battler_name
  4136.   end
  4137.   #--------------------------------------------------------------------------
  4138.   # ● 通常攻撃 アニメーション ID の取得
  4139.   #--------------------------------------------------------------------------
  4140.   def atk_animation_id1
  4141.     return weapons[0].animation_id if weapons[0]
  4142.     return weapons[1] ? 0 : 1
  4143.   end
  4144.   #--------------------------------------------------------------------------
  4145.   # ● 通常攻撃 アニメーション ID の取得(二刀流:武器2)
  4146.   #--------------------------------------------------------------------------
  4147.   def atk_animation_id2
  4148.     return weapons[1] ? weapons[1].animation_id : 0
  4149.   end
  4150. end

  4151. #==============================================================================
  4152. # ■ Sprite_Base
  4153. #------------------------------------------------------------------------------
  4154. #  アニメーションの表示処理を追加したスプライトのクラスです。
  4155. #==============================================================================
  4156. class Sprite_Base < Sprite
  4157.   #--------------------------------------------------------------------------
  4158.   # ● アニメーションの座標更新 (ホーミングあり)
  4159.   #--------------------------------------------------------------------------
  4160.   def update_animation_position_horming
  4161.     return if @action_end_cancel
  4162.     ani_ox_set if @horming
  4163.     camera_zoom = $sv_camera.zoom
  4164.     camera_zoom = 1 if @move_anime
  4165.     kind = 1
  4166.     kind = -1 if @ani_mirror && !@anime_no_mirror
  4167.     cell_data = @animation.frames[@animation.frame_max - (@ani_duration + @ani_rate - 1) / @ani_rate].cell_data
  4168.     for i in 0..15
  4169.       @ani_sprites[i].x = (@ani_ox + cell_data[i, 1] * kind - $sv_camera.x) * camera_zoom if @ani_sprites[i] != nil && cell_data[i, 1] != nil
  4170.       @ani_sprites[i].y = (@ani_oy + cell_data[i, 2] - $sv_camera.y) * camera_zoom if @ani_sprites[i] != nil && cell_data[i, 2] != nil
  4171.     end
  4172.   end
  4173.   #--------------------------------------------------------------------------
  4174.   # ● アニメーション元の座標をセット
  4175.   #--------------------------------------------------------------------------
  4176.   def ani_ox_set
  4177.     if !SceneManager.scene_is?(Scene_Battle)
  4178.       @real_x = x
  4179.       @real_y = y
  4180.     end
  4181.     @ani_ox = @real_x - ox + width / 2
  4182.     @ani_oy = @real_y - oy + height / 2
  4183.     @ani_oy -= height / 2 if @animation.position == 0
  4184.     @ani_oy += height / 2 if @animation.position == 2
  4185.   end
  4186.   #--------------------------------------------------------------------------
  4187.   # ● アニメーションの更新
  4188.   #--------------------------------------------------------------------------
  4189.   alias update_animation_sprite_base_n03 update_animation
  4190.   def update_animation
  4191.     update_animation_position_horming if animation? && SceneManager.scene_is?(Scene_Battle) && @animation.position != 3
  4192.     update_animation_sprite_base_n03
  4193.   end
  4194.   #--------------------------------------------------------------------------
  4195.   # ● アニメーションの原点設定 ★再定義
  4196.   #--------------------------------------------------------------------------
  4197.   def set_animation_origin
  4198.     return ani_ox_set if @animation.position != 3
  4199.     if viewport == nil
  4200.       @ani_ox = Graphics.width / 2
  4201.       @ani_oy = Graphics.height / 2
  4202.     else
  4203.       @ani_ox = viewport.rect.width / 2
  4204.       @ani_oy = viewport.rect.height / 2
  4205.     end
  4206.   end
  4207.   #--------------------------------------------------------------------------
  4208.   # ● アニメーションスプライトの設定 ★再定義
  4209.   #--------------------------------------------------------------------------
  4210.   def animation_set_sprites(frame)
  4211.     camera_zoom = 1
  4212.     camera_zoom = $sv_camera.zoom if @anime_camera_zoom && @animation.position != 3 && SceneManager.scene_is?(Scene_Battle)
  4213.     camera_x = $sv_camera.x
  4214.     camera_y = $sv_camera.y
  4215.     camera_x = camera_y = 0 if @animation.position == 3 or !SceneManager.scene_is?(Scene_Battle)
  4216.     plus_z = 5
  4217.     plus_z = 1000 if @animation.position == 3
  4218.     plus_z = -17 if @plus_z != nil && @plus_z == false
  4219.     plus_z = -self.z + 10 if @plus_z != nil && @plus_z == false && @animation.position == 3
  4220.     cell_data = frame.cell_data
  4221.     @ani_sprites.each_with_index do |sprite, i|
  4222.       next unless sprite
  4223.       pattern = cell_data[i, 0]
  4224.       if !pattern || pattern < 0
  4225.         sprite.visible = false
  4226.         next
  4227.       end
  4228.       sprite.bitmap = pattern < 100 ? @ani_bitmap1 : @ani_bitmap2
  4229.       sprite.visible = true
  4230.       sprite.src_rect.set(pattern % 5 * 192,
  4231.         pattern % 100 / 5 * 192, 192, 192)
  4232.       if @ani_mirror && !@anime_no_mirror
  4233.         sprite.x = (@ani_ox - cell_data[i, 1] - camera_x) * camera_zoom
  4234.         sprite.y = (@ani_oy + cell_data[i, 2] - camera_y) * camera_zoom
  4235.         sprite.angle = (360 - cell_data[i, 4])
  4236.         sprite.mirror = (cell_data[i, 5] == 0)
  4237.       else
  4238.         sprite.x = (@ani_ox + cell_data[i, 1] - camera_x) * camera_zoom
  4239.         sprite.y = (@ani_oy + cell_data[i, 2] - camera_y) * camera_zoom
  4240.         sprite.angle = cell_data[i, 4]
  4241.         sprite.mirror = (cell_data[i, 5] == 1)
  4242.       end
  4243.       sprite.z = self.z + plus_z + i
  4244.       sprite.ox = 96
  4245.       sprite.oy = 96
  4246.       sprite.zoom_x = cell_data[i, 3] * camera_zoom / 100.0
  4247.       sprite.zoom_y = cell_data[i, 3] * camera_zoom/ 100.0
  4248.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  4249.       sprite.blend_type = cell_data[i, 7]
  4250.     end
  4251.   end
  4252.   #--------------------------------------------------------------------------
  4253.   # ● 子スプライトフラグ
  4254.   #--------------------------------------------------------------------------
  4255.   def set(battler, horming, camera_zoom, no_mirror)
  4256.     @battler = battler
  4257.     @next = true
  4258.     self.bitmap = Bitmap.new(@battler.sv.cw, @battler.sv.ch)
  4259.     self.ox = bitmap.width / 2
  4260.     self.oy = bitmap.height
  4261.     @horming = horming
  4262.     @anime_camera_zoom = camera_zoom
  4263.     @anime_no_mirror = no_mirror
  4264.     @battler.sv.reset_anime_data
  4265.   end  
  4266.   #--------------------------------------------------------------------------
  4267.   # ● 子スプライト座標セット
  4268.   #--------------------------------------------------------------------------
  4269.   def set_position(z, zoom_x, zoom_y, real_x, real_y)
  4270.     self.z = z
  4271.     self.zoom_x = zoom_x
  4272.     self.zoom_y = zoom_y
  4273.     @real_x = real_x
  4274.     @real_y = real_y
  4275.   end
  4276.   #--------------------------------------------------------------------------
  4277.   # ● 他スプライトへのタイミング処理
  4278.   #--------------------------------------------------------------------------
  4279.   def other_process_timing(timing)
  4280.     se_flag = true
  4281.     se_flag = @se_flag if @se_flag != nil
  4282.     @battler.sv.timing.push([se_flag, timing.dup])
  4283.   end
  4284.   #--------------------------------------------------------------------------
  4285.   # ● 他バトラーへのタイミング処理
  4286.   #--------------------------------------------------------------------------
  4287.   def target_battler_process_timing(timing)
  4288.     for target in @timing_targets
  4289.       target.sv.timing.push([false, timing.dup])
  4290.     end  
  4291.   end
  4292.   #--------------------------------------------------------------------------
  4293.   # ● SE とフラッシュのタイミング処理
  4294.   #--------------------------------------------------------------------------
  4295.   alias animation_process_timing_sprite_base_n03 animation_process_timing
  4296.   def animation_process_timing(timing)
  4297.     target_battler_process_timing(timing) if @timing_targets && @timing_targets != []
  4298.     return other_process_timing(timing) if @next != nil
  4299.     animation_process_timing_sprite_base_n03(timing)
  4300.   end
  4301.   #--------------------------------------------------------------------------
  4302.   # ● アニメーションの解放
  4303.   #--------------------------------------------------------------------------
  4304.   alias dispose_animation_sprite_base_n03 dispose_animation
  4305.   def dispose_animation
  4306.     dispose_animation_sprite_base_n03
  4307.   end
  4308. end


  4309. #==============================================================================
  4310. # ■ Sprite_Battler
  4311. #------------------------------------------------------------------------------
  4312. #  バトラー表示用のスプライトです。
  4313. #==============================================================================
  4314. class Sprite_Battler < Sprite_Base
  4315.   #--------------------------------------------------------------------------
  4316.   # ● 公開インスタンス変数 
  4317.   #--------------------------------------------------------------------------
  4318.   attr_accessor   :removing             # パーティ離脱中
  4319.   #--------------------------------------------------------------------------
  4320.   # ● オブジェクト初期化
  4321.   #--------------------------------------------------------------------------
  4322.   alias initialize_sprite_battler_n03 initialize
  4323.   def initialize(viewport, battler = nil)
  4324.     initialize_sprite_battler_n03(viewport, battler)
  4325.     @real_x = @real_y = 0
  4326.     update_bitmap if @battler != nil
  4327.   end
  4328.   #--------------------------------------------------------------------------
  4329.   # ● アニメーションの開始 ★再定義
  4330.   #--------------------------------------------------------------------------
  4331.   def start_animation(animation, mirror = false)
  4332.     return next_animation(animation, mirror) if animation?
  4333.     @animation = animation
  4334.     if @animation
  4335.       @horming = @battler.sv.anime_horming
  4336.       @anime_camera_zoom = @battler.sv.anime_camera_zoom
  4337.       @anime_no_mirror = @battler.sv.anime_no_mirror
  4338.       @timing_targets = @battler.sv.timing_targets
  4339.       @plus_z = @battler.sv.anime_plus_z
  4340.       @battler.sv.reset_anime_data
  4341.       @ani_mirror = mirror
  4342.       set_animation_rate
  4343.       @ani_duration = @animation.frame_max * @ani_rate + 1
  4344.       load_animation_bitmap
  4345.       make_animation_sprites
  4346.       set_animation_origin
  4347.     end
  4348.   end
  4349.   #--------------------------------------------------------------------------
  4350.   # ● 次のアニメを開始
  4351.   #--------------------------------------------------------------------------
  4352.   def next_animation(animation, mirror)
  4353.     @next_anime = [] if @next_anime == nil
  4354.     @next_anime.push(Sprite_Base.new(viewport))
  4355.     @next_anime[@next_anime.size - 1].set(battler, @battler.sv.anime_horming, @battler.sv.anime_camera_zoom, @battler.sv.anime_no_mirror)
  4356.     @next_anime[@next_anime.size - 1].set_position(self.z, self.zoom_x, self.zoom_y, @real_x, @real_y)
  4357.     @next_anime[@next_anime.size - 1].start_animation(animation, mirror)
  4358.   end
  4359.   #--------------------------------------------------------------------------
  4360.   # ● 影グラフィック作成
  4361.   #--------------------------------------------------------------------------
  4362.   def create_shadow
  4363.     reset_shadow
  4364.     return if @battler.sv.shadow == false
  4365.     @shadow = Sprite.new(viewport) if @shadow == nil
  4366.     @shadow.bitmap = Cache.character(@battler.sv.shadow)
  4367.     @shadow.ox = @shadow.bitmap.width / 2
  4368.     @shadow.oy = @shadow.bitmap.height / 2
  4369.   end
  4370.   #--------------------------------------------------------------------------
  4371.   # ● 影グラフィック初期化
  4372.   #--------------------------------------------------------------------------
  4373.   def reset_shadow
  4374.     return if @shadow == nil
  4375.     @shadow.dispose
  4376.     @shadow = nil
  4377.   end  
  4378.   #--------------------------------------------------------------------------
  4379.   # ● 転送元ビットマップの更新 ★再定義
  4380.   #--------------------------------------------------------------------------
  4381.   def update_bitmap
  4382.     update_bitmap_enemy if [email protected]?
  4383.     update_bitmap_actor if @battler.actor?
  4384.     update_src_rect if @battler != nil
  4385.     update_color if @battler != nil
  4386.   end
  4387.   #--------------------------------------------------------------------------
  4388.   # ● 転送元ビットマップ:エネミー
  4389.   #--------------------------------------------------------------------------
  4390.   def update_bitmap_enemy
  4391.     if @battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue
  4392.       @battler_name = @battler.battler_name
  4393.       @battler_hue = @battler.battler_hue
  4394.       @battler_graphic_file_index = @battler.sv.graphic_file_index
  4395.       @graphic_mirror_flag = @battler.sv.graphic_mirror_flag
  4396.       self.bitmap = Cache.battler(@battler_name + @battler_graphic_file_index, @battler_hue)
  4397.       @battler.sv.setup(self.bitmap.width, self.bitmap.height, @battler_id != @battler.id)
  4398.       create_shadow
  4399.       init_visibility
  4400.       @battler_id = @battler.id
  4401.     end
  4402.   end  
  4403.   #--------------------------------------------------------------------------
  4404.   # ● 転送元ビットマップ:アクター
  4405.   #--------------------------------------------------------------------------
  4406.   def update_bitmap_actor
  4407.     if @battler.character_name != @battler_name or @battler.character_index != @battler_index
  4408.       @battler_name = @battler.character_name
  4409.       @battler_index = @battler.character_index
  4410.       @battler_graphic_file_index = @battler.sv.graphic_file_index
  4411.       @graphic_mirror_flag = @battler.sv.graphic_mirror_flag
  4412.       self.bitmap = Cache.character(@battler_name + @battler_graphic_file_index)
  4413.       @battler.sv.setup(self.bitmap.width, self.bitmap.height, @battler_id != @battler.id)
  4414.       create_shadow
  4415.       init_visibility
  4416.       @battler_id = @battler.id
  4417.     end
  4418.   end
  4419.   #--------------------------------------------------------------------------
  4420.   # ● 可視状態の初期化 ★再定義
  4421.   #--------------------------------------------------------------------------
  4422.   def init_visibility
  4423.     @battler_visible = @battler.alive?
  4424.     @battler_visible = true if @battler.sv.state(1) != "敵コラプス"
  4425.     @battler_visible = false if @battler.hidden?
  4426.     @battler.sv.opacity = 0 unless @battler_visible
  4427.     self.opacity = 0 unless @battler_visible
  4428.     self.opacity = 255 if @battler_visible
  4429.     @battler.sv.weapon_visible = @battler_visible
  4430.   end
  4431.   #--------------------------------------------------------------------------
  4432.   # ● 転送元矩形の更新
  4433.   #--------------------------------------------------------------------------
  4434.   def update_src_rect
  4435.     return if @battler.sv.collapse
  4436.     if @battler_graphic_file_index != @battler.sv.graphic_file_index
  4437.       @battler_graphic_file_index = @battler.sv.graphic_file_index
  4438.       self.bitmap = Cache.character(@battler_name + @battler_graphic_file_index) if @battler.actor?
  4439.       self.bitmap = Cache.battler(@battler_name + @battler_graphic_file_index, @battler_hue) if [email protected]?
  4440.       @battler.sv.set_graphics(self.bitmap.width, self.bitmap.height)
  4441.     end
  4442.     anime_off if @battler.sv.anime_off
  4443.     self.src_rect.set(@battler.sv.sx, @battler.sv.sy, @battler.sv.cw, @battler.sv.ch)
  4444.     self.opacity = @battler.sv.opacity if @battler_visible
  4445.     set_process_timing(@battler.sv.timing) if @battler && @battler.sv.timing != []
  4446.   end
  4447.   #--------------------------------------------------------------------------
  4448.   # ● 位置の更新 ★再定義
  4449.   #--------------------------------------------------------------------------
  4450.   def update_position
  4451.     @real_x = @battler.sv.x / 100
  4452.     @real_y = (@battler.sv.y - @battler.sv.h - @battler.sv.j - @battler.sv.c - @battler.sv.oy_adjust)/ 100
  4453.     self.x = @real_x - $sv_camera.x
  4454.     self.y = @real_y - $sv_camera.y
  4455.     self.z = @battler.sv.z - @battler.sv.c / 100
  4456.     if @battler.sv.h <= 0
  4457.       self.x += $sv_camera.sx / 100
  4458.       self.y += $sv_camera.sy / 100
  4459.     end  
  4460.     self.x *= $sv_camera.zoom
  4461.     self.y *= $sv_camera.zoom
  4462.   end
  4463.   #--------------------------------------------------------------------------
  4464.   # ● 原点の更新 ★再定義
  4465.   #--------------------------------------------------------------------------
  4466.   def update_origin
  4467.     return if !bitmap or @battler.sv.collapse
  4468.     self.ox = @battler.sv.ox
  4469.     self.oy = @battler.sv.oy
  4470.     self.angle = @battler.sv.angle
  4471.     self.zoom_x = @battler.sv.zoom_x * $sv_camera.zoom
  4472.     self.zoom_y = @battler.sv.zoom_y * $sv_camera.zoom
  4473.     self.mirror = @battler.sv.mirror if !@graphic_mirror_flag
  4474.     self.mirror = [email protected] if @graphic_mirror_flag
  4475.   end
  4476.   #--------------------------------------------------------------------------
  4477.   # ● 影グラフィックの更新
  4478.   #--------------------------------------------------------------------------
  4479.   def update_shadow
  4480.     @shadow.visible = @battler.sv.shadow_visible
  4481.     @shadow.opacity = @battler.sv.opacity if @battler.sv.opacity_data[3]
  4482.     @shadow.opacity = self.opacity if [email protected]_data[3]
  4483.     @shadow.x = @real_x - $sv_camera.x
  4484.     @shadow.y = (@battler.sv.y - @battler.sv.c)/ 100 - $sv_camera.y
  4485.     @shadow.z = @battler.sv.z - 10
  4486.     @shadow.zoom_x = $sv_camera.zoom
  4487.     @shadow.zoom_y = $sv_camera.zoom
  4488.     @shadow.x += $sv_camera.sx / 100
  4489.     @shadow.y += $sv_camera.sy / 100
  4490.     @shadow.x *= $sv_camera.zoom
  4491.     @shadow.y *= $sv_camera.zoom
  4492.     @shadow.color.set(@color_data[0], @color_data[1], @color_data[2], @color_data[3]) if @color_data != nil
  4493.   end
  4494.   #--------------------------------------------------------------------------
  4495.   # ● ふきだしの更新
  4496.   #--------------------------------------------------------------------------
  4497.   def update_balloon
  4498.     if @battler.sv.balloon_data == [] && @balloon
  4499.       @balloon_data = []
  4500.       @balloon.dispose
  4501.       return @balloon = nil
  4502.     elsif @battler.sv.balloon_data != [] && @battler.sv.balloon_data != @balloon_data
  4503.       @balloon_data = @battler.sv.balloon_data
  4504.       @balloon = Sprite.new(self.viewport)
  4505.       @balloon.bitmap = Cache.system("Balloon")
  4506.       @balloon.zoom_x = @balloon_data[3]
  4507.       @balloon.zoom_y = @balloon_data[3]
  4508.       @balloon.ox = 32 if @battler.sv.mirror
  4509.       @balloon.oy = 16
  4510.       @balloon_count = 0
  4511.     end
  4512.     return if !@balloon
  4513.     @balloon.opacity = self.opacity
  4514.     @balloon.x = self.x
  4515.     @balloon.y = self.y - @battler.sv.ch * $sv_camera.zoom
  4516.     @balloon.z = self.z + 20
  4517.     @balloon.src_rect.set(32 + @balloon_count / @balloon_data[2] * 32, @balloon_data[1] * 32, 32, 32) if @balloon_count % @balloon_data[2] == 0
  4518.     @balloon.color.set(@color_data[0], @color_data[1], @color_data[2], @color_data[3]) if @color_data != nil
  4519.     @balloon_count += 1
  4520.     @balloon_count = 0 if @balloon_count == @balloon_data[2] * 7
  4521.   end
  4522.   #--------------------------------------------------------------------------
  4523.   # ● 色調変更の更新
  4524.   #--------------------------------------------------------------------------
  4525.   def update_color
  4526.     color_set if @battler.sv.color_set != []
  4527.     return if @color_data == nil
  4528.     @color_data[4] -= 1
  4529.     if @color_data[4] == 0 && @color_data[5] != 0
  4530.       @color_data[4] = @color_data[5]
  4531.       @color_data[5] = 0
  4532.       @color_data[6] = [0,0,0,0]
  4533.     elsif @color_data[4] == 0
  4534.       @remain_color_data = @color_data
  4535.       @battler.sv.color = @color_data.dup
  4536.       return @color_data = nil
  4537.     end  
  4538.     for i in 0..3
  4539.       @color_data[i] = (@color_data[i] * (@color_data[4] - 1) + @color_data[6][i]) / @color_data[4]
  4540.     end  
  4541.     @battler.sv.color = @color_data.dup
  4542.     self.color.set(@color_data[0], @color_data[1], @color_data[2], @color_data[3])
  4543.   end
  4544.   #--------------------------------------------------------------------------
  4545.   # ● 残像の更新
  4546.   #--------------------------------------------------------------------------
  4547.   def update_mirage
  4548.     if @battler.sv.mirage == [] && @mirages
  4549.       @mirage_data = []
  4550.       for mirage in @mirages do mirage.dispose end
  4551.       return @mirages = nil
  4552.     elsif @battler.sv.mirage != [] && @battler.sv.mirage != @mirage_data
  4553.       @mirage_data = @battler.sv.mirage
  4554.       @mirages = []
  4555.       for i in 0...@mirage_data[1] do @mirages[i] = Sprite.new(self.viewport) end
  4556.       @mirage_count = 0
  4557.     end
  4558.     return if !@mirages
  4559.     @mirage_count += 1
  4560.     @mirage_count = 0 if @mirage_count == @mirage_data[2] * @mirages.size
  4561.     for i in [email protected]
  4562.       mirage_body(@mirages[i], @mirage_data[4]) if @mirage_count == 1 + i * @mirage_data[2]
  4563.     end
  4564.   end
  4565.   #--------------------------------------------------------------------------
  4566.   # ● 残像本体
  4567.   #--------------------------------------------------------------------------
  4568.   def mirage_body(body, opacity)
  4569.     body.bitmap = self.bitmap.dup
  4570.     body.x = self.x
  4571.     body.y = self.y
  4572.     body.ox = self.ox
  4573.     body.oy = self.oy
  4574.     body.z = self.z - 20
  4575.     body.mirror = self.mirror
  4576.     body.angle = self.angle
  4577.     body.opacity = opacity * self.opacity / 255
  4578.     body.zoom_x = self.zoom_x
  4579.     body.zoom_y = self.zoom_y   
  4580.     body.src_rect.set(@battler.sv.sx, @battler.sv.sy, @battler.sv.cw, @battler.sv.ch)
  4581.     body.color.set(@color_data[0], @color_data[1], @color_data[2], @color_data[3]) if @color_data != nil
  4582.   end   
  4583.   #--------------------------------------------------------------------------
  4584.   # ● 次のアニメを更新
  4585.   #--------------------------------------------------------------------------
  4586.   def update_next_anime
  4587.     return if !@next_anime
  4588.     for anime in @next_anime
  4589.       anime.update
  4590.       anime.set_position(self.z, self.zoom_x, self.zoom_y, @real_x, @real_y) if @horming
  4591.       anime.dispose if !anime.animation?
  4592.       @next_anime.delete(anime) if !anime.animation?
  4593.     end  
  4594.   end
  4595.   #--------------------------------------------------------------------------
  4596.   # ● フレーム更新
  4597.   #--------------------------------------------------------------------------
  4598.   alias update_sprite_battler_n03 update
  4599.   def update
  4600.     @battler.sv.update if @battler
  4601.     update_sprite_battler_n03
  4602.     update_next_anime
  4603.     update_shadow  if @battler && @shadow
  4604.     update_mirage  if @battler
  4605.     update_balloon if @battler
  4606.     update_remove if @battler && @removing && @battler.sv.change_up
  4607.   end
  4608.   #--------------------------------------------------------------------------
  4609.   # ● 戦闘アニメ消去
  4610.   #--------------------------------------------------------------------------
  4611.   def anime_off
  4612.     @battler.sv.anime_off = false
  4613.     dispose_animation
  4614.     for anime in @next_anime do anime.dispose_animation end if @next_anime
  4615.   end
  4616.   #--------------------------------------------------------------------------
  4617.   # ● バトラー入れ替え
  4618.   #--------------------------------------------------------------------------
  4619.   def remove
  4620.     @battler.sv.start_action(@battler.sv.remove_action)
  4621.     $sv_camera.wait = 40
  4622.     @battler.sv.add_action("eval('set_change')")
  4623.     @removing = true
  4624.   end
  4625.   #--------------------------------------------------------------------------
  4626.   # ● バトラー入れ替えの更新
  4627.   #--------------------------------------------------------------------------
  4628.   def update_remove
  4629.     @battler.sv.change_up = false
  4630.     @removing = false
  4631.     @battler = nil
  4632.   end  
  4633.   #--------------------------------------------------------------------------
  4634.   # ● バトラー加入
  4635.   #--------------------------------------------------------------------------
  4636.   def join(join_battler)
  4637.     $sv_camera.wait = 30
  4638.     @battler = join_battler
  4639.     @battler_name = @battler.character_name
  4640.     @battler_index = @battler.character_index
  4641.     @battler_graphic_file_index = @battler.sv.graphic_file_index
  4642.     self.bitmap = Cache.character(@battler_name)
  4643.     @battler.sv.setup(self.bitmap.width, self.bitmap.height, true)
  4644.     create_shadow
  4645.     init_visibility
  4646.   end
  4647.   #--------------------------------------------------------------------------
  4648.   # ● 通常の設定に戻す ★再定義
  4649.   #--------------------------------------------------------------------------
  4650.   def revert_to_normal
  4651.     self.blend_type = 0
  4652.     self.opacity = 255
  4653.   end
  4654.   #--------------------------------------------------------------------------
  4655.   # ● 崩壊エフェクトの更新
  4656.   #--------------------------------------------------------------------------
  4657.   alias update_collapse_sprite_battler_n03 update_collapse
  4658.   def update_collapse
  4659.     return if @battler.sv.state(1) != "敵コラプス"
  4660.     update_collapse_sprite_battler_n03
  4661.     @battler.sv.weapon_visible = false
  4662.   end
  4663.   #--------------------------------------------------------------------------
  4664.   # ● ボス崩壊エフェクトの更新 ★再定義
  4665.   #--------------------------------------------------------------------------
  4666.   def update_boss_collapse
  4667.     @effect_duration = @battler.sv.ch if @effect_duration >= @battler.sv.ch
  4668.     alpha = @effect_duration * 120 / @battler.sv.ch
  4669.     self.ox = @battler.sv.cw / 2 + @effect_duration % 2 * 4 - 2
  4670.     self.blend_type = 1
  4671.     self.color.set(255, 255, 255, 255 - alpha)
  4672.     self.opacity = alpha
  4673.     self.src_rect.y -= 1
  4674.     Sound.play_boss_collapse2 if @effect_duration % 20 == 19
  4675.   end
  4676.   #--------------------------------------------------------------------------
  4677.   # ● 別スプライトからのタイミング処理
  4678.   #--------------------------------------------------------------------------
  4679.   def set_process_timing(timing_data)
  4680.     for data in timing_data
  4681.       set_timing(data[0],data[1])
  4682.     end
  4683.     @battler.sv.timing = []
  4684.   end
  4685.   #--------------------------------------------------------------------------
  4686.   # ● タイミング処理
  4687.   #--------------------------------------------------------------------------
  4688.   def set_timing(se_flag, data)
  4689.     @ani_rate = 4
  4690.     data.se.play if se_flag
  4691.     case data.flash_scope
  4692.     when 1 ;self.flash(data.flash_color, data.flash_duration * @ani_rate)
  4693.     when 2 ;viewport.flash(data.flash_color, data.flash_duration * @ani_rate) if viewport
  4694.     when 3 ;self.flash(nil, data.flash_duration * @ani_rate)
  4695.     end
  4696.   end
  4697.   #--------------------------------------------------------------------------
  4698.   # ● 色調変更
  4699.   #--------------------------------------------------------------------------
  4700.   def color_set
  4701.     set = @battler.sv.color_set
  4702.     @battler.sv.color_set= []
  4703.     set[4] = 1 if set[4] == 0
  4704.     @remain_color_data = [0,0,0,0] if @remain_color_data == nil
  4705.     @color_data = @remain_color_data
  4706.     @color_data[4] = set[4]
  4707.     @color_data[5] = set[5]
  4708.     @color_data[6] = set
  4709.   end
  4710.   #--------------------------------------------------------------------------
  4711.   # ● 解放
  4712.   #--------------------------------------------------------------------------
  4713.   alias dispose_sprite_battler_n03 dispose
  4714.   def dispose
  4715.     dispose_sprite_battler_n03
  4716.     @shadow.dispose if @shadow != nil
  4717.     @balloon.dispose if @balloon != nil
  4718.     for mirage in @mirages do mirage.dispose end if @mirages != nil
  4719.     for anime in @next_anime do anime.dispose end if @next_anime
  4720.   end
  4721. end


  4722. #==============================================================================
  4723. # ■ Spriteset_Battle
  4724. #------------------------------------------------------------------------------
  4725. #  バトル画面のスプライトをまとめたクラスです。
  4726. #==============================================================================
  4727. class Spriteset_Battle
  4728.   #--------------------------------------------------------------------------
  4729.   # ● 戦闘背景(床)スプライトの作成 ★再定義
  4730.   #--------------------------------------------------------------------------
  4731.   def create_battleback1
  4732.     @back1_sprite = Sprite_Battle_Back.new(@viewport1, 1, battleback1_name)
  4733.     @back1_sprite.set_graphics(battleback1_bitmap) if battleback1_name != nil
  4734.     @back1_sprite.z = 0
  4735.   end
  4736.   #--------------------------------------------------------------------------
  4737.   # ● 戦闘背景(壁)スプライトの作成 ★再定義
  4738.   #--------------------------------------------------------------------------
  4739.   def create_battleback2
  4740.     @back2_sprite = Sprite_Battle_Back.new(@viewport1, 2, battleback2_name)
  4741.     @back2_sprite.set_graphics(battleback2_bitmap) if battleback2_name != nil
  4742.     @back2_sprite.z = 1
  4743.   end
  4744.   #--------------------------------------------------------------------------
  4745.   # ● アクタースプライトの作成 ★再定義
  4746.   #--------------------------------------------------------------------------
  4747.   def create_actors
  4748.     @actor_sprites = []
  4749.     for i in 0...$game_party.max_battle_members
  4750.       @actor_sprites[i] = Sprite_Battler.new(@viewport1, $game_party.members[i])
  4751.     end
  4752.     @effect_sprites = Spriteset_Sideview.new(@viewport1)
  4753.   end
  4754.   #--------------------------------------------------------------------------
  4755.   # ● アクタースプライトの更新 ★再定義
  4756.   #--------------------------------------------------------------------------
  4757.   def update_actors
  4758.     @actor_sprites.each_with_index do |sprite, i|
  4759.       sprite_join($game_party.members[i], sprite) if sprite.battler == nil && sprite.battler != $game_party.members[i]
  4760.       sprite.remove if sprite.battler != nil && !sprite.removing && sprite.battler != $game_party.members[i]
  4761.       sprite.update
  4762.     end
  4763.     @effect_sprites.update
  4764.     update_program
  4765.   end
  4766.   #--------------------------------------------------------------------------
  4767.   # ● メンバーを加える
  4768.   #--------------------------------------------------------------------------
  4769.   def sprite_join(member, sprite)
  4770.     for sp in @actor_sprites
  4771.       sp.update_remove if member == sp.battler && !sp.battler.sv.change_up
  4772.     end
  4773.     sprite.join(member)
  4774.   end
  4775.   #--------------------------------------------------------------------------
  4776.   # ● バトルプログラムの更新
  4777.   #--------------------------------------------------------------------------
  4778.   def update_program
  4779.     return if $sv_camera.program_scroll == []
  4780.     for data in  $sv_camera.program_scroll
  4781.       @back1_sprite.start_back_data(data) if data[2] == 1
  4782.       @back2_sprite.start_back_data(data) if data[2] == 2
  4783.     end
  4784.     $sv_camera.program_scroll = []
  4785.   end
  4786.   #--------------------------------------------------------------------------
  4787.   # ● ヒット時の戦闘アニメ実行
  4788.   #--------------------------------------------------------------------------
  4789.   def set_hit_animation(battler, weapon_index, hit_targets, miss)
  4790.     @effect_sprites.set_hit_animation(battler, weapon_index, hit_targets, miss)
  4791.   end
  4792.   #--------------------------------------------------------------------------
  4793.   # ● ダメージPOP
  4794.   #--------------------------------------------------------------------------
  4795.   def set_damage_pop(target)
  4796.     @effect_sprites.set_damage_pop(target)
  4797.   end
  4798.   #--------------------------------------------------------------------------
  4799.   # ● 解放
  4800.   #--------------------------------------------------------------------------
  4801.   alias dispose_spriteset_battle_n03 dispose
  4802.   def dispose
  4803.     dispose_spriteset_battle_n03
  4804.     @effect_sprites.dispose
  4805.   end
  4806.   
  4807.   
  4808.   
  4809. end


  4810. #==============================================================================
  4811. # ■ Window_BattleLog
  4812. #------------------------------------------------------------------------------
  4813. #  戦闘の進行を実況表示するウィンドウです。
  4814. #==============================================================================
  4815. class Window_BattleLog < Window_Selectable
  4816.   #--------------------------------------------------------------------------
  4817.   # ● ウェイト ★再定義
  4818.   #--------------------------------------------------------------------------
  4819.   def wait
  4820.   end
  4821.   #--------------------------------------------------------------------------
  4822.   # ● ウェイトとクリア ★再定義
  4823.   #--------------------------------------------------------------------------
  4824.   def wait_and_clear
  4825.     $sv_camera.wait = 10
  4826.   end
  4827.   #--------------------------------------------------------------------------
  4828.   # ● 行動結果の表示 ★再定義
  4829.   #--------------------------------------------------------------------------
  4830.   def display_action_results(target, item)
  4831.     if target.result.used
  4832.       last_line_number = line_number
  4833.       display_critical(target, item)
  4834.       display_damage(target, item)
  4835.       display_affected_status(target, item)
  4836.       display_failure(target, item)
  4837.     end
  4838.     off if !N03::BATTLE_LOG
  4839.   end
  4840.   #--------------------------------------------------------------------------
  4841.   # ● ウインドウ非表示
  4842.   #--------------------------------------------------------------------------
  4843.   def off
  4844.     @back_sprite.visible = self.visible = false
  4845.   end
  4846. end
  4847. #==============================================================================
  4848. # ■ Game_Interpreter
  4849. #------------------------------------------------------------------------------
  4850. #  イベントコマンドを実行するインタプリタです。
  4851. #==============================================================================
  4852. class Game_Interpreter
  4853.   #--------------------------------------------------------------------------
  4854.   # ● スイッチの操作
  4855.   #--------------------------------------------------------------------------
  4856.   alias command_121_game_interpreter_n03 command_121
  4857.   def command_121
  4858.     command_121_game_interpreter_n03
  4859.     $sv_camera.program_check
  4860.   end
  4861. end
复制代码

该代码3452行错误
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2547
在线时间
210 小时
注册时间
2018-8-8
帖子
105
7
 楼主| 发表于 2018-9-28 16:30:15 | 只看该作者
抱歉,代码发错了
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2547
在线时间
210 小时
注册时间
2018-8-8
帖子
105
8
 楼主| 发表于 2018-9-28 16:31:18 | 只看该作者
应该是重发代码的第3454行 def move(target_x, target_y, zoom, time, screen = true)错误
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-26 19:07

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表