[XP] Terrain Step Sound

Started by G_G, April 26, 2011, 08:42:09 pm

Previous topic - Next topic

G_G

They're not included. It was just an example of how to configure the script. You'll have to provide your own sound effects.

toni112007

ow so i can use my sounds and change name in script of these?

and one more thing sorry for offtop but i need to know how to make light effect
because im making dark horror game and i need light effect for lantern

G_G

Yes, you can use your own sounds. As for the light effect, you're going to have to post that in the Tutorials Request board.

toni112007

Hi again how can i set more sounds for one terrain? because with only one sound for fs it sounds like typewriter.
is there any way to make more sounds for one terrain.etc like i have 3 sounds for one terrain and sound change on each tile/footstep(more realistic) you know what i mean?

G_G

It's not possible with this version of the script, but I could add that possibility in there. I have to update the script anyways to fix the issue Vexus was having.

toni112007


Blizzard

Quick idea: You could use an array of strings (instead of just a string) as config. Then you simply pick a string randomly for the sound effect. This can be implemented in, like, 5 minutes.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

That's actually what I had planned. xD I have a job now so I don't just sit at my computer 24/7 like usual. I'll get to it this Saturday, I have it off.


ForeverZer0

Quote from: Blizzard on June 28, 2012, 04:47:22 pm
Quick idea: You could use an array of strings (instead of just a string) as config. Then you simply pick a string randomly for the sound effect. This can be implemented in, like, 5 minutes.


Thats how I did the "Ambient SFX" script I made a long time ago.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

toni112007

Could you make script that includes for when left leg moves plays one sound and when right leg moves plays other sound.that way it would be good footstep sound.thx

G_G

Updated to 1.2.

Play rate is now checked through Game_Player's "update_move" method so sounds should always work.
Every terrain must now be an array. Within the array, you can define sounds as a single "string" or as an array with volume and pitch options.
Terrain[0] = ["sound1", "sound2", ["sound3", 100, 0]]

If you only want one sound per terrain, you have the option to only put one sound in. If you don't want any sounds for the terrain, leave it empty.

You can also change the sound rate in game by using a script call.
$game_map.rate = X
X = value (the lower, the more frequent the sounds, 5-10 works weel)


Enjoy!

Vexus

Thanks for updating the script but now I get an error on Blizz Abs Part 2 on line 2219: NoMethodError occurred.

undefined method 'refresh' for #<Game_Player:0x8df1060>

Placing script over Blizz Abs scripts removes the error but no sound plays.
Current Project/s:

G_G

Go to line 99 and change this
class Game_Player < Game_Character

to
class Game_Player < Map_Actor

Vexus

Ok that fixed the first error now I'm getting another when I make a step on a terrain which has a sound.

line 115: TypeError occurred.

cannot convert fixnum into string.

Current Project/s:

G_G

Can you paste your configuration please?

Vexus

Sure:

#===============================================================================
# Terrain Step Sound
# Version 1.2
# 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
# Specify an array of sounds for each terrain, allowing random sounds for each step
#
# Instructions:
# Setup the config below, its pretty self explanatory, more instructions
# with config.
#
# You can now change the sound rate in game using a script call.
# $game_map.rate = X
# X = sound rate (the lower the value, the more frequent the sounds)
#
# 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 = 18
  # 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.
  # Each terrain must now be an array. This allows you to define multiple
  # sound effects for each terrain.
  #===========================================================================
  #Terrains[0] = ['001-System01', '002-System02', '003-System03']
  Terrains[1] = 'Wood'
  Terrains[2] = 'Floor'
  Terrains[3] = ''
  Terrains[4] = ''
  Terrains[5] = ''
  Terrains[6] = ''
  #===========================================================================
  # 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.
  # You can also define multiple sound effects with pitch and volume.
  #===========================================================================
  #Terrains[7] = [["sound", 80, 10], "sound2", ["sound3", 50, 0]]
  Terrains[2] = ["Floor", 70, 100]
  #===========================================================================
  # 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", "sound file2", etc...]
  # 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] = "Floor"
  Tilesets[1][1] = ["Floor", 50, 100]
  #
  Tilesets[54] = []
  #Tilesets[54][1] = "Metal Step"
  Tilesets[54][1] = ["Metal Step", 80, 100]
end
class Game_Map
 
  attr_accessor :rate
 
  alias gg_init_terrain_sounds_map_lat initialize
  def initialize
    @rate = TSS::Wait
    return gg_init_terrain_sounds_map_lat
  end
 
  def terrain_sound
    if TSS::Tilesets[@map.tileset_id] != nil
      sounds = TSS::Tilesets[@map.tileset_id][$game_player.terrain_tag]
    else
      sounds = TSS::Terrains[$game_player.terrain_tag]
    end
    return nil if sounds == nil || !sounds.is_a?(Array) || sounds.size < 1
    sound = sounds[rand(sounds.size)]
    if sound.is_a?(Array)
      return [sound[0], sound[1], sound[2]]
    else
      return [sound, 100, 0]
    end
  end
 
end

class Game_Player < Map_Actor
 
  def update_move
    @timer = $game_map.rate if @timer == nil
    @timer -= 1
    if @timer < 1
      terrain = $game_map.terrain_sound
      if terrain != nil
        vol = terrain[1]
        pit = terrain[2]
        son = terrain[0]
        Audio.se_play('Audio/SE/' + son, vol, pit)
      end
      @timer = $game_map.rate
    end
    super
  end
 
end
Current Project/s:

G_G

This is your issue. Each sound or sound array, needs to be in an array itself.
Tilesets[54][1] = ["Metal Step", 80, 100]

To
Tilesets[54][1] = [["Metal Step", 80, 100]]


Along with these options as well.
Terrains[1] = 'Wood'
  Terrains[2] = 'Floor'
  Terrains[3] = ''
  Terrains[4] = ''
  Terrains[5] = ''
  Terrains[6] = ''
Terrains[2] = ["Floor", 70, 100]

Tilesets[1][0] = "Floor"
  Tilesets[1][1] = ["Floor", 50, 100]


All need to be wrapped in  [ ]

Vexus

July 16, 2012, 08:59:18 am #38 Last Edit: July 16, 2012, 09:10:22 am by Vexus
Ok that fixed it thanks :)

Now I'll try the feature you implemented for me to see if it's how I wanted it. (I'll update post if it gives me problems or whatever.)

[Edit]

Works perfectly, your awesome :)

+1
Current Project/s:

Vexus

August 06, 2012, 02:03:36 pm #39 Last Edit: August 06, 2012, 04:04:29 pm by Vexus
Anyway I can disable/enable this script?

In the beginning of my game your bare footed and I don't want to have the stepping sounds I have produced by shoes.

Thanks
Current Project/s: