Advertisement
Guest User

XS - Battle Audio

a guest
Apr 5th, 2012
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.09 KB | None | 0 0
  1. #==============================================================================
  2. #   XaiL System - Battle Audio
  3. #   Author: Nicke
  4. #   Created: 03/04/2012
  5. #   Edited: 03/04/2012
  6. #   Version: 1.0
  7. #==============================================================================
  8. # Instructions
  9. # -----------------------------------------------------------------------------
  10. # To install this script, open up your script editor and copy/paste this script
  11. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  12. #
  13. # This small scripts enables a randomized SE, BGM and ME to be played upon
  14. # entering battle.
  15. #
  16. # Note! Randomize will only work if you don't have a selected audio file in
  17. # the database for Battle, Battle Start or Battle End.
  18. #
  19. # Script can be enabled/disabled using a switch ingame.
  20. #
  21. # *** Only for RPG Maker VX Ace. ***
  22. #==============================================================================
  23. ($imported ||= {})["XAIL-BATTLE-AUDIO"] = true
  24.  
  25. module XAIL
  26.   module BATTLE_AUDIO
  27.   #--------------------------------------------------------------------------#
  28.   # * Settings
  29.   #--------------------------------------------------------------------------#
  30.     # Randomized switch enabler/disabler.
  31.     # Use this ingame if you wish to disable this script. Can be useful if you
  32.     # wish to select a specific audio for a battle.
  33.     # RAND_SWITCH = switch_id
  34.     RAND_SWITCH = 11
  35.  
  36.     # Battle start SE.
  37.     # RAND_BATTLE_SND = [name, volume, pitch]
  38.     RAND_BATTLE_SND = []
  39.     RAND_BATTLE_SND[0] = ["Battle1", 80, 100]
  40.     RAND_BATTLE_SND[1] = ["Battle2", 80, 100]
  41.     RAND_BATTLE_SND[2] = ["Battle3", 80, 100]
  42.    
  43.     # Battle BGM.
  44.     # RAND_BATTLE_BGM = [name, volume, pitch]
  45.     RAND_BATTLE_BGM = []
  46.     RAND_BATTLE_BGM[0] = ["Battle1", 80, 100]
  47.     RAND_BATTLE_BGM[1] = ["Battle2", 80, 100]
  48.     RAND_BATTLE_BGM[2] = ["Battle3", 80, 100]
  49.     RAND_BATTLE_BGM[3] = ["Battle4", 80, 100]
  50.     RAND_BATTLE_BGM[4] = ["Battle5", 80, 100]
  51.    
  52.     # Battle victory ME.
  53.     # RAND_BATTLE_ME = [name, volume, pitch]
  54.     RAND_BATTLE_ME = []
  55.     RAND_BATTLE_ME[0] = ["Victory1", 80, 100]
  56.     RAND_BATTLE_ME[1] = ["Victory2", 80, 100]
  57.   end
  58. end
  59. # *** Don't edit below unless you know what you are doing. ***
  60. #==============================================================================#
  61. # ** Module Sound
  62. #==============================================================================#
  63. class << Sound
  64.  
  65.   alias xail_snd_battle_start play_battle_start
  66.   def play_battle_start(*args, &block)
  67.     # // Method self.play_battle_start.
  68.     xail_snd_battle_start(*args, &block)
  69.     rand_snd = rand(XAIL::BATTLE_AUDIO::RAND_BATTLE_SND.size)
  70.     return play_system_sound(7) if $game_switches[XAIL::BATTLE_AUDIO::RAND_SWITCH]
  71.     # If no audio is selected in database do randomize otherwise use default method.
  72.     unless $data_system.sounds[7].name == ""
  73.       play_system_sound(7)
  74.     else
  75.        play_random_battle_sound(rand_snd)
  76.     end
  77.   end
  78.  
  79.   def play_random_battle_sound(id)
  80.     # // New method to play a random sound when entering battle.
  81.     se = XAIL::BATTLE_AUDIO::RAND_BATTLE_SND
  82.     RPG::SE.new(se[id][0], se[id][1], se[id][2]).play
  83.   end
  84.  
  85. end
  86. #==============================================================================#
  87. # ** Module BattleManager
  88. #==============================================================================#
  89. class << BattleManager
  90.  
  91.   alias xail_bgm_battle_start play_battle_bgm
  92.   def play_battle_bgm(*args, &block)
  93.     # // Method self.play_battle_bgm.
  94.     xail_bgm_battle_start(*args, &block)
  95.     rand_snd = rand(XAIL::BATTLE_AUDIO::RAND_BATTLE_BGM.size)
  96.     return $game_system.battle_bgm.play if $game_switches[XAIL::BATTLE_AUDIO::RAND_SWITCH]
  97.     # If no audio is selected in database do randomize otherwise use default method.
  98.     unless $game_system.battle_bgm.name == ""
  99.       $game_system.battle_bgm.play
  100.     else
  101.       play_random_battle_bgm(rand_snd)
  102.     end
  103.     RPG::BGS.stop
  104.   end
  105.  
  106.   def play_random_battle_bgm(id)
  107.     # // New method to play a random bgm.
  108.     bgm = XAIL::BATTLE_AUDIO::RAND_BATTLE_BGM
  109.     RPG::BGM.new(bgm[id][0], bgm[id][1], bgm[id][2]).play
  110.   end
  111.  
  112.   alias xail_play_battle_end play_battle_end_me
  113.   def play_battle_end_me(*args, &block)
  114.     # // Method self.play_battle_end_me.
  115.     xail_play_battle_end(*args, &block)
  116.     rand_snd = rand(XAIL::BATTLE_AUDIO::RAND_BATTLE_ME.size)
  117.     return $game_system.battle_end_me.play if $game_switches[XAIL::BATTLE_AUDIO::RAND_SWITCH]
  118.     # If no audio is selected in database do randomize otherwise use default method.
  119.     unless $game_system.battle_end_me.name == ""
  120.       $game_system.battle_end_me.play
  121.     else
  122.       play_random_battle_me(rand_snd)
  123.     end
  124.   end
  125.  
  126.   def play_random_battle_me(id)
  127.     # // New method to play a random me.
  128.     me = XAIL::BATTLE_AUDIO::RAND_BATTLE_ME
  129.     RPG::ME.new(me[id][0], me[id][1], me[id][2]).play
  130.   end
  131.  
  132. end # END OF FILE
  133.  
  134. #=*==========================================================================*=#
  135. # ** END OF FILE
  136. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement