Introduction
This sucker is pretty self explanatory. I just have a variable pre-defined in Game_System that holds the current Sound Effect value (0 to 100). This module adjusts the volume of the Sound being played in the Battle Animations based on the value stored IN Game_System.
Without it, you will only adjust the volume of the music and sound effects OTHER than battle animations.
Screenshots
Audio effect, guys....
Demo
None
Script
In two small parts...
Part 1: The adjustable variables
Code:
#==============================================================================
# ** Game_System [Edit]
#------------------------------------------------------------------------------
# This class handles data surrounding the system. Backround music, etc.
# is managed here as well. Refer to "$game_system" for the instance of
# this class.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :bgm_volume
attr_accessor :se_volume
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias initialize_game_system initialize
def initialize
initialize_game_system
# Music / SFX Options
@bgm_volume = 100; @se_volume = 100
end
#--------------------------------------------------------------------------
# * End of Class
#--------------------------------------------------------------------------
end
@bgm_volume and @se_volume are the values that you Option Menu scripters will be using (I figure ) to adjust... the Background Music and the Sound Effects.
Part 2: The MEAT!
The code below uses the se_volume value to adjust the Battle Animation volume properly
Code:
#==============================================================================
# ** EDIT: Animation Audio Fix
#------------------------------------------------------------------------------
# This update to the Animation Timer allows for volume adjustment through the
# Options Menu. Without this module, all battle animations would be at full
# volume.
#==============================================================================
module RPG
class Sprite < ::Sprite
def animation_process_timing(timing, hit)
if (timing.condition == 0) or
(timing.condition == 1 and hit == true) or
(timing.condition == 2 and hit == false)
if timing.se.name != ""
se = timing.se
Audio.se_play("Audio/SE/" + se.name, se.volume * $game_system.se_volume / 100 ,se.pitch)
end
case timing.flash_scope
when 1
self.flash(timing.flash_color, timing.flash_duration * 2)
when 2
if self.viewport != nil
self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
end
when 3
self.flash(nil, timing.flash_duration * 2)
end
end
end
end
end
Take note that the Audio.se_play line in the 2nd half says...
Quote:se.volume * $game_system.se_volume / 100
It takes the current volume that the animation is set at, then multiplies it by the value we've given it. True, that would BLAST OUR EARS OFF. But we then divide the volume's value by 100, thus decreasing it properly. We couldn't multiply the value by a percentage as the script probably wouldn't accept fractions or decimal values, so I did this instead.
Compatibility
This script rewrites the animation module to allow for audio control. If anyone edits the audio module... be forewarned. After that, ANYTHING else should work.