Randomize SE in moving route

Discussion in 'RPG Maker MV' started by Kuu_t, Sep 9, 2018.

  1. Kuu_t

    Kuu_t Veteran Veteran

    Messages:
    30
    Likes Received:
    20
    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.

    [​IMG]
     
    #1
  2. Milennin

    Milennin "With a bang and a boom!" Veteran

    Messages:
    2,197
    Likes Received:
    1,255
    Location:
    Fiore
    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.
     
    #2
    Kuu_t likes this.
  3. Kuu_t

    Kuu_t Veteran Veteran

    Messages:
    30
    Likes Received:
    20
    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.

    [​IMG]
     
    #3
    Milennin likes this.
  4. OS87

    OS87 Warper Member

    Messages:
    3
    Likes Received:
    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: Sep 11, 2018
    #4

Share This Page