Sound Emitting Events
Sound Emitting Events
(v.2.1)
Introduction
This little script allows you to set up events that will play BGS/ME/SE (you could try BGM, but..) if the player gets close enough.
The volume is based on the distance between the player and the event, so the closer the player is to the event, the louder it will play, the farthest the player is, the softer it will play (or not play at all).
You can set a max volume for the sound/music. (v.2.1)
Features
- Easy to use.
- Compatibility friendly.
- Lemonade friendly.
Screenshot
http://img850.imageshack.us/img850/4089/lsee.png
How to Use
To use it, you just need to make a comment inside the event that would be the sound source with the following →
Code:
LSEE TYPE RANGE PITCH VOLUME FILENAME
If you want a BGS to play, you need to add BGS after LSEE, like this →
Code:
LSEE BGS 8 100 100 Fire
If you want to play ME/SE, you also need to two additional indicators for delay and variance →
Code:
LSEE SE 8 100 45 Absorb2 60 100
Demo
http://www.mediafire...41g2a39vpkuh00d
Script
Spoiler Code:
#==============================================================================
# ** Lemony's Sound Emitting Events
#------------------------------------------------------------------------------
# * This little script allows to make certain events play music/sounds based
# on player proximity.
# * It is currently limited by one bgs at a time, resulting in lag if one
# sound emitting event's area is overlapping other's sound emitting event area.
#------------------------------------------------------------------------------
# To use it, simple make a comment inside the target event with the following
# LSEE TYPE RANGE PITCH VOLUME FILENAME => LSEE BGS 8 100 100 Fire
# If type is SE or ME, you need two additional variables
# LSEE TYPE RANGE PITCH VOLUME FILENAME DELAY RANDOM
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# * Refresh Alias
#--------------------------------------------------------------------------
alias lemony_see_refresh refresh
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
lemony_see_refresh
return if (@page.nil? || @page.list.nil?)
@page.list.each {|p| b = p.parameters
s, @lsee_out = (b != nil && b.is_a?(String)) ? b.split : '', false
if (p.code == 108 || p.code == 408) && b.include?('LSEE')
@lsee_data = , s, s.to_i, s, s, s.to_i, s.to_i]
break if @lsee_data != nil
else @lsee_out = true end}
end
#--------------------------------------------------------------------------
# * Update Alias
#--------------------------------------------------------------------------
alias lemony_see_update update
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
lemony_see_update
if !@lsee_data.nil?
xx, yy = (@real_x - $game_player.real_x), (@real_y - $game_player.real_y)
close = (Math.sqrt((xx * xx) + (yy * yy)) <= @lsee_data.to_i)
r, d = @lsee_data.to_i, Math.sqrt((xx * xx) + (yy * yy))
v, go, ms = (r - (d - 1 % r)) * @lsee_data.to_i / r, true, ['ME', 'SE']
if !@lsee_out
if ms.include?(@lsee_data)
@lsee_timer ||= @lsee_data + rand(@lsee_data)
@lsee_timer = [@lsee_timer - 1, 0].max
go = @lsee_timer <= 0
@lsee_timer = nil if go
end
out = (!@lsee_data.nil? && (@lsee_data.volume > 0 && !close)) && go
f = "#{@lsee_data}.new('#{@lsee_data}', #{v}, #{@lsee_data})"
@lsee_data ||= eval("RPG::" + f) if close && go
@lsee_data.volume = v if !@lsee_data.nil? && close
@lsee_data.play if ((!@lsee_data.nil? && close) && go) || out
@lsee_data.volume -= 1 if !@lsee_data.nil? && !close
@lsee_data = nil if (!@lsee_data.nil? && @lsee_data.volume <= 0)
elsif @lsee_out
@lsee_data.volume -= 1 if !@lsee_data.nil?
@lsee_data.play if !@lsee_data.nil? && !ms.include?(@lsee_data)
if (!@lsee_data.nil? && @lsee_data.volume <= 0)
@lsee_data, @lsee_out = nil, false
end
end
end
end
end
Author's Notes
Free for use in commercial/noncommercial games, no credits needed.
本贴来自国际rpgmaker官方论坛作者:♥SOURCE♥处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/sound-emitting-events.1714/
页:
[1]