Randomize SE in moving route

Kuu_t

Veteran
Veteran
Joined
Jun 19, 2016
Messages
33
Reaction score
23
First Language
Finnish
Primarily Uses
RMMV
Hello everybody,

I have a traditional puzzle, where the player pushes a boulder on the button to open a door.

The puzzle is fine, but I'd like to do it more interesting for the player. I'd like to randomize the pitch of the pushing SFX to make it less monotonous to listen.

Is there a way to achieve this by eventing? I prefer eventing over a plugin because I'm already using Yanflies moving route plugins. I'm afraid that I'd broke the system with another plugin to override the moving route.

 

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
2,511
Reaction score
1,642
First Language
English
Primarily Uses
RMMV
Set a variable to random value (for example, random 1-3), then make conditional branches to cover each possible outcome (1, 2, 3, if following the example) with a different sound.
 

Kuu_t

Veteran
Veteran
Joined
Jun 19, 2016
Messages
33
Reaction score
23
First Language
Finnish
Primarily Uses
RMMV
Thanks! Unfortunately, I had to do it outside of the moving route loop. This is a bit clunky solution, but it works.

 

OS87

Warper
Member
Joined
May 11, 2018
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hey,
I wrote a little script for you to handle randomized sound effects within a move route.

add it to a new .js file in your js/plugins folder and activate it in the editor.

Code:
function soundPool(a, b) {
    // a = sound file name
    // b = number of sounds
return a + Math.floor(Math.random() * (b+1));
};
To use:
Create copies or rename your sound files so they share the same name, ending in a different number, starting at zero.
So the files would be:
Raise0.ogg
Raise1.ogg
Raise2.ogg

But it needs to start at 0, and there can't be any gaps in numbering. (so no 1,2,4,6).

In your Set Movement Route, select the "script" option, and paste in:
AudioManager.playSe({name: soundPool('Raise', 2), volume: 100, pitch: 100, pan: 0})

Obviously you can set the file name, the number to count up to, volume, pitch and pan to whatever you like!

How it works:
The script is a little function I've arbitrarily called soundPool, in the example above you give it two arguments: 'Raise' (the sound 'family' name) and 2; the highest number you have in that pool of sounds.
Used inside the AudioManager.playSe functionality from the engine itself, it justs chooses a random file from that pool of Raise sounds from 0 to the max you set.

Alternatively / Additionally:

Code:
function Pitchy(a, b) {
    // a = base value
    // b = range either side for random number
return a + Math.floor(Math.random() * (2*b+1) -b);
}
You can vary the pitch like this, input your base value and the number of variance you want on either side.

So in your setMovement you could have:
AudioManager.playSe({name: 'Raise0', volume: 100, pitch: Pitchy(100,2), pan: 0})

And this would use one sound, but every time it's played it'd be pitched within 2 of
100, (so it'd play at pitch 98,99,100,101 or 102).

You can use either or both at the same time, and they won't interfere with any other scripts, they're just additional tools you can use in your script calls.

Hope these help, your game looks nice!
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,975
Members
137,563
Latest member
cexojow
Top