Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> 


———
Before you ask! Read! ;)

You must have 30+ Posts to create a topic here!

Thanks for reading!
———

 
Reply to this topicStart new topic
> Battle music toggle?
pudding
post Jul 21 2012, 09:18 PM
Post #1


Level 9
Group Icon

Group: Revolutionary
Posts: 140
Type: Writer
RM Skill: Intermediate




Hi!
Before anyone says anything, yes I know you can change the battle music using an event but (and please correct me if I'm wrong and you can do this by eventing!) I was wondering if there was a script to do this. Basically, each time the actors go into battle, a theme from a pool of 5 will be chosen at random so if you get into a battle the music changes every time. I'm sure you can do this with eventing and I just can't figure it out, but either way (scripting or eventing) help would be MAJORLY appreciated. A game with a good example of this is Visions and Voices if anyone has played that. I can't figure out how they did it tongue.gif. Much appreciated!


__________________________
""
Go to the top of the page
 
+Quote Post
   
diamondandplatin...
post Jul 22 2012, 10:27 AM
Post #2


Level 5
Group Icon

Group: Member
Posts: 72
Type: Writer
RM Skill: Skilled
Rev Points: 45




Can be done by eventing if you're using map monster encounters, otherwise you would need a script to do random battle themes just before battle.


I did it for you, so here you go smile.gif

code

CODE
#==============================================================================
#  Random Battle Themes
#  Version: 1.0
#  Author: DiamondandPlatinum3
#  Date: July 23, 2012
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#    This script allows you to play a random battle theme upon starting a
#    battle, it can be turned off before a boss battle via switch so that
#    the appropriate battle them still plays for them.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#------------------------------------------------------------------------------
#  Instructions:
#  
#     - Just take a look at the editable region and modify things
#       appropriately.
#
#==============================================================================
module RNDM_Battle_Themes
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#                                                        -=
#                 Editable Region        ////            ==
#                                                        =-
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

  Boss_Battle_Event_Switch_ID = 10          # Turn this switch on before a boss
                                            # battle so that the music you actually
                                            #want to play will play.

  Battle_Theme_Volume         = 100         # The Volume of the BGM
  Battle_Theme_Pitch          = 100         # The Pitch of the BGM
  
  First_Random_Battle_Theme   = "Battle1"   # The Name of One of the Random Battle Themes
  Second_Random_Battle_Theme  = "Battle2"   # The Name of One of the Random Battle Themes
  Third_Random_Battle_Theme   = "Battle3"   # The Name of One of the Random Battle Themes
  Fourth_Random_Battle_Theme  = "Battle4"   # The Name of One of the Random Battle Themes
  Fifth_Random_Battle_Theme   = "Battle5"   # The Name of One of the Random Battle Themes
  
  
#===========================================================
end # of Editable Region
#===========================================================
#---------------------------------------------------------
# No touchie past here unless you know what you are
# doing. Failure to heed this warning could cause your
# computer to yell and scream at you.
#
# Edit at your own risk.
#--------------------------------------------------------














class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Switch to Battle Screen
  #--------------------------------------------------------------------------
  alias rndm_battle_themes_cb_4wa2 call_battle
  def call_battle
    @spriteset.update
    Graphics.update
    $game_player.make_encounter_count
    $game_player.straighten
    $game_temp.map_bgm = RPG::BGM.last
    $game_temp.map_bgs = RPG::BGS.last
    RPG::BGM.stop
    RPG::BGS.stop
    
    
    Sound.play_battle_start
    
    @bgm_volume = RNDM_Battle_Themes::Battle_Theme_Volume
    @bgm_pitch  = RNDM_Battle_Themes::Battle_Theme_Pitch
    
    @bt = rand(5) + 1
    
    if @bt == 1
      @battle_bgm   = "Audio/BGM/" + RNDM_Battle_Themes::First_Random_Battle_Theme
      Audio.bgm_play(@battle_bgm, @bgm_volume, @bgm_pitch)
    elsif @bt == 2
      @battle_bgm   = "Audio/BGM/" + RNDM_Battle_Themes::Second_Random_Battle_Theme
      Audio.bgm_play(@battle_bgm, @bgm_volume, @bgm_pitch)
    elsif @bt == 3
      @battle_bgm   = "Audio/BGM/" + RNDM_Battle_Themes::Third_Random_Battle_Theme
      Audio.bgm_play(@battle_bgm, @bgm_volume, @bgm_pitch)
    elsif @bt == 4
      @battle_bgm   = "Audio/BGM/" + RNDM_Battle_Themes::Fourth_Random_Battle_Theme
      Audio.bgm_play(@battle_bgm, @bgm_volume, @bgm_pitch)      
    elsif @bt == 5
      @battle_bgm   = "Audio/BGM/" + RNDM_Battle_Themes::Fifth_Random_Battle_Theme
      Audio.bgm_play(@battle_bgm, @bgm_volume, @bgm_pitch)
    else #if something went wrong              
      $game_system.battle_bgm.play
    end
      
    $game_system.battle_bgm.play if $game_switches[RNDM_Battle_Themes::Boss_Battle_Event_Switch_ID] == true
    
    $game_temp.next_scene = nil
    $scene = Scene_Battle.new
  end
end


This post has been edited by diamondandplatinum3: Jul 22 2012, 10:41 AM


__________________________
Go to the top of the page
 
+Quote Post
   
pudding
post Jul 22 2012, 11:22 AM
Post #3


Level 9
Group Icon

Group: Revolutionary
Posts: 140
Type: Writer
RM Skill: Intermediate




Oh my gosh, thank you so much your the best! I cannot wait to try it!
So I just tried it and I got a small error :/ "Script 'Battle Music Toggle' line 68: NameError occurred. undefined method 'call_battle' for class 'Scene_Map' This is most likely something I did wrong. What I did was I named the 5 battle themes Battle1, Battle2 etc. Is there anything else I should do and that's why it's not working, or maybe another script is preventing it from working? Either way, I'm sorry to bother you but this script looks so cool and I would really love to get it to work!


__________________________
""
Go to the top of the page
 
+Quote Post
   
diamondandplatin...
post Jul 22 2012, 11:25 AM
Post #4


Level 5
Group Icon

Group: Member
Posts: 72
Type: Writer
RM Skill: Skilled
Rev Points: 45




Well I wrote the script for RMVX, are you using that maker?


I'm guessing you must be using RMVXA, I can write the script for that as well smile.gif


__________________________
Go to the top of the page
 
+Quote Post
   
pudding
post Jul 22 2012, 12:02 PM
Post #5


Level 9
Group Icon

Group: Revolutionary
Posts: 140
Type: Writer
RM Skill: Intermediate




QUOTE (diamondandplatinum3 @ Jul 22 2012, 11:25 AM) *
Well I wrote the script for RMVX, are you using that maker?


I'm guessing you must be using RMVXA, I can write the script for that as well smile.gif


I cannot believe I forgot to tell you that. Ah, so stupid, my mistake so sorry! Yes I'm using ace and I would be so grateful if you wouldn't mind doing an ace version. That would be splendid. Thank you and sorry!


__________________________
""
Go to the top of the page
 
+Quote Post
   
diamondandplatin...
post Jul 22 2012, 12:06 PM
Post #6


Level 5
Group Icon

Group: Member
Posts: 72
Type: Writer
RM Skill: Skilled
Rev Points: 45




VXA

code

CODE
#==============================================================================
#  Random Battle Themes
#  Version: 1.0
#  Author: DiamondandPlatinum3
#  Date: July 23, 2012
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#    This script allows you to play a random battle theme upon starting a
#    battle, it can be turned off before a boss battle via switch so that
#    the appropriate battle them still plays for them.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#------------------------------------------------------------------------------
#  Instructions:
#  
#     - Just take a look at the editable region and modify things
#       appropriately.
#
#==============================================================================
module RNDM_Battle_Themes
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#                                                        -=
#                 Editable Region        ////            ==
#                                                        =-
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

  Boss_Battle_Event_Switch_ID = 10          # Turn this switch on before a boss
                                            # battle so that the music you actually
                                            #want to play will play.

  Battle_Theme_Volume         = 100         # The Volume of the BGM
  Battle_Theme_Pitch          = 100         # The Pitch of the BGM
  
  First_Random_Battle_Theme   = "Battle1"   # The Name of One of the Random Battle Themes
  Second_Random_Battle_Theme  = "Battle2"   # The Name of One of the Random Battle Themes
  Third_Random_Battle_Theme   = "Battle3"   # The Name of One of the Random Battle Themes
  Fourth_Random_Battle_Theme  = "Battle4"   # The Name of One of the Random Battle Themes
  Fifth_Random_Battle_Theme   = "Battle5"   # The Name of One of the Random Battle Themes
  
  
#===========================================================
end # of Editable Region
#===========================================================
#---------------------------------------------------------
# No touchie past here unless you know what you are
# doing. Failure to heed this warning could cause your
# computer to yell and scream at you.
#
# Edit at your own risk.
#--------------------------------------------------------














class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Switch to Battle Screen
  #--------------------------------------------------------------------------
  alias rndm_battle_themes_cb_4wa2 pre_battle_scene
  def pre_battle_scene
    Graphics.update
    Graphics.freeze
    @spriteset.dispose_characters
    BattleManager.save_bgm_and_bgs
    
    @bgm_volume = RNDM_Battle_Themes::Battle_Theme_Volume
    @bgm_pitch  = RNDM_Battle_Themes::Battle_Theme_Pitch
    
    @bt = rand(5) + 1
    
    if @bt == 1
      @battle_bgm   = "Audio/BGM/" + RNDM_Battle_Themes::First_Random_Battle_Theme
      Audio.bgm_play(@battle_bgm, @bgm_volume, @bgm_pitch)
    elsif @bt == 2
      @battle_bgm   = "Audio/BGM/" + RNDM_Battle_Themes::Second_Random_Battle_Theme
      Audio.bgm_play(@battle_bgm, @bgm_volume, @bgm_pitch)
    elsif @bt == 3
      @battle_bgm   = "Audio/BGM/" + RNDM_Battle_Themes::Third_Random_Battle_Theme
      Audio.bgm_play(@battle_bgm, @bgm_volume, @bgm_pitch)
    elsif @bt == 4
      @battle_bgm   = "Audio/BGM/" + RNDM_Battle_Themes::Fourth_Random_Battle_Theme
      Audio.bgm_play(@battle_bgm, @bgm_volume, @bgm_pitch)      
    elsif @bt == 5
      @battle_bgm   = "Audio/BGM/" + RNDM_Battle_Themes::Fifth_Random_Battle_Theme
      Audio.bgm_play(@battle_bgm, @bgm_volume, @bgm_pitch)
    else #if something went wrong              
      BattleManager.play_battle_bgm
      Sound.play_battle_start
    end
      
    
    if $game_switches[RNDM_Battle_Themes::Boss_Battle_Event_Switch_ID] == true
      BattleManager.play_battle_bgm
      Sound.play_battle_start
    end
    
  end
end


__________________________
Go to the top of the page
 
+Quote Post
   
pudding
post Jul 22 2012, 12:13 PM
Post #7


Level 9
Group Icon

Group: Revolutionary
Posts: 140
Type: Writer
RM Skill: Intermediate




Thank you so much!


__________________________
""
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 04:34 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker