RPG Maker Forums

So, Galv's Region Effects allows you to play SEs and trigger Events when the player moves into the region.

And Victor's Step Sound allows you to play SEs when the player, events and followers move into the region.

Now, what if the best of both worlds could be combined?

That's what I first thought when I used Region Effects, since using the effect broke the atmosphere, seeing how only my actor had legs.

I searched and found Victor's Step Sound, which solves one problem, but has the limit of no events.

And so, I decided to edit the code in Victor's Step Sound, so that I can call a method "region_event" from Galv's Region Effects, while using parameters @x and @y in place of game_player.x and game_player.y. I assumed this would work, as under the same class where I'm using "region_effect" in Step Sound(Game_CharacterBase), there is a method "step volume" which uses the method "distance_x_from" which uses the public instance variable "x" from Game_Character. But it doesn't, and only the SEs play (I added in extra code for event playing as seperate methods). 

Now, I haven't changed anything from Region Effects, and yes, I made sure that Step Sound is below Victor's Engine which is below Region Effects.

So, yeah. If anyone could either introduce me to a script that does just this which I've missed on the internet, or help me out with this code. I'll be asking them for permissions to edit their codes (Or just Victor if it works out well on Region Effects' side) once this works.

Code:

#==============================================================================# ** Victor Engine - Step Sound

#------------------------------------------------------------------------------

# Author : Victor Sant

#

# Version History:

#  v 1.00 - 2012.01.08 > First release

#  v 1.01 - 2012.01.15 > Fixed the Regular Expressions problem with "" and “”

#  v 1.02 - 2012.05.30 > Compatibility with Pixel Movement

#  v 1.03 - 2012.08.02 > Compatibility with Basic Module 1.27

#------------------------------------------------------------------------------

#  This script allows to add sound to the step for actors and events on map.

# It's possible to set sounds based on tileset terrain tags or map regions.

#------------------------------------------------------------------------------

# Compatibility

#   Requires the script 'Victor Engine - Basic Module' v 1.27 or higher

#

# * Alias methods

#   class Game_Map

#     def setup(map_id)

#

#   class Game_CharacterBase

#     def update_move

#     def update_stop

#

#   class Game_Player < Game_Character

#     def update



#   class Game_Event < Game_Character

#     def clear_starting_flag

#

#   class Game_Follower < Game_Character

#     def update

#

#   class Game_Vehicle < Game_Character

#     def update

#

#------------------------------------------------------------------------------

# Maps and Tilests note tags:

#   Tags to be used on Maps and Tilests note boxes.



#  <step sound>

#  settings

#  </step sound>

#   Set the sound effect played when steping on a tile with terrain or region

#   set, add the following values to the settings. The ID and file name 

#   must be added, other values are optional. 

#     id: x     : region ID or terrain ID

#     name: "x" : sound effect filename ("filename)

#     volume: x : sound effect volume (0-100, default = 100)

#     pitch: x  : sound effect pitch (50-150, default = 100)

#

#------------------------------------------------------------------------------

# Actors, Classes, States, Weapons, Armors and Comment Boxes note tags:

#   Tags to be used on Actors, Classes, States, Weapons, Armors note boxes

#   and Events Comment boxes. The comment boxes are different from the comment

#   call, they're called always the even refresh.



#  <no step sound>

#   The actor or event won't play any sound when walking on tiles with sound.

#

#------------------------------------------------------------------------------

# Instructions:

#  To instal the script, open you script editor and paste this script on

#  a new section bellow the Materials section. This script must also

#  be bellow the script 'Victor Engine - Basic'

#

#==============================================================================

 

#==============================================================================

# ** Victor Engine

#------------------------------------------------------------------------------

#   Setting module for the Victor Engine

#==============================================================================

 

module Victor_Engine

  #--------------------------------------------------------------------------

  # * required

  #   This method checks for the existance of the basic module and other

  #   VE scripts required for this script to work, don't edit this

  #--------------------------------------------------------------------------

  def self.required(name, req, version, type = nil)

    if !$imported[:ve_basic_module]

      msg = "The script '%s' requires the script\n"

      msg += "'VE - Basic Module' v%s or higher above it to work properly\n"

      msg += "Go to http://victorscripts.wordpress.com/ to download this script."

      msgbox(sprintf(msg, self.script_name(name), version))

      exit

    else

      self.required_script(name, req, version, type)

    end

  end

  #--------------------------------------------------------------------------

  # * script_name

  #   Get the script name base on the imported value, don't edit this

  #--------------------------------------------------------------------------

  def self.script_name(name, ext = "VE")

    name = name.to_s.gsub("_", " ").upcase.split

    name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }

    name.join(" ")

  end

end

 

$imported ||= {}

$imported[:ve_step_sound] = 1.03

Victor_Engine.required:)ve_step_sound, :ve_basic_module, 1.27, :above)

 

#==============================================================================

# ** Game_Map

#------------------------------------------------------------------------------

#  This class handles maps. It includes scrolling and passage determination

# functions. The instance of this class is referenced by $game_map.

#==============================================================================

 

class Game_Map

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_reader :terrain_sounds

  attr_reader :regions_sounds

  attr_reader :terrain_events

  attr_reader :regions_events

  attr_reader :terrain_com_events

  attr_reader :regions_com_events

  #--------------------------------------------------------------------------

  # * Alias method: battle_start

  #--------------------------------------------------------------------------

  alias :setup_ve_step_sound :setup

  def setup(map_id)

    setup_ve_step_sound(map_id)

    setup_step_sound

  end

  #--------------------------------------------------------------------------

  # * New method: setup_step_sound

  #--------------------------------------------------------------------------

  def setup_step_sound

    @regions_sounds = setup_sound_settings(note)

    @terrain_sounds = setup_sound_settings(tileset.note)

    @regions_events = setup_event(note)

    @terrain_events = setup_event(tileset.note)

    @regions_com_events = setup_com_event(note)

    @terrain_com_events = setup_com_event(tileset.note)

  end

  #--------------------------------------------------------------------------

  # * New method: setup_sound_settings

  #--------------------------------------------------------------------------  

  def setup_sound_settings(note)

    settings = {}

    regexp   = get_all_values("STEP SOUND")

    note.scan(regexp) do

      value  = $1.dup

      name   = value =~ /NAME: #{get_filename}/i ? $1 : ""

      id     = value =~ /ID: (\d+)/i     ? $1.to_i : 0

      volume = value =~ /VOLUME: (\d+)/i ? $1.to_i : 100

      pitch  = value =~ /PITCH: (\d+)/i  ? $1.to_i : 100

      settings[id] = RPG::SE.new(name, volume, pitch)

    end

    settings.dup

  end

  #--------------------------------------------------------------------------

  # * New method: setup_event

  #--------------------------------------------------------------------------  

  def setup_event(note)

    settingsEv = {}

    regexp   = get_all_values("STEP SOUND")

    note.scan(regexp) do

      value  = $1.dup

      id     = value =~ /ID: {\d+}/i     ? $1.to_i : 0

      event  = value =~ /EVENT: {\d+}/i  ? $1.to_i : 0

      settingsEv = {"id" => id, "event" => event}

    end

    return settingsEv

  end

  #--------------------------------------------------------------------------

  # * New method: setup_com_event

  #--------------------------------------------------------------------------  

  def setup_com_event(note)

    settingsComEv = {}

    regexp   = get_all_values("STEP SOUND")

    note.scan(regexp) do

      value  = $1.dup

      id     = value =~ /ID: {\d+}/i     ? $1.to_i : 0

      com_event  = value =~ /COM_EVENT: {\d+}/i  ? $1.to_i : 0

      settingsComEv = {"id" => id, "com_event" => com_event}

    end

    return settingsComEv

  end

end

#==============================================================================

# ** Game_CharacterBase

#------------------------------------------------------------------------------

#  This class deals with characters. Common to all characters, stores basic

# data, such as coordinates and graphics. It's used as a superclass of the

# Game_Character class.

#==============================================================================

 

class Game_CharacterBase

  #--------------------------------------------------------------------------

  # * Alias method: update_move

  #--------------------------------------------------------------------------

 

  alias :update_move_ve_step_sound :update_move

  def update_move

    update_move_ve_step_sound

    update_step_sound if moving? || @moved

  end

 

  #--------------------------------------------------------------------------

  # * Alias method: update_stop

  #--------------------------------------------------------------------------

  alias :update_stop_ve_step_sound :update_stop

  def update_stop

    update_stop_ve_step_sound 

    @step_update = 0 if @stop_count > 1 || @locked

  end

  #--------------------------------------------------------------------------

  # * New method: update_step_sound

  #--------------------------------------------------------------------------

  def update_step_sound

    return if @no_step_sound

    @step_update ||= 0

    play_step_sound if @step_update == 0

    play_event if @step_update == 0

    @step_update += 10

    @step_update = 0 if @step_update > ((8 - real_move_speed) * 40)

  end

  #--------------------------------------------------------------------------

  # * New method: play_step_sound

  #--------------------------------------------------------------------------

  def play_step_sound

    v = rand(10) - rand(10)

    p = rand(40) - rand(40)

    if $game_map.terrain_sounds[terrain_tag]

      sound = $game_map.terrain_sounds[terrain_tag].clone

      eve = $game_map.terrain_events

      com_eve = $game_map.terrain_com_events

    elsif $game_map.regions_sounds[region_id]

      sound = $game_map.regions_sounds[region_id].clone

      eve = $game_map.regions_events

      com_eve = $game_map.regions_com_events

    end

    return unless sound

    sound.volume = (sound.volume + v) * step_volume

    sound.pitch = (sound.pitch + p)

    sound.play

  end

  #--------------------------------------------------------------------------

  # * New method: play_event

  #--------------------------------------------------------------------------

  def play_event

    return if $game_map.terrain_events["event"] == nil || eve = $game_map.regions_events["event"] == nil

    if $game_map.terrain_sounds[terrain_tag]

      eve = $game_map.terrain_events["event"]

      com_eve = $game_map.terrain_com_events["event"]

    elsif $game_map.regions_sounds[region_id]

      eve = $game_map.regions_events["event"]

      com_eve = $game_map.regions_com_events["event"]

    end

      if eve > 0  

        $game_map.region_event(@x, @y, eve, Region_Effects::SPAWN_MAP_ID)

      end

    $game_temp.reserve_common_event(com_eve) unless com_eve == nil

  end

  #--------------------------------------------------------------------------

  # * New method: step_volume

  #--------------------------------------------------------------------------

  def step_volume

    sx = distance_x_from($game_player.x).abs

    sy = distance_y_from($game_player.y).abs

    [[(100 - (sx + sy - 2) * 5), 0].max, 100].min / 100.0

  end

  #--------------------------------------------------------------------------

  # * Alias method: update_player_step_sound

  #--------------------------------------------------------------------------

  def update_player_step_sound

    return unless actor

    if @step_info != [actor.equips, actor.states, actor.class]

      @step_info = [actor.equips, actor.states, actor.class]

      @no_step_sound_player = actor.note =~ /<NO STEP EVENT>/i

      actor.equips.compact.each do |equip|

        @no_step_sound_player |= equip.note =~ /<NO STEP EVENT>/i

      end

      actor.states.each do |state|

        @no_step_sound_player |= state.note =~ /<NO STEP EVENT>/i

      end

      @no_step_sound_player |= actor.class.note =~ /<NO STEP EVENT>/i

    end

  end  

end

 

#==============================================================================

# ** Game_Player

#------------------------------------------------------------------------------

#  This class handles the player.

# The instance of this class is referenced by $game_map.

#==============================================================================

 

class Game_Player < Game_Character

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_reader   :vehicle_getting_on

  attr_reader   :vehicle_getting_off

  #--------------------------------------------------------------------------

  # * Alias method: update

  #--------------------------------------------------------------------------

  alias :update_ve_step_sound :update

  def update

    update_player_step_sound

    @no_step_sound = vehicle && vehicle.altitude > 0 || @no_step_sound_player

    update_ve_step_sound

  end

end

#==============================================================================

# ** Game_Event

#------------------------------------------------------------------------------

#  This class deals with events. It handles functions including event page 

# switching via condition determinants, and running parallel process events.

# It's used within the Game_Map class.

#==============================================================================

 

class Game_Event < Game_Character

  #--------------------------------------------------------------------------

  # * Alias method: clear_starting_flag

  #--------------------------------------------------------------------------

  alias :clear_starting_flag_ve_step_sound :clear_starting_flag

  def clear_starting_flag

    clear_starting_flag_ve_step_sound

    @no_step_sound = note =~ /<NO STEP SOUND>/i if @page

  end

end

 

#==============================================================================

# ** Game_Follower

#------------------------------------------------------------------------------

#  This class handles the followers. Followers are the actors of the party

# that follows the leader in a line. It's used within the Game_Followers class.

#==============================================================================

 

class Game_Follower < Game_Character

  #--------------------------------------------------------------------------

  # * Alias method: update

  #--------------------------------------------------------------------------

  alias :update_ve_step_sound :update

  def update

    update_player_step_sound

    @no_step_sound = no_step_follower || @no_step_sound_player

    update_ve_step_sound

  end

  #--------------------------------------------------------------------------

  # * New method: no_step_follower

  #--------------------------------------------------------------------------

  def no_step_follower

    !visible? || ($game_player.vehicle && (!$game_player.vehicle_getting_on &&

    !$game_player.vehicle_getting_off))

  end

end

 

#==============================================================================

# ** Game_Vehicle

#------------------------------------------------------------------------------

#  This class handles vehicles. It's used within the Game_Map class. If there

# are no vehicles on the current map, the coordinates is set to (-1,-1).

#==============================================================================

 

class Game_Vehicle < Game_Character

  #--------------------------------------------------------------------------

  # * Alias method: update

  #--------------------------------------------------------------------------

  alias :update_ve_step_sound :update

  def update

    @no_step_sound = true

    update_ve_step_sound

  end

end
 

Note: I'm not a Ruby programmer, but I managed to get a bit of basics from their interactivity tutorial. I do mainly C++, which is why I have little idea as to how those @variables work, and how my code might be missing something simple. People have requested for Region Effects to be implemented for followers, which I would then be able to tweak for events, but he said no on his blog :( Also, I'm surprised that no one had asked/done scripts fulfilling this purpose. Is it really such an unwanted feature, or is it just impossible to do in this current system?

Edit: I might've used Hashes wrongly while setting up events and common events.

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,038
Messages
1,018,467
Members
137,821
Latest member
Capterson
Top