Level Up sound effect script.

One thing that the PS1 version of RPG Maker had was the option to play a sound effect whenever one or more party members leveled up during battle.

Sadly, RPG Maker VX Ace lacks native support for this.

I would like to implement something like that in my game. So, I was wondering if a script could be made that plays a sound effect whenever an actor gains a level.


Ideally, I would like a script where within the script, I would tell it what sound effect that I want to use as a level up sound effect by typing something like "filename.ogg". The sound effect would have to be in the SE folder for it to work.

Also ideally, I only want the sound effect to play only once even when multiple actors level up in the same battle.

I would also like the sound effect to play when a player levels up on the map from an event that either gives XP or a solid level up. However, this is optional. I can do without. Having the level up sound upon battle victory is most important.

I would like the availability to work with .wav and .mp3 as well, but that is optional. I am fine is the script only supports .ogg

Everybody on this forums have been so helpful with scripts and I appreciate it. I may not be the best at expressing gratitude, but I do appreciate all the hard word you guys have put forth to help me. 🙂
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Level Up Sounds                        ║  Version: 1.00     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║   Play a sound on level up                    ║    20 Oct 2023     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil                                                      ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║   Change the name of the sound file to play                        ║
# ║   Supports what file type you make VXA support                     ║
# ║                                                                    ║
# ║   Change the option to play the file or not                        ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - 20 Oct 2020 - Script finished                               ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks:                                                ║
# ║   Roninator2                                                       ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use:                                                      ║
# ║  Follow the original Authors terms of use where applicable         ║
# ║    - When not made by me (Roninator2)                              ║
# ║  Free for all uses in RPG Maker except nudity                      ║
# ║  Anyone using this script in their project before these terms      ║
# ║  were changed are allowed to use this script even if it conflicts  ║
# ║  with these new terms. New terms effective 03 Apr 2024             ║
# ║  No part of this code can be used with AI programs or tools        ║
# ║  Credit must be given                                              ║
# ╚════════════════════════════════════════════════════════════════════╝

module R2_Level_Up_Sound
 
  #Name of the ME to play.
  ME = "Item"
  PLAY_ME = false
  
  #Name of the SE to play.
  SE = "Laser"
  PLAY_SE = true
  
  #Switch used to control playing the sound once
  SWITCH = 1
  
end

# ╔════════════════════════════════════════════════════════════════════╗
# ║                      End of editable region                        ║
# ╚════════════════════════════════════════════════════════════════════╝

#==============================================================================
# ** BattleManager
#==============================================================================
module BattleManager
  #--------------------------------------------------------------------------
  # * EXP Acquisition and Level Up Display
  #--------------------------------------------------------------------------
  class << self
    alias r2_gain_exp_sound gain_exp
  end
  def self.gain_exp
    $game_switches[R2_Level_Up_Sound::SWITCH] = true
    r2_gain_exp_sound
    $game_switches[R2_Level_Up_Sound::SWITCH] = false
  end
end

#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Level Up
  #--------------------------------------------------------------------------
  alias r2_level_up_sounds_actor level_up
  def level_up
    if $game_switches[R2_Level_Up_Sound::SWITCH] == true
      Audio.se_play("Audio/SE/" + R2_Level_Up_Sound::SE, 100, 100) if R2_Level_Up_Sound::PLAY_SE
      Audio.me_play("Audio/ME/" + R2_Level_Up_Sound::ME, 100, 100) if R2_Level_Up_Sound::PLAY_ME
    end
    $game_switches[R2_Level_Up_Sound::SWITCH] = false
    r2_level_up_sounds_actor
  end
end

#==============================================================================
# ** Game_Interpreter
#==============================================================================
class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Change EXP
  #--------------------------------------------------------------------------
  alias r2_gain_exp_315 command_315
  def command_315
    $game_switches[R2_Level_Up_Sound::SWITCH] = true
    r2_gain_exp_315
    $game_switches[R2_Level_Up_Sound::SWITCH] = false
  end
end
Works great! Thank you!
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Level Up Sounds                        ║  Version: 1.00     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║   Play a sound on level up                    ║    20 Oct 2023     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil                                                      ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║   Change the name of the sound file to play                        ║
# ║   Supports what file type you make VXA support                     ║
# ║                                                                    ║
# ║   Change the option to play the file or not                        ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - 20 Oct 2020 - Script finished                               ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks:                                                ║
# ║   Roninator2                                                       ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use:                                                      ║
# ║  Follow the original Authors terms of use where applicable         ║
# ║    - When not made by me (Roninator2)                              ║
# ║  Free for all uses in RPG Maker except nudity                      ║
# ║  Anyone using this script in their project before these terms      ║
# ║  were changed are allowed to use this script even if it conflicts  ║
# ║  with these new terms. New terms effective 03 Apr 2024             ║
# ║  No part of this code can be used with AI programs or tools        ║
# ║  Credit must be given                                              ║
# ╚════════════════════════════════════════════════════════════════════╝

module R2_Level_Up_Sound
 
  #Name of the ME to play.
  ME = "Item"
  PLAY_ME = false
 
  #Name of the SE to play.
  SE = "Laser"
  PLAY_SE = true
 
  #Switch used to control playing the sound once
  SWITCH = 1
 
end

# ╔════════════════════════════════════════════════════════════════════╗
# ║                      End of editable region                        ║
# ╚════════════════════════════════════════════════════════════════════╝

#==============================================================================
# ** BattleManager
#==============================================================================
module BattleManager
  #--------------------------------------------------------------------------
  # * EXP Acquisition and Level Up Display
  #--------------------------------------------------------------------------
  class << self
    alias r2_gain_exp_sound gain_exp
  end
  def self.gain_exp
    $game_switches[R2_Level_Up_Sound::SWITCH] = true
    r2_gain_exp_sound
    $game_switches[R2_Level_Up_Sound::SWITCH] = false
  end
end

#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Level Up
  #--------------------------------------------------------------------------
  alias r2_level_up_sounds_actor level_up
  def level_up
    if $game_switches[R2_Level_Up_Sound::SWITCH] == true
      Audio.se_play("Audio/SE/" + R2_Level_Up_Sound::SE, 100, 100) if R2_Level_Up_Sound::PLAY_SE
      Audio.me_play("Audio/ME/" + R2_Level_Up_Sound::ME, 100, 100) if R2_Level_Up_Sound::PLAY_ME
    end
    $game_switches[R2_Level_Up_Sound::SWITCH] = false
    r2_level_up_sounds_actor
  end
end

#==============================================================================
# ** Game_Interpreter
#==============================================================================
class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Change EXP
  #--------------------------------------------------------------------------
  alias r2_gain_exp_315 command_315
  def command_315
    $game_switches[R2_Level_Up_Sound::SWITCH] = true
    r2_gain_exp_315
    $game_switches[R2_Level_Up_Sound::SWITCH] = false
  end
end

Hello, first of all, thanks a lot for this. This script was just what I was looking for. I'm new to the RPG maker series. My dad just got me RPG Maker VXACE and MZ when they was on sale last time. I have a question though when you see this, no rush though. The script didn't work with my VXACE project initially, but once I removed one part of it, it worked great.

However even though my custom music I made for it works with everything else, it doesn't seem to want to work with the script. I keep getting a message telling me it can not locate it and it just crashes the game out. Your sound that you had listed in the script works, but if I try to change it, it just does this. Any ideas? Does it only work with sounds that already came with the game, or is there a certain way they have to be saved? I've tried MP3, and .Ogg so far.
but if I try to change it, it just does this.
You have to have the sound file in the SE folder in Audio folder. It should be an .ogg file.

Also you do realize you can do screen captures? there is 100% no need to use your phone.
Click the start button and type in (without the quotes) "snip"
It will show you the snipping tool. I'm pretty sure it is still there for windows 11. (I have windows 10)

What part did you remove?
You have to have the sound file in the SE folder in Audio folder. It should be an .ogg file.

Also you do realize you can do screen captures? there is 100% no need to use your phone.
Click the start button and type in (without the quotes) "snip"
It will show you the snipping tool. I'm pretty sure it is still there for windows 11. (I have windows 10)

What part did you remove?
Ok I just looked, its in the SE Audio folder for the project. But I looked at the properties, when I saved it, its saved as an MP3. I'll switch that over to .ogg here in awhile.

Screen capture on the game itself? The old windows button + whatever trick don't work at the moment on my keyboard or computer for some reason. It was working at one time, but it stopped, no idea why, its an old computer though, but dad installed almost all new parts. "snip?" I'll have to try that next time, did not know you could do that. This computer still runs on Windows 10.

Oh the only thing I removed was the first line where it says Ruby:
For some reason it was acting like that was preventing it from working, but once I deleted that, it worked great, well until I tried to change the sound effect from the default laser to my sound effect Power up! (mp3)
Oh the only thing I removed was the first line where it says Ruby:
The ruby is there as part of the code post with the forums.
That part just tells you this code is displayed as ruby code.
That's why it is coloured.

Original thread: https://forums.rpgmakerweb.com/threads/level-up-sound-effect-script.162193/