RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Sound Emitting Areas/Events

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Sound Emitting Areas/Events
Version: 2.0
Author: modern algebra
Date: August 9, 2008

Version History


  • <Version 2.0> - Allows you to set sound emission from an event as well - August 9, 2008
  • <Version 1.1> - Now fully compatible with Advanced Areas and will turn the sound off the moment an area is deactivated - July 31, 2008
  • <Version 1.0b> - A slight oversight in the calculations fixed - July 29, 2008
  • <Version 1.0> - Original Release - July 26, 2008

Description


This script allows you to set a bgm, bgs, se, or me to areas or events and it dynamically calculates the volume depending on how far the player is from the area or event, creating the impression that the sound is emitting from that area or event.

Features

  • Can set sound emission to either an area or an event
  • Can attach a different sound or no sound to each individual page of an event.
  • Can set a bgm, bgs, se, or me
  • Smooth volume transition
  • Allows you to set SE repetition by frames and with variance
  • Lots of options for configuring each sound
  • Compatible with Advanced Areas, allowing you to turn off Areas that emit sound

Screenshots

Not applicable for this script. See the Demo for a better understanding of the script.

Instructions

See inside the script.

Script


Code: [Select]
#==============================================================================
#  Dynamic Sound Emitting Areas/Events (VX)
#  Version 2.0
#  Author: modern algebra (rmrk.net)
#  Date: August 9, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#    This script allows you to set a bgm, bgs, se, and me to areas or events and
#    it dynamically adjusts the volume depending on how far the player is from
#    the area or event, thus creating the impression that the sound is emitting
#    from that area or event.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Instructions:
#
#    For setting up an event, all you need to do is place a comment in the
#   first lines of a page with any number of these codes:
#
#      \SNDEMIT[stat = value]
#
#    The possible stats to set are:
#
#      bgm_name = 'Name of BGM you wish to emit'                (Default = '')
#      bgm_pitch = the pitch of the BGM, from 50 to 150         (Default = 100)
#      bgm_radius = the radius, in squares, of BGM range.       (Default = 10)
#      bgm_max_volume = The maximum volume of the BGM           (Default = 100)
#      bgs_name = 'Name of BGS you wish to emit'                (Default = '')
#      bgs_pitch = the pitch of the BGS, from 50 to 150         (Default = 100)
#      bgs_radius = the radius, in squares, of BGS range.       (Default = 10)
#      bgs_max_volume = The maximum volume of the BGS           (Default = 100)    
#      se_name = 'Name of SE you wish this area to emit'        (Default = '')
#      se_pitch = the pitch of the SE, from 50 to 150           (Default = 100)
#      se_radius = the radius, in squares, of the SE range      (Default = 10)
#      se_max_volume = the maximum volume of the SE             (Default = 100)
#      se_frames = the number of frames between playing the SE  (Default = 20)
#      se_frame_variance = the variance off se_frames           (Default = 0)
#      me_name = 'Name of ME you wish this area to emit'        (Default = '')
#      me_pitch = the pitch of the ME, from 50 to 150           (Default = 100)
#      me_radius = the radius, in squares, of the ME range      (Default = 10)  
#      me_max_volume = the maximum volume of the ME             (Default = 100)
#      me_frames = the number of frames between playing the ME  (Default = 20)
#      me_frame_variance = the variance off me_frames           (Default = 0)
#
#    EXAMPLE:
#     Set this in a comment of an event:
#
#      \sndemit[se_name = 'Chicken']
#      \SndEmit[se_max_volume = 80]
#      \sNdeMit[se_frames = 440]
#      \SNDEMIT[se_frame_variance = 60]
#
#    And the event will play the sound effect 'Chicken' at a max volume of 80
#   with a range of 10. It will repeat this SE every 380 - 500 frames
#==============================================================================

#==============================================================================
# ** RPG::Area
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    new instance variables - se_frames, se_frame_variance, me_frames,
#                             me_frame_variance
#    new methods - setup_sound_emissions, bgm, bgs, me, se, bgm?, bgs?, se?,
#                me?, volume, update_se, update_me
#==============================================================================

class RPG::Area
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader   :sound_emission
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Setup Sound Emissions
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def setup_sound_emissions
    s = @sound_emission = RPG::Sound_Emission.new
    case @id
    #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    #  !*!*! CONFIGURABLE REGION
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #  Set this region up in this way:
    #    
    #    when area_id
    #      s.stat = value
    #
    #     The stats and possible values are recorded in the initial header.
    #   You can set as many of them as you like.
    #
    #  EXAMPLE:
    #    when 1 # Waterfall
    #      # BGS
    #      s.bgs_name = 'River'
    #      s.bgs_radius = 15
    #      s.bgs_max_volume = 110
    #
    #    Will make it so that Area 1 will emit the BGS 'River' at a max volume
    #   of 110% within a radius of 15 squares
    #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    when 1 # Area 1
    when 4 # Area 4
    #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    #  !*!*! END CONFIGURABLE REGION
    #////////////////////////////////////////////////////////////////////////
    end
    @sound_emission.rect = self.rect
    @sound_emission.initialize_frame_counts
  end
end

#==============================================================================
# ** RPG::Sound_Emission
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  This class holds data relating to a sound emitting area
#==============================================================================

class RPG::Sound_Emission
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :rect
  attr_accessor :bgs_name
  attr_accessor :bgs_pitch
  attr_accessor :bgs_radius
  attr_accessor :bgs_max_volume
  attr_accessor :bgm_name
  attr_accessor :bgm_pitch
  attr_accessor :bgm_radius
  attr_accessor :bgm_max_volume
  attr_accessor :se_name
  attr_accessor :se_pitch
  attr_accessor :se_radius
  attr_accessor :se_max_volume
  attr_accessor :se_frames
  attr_accessor :se_frame_variance
  attr_accessor :me_name
  attr_accessor :me_pitch
  attr_accessor :me_radius
  attr_accessor :me_max_volume
  attr_accessor :me_frames
  attr_accessor :me_frame_variance
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Setup Sound Emissions
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize
    # Set Default Values
    @rect = Rect.new (0, 0, 0, 0)
    # Default values
    @bgs_name, @bgs_pitch, @bgs_radius, @bgs_max_volume, @bgm_name, @bgm_pitch,
      @bgm_radius, @bgm_max_volume, @se_name, @se_pitch, @se_radius,
      @se_max_volume, @me_name, @me_pitch, @me_radius, @me_max_volume,
      @se_frames, @se_frame_variance, @me_frames, @me_frame_variance = '', 100,
      10, 100, '', 100, 10, 100, '', 100, 10, 100 , '', 100, 10, 100, 20, 0, 20, 0
    initialize_frame_counts
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Initialize Frame Counts
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize_frame_counts
    @se_frame_count = @se_frames + rand (2*@se_frame_variance).floor - @se_frame_variance
    @me_frame_count = @me_frames + rand (2*@me_frame_variance).floor - @me_frame_variance
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Sound
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update
    @stopped = false
    bgm.play if @bgm_name != ''
    bgs.play if @bgs_name != ''
    update_se if @se_name != ''
    update_me if @me_name != ''
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Stop Sound
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def stop
    return if @stopped
    RPG::BGM.stop if @bgm_name != ''
    RPG::BGS.stop if @bgs_name != ''
    @stopped = true
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * BGM
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def bgm
    @bgm = RPG::BGM.new (@bgm_name, 0, @bgm_pitch) if @bgm == nil
    @bgm.volume = volume (@bgm_radius, @bgm_max_volume)
    return @bgm
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * BGS
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def bgs
    @bgs = RPG::BGS.new (@bgs_name, 0, @bgs_pitch) if @bgs == nil
    @bgs.volume = volume (@bgs_radius, @bgs_max_volume)
    return @bgs
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * SE
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def se
    @se = RPG::SE.new (@se_name, 0, @se_pitch) if @se == nil
    @se.volume = volume (@se_radius, @se_max_volume)
    return @se
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * SE Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update_se
    if @se_frame_count == 0
      se.play
      @se_frame_count = @se_frames + rand (2*@se_frame_variance).floor - @se_frame_variance
    else
      @se_frame_count -= 1
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * ME
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def me
    @me = RPG::ME.new (@me_name, 0, @me_pitch) if @me == nil
    @me.volume = volume (@me_radius, @me_max_volume)
    return @me
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * ME Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update_me
    if @me_frame_count == 0
      me.play
      @me_frame_count = @me_frames + rand (2*@me_frame_variance).floor - @me_frame_variance
    else
      @me_frame_count -= 1
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Volume
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def volume (radius, max_volume)
    x, y = $game_player.x, $game_player.y
    # Determine distance between position and the sound emitting object
    xd, yd = x - @rect.x, y - @rect.y
    # Evaluate X distance
    xd > 0 ? xd = x.between? (@rect.x, @rect.x + @rect.width) ? 0 : xd - @rect.width : xd *= -1
    # Evaluate Y distance
    yd > 0 ? yd = y.between? (@rect.y, @rect.y + @rect.height) ? 0 :yd - @rect.height : yd *= -1
    # Calculate the total distance
    total_distance = Math.sqrt(xd*xd + yd*yd).ceil.to_i
    # Get the percentage of max volume
    percent = (total_distance.to_f / radius.to_f)*100
    percent = (100 - [percent, 100].min).to_f / 100.0
    return (percent*max_volume.to_f).to_i
  end
end

#==============================================================================
# ** Game_Event
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    aliased method - setup, update
#==============================================================================

class Game_Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Setup
  #    page : the new page
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_sound_emit_obj_stp_event_pg_85nd setup
  def setup (new_page)
    # Run Original Method
    ma_sound_emit_obj_stp_event_pg_85nd (new_page)
    @sound_emission.stop unless @sound_emission.nil?
    # If page is legitimate
    unless @page == nil
      s = @sound_emission = RPG::Sound_Emission.new
      @sound_emission.rect = Rect.new (@x, @y, 1, 1)
      # Evaluate comments
      comments = []
      @page.list.each { |i| i.code == 108 || i.code == 408 ? comments.push (i) : break }
      # Evaluate comments for \SNDEMIT codes
      comments.each { |i|
        text = i.parameters[0].dup
        while text.sub! (/\\SNDEMIT\[(.+)\]/i) { '' } != nil
          eval ("@sound_emission." + $1.to_s)
        end
      }
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_snd_emssn_script_upd_evnt_4n2 update
  def update
    # Run Original Event
    modalg_snd_emssn_script_upd_evnt_4n2
    return if @sound_emission.nil?
    @sound_emission.rect.x, @sound_emission.rect.y = @x, @y
    @sound_emission.update
  end
end

#==============================================================================
# ** Game_Map
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    aliased method - update, setup
#==============================================================================

class Game_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Setup
  #    map_id : the ID of the map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_dynamic_snd_emit_stup_rn4 setup
  def setup(map_id)
    @areas.each { |area| area.sound_emission.stop } unless @areas.nil?
    # Run Original Method
    modalg_dynamic_snd_emit_stup_rn4 (map_id)
    # Get all areas that belong to this map
    @areas = []
    $data_areas.values.each { |area| @areas.push (area) if map_id == area.map_id }
    # Ensure Area Sound Effects are setup
    @areas.each { |i| i.setup_sound_emissions if i.sound_emission == nil }
    @advanced_areas = false
    begin
      # Test for exception thrown on .active?
      $data_areas[1].active?
      @advanced_areas = true
    rescue
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_dyn_sound_emitting_objects_upd_4h3 update
  def update
    # Run Original Map
    modalg_dyn_sound_emitting_objects_upd_4h3
    # For all area
    @areas.each { |area|
      @advanced_areas && !area.active? ? area.sound_emission.stop : area.sound_emission.update
      }
  end
end

Credit


  • modern algebra

Support


Please post here for swiftest support.

Demo


See attached.

Author's Notes


This script is based off of the version I wrote for RMXP with a number of significant alterations. This script is completely compatible with my Advanced Areas script, and I recommend it if you do not want the sounds playing all the time, as the Advanced Areas script includes a way to turn the area off by a switch and this script will recognize that command as well.


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
« Last Edit: February 11, 2010, 09:54:07 PM by Modern Algebra »

**
Rep: +0/-0Level 85
Wow, great script....  :)

I found a bug though....
If you use your advanced areas script, and you deactivate an area wich also produces sound, the area is going to loop the current settings forever..
(In my case, the fireplace still makes fire sounds while the user already put out the fire...)

This:
Code: [Select]
next if @advanced_areas_included && !area.active?
      area.update_sound
just stops updating the sound, but it still plays the way it did.....

I suggest you change it to something like this:

Code: [Select]
next if @advanced_areas_included && !area.active?
      area.update_sound
    Else  #Not sure about this though... because I dont know if area.active returns true or false when an area is NOT active
      area.kill_sound         

and make kill_sound something that completely mutes or stops the sound...

Portals - in VX!
Spoiler for Do require's in VX::
Code: [Select]
$LOAD_PATH << Dir.getwd #You only need to call this once
Kernel.require("includable.rb") #replace includable.rb with the name of the file you want to load
Spoiler for Invert Dash enabling::
Code: [Select]
#=============================================================================#
# # # ANTI DASH HACK    # # #
# # #   By AmIMeYet # # #
# # #    please credit me   # # #
#=============================================================================#
class Game_Player < Game_Character
  def dash?
return false if @move_route_forcing
return false if in_vehicle?
return true if Input.press?(Input::A) and $game_map.disable_dash?
  end
 end
This snippet basically inverts the dashing.. allowing you to dash only when 'disable dashing' is checked.
This way, normal maps disable dashing, but the ones you set to disable actually allow dashing..

It should be placed where you normally place the scripts ('above main', in the materials section of the scripts window)..

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Yeah, I was aware of that but the way that RMVX handles sound will make it hard.

The reason is because you cannot stop a particular sound, but instead have to do it like this:

RPG::BGM.stop
RPG::BGS.stop
RPG::SE.stop
RPG::ME.stop

Now, SE and ME are irrelevant as they will stop once they've stopped updating. But, for BGM and BGS the danger arises in their being another sound area in the room. I can't constantly kill the sound then, or it will kill the sound coming from the other area when this one isn't active. Anyway, it is a planned feature I am just looking for a nice way to implement. So far, I am thinking of introducing a variable that is true when it suddenly becomes inactive and false one frame after, so that it will only kill the sound once.

**
Rep: +0/-0Level 85
Yeah, that could work...

But isn't it possible to maybe lower the volume of the bgm and bgs dynamically?
I mean... it works with distance, so why not with on/off?
If that works, maybe alter other settings too.. so it creates less lag (with multiple processes).

Portals - in VX!
Spoiler for Do require's in VX::
Code: [Select]
$LOAD_PATH << Dir.getwd #You only need to call this once
Kernel.require("includable.rb") #replace includable.rb with the name of the file you want to load
Spoiler for Invert Dash enabling::
Code: [Select]
#=============================================================================#
# # # ANTI DASH HACK    # # #
# # #   By AmIMeYet # # #
# # #    please credit me   # # #
#=============================================================================#
class Game_Player < Game_Character
  def dash?
return false if @move_route_forcing
return false if in_vehicle?
return true if Input.press?(Input::A) and $game_map.disable_dash?
  end
 end
This snippet basically inverts the dashing.. allowing you to dash only when 'disable dashing' is checked.
This way, normal maps disable dashing, but the ones you set to disable actually allow dashing..

It should be placed where you normally place the scripts ('above main', in the materials section of the scripts window)..

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
I don't know what you mean by that really. Fade it out? Is it creating a lot of lag? Anyway, I think I've bypassed the problem I detailed.

Anyway, I finished the update where you can turn off the sound once it is started. I will post it as soon as I get a better idea of what you want. It is updated now.
« Last Edit: July 31, 2008, 02:09:32 PM by modern algebra »

**
Rep: +0/-0Level 85
I don't know what you mean by that really. Fade it out? Is it creating a lot of lag? Anyway, I think I've bypassed the problem I detailed.

Anyway, I finished the update where you can turn off the sound once it is started. I will post it as soon as I get a better idea of what you want. It is updated now.

Yeah, that fixed it... thanks

My idea was to use the same technique wich you use for distance but then just set the volume to 0...
My solution doen't matter though, as long as yours works  ;)

Found another bug.... if you are in an area while sound is playing, and then leave the map, the sound keeps on looping aswell.
This could be easilly diverted if you deactivate the area before teleporting, but could use a fix anyway...


PS: It isn't creating any lag,  but the thing is it MIGHT....  ;)   Never mind it though... you fixed it...

Portals - in VX!
Spoiler for Do require's in VX::
Code: [Select]
$LOAD_PATH << Dir.getwd #You only need to call this once
Kernel.require("includable.rb") #replace includable.rb with the name of the file you want to load
Spoiler for Invert Dash enabling::
Code: [Select]
#=============================================================================#
# # # ANTI DASH HACK    # # #
# # #   By AmIMeYet # # #
# # #    please credit me   # # #
#=============================================================================#
class Game_Player < Game_Character
  def dash?
return false if @move_route_forcing
return false if in_vehicle?
return true if Input.press?(Input::A) and $game_map.disable_dash?
  end
 end
This snippet basically inverts the dashing.. allowing you to dash only when 'disable dashing' is checked.
This way, normal maps disable dashing, but the ones you set to disable actually allow dashing..

It should be placed where you normally place the scripts ('above main', in the materials section of the scripts window)..

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Ah, you're right that should be fixed. Thanks for the headsup.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Updated to Version 2.0

All known bugs are fixed, but more importantly you can now set events to emit sounds by comments.

**
Rep: +0/-0Level 88
I get an error, just by having the script in my game, I don't even have any sounds yet:

"Script 'Sound Emitting Events' line 293: NoMethodError occured.
undefined method 'rect' for nil:NilClass"

I'm using several other scripts, one of them is an audio adjustment option menu, but when I disable that it still errors.. not sure what else it could possibly be.

-Psiclone

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Does the error occur if you put the script directly into a new project?

In any case, making that method look like this:

Code: [Select]

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_snd_emssn_script_upd_evnt_4n2 update
  def update
    # Run Original Event
    modalg_snd_emssn_script_upd_evnt_4n2
    return if @sound_emission.nil?
    @sound_emission.rect.x, @sound_emission.rect.y = @x, @y
    @sound_emission.update
  end

should fix that error, but I have no guarantee that it will work with this other script in any case.
« Last Edit: August 23, 2008, 03:40:11 AM by modern algebra »

**
Rep: +0/-0Level 88
For the time being (until I can 'beta test' all the scripts), that fixed the error, and everything works great. Thanks, MA

EDIT: Er, on second thought, all is not well..

If there's more than one sound emitting event, only 1 of them will work, and only from one specific direction (if you're to the right of it). Also, the 'area' one DID work, but once I made an event that emitted sound, the area stopped working, and has not worked again even after deleting the one event that was to emit sound. I could try to write a list of all the scripts I use, but that might be a long post.. would it work if I sent you the script.rvdata file of all the scripts I'm using? Or, you could tell me what methods (if any) this script overwrites, then maybe I can just do a search for that method and try to pinpoint what script is possibly conflicting.

-Psiclone
« Last Edit: August 25, 2008, 04:16:15 AM by psiclone »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
The script doesn't overwrite any methods at all.

One thing that this script won't do, and I mentioned this in the first post, is play more than one BGM or BGS in a single map, because that's just not an ability that RMVX has. There is no way to play more than one BGS or BGM, at least not without rewriting the entire Audio class.

The second problem shouldn't happen. If there's only one sound emitting it should play. My guess is that maybe you have also turned on another BGM or BGS from the map? That also cannot be done, for the same reason as the first.

If that's not the problem, then yeah, send me the rvdata and I'll take a look.

**
Rep: +0/-0Level 56
RMRK Junior
Hey,

I have been using this script in RMVX and i'm converting my project over to Ace, are there any plans to update this to work with Ace? I think a lot of people would use it, it's really useful.

Thanks
« Last Edit: April 19, 2012, 10:42:13 AM by paradoxum »

**
Rep: +0/-0Level 56
RMRK Junior
I posted a conversion request for this script to VXA on another forum, but I figured it would be a good idea to check if you're okay with that and if not I guess I can change it to a general request rather than a 'conversion' of your existing VX one.

let me know,

thanks

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
@paradoxum - if you are still looking for a copy of this script for VXA, I finally did get around to writing it: http://rmrk.net/index.php/topic,46842.0.html

**
Rep: +0/-0Level 56
RMRK Junior
You shouldn't have wasted your time, someone on another forum coded it months ago, sorry for not updating the topic but I didn't think you gave a shit.


*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, I didn't do it exclusively for you, so I don't think it was a waste of time regardless. However, I am glad to hear that you were able to find another scripter to write it, as it would have been an exorbitantly long wait otherwise.

**
Rep: +0/-0Level 57
RMRK Junior
I tried the script you put in the subject, and put it in the demo (deleting those who are there) and the waterfall does not emit sound.
So what do you recommend to use? The one who is here in the subject, or those who are in the demo?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
The script in this topic and the script in the demo are functionally equivalent; the only difference is the demo is configured with the waterfall area.

The reason the waterfall is not emitting sound when you replace the scripts there is only because the waterfall area is only setup in the demo version of the script. If you wanted to change that, you would only need to go to the following portion of the script:

Code: [Select]

    #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    #  !*!*! CONFIGURABLE REGION
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #  Set this region up in this way:
    #   
    #    when area_id
    #      s.stat = value
    #
    #     The stats and possible values are recorded in the initial header.
    #   You can set as many of them as you like.
    #
    #  EXAMPLE:
    #    when 1 # Waterfall
    #      # BGS
    #      s.bgs_name = 'River'
    #      s.bgs_radius = 15
    #      s.bgs_max_volume = 110
    #
    #    Will make it so that Area 1 will emit the BGS 'River' at a max volume
    #   of 110% within a radius of 15 squares
    #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    when 1 # Area 1
    when 4 # Area 4
    #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    #  !*!*! END CONFIGURABLE REGION
    #////////////////////////////////////////////////////////////////////////

and follow the instructions to set a sound emitting area.

**
Rep: +0/-0Level 57
RMRK Junior
Oh, I can understand now, my mistake was not fully read the instructions.
« Last Edit: October 10, 2012, 07:51:56 AM by Lord_Szekelys »

**
Rep: +0/-0Level 40
Chronically Spontaneous
*Edit: Better example
I have a river flowing through a town. There are frogs in the river. I want them to croak at random intervals, but I want each croak to have a different pitch.

Would I have to make a separate area for each of them, or is there some way I can vary the pitch within a single area?
« Last Edit: August 23, 2013, 04:23:42 PM by Space »
Spoiler for Current Project:
Chrononauts V: The Time Between Moments
[Working Title]
The first and final game in the epic Chrononauts series

Survived the kraaken and weeaboos. No power at home. Back when I learn to fix the electricity.