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).
Kind of hard for sound effects...
Click here for the script.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# 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
Place script below Game_Map and above "Main". There are instructions for configuration in the script.
No known compatibility issues.
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. Although RMXP does not support playing them streaming, their small file size and good compression make them good for such a thing.