bgillisp

Battle Music Control

Oct 21st, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. # Script: Battle Music Control
  2. # By: Bgillisp, using code from DiamondandPlatium3's Ruby tutorials
  3. # Released: 10/21/2014
  4.  
  5. # This code lets you turn off the battle music by turning a
  6. # switch off. Turn it on to return to the default.
  7. #
  8. # In addition, you can use the notetag:
  9. #
  10. # <Battle Theme: x>
  11. #
  12. # on a monster, and it will play that theme if the monster is in
  13. # the troop you are fighting. In the event of multiple tags,
  14. # the last found tag should be loaded
  15.  
  16. # Make sure to spell the name of the theme exactly as it is in
  17. # the sound test and resource manager. Otherwise it will fail
  18. # to find it.
  19.  
  20. # Terms of use: Since this script is mainly modified code
  21. # from DiamondandPlatium3's tutorial videos, I do not claim onwership
  22. # of the code, as all I did was put it all in one script to use.
  23. #
  24. # Therefore, the terms of use are the same as DiamondandPlatium3's
  25. # scripts, since it is based on his work. His terms of use can be
  26. # found here:
  27. #
  28. # http://www.diamondandplatinum3.net/rpg-maker-scripts/terms-of-use/
  29.  
  30. #-----------------------------------------------------------------------
  31. #Editable Region
  32.  
  33. module BGBattleMusic
  34.  
  35. #Value of the switch to turn on when you want the battle music to play.
  36. BattleMusicSwitch = 101
  37.  
  38. end
  39.  
  40. #End of Editable Region
  41. #-----------------------------------------------------------------------
  42. #Do not edit anything below this line unless you know what you are doing.
  43. #Failure to ahead to this could result in unpreditable behavior in the game
  44. #or the game crashing on you.
  45.  
  46. module BattleManager
  47.  
  48. class << self
  49.  
  50. #Overwritten Method, play_battle_bgm
  51. def play_battle_bgm
  52.  
  53. #If the switch is on, play the battle bgm. If not, ignore and stay
  54. #with the map music.
  55. if($game_switches[BGBattleMusic::BattleMusicSwitch] == true)
  56. $game_system.battle_bgm.play
  57. RPG::BGS.stop
  58.  
  59. #Check for notetags on the enemy to play a custom theme
  60. $game_troop.members.each do |enemy|
  61. $data_enemies[enemy.enemy_id].note[/<Battle Theme:\s*(\w+)>/im]
  62. if $1 && $1 != ""
  63. RPG::BGM.new($1, 100, 100).play
  64. end
  65. end
  66.  
  67. end #End if statement
  68.  
  69. end #End def play_battle_bgm
  70.  
  71. end #End class
  72.  
  73. end #End Module
Advertisement
Add Comment
Please, Sign In to add comment