Code:
#===========================================
# * Sound STEP Script v.2
#------------------------------------------------------------------------------
# by Woratana [woratana@hotmail.com]
# Thaiware RPG Maker Community
# Released on: 13/01/2008
=begin
# SCRIPTER'S NOTE
* for File name: you don't have to put file type
(e.g. file name "Walk.mp3", you just put "Walk" in script)
=end
#==============================================
=begin #=======================================================================
#==============================================================================
# ** RMXP Standard Development Kit
#------------------------------------------------------------------------------
# Build Date - 22.11.05
# Version 1.0 - Near Fantastica - 22.11.05
# Version 1.1 - SephirothSpawn - 18.12.05 - (Near Fantastica)
# Version 1.2 - Near Fantastica - 18.12.05
=end #===============================================================================
module SDK
#--------------------------------------------------------------------------
# * Returns a list of parameters form a Event Comments
#--------------------------------------------------------------------------
def self.event_comment_input(*args)
parameters = []
list = *args[0].list
elements = *args[1]
trigger = *args[2]
return nil if list == nil
return nil unless list.is_a?(Array)
for idem in list
next if idem.code != 108
if idem.parameters[0] == trigger
start = list.index(idem) + 1
finish = start + elements
for id in start...finish
next if !list[id]
parameters.push(list[id].parameters[0])
end
return parameters
end
end
return nil
end
end #SDK
#===========================================
# * Sound STEP Script
# START from Here!
# Need Support? just e-mail to me. (woratana@hotmail.com)
#==============================================
#============================================
# Game Map
#============================================
class Game_Map
#------------------------------------------------------------------------------
# * Setup Sound STEP
#--------------------------------------------------------------------------
SWITCH = 1 # Set Switch for turn on/off system
$hero_step = -1 # 0 to turn off hero's step sound
$hero_sound = 60
attr_accessor :s_sound, :sound_step, :terrain_step, :step_vol, :step_tem, :volume
#------------------------------------------------------------------------------
# * Setup Sounds
#--------------------------------------------------------------------------
alias map_ini initialize
def initialize
map_ini
@sound_step = @terrain_step = @sound = []
# Setup Normal Sound
@sound_step[0] = @terrain_step[0] = "047-Book02" # Normal step sound
@step_vol = 100 # Step sound Volume [Lowest (No sound) 0 - 100 Highes]
@step_tem = 100 # Step sound Tempo [Default = 100]
# Add more sounds below here
@sound_step[1] = @terrain_step[2] = "040-Knock01"
@step_vol = 100
@step_tem = 100
@sound_step[2] = "040-Knock01"
@sound_step[3] = "Walk-Hall"
@sound_step[4] = "Walk-Tile"
# Add more sounds depend on [Terrain Tag] below here
@terrain_step[1] = "Walk-Grass"
@terrain_step[2] = "040-Knock01"
@terrain_step[3] = "Walk-Hall"
@terrain_step[4] = "Walk-Tile"
end
#------------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias map_update update
def update
map_update
return unless $game_switches[SWITCH] == true
for i in @events.keys
step_check(@events[i])
# Check if start new map
end #for
if $hero_step != 0
step_check($game_player)
end
end #def update
#------------------------------------------------------------------------------
# * Character Step Check
#--------------------------------------------------------------------------
def step_check(ev)
# Setup
if ev.lx == 0
ev.lx = ev.x
end
if ev.ly == 0
ev.ly = ev.y
end
# Check event move here
if ev.lx != ev.x or ev.ly != ev.y
ev.lx = ev.x
ev.ly = ev.y
# Read Event Comment
sound = []
if ev != $game_player
eff = SDK.event_comment_input(ev, 2, "step")
return if eff.nil?
sound = eff.to_a
else # Hero Case
sound[0] = $hero_step
sound[1] = $hero_sound
end
if sound[1].to_i > 0
volume = sound[1].to_i
else
volume = @step_vol
end
play_sound(sound,ev,volume)
end
end
#------------------------------------------------------------------------------
# * Play Sound STEP Effect
#--------------------------------------------------------------------------
def play_sound(sound,ev,volume)
case sound[0].to_i
when nil
@s_sound = @sound_step[0]
when -1
terrain_sound(ev)
else
if @sound_step[sound[0].to_i] != nil
@s_sound = @sound_step[sound[0].to_i]
else
@s_sound = @sound_step[0]
end
end
Audio.se_play("Audio/SE/" + @s_sound.to_s, volume.to_i, @step_tem)
end
#------------------------------------------------------------------------------
# * Depend on Terrain
#--------------------------------------------------------------------------
def terrain_sound(ev)
terrain = ev.terrain_tag
if @sound_step[terrain] != nil
@s_sound = @sound_step[terrain]
else
@s_sound = @sound_step[0]
end
end
end #CLASS END
#============================================
# Game Character
#============================================
class Game_Character
#------------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :lx, :ly
#------------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias char_initialize initialize
def initialize
char_initialize
@lx = 0
@ly = 0
end
end #Class Game_Character
#===========================================
# * Sound STEP Script END Here
# Need Support? just e-mail to me. (woratana@hotmail.com)
#==============================================