#===============================================================================
# Terrain Step Sound
# Version 1.1
# Author game_guy
#-------------------------------------------------------------------------------
# Intro:
# Create nice aesthetics with terrain noise. As you walk across grass or sand,
# let it play a beautiful noise to add to the atmosphere and realism of the
# game.
#
# Features:
# Specific Sound for Each Terrain
# Specific Sounds for Each Tileset
# Specify Volume and Pitch
#
# Instructions:
# Setup the config below, its pretty self explanatory, more instructions
# with config.
#
# Credits:
# game_guy ~ For creating it
# Tuggernuts ~ For requesting it a long time ago
# Sase ~ For also requeseting it
#===============================================================================
module TSS
  # In Frames Recommended 5-10
  Wait = 5
  # Ignore the next 2 lines
  Terrains = []
  Tilesets = []
  #===========================================================================
  # Enter in sounds for each terrain tag
  # Goes from 0-8. Set as nil to disable that terrain or delete the line.
  #===========================================================================
  Terrains[0] = '001-System01'
  Terrains[1] = 'fs_wood_hard1'
  Terrains[2] = 'fs_grass03'
  Terrains[3] = 'fs_stone_hoof2'
  Terrains[4] = 'as_na_grassmove2'
  Terrains[5] = 'fs_water_hard1'
  Terrains[6] = 'fs_dirt_hard1'
  #===========================================================================
  # If you would like to specifiy a volume and pitch, simply set the
  # terrain as an array.
  # Terrains[7] = ["sound", volume, pitch]
  # Just set it as a string if you would like the volume to be at 100 and
  # pitch at 0.
  # This also applies for tilesets below.
  #===========================================================================
  Terrains[7] = ["sound", 80, 10]
  #===========================================================================
  # With tilesets, you can set specific sounds for each tileset so you don't
  # have the same sounds. Add a new line and put
  # Tilesets[tileset id] = []
  # Then for each terrain put
  # Tilesets[tileset id][terrain id] = "sound file"
  # If a sound doesn't exist for a tileset, it will play a default sound,
  # if a default doesn't exist, no sound at all.
  #===========================================================================
  Tilesets[1] = []
  Tilesets[1][0] = "Sound"
  Tilesets[1][1] = ["sound", 75, 50]
end
class Game_Map
  def terrain_sound
    if TSS::Tilesets[@map.tileset_id] != nil
      return TSS::Tilesets[@map.tileset_id][$game_player.terrain_tag]
    else
      return TSS::Terrains[$game_player.terrain_tag]
    end
    return nil
  end
end
class Scene_Map
  alias gg_init_terrain_sounds_lat initialize
  def initialize
    @tsswait = TSS::Wait
    gg_init_terrain_sounds_lat
  end
  alias gg_update_terrain_sounds_lat update
  def update
    if $game_player.moving?
      @tsswait -= 1
      terrain = $game_map.terrain_sound
      if terrain != nil
        if @tsswait == 0
          vol = terrain.is_a?(Array) ? terrain[1] : 100
          pit = terrain.is_a?(Array) ? terrain[2] : 0
          son = terrain.is_a?(Array) ? terrain[0] : terrain
          Audio.se_play('Audio/SE/' + son, vol, pit)
          @tsswait = TSS::Wait
        end
      end
    end
    gg_update_terrain_sounds_lat
  end
end