About terrain tags

Pixel_Crow

Pixel Crow
Member
Joined
Jun 21, 2019
Messages
2
Reaction score
0
First Language
Tagalog
Primarily Uses
RMXP
Hi!

Lately I've been checking out the tilesets in RMXP and found terrain tags. I'm not quite sure how they're used in general, since there isn't much about terrain tags on the manual or over the internet. Though I think that they could be used for footstep sounds or trigger events in certain surfaces, but my resources have been pretty vague about them. Overall I'd like to know what they're being used for.

(And, in case if it does do different footstep sounds for different tiles, can someone teach me how to do that? I'd like to use that for a game I'm making:kaocry:)
 

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
Terrain tags originated in earlier RPGMaker games, those being RPGMaker 2000 and RPGMaker 2003. In fact, those two engines had Terrain databases where you actually three things: (1) The battlebackground if combat starts when on that tile, (2) The vehicle that can travel along that tile, and (3) the way some tiles draw OVER the player for thick brush or wading-in-water effects. And at the same time, you could go BEYOND the limit of 8 terrain tags because you could increase the number in your database........

pic10.jpg

That was the past.... Leave it to developers to take THINGS OUT of one engine to PUT THEM BACK in another iteration. No engine has ALL the features desired, eh?

Well, terrain tags do exist in RPGMaker XP and VXAce I hear. Definitely not VX (see above about not every engine... :p ). However, there is no database tied to terrain tags as before. And the 'thick brush' option was put into the tileset database. So what good are terrain tags?????

We scripters found that we could access the terrain tags to make use of them. In scripts like 'Mode7', terrain tags can be used to affect what 2nd or 3rd layer graphics gets drawn upright in compared to the rest of the map. In vehicle scripts, they can return the option where vehicles may be able to cross special tiles (like a boat in the water). In other scripts, terrain tags can return 'battlebacks per tags' options. It just depends on what feature(s) you want and how you use the scripts.

Code:
#==============================================================================
# ** Hear_Steps
#------------------------------------------------------------------------------
# A DerVV edit of the original
#------------------------------------------------------------------------------
#  Original version by
#  by arevulopapo
#  9.11.2006
#------------------------------------------------------------------------------
# To make an event deliver audio, you must force their 'hear step' flag to true
# or false by these commands:
#
# $game_player.hear_steps = true / false
#
# $game_map.events[ID].hear_steps = true / false
#
#==============================================================================

module TagSound
 
  #--------------------------------------------------------------------------
  TAG = {}   # DO NOT TOUCH
  #--------------------------------------------------------------------------
 
  # TAG       SOUND EFFECT
  # =====     ============
  TAG[0]  =   ""
  TAG[1]  =   "001-System01"
 
 
end


#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :hear_steps               # step audible flag
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------  
  alias arevulopapo_hear_steps_initialize initialize
  alias arevulopapo_hear_steps_update update
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Original call
    arevulopapo_hear_steps_initialize
    @hear_steps = false
  end
  #def hear_steps=(value)
  #  @hear_steps = value
  #end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Original call
    arevulopapo_hear_steps_update
    # Perform Sound
    play_step
  end
  #--------------------------------------------------------------------------
  # * Frame Update : Playing Sound Effect
  #--------------------------------------------------------------------------
  def play_step
    # Ensure moving and only in valid map coords
    return unless self.moving?
    return unless self.hear_steps == true
    return unless (Graphics.frame_count + 2 * self.id) % (18 - @move_speed) == 0
    return unless self.screen_x > 0
    return unless self.screen_x < 640
    return unless self.screen_y > 0
    return unless self.screen_y < 480
    # Get current tag for the character
    tag = $game_map.terrain_tag(self.x, self.y)
    # Set Volume compared to player
    volume = 100 - 5 *
      Math.sqrt((self.x - $game_player.x)*(self.x - $game_player.x) +
      (self.y - $game_player.y)*(self.y - $game_player.y))
    # Default sound
    step_sound = nil
    # Set sound from config based on tag
    unless TagSound::TAG[tag].nil?
      unless TagSound::TAG[tag] == ""
        step_sound = "Audio/SE/" + TagSound::TAG[tag]
      end
    end
    # Play Audio
    Audio.se_play(step_sound, volume, 100) unless step_sound.nil?
  end
end
This is a quickie butchering of his 2006 code to enable more than just 1 SE. It was set up NOT to use different SEs per tag.
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
281
Reaction score
106
First Language
English
Primarily Uses
RMXP
Here's another step sound script. It's a modified version of https://forum.chaos-project.com/index.php/topic,9460.0.html
Code:
#===============================================================================
# Terrain Step Sound + Events
# Version 1.3
# Author game_guy
# New Features by Zexion
#-------------------------------------------------------------------------------
# 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
# Specify events that can play these sounds.
#
# 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)
#
# Add the Name_Tag ("steps" by default) to the event page name (without quotes)
# to add dynamic footstep sounds to that event.
#
# Credits:
# game_guy ~ For creating it
# Tuggernuts ~ For requesting it a long time ago
# Sase ~ For also requeseting it
# Zex - For the Event & move_speed edit
# kk20 - for listening to zex's complaints
#===============================================================================
module TSS
  # Adjust this to your liking
  Wait = 20
  Name_Tag = "steps"
  # Ignore this
  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] = []
  Terrains[1] = [["FS - 03 - Wood", 40, 0],["FS - 04 - Wood", 40, 0]]
  Terrains[2] = ['FS - 05 - Metal']
  Terrains[3] = ['FS - 07 - Hollow Metal']
  Terrains[4] = [["FS - 09 - Concrete", 40, 0]]
  Terrains[5] = [["FS - 11 - Dirt", 40, 0],["FS - 11 - Dirt", 40, 0]]
  Terrains[6] = [["FS - 13 - Grass", 40, 0], ["FS - 14 - Grass", 40, 0]]
  #===========================================================================
  # 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] = [["FS - 01 - Water", 50, 0],["FS - 02 - Water", 50, 0]]
  #===========================================================================
  # 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.
  #===========================================================================
end
#-------------------------------------------------------------------------------
# Game_Map
#-------------------------------------------------------------------------------
class Game_Map
  attr_accessor :map          # make public
end
#-------------------------------------------------------------------------------
# Game_Character
#-------------------------------------------------------------------------------
# Adds Gameus's terrain_sound method to game_character.
#-------------------------------------------------------------------------------
class Game_Character
  attr_accessor :move_speed   # make public
  #-----------------------------------------------------------------------------
  # Initialize ss_index
  #-----------------------------------------------------------------------------
  alias g_c_sfe_init initialize
  def initialize
   g_c_sfe_init
   @ss_index = 0
   @timer = 0
   @tss_speed = @move_speed
   set_tss_offset
  end
  #-----------------------------------------------------------------------------
  # Updates the timer when needed
  #-----------------------------------------------------------------------------
  alias g_c_sfe_update update
  def update
   g_c_sfe_update
   @timer -= 1 if @timer > 0
   if @tss_speed != self.move_speed
     set_tss_offset
   end
  end
  #-----------------------------------------------------------------------------
  # Sets the sound offset
  #-----------------------------------------------------------------------------
  def set_tss_offset    
   # Timer offset by movespeed
   case self.move_speed
   when 0..2
     @tss_offset = TSS::Wait + self.move_speed
   when 3
     @tss_offset = TSS::Wait
   else
     @tss_offset = TSS::Wait - self.move_speed * 2
   end
  end
  #-----------------------------------------------------------------------------
  # Returns the array to be used later
  #-----------------------------------------------------------------------------
  def terrain_sound
   if TSS::Tilesets[$game_map.map.tileset_id] != nil
     sounds = TSS::Tilesets[$game_map.map.tileset_id][self.terrain_tag]
   else
     sounds = TSS::Terrains[self.terrain_tag]
   end
   return nil if sounds == nil || !sounds.is_a?(Array) || sounds.size < 1
   index_max = sounds.size - 1
   @ss_index = (@ss_index < index_max) ? (@ss_index + 1) : 0
   sound = sounds[@ss_index]
   if sound.is_a?(Array)
     return [sound[0], sound[1], sound[2]]
   else
     return [sound, 100, 0]
   end
  end
end
#-------------------------------------------------------------------------------
# Game_Player
#-------------------------------------------------------------------------------
Tss_Parent = $BlizzABS ? (Map_Actor) : (Game_Character)
class Game_Player < Tss_Parent
  #-----------------------------------------------------------------------------
  # Adds step sounds to the player
  #-----------------------------------------------------------------------------
  def update_move
   # Make sure this is the player
   if self != $game_event && @timer == 0
     # Play the sound effect
     terrain = self.terrain_sound
     if terrain != nil
       vol = terrain[1]
       pit = terrain[2]
       son = terrain[0]
       Audio.se_play('Audio/SE/' + son, vol, pit)
     end
     # Set timer
     @timer = @tss_offset
   end
   # Call original code
   super
  end
end
#-------------------------------------------------------------------------------
# Game_Event
#-------------------------------------------------------------------------------
class Game_Event < Game_Character
  #-----------------------------------------------------------------------------
  # Set the variable for checking if the event should make a sound
  #-----------------------------------------------------------------------------
  alias g_e_sfe_init initialize
  def initialize(map_id, event)
   g_e_sfe_init(map_id, event)
   @tss = self.name.include?(TSS::Name_Tag) ? true : false
  end
  #--------------------------------------------------------------------------
  # * Returns the event's name
  #--------------------------------------------------------------------------
  def name
    return @event.name
  end
  #-----------------------------------------------------------------------------
  # Returns the distance of this event from the player
  #-----------------------------------------------------------------------------
  def range?
   if $BlizzABS && BlizzABS::Config::PIXEL_MOVEMENT_RATE == 1
     player_x = $game_player.x / 2 # Adjusted for 1.0 pixel movement rate
     player_y = $game_player.y / 2 # Adjusted for 1.0 pixel movement rate
   else
     player_x = $game_player.x
     player_y = $game_player.y
   end
   radius = (Math.hypot((self.x - player_x), (self.y - player_y))).abs.floor
   return (radius)
  end
  #-----------------------------------------------------------------------------
  # Adds step sounds to the event with dynamic volume
  #-----------------------------------------------------------------------------
  def update_move
   # Check if the event should play a sound
   if @tss
     # Make sure it's an event
     if self != $game_player
       # Check if the event is anywhere near the player
       if range? <= 6 && @timer == 0
         # The amount to subtract from the normal volume
         sub_vol = 4 * range?
         # Play the sound effect
         terrain = self.terrain_sound
           if terrain != nil
             vol = terrain[1]
             pit = terrain[2]
             son = terrain[0]
             # Dynamic sound edit
             vol = vol - sub_vol
             vol = 0 if vol < 0
             Audio.se_play('Audio/SE/' + son, vol, pit)
           end
           # Set timer
           @timer = @tss_offset
         end
       end
     end
     # Call original code
     super
   end
end
 

Pixel_Crow

Pixel Crow
Member
Joined
Jun 21, 2019
Messages
2
Reaction score
0
First Language
Tagalog
Primarily Uses
RMXP
I see, so it used to be a thing for vehicles and other things. Makes me kind of disappointed that they removed that stuff in XP and can only be used for scripting.
Also, thanks for the codes! But I don't know how to integrate both of them into my game, since scripting is still pretty new to me. I've tried out both of them, pasted them in and edited a few things (that were supposed to be edited, I guess?), but none of them really worked, probably because I did it wrong. I'm unsure about which parts I should be editing and how I should be doing that in order to make it work :/
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
281
Reaction score
106
First Language
English
Primarily Uses
RMXP
First off, did you put the script somewhere after Scene_Debug but before Main? Are you using any other scripts or is this a fresh, clean project (which I'd recommend you do when play-testing a new script)?

Regarding the script I posted, the default configuration uses sound files that don't exist in the RTP. You're going to want to replace them with the name of actual sound effects you have, such as
Code:
Terrains[2] = ['016-Jump02']
So now the 016-Jump02 sound effect will play when moving over any tile with a terrain tag of 2.

For the configurations like...
Code:
Terrains[4] = ["FS - 09 - Concrete", 40, 0]
The numbers after the name refer to the volume and pitch of the sound effect. Not providing any (like I did with the Jump above) will default to 100 and 0 respectively.
 

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
Regarding the one that I posted, it uses a default 'beep' effect from the menu, but only if your character is stepping on a terrain with a terrain tag of '1'. So, of course, you would need to test it on a map that has multiple terrain tags... especially tag 1. And as 'typical'... paste the script below Scene_Debug and above Main.

The difference in the one I posted... cheaper and probably a bit clumsy when handling 'steps' But you can enable/disable which characters can generate the sounds. ;_; DUH! It's set to NOT play sounds by default!!!! This way, you control how many events make movement sounds that are meant to be footsteps.

Create a script call of:....
Code:
$game_player.hear_steps = true
... and you will hear your player's footsteps!!!

If event #2 walking around needs footstep sounds, make a script call of ...
Code:
$game_map.events[2].hear_steps = true
In a word... DUH!!!! *DerVV headdesks!*
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top