Anybody know a way to play tune when you level up?

Status
Not open for further replies.

SpunkyDuck

Ruby Programming Enthusiast
Veteran
Joined
Jun 5, 2020
Messages
97
Reaction score
411
First Language
(US) English
Primarily Uses
RMVXA
Here, this will work whenever and wherever a party member levels up. You can adjust the settings accordingly. Sorry it looks like a mess but XP's source code was messy from day 1.
Ruby:
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles the actor. It's used within the Game_Actors class
#  ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * CONSTANTS
  #--------------------------------------------------------------------------
  XANE_LVL_UP_TUNE_ERROR_CHECK = true
  XANE_LVL_UP_TUNE_TYPE = 'ME'
  XANE_LVL_UP_TUNE = ['010-Item01', 100, 100]
  #--------------------------------------------------------------------------
  # * Change EXP
  #     exp : new EXP
  #--------------------------------------------------------------------------
  def exp=(exp)
    @exp = [[exp, 9999999].min, 0].max
    # Level up
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      # Play Level Up Tune
      param0 = XANE_LVL_UP_TUNE[0]
      param1 = XANE_LVL_UP_TUNE[1]
      param2 = XANE_LVL_UP_TUNE[2]
      case XANE_LVL_UP_TUNE_TYPE
      when 'ME'
        Audio.me_play("Audio/ME/" + param0, param1, param2)
      when 'SE'
        Audio.se_play("Audio/SE/" + param0, param1, param2)
      else
        if XANE_LVL_UP_TUNE_ERROR_CHECK
          print('Invalid Tune Type. Please Use ME, or SE Only.')
        end
      end
      # Increase Level
      @level += 1
      # Learn skill
      for j in $data_classes[@class_id].learnings
        if j.level == @level
          learn_skill(j.skill_id)
        end
      end
    end
    # Level down
    while @exp < @exp_list[@level]
      @level -= 1
    end
    # Correction if exceeding current max HP and max SP
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
  end
end
 

Fauxworks

Feelin foxy
Veteran
Joined
Dec 13, 2020
Messages
33
Reaction score
15
First Language
English
Primarily Uses
RMXP
Here, this will work whenever and wherever a party member levels up. You can adjust the settings accordingly. Sorry it looks like a mess but XP's source code was messy from day 1.
Ruby:
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles the actor. It's used within the Game_Actors class
#  ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * CONSTANTS
  #--------------------------------------------------------------------------
  XANE_LVL_UP_TUNE_ERROR_CHECK = true
  XANE_LVL_UP_TUNE_TYPE = 'ME'
  XANE_LVL_UP_TUNE = ['010-Item01', 100, 100]
  #--------------------------------------------------------------------------
  # * Change EXP
  #     exp : new EXP
  #--------------------------------------------------------------------------
  def exp=(exp)
    @exp = [[exp, 9999999].min, 0].max
    # Level up
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      # Play Level Up Tune
      param0 = XANE_LVL_UP_TUNE[0]
      param1 = XANE_LVL_UP_TUNE[1]
      param2 = XANE_LVL_UP_TUNE[2]
      case XANE_LVL_UP_TUNE_TYPE
      when 'ME'
        Audio.me_play("Audio/ME/" + param0, param1, param2)
      when 'SE'
        Audio.se_play("Audio/SE/" + param0, param1, param2)
      else
        if XANE_LVL_UP_TUNE_ERROR_CHECK
          print('Invalid Tune Type. Please Use ME, or SE Only.')
        end
      end
      # Increase Level
      @level += 1
      # Learn skill
      for j in $data_classes[@class_id].learnings
        if j.level == @level
          learn_skill(j.skill_id)
        end
      end
    end
    # Level down
    while @exp < @exp_list[@level]
      @level -= 1
    end
    # Correction if exceeding current max HP and max SP
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
  end
end




Where do I enter the song title?
 

SpunkyDuck

Ruby Programming Enthusiast
Veteran
Joined
Jun 5, 2020
Messages
97
Reaction score
411
First Language
(US) English
Primarily Uses
RMVXA
On this line:
Ruby:
 XANE_LVL_UP_TUNE = ['010-Item01', 100, 100]
The first argument is the sound file's name, the second is volume, and the third is pitch.

You'll find every setting you need under this section.
Ruby:
#--------------------------------------------------------------------------
# * CONSTANTS
#--------------------------------------------------------------------------
 

Fauxworks

Feelin foxy
Veteran
Joined
Dec 13, 2020
Messages
33
Reaction score
15
First Language
English
Primarily Uses
RMXP
On this line:
Ruby:
 XANE_LVL_UP_TUNE = ['010-Item01', 100, 100]
The first argument is the sound file's name, the second is volume, and the third is pitch.

You'll find every setting you need under this section.
Ruby:
#--------------------------------------------------------------------------
# * CONSTANTS
#--------------------------------------------------------------------------

Got it to work thank you!
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
16,119
Reaction score
8,930
First Language
English
Primarily Uses
RMMV

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

Another comic with Backstage Malak...
If you want to ask him anything, you can ask on my DeviantArt page! I'm not sure if you're allowed to do it here.
Forum tip of the day ...
If you get a temporary suspension for being a jerk to people who are trying to help you, and arguing with mods and admins, don't go making new accounts. Chances are, if you p**s us off enough to suspend you for a week, we're not going to hesitate giving you a permanent ban when you give us a reason.
E_6fAErVkAQILXu.png
I'm so close to releasing my game on steam! :blush::blush::blush:
Us:
"This game is awesome! I wish there are more games like this in the future."
Also us:
"I hate how games stopped being original and start copying other successful games."
Should've done this a few days ago but...
PRI_200136808.jpg
Rest in Peace, Sir Clive Sinclair
1940 - 2021
Entrepreneur, Technologist, Father of the Modern British Computing Industry, and protagonist of Legend of ZUN.

Without you, England's games and tech industry wouldn't be where it is.

Forum statistics

Threads
115,287
Messages
1,088,657
Members
149,913
Latest member
badalias
Top