| 
 
| 赞 | 0 |  
| VIP | 0 |  
| 好人卡 | 0 |  
| 积分 | 1 |  
| 经验 | 835 |  
| 最后登录 | 2017-8-23 |  
| 在线时间 | 4 小时 |  
 Lv1.梦旅人 
	梦石0 星屑50 在线时间4 小时注册时间2008-8-24帖子49 | 
| 本帖最后由 sadsqw1 于 2009-8-9 11:57 编辑 
 第一部分第2部分
 复制代码#==============================================================================
#RTAB观光游第六站,连击效果+连击数显示 (计算部分) 
#==============================================================================
# 連撃 Ver 1.03
# 配布元・サポートURL
# http://members.jcom.home.ne.jp/cogwheel/
#==============================================================================
# ■ Scene_Battle (分割定義 4)
#------------------------------------------------------------------------------
#  バトル画面の処理を行うクラスです。
#==============================================================================
# アニメに強さ0のフラッシュが存在した場合、
# 赤:倍率 緑:+スキル・アイテムID でダメージ計算を行う。
#
# 连击数,每次伤害比率如何设置,参考动画“千裂斩”
class Scene_Battle
attr_reader :skill#到此一游
#--------------------------------------------------------------------------
# ● ATB基礎セットアップ
#--------------------------------------------------------------------------
  alias :atb_setup_straight :atb_setup
  def atb_setup
    atb_setup_straight
    for battler in $game_party.actors + $game_troop.enemies
      battler.total_damage = {}
    end
  end
#--------------------------------------------------------------------------
# ● アクション更新 (メインフェーズ)
#--------------------------------------------------------------------------
  def action_phase(battler)
    while true
      # action が 1 の場合、バトラーが行動中かどうか確認
      if @action == 1 and battler.phase < 3
        for target in battler.target
          speller = synthe?(target)
          if speller == nil
            # ターゲットが通常行動中の場合
            if @action_battlers.include?(target)
              if target.phase > 2
                return
              end
            end
          else
            # ターゲットが連携スキル発動中の場合
            for spell in speller
              if @action_battlers.include?(spell)
                if spell.phase > 2
                  return
                end
              end
            end
          end
        end
      end
      case battler.phase
      when 1
        update_phase4_step1(battler)
      when 2
        update_phase4_step2(battler)
      when 3
        update_phase4_step3(battler)
      when 4
        update_phase4_step4(battler)
      when 5
        update_phase4_step5(battler)
      when 6
        update_phase4_step6(battler)
      end
      # ウェイトが入った場合
      if battler.wait > 0
        # ウェイトカウントを減らして終了
        battler.wait -= 1
        break
      end
      # 行動終了した場合ループを抜ける
      unless @action_battlers.include?(battler)
        break
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 1 : アクション準備)
  #--------------------------------------------------------------------------
  def update_phase4_step1(battler)
    # すでに戦闘から外されている場合
    if battler.index == nil
      @action_battlers.delete(battler)
      anime_wait_return
      battler.wait = 1
      return
    end
    speller = synthe?(battler)
    if speller == nil
      # ダメージ食らい中の場合
      unless battler.damage.empty? or @action > 2
        battler.wait = 1
        return
      end
      # 行動可能かどうか判定
      unless battler.movable?
        battler.phase = 6
        return
      end
    else
      # ダメージ食らい中の場合
      for spell in speller
        unless spell.damage.empty? or @action > 2
          battler.wait = 1
          return
        end
        # 行動可能かどうか判定
        unless spell.movable?
          battler.phase = 6
          return
        end
      end
    end
    # スキル使用時、詠唱時間設定
    # 強制アクションかつ @force が 2 の時はスキルを即時発動
    if battler.current_action.kind == 1 and
      (not battler.current_action.forcing or @force != 2)
      if battler.rtp == 0
        # スキル詠唱中ならば、解除
        skill_reset(battler)
        # スキル詠唱時間設定
        recite_time(battler)
        # 連携技設定
        synthe_spell(battler)
        # スキルを詠唱する場合
        if battler.rtp > 0
          # 強制アクションかつ @force が 1 の時は連携スキルのみ即時発動
          speller = synthe?(battler)
          if battler.current_action.forcing and @force > 0 and speller != nil
            for spell in speller
              spell.rt = spell.rtp
            end
          else
            battler.blink = true
            if battler.current_action.forcing
              $game_temp.forcing_battler = nil
              battler.current_action.forcing = false
            end
            @action_battlers.delete(battler)
            return
          end
        end
      end
    end
    # アクターの明滅エフェクト OFF
    if battler != nil
      battler.blink = false
    end
    speller = synthe?(battler)
    if speller == nil
      @spell_p.delete(battler)
      @spell_e.delete(battler)
    else
      for spell in speller
        spell.blink = false
        @spell_p.delete(spell)
        @spell_e.delete(spell)
      end
    end
    # ステップ 2 に移行
    battler.phase = 2
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
  #--------------------------------------------------------------------------
  def update_phase4_step2(battler)
    # 強制アクションでなければ
    unless battler.current_action.forcing
      # 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合
      if battler.restriction == 2 or battler.restriction == 3
        # アクションに攻撃を設定
        battler.current_action.kind = 0
        battler.current_action.basic = 0
      end
    end
    # アクションの種別より攻撃アニメーションを取得する
    case battler.current_action.kind
    when 0 # 基本
      if battler.is_a?(Game_Actor)
        base_id = battler.weapon_id
      end
      anime_id = battler.animation2_id
      # 防御など特殊行動の場合は次のステップへ
      unless make_basic_action_preparation(battler)
        return
      end
      # 戦闘が終了した場合は行動をキャンセル
      if fin?
        battler.phase = 6
        return
      end
    when 1 # スキル
      base_id = battler.current_action.skill_id
      anime_id = $data_skills[battler.current_action.skill_id].animation2_id
      # スキルが使用できない場合は行動をキャンセル
      unless make_skill_action_preparation(battler)
        return
      end
      # 戦闘が終了した場合は行動をキャンセル
      if fin? and $data_skills[anime_id].scope == 1..2
        battler.phase = 6
        return
      end
    when 2 # アイテム
      base_id = battler.current_action.item_id
      anime_id = $data_items[battler.current_action.item_id].animation2_id
      # アイテムが使用できない場合は行動をキャンセル
      unless make_item_action_preparation(battler)
        return
      end
      # 戦闘が終了した場合は行動をキャンセル
      if fin? and $data_items[anime_id].scope == 1..2
        battler.phase = 6
        return
      end
    end
    # アニメーションを検索し、連撃性を変数serialに代入する
    serial = []
    frame = 0
    if $data_animations[anime_id] != nil
      for animation in $data_animations[anime_id].timings
        color = animation.flash_color
        # アニメーション・フラッシュの強さが0の場合
        if color.alpha == 0
          serial.push([color.red.to_i, color.green, animation.frame - frame])
          frame = animation.frame
        end
      end
      # 連撃性がない場合単発攻撃
      if serial.empty?
        serial = [[20, 100, $data_animations[anime_id].frame_max - 5]]
      end
    else
      # アニメーションが存在しない場合
      serial = [[20, 100, 0]]
    end
    # ハッシュ total_damage の作成
    total_damage = {}
    for target in battler.target
      total_damage[target] = []
    end
    # 連撃回数分ダメージ計算を行う
    for attack in serial
      # アクションの種別で分岐
      case battler.current_action.kind
      when 0  # 基本
        if battler.is_a?(Game_Actor)
          # バトラーがアクターの場合、攻撃時に武器を変更する
          battler.change_weapon(base_id + attack[1] - 100)
        end
        make_basic_action_result(battler)
      when 1  # スキル
        # 連携スキルのことを考え、スキルIDの変更は内部処理で行う
        make_skill_action_result(battler, attack[1] - 100)
      when 2  # アイテム
        # アイテムIDを設定分変化させる
        battler.current_action.item_id = base_id + attack[1] - 100
        make_item_action_result(battler)
      end
      # total_damage へダメージを代入
      for target in battler.target
        # ダメージがある場合、ダメージをX/20倍する。
        if target.damage[battler].is_a?(Numeric)
          damage = target.damage[battler] * attack[0] / 20
        else
          damage = target.damage[battler]
        end
        # 回復HP量がある場合、回復HP量をX/20倍する。
        if target.recover_hp[battler].is_a?(Numeric)
          recover_hp = target.recover_hp[battler] * attack[0] / 20
        end
        # 回復SP量がある場合、回復SP量をX/20倍する。
        if target.recover_sp[battler].is_a?(Numeric)
          recover_sp = target.recover_sp[battler] * attack[0] / 20
        end
        critical = target.critical[battler]
        # total_damage = [ダメージ, クリティカルフラグ, 回復HP量, 回復SP量,
        #                 ステート変化, ステート回復, 待ちフレーム時間]
        total_damage[target].push([damage, critical, recover_hp, recover_sp,
          target.state_p[battler], target.state_m[battler], attack[2]])
      end
    end
    # トータルダメージを、バトラーのインスタンスに代入
    for target in battler.target
      target.total_damage[battler] = total_damage[target]
    end
    # 武器・スキル・アイテムIDを通常に戻す
    case battler.current_action.kind
    when 0  # 基本
      if battler.is_a?(Game_Actor)
        battler.change_weapon(base_id)
      end
    when 1  # スキル
      battler.current_action.skill_id = base_id
    when 2  # アイテム
      battler.current_action.item_id = base_id
    end
    if battler.phase == 2
      # ステップ 3 に移行
      battler.phase = 3
    end
  end
  #--------------------------------------------------------------------------
  # ● 基本アクション 準備
  #--------------------------------------------------------------------------
  def make_basic_action_preparation(battler)
    # 攻撃の場合
    if battler.current_action.basic == 0
      # アニメーション ID を設定
      battler.anime1 = battler.animation1_id
      battler.anime2 = battler.animation2_id
      # 行動側バトラーがエネミーの場合
      if battler.is_a?(Game_Enemy)
        if battler.restriction == 3
          target = $game_troop.random_target_enemy
        elsif battler.restriction == 2
          target = $game_party.random_target_actor
        else
          index = battler.current_action.target_index
          target = $game_party.smooth_target_actor(index)
        end
      end
      # 行動側バトラーがアクターの場合
      if battler.is_a?(Game_Actor)
        if battler.restriction == 3
          target = $game_party.random_target_actor
        elsif battler.restriction == 2
          target = $game_troop.random_target_enemy
        else
          index = battler.current_action.target_index
          target = $game_troop.smooth_target_enemy(index)
        end
      end
      # 対象側バトラーの配列を設定
      battler.target = [target]
      return true
    end
    # 防御の場合
    if battler.current_action.basic == 1
      # ステップ 3 に移行
      battler.phase = 3
      return false
    end
#===============0.15b(RTAB官方更新)===========================================    
    # 逃げるの場合
    if battler.is_a?(Game_Enemy) and battler.current_action.basic == 2
      # ステップ 3 に移行
      battler.phase = 3
      return false
    end
#=============================================================================
    # 何もしないの場合
    if battler.current_action.basic == 3
      # ステップ 6 に移行
      battler.phase = 6
      return false
    end
  end
  #--------------------------------------------------------------------------
  # ● スキルアクション 準備
  #--------------------------------------------------------------------------
  def make_skill_action_preparation(battler)
    # スキルを取得
    @skill = $data_skills[battler.current_action.skill_id]
    # 連携スキルであるかどうか確認
    speller = synthe?(battler)
    # 強制アクションでなければ
    unless battler.current_action.forcing
      # SP 切れなどで使用できなくなった場合
      if speller == nil
        unless battler.skill_can_use?(@skill.id)
          # ステップ 6 に移行
          battler.phase = 6
         return false
        end
      end
    end
    # SP 消費
    temp = false
    if speller != nil
      for spell in speller
        if spell.current_action.spell_id == 0
          spell.sp -= @skill.sp_cost
        else
          spell.sp -= $data_skills[spell.current_action.spell_id].sp_cost
        end
        # ステータスウィンドウをリフレッシュ
        status_refresh(spell)
      end
    else
      battler.sp -= @skill.sp_cost
      # ステータスウィンドウをリフレッシュ
      status_refresh(battler)
    end
    # アニメーション ID を設定
    battler.anime1 = @skill.animation1_id
    battler.anime2 = @skill.animation2_id
    # コモンイベント ID を設定
    battler.event = @skill.common_event_id
    # 対象側バトラーを設定
    set_target_battlers(@skill.scope, battler)
    return true
  end
  #--------------------------------------------------------------------------
  # ● アイテムアクション 準備
  #--------------------------------------------------------------------------
  def make_item_action_preparation(battler)
    # アイテムを取得
    @item = $data_items[battler.current_action.item_id]
    # アイテム切れなどで使用できなくなった場合
    unless $game_party.item_can_use?(@item.id)
      # ステップ 6 に移行
      battler.phase = 6
      return false
    end
    # 消耗品の場合
    if @item.consumable
      # 使用したアイテムを 1 減らす
      $game_party.lose_item(@item.id, 1)
    end
    # アニメーション ID を設定
    battler.anime1 = @item.animation1_id
    battler.anime2 = @item.animation2_id
    # コモンイベント ID を設定
    battler.event = @item.common_event_id
    # 対象を決定
    index = battler.current_action.target_index
    target = $game_party.smooth_target_actor(index)
    # 対象側バトラーを設定
    set_target_battlers(@item.scope, battler)
    return true
  end
  #--------------------------------------------------------------------------
  # ● 基本アクション 結果作成
  #--------------------------------------------------------------------------
  def make_basic_action_result(battler)
    # 通常攻撃の効果を適用
    for target in battler.target
      target.attack_effect(battler)
    end
  end
  #--------------------------------------------------------------------------
  # ● スキルアクション 結果作成
  #--------------------------------------------------------------------------
  def make_skill_action_result(battler, plus_id)
    # スキルを取得
    @skill = $data_skills[battler.current_action.skill_id + plus_id]
    # 連携スキルであるかどうか確認
    speller = synthe?(battler)
    # スキルの効果を適用
    for target in battler.target
      if speller != nil
        damage = 0
        effective = false
        state_p = []
        state_m = []
        d_result = false
        for spell in speller
          if spell.current_action.spell_id != 0
            @skill = $data_skills[spell.current_action.spell_id + plus_id]
          end
          effective |= target.skill_effect(spell, @skill)
          if target.damage[spell].class != String
            d_result = true
            damage += target.damage[spell]
          elsif effective
            effect = target.damage[spell]
          end
          state_p += target.state_p[spell]
          state_m += target.state_m[spell]
          target.damage.delete(spell)
          target.state_p.delete(spell)
          target.state_m.delete(spell)
        end
        if d_result
          target.damage[battler] = damage
        elsif effective
          target.damage[battler] = effect
        end
        target.state_p[battler] = state_p
        target.state_m[battler] = state_m
      else
        target.skill_effect(battler, @skill)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● アイテムアクション 結果作成
  #--------------------------------------------------------------------------
  def make_item_action_result(battler)
    # アイテムを取得
    @item = $data_items[battler.current_action.item_id]
    # アイテムの効果を適用
    for target in battler.target
      target.item_effect(@item, battler)
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 4 : 対象側アニメーション)
  #--------------------------------------------------------------------------
  def update_phase4_step4(battler)
    # カメラ設定
    if battler.target[0].is_a?(Game_Enemy) and battler.anime1 != 0
      camera_set(battler)
    end
    # 対象側アニメーション
    for target in battler.target
      target.animation.push([battler.anime2,
                                          (target.damage[battler] != "Miss")])
      unless battler.anime2 == 0
        battler.wait = 2 * target.total_damage[battler][0][6] - 1 +
          Graphics.frame_count % 2
      end
    end
    # ステップ 5 に移行
    battler.phase = 5
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  #--------------------------------------------------------------------------
  def update_phase4_step5(battler)
    next_step = true
    # ダメージ表示
    for target in battler.target
      # total_damage より全ダメージを算出
      total_damage = target.total_damage[battler].shift
      target.damage[battler] = total_damage[0]
      target.critical[battler] = total_damage[1]
      target.recover_hp[battler] = total_damage[2]
      target.recover_sp[battler] = total_damage[3]
      target.state_p[battler] = total_damage[4]
      target.state_m[battler] = total_damage[5]
      # ダメージ表示フラグをON
      target.damage_pop[battler] = true
      # 恭喜你发现了连击计算的关键一行!
      target.combohit_count if target.damage[battler].to_i > 0 and target.damage[battler] != "Miss"
      # 実際にダメージを与える
#      target.damage_effect(battler, battler.current_action.kind)
      target.damage_effect(battler, battler.current_action.kind,skill)#到此一游
      # 余計なハッシュを削除
      target.recover_hp.delete(battler)
      target.recover_sp.delete(battler)
      target.state_p.delete(battler)
      target.state_m.delete(battler)
      # ダメージを全て与えきった場合
      if target.total_damage[battler].empty?
        # ターゲットへの全ダメージを削除
        target.total_damage.delete(battler)
        # 指定時間ウェイトする
        battler.wait = @damage_wait
      else
        # 指定時間ウェイトする
        next_step = false
        battler.wait = 2 * target.total_damage[battler][0][6]
      end
      # ステータスウィンドウをリフレッシュ
      status_refresh(target)
    end
    if next_step
      # ステップ 6 に移行
      battler.phase = 6
    end
  end
  
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ)
  #--------------------------------------------------------------------------
  def update_phase4_step6(battler)
    # カメラを戻す
    if battler.target[0].is_a?(Game_Enemy) and @camera == battler
      @spriteset.screen_target(0, 0, 1)
    end
    # スキルラーニング
    if battler.target[0].is_a?(Game_Actor) and battler.current_action.kind == 1
      for target in battler.target        
        if target.is_a?(Game_Actor)#(0.16)
        skill_learning(target, target.class_id,
                        battler.current_action.skill_id)
        end #(0.16)               
      end
    end
    # アクション強制対象のバトラーをクリア
    if battler.current_action.forcing == true and
        battler.current_action.force_kind == 0 and
        battler.current_action.force_basic == 0 and
        battler.current_action.force_skill_id == 0
      $game_temp.forcing_battler = nil
      battler.current_action.forcing = false
    end
    refresh_phase(battler)
    speller = synthe?(battler)
    if speller != nil
      for spell in speller
        if spell != battler
          refresh_phase(spell)
        end
      end
      synthe_delete(speller)
    end
    # コモンイベント ID が有効の場合
  #  if battler.event > 0
      # イベントをセットアップ
  #    common_event = $data_common_events[battler.event]
  #    $game_system.battle_interpreter.setup(common_event.list, 0)
  #  end
    act = 0
    for actor in $game_party.actors + $game_troop.enemies
      if actor.movable?
        act += 1
      end
    end
    if @turn_cnt >= act and act > 0
      @turn_cnt %= act
      $game_temp.battle_turn += 1
      # バトルイベントの全ページを検索
      for index in 0...$data_troops[@troop_id].pages.size
        # イベントページを取得
        page = $data_troops[@troop_id].pages[index]
        # このページのスパンが [ターン] の場合
        if page.span == 1
          # 実行済みフラグをクリア
          $game_temp.battle_event_flags[index] = false
        end
      end
    end
    battler.phase = 1
    @action_battlers.delete(battler)
  end
#//////////////////////////////////////////////////////////////////////////////
#连击数计算的基础部分Part1  by 桜雅 在土
#------------------------------------------------------------------------------
# ● メイン処理
#------------------------------------------------------------------------------
  alias xrxs_bp19_main main
  def main
    # コンボヒットウィンドウを作成
    @combohit_window = Window_ComboHit.new
    # 呼び戻す
    xrxs_bp19_main
    # ウィンドウを解放
    @combohit_window.dispose
    # コンボクリア
    $game_party.actors.each {|actor| actor.combohit_clear}
  end
#------------------------------------------------------------------------------
# ● フレーム更新
#------------------------------------------------------------------------------
  alias xrxs_bp19_update update
  def update
    # フレーム更新
    @combohit_window.update
    $game_party.actors.each {|actor| actor.combohit_update}
    $game_troop.enemies.each{|enemy| enemy.combohit_update}
    # 呼び戻す
    xrxs_bp19_update
  end
#------------------------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
#------------------------------------------------------------------------------
  alias xrxs_bp19_update_phase4_step5 update_phase4_step5
  def update_phase4_step5(battler)
    # 呼び戻す
    xrxs_bp19_update_phase4_step5(battler)
    # コンボ数の最も高いターゲットを探す
    max = 0
    hit_target = nil
    for target in battler.target
      if target.combohit > max
        max = target.combohit
        hit_target = target
      end
    end
    if max >= 2 and !hit_target.nil?
      @combohit_window.x = hit_target.is_a?(Game_Enemy) ? 512 : 512
      @combohit_window.refresh(max, hit_target.combohit_duration)
    end
  end  
end
#//////////////////////////////////////////////////////////////////////////////
#==============================================================================
# ■ Game_Battler (分割定義 1)
#------------------------------------------------------------------------------
#  バトラーを扱うクラスです。このクラスは Game_Actor クラスと Game_Enemy クラ
# スのスーパークラスとして使用されます。
#==============================================================================
class Game_Battler
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数追加
  #--------------------------------------------------------------------------
  attr_accessor :total_damage              # 総ダメージ
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias :initialize_straight :initialize
  def initialize
    initialize_straight
    @total_damage = {}
  end
  #--------------------------------------------------------------------------
  # ● 存在判定
  #--------------------------------------------------------------------------
  def exist?
    return (not @hidden and (@hp > 0 or @immortal or not @total_damage.empty?))
  end
  #--------------------------------------------------------------------------
  # ● 残HP予測
  #--------------------------------------------------------------------------
  def rest_hp
    # rest_hp に現HPを代入
    rest_hp = @hp
    # バトラーが受ける全ダメージをrest_hpに反映させる
    for total in @total_damage
      for pre_damage in total[1]
        if pre_damage[0].is_a?(Numeric)
          rest_hp -= pre_damage[0]
        end
        if pre_damage[2].is_a?(Numeric)
          rest_hp += pre_damage[2]
        end
      end
    end
    return rest_hp
  end
end
#//////////////////////////////////////////////////////////////////////////////
#连击数计算的基础部分Part2  by 桜雅 在土
#------------------------------------------------------------------------------
# ● 公開インスタンス変数
#------------------------------------------------------------------------------
  def combohit
    @combohit = 0 if @combohit.nil?
    return @combohit
  end
  def combohit_duration
    @combohit_duration = 0 if @combohit_duration.nil?
    return @combohit_duration
  end
#------------------------------------------------------------------------------
# ○ コンボヒットを更新
#------------------------------------------------------------------------------  
  def combohit_update
    # 例外補正
    @combohit_duration = 0 if @combohit_duration.nil?
    # カウント
    if @combohit_duration > 0
      @combohit_duration -= 1
      # のけぞり時間終了時、コンボ数をリセット
      @combohit = 0 if @combohit_duration == 0
    end
  end
#------------------------------------------------------------------------------
# ○ コンボヒットをカウント
#------------------------------------------------------------------------------ 
  def combohit_count
    # 例外補正
    @combohit = 0 if @combohit.nil?  
    # カウント
    @combohit += 1
    @combohit_duration = XRXS_BP19::COMBOHIT_DURATION
  end
#------------------------------------------------------------------------------
# ○ コンボヒットをクリア
#------------------------------------------------------------------------------  
  def combohit_clear
    @combohit = nil
    @combohit_duration = nil
  end
#//////////////////////////////////////////////////////////////////////////////
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors)
# の内部で使用され、Game_Party クラス ($game_party) からも参照されます。
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  def change_weapon(id)
    @weapon_id = id
  end
end
#==============================================================================
# ■ Sprite_Battler
#------------------------------------------------------------------------------
#  バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、
# スプライトの状態を自動的に変化させます。
#==============================================================================
class Sprite_Battler < RPG::Sprite
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    # バトラーが nil の場合
    if @battler == nil
      self.bitmap = nil
      loop_animation(nil)
      return
    end
    # ファイル名か色相が現在のものと異なる場合
    if @battler.battler_name != @battler_name or
       @battler.battler_hue != @battler_hue
      # ビットマップを取得、設定
      @battler_name = @battler.battler_name
      @battler_hue = @battler.battler_hue
      self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
      @width = bitmap.width
      @height = bitmap.height
      self.ox = @width / 2
      self.oy = @height
      if @battler.is_a?(Game_Enemy)
        @battler.height = @height
      end
      # 戦闘不能または隠れ状態なら不透明度を 0 にする
      if @battler.dead? or @battler.hidden
        self.opacity = 0
      end
    end
    # アニメーション ID が現在のものと異なる場合
    if @battler.state_animation_id != @state_animation_id
      @state_animation_id = @battler.state_animation_id
      loop_animation($data_animations[@state_animation_id])
    end
    # 表示されるべきアクターの場合
    if @battler.is_a?(Game_Actor) and @battler_visible
      # メインフェーズでないときは不透明度をやや下げる
      if $game_temp.battle_main_phase
        self.opacity += 3 if self.opacity < 255
      else
        self.opacity -= 3 if self.opacity > 207
      end
    end
    # 明滅
    if @battler.blink
      blink_on
    else
      blink_off
    end
    # 不可視の場合
    unless @battler_visible
      # 出現
      if not @battler.hidden and not @battler.dead? and
         (@battler.damage.size < 2 or @battler.damage_pop.size < 2)
        appear
        @battler_visible = true
      end
    end
    # ダメージ
    for battler in @battler.damage_pop
      if battler[0].class == Array
        if battler[0][1] >= 0
          $scene.skill_se
        else
          $scene.levelup_se
        end
        damage(@battler.damage[battler[0]], false, 2)
      else
        damage(@battler.damage[battler[0]], @battler.critical[battler[0]])
      end
      if @battler.damage_sp.include?(battler[0])
        damage(@battler.damage_sp[battler[0]],
                @battler.critical[battler[0]], 1)
        @battler.damage_sp.delete(battler[0])
      end
      @battler.damage_pop.delete(battler[0])
      @battler.damage.delete(battler[0])
      @battler.critical.delete(battler[0])
    end
    # 可視の場合
    if @battler_visible
      # 逃走
      if @battler.hidden
        $game_system.se_play($data_system.escape_se)
        escape
        @battler_visible = false
      end
      # 白フラッシュ
      if @battler.white_flash
        whiten
        @battler.white_flash = false
      end
      # アニメーション
      unless @battler.animation.empty?
        for animation in @battler.animation.reverse
          animation($data_animations[animation[0]], animation[1])
          @battler.animation.delete(animation)
        end
      end
      # コラプス
      if @battler.total_damage.empty? and @battler.dead?
        if $scene.dead_ok?(@battler)
          if @battler.is_a?(Game_Enemy)
            $game_system.se_play($data_system.enemy_collapse_se)
          else
            $game_system.se_play($data_system.actor_collapse_se)
          end
          collapse
          @battler_visible = false
        end
      end
    end
    # スプライトの座標を設定
    self.x = @battler.screen_x
    self.y = @battler.screen_y
    self.z = @battler.screen_z
    if @battler.is_a?(Game_Enemy)
      self.zoom_x = @battler.real_zoom * @battler.zoom
      self.zoom_y = @battler.real_zoom * @battler.zoom
    end
  end
end
 | 
 |