 #06/10/10
#==============================================================================
# ■ エネミー追加データ
#==============================================================================
module Enemy_Ex
  #--------------------------------------------------------------------------
  # Ex[エネミーID] = {1=>[盗むアイテム/盗むレア/変化アイテム]}
  # "i(ID)" ：アイテム  "w(ID)"　：武器　"a(ID)"　：防具　"g(金額)"　：お金　 ""　：無しの場合　
  #--------------------------------------------------------------------------
  Ex = []
  Ex[0] = {1=>["","",""]} # エネミーID未設定の場合
  
  Ex[1] = {1=>["","g1000","a1"]} # ゴースト
  Ex[2] = {1=>["i1","w1",""]} # バジリスク
  
  
end
#==============================================================================
# ■ 盗む/変化
#------------------------------------------------------------------------------
# スキルに追加　名前：ぬすむ、へんか　効果範囲：敵単体
#==============================================================================
class Game_Enemy < Game_Battler
  include Enemy_Ex
  attr_accessor :enemy_id                 # エネミーID
  attr_accessor :steal_item               # 盗めるアイテム
  attr_accessor :change_item              # アイテムに変化
  #--------------------------------------------------------------------------
  # ■ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias hidesp2_initialize initialize
  def initialize(troop_id, member_index)
    super()
    # 元の処理を呼び出し
    hidesp2_initialize(troop_id, member_index)
    
    @change_item = [false,nil,nil,nil,nil,false]
    # □[ぬすむ]アイテム
    @steal_item = [0]
    e = @enemy_id
    if Enemy_Ex::Ex[@enemy_id] == nil
      # Enemy_Ex未設定の場合
      e = 0
      @steal_item[5] = true
    end
    Enemy_Ex::Ex[e][1][0].scan(/([iwag])([0-9]+)/)
    @steal_item[1] = $1
    @steal_item[2] = $2.to_i
    Enemy_Ex::Ex[e][1][1].scan(/([iwag])([0-9]+)/)
    @steal_item[3] = $1
    @steal_item[4] = $2.to_i
    # □[へんか]アイテム
    Enemy_Ex::Ex[e][1][2].scan(/([iwag])([0-9]+)/)
    @change_item[1] = $1
    @change_item[2] = $2.to_i
    
    if @steal_item[1] == nil && @steal_item[3] == nil
      # [ぬすむ]アイテム未設定の場合
      @steal_item[5] = true
    end
  end
end

class Game_Battler
  #--------------------------------------------------------------------------
  # ■ スキルの効果適用
  #--------------------------------------------------------------------------
  alias hidesp2_skill_effect skill_effect
  def skill_effect(user, skill)
    # アクター専用
    if skill != nil && user.is_a?(Game_Actor) && self.is_a?(Game_Enemy)
      case skill.name
      #…………………………………………………………………………………………………
      # ■[ぬすむ]の場合
      #…………………………………………………………………………………………………
      when "ぬすむ"
        if self.is_a?(Game_Actor)
          self.damage = "Miss"
        else
          self.damage = "Steal!"
          self.steal_item[0] = true
        end
        return true
      #…………………………………………………………………………………………………
      # ■[へんか]の場合
      #…………………………………………………………………………………………………
      when "へんか"
        if self.is_a?(Game_Actor)
          self.damage = "Miss"
        else
          self.damage = "Change!"
          self.change_item[0] = true
        end
        return true
      end
    end
    # 元の処理を呼び出し
    hidesp2_skill_effect(user, skill)
  end
end

class Scene_Battle
  #--------------------------------------------------------------------------
  # ■ フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  #--------------------------------------------------------------------------
  alias hidesp2_update_phase4_step5 update_phase4_step5
  def update_phase4_step5
    # スキルの効果範囲を敵単体に設定している為ターゲットは[0]
    tc = @target_battlers[0]
    if tc != nil
      if tc.is_a?(Game_Enemy)
        #…………………………………………………………………………………………………
        # ■[へんか]の場合
        #…………………………………………………………………………………………………
        if tc.change_item[0] == true
          # アイテムデータの取得
          tc.change_item_effect(tc,@active_battler)
          @help_window.set_text_icon(tc,tc.change_item[3], 1)
          @wait_count = 40
          # [へんか]フラグOFF
          tc.change_item[0] = false
          # [へんか]成功の場合
          if tc.change_item[5] == true
            # 変化したモンスターの行動をクリア
            tc.current_action.clear
            # 隠れフラグをON(隠れる)
            tc.hidden = true
          end
        #…………………………………………………………………………………………………
        # ■[ぬすむ]の場合
        #…………………………………………………………………………………………………
        elsif tc.steal_item[0] == true
          # アイテムデータの取得
          tc.steal_item_effect(tc,@active_battler)
          @help_window.set_text_icon(tc,tc.steal_item[6], 1)
          @wait_count = 40
          # [ぬすむ]フラグOFF
          
          tc.steal_item[0] = false
        else
          # 元の処理を呼び出し
          hidesp2_update_phase4_step5
          return
        end
        tc.damage_pop = true
        # ステップ 6 に移行
        @phase4_step = 6
        return
      end
    end
    # 元の処理を呼び出し
    hidesp2_update_phase4_step5
  end
  
end

