iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
 
Closed TopicStart new topic
> Random Battle-BGM
Rating 4 V
ERZENGEL
post Feb 3 2008, 08:58 PM
Post #1



Group Icon


Type: Undisclosed




  1. Description
    With the help of this small script you can set a number of audio files. One of them will select at the beginning of a battle and used as a battle-BGM. This happens randomly and brings a little variety to the battle.

  2. Skript
    CODE
    #==========================================================================
    # ** Random Battle-BGM 1.02 (by ERZENGEL)
    #==========================================================================

    #==========================================================================
    # * Game_Map
    #==========================================================================
    class Game_Map
      
      attr_accessor :rbm
      attr_accessor :rbmfiles
      
      alias erz_rbm_initialize initialize
      def initialize
        # The names of the audiofiles (they must be in the BGM-folder!)
        @rbmfiles = ["Battle1", "Battle2", "Battle3","Battle4"]
        # TRUE if script should be active / FALSE if script should be inactive
        @rbm = true
        erz_rbm_initialize
      end
      
    end
    #==========================================================================
    # * Scene_Map
    #==========================================================================
    class Scene_Map

      alias erz_rbm_callbattle call_battle
      def call_battle
        rbmoff = $data_system.battle_bgm.name.clone
        if $game_map.rbm
          audio = rand($game_map.rbmfiles.size)
          $data_system.battle_bgm.name = $game_map.rbmfiles[audio]
        end
        erz_rbm_callbattle
        $data_system.battle_bgm.name = rbmoff.clone
      end

    end

  3. Guide
    The variable $game_map.rbmusic can be assigned audiofiles. The files must be in the BGM folder and seperated by a comma. Don't forget the quotation marks if you add a file!
    With the global variable $game_map.rbm you can specify whether the script should be used. If you want do disable the script e.g. for a Boss battle, you proceed like this:
    CODE
    $game_map.rbm = false
    To enable:
    CODE
    $game_map.rbm = true
    This can be done in the script or in the eventscript.

  4. Final word
    The script isn't a masterpiece but in any case it will take a little bit of variety into the game and it isn't always the same Battle-BGM used. If you found an error, please write it in this topic. Who wants to praise me for this can do it in this topic too wink.gif


This post has been edited by ERZENGEL: Mar 7 2008, 12:20 PM
Go to the top of the page
 
+Quote Post
   
Rabu
post Feb 4 2008, 11:45 AM
Post #2



Group Icon






I'll praise you for that nifty little script, old fellow *g*

Nicely done. Maybe it could be done depending on the strength of the monster. The tougher the monster (group), the more dramatical the BGM. Just an idea so far.

This post has been edited by Rabu: Feb 4 2008, 11:56 AM


--------------------
Greetz, Rabu
Go to the top of the page
 
+Quote Post
   
Jasonicus
post Feb 4 2008, 11:31 PM
Post #3


Old Friend
Group Icon


Type: Writer
Alignment: Chaotic Neutral




I like this idea. Very cool. I plan to use it in a future game if possible.


--------------------
Trailer for It Came From Yesterday: Click Me

This was made by a dear friend of mine. Any support is appreciated! Also, Like the Facebook page while you're at it: It Came From Yesterday

New and improved official site: ICFY

Swagbucks referral link: http://www.swagbucks.com/refer/jbart321
Go to the top of the page
 
+Quote Post
   
raguel
post Feb 6 2008, 09:22 PM
Post #4



Group Icon


Type: Undisclosed




thats one of best scripts imo- it should be implemented by default :/
Go to the top of the page
 
+Quote Post
   
Shixx
post Feb 7 2008, 08:08 AM
Post #5



Group Icon


Type: Coder




well damn, lol I just finished making my own script for this. I guess I should've looked here first sleep.gif


--------------------
<
Go to the top of the page
 
+Quote Post
   
Jumbo
post Feb 7 2008, 04:21 PM
Post #6


Highest and Lowest of all Nigel
Group Icon


Type: Designer




Nice script!
I'll probably use it someday wink.gif


--------------------

Hello, I am jumbo!
As you can see, I don't post in RMVX related threads (well, sometimes...).
That's because I don't like VX, I'm staying here just because of some friends I met.
So, you'll only see me in the Fun&Games forum.


Go to the top of the page
 
+Quote Post
   
hpwong87
post Feb 12 2008, 06:08 PM
Post #7



Group Icon


Type: Spriter




nice that definitely would make battles more interesting


--------------------
IPB Image
Go to the top of the page
 
+Quote Post
   
Kirbysuperstar
post Mar 6 2008, 01:10 AM
Post #8



Group Icon






Awesome script. The only qualm I have with it is the random factor. It uh, tends to repeat a lot. Is it feasible to write it so that it randomly picks one of the songs, but doesn't play that same song again until all the others have played?
Go to the top of the page
 
+Quote Post
   
Ky the Black Cat
post May 1 2008, 10:51 AM
Post #9


Resident Kitty
Group Icon


Type: Writer




Many thanks. I've wantd to use three random battle tunes and now instead of setting them via events every so often, this will be much simpler.

Have a cookie!


--------------------
» Click to show Spoiler - click again to hide... «


Go to the top of the page
 
+Quote Post
   
Equilibrium Keep...
post May 20 2008, 08:26 PM
Post #10



Group Icon


Type: Coder




It is problematic to carry out, as in RPGMaker VX monsters do not have parameter "level". It is necessary to calculate in the beginning it proceeding from other parameters of the monster.
For example:
CODE
@level = (100*$data_enemies[@enemy_id].maxhp/27000 + 100*$data_enemies[@enemy_id].atk/360 + 100*$data_enemies[@enemy_id].def/225 + 100*$data_enemies[@enemy_id].spi/240 + 100*$data_enemies[@enemy_id].agi/225)/5
Go to the top of the page
 
+Quote Post
   
Equilibrium Keep...
post May 20 2008, 10:33 PM
Post #11



Group Icon


Type: Coder




Has edited a script. Now it calculates a level of the strongest enemy in group then chooses a casual composition of that are fixed to an interval of levels in which the enemy gets.

At once I wish to warn:
1. I do not know English.
2. I am not able to program.
3. It is my first script on RGSS.
From here a conclusion: For bad English and a curve code slippers to not beat!

Ittadakimase:

CODE
#==========================================================================
# ** Random Battle-BGM 1.02 (by ERZENGEL)
#--------------------------------------------------------------------------
# ** Modified by Equilibrium Keeper 1.01
#==========================================================================

#==========================================================================
# * Game_Map
#==========================================================================
class Game_Map
  
  attr_accessor :rbm
  attr_accessor :rbmfiles
  
  alias erz_rbm_initialize initialize
  def initialize
    # The names of the audiofiles (they must be in the BGM-folder!)
    @rbmfiles = [
      ["Battle1", "Battle2"],
      ["Battle3", "Battle4"],
      ["Battle5", "Battle6"],
      ["Battle7", "Battle8"],
      ["Battle9", "Battle10"]]
    # TRUE if script should be active / FALSE if script should be inactive
    @rbm = true
    erz_rbm_initialize
  end
  
end
#==========================================================================
# * Scene_Map
#==========================================================================
class Scene_Map

  alias erz_rbm_callbattle call_battle
  def call_battle
    # Initialize
    @enemy_mhp = [] # Enemies HP
    @enemy_atk = [] # Enemies Attack
    @enemy_def = [] # Enemies Defence
    @enemy_spi = [] # Enemies Spirit
    @enemy_agi = [] # Enemies Agility
    @level     = [] # Enemies Levels
    @musicpack = $game_map.rbmfiles # Random music packs
        
    # Collect parameters of all enemies from base
    for i in 1..$data_enemies.size-1      
      @enemy_mhp[i] = $data_enemies[i].maxhp
      @enemy_atk[i] = $data_enemies[i].atk
      @enemy_def[i] = $data_enemies[i].def
      @enemy_spi[i] = $data_enemies[i].spi
      @enemy_agi[i] = $data_enemies[i].agi
    end
    
    # Calculate a level of monsters in group
    for i in 0..$game_troop.members.size-1      
      @enemy_id = $game_troop.members[i].enemy_id
      @level[i] = (100*$data_enemies[@enemy_id].maxhp/@enemy_mhp.max + 100*$data_enemies[@enemy_id].atk/@enemy_atk.max + 100*$data_enemies[@enemy_id].def/@enemy_def.max + 100*$data_enemies[@enemy_id].spi/@enemy_spi.max + 100*$data_enemies[@enemy_id].agi/@enemy_agi.max)/5
    end
        
    rbmoff = $data_system.battle_bgm.name.clone
    if $game_map.rbm
      # Check value of a level of the strongest enemy then the corresponding music pack is fastened
      case @level.max
        when 0..20
          audio = rand(@musicpack[0].size)
          $data_system.battle_bgm.name = @musicpack[0][audio]
        when 21..40
          audio = rand(@musicpack[1].size)
          $data_system.battle_bgm.name = @musicpack[1][audio]
        when 41..60
          audio = rand(@musicpack[2].size)
          $data_system.battle_bgm.name = @musicpack[2][audio]
        when 61..80
          audio = rand(@musicpack[3].size)
          $data_system.battle_bgm.name = @musicpack[3][audio]
        when 81..100
          audio = rand(@musicpack[4].size)
          $data_system.battle_bgm.name = @musicpack[4][audio]
      end
    end
    erz_rbm_callbattle
    $data_system.battle_bgm.name = rbmoff.clone
  end

end


This post has been edited by Equilibrium Keeper: May 21 2008, 10:02 AM
Go to the top of the page
 
+Quote Post
   
anh vo
post Mar 27 2009, 12:54 PM
Post #12



Group Icon


Type: Undisclosed




Nice code. But it will better if you add some these options:
1. User want to enable random battle BGM only for random troops battle.
2. ... I have not thought yet tongue.gif
Go to the top of the page
 
+Quote Post
   
makryu
post Mar 27 2009, 01:36 PM
Post #13


What can change the nature of a man?
Group Icon


Type: Writer
Alignment: Lawful Neutral




I have a suggestion for this: implement a feature that allows the selected battle BGM to be tied to specific areas/enemies/troops. There could be some specific code after an area's name to define in the script which theme to play. Likewise, there could be a code after troop names or comments in enemy notes to accomplish the same thing.


--------------------

Take a look at the recruitment thread for my project! You know you want to...
Go to the top of the page
 
+Quote Post
   
Kirbysuperstar
post Mar 30 2009, 05:57 AM
Post #14



Group Icon






You can do that with events, y'know. Just make a Script event command like this:

CODE
$game_map.rbmusic = ["bgm_battle_1_1",
"bgm_battle_1_2", "bgm_battle_3_1",
"bgm_battle_3_2", "bgm_battle_4_1",
"bgm_battle_4_2"]


Then just set it to parallel when you enter the area or whatever.
Go to the top of the page
 
+Quote Post
   
makryu
post Mar 30 2009, 07:58 AM
Post #15


What can change the nature of a man?
Group Icon


Type: Writer
Alignment: Lawful Neutral




Maybe I'm forgetting something, but wouldn't then I need to activate the common event through some local event? That would be pretty much kill what I'm planning, as my idea was to use this to set up different battle themes for each region of my world map, that's why I wouldn't be able to depend on the player activating some switch.


--------------------

Take a look at the recruitment thread for my project! You know you want to...
Go to the top of the page
 
+Quote Post
   
Kirbysuperstar
post Mar 30 2009, 09:17 AM
Post #16



Group Icon






Probably, but honestly, there's no easy way to do what you want. Uh.. only way I can think of would be to use the "monster level" modification a few posts up, make Map Areas for each region and work it that way. Either that or design the entrances to each region in such a way that there's only a few spots to enter from, and thus you don't have twenty-odd event tiles lined up just to change the BGM.
Go to the top of the page
 
+Quote Post
   
bulletxt
post Apr 5 2009, 01:12 PM
Post #17


bullet inside me
Group Icon


Type: Coder
Alignment: Unaligned




QUOTE (makryu @ Mar 30 2009, 08:58 AM) *
Maybe I'm forgetting something, but wouldn't then I need to activate the common event through some local event? That would be pretty much kill what I'm planning, as my idea was to use this to set up different battle themes for each region of my world map, that's why I wouldn't be able to depend on the player activating some switch.



QUOTE (Kirbysuperstar @ Mar 30 2009, 10:17 AM) *
Probably, but honestly, there's no easy way to do what you want. Uh.. only way I can think of would be to use the "monster level" modification a few posts up, make Map Areas for each region and work it that way. Either that or design the entrances to each region in such a way that there's only a few spots to enter from, and thus you don't have twenty-odd event tiles lined up just to change the BGM.


You can avoid having events for changing BGM by simply using the following script: Do $something if inside an Area! It will turn a switch ON when inside an area and turn it off when out of it. You can get it: here .

This post has been edited by bulletxt: Apr 5 2009, 01:12 PM


--------------------
Working on the following games: Lodestone2d , World Truck Racing
Go to the top of the page
 
+Quote Post
   
supershadowmarti...
post Jan 11 2011, 03:59 PM
Post #18



Group Icon


Type: Designer
Alignment: Chaotic Good




I have a well not a problem as such.
I like havig the random battle bgm but I each time I put a event for a boss like "Change Battle bgm" to a boss music then after the boss is over and done with I want the random Battle bgm to resume but each time I go into a batte the boss theme what I chose for the boss plays instead of the random Batte bgm.


--------------------
If we SURPOSED to evole from monkeys then why is there still monkeys left on the planet?


Click here to level up my card!
Go to the top of the page
 
+Quote Post
   
KleptoLizard
post Jan 19 2011, 02:52 AM
Post #19



Group Icon


Type: Undisclosed




Nice.
Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 2nd September 2014 - 10:49 PM

RPGMakerVX.net is an Privacy Policy, Legal.