Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[VX] [Request] - random battle music

Okay, this shouldn't be -too- hard I hope; I had written up a tiny modification back in RMXP about two years ago to allow a random song to be chosen (Battle1, Battle2, Battle3 and Battle4) just to add a bit of variety to the combat.  Trying to recall how to define that again for RMVX, and I'm just NOT quite getting a handle on the finding of content nested into the game's folders and could use a quick script.  Looks like it's defined in Game_System but from there I've tried about 15 different things and just keep getting syntax errors.  Muchly appreciated. :)

- Chal
 
Something like...

Code:
class Game_System
  def battle_bgm
    if @battle_bgm == nil
      #return $data_system.battle_bgm
      rand_bgm = rand(3) + 1
      bgm_name = "battle" + rand_bgm.to_s
      bgm = RPG::BGM.new(bgm_name)
      return bgm
    else
      return @battle_bgm
    end
  end
end

You can paste that as a new script above main, or just use the battle_bgm method in your Game_System class...

Since it still checks to see if @battle_bgm == nil, you can force your own specific battle music
with the "Change Battle BGM" event command. Or, set the Battle BGM to 'none' to use a random
BGM.

Be Well
 

Taylor

Sponsor

You could also check in the project 'Magivolve' posted here. :V *yoink*
Code:
#==========================================================================
# ** Random Battle-BGM 1.01
#==========================================================================
# by ERZENGEL (www.rpgvx.de.ms)
#==========================================================================

#==========================================================================
# * Game_Map
#==========================================================================
class Game_Map
  
  attr_accessor :rbm
  attr_accessor :rbmusic
  
  alias erzengel_rbminitialize initialize
  def initialize
    # The names of the audiofiles (they must be in the BGM-folder!)
    @rbmusic = ["Battle1", "Battle2", "Battle3","Battle4"]
    # TRUE if script should be active / FALSE if script should be inactive
    @rbm = true
    erzengel_rbminitialize
  end
  
end
#==========================================================================
# * Scene_Map
#==========================================================================
class Scene_Map
  
  alias erzengel_rbmcallbattle call_battle
  def call_battle
    rbm = $data_system.battle_bgm.name.clone
    if $game_map.rbm == true
      rndmusic = rand($game_map.rbmusic.size)
      $data_system.battle_bgm.name = $game_map.rbmusic[rndmusic]
    end    
    erzengel_rbmcallbattle
    $data_system.battle_bgm.name = rbm.clone
  end

end

I tried to find the original location of the script but it wasn't anywhere here http://www.rpgvx.de.ms/ .

You use $game_map.rbm = false/true to turn it off or on - off plays the currently set battle music. (Defined in the database or changed by the event command.)

Ofcourse if this was created exclusively for Magivolve I'll edit this post. (As far as I can see it doesn't look exclusive.)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top