#==============================================================================
# AGO (Audio-Graphics-Others) Finder v1.0
#------------------------------------------------------------------------------
# Author: Wecoc
# No credits needed! :)
#==============================================================================

=begin

This script allows you to find across the whole game something in particular
(like a bgm, a picture, or a switch) to know where it was used.

You can copy the script on your game over main
then use it as times as you want and then delete it again.

There are three big types of methods you can insert on script call

1A. p check_{something}

  For example: p check_se
 
  This call returns a list on a content box with all the files of that type
  used in the game.
 
  If you need to know which RTP files are you using or which files you have in
  the folder but the game does not use, this method will be useful to you.
 
  Beware the scripts anyway before to delete the file. The method checks also
  script calls from interpreters, but not the Script Editor, so before delete the
  file do a search of it's name there.

1B. p check_unused_{something}
 
  This call returns a list on a content box with all the files on their folder
  minus the files detected with the check call.
 
2. p {something}_where?(file)

  For example: p bgm_where?("001-Battle01")
 
  This method finds the file and returns where it's used.
  If you want to change the name of a file, or change the file to another file
  (for example change a RPG file to a non-RTP file), this method will be
  useful to you.
 
3. write_txt(:check_{something}, name)

  For example: write_txt(:check_bgm, "BGM") # creates a txt file called ResultBGM.txt
 
  This method does the same as the first one besides it creates a txt file
  with the same contents. It does not use p and it uses : before check_  
 
------ AUDIO ------

  p check_bgm
  p check_bgs
  p check_me
  p check_se
 
  p check_unused_bgm
  p check_unused_bgs
  p check_unused_me
  p check_unused_se
 
  p bgm_where?(file name)
  p bgs_where?(file name)
  p me_where?(file name)
  p se_where?(file name)

------ GRAPHICS ------

  p check_animation
  p check_autotile
  p check_battleback
  p check_battler
  p check_character
  p check_fog
  p check_icon
  p check_panorama
  p check_picture
  p check_tileset
  p check_transition
  p check_windowskin
 
  p check_unused_animation
  p check_unused_autotile
  p check_unused_battleback
  p check_unused_battler
  p check_unused_character
  p check_unused_fog
  p check_unused_icon
  p check_unused_panorama
  p check_unused_picture
  p check_unused_tileset
  p check_unused_transition
  p check_unused_windowskin

 
  p ani_where?(file name) | p ani_where?(animation id on DB)
  p atile_where?(file name)
  p bback_where?(file name)
  p battler_where?(file name)
  p chara_where?(file name)
  p fog_where?(file name)
  p icon_where?(file name)
  p picture_where?(file name)
  p panorama_where?(file name)
  p tileset_where?(file name)
  p trans_where?(file name)
  p wskin_where?(file name)

------ OTHERS ------

  p skill_where?(skill id)   |  p skill_where?(skill name)
  p item_where?(item id)     |  p item_where?(item name)
  p weapon_where?(weapon id) |  p weapon_where?(weapon name)
  p armor_where?(weapon id)  |  p weapon_where?(armor name)
  p switch_where?(switch id)
  p variable_where?(variable id)
  p comev_call_where?(common event id)

=end

#==============================================================================


module AGO
  AUDIO_FINDER = true     # true to activate the Audio Finder methods
  GRAPHICS_FINDER = true  # true to activate the Graphics Finder methods
  OTHERS_FINDER = true    # true to activate the Others Finder methods
 
  JOIN = true
  # JOIN : when true, the names on the content box are shown "A, B, C, D"
  # a bit easier to read than "A","B","C","D"
end

#==============================================================================

module ScriptTools
  def self.get_map_id(id)
    return map_id = id < 1 ? $game_map.map_id : id
  end
end

class Interpreter
  attr_accessor  :event_id
 
  def write_txt(content, type)
    csd = self.send(content)
    p csd
    content = AGO::JOIN == true ? csd.split(", ") : csd
    f = File.new("Result#{type}.txt", "w")
    count = 0
    content.each{|name|
    f << name + "\n"
    count += 1
    }
    f << "\nResults counted: #{count}"
    f.close
  end
end

class String
  def new_to_a
    content = self.split(", ")
    array = []
    content.each{|name| array << name}
  end
end

class Game_Maps # (by Youkai)
  def initialize
    @maps = [nil]
    id = 1
    while FileTest.exist?(sprintf("Data/Map%03d.rxdata", id))
      map = load_data(sprintf("Data/Map%03d.rxdata", id))
      @maps.push(map)
      id += 1
    end
  end
  def [](map_id)
    return @maps[map_id]
  end
  def size
    return @maps.size
  end
end
     
class Scene_Title
  alias tilemod_command_new_game command_new_game unless $@
  def command_new_game
    $game_maps = Game_Maps.new
    tilemod_command_new_game
  end
end

class Game_Event < Game_Character
  attr_accessor :id
end

class Game_System
  def initialize
    @map_interpreter = Interpreter.new(0, true)
    @battle_interpreter = Interpreter.new(0, false)
    @timer = 0
    @timer_working = false
    @save_disabled = false
    @menu_disabled = false
    @encounter_disabled = false
    @message_position = 2
    @message_frame = 0
    @save_count = 0
    @magic_number = 0
  end
 
  def get_extension_files(dirname)
    Dir.open(dirname) {|d|
      return d.select {|ent| File.file?("#{dirname}/#{ent}") }
    }
  end
 
  def get_files(dirname)
    folder_files = get_extension_files(dirname)
    folder_files.each do |d|
      d.chomp!(".png") ; d.chomp!(".jpg") ; d.chomp!(".bmp")
      d.chomp!(".mid") ; d.chomp!(".ogg") ; d.chomp!(".wma")
      d.chomp!(".mp3") ; d.chomp!(".wav")
    end
    return folder_files
  end
end

#==============================================================================
#==============================================================================
#==============================================================================

if AGO::AUDIO_FINDER == true

class Game_System
  def check_bgm_complete
    data = []
    # Data System
    data.push($data_system.battle_bgm.name)
    data.push($data_system.title_bgm.name)
    # Map Initialize Bgm
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      if map.autoplay_bgm
        data.push(map.bgm.name)
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 241 # Play BGM
          data.push(list[i].parameters[0].name)
        end
        if list[i].code == 132 # Change Battle BGM
          data.push(list.parameters[0].name)
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 241 # Play BGM
              data.push(list.parameters[0].name)
            end
            if list.code == 132 # Change Battle BGM
              data.push(list.parameters[0].name)
            end
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 241
            data.push(list.parameters[0].name)
          end
          if list.code == 132
            data.push(list.parameters[0].name)
          end
        end
      end
    end
    data.compact!
    data.delete("")
    return data
  end
 
  def check_bgm
    data = check_bgm_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end

  def bgm_where?(bgm) # (where is used)
    data = []
    # Data System
    if $data_system.battle_bgm == bgm
      data.push("Battle BGM")
    end
    if $data_system.title_bgm == bgm
      data.push("Title BGM")
    end
    # Map Initialize Bgm
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      if map.bgm.name == bgm
        if map.autoplay_bgm
          data.push("Map "+gamemap.to_s+" BGM")
        else
          data.push("Map "+gamemap.to_s+" BGM (Autoplay disabled!)")
        end
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 241 # Play BGM
          if list[i].parameters[0].name == bgm
            data.push("Common Ev "+common_event.to_s)
          end
        end
        if list[i].code == 132 # Change Battle BGM
          if list[i].parameters[0].name == bgm
            data.push("Common Ev "+common_event.to_s+" (Change Battle BGM)")
          end
        end
        if list[i].code == 355
          if list[i].parameters[0].include?(bgm)
            data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 241 # Play BGM
              if list.parameters[0].name == bgm
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1}")
              end
            end
            if list.code == 132 # Change Battle BGM
              if list.parameters[0].name == bgm
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Change Battle BGM)")
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355
                if list.parameters[0].include?(bgm)
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 241
            if list.parameters[0].name == bgm
              data.push("Troop "+gametroop.to_s+" Page #{page+1}")
            end
          end
          if list.code == 132
            if list.parameters[0].name == bgm
              data.push("Troop "+gametroop.to_s+
              " Page #{page+1} (Change Battle BGM)")
            end
          end
          if list.code == 355
            if list.parameters[0].include?(bgm)
              data.push("Troop "+gametroop.to_s+
              " Page #{page+1} (Script Call)")
            end
          end
        end
      end
    end
    
    data.push("Not found!") if data.size == 0
    return data
  end
 
  def check_unused_bgm
    check = check_bgm
    folder = get_files("Audio/BGM/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
 
  #---------------------------------------------------------------------------
 
  def check_bgs_complete
    data = []
    # Map Initialize Bgm
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      if map.autoplay_bgs
        data.push(map.bgs.name)
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 245 # Play BGM
          data.push(list[i].parameters[0].name)
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 245 # Play BGM
              data.push(list.parameters[0].name)
            end
          end
        end
      end
    end   
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 245
            data.push(list.parameters[0].name)
          end
        end
      end
    end
    data.compact!
    data.delete("")
    return data
  end
 
  def check_bgs
    data = check_bgs_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end

  def bgs_where?(bgs) # (where is used)
    data = []
    # Map Initialize Bgm
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      if map.bgs.name == bgs
        if map.autoplay_bgs
          data.push("Map "+gamemap.to_s+" BGS")
        else
          data.push("Map "+gamemap.to_s+" BGS (Autoplay disabled!)")
        end
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 245 # Play BGS
          if list[i].parameters[0].name == bgs
            data.push("Common Ev "+common_event.to_s)
          end
        end
        if list[i].code == 355
          if list[i].parameters[0].include?(bgs)
            data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 245 # Play BGS
              if list.parameters[0].name == bgs
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1}")
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355
                if list.parameters[0].include?(bgs)
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 245
            if list.parameters[0].name == bgs
              data.push("Troop "+gametroop.to_s+" Page #{page+1}")
            end
          end
          if list.code == 355
            if list.parameters[0].include?(bgs)
              data.push("Troop "+gametroop.to_s+
              " Page #{page+1} (Script Call)")
            end
          end
        end
      end
    end
    
    data.push("Not found!") if data.size == 0
    return data
  end

  def check_unused_bgs
    check = check_bgs
    folder = get_files("Audio/BGS/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
 
  #---------------------------------------------------------------------------
 
  def check_me_complete
    data = []
    # Data System
    data.push($data_system.gameover_me.name)
    data.push(battle_end_me.name)
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 249 # Play ME
          data.push(list[i].parameters[0].name)
        end
        if list[i].code == 133 # Change Battle End ME
          data.push(list.parameters[0].name)
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 249 # Play ME
              data.push(list.parameters[0].name)
            end
            if list.code == 133 # Change Battle End ME
              data.push(list.parameters[0].name)
            end
          end
        end
      end
    end   
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 249 # Play ME
            data.push(list.parameters[0].name)
          end
          if list.code == 133 # Change Battle End ME
            data.push(list.parameters[0].name)
          end
        end
      end
    end
    data.compact!
    data.delete("")
    return data
  end
 
  def check_me
    data = check_me_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end
 
  def me_where?(me) # (where is used)
    data = []
    # Data System
    if $data_system.gameover_me.name == me
      data.push("Game Over")
    end
    if battle_end_me.name == me
      data.push("Victory Database")
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 249 # Play ME
          data.push("Common Ev "+common_event.to_s)
        end
        if list[i].code == 133 # Change Battle End ME
          data.push("Common Ev "+common_event.to_s+" (Change Victory ME)")
        end
        if list[i].code == 355
          if list[i].parameters[0].include?(me)
            data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 249 # Play ME
              if list.parameters[0].name == me
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1}")
              end
            end
            if list.code == 133 # Change Battle End ME
              if list.parameters[0].name == me
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Change Victory ME)")
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355
                if list.parameters[0].include?(me)
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end   
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 249
            if list.parameters[0].name == me
              data.push("Troop "+gametroop.to_s+" Page #{page+1}")
            end
          end
          if list.code == 133
            if list.parameters[0].name == me
              data.push("Troop "+gametroop.to_s+
              " Page #{page+1} (Change Victory ME)")
            end
          end
          if list.code == 355
            if list.parameters[0].include?(me)
              data.push("Troop "+gametroop.to_s+
              " Page #{page+1} (Script Call)")
            end
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
 
  def check_unused_me
    check = check_me
    folder = get_files("Audio/ME/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
 
  #---------------------------------------------------------------------------
 
  def check_se_complete
    data = []
    # Data System
    data.push($data_system.cursor_se.name)
    data.push($data_system.decision_se.name)
    data.push($data_system.cancel_se.name)
    data.push($data_system.buzzer_se.name)
    data.push($data_system.equip_se.name)
    data.push($data_system.shop_se.name)
    data.push($data_system.save_se.name)
    data.push($data_system.load_se.name)
    data.push($data_system.battle_start_se.name)
    data.push($data_system.escape_se.name)
    data.push($data_system.actor_collapse_se.name)
    data.push($data_system.enemy_collapse_se.name)
    # Data Animation
    for animation in 1...$data_animations.size
      ani = $data_animations[animation]
      for timing in ani.timings
        data.push(timing.se.name)
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 250 # Play SE
          data.push(list[i].parameters[0].name)
        end
        if list[i].code == 209 # Move Route
          for param in 1...list.parameters.size
            parameter = list.parameters[param]
            for param2 in 0...parameter.list.size
              param3 = parameter.list[param2]
              data.push(param3.parameters[0].name) if param3.code == 44
            end
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 250 # Play SE
            data.push(list.parameters[0].name)
          end
          if list.code == 209 # Move Route
            for param in 1...list.parameters.size
              parameter = list.parameters[param]
              for param2 in 0...parameter.list.size
                param3 = parameter.list[param2]
                data.push(param3.parameters[0].name) if param3.code == 44
              end
            end
          end
        end
      end
    end
    # Data Skills
    for skill in 1...$data_skills.size
      data.push($data_skills[skill].menu_se.name)
    end
    # Data Items
    for item in 1...$data_items.size
      data.push($data_items[item].menu_se.name)
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 250 # Play SE
              data.push(list.parameters[0].name)
            end
            if list.code == 209 # Move Route
              for param in 1...list.parameters.size
                parameter = list.parameters[param]
                for param2 in 0...parameter.list.size
param3 = parameter.list[param2]
data.push(param3.parameters[0].name) if param3.code == 44
                end
              end
            end
          end
        end
      end
    end
    # Event Routes
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.move_route.list.size
            list = map.events[event].pages[page].move_route.list[glist]
            if list.code == 44
              data.push(list.parameters[0].name)
            end
          end
        end
      end
    end
     
    data.compact!
    data.delete("")
    return data
  end
 
  def check_se
    data = check_se_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end
 
  def se_where?(se) # (where is used)
    data = []
    # Data System
    if $data_system.cursor_se.name == se
      data.push("Cursor System Database")
    end
    if $data_system.decision_se.name == se
      data.push("Decision System Database")
    end
    if $data_system.cancel_se.name == se
      data.push("Cancel System Database")
    end
    if $data_system.buzzer_se.name == se
      data.push("Buzzer System Database")
    end
    if $data_system.buzzer_se.name == se
      data.push("Equip System Database")
    end
    if $data_system.buzzer_se.name == se
      data.push("Shop System Database")
    end
    if $data_system.save_se.name == se
      data.push("Save System Database")
    end
    if $data_system.load_se.name == se
      data.push("Load System Database")
    end
    if $data_system.battle_start_se.name == se
      data.push("Battle Start System Database")
    end
    if $data_system.battle_start_se.name == se
      data.push("Escape System Database")
    end
    if $data_system.battle_start_se.name == se
      data.push("Actor Collapse System Database")
    end
    if $data_system.battle_start_se.name == se
      data.push("Enemy Collapse System Database")
    end
    # Data Animation
    for animation in 1...$data_animations.size
      ani = $data_animations[animation]
      for timing in ani.timings
        if timing.se.name == se
          data.push("Animation '"+$data_animations[animation].name+"' ("+animation.to_s+")")
        end
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 250 # Play SE
          if list[i].parameters[0].name == se
            data.push("Common Ev "+common_event.to_s)
          end
        end
        if list[i].code == 209 # Move Route
          for param in 1...list.parameters.size
            parameter = list.parameters[param]
            for param2 in 0...parameter.list.size
              param3 = parameter.list[param2]
              if param3.code == 44
                if param3.parameters[0].name == se
data.push("Common Ev "+common_event.to_s+" (Command Route)")
                end
              end
            end
          end
        end
        if list[i].code == 355
          if list[i].parameters[0].include?(se)
            data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 250
            if list.parameters[0].name == se
              data.push("Troop "+gametroop.to_s+" Page #{page+1}")
            end
          end
          if list.code == 209
            for param in 1...list.parameters.size
              parameter = list.parameters[param]
              for param2 in 0...parameter.list.size
                param3 = parameter.list[param2]
                if param3.code == 44
if param3.parameters[0].name == se
data.push("Troop "+gametroop.to_s+
" Page #{page+1} (Command Route)")
end
                end
              end
            end
          end
          if list.code == 355
            if list.parameters[0].include?(se)
              data.push("Troop "+gametroop.to_s+
              " Page #{page+1} (Script Call)")
            end
          end
        end
      end
    end
    # Data Skills
    for skill in 1...$data_skills.size
      if $data_skills[skill].menu_se.name == se
        data.push("Skill '"+$data_skills[skill].name+"' ("+skill.to_s+")")
        #data.push("Skill "+skill.to_s+" Menu Sound")
      end
    end
    # Data Items
    for item in 1...$data_items.size
      if $data_items[item].menu_se.name == se
        data.push("Item '"+$data_items[item].name+"' ("+item.to_s+")")
        #data.push("Item "+item.to_s+" Menu Sound")
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 250 # Play SE
              if list.parameters[0].name == se
                data.push("Map "+gamemap.to_s+
                " Event "+event.to_s+" Page #{page+1}")
              end
            end
            if list.code == 209 # Move Route
              for param in 1...list.parameters.size
                parameter = list.parameters[param]
                for param2 in 0...parameter.list.size
param3 = parameter.list[param2]
if param3.code == 44
if param3.parameters[0].name == se
data.push("Map "+gamemap.to_s+
" Event "+event.to_s+" Page #{page+1} (Command Route)")
end
end
                end
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355
                if list.parameters[0].include?(se)
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    # Event Routes
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.move_route.list.size
            list = map.events[event].pages[page].move_route.list[glist]
            if list.code == 44
              if list.parameters[0].name == se
                data.push("Map "+gamemap.to_s+
                " Event "+event.to_s+" Page #{page+1} (Event Page Route)")
              end
            end
          end
        end
      end
    end   
    
    data.push("Not found!") if data.size == 0
    return data
  end
 
  def check_unused_se
    check = check_se
    folder = get_files("Audio/SE/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
end

#==============================================================================

class Interpreter
  def check_bgm
    $game_system.check_bgm
  end
  def check_bgs
    $game_system.check_bgs
  end
  def check_me
    $game_system.check_me
  end
  def check_se
    $game_system.check_se
  end

  def check_unused_bgm
    $game_system.check_unused_bgm
  end
  def check_unused_bgs
    $game_system.check_unused_bgs
  end
  def check_unused_me
    $game_system.check_unused_me
  end
  def check_unused_se
    $game_system.check_unused_se
  end
 
  def bgm_where?(bgm)
    $game_system.bgm_where?(bgm)
  end
  def bgs_where?(bgs)
    $game_system.bgs_where?(bgs)
  end
  def me_where?(me)
    $game_system.me_where?(me)
  end
  def se_where?(se)
    $game_system.se_where?(se)
  end
end
 
end


#==============================================================================
#==============================================================================
#==============================================================================

if AGO::GRAPHICS_FINDER == true
 
class Game_System
  def check_animation_complete
    animation = []
    # Data Weapon / Item / Skill / Enemy / State
    for weapon in 1...$data_weapons.size
      weapon = $data_weapons[weapon]
      animation.push(weapon.animation1_id)
      animation.push(weapon.animation2_id)
    end
    for item in 1...$data_items.size
      item = $data_items[item]
      animation.push(item.animation1_id)
      animation.push(item.animation2_id)
    end
    for skill in 1...$data_skills.size
      skill = $data_skills[skill]
      animation.push(skill.animation1_id)
      animation.push(skill.animation2_id)
    end
    for enemy in 1...$data_enemies.size
      enemy = $data_enemies[enemy]
      animation.push(enemy.animation1_id)
      animation.push(enemy.animation2_id)
    end
    for state in 1...$data_states.size
      state = $data_states[state]
      animation.push(state.animation_id)
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 207 # Show Animation (Map)
          animation.push(list[i].parameters[1])
        end
        if list[i].code == 337 # Show Animation (Battle)
          animation.push(list[i].parameters[2])
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 207
            data.push(list.parameters[1])
          end
          if list.code == 337
            data.push(list.parameters[2])
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 207 # Show Animation (Map)
              animation.push(list.parameters[1])
            end
            if list.code == 337 # Show Animation (Battle)
              animation.push(list.parameters[2])
            end
          end
        end
      end
    end
    animation.compact!
    animation.delete(0)
    data = []
    for i in 0...animation.size
      next if $data_animations[i] == nil
      data.push($data_animations[i].animation_name)
    end
    return data
  end
 
  def check_animation
    data = check_animation_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end
    
  def ani_where?(animation)
    animation_data = []
    data = []
    if animation.is_a?(Integer)
      animation = $data_animations[animation].animation_name
    end
    for ani in 1...$data_animations.size
      if $data_animations[ani].animation_name == animation
        animation_data.push(ani)
      end
    end
    for weapon in 1...$data_weapons.size
      weapon = $data_weapons[weapon]
      if weapon.animation1_id != nil and animation_data.include?(weapon.animation1_id)
        data.push("Weapon '"+weapon.name+" ("+weapon.id.to_s+
        ") A1 = "+$data_animations[weapon.animation1_id].name)
      end
      if weapon.animation2_id != nil and animation_data.include?(weapon.animation2_id)
        data.push("Weapon '"+weapon.name+" ("+weapon.id.to_s+
        ") A2 = "+$data_animations[weapon.animation1_id].name)
      end
    end
    for item in 1...$data_items.size
      item = $data_items[item]
      if item.animation1_id != nil and animation_data.include?(item.animation1_id)
        data.push("Item '"+item.name+" ("+item.id.to_s+
        ") A1 = "+$data_animations[item.animation1_id].name)
      end
      if item.animation2_id != nil and animation_data.include?(item.animation2_id)
        data.push("Item '"+item.name+" ("+item.id.to_s+
        ") A2 = "+$data_animations[item.animation2_id].name)
      end
    end
    for skill in 1...$data_skills.size
      skill = $data_skills[skill]
      if skill.animation1_id != nil and animation_data.include?(skill.animation1_id)
        data.push("Skill '"+skill.name+" ("+skill.id.to_s+
        ") A1 = "+$data_animations[skill.animation1_id].name)
      end
      if skill.animation2_id != nil and animation_data.include?(skill.animation2_id)
        data.push("Skill '"+skill.name+" ("+skill.id.to_s+
        ") A2 = "+$data_animations[skill.animation2_id].name)
      end
    end
    for enemy in 1...$data_enemies.size
      enemy = $data_enemies[enemy]
      if enemy.animation1_id != nil and animation_data.include?(enemy.animation1_id)
        data.push("Enemy '"+enemy.name+" ("+enemy.id.to_s+
        ") A1 = "+$data_animations[enemy.animation1_id].name)
      end
      if enemy.animation2_id != nil and animation_data.include?(enemy.animation2_id)
        data.push("Enemy '"+enemy.name+" ("+enemy.id.to_s+
        ") A2 = "+$data_animations[enemy.animation2_id].name)
      end
    end
    for state in 1...$data_states.size
      state = $data_states[state]
      if state.animation_id != nil and animation_data.include?(state.animation_id)
        data.push("State '"+state.name+" ("+state.id.to_s+
        ") A = "+$data_animations[state.animation_id].name)
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 207 # Show Animation (Map)
          if list[i].parameters[1] == animation
            data.push("Common Ev "+common_event.to_s+" (Show Map Animation)")
          end
        end
        if list[i].code == 337 # Show Animation (Battle)
          if list[i].parameters[2] == animation
            data.push("Common Ev "+common_event.to_s+" (Show Battle Animation)")
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 207 # Show Animation (Map)
            if list.parameters[1] == animation
              data.push("Troop "+gametroop.to_s+" Page #{page+1}"+
              " (Show Map Animation)")
            end
          end
          if list.code == 337 # Show Animation (Battle)
            if list.parameters[2] == animation
              data.push("Troop "+gametroop.to_s+" Page #{page+1}"+
              " (Show Battle Animation)")
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 207 # Show Animation (Map)
              if list.parameters[1] == animation
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Show Map Animation)")
              end
            end
            if list.code == 337 # Show Animation (Battle)
              if list.parameters[2] == animation
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Show Battle Animation)")
              end
            end
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end

  def check_unused_animation
    check = check_animation
    folder = get_files("Graphics/Animations/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
 
  #---------------------------------------------------------------------------

  def check_autotile_complete
    data = []
    # Tileset
    for tileset in 1...$data_tilesets.size
      tileset = $data_tilesets[tileset]
      for autotile in 0..8
        data.push(tileset.autotile_names[autotile])
      end
    end
    data.compact!
    data.delete("")
    return data
  end
 
  def check_autotile
    data = check_autotile_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end
 
  def atile_where?(autotile)
    data = []
    for tileset in 1...$data_tilesets.size
      tileset = $data_tilesets[tileset]
      for atile in 0..8
        if tileset.autotile_names[atile] == autotile
          data.push("Database Tileset "+tileset.to_i)
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
 
  def check_unused_autotile
    check = check_autotile
    folder = get_files("Graphics/Autotiles/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
 
  #---------------------------------------------------------------------------
 
  def check_battleback_complete
    data = []
    # Tileset
    for tileset in 1...$data_tilesets.size
      tileset = $data_tilesets[tileset]
      data.push(tileset.battleback_name)
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 204 # Change Map Graphics
          if list[i].parameters[0] == 2 # Battleback
            data.push(list[i].parameters[1])
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 204
            if list.parameters[0] == 2 # Battleback
              data.push(list.parameters[1])
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 204 # Change Map Graphics
              if list.parameters[0] == 2 # Battleback
                data.push(list.parameters[1])
              end
            end
          end
        end
      end
    end
    data.compact!
    data.delete("")
    return data
  end
 
  def check_battleback
    data = check_battleback_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end
 
  def bback_where?(bback)
    data = []
    for tileset in 1...$data_tilesets.size
      tileset = $data_tilesets[tileset]
      if tileset.battleback_name == bback
        data.push("Database Tileset "+tileset.name)
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 204 # Change Map Graphics
          if list[i].parameters[0] == 2 # Battleback
            if list[i].parameters[1] == bback
              data.push("Common Ev "+common_event.to_s)
            end
          end
        end
        if list[i].code == 355 # Script
          if list[i].parameters[0].split.join.include?(bback)
            data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 204
            if list.parameters[0] == 2 # Battleback
              if list.parameters[1] == bback
                data.push("Troop "+gametroop.to_s+" Page #{page+1}")
              end
            end
            if list.code == 355 # Script
              if list.parameters[0].split.join.include?(bback)
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
              end
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 204 # Change Map Graphics
              if list.parameters[0] == 2 # Battleback
                if list.parameters[1] == bback
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1}")
                end
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355 # Script
                if list.parameters[0].split.join.include?(bback)
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
 
  def check_unused_battleback
    check = check_battleback
    folder = get_files("Graphics/Battlebacks/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
 
  #---------------------------------------------------------------------------
 
  def check_battler_complete
    data = []
    # Data Actor / Enemy
    for actor in 1...$data_actors.size
      actor = $data_actors[actor]
      data.push(actor.battler_name)
    end
    for enemy in 1...$data_enemies.size
      enemy = $data_enemies[enemy]
      data.push(enemy.battler_name)
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 322 # Change Actor Graphic
          data.push(list[i].parameters[3])
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 322 # Change Actor Graphic
            data.push(list.parameters[3])
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 322 # Change Actor Graphic
              data.push(list.parameters[3])
            end
          end
        end
      end
    end    
    data.compact!
    data.delete("")
    return data
  end
 
  def check_battler
    data = check_battler_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end

  def battler_where?(battler)
    data = []
    # Data Actor / Enemy
    for actor in 1...$data_actors.size
      actor = $data_actors[actor]
      if actor.battler_name == battler
        data.push("Actor "+actor.id.to_s)
      end
    end
    for enemy in 1...$data_enemies.size
      enemy = $data_enemies[enemy]
      if enemy.battler_name == battler
        data.push("Enemy "+enemy.id.to_s)
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 322 # Change Actor Graphic
          if list[i].parameters[3] == battler
            data.push("Common Ev "+common_event.to_s)
          end
        end
        if list[i].code == 355 # Script
          if list[i].parameters[0].split.join.include?(battler)
            data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 322 # Change Actor Graphic
            if list.parameters[3] == battler
              data.push("Troop "+gametroop.to_s+" Page #{page+1}")
            end
            if list.code == 355 # Script
              if list.parameters[0].split.join.include?(battler)
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
              end
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 322 # Change Actor Graphic
              if list.parameters[3] == battler
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1}")
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355 # Script
                if list.parameters[0].split.join.include?(battler)
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end    
    data.push("Not found!") if data.size == 0
    return data
  end
 
  def check_unused_battler
    check = check_battler
    folder = get_files("Graphics/Battlers/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
 
  #---------------------------------------------------------------------------
 
  def check_character_complete
    data = []
    # Data Actor
    for actor in 1...$data_actors.size
      actor = $data_actors[actor]
      data.push(actor.character_name)
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 322 # Change Actor Graphic
          data.push(list[i].parameters[1])
        end
        if list[i].code == 209 # Move Route
          for param in 1...list.parameters.size
            parameter = list.parameters[param]
            for param2 in 0...parameter.list.size
              param3 = parameter.list[param2]
              data.push(param3.parameters[0]) if param3.code == 41
            end
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 322 # Change Actor Graphic
            data.push(list.parameters[1])
          end
          if list.code == 209 # Move Route
            for param in 1...list.parameters.size
              parameter = list.parameters[param]
              for param2 in 0...parameter.list.size
                param3 = parameter.list[param2]
                data.push(param3.parameters[0]) if param3.code == 41
              end
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 322 # Change Actor Graphic
              data.push(list.parameters[1])
            end
            if list.code == 209 # Move Route
              for param in 1...list.parameters.size
                parameter = list.parameters[param]
                for param2 in 0...parameter.list.size
param3 = parameter.list[param2]
data.push(param3.parameters[0]) if param3.code == 41
                end
              end
            end
          end
        end
      end
    end
    # Event Routes
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.move_route.list.size
            list = map.events[event].pages[page].move_route.list[glist]
            if list.code == 41
              data.push(list.parameters[0])
            end
          end
        end
      end
    end
    # Event Graphics
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          data.push(pag.graphic.character_name)
        end
      end
    end
    data.compact!
    data.delete("")
    return data
  end
 
  def check_character
    data = check_character_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end
 
  def chara_where?(chara)
    data = []
    # Data Actor
    for actor in 1...$data_actors.size
      actor = $data_actors[actor]
      if actor.character_name == chara
        data.push("Actor "+actor.id.to_s)
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 322 # Change Actor Graphic
          if list[i].parameters[1] == chara
            data.push("Common Ev "+common_event.to_s)
          end
        end
        if list.code == 355 # Script
          if list.parameters[0].split.join.include?(chara)
            data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end
        if list[i].code == 209 # Move Route
          for param in 1...list.parameters.size
            parameter = list.parameters[param]
            for param2 in 0...parameter.list.size
              param3 = parameter.list[param2]
              if param3.code == 41
                if param3.parameters[0] == chara
data.push("Common Ev "+common_event.to_s+" (Command Route)")
                end
              end
              if param3.code == 45
                if param3.parameters[0].split.join.include?(chara)
data.push("Common Ev "+common_event.to_s+" (Command Route Script)")
                end
              end
            end
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 322 # Change Actor Graphic
            if list.parameters[1] == chara
              data.push("Troop "+gametroop.to_s+" Page #{page+1}")
            end
          end
          if list.code == 355 # Script
            if list.parameters[0].split.join.include?(chara)
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
            end
          end
          if list.code == 209 # Move Route
            for param in 1...list.parameters.size
              parameter = list.parameters[param]
              for param2 in 0...parameter.list.size
                param3 = parameter.list[param2]
                if param3.code == 41
if param3.parameters[0] == chara
data.push("Troop "+gametroop.to_s+" Page #{page+1} (Command Route)")
end
                end
                if param3.code == 45
if param3.parameters[0].split.join.include?(chara)
data.push("Troop "+gametroop.to_s+
" Page #{page+1} (Command Route Script)")
end
                end
              end
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 322 # Change Actor Graphic
              if list.parameters[1] == chara
                data.push("Map "+gamemap.to_s+
                " Event "+event.to_s+" Page #{page+1}")
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355 # Script
                if list.parameters[0].split.join.include?(chara)
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
            if list.code == 209 # Move Route
              for param in 1...list.parameters.size
                parameter = list.parameters[param]
                for param2 in 0...parameter.list.size
param3 = parameter.list[param2]
if param3.code == 41
if param3.parameters[0] == chara
data.push("Map "+gamemap.to_s+
" Event "+event.to_s+" Page #{page+1} (Command Route)")
end
end
if param3.code == 45
if param3.parameters[0].split.join.include?(chara)
data.push("Map "+gamemap.to_s+
" Event "+event.to_s+" Page #{page+1} (Command Route Script)")
end
end
                end
              end
            end
          end
        end
      end
    end
    # Event Routes
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.move_route.list.size
            list = map.events[event].pages[page].move_route.list[glist]
            if list.code == 41
              if list.parameters[0] == chara
                data.push("Map "+gamemap.to_s+
                " Event "+event.to_s+" Page #{page+1} (Event Page Route)")
              end
            end
            if list.code == 45
              if list.parameters[0].split.join.include?(chara)
                data.push("Map "+gamemap.to_s+
                " Event "+event.to_s+" Page #{page+1} (Event Page Route Script)")
              end
            end
          end
        end
      end
    end
    # Event Graphics
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          if pag.graphic.character_name == chara
            data.push("Map "+gamemap.to_s+
            " Event "+event.to_s+" Page #{page+1} (Event Graphic)")
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
 
  def check_unused_character
    check = check_character
    folder = get_files("Graphics/Characters/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
 
  #---------------------------------------------------------------------------
 
  def check_fog_complete
    data = []
    # Tileset
    for tileset in 1...$data_tilesets.size
      tileset = $data_tilesets[tileset]
      data.push(tileset.fog_name)
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 204 # Change Map Graphics
          if list[i].parameters[0] == 1 # Fog
            data.push(list[i].parameters[1])
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 204 # Change Map Graphics
            if list.parameters[0] == 1 # Fog
              data.push(list.parameters[1])
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 204 # Change Map Graphics
              if list.parameters[0] == 1 # Fog
                data.push(list.parameters[1])
              end
            end
          end
        end
      end
    end
    data.compact!
    data.delete("")
    return data
  end
 
  def check_fog
    data = check_fog_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end

  def fog_where?(fog)
    data = []
    # Tileset
    for tileset in 1...$data_tilesets.size
      tileset = $data_tilesets[tileset]
      if tileset.fog_name == fog
        data.push("Tileset "+tileset.name)
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 204 # Change Map Graphics
          if list[i].parameters[0] == 1 # Battleback
            if list[i].parameters[1] == fog
              data.push("Common Ev "+common_event.to_s)
            end
          end
        end
        if list[i].code == 355 # Script
          if list[i].parameters[0].split.join.include?(fog)
            data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 204 # Change Map Graphics
            if list.parameters[0] == 1 # Battleback
              if list.parameters[1] == fog
                data.push("Troop "+gametroop.to_s+" Page #{page+1}")
              end
            end
            if list.code == 355 # Script
              if list.parameters[0].split.join.include?(fog)
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
              end
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 204 # Change Map Graphics
              if list.parameters[0] == 1 # Battleback
                if list.parameters[1] == fog
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1}")
                end
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355 # Script
                if list.parameters[0].split.join.include?(fog)
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
 
  def check_unused_fog
    check = check_fog
    folder = get_files("Graphics/Fogs/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
 
  #---------------------------------------------------------------------------
 
  def check_icon_complete
    data = []
    # Data Skills / Items / Weapons / Armors
    for skill in 1...$data_skills.size
      data.push($data_skills[skill].icon_name)
    end
    for item in 1...$data_items.size
      data.push($data_items[item].icon_name)
    end
    for weapon in 1...$data_weapons.size
      data.push($data_weapons[weapon].icon_name)
    end
    for armor in 1...$data_armors.size
      data.push($data_armors[armor].icon_name)
    end
    data.compact!
    data.delete("")
    return data
  end
 
  def check_icon
    data = check_icon_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end
 
  def icon_where?(icon)
    data = []
    # Data Skills / Items / Weapons / Armors
    for skill in 1...$data_skills.size
      if $data_skills[skill].icon_name == icon
        data.push("Skill "+$data_skills[skill].name)
      end
    end
    for item in 1...$data_items.size
      if $data_items[item].icon_name == icon
        data.push("Item "+$data_items[item].name)
      end
    end
    for weapon in 1...$data_weapons.size
      if $data_weapons[weapon].icon_name == icon
        data.push("Weapon "+$data_weapons[weapon].name)
      end
    end
    for armor in 1...$data_armors.size
      if $data_armors[armor].icon_name == icon
        data.push("Armor "+$data_armors[armor].name)
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
 
  def check_unused_icon
    check = check_icon
    folder = get_files("Graphics/Icons/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
 
  #---------------------------------------------------------------------------

  def check_panorama_complete
    data = []
    # Tileset
    for tileset in 1...$data_tilesets.size
      tileset = $data_tilesets[tileset]
      data.push(tileset.panorama_name)
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 204 # Change Map Graphics
          if list[i].parameters[0] == 0 # Panorama
            data.push(list[i].parameters[1])
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 204 # Change Map Graphics
            if list.parameters[0] == 0 # Panorama
              data.push(list.parameters[1])
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 204 # Change Map Graphics
              if list.parameters[0] == 0 # Panorama
                data.push(list.parameters[1])
              end
            end
          end
        end
      end
    end
    data.compact!
    data.delete("")
    return data
  end
 
  def check_panorama
    data = check_panorama_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end

  def panorama_where?(panorama)
    data = []
    # Tileset
    for tileset in 1...$data_tilesets.size
      tileset = $data_tilesets[tileset]
      if tileset.panorama_name == panorama
        data.push("Tileset "+tileset.name)
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 204 # Change Map Graphics
          if list[i].parameters[0] == 0
            if list[i].parameters[1] == panorama
              data.push("Common Ev "+common_event.to_s)
            end
          end
        end
        if list[i].code == 355 # Script
          if list[i].parameters[0].split.join.include?(panorama)
            data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 204 # Change Map Graphics
            if list.parameters[0] == 0
              if list.parameters[1] == panorama
                data.push("Troop "+gametroop.to_s+" Page #{page+1}")
              end
            end
            if list.code == 355 # Script
              if list.parameters[0].split.join.include?(panorama)
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
              end
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 204 # Change Map Graphics
              if list.parameters[0] == 0
                if list.parameters[1] == panorama
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1}")
                end
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355 # Script
                if list.parameters[0].split.join.include?(panorama)
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
 
  def check_unused_panorama
    check = check_icon
    folder = get_files("Graphics/Panoramas/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
 
  #---------------------------------------------------------------------------

  def check_picture_complete
    data = []
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 231 # Show Picture
          data.push(list[i].parameters[1])
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 231 # Show Picture
            data.push(list.parameters[1])
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 231 # Show Picture
              data.push(list.parameters[1])
            end
          end
        end
      end
    end
    data.compact!
    data.delete("")
    return data
  end
 
  def check_picture
    data = check_picture_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end
 
  def picture_where?(picture)
    data = []
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 231 # Show Picture
          if list[i].parameters[1] == picture
            data.push("Common Ev "+common_event.to_s)
          end
        end
        if list[i].code == 355 # Script
          if list[i].parameters[0].split.join.include?(picture)
            data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 231 # Show Picture
            if list.parameters[1] == picture
              data.push("Troop "+gametroop.to_s+" Page #{page+1}")
            end
            if list.code == 355 # Script
              if list.parameters[0].split.join.include?(picture)
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
              end
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 231 # Show Picture
              if list.parameters[1] == picture
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1}")
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355 # Script
                if list.parameters[0].split.join.include?(picture)
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
 
  def check_unused_picture
    check = check_picture
    folder = get_files("Graphics/Pictures/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
 
  #---------------------------------------------------------------------------

  def check_tileset_complete
    data = []
    # Tileset
    for tileset in 1...$data_tilesets.size
      tileset = $data_tilesets[tileset]
      data.push(tileset.tileset_name)
    end
    data.compact!
    data.delete("")
    return data
  end
 
  def check_tileset
    data = check_tileset_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end
 
  def tileset_where?(tileset)
    data = check_tileset_complete
    if data.include?(tileset)
      return "On Tileset Database!"
    else
      return "Not found!"
    end
  end
 
  def check_unused_tileset
    check = check_tileset
    folder = get_files("Graphics/Tilesets/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
 
  #---------------------------------------------------------------------------

  def check_transition_complete
    data = []
    # System Database
    data.push($data_system.battle_transition)
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 222 # Show Transition
          data.push(list[i].parameters[0])
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 222 # Show Transition
            data.push(list.parameters[0])
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 222 # Show Transition
              data.push(list.parameters[0])
            end
          end
        end
      end
    end
    data.compact!
    data.delete("")
    return data
  end
 
  def check_transition
    data = check_transition_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end
 
  def trans_where?(transition)
    data = []
    # System Database
    if $data_system.battle_transition == transition
      data.push("Battle Transition")
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 222 # Show Transition
          if list[i].parameters[0] == transition
            data.push("Common Ev "+common_event.to_s)
          end
        end
        if list[i].code == 355 # Script
          if list[i].parameters[0].split.join.include?(transition)
            data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 222 # Show Transition
            if list.parameters[0] == transition
              data.push("Troop "+gametroop.to_s+" Page #{page+1}")
            end
            if list.code == 355 # Script
              if list.parameters[0].split.join.include?(transition)
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
              end
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 222 # Show Transition
              if list.parameters[0] == transition
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1}")
              end
            end
            if list.code == 355 # Script
              if list.parameters[0].split.join.include?(transition)
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Script Call)")
              end
            end
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
 
  def check_unused_transition
    check = check_transition
    folder = get_files("Graphics/Transitions/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
 
  #---------------------------------------------------------------------------

  def check_windowskin_complete
    data = []
    # System Database
    data.push($data_system.windowskin_name)
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 131 # Change Windowskin
          data.push(list[i].parameters[0])
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 131 # Change Windowskin
            data.push(list.parameters[0])
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 131 # Change Windowskin
              data.push(list.parameters[0])
            end
          end
        end
      end
    end
    data.compact!
    data.delete("")
    return data
  end
 
  def check_windowskin
    data = check_windowskin_complete
    hash = Hash.new(0)
    data.each{|x| hash[x]+=1 }
    data = hash.keys
    data.sort!
    return AGO::JOIN == true ? data.join(', ') : data
  end
 
  def wskin_where?(windowskin)
    data = []
    # System Database
    if $data_system.windowskin_name == windowskin
      data.push("System Database")
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 131 # Change Windowskin
          if list[i].parameters[0] == windowskin
            data.push("Common Ev"+common_event.to_s)
          end
        end
        if list[i].code == 355 # Script
          if list[i].parameters[0].split.join.include?(windowskin)
            data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 131 # Change Windowskin
            if list.parameters[0] == windowskin
              data.push("Troop "+gametroop.to_s+" Page #{page+1}")
            end
            if list.code == 355 # Script
              if list.parameters[0].split.join.include?(windowskin)
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
              end
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 131 # Change Windowskin
              if list.parameters[0]
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1}")
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355 # Script
                if list.parameters[0].split.join.include?(windowskin)
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
 
  def check_unused_windowskin
    check = check_windowskin
    folder = get_files("Graphics/Windowskins/")
    
    used = AGO::JOIN == true ? check.new_to_a : check
    unused = folder - used
    return AGO::JOIN == true ? unused.join(', ') : unused
  end
end

#==============================================================================

class Interpreter
  def check_animation
    $game_system.check_animation
  end
  def check_autotile
    $game_system.check_autotile
  end
  def check_battleback
    $game_system.check_battleback
  end
  def check_battler
    $game_system.check_battler
  end
  def check_character
    $game_system.check_character
  end
  def check_fog
    $game_system.check_fog
  end
  def check_icon
    $game_system.check_icon
  end
  def check_panorama
    $game_system.check_panorama
  end
  def check_picture
    $game_system.check_picture
  end
  def check_tileset
    $game_system.check_tileset
  end
  def check_transition
    $game_system.check_transition
  end
  def check_windowskin
    $game_system.check_windowskin
  end
 
  def check_unused_animation
    $game_system.check_unused_animation
  end
  def check_unused_autotile
    $game_system.check_unused_autotile
  end
  def check_unused_battleback
    $game_system.check_unused_battleback
  end
  def check_unused_battler
    $game_system.check_unused_battler
  end
  def check_unused_character
    $game_system.check_unused_character
  end
  def check_unused_fog
    $game_system.check_unused_fog
  end
  def check_unused_icon
    $game_system.check_unused_icon
  end
  def check_unused_panorama
    $game_system.check_unused_panorama
  end
  def check_unused_picture
    $game_system.check_unused_picture
  end
  def check_unused_tileset
    $game_system.check_unused_tileset
  end
  def check_unused_transition
    $game_system.check_unused_transition
  end
  def check_unused_windowskin
    $game_system.check_unused_windowskin
  end
 
  def ani_where?(animation)
    $game_system.ani_where?(animation)
  end
  def atile_where?(autotile)
    $game_system.atile_where?(autotile)
  end
  def bback_where?(battleback)
    $game_system.bback_where?(battleback)
  end
  def battler_where?(battler)
    $game_system.battler_where?(battler)
  end
  def chara_where?(chara)
    $game_system.chara_where?(chara)
  end
  def fog_where?(fog)
    $game_system.fog_where?(fog)
  end
  def icon_where?(icon)
    $game_system.icon_where?(icon)
  end
  def picture_where?(picture)
    $game_system.picture_where?(picture)
  end
  def panorama_where?(panorama)
    $game_system.panorama_where?(panorama)
  end
  def tileset_where?(tileset)
    $game_system.tileset_where?(tileset)
  end
  def trans_where?(transition)
    $game_system.trans_where?(transition)
  end
  def wskin_where?(windowskin)
    $game_system.wskin_where?(windowskin)
  end
end

end

#==============================================================================
#==============================================================================
#==============================================================================

if AGO::OTHERS_FINDER == true

class Game_System
  def skill_where?(skill)
    data = []
    if skill.is_a?(String)
      for i in 1...$data_skills.size
        if $data_skills[i].name == skill
          skill = i
        end
      end
    end
    return "Invalid number" if skill > $data_skills.size
    # Class Learnings
    for clas in 1...$data_classes.size
      clas = $data_classes[clas]
      for learn in 0...clas.learnings.size
        if clas.learnings[learn].skill_id == skill
          data.push("Class '"+clas.name+ "' Learning")
        end
      end
    end
    # Enemy Action Skills
    for enemy in 1...$data_enemies.size
      for action in 0...$data_enemies[enemy].actions.size
        if $data_enemies[enemy].actions[action].kind == 1
          if $data_enemies[enemy].actions[action].skill_id == skill
            data.push("Enemy #{enemy} Action Skill")
          end
        end
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 318  # Change Skills
          if list[i].parameters[2] == skill
            data.push("Troop "+gametroop.to_s+" Page #{page+1}")
          end
        end
        if list[i].code == 339  # Force Action
          if list[i].parameters[2] != 0 and list[i].parameters[3] == skill
            data.push("Troop "+gametroop.to_s+" Page #{page+1} (Force Action)")
          end
        end
        if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
          if list[i].code == 355 # Script
            if list[i].parameters[0].split.join.include?("skill#{skill}") or
              list[i].parameters[0].split.join.include?("skill(#{skill}") or
              list[i].parameters[0].split.join.include?("skills[#{skill}")
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
            end
          end
        end
      end
    end
    # Data Troop
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 318  # Change Skills
            if list.parameters[2] == skill
              data.push("Troop "+gametroop.to_s+" Page #{page+1}")
            end
          end
          if list.code == 339  # Force Action
            if list.parameters[2] != 0 and list.parameters[3] == skill
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Force Action)")
            end
          end
          if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
            if list.code == 355 # Script
              if list.parameters[0].split.join.include?("skill#{skill}") or
                list.parameters[0].split.join.include?("skill(#{skill}") or
                list.parameters[0].split.join.include?("skills[#{skill}")
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
              end
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 318  # Change Skills
              if list.parameters[2] == skill
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1}")
              end
            end
            if list.code == 339  # Force Action
              if list.parameters[2] != 0 and list.parameters[3] == skill
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Force Action)")
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355 # Script
                if list.parameters[0].split.join.include?("skill#{skill}") or
list.parameters[0].split.join.include?("skill(#{skill}") or
list.parameters[0].split.join.include?("skills[#{skill}")
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end

  #---------------------------------------------------------------------------
 
  def item_where?(item)
    data = []
    if item.is_a?(String)
      for i in 1...$data_items.size
        if $data_items[i].name == item
          item = i
        end
      end
    end
    return "Invalid number" if item > $data_items.size
    # Enemy treasures
    for enemy in 1...$data_enemies.size
      if $data_enemies[enemy].item_id == item
        data.push("Enemy "+enemy.to_s+" Treasure")
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 126 # Gain Item
          if list[i].parameters[0] == item
            data.push("Common Ev "+common_event.to_s)
          end
        end
        if list[i].code == 302 or list[i].code == 605 # Shop
          if list[i].parameters == [0, item]
            data.push("Common Ev "+common_event.to_s+" (Shop)")
          end
        end
        if list[i].code == 111 # Conditional branch
          if list[i].paramaters[0] == 8
            if list[i].parameters[1] == item
              data.push("Common Ev "+common_event.to_s+" (Cond Branch)")
            end
          end
        end
        if list[i].code == 122 # Variable
          if list[i].parameters[3] == 3
            if list[i].parameters[4] == item
              data.push("Common Ev "+common_event.to_s+" (Variable)")
            end
          end
        end
        if list[i].code == 355 # Script
          if list[i].parameters[0].split.join.include?("item#{item}") or
            list[i].parameters[0].split.join.include?("item(#{item}") or
            list[i].parameters[0].split.join.include?("item[#{item}") or
            list[i].parameters[0].split.join.include?("items[#{item}")
              data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 126 # Gain Item
            if list.parameters[0] == item
              data.push("Troop "+gametroop.to_s+" Page #{page+1}")
            end
          end
          if list.code == 302 or list.code == 605 # Shop
            if list.parameters == [0, item]
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Shop)")
            end
          end
          if list.code == 111 # Conditional branch
            if list.paramaters[0] == 8
              if list.parameters[1] == item
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Cond Branch)")
              end
            end
          end
          if list.code == 122 # Variable
            if list.parameters[3] == 3
              if list.parameters[4] == item
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Variable)")
              end
            end
          end
          if list.code == 355 # Script
            if list.parameters[0].split.join.include?("item#{item}") or
              list.parameters[0].split.join.include?("item(#{item}") or
              list.parameters[0].split.join.include?("item[#{item}") or
              list.parameters[0].split.join.include?("items[#{item}")
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 126 # Gain Item
              if list.parameters[0] == item
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1}")
              end
            end
            if list.code == 302 or list.code == 605 # Shop
              if list.parameters == [0, item]
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Shop)")
              end
            end
            if list.code == 111 # Conditional branch
              if list.paramaters[0] == 8
                if list.parameters[1] == item
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Cond Branch)")
                end
              end
            end
            if list.code == 122 # Variable
              if list.parameters[3] == 3
                if list.parameters[4] == item
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Variable)")
                end
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355 # Script
                if list.parameters[0].split.join.include?("item#{item}") or
list.parameters[0].split.join.include?("item(#{item}") or
list.parameters[0].split.join.include?("item[#{item}") or
list.parameters[0].split.join.include?("items[#{item}")
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
 
  #---------------------------------------------------------------------------
 
  def weapon_where?(item)
    data = []
    if item.is_a?(String)
      for i in 1...$data_weapons.size
        if $data_weapons[i].name == item
          item = i
        end
      end
    end
    return "Invalid number" if item > $data_weapons.size
    # Actor equipment
    for actor in 1...$data_actors.size
      if $data_actors[actor].weapon_id == item
        data.push("Actor "+actor.to_s+" Ini Weapon")
      end
    end
    # Enemy treasures
    for enemy in 1...$data_enemies.size
      if $data_enemies[enemy].weapon_id == item
        data.push("Enemy "+enemy.to_s+" Treasure")
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 127 # Gain Weapon
          if list[i].parameters[0] == item
            data.push("Common Ev "+common_event.to_s)
          end
        end
        if list[i].code == 302 or list[i].code == 605 # Shop
          if list[i].parameters == [1, item]
            data.push("Common Ev "+common_event.to_s+" (Shop)")
          end
        end
        if list[i].code == 319 # Change Equipment
          if list[i].parameters[1] == 0 and list[i].parameters[2] == item
            data.push("Common Ev "+common_event.to_s+" (Change Equip)")
          end
        end
        if list[i].code == 111 # Conditional branch
          if list[i].paramaters[0] == 9
            if list[i].parameters[1] == item
              data.push("Common Ev "+common_event.to_s+" (Cond Branch)")
            end
          end
          if list[i].paramaters[0] == 4 and list[i].paramaters[2] == 3
            if $game_actors[list[i].paramaters[1]].weapon_id == item
              data.push("Common Ev "+common_event.to_s+" (Cond Branch)")
            end
          end
        end
        if list[i].code == 355 # Script
          if list[i].parameters[0].split.join.include?("weapon#{item}") or
            list[i].parameters[0].split.join.include?("weapon(#{item}") or
            list[i].parameters[0].split.join.include?("weapon[#{item}") or
            list[i].parameters[0].split.join.include?("weapons[#{item}")
              data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 127 # Gain Weapon
            if list.parameters[0] == item
              data.push("Troop "+gametroop.to_s+" Page #{page+1}")
            end
          end
          if list.code == 302 or list.code == 605 # Shop
            if list.parameters == [1, item]
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Shop)")
            end
          end
          if list.code == 319 # Change Equipment
            if list.parameters[1] == 0 and list.parameters[2] == item
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Change Equip)")
            end
          end
          if list.code == 111 # Conditional branch
            if list.paramaters[0] == 9
              if list.parameters[1] == item
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Cond Branch)")
              end
            end
            if list.paramaters[0] == 4 and list.paramaters[2] == 3
              if $game_actors[list.paramaters[1]].weapon_id == item
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Cond Branch)")
              end
            end
          end
          if list.code == 355 # Script
            if list.parameters[0].split.join.include?("weapon#{item}") or
              list.parameters[0].split.join.include?("weapon(#{item}") or
              list.parameters[0].split.join.include?("weapon[#{item}") or
              list.parameters[0].split.join.include?("weapons[#{item}")
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 127 # Gain Weapon
              if list.parameters[0] == item
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1}")
              end
            end
            if list.code == 302 or list.code == 605 # Shop
              if list.parameters == [1, item]
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Shop)")
              end
            end
            if list.code == 319 # Change Equipment
              if list.parameters[1] == 0 and list.parameters[2] == item
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Change Equip)")
              end
            end
            if list.code == 111 # Conditional branch
              if list.paramaters[0] == 9
                if list.parameters[1] == item
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Cond Branch)")
                end
              end
              if list.paramaters[0] == 4 and list.paramaters[2] == 3
                if $game_actors[list.paramaters[1]].weapon_id == item
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Cond Branch)")
                end
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355 # Script
                if list.parameters[0].split.join.include?("weapon#{item}") or
list.parameters[0].split.join.include?("weapon(#{item}") or
list.parameters[0].split.join.include?("weapon[#{item}") or
list.parameters[0].split.join.include?("weapons[#{item}")
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end

  #---------------------------------------------------------------------------
 
  def armor_where?(item)
    data = []
    if item.is_a?(String)
      for i in 1...$data_armors.size
        if $data_armors[i].name == item
          item = i
        end
      end
    end
    return "Invalid number" if item > $data_armors.size
    # Actor equipment
    for actor in 1...$data_actors.size
      if $data_actors[actor].armor1_id == item
        data.push("Actor "+actor.to_s+" Ini Armor 1")
      end
      if $data_actors[actor].armor2_id == item
        data.push("Actor "+actor.to_s+" Ini Armor 2")
      end
      if $data_actors[actor].armor3_id == item
        data.push("Actor "+actor.to_s+" Ini Armor 3")
      end
      if $data_actors[actor].armor4_id == item
        data.push("Actor "+actor.to_s+" Ini Armor 4")
      end
    end
    # Enemy treasures
    for enemy in 1...$data_enemies.size
      if $data_enemies[enemy].armor_id == item
        data.push("Enemy "+enemy.to_s+" Treasure")
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 128 # Gain Armor
          if list[i].parameters[0] == item
            data.push("Common Ev "+common_event.to_s)
          end
        end
        if list[i].code == 302 or list[i].code == 605 # Shop
          if list[i].parameters == [2, item]
            data.push("Common Ev "+common_event.to_s+" (Shop)")
          end
        end
        if list[i].code == 319 # Change Equipment
          if list[i].parameters[1] == ($data_armors[item].kind + 1) and
            list[i].parameters[2] == item
            data.push("Common Ev "+common_event.to_s+" (Change Equip)")
          end
        end
        if list[i].code == 111 # Conditional branch
          if list[i].paramaters[0] == 10
            if list[i].parameters[1] == item
              data.push("Common Ev "+common_event.to_s+" (Cond Branch)")
            end
          end
          if list[i].paramaters[0] == 4 and list[i].paramaters[2] == 4
            if $game_actors[list[i].paramaters[1]].armor1_id == item or
              $game_actors[list[i].paramaters[1]].armor2_id == item or
              $game_actors[list[i].paramaters[1]].armor3_id == item or
              $game_actors[list[i].paramaters[1]].armor4_id == item
              data.push("Common Ev "+common_event.to_s+" (Cond Branch)")
            end
          end
        end
        if list[i].code == 355 # Script
          if list[i].parameters[0].split.join.include?("armor#{item}") or
            list[i].parameters[0].split.join.include?("armor(#{item}") or
            list[i].parameters[0].split.join.include?("armor[#{item}") or
            list[i].parameters[0].split.join.include?("armors[#{item}")
              data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end
      end
    end
    # Data Troops
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 128 # Gain Armor
            if list.parameters[0] == item
              data.push("Troop "+gametroop.to_s+" Page #{page+1}")
            end
          end
          if list.code == 302 or list.code == 605 # Shop
            if list.parameters == [2, item]
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Shop)")
            end
          end
          if list.code == 319 # Change Equipment
            if list.parameters[1] == ($data_armors[item].kind + 1) and
              list.parameters[2] == item
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Change Equip)")
            end
          end
          if list.code == 111 # Conditional branch
            if list.paramaters[0] == 10
              if list.parameters[1] == item
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Cond Branch)")
              end
            end
            if list.paramaters[0] == 4 and list.paramaters[2] == 4
              if $game_actors[list.paramaters[1]].armor1_id == item or
                $game_actors[list.paramaters[1]].armor2_id == item or
                $game_actors[list.paramaters[1]].armor3_id == item or
                $game_actors[list.paramaters[1]].armor4_id == item
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Cond Branch)")
              end
            end
          end
          if list.code == 355 # Script
            if list.parameters[0].split.join.include?("armor#{item}") or
              list.parameters[0].split.join.include?("armor(#{item}") or
              list.parameters[0].split.join.include?("armor[#{item}") or
              list.parameters[0].split.join.include?("armors[#{item}")
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 128 # Gain Armor
              if list.parameters[0] == item
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1}")
              end
            end
            if list.code == 302 or list.code == 605 # Shop
              if list.parameters == [2, item]
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Shop)")
              end
            end
            if list.code == 319 # Change Equipment
              if list.parameters[1] == ($data_armors[item].kind + 1) and
              list.parameters[2] == item
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Change Equip)")
              end
            end
            if list.code == 111 # Conditional branch
              if list.paramaters[0] == 10
                if list.parameters[1] == item
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Cond Branch)")
                end
              end
              if list.paramaters[0] == 4 and list.paramaters[2] == 4
                if $game_actors[list.paramaters[1]].armor1_id == item or
$game_actors[list.paramaters[1]].armor2_id == item or
$game_actors[list.paramaters[1]].armor3_id == item or
$game_actors[list.paramaters[1]].armor4_id == item
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Cond Branch)")
                end
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355 # Script
                if list.parameters[0].split.join.include?("armor#{item}") or
list.parameters[0].split.join.include?("armor(#{item}") or
list.parameters[0].split.join.include?("armor[#{item}") or
list.parameters[0].split.join.include?("armors[#{item}")
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
 
  #---------------------------------------------------------------------------
 
  def switch_where?(switch)
    data = []
    # Enemy Action Condition
    for enemy in 1...$data_enemies.size
      for action in 0...$data_enemies[enemy].actions.size
        if $data_enemies[enemy].actions[action].condition_switch_id == switch
          data.push("Enemy #{enemy} Action Condition")
        end
      end
    end
    # Troop Condition
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        if pag.condition.switch_valid == true
          if pag.condition.switch_id == switch
            data.push("Troop #{gametroop} Page #{page+1} Condition")
          end
        end
      end
    end
    # Common Event Condition
    for common_event in 1...$data_common_events.size
      if $data_common_events[common_event].trigger > 0
        if $data_common_events[common_event].switch_id == switch
          data.push("Common Ev "+common_event.to_s+" Condition")
        end
      end
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[i].code == 111 # Conditional branch
          if list[i].paramaters[0] == 0 and list[i].paramaters[1] == switch
            data.push("Common Ev "+common_event.to_s+" (Cond Branch)")
          end
          if list[i].paramaters[0] == 12
            if list[i].parameters[1].split.join.include?("$game_switches[#{switch}")
              data.push("Common Ev "+common_event.to_s+" (Cond Branch)")
            end
          end
        end
        if list[i].code == 121 # Control Switches
          for j in list[i].parameters[0] .. list[i].parameters[1]
            if j == switch
              data.push("Common Ev "+common_event.to_s+" (Control Switches)")
            end
          end
        end
        if list[i].code == 209 # Move Route
          for param in 1...list[i].parameters.size
            parameter = list[i].parameters[param]
            for param2 in 0...parameter.list.size
              param3 = parameter.list[param2]
              if param3.code == 27 or param3.code == 28 # Switch On / Off
                data.push("Common Ev "+common_event.to_s+" (Command Route)")
              end
              if param3.code == 45 # Script
                if param3.parameters[0].split.join.include?("$game_switches[#{switch}")
data.push("Common Ev "+common_event.to_s+" (Command Route Script)")
                end
              end
            end
          end
        end
        if list[i].code == 355 # Script
          if list[i].parameters[0].split.join.include?("$game_switches[#{switch}")
            data.push("Map "+gamemap.to_s+" Event "+event.to_s+
            " Page #{page+1} (Script Call)")
          end
        end
      end
    end
    # Data Troop
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 111 # Conditional branch
            if list.paramaters[0] == 0 and list.paramaters[1] == switch
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Cond Branch)")
            end
            if list.paramaters[0] == 12
              if list.parameters[1].split.join.include?("$game_switches[#{switch}")
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Cond Branch)")
              end
            end
          end
          if list.code == 121 # Control Switches
            for i in list.parameters[0] .. list.parameters[1]
              if i == switch
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Control Switches)")
              end
            end
          end
          if list.code == 209 # Move Route
            for param in 1...list.parameters.size
              parameter = list.parameters[param]
              for param2 in 0...parameter.list.size
                param3 = parameter.list[param2]
                if param3.code == 27 or param3.code == 28 # Switch On / Off
data.push("Troop "+gametroop.to_s+" Page #{page+1} (Command Route)")
                end
                if param3.code == 45 # Script
if param3.parameters[0].split.join.include?("$game_switches[#{switch}")
data.push("Troop "+gametroop.to_s+
" Page #{page+1} (Command Route Script)")
end
                end
              end
            end
          end
          if list.code == 355 # Script
            if list.parameters[0].split.join.include?("$game_switches[#{switch}")
              data.push("Map "+gamemap.to_s+" Event "+event.to_s+
              " Page #{page+1} (Script Call)")
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 111 # Conditional branch
              if list.paramaters[0] == 0 and list.paramaters[1] == switch
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Cond Branch)")
              end
              if list.paramaters[0] == 12
                if list.parameters[1].split.join.include?("$game_switches[#{switch}")
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Cond Branch)")
                end
              end
            end
            if list.code == 121 # Control Switches
              for i in list.parameters[0] .. list.parameters[1]
                if i == switch
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Control Switches)")
                end
              end
            end
            if list.code == 209 # Move Route
              for param in 1...list.parameters.size
                parameter = list.parameters[param]
                for param2 in 0...parameter.list.size
param3 = parameter.list[param2]
if param3.code == 27 or param3.code == 28 # Switch On / Off
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Command Route)")
end
if param3.code == 45 # Script
if param3.parameters[0].split.join.include?("$game_switches[#{switch}")
data.push("Map "+gamemap.to_s+
" Event "+event.to_s+" Page #{page+1} (Command Route Script)")
end
end
                end
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355 # Script
                if list.parameters[0].split.join.include?("$game_switches[#{switch}")
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    # Event Routes
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.move_route.list.size
            list = map.events[event].pages[page].move_route.list[glist]
            if list.code == 27 or list.code == 28 # Switch On / Off
              data.push("Map "+gamemap.to_s+" Event "+event.to_s+
              " Page #{page+1} (Event Page Route)")
            end
            if list.code == 45 # Script
              if list.parameters[0].split.join.include?("$game_switches[#{switch}")
              data.push("Map "+gamemap.to_s+" Event "+event.to_s+
              " Page #{page+1} (Event Page Route Script)")
              end
            end
          end
        end
      end
    end
    # Event Conditions
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          if (pag.condition.switch1_valid and pag.condition.switch1_id == switch) or
            (pag.condition.switch2_valid and pag.condition.switch2_id == switch)
              data.push("Map "+gamemap.to_s+" Event "+event.to_s+
              " Page #{page+1} (Page Condition)")
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
 
  #---------------------------------------------------------------------------

  def variable_where?(variable)
    data = []
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[0].code == 101 # Message Box A
          if list[0].parameters[0].include?("v[#{variable}]")
            data.push("Common Ev "+common_event.to_s+" (Message Box)")
          end
        end
        if list[0].code == 402 # Message Box B
          if list[0].parameters[1].include?("v[#{variable}]")
            data.push("Common Ev "+common_event.to_s+" (Message Box)")
          end
        end
        if list[0].code == 103 # Input Number
          if list[0].parameters[0] == variable
            data.push("Common Ev "+common_event.to_s+" (Input Number)")
          end
        end
        if list[0].code == 105 # Button Input Proc
          if list[0].parameters[0] == variable
            data.push("Common Ev "+common_event.to_s+" (Button Input Proc)")
          end
        end
        if list[0].code == 111 # Conditional branch
          if list[0].paramaters[0] == 1
            if list[0].paramaters[1] == variable or list[0].paramaters[3] == variable
              data.push("Common Ev "+common_event.to_s+" (Cond Branch)")
            end
          end
          if list[0].paramaters[0] == 12
            if list[0].parameters[1].split.join.include?("$game_variables[#{variable}")
              data.push("Common Ev "+common_event.to_s+" (Cond Branch)")
            end
          end
        end
        if list[0].code == 122 # Control Variables
          jj = false
          for i in list[0].parameters[0] .. list[0].parameters[1]
            if i == variable
              jj = true
            end
          end
          if list[0].parameters[3] == 1 and list[0].parameters[4] == variable
            jj = true
          end
          if jj == true
            data.push("Common Ev "+common_event.to_s+" (Control Variables)")
          end
        end
        if list[0].code == 125  # Change Gold
          if list[0].parameters[1] != 0 and list[0].parameters[2] == variable
            data.push("Common Ev "+common_event.to_s+" (Change Gold)")
          end
        end
        if list[0].code == 126  # Change Items
          if list[0].parameters[2] != 0 and list[0].parameters[3] == variable
            data.push("Common Ev "+common_event.to_s+" (Change Items)")
          end
        end
        if list[0].code == 127  # Change Weapons
          if list[0].parameters[2] != 0 and list[0].parameters[3] == variable
            data.push("Common Ev "+common_event.to_s+" (Change Weapons)")
          end
        end
        if list[0].code == 128  # Change Armors
          if list[0].parameters[2] != 0 and list[0].parameters[3] == variable
            data.push("Common Ev "+common_event.to_s+" (Change Armors)")
          end
        end
        if list[0].code == 201 # Transfer Player
          if list[0].parameters[0] != 0
            if list[0].parameters[1] == variable or list[0].parameters[2] == variable or
              list[0].parameters[3] == variable or list[0].parameters[4] == variable
              data.push("Common Ev "+common_event.to_s+" (Transfer Player)")
            end
          end
        end
        if list[0].code == 202 # Transfer Event
          if list[0].parameters[1] == 1
            if list[0].parameters[2] == variable or list[0].parameters[3] == variable
              data.push("Common Ev "+common_event.to_s+" (Transfer Event)")
            end
          end
        end
        if list[0].code == 231  # Show Picture
          if list[0].parameters[3] != 0
            if list[0].parameters[4] == variable or list[0].parameters[5] == variable
              data.push("Common Ev "+common_event.to_s+" (Show Picture)")
            end
          end
        end
        if list[0].code == 232  # Move Picture
          if list[0].parameters[3] != 0
            if list[0].parameters[4] == variable or list[0].parameters[5] == variable
              data.push("Common Ev "+common_event.to_s+" (Move Picture)")
            end
          end
        end
        if list[0].code == 311 or list[0].code == 331 # Change HP
          if list[0].parameters[2] != 0 and list[0].parameters[3] == variable
            data.push("Common Ev "+common_event.to_s+" (Change HP)")
          end
        end
        if list[0].code == 312 or list[0].code == 332 # Change SP
          if list[0].parameters[2] != 0 and list[0].parameters[3] == variable
            data.push("Common Ev "+common_event.to_s+" (Change SP)")
          end
        end
        if list[0].code == 315  # Change EXP
          if list[0].parameters[2] != 0 and list[0].parameters[3] == variable
            data.push("Common Ev "+common_event.to_s+" (Change EXP)")
          end
        end
        if list[0].code == 316  # Change LV
          if list[0].parameters[2] != 0 and list[0].parameters[3] == variable
            data.push("Common Ev "+common_event.to_s+" (Change LV)")
          end
        end
        if list[0].code == 317  # Change Parameters
          if list[0].parameters[3] != 0 and list[0].parameters[4] == variable
            data.push("Common Ev "+common_event.to_s+" (Change Parameters)")
          end
        end
        if list[0].code == 338  # Deal Damage
          if list[0].parameters[2] != 0 and list[0].parameters[3] == variable
            data.push("Common Ev "+common_event.to_s+" (Deal Damage)")
          end
        end
        if list[0].code == 209 # Move Route
          for param in 1...list[0].parameters.size
            parameter = list[0].parameters[param]
            for param2 in 0...parameter.list.size
              param3 = parameter.list[param2]
              if param3.code == 45 # Script
                if param3.parameters[0].split.join.include?("$game_variables[#{variable}")
data.push("Common Ev "+common_event.to_s+" (Command Route Script)")
                end
              end
            end
          end
        end
        if list[0].code == 355 # Script
          if list[0].parameters[0].split.join.include?("$game_variables[#{variable}")
            data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end          
      end
    end
    # Data Troop
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 101 # Message Box A
            if list.parameters[0].include?("v[#{variable}]")
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Message Box)")
            end
          end
          if list.code == 402 # Message Box B
            if list.parameters[1].include?("v[#{variable}]")
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Message Box)")
            end
          end
          if list.code == 103 # Input Number
            if list.parameters[0] == variable
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Input Number)")
            end
          end
          if list.code == 105 # Button Input Proc
            if list.parameters[0] == variable
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Button Input Proc)")
            end
          end
          if list.code == 111 # Conditional branch
            if list.paramaters[0] == 1
              if list.paramaters[1] == variable or list.paramaters[3] == variable
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Cond Branch)")
              end
            end
            if list.paramaters[0] == 12
              if list.parameters[1].split.join.include?("$game_variables[#{variable}")
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Cond Branch)")
              end
            end
          end
          if list.code == 122 # Control Variables
            jj = false
            for i in list.parameters[0] .. list.parameters[1]
              jj = true if i == variable
            end
            if list.parameters[3] == 1 and list.parameters[4] == variable
              jj = true
            end
            if jj == true
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Control Variables)")
            end
          end
          if list.code == 125  # Change Gold
            if list.parameters[1] != 0 and list.parameters[2] == variable
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Change Gold)")
            end
          end
          if list.code == 126  # Change Items
            if list.parameters[2] != 0 and list.parameters[3] == variable
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Change Items)")
            end
          end
          if list.code == 127  # Change Weapons
            if list.parameters[2] != 0 and list.parameters[3] == variable
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Change Weapons)")
            end
          end
          if list.code == 128  # Change Armors
            if list.parameters[2] != 0 and list.parameters[3] == variable
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Change Armors)")
            end
          end
          if list.code == 201 # Transfer Player
            if list.parameters[0] != 0
              if list.parameters[1] == variable or list.parameters[2] == variable or
                list.parameters[3] == variable or list.parameters[4] == variable
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Transfer Player)")
              end
            end
          end
          if list.code == 202 # Transfer Event
            if list.parameters[1] == 1
              if list.parameters[2] == variable or list.parameters[3] == variable
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Transfer Event)")
              end
            end
          end
          if list.code == 231  # Show Picture
            if list.parameters[3] != 0
              if list.parameters[4] == variable or list.parameters[5] == variable
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Show Picture)")
              end
            end
          end
          if list.code == 232  # Move Picture
            if list.parameters[3] != 0
              if list.parameters[4] == variable or list.parameters[5] == variable
                data.push("Troop "+gametroop.to_s+" Page #{page+1} (Move Picture)")
              end
            end
          end
          if list.code == 311 or list.code == 331 # Change HP
            if list.parameters[2] != 0 and list.parameters[3] == variable
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Change HP)")
            end
          end
          if list.code == 312 or list.code == 332 # Change SP
            if list.parameters[2] != 0 and list.parameters[3] == variable
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Change SP)")
            end
          end
          if list.code == 315  # Change EXP
            if list.parameters[2] != 0 and list.parameters[3] == variable
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Change EXP)")
            end
          end
          if list.code == 316  # Change LV
            if list.parameters[2] != 0 and list.parameters[3] == variable
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Change LV)")
            end
          end
          if list.code == 317  # Change Parameters
            if list.parameters[3] != 0 and list.parameters[4] == variable
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Change Parameters)")
            end
          end
          if list.code == 338  # Deal Damage
            if list.parameters[2] != 0 and list.parameters[3] == variable
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Deal Damage)")
            end
          end
          if list.code == 209 # Move Route
            for param in 1...list.parameters.size
              parameter = list.parameters[param]
              for param2 in 0...parameter.list.size
                param3 = parameter.list[param2]
                if param3.code == 45 # Script
if param3.parameters[0].split.join.include?("$game_variables[#{variable}")
data.push("Troop "+gametroop.to_s+
" Page #{page+1} (Command Route Script)")
end
                end
              end
            end
          end
          if list.code == 355 # Script
            if list.parameters[0].split.join.include?("$game_variables[#{variable}")
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 101 # Message Box A
              if list.parameters[0].include?("v[#{variable}]")
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Message Box)")
              end
            end
            if list.code == 402 # Message Box B
              if list.parameters[1].include?("v[#{variable}]")
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Message Box)")
              end
            end
            if list.code == 103 # Input Number
              if list.parameters[0] == variable
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Input Number)")
              end
            end
            if list.code == 105 # Button Input Proc
              if list.parameters[0] == variable
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Button Input Proc)")
              end
            end
            if list.code == 111 # Conditional branch
              if list.paramaters[0] == 1
                if list.paramaters[1] == variable or list.paramaters[3] == variable
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Cond Branch)")
                end
              end
              if list.paramaters[0] == 12
                if list.parameters[1].split.join.include?("$game_variables[#{variable}")
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Cond Branch)")
                end
              end
            end
            if list.code == 122 # Control Variables
              jj = false
              for i in list.parameters[0] .. list.parameters[1]
                jj = true if i == variable
              end
              if list.parameters[3] == 1 and list.parameters[4] == variable
                jj = true
              end
              if jj == true
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Control Variables)")
              end
            end
            if list.code == 125  # Change Gold
              if list.parameters[1] != 0 and list.parameters[2] == variable
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Change Gold)")
              end
            end
            if list.code == 126  # Change Items
              if list.parameters[2] != 0 and list.parameters[3] == variable
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Change Items)")
              end
            end
            if list.code == 127  # Change Weapons
              if list.parameters[2] != 0 and list.parameters[3] == variable
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Change Weapons)")
              end
            end
            if list.code == 128  # Change Armors
              if list.parameters[2] != 0 and list.parameters[3] == variable
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Change Armors)")
              end
            end
            if list.code == 201 # Transfer Player
              if list.parameters[0] != 0
                if list.parameters[1] == variable or list.parameters[2] == variable or
list.parameters[3] == variable or list.parameters[4] == variable
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Transfer Player)")
                end
              end
            end
            if list.code == 202 # Transfer Event
              if list.parameters[1] == 1
                if list.parameters[2] == variable or list.parameters[3] == variable
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Transfer Event)")
                end
              end
            end
            if list.code == 231  # Show Picture
              if list.parameters[3] != 0
                if list.parameters[4] == variable or list.parameters[5] == variable
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Show Picture)")
                end
              end
            end
            if list.code == 232  # Move Picture
              if list.parameters[3] != 0
                if list.parameters[4] == variable or list.parameters[5] == variable
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Move Picture)")
                end
              end
            end
            if list.code == 311 or list.code == 331 # Change HP
              if list.parameters[2] != 0 and list.parameters[3] == variable
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Change HP)")
              end
            end
            if list.code == 312 or list.code == 332 # Change SP
              if list.parameters[2] != 0 and list.parameters[3] == variable
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Change SP)")
              end
            end
            if list.code == 315  # Change EXP
              if list.parameters[2] != 0 and list.parameters[3] == variable
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Change EXP)")
              end
            end
            if list.code == 316  # Change LV
              if list.parameters[2] != 0 and list.parameters[3] == variable
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Change LV)")
              end
            end
            if list.code == 317  # Change Parameters
              if list.parameters[3] != 0 and list.parameters[4] == variable
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Change Parameters)")
              end
            end
            if list.code == 338  # Deal Damage
              if list.parameters[2] != 0 and list.parameters[3] == variable
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1} (Deal Damage)")
              end
            end
            if list.code == 209 # Move Route
              for param in 1...list.parameters.size
                parameter = list.parameters[param]
                for param2 in 0...parameter.list.size
param3 = parameter.list[param2]
if param3.code == 45 # Script
if param3.parameters[0].split.join.include?("$game_variables[#{variable}")
data.push("Map "+gamemap.to_s+
" Event "+event.to_s+" Page #{page+1} (Command Route Script)")
end
end
                end
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355 # Script
                if list.parameters[0].split.join.include?("$game_variables[#{variable}")
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    # Event Routes
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.move_route.list.size
            list = map.events[event].pages[page].move_route.list[glist]
            if list.code == 45 # Script
              if list.parameters[0].split.join.include?("$game_variables[#{variable}")
              data.push("Map "+gamemap.to_s+" Event "+event.to_s+
              " Page #{page+1} (Event Page Route Script)")
              end
            end
          end
        end
      end
    end
    # Event Conditions
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          if pag.condition.variable_valid and pag.condition.variable_id == variable
            data.push("Map "+gamemap.to_s+" Event "+event.to_s+
            " Page #{page+1} (Page Condition)")
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
 
  #---------------------------------------------------------------------------
 
  def comev_call_where?(comev)
    data = []
    common = $data_common_events[comev]
    # Items
    for item in 1...$data_items.size
      it = $data_items[item]
      if it.common_event_id == comev
        data.push ("Item '"+it.name+"' (#{item})")
      end
    end
    # Skills
    for skill in 1...$data_skills.size
      it = $data_skills[skill]
      if it.common_event_id == comev
        data.push ("Skill '"+it.name+"' (#{skill})")
      end
    end
    # Common Event Trigger
    if common.trigger > 0
      data.push "Switch "+common.switch_id.to_s+" trigger =>"
      data.push switch_where?(common.switch_id)
    end
    # Data Common Events
    for common_event in 1...$data_common_events.size
      list = $data_common_events[common_event].list
      for i in 0...list.size
        if list[0].code == 117  # Call Common Event
          if list[0].parameters[0] == comev
            data.push("Common Ev "+common_event.to_s)
          end
        end
        if list[0].code == 355 # Script
          if list[0].parameters[0].split.join.include?("$data_common_events[#{comev}")
            data.push("Common Ev "+common_event.to_s+" (Script Call)")
          end
        end
      end
    end
    # Data Troop
    for gametroop in 1...$data_troops.size
      troop = $data_troops[gametroop]
      for page in 0...troop.pages.size
        pag = troop.pages[page]
        for glist in 0...pag.list.size
          list = troop.pages[page].list[glist]
          if list.code == 117  # Call Common Event
            if list.parameters[0] == comev
              data.push("Troop "+gametroop.to_s+" Page #{page+1}")
            end
          end
          if list.code == 355 # Script
            if list.parameters[0].split.join.include?("$data_common_events[#{comev}")
              data.push("Troop "+gametroop.to_s+" Page #{page+1} (Script Call)")
            end
          end
        end
      end
    end
    # Event Lists
    for gamemap in 1...$game_maps.size
      map = $game_maps[gamemap]
      next if map == nil
      for event in 1..map.events.size
        eve = map.events[event]
        next if eve == nil
        for page in 0...eve.pages.size
          pag = eve.pages[page]
          for glist in 0...pag.list.size
            list = map.events[event].pages[page].list[glist]
            if list.code == 117  # Call Common Event
              if list.parameters[0] == comev
                data.push("Map "+gamemap.to_s+" Event "+event.to_s+
                " Page #{page+1}")
              end
            end
            if not ($game_map.map_id == gamemap and self.map_interpreter.event_id == event)
              if list.code == 355 # Script
                if list.parameters[0].split.join.include?("$data_common_events[#{comev}")
data.push("Map "+gamemap.to_s+" Event "+event.to_s+
" Page #{page+1} (Script Call)")
                end
              end
            end
          end
        end
      end
    end
    data.push("Not found!") if data.size == 0
    return data
  end
end

class Interpreter
  def skill_where?(skill)
    $game_system.skill_where?(skill)
  end
  def item_where?(item)
    $game_system.item_where?(item)
  end
  def weapon_where?(item)
    $game_system.weapon_where?(item)
  end
  def armor_where?(item)
    $game_system.armor_where?(item)
  end
  def switch_where?(switch)
    $game_system.switch_where?(switch)
  end
  def variable_where?(variable)
    $game_system.variable_where?(variable)
  end
  def comev_call_where?(comev)
    $game_system.comev_call_where?(comev)
  end
end

end