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.

Ambient Sound Effects

Ambient SFX Version: 1.1
By: ForeverZer0

Introduction

This system will play SE at intervals in addition to the BGM/BGS. You can configure each map separately with its own array of SE to play. The SE will played randomly and will be played at random intervals (configurable).

Features
  • Each map can be configured separately
  • Can use as many different SFX as you want for each map
  • Provides a more 'random' effect than a simple looping BGM/BGS
  • Temporary changes or enabling/disabling with script calls
  • Perfect for bird chirps, insect SFX, etc.

Screenshots

Kind of hard for sound effects...

Demo

Demo Link

Script

[rgss]#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Ambient SFX
# Author: ForeverZer0
# Date: 5.1.2011
# Version: 1.1
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#   This system will play SE at intervals in addition to the BGM/BGS. You can
#   configure each map separately with its own array of SE to play. The SE
#   will played randomly and will be played at random intervals (configurable).
#  
# Features:
#   - Each map can be configured separately
#   - Can use as many different SFX as you want for each map
#   - Provides a more 'random' effect than a simple looping BGM/BGS
#   - Temporary changes or enabling/disabling with script calls
#   - Perfect for bird chirps, insect SFX, etc.
#
# Instructions:
#   - Set your maps up using this syntax:
#
#   when MAP_ID then [DELAY, ['SE_NAME', VOLUME, PITCH],
#     ['ANOTHER_SE_NAME', VOLUME, PITCH], ['ANOTHER_SE_NAME', VOLUME, PITCH]]
#
# The system will choose a random number between 0 - DELAY each frame (that
# is 40 times per second for those who don't know), and if that number is equal
# to 0, a random SE in the array will be played. You don't need to set up any
# maps if you are not using this system for it.  
#
# The system can be toggled ON/OFF with the script call:
#
#            $game_system.AMBIENT_SE = true/false
#
# It can also be temporarily added or changed with the script call:
#
#   $game_map.ambient_SE = [DELAY, ['SE_NAME', VOLUME, PITCH],
#     ['ANOTHER_SE_NAME', VOLUME, PITCH], ['ANOTHER_SE_NAME', VOLUME, PITCH]]
#
# ...or turned off temporarilly on the current map with:
#
#   $game_map.ambient_SE = nil
#
# These will only work on a temporary basis for the current map, everything will
# return to normal once the player moves to a different map. Disable the add-on
# completely if you don't want it to persist.
#
# Author's Notes:
#   Try to avoid using WAV files for the SFX. I have found that this can cause
#   lag occasionally when the SE is played. Use OGG or MIDI.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
 
class Game_Map
  
  attr_accessor :ambient_SE
 
  alias zer0_ambient_sfx_setup setup
  def setup(map_id)
    @ambient_SE = case map_id
#-------------------------------------------------------------------------------
# BEGIN CONFIGURATION
#-------------------------------------------------------------------------------
    # You can add more than 1 map_id per case.     ex. (when 1, 8, 32)
    when 1
      [150, ['Birdsong1', 80, 100], ['Birdsong2', 80, 100],
      ['Birdsong3', 80, 100], ['Birdsong4', 80, 100]]
    when 2
      [40, ['Cricket', 80, 100], ['Frog', 80, 100]]
#-------------------------------------------------------------------------------
# END CONFIGURATION
#-------------------------------------------------------------------------------
    end
    zer0_ambient_sfx_setup(map_id)
  end
  
  alias zer0_ambient_sfx_upd update
  def update
    if $game_system.AMBIENT_SFX && @ambient_SE != nil
      if rand(@ambient_SE[0]) == 0
        r = rand(@ambient_SE.size - 1) + 1
        $game_system.se_play(RPG::AudioFile.new(*@ambient_SE[r]))
      end
    end
    zer0_ambient_sfx_upd
  end
end
 
#===============================================================================
# ** Game_System
#===============================================================================
 
class Game_System
  
  attr_accessor :AMBIENT_SFX
  
  alias zer0_ambient_sfx_init initialize
  def initialize
    zer0_ambient_sfx_init
    @AMBIENT_SFX = true
  end
end
[/rgss]

Instructions

Place script below Game_Map and above "Main". There are instructions for configuration in the script.

Compatibility

No known compatibility issues.

Author's Notes

Please report any bugs/issues so that they can be resolved. Enjoy!

Terms and Conditions

Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
You are free:

to Share - to copy, distribute and transmit the work
to Remix - to adapt the work

Under the following conditions:

Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).

Noncommercial. You may not use this work for commercial purposes.

Share alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.

- For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.

- Any of the above conditions can be waived if you get permission from the copyright holder.

- Nothing in this license impairs or restricts the author's moral rights.
 

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