Zer0Morph

Regular
Regular
Joined
Sep 8, 2022
Messages
83
Reaction score
41
First Language
English
Primarily Uses
RMMZ
Hey Gang!

I'm looking for help on making a simple plugin that allows me to add a proximity effect to a sound effect (SE) so that when the player gets closer to the sound, it plays louder, and when the player moves further, it gets quieter.

I've tried several plugins that already do this without success. Here's the ones I've tried to far.

OCRam_Audio - His works but the sound has a slight amount of reverb to it. It sounds like it's in a tin can and I'm not sure why. Other than that, it works great.
Tea_ProximitySound - Her plugin also works but I can't shut off the BGS file after I leave the map causing it to play on other maps that use the same BGS. If she programmed it to auto-remove, then I could use this, and yes I already asked her in the thread.
VisuMZ_4_AmbienceSounds - This one plays random SE files and while it does have a proximity property to it, the sound volume only adjusts AFTER it plays again (repeats).
PKD_AmbientSounds - Similar to VisuMZ, it works but forces the SE to repeat over and over again which I don't want it to do.

I don't know of any other plugins to try for MZ (Paid or Unpaid). Any help would be greatly appreciated!
 

Eliaquim

Hakuen Studio
Regular
Joined
May 22, 2018
Messages
3,345
Reaction score
2,644
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi there!
Maybe the solution here for you is to event this system, which is not so hard to do.

You can try this script call:
$gameMap.distance(x1, y1, x2, y2) → This will return a number that measures the distance in tiles.
So:
JavaScript:
$gameMap.distance($gamePlayer.x, $gamePlayer.y, x2, y2)
And replace X2 and Y2 with the values you want(the source of the sound).
Then you can just play the sound according to the distance.

Another way to do it is to put regions all over the sound source, and according to what region the player is in, you adjust the sound for it.
 

Zer0Morph

Regular
Regular
Joined
Sep 8, 2022
Messages
83
Reaction score
41
First Language
English
Primarily Uses
RMMZ
Would I also play the sound in the same script call, or is the script call in its own entry?

I currently have footstep sounds being played in my region IDs and though I could try multiple SEs for shared regions, it would be messy and difficult to implement across many maps.
 

Eliaquim

Hakuen Studio
Regular
Joined
May 22, 2018
Messages
3,345
Reaction score
2,644
First Language
Portuguese - Br
Primarily Uses
RMMZ
Would I also play the sound in the same script call, or is the script call in its own entry?

I currently have footstep sounds being played in my region IDs and though I could try multiple SEs for shared regions, it would be messy and difficult to implement across many maps.
That script call is only to measure the distance. You can play the sound the way you want. Event commands or another script call.
If you used that amount of plugins and none of them worked for you, I believe the event way is what is left.

I believe you shouldn't think if it is difficult or not. Just think if you want this or not. Like, you want an easy way to implement this feature, or you just want this feature in your game?

It could be messy on the first try, but it can be improved with more tries until it gets into a cleaner event.

Or you could try the plugins again, make a sample project replicating the error, and contact the authors so they can help you out.
 

Zer0Morph

Regular
Regular
Joined
Sep 8, 2022
Messages
83
Reaction score
41
First Language
English
Primarily Uses
RMMZ
That script call is only to measure the distance. You can play the sound the way you want. Event commands or another script call.
If you used that amount of plugins and none of them worked for you, I believe the event way is what is left.

I believe you shouldn't think if it is difficult or not. Just think if you want this or not. Like, you want an easy way to implement this feature, or you just want this feature in your game?

It could be messy on the first try, but it can be improved with more tries until it gets into a cleaner event.

Or you could try the plugins again, make a sample project replicating the error, and contact the authors so they can help you out.
Okay thanks, I'll try your script call then play the sound effect in an event command.
 

Zer0Morph

Regular
Regular
Joined
Sep 8, 2022
Messages
83
Reaction score
41
First Language
English
Primarily Uses
RMMZ
Eli,

So I did as you said and I made an Autorun event putting your script at the top, then played my SE via the event command. It played the SE but it didn't get quieter or louder depending on my distance from it. I'm not sure how to proceed from here. Any ideas?

1685928500684.png
 

Eliaquim

Hakuen Studio
Regular
Joined
May 22, 2018
Messages
3,345
Reaction score
2,644
First Language
Portuguese - Br
Primarily Uses
RMMZ
Eli,

So I did as you said and I made an Autorun event putting your script at the top, then played my SE via the event command. It played the SE but it didn't get quieter or louder depending on my distance from it. I'm not sure how to proceed from here. Any ideas?

View attachment 264221

$gameMap.distance(x1, y1, x2, y2) → This will return a number that measures the distance in tiles.
So:
JavaScript:
$gameMap.distance($gamePlayer.x, $gamePlayer.y, x2, y2)
And replace X2 and Y2 with the values you want(the source of the sound).
Then you can just play the sound according to the distance.
You are using it wrong. As I said, the script call will return a number, with the distance, in tiles from a point X1, Y1 to another point X2, Y2.
You used the script call, but you are doing nothing with the number it returns. You need to keep getting the distance of the player from the sound source, so you can play the sound the way you like, according to the distance.

This will probably need a parallel event, not autorun. If you use autorun, how the player will move? If the player not moves, why do you need to check the distance between him and the source sound?
 

Zer0Morph

Regular
Regular
Joined
Sep 8, 2022
Messages
83
Reaction score
41
First Language
English
Primarily Uses
RMMZ
How would I get the number the script call returns?
 

Latest Posts

Latest Profile Posts

I'm pretty sure me watching Netflix while having sushi just led to me eating the tail of my tempura shrimp.
1696004095642.png
...and now he even makes resources, too! xD
OMG Y'all. I found an alternate Google Drive I 100% forgot I had. All my crusty old game files from 2014 (when I signed up) are in there. When I like...maybe actually make a prototype thread it's gonna be so much fun taking everyone down my memory lane.
We are at the finish line!!! Thank you COMMUNITY!!!
GameCompletion.jpg

Forum statistics

Threads
134,903
Messages
1,251,756
Members
177,723
Latest member
DemonHitmaker
Top