Introduction
This little script calculate the distance between an event and the player and the volume for a sound that can be played by that event.
Features
- Friendly little helper
How to Use
Simple put a call script command in your event.
In my example I use a cat as an event that randomly plays a "meow" every five seconds with a probability of 25%.
The maximum volume is 50 and the maximum distance the sound is played is 20.
The call script command should be like this:
@>Control Variables:[0021:Miau] = Random No.(0..100)
@>Conditional Branch; Variable[0021:Miau]<=25
@>Script: RPG::SE.new("Cat", volume(@event_id,20,50), 100).play
@>Wait:300 frame(s)
@>
: Else
@>Wait:300 frame(s)
@>
: Branch End
@>
Author's Note
Free for use in commercial/noncommercial games.
Credits are welcome.
Script
# Version 1.01# Date : Nov 15, 2013
#------------------------------------------------------------------------------
# Parameters:
# eventID : ID of the event that produces the SE
# md : maximum distance up to which you can hear the SE
# mv : maximum volume of the SE
# return : actual volume depending on the actual distance
#
# Example:
# RPG::SE.new("Cat", volume(@event_id,20,50), 100).play
#------------------------------------------------------------------------------
def volume(eventID, md, mv)
x1 = $game_player.x
y1 = $game_player.y
x2 = $game_map.events[eventID].x
y2 = $game_map.events[eventID].y
d = Math.sqrt((x2-x1)**2 + (y2-y1)**2).round
v = mv-(mv*d/md).round
if v < 0 then
v = 0
end
return(v)
end
This little script calculate the distance between an event and the player and the volume for a sound that can be played by that event.
Features
- Friendly little helper
How to Use
Simple put a call script command in your event.
In my example I use a cat as an event that randomly plays a "meow" every five seconds with a probability of 25%.
The maximum volume is 50 and the maximum distance the sound is played is 20.
The call script command should be like this:
@>Control Variables:[0021:Miau] = Random No.(0..100)
@>Conditional Branch; Variable[0021:Miau]<=25
@>Script: RPG::SE.new("Cat", volume(@event_id,20,50), 100).play
@>Wait:300 frame(s)
@>
: Else
@>Wait:300 frame(s)
@>
: Branch End
@>
Author's Note
Free for use in commercial/noncommercial games.
Credits are welcome.
Script
#------------------------------------------------------------------------------
# weilhalt scripts
# [email hidden]
#------------------------------------------------------------------------------
#
#------------------------------------------------------------------------------
# Title : Sound Volume
# Author : Peter Guettinger
# weilhalt scripts
# [email hidden]
#------------------------------------------------------------------------------
#
#------------------------------------------------------------------------------
# Title : Sound Volume
# Author : Peter Guettinger
#------------------------------------------------------------------------------
# Parameters:
# eventID : ID of the event that produces the SE
# md : maximum distance up to which you can hear the SE
# mv : maximum volume of the SE
# return : actual volume depending on the actual distance
#
# Example:
# RPG::SE.new("Cat", volume(@event_id,20,50), 100).play
#------------------------------------------------------------------------------
def volume(eventID, md, mv)
x1 = $game_player.x
y1 = $game_player.y
x2 = $game_map.events[eventID].x
y2 = $game_map.events[eventID].y
d = Math.sqrt((x2-x1)**2 + (y2-y1)**2).round
v = mv-(mv*d/md).round
if v < 0 then
v = 0
end
return(v)
end