Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

tiles w/ sound effects

I've been asking the same question. I think there was a script (before the big hack), that had a bunch of things, include sound per terrain, and it also had ice, lava, and swamp water tile effects.
 
I know exactly how to do this. I'll be back in a few mins with screenshots to explain it better. Does not require a script
EDIT:
Ok. Here we go. And yea I'm aware I spelled terrain wrong in the screenshots. No big deal though.
http://i203.photobucket.com/albums/aa25 ... tled-1.png[/IMG]

First, you need to make a new variable. Call it terrian tag or something like that.



http://i203.photobucket.com/albums/aa25 ... tled-2.png[/IMG]

You should be at the control variables thing. Make sure it is on Set, and on character. Select player, and terrian tag.



http://i203.photobucket.com/albums/aa25 ... tled-4.png[/IMG]

This event should be parallel process

So set the variable, and make a conditional branch with the terrian tag variable equaling the terrian tag number. So say you had a tile with a terrian tag of 1, then you have the variable equal to 1. Or if your desired tile had the terrain tag of 3, then the variable should equal 3.
Then just put the SE you want to play and put in some wait frames so it doesnt repeat so fast.
 
Try this:

Code:
class Game_Map
  Terrain_Tag_Sound_Effects = {}
  # Don't Edit these lines
  Terrain_Tag_Sound_Effects.default = {}
  Terrain_Tag_Sound_Effects.default.default = nil
  Terrain_Tag_Sound_Effects.values.each {|x| x.default = nil}
  def terrain_tag_sound_effect(terrain_tag)
    return Terrain_Tag_Sound_Effects[@map_id][terrain_tag]
  end
end

class Game_Player
  alias_method :seph_terraintileses_gmplyr_is, :increase_steps
  def increase_steps
    seph_terraintileses_gmplyr_is
    if $game_map.terrain_tag_sound_effect(terrain_tag) != nil
      n = $game_map.terrain_tag_sound_effect(terrain_tag)
      $game_system.se_play(AudioFile.new(n))
    end
  end
end

Add lines below Terrain_Tag_Sound_Effects = {} like so:

Code:
Terrain_Tag_Sound_Effects[map_id] = {}
Terrain_Tag_Sound_Effects[map_id][terrain_tag] = 'SE Filename'

Start by adding the first line changing the map_id with the map id you want to change the terrain for.
Then add lines for each terrain you would like for your map with the second line.

For example:

Map 3: Terrain 3 - SE 'Filename 1', Terrain 5 - SE 'Filename 2'
Code:
Terrain_Tag_Sound_Effects[3] = {}
Terrain_Tag_Sound_Effects[3][3] = 'Filename 1'
Terrain_Tag_Sound_Effects[3][5] = 'Filename 2'

Just let me know if that doesn't work or if you need any help.
 

Aran

Member

Code:
class Game_Map
  Terrain_Tag_Sound_Effects = {}
  Terrain_Tag_Sound_Effects[@map_id] = {}
  Terrain_Tag_Sound_Effects[@map_id][1] = '001-System01'
  # Don't Edit these lines
  Terrain_Tag_Sound_Effects.default = {}
  Terrain_Tag_Sound_Effects.default.default = nil
  Terrain_Tag_Sound_Effects.values.each {|x| x.default = nil}
  def terrain_tag_sound_effect(terrain_tag)
    return Terrain_Tag_Sound_Effects[@map_id][terrain_tag]
  end
end

class Game_Player
  alias_method :seph_terraintileses_gmplyr_is, :increase_steps
  def increase_steps
    seph_terraintileses_gmplyr_is
    if $game_map.terrain_tag_sound_effect(terrain_tag) != nil
      n = $game_map.terrain_tag_sound_effect(terrain_tag)
      $game_system.se_play(AudioFile.new(n))
    end
  end
end

I tried it and I didn't get any errors but it makes no sound.
 
SephirothSpawn;315787 said:
Try this:

Code:
class Game_Map
  Terrain_Tag_Sound_Effects = {}
  # Don't Edit these lines
  Terrain_Tag_Sound_Effects.default = {}
  Terrain_Tag_Sound_Effects.default.default = nil
  Terrain_Tag_Sound_Effects.values.each {|x| x.default = nil}
  def terrain_tag_sound_effect(terrain_tag)
    return Terrain_Tag_Sound_Effects[@map_id][terrain_tag]
  end
end

class Game_Player
  alias_method :seph_terraintileses_gmplyr_is, :increase_steps
  def increase_steps
    seph_terraintileses_gmplyr_is
    if $game_map.terrain_tag_sound_effect(terrain_tag) != nil
      n = $game_map.terrain_tag_sound_effect(terrain_tag)
      $game_system.se_play(AudioFile.new(n))
    end
  end
end

Add lines below Terrain_Tag_Sound_Effects = {} like so:

Code:
Terrain_Tag_Sound_Effects[map_id] = {}
Terrain_Tag_Sound_Effects[map_id][terrain_tag] = 'SE Filename'

Start by adding the first line changing the map_id with the map id you want to change the terrain for.
Then add lines for each terrain you would like for your map with the second line.

For example:

Map 3: Terrain 3 - SE 'Filename 1', Terrain 5 - SE 'Filename 2'
Code:
Terrain_Tag_Sound_Effects[3] = {}
Terrain_Tag_Sound_Effects[3][3] = 'Filename 1'
Terrain_Tag_Sound_Effects[3][5] = 'Filename 2'

Just let me know if that doesn't work or if you need any help.


This works great and it was just what I needed... Is there a way to add Pitch to this code aswell though?

If you get a second, to look at this, that would be awsome..!

Thanks again,

Fenwick
 
Sure.

Code:
class Game_Map
  Terrain_Tag_Sound_Effects = {}
  # Don't Edit these lines
  Terrain_Tag_Sound_Effects.default = {}
  Terrain_Tag_Sound_Effects.default.default = nil
  Terrain_Tag_Sound_Effects.values.each {|x| x.default = nil}
  def terrain_tag_sound_effect(terrain_tag)
    return Terrain_Tag_Sound_Effects[@map_id][terrain_tag]
  end
end

class Game_Player
  alias_method :seph_terraintileses_gmplyr_is, :increase_steps
  def increase_steps
    seph_terraintileses_gmplyr_is
    if $game_map.terrain_tag_sound_effect(terrain_tag) != nil
      n = $game_map.terrain_tag_sound_effect(terrain_tag)
      $game_system.se_play(AudioFile.new(*n))
    end
  end
end

Ok. So I only edited one line. Now, you can edit your constant like so:

Code:
Terrain_Tag_Sound_Effects[map_id][terrain_tag] = 'SE Filename'
# or
Terrain_Tag_Sound_Effects[map_id][terrain_tag] = 'SE Filename', volume
# or
Terrain_Tag_Sound_Effects[map_id][terrain_tag] = 'SE Filename', volume, pitch

Let me know if you have any trouble.
 
SephirothSpawn;317732 said:
Sure.

Code:
class Game_Map
  Terrain_Tag_Sound_Effects = {}
  # Don't Edit these lines
  Terrain_Tag_Sound_Effects.default = {}
  Terrain_Tag_Sound_Effects.default.default = nil
  Terrain_Tag_Sound_Effects.values.each {|x| x.default = nil}
  def terrain_tag_sound_effect(terrain_tag)
    return Terrain_Tag_Sound_Effects[@map_id][terrain_tag]
  end
end

class Game_Player
  alias_method :seph_terraintileses_gmplyr_is, :increase_steps
  def increase_steps
    seph_terraintileses_gmplyr_is
    if $game_map.terrain_tag_sound_effect(terrain_tag) != nil
      n = $game_map.terrain_tag_sound_effect(terrain_tag)
      $game_system.se_play(AudioFile.new(*n))
    end
  end
end

Ok. So I only edited one line. Now, you can edit your constant like so:

Code:
Terrain_Tag_Sound_Effects[map_id][terrain_tag] = 'SE Filename'
# or
Terrain_Tag_Sound_Effects[map_id][terrain_tag] = 'SE Filename', volume
# or
Terrain_Tag_Sound_Effects[map_id][terrain_tag] = 'SE Filename', volume, pitch

Let me know if you have any trouble.


Getting an Error:

"Uninitialized constant Game_Player::AudioFile"

What would I need to do to Initialize this or fix it?

Thanks again,
Fenwick

Edit:

Never mind, I fixed it... What I had to do, is change the one line to read this (without the quotes of course):

From: "$game_system.se_play(AudioFile.new(*n))"

To This: "$game_system.se_play(RPG::AudioFile.new(*n))"
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top