Stepsound script

Started by Sase, April 05, 2008, 12:19:23 pm

Previous topic - Next topic

Sase

Well...

I don't remember if one exists already, but this should do the same as a terrain setting back in the 2k3's.

You can choose sound effects for each terrain tags and/or tilesets.

Example
when 0 then "Step-Grass"
when 1 then "Step-Wood"
when 2 then "Step-Long Grass"
when 3 then "Step-Water"
when 4 then "Step-Carpet"
when 5 then "Step-Rocks"
when 6 then "Step-Wet Land"

OR
[1 => 'Step-Grass', 2 => 'Step-Wood'.......]


Thanks :)

elmangakac

Here: I Dont know who made it...

PD: Qhen character Run, the sound keep the same speed T_T



##=============================================================================
##=============================================================================
##
##                       PR Step Sound
##                      v.1.0 21/01/2010
##
##=============================================================================
##=============================================================================
##  Este script faz que quando o player se mova sera executado
##  sons, e estes sons pode variar dependendo do terreno
##  com isso sera possivel realizar sons de passos para cada
##  tipo de terreno.
##
##  obs(As configurações deste script esta logo abaixo em
##      PRStepSoundConfig)
##
##  Bom proveito!!
##=============================================================================
##=============================================================================

#==============================================================================
# module PRStepSoundConfig
#------------------------------------------------------------------------------
# Configuração do PR Step Sound
#==============================================================================

module PRStepSoundConfig
 
 # Configuração do som de cada terreno.
 # Segue-se um exemplo:
 #
 # SOUDS_TERRAIN[a] = b
 #
 #  a = ID do terreno
 #  b = Som usado, obs(use a classe RPG::AudioFile)
 #
 # Para quem não sabe usar esta classe:
 #
 # RPG::AudioFile.new(a, b, c)
 #
 #  a = Nome do arquivo do som, que fica na pasta Audio/SE
 #  b = Volume
 #  c = Potencia
 
 SOUDS_TERRAIN = []
 
 SOUDS_TERRAIN[0] = RPG::AudioFile.new("042-Knock03.ogg", 70, 100)
 SOUDS_TERRAIN[1] = RPG::AudioFile.new("041-Knock02.ogg", 80, 100)
 SOUDS_TERRAIN[2] = RPG::AudioFile.new("118-Fire02.ogg", 80, 140)
 SOUDS_TERRAIN[3] = RPG::AudioFile.new("128-Water03.ogg", 90, 150)
 SOUDS_TERRAIN[4] = RPG::AudioFile.new("129-Earth01.ogg", 90, 120)
 SOUDS_TERRAIN[5] = RPG::AudioFile.new("", 100, 100)
 SOUDS_TERRAIN[6] = RPG::AudioFile.new("", 100, 100)
 SOUDS_TERRAIN[7] = RPG::AudioFile.new("", 100, 100)
 
 # Frame rate do efeito de som
 
 FRAME_RATE  = 5
 
 # Se este efeito sera executado nos eventos
 
 ALL_PLAYERS = true
 
 # Não modificar
 
 def self.terrain_sound(pt)
   return SOUDS_TERRAIN[pt]
 end
end

#==============================================================================
# Game_Player
#------------------------------------------------------------------------------
# Esta classe engloba o Jogador. Suas funções incluem a inicialização das
# determinantes dos eventos e o scroll do mapa. Se refere a "$game_player" para
# as instâncias desta classe.
#==============================================================================

class Game_Player
 
 alias update_step_sound update
 
 #--------------------------------------------------------------------------
 # - Inicialização dos Objetos
 #--------------------------------------------------------------------------
 
 def initialize
   super
   @frame = PRStepSoundConfig::FRAME_RATE
 end
 
 #--------------------------------------------------------------------------
 # - Atualização de um Frame
 #--------------------------------------------------------------------------
 
 def update
   update_step_sound
   update_pr_step_sound
 end
 
 #--------------------------------------------------------------------------
 # - Se o player esta se movimentando ou precionando as teclas
 #   de direção.
 #--------------------------------------------------------------------------
 
 def move?
   unless $game_system.map_interpreter.running? or
          @move_route_forcing or $game_temp.message_window_showing
     case Input.dir4
     when 2, 4, 6, 8
       return true
     end

   end
   if moving?
     return true
   end
   return false
 end
 
 #--------------------------------------------------------------------------
 # - Atualização do efeito de som no passo
 #--------------------------------------------------------------------------
 
 def update_pr_step_sound
   if move?
     @frame += 1
     if @frame >= PRStepSoundConfig::FRAME_RATE
       @frame = 0
       sound = PRStepSoundConfig.terrain_sound(terrain_tag)
       $game_system.se_play(sound)
     end
   else
     @frame = PRStepSoundConfig::FRAME_RATE
   end
 end
end

#==============================================================================
# Game_Event
#------------------------------------------------------------------------------
# Esta é a classe que engloba os eventos. O que inclui as funções nas páginas de
# evento alterando estas através das Condições de Evento, e faz funcionar os
# Processos Paralelos. Esta classe está inserida na classe Game_Map.
#==============================================================================

class Game_Event
 
 alias initialize_step_sound initialize
 alias update_step_sound update
 
 #--------------------------------------------------------------------------
 # - Inicialização dos Objetos
 #     map_id : ID do mapa
 #     event  : evento (RPG::Event)
 #--------------------------------------------------------------------------
 
 def initialize(map_id, event)
   initialize_step_sound(map_id, event)
   @frame = PRStepSoundConfig::FRAME_RATE
 end
 
 #--------------------------------------------------------------------------
 # - Atualização de um Frame
 #--------------------------------------------------------------------------
 
 def update
   update_step_sound
   if PRStepSoundConfig::ALL_PLAYERS
     update_pr_step_sound
   end
 end
 
 #--------------------------------------------------------------------------
 # - Atualização do efeito de som no passo
 #--------------------------------------------------------------------------
 
 def update_pr_step_sound
   if moving?
     @frame += 1
     if @frame >= PRStepSoundConfig::FRAME_RATE
       @frame = 0
       sound = PRStepSoundConfig.terrain_sound(terrain_tag)
       $game_system.se_play(sound)
     end
   else
     @frame = PRStepSoundConfig::FRAME_RATE
   end
 end
end


G_G

I made one awhile ago strictly for Branden/Tugger's game. Anyways if I can find it (or if I remake it) I'll post it up here. It was a lot better. First you could define sounds for terrains by default. Then you could set terrains for each tileset. If sound didn't exist for tileset, then it checked default terrains, if that wasn't set then it wouldn't play a sound.

elmangakac


Cid

I've been thinking about using something like this for a while now, so I'd be interested in your superior script as well, g_g.

The one posted above was a nice teaser, but it seems quite restrictive, and also has compatibility issues with Tons.

Spaceman McConaughey

I have the script. Maybe I can post it, maybe I cannot. :naughty:

G_G

Its completely up to tugger, I forgot that I had made it specifically for his game.

Spaceman McConaughey

Here:
module TSS
 # In Frames Recommended 5-10
 Wait = 5
 Terrains = []
 # Enter in sounds for each terrain tag
 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'
 Terrains[7] = 'fs_leaf_hard1'
 # Change terrain sound anytime using
 # $game_system.change_sound(terrain tag, sound file)
end
class Game_System
 attr_accessor :terrain_sounds
 alias gg_init_terrain_sounds_lat_sys initialize
 def initialize
   @terrain_sounds = TSS::Terrains
   gg_init_terrain_sounds_lat_sys
 end
 def change_sound(terrain, sound)
   @terrain_sounds[terrain] = sound
 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 = TSS::Terrains[$game_player.terrain_tag]
     if terrain != ''
       if @tsswait == 0
         Audio.se_play('Audio/SE/' + terrain, 100, 0)
         @tsswait = TSS::Wait
       end
     end
   end
   gg_update_terrain_sounds_lat
 end
end


But you better give G_G credit. And credit me for giving it to you guys, therefore making it a script no longer unique to my game(if that is fine with G_G, you better >8U).

And level me up, because I need them to live. :V:

G_G

Updated version, allows tileset support, posting in database now.

#===============================================================================
# Terrain Step Sound
# Version 1.0
# 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
#
# 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'
  Terrains[7] = 'fs_leaf_hard1'
  #===========================================================================
  # 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"
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
          Audio.se_play('Audio/SE/' + terrain, 100, 0)
          @tsswait = TSS::Wait
        end
      end
    end
    gg_update_terrain_sounds_lat
  end
end