Advertisement
CompanionWulf

Map Music in Battles Scriptlet (RGSS/RMXP)

Mar 6th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 13.53 KB | None | 0 0
  1. =begin
  2. ╔══════════════════════════════════════════════════════════════════════════════╗
  3. ║ Map Music in Battles Scriptlet                                               ║
  4. ╟──────────────────────────────────────────────────────────────────────────────╢
  5. ║   Version       : 1.0                                                        ║
  6. ║   Author        : Companion Wulf                                             ║
  7. ║   Platforms     : RMXP                                                       ║
  8. ║   Release Date  : 7 March 2015                                               ║
  9. ║   Last Update   : 7 March 2015                                               ║
  10. ║   Demo Version  : N/A                                                        ║
  11. ║   Demo Date     : Unreleased                                                 ║
  12. ║   Website       : http://rpgmakertimes.info                                  ║
  13. ║   Blog          : http://blog.rpgmakertimes.info                             ║
  14. ║                                                                              ║
  15. ╠══════════════════════════════════════════════════════════════════════════════╣
  16. ║ ◄ DESCRIPTION ►                                                              ║
  17. ╟──────────────────────────────────────────────────────────────────────────────╢
  18. ║     This scriptlet enables the current  map BGM to play throughout           ║
  19. ║     battles without pausing,  disabling the battle BGM and victory           ║
  20. ║     ME completely.                                                           ║
  21. ║                                                                              ║
  22. ╠══════════════════════════════════════════════════════════════════════════════╣
  23. ║ ◄ INSTALLATION ►                                                             ║
  24. ╟──────────────────────────────────────────────────────────────────────────────╢
  25. ║     Place the scriptlet above "Main".                                        ║
  26. ║                                                                              ║
  27. ╠══════════════════════════════════════════════════════════════════════════════╣
  28. ║ ◄ INSTRUCTIONS ►                                                             ║
  29. ╟──────────────────────────────────────────────────────────────────────────────╢
  30. ║     Import  all  parallax  graphics  into the  Graphics/Parallaxes           ║
  31. ║     Set  BATTLE_MUSIC to "false" to enable the  map BGM to play in           ║
  32. ║     battles. Setting it to "true" will reenable it.                          ║
  33. ║                                                                              ║
  34. ║     To toggle it on or off during the game you can use the follow-           ║
  35. ║     ing either in a script or Script event command:                          ║
  36. ║                                                                              ║
  37. ║         $game_battle_bgm.battle_music = true/false                           ║
  38. ║                                                                              ║
  39. ╠══════════════════════════════════════════════════════════════════════════════╣
  40. ║ ◄ DEVELOPMENT NOTES ►                                                        ║
  41. ╟──────────────────────────────────────────────────────────────────────────────╢
  42. ║     This scriptlet was inspired by a question on Yahoo! Answers.             ║
  43. ║                                                                              ║
  44. ║       https://ca.answers.yahoo.com/question/index?qid=20150225050638AAmsjt3  ║
  45. ║                                                                              ║
  46. ╠══════════════════════════════════════════════════════════════════════════════╣
  47. ║ ◄ COMPATIBILITY ISSUES ►                                                     ║
  48. ╟──────────────────────────────────────────────────────────────────────────────╢
  49. ║     There may be  incompatibility issues with  scripts that affect           ║
  50. ║     the post-battle phase.  Aside from that  I don't see any other           ║
  51. ║     problems.                                                                ║
  52. ║                                                                              ║
  53. ╠══════════════════════════════════════════════════════════════════════════════╣
  54. ║ ◄ METHODS AFFECTED ►                                                         ║
  55. ╟──────────────────────────────────────────────────────────────────────────────╢
  56. ║     ● New Methods                                                            ║
  57. ║     ● Aliased Methods                                                        ║
  58. ║       ● Game_Map:                                                            ║
  59. ║         ○ main                                                               ║
  60. ║    ● Overwritten Methods                                                     ║
  61. ║       ● Scene_Map:                                                           ║
  62. ║         ○ call_battle                                                        ║
  63. ║       ● Scene_Battle:                                                        ║
  64. ║         ○ start_phase5                                                       ║
  65. ║                                                                              ║
  66. ╠══════════════════════════════════════════════════════════════════════════════╣
  67. ║ ◄ FUTURE UPDATES ►                                                           ║
  68. ╟──────────────────────────────────────────────────────────────────────────────╢
  69. ║   ● No future updates are planned.                                           ║
  70. ║                                                                              ║
  71. ╠══════════════════════════════════════════════════════════════════════════════╣
  72. ║ ◄ VERSION HISTORY ►                                                          ║
  73. ╟──────────────────────────────────────────────────────────────────────────────╢
  74. ║   v1.0 (07-Mar-2015)                                                         ║
  75. ║     ● Began/Finished scriptlet                                               ║
  76. ║                                                                              ║
  77. ╚══════════════════════════════════════════════════════════════════════════════╝
  78. =end
  79.  
  80. $imported = {} if $imported == nil; $imported["CW-MapMusicBattles"] = true
  81.  
  82. #==============================================================================
  83. # ** Battle_Music
  84. #==============================================================================
  85. class Battle_Music
  86.   attr_accessor :battle_music
  87.   def initialize
  88.     @battle_music = false
  89.   end
  90. end
  91.  
  92. #==============================================================================
  93. # ** Scene_Title
  94. #==============================================================================
  95. class Scene_Title
  96.   #--------------------------------------------------------------------------
  97.   # * Main Processing
  98.   #--------------------------------------------------------------------------
  99.   alias cw_mmibs_main main
  100.   def main
  101.     cw_mmibs_main
  102.     $game_battle_bgm = Battle_Music.new
  103.   end
  104. end
  105.  
  106. #==============================================================================
  107. # ** Scene_Map
  108. #==============================================================================
  109. class Scene_Map
  110.   #--------------------------------------------------------------------------
  111.   # * Battle Call
  112.   #--------------------------------------------------------------------------
  113.   def call_battle
  114.     # Clear battle calling flag
  115.     $game_temp.battle_calling = false
  116.     # Clear menu calling flag
  117.     $game_temp.menu_calling = false
  118.     $game_temp.menu_beep = false
  119.     # Make encounter count
  120.     $game_player.make_encounter_count
  121.     # Memorize map BGM and stop BGM
  122.     $game_temp.map_bgm = $game_system.playing_bgm
  123.     if $game_battle_bgm.battle_music
  124.       $game_system.bgm_stop
  125.       # Play battle start SE
  126.       $game_system.se_play($data_system.battle_start_se)
  127.       # Play battle BGM
  128.       $game_system.bgm_play($game_system.battle_bgm)
  129.     end
  130.     # Straighten player position
  131.     $game_player.straighten
  132.     # Switch to battle screen
  133.     $scene = Scene_Battle.new
  134.   end
  135. end
  136.  
  137. #==============================================================================
  138. # ** Scene_Battle (part 2)
  139. #==============================================================================
  140.  
  141. class Scene_Battle
  142.   #--------------------------------------------------------------------------
  143.   # * Start After Battle Phase
  144.   #--------------------------------------------------------------------------
  145.   def start_phase5
  146.     # Shift to phase 5
  147.     @phase = 5
  148.     # Play battle end ME
  149.     $game_system.me_play($game_system.battle_end_me) if $game_battle_bgm.battle_music#BATTLE_MUSIC
  150.     # Return to BGM before battle started
  151.     $game_system.bgm_play($game_temp.map_bgm)
  152.     # Initialize EXP, amount of gold, and treasure
  153.     exp = 0
  154.     gold = 0
  155.     treasures = []
  156.     # Loop
  157.     for enemy in $game_troop.enemies
  158.       # If enemy is not hidden
  159.       unless enemy.hidden
  160.         # Add EXP and amount of gold obtained
  161.         exp += enemy.exp
  162.         gold += enemy.gold
  163.         # Determine if treasure appears
  164.         if rand(100) < enemy.treasure_prob
  165.           if enemy.item_id > 0
  166.             treasures.push($data_items[enemy.item_id])
  167.           end
  168.           if enemy.weapon_id > 0
  169.             treasures.push($data_weapons[enemy.weapon_id])
  170.           end
  171.           if enemy.armor_id > 0
  172.             treasures.push($data_armors[enemy.armor_id])
  173.           end
  174.         end
  175.       end
  176.     end
  177.     # Treasure is limited to a maximum of 6 items
  178.     treasures = treasures[0..5]
  179.     # Obtaining EXP
  180.     for i in 0...$game_party.actors.size
  181.       actor = $game_party.actors[i]
  182.       if actor.cant_get_exp? == false
  183.         last_level = actor.level
  184.         actor.exp += exp
  185.         if actor.level > last_level
  186.           @status_window.level_up(i)
  187.         end
  188.       end
  189.     end
  190.     # Obtaining gold
  191.     $game_party.gain_gold(gold)
  192.     # Obtaining treasure
  193.     for item in treasures
  194.       case item
  195.       when RPG::Item
  196.         $game_party.gain_item(item.id, 1)
  197.       when RPG::Weapon
  198.         $game_party.gain_weapon(item.id, 1)
  199.       when RPG::Armor
  200.         $game_party.gain_armor(item.id, 1)
  201.       end
  202.     end
  203.     # Make battle result window
  204.     @result_window = Window_BattleResult.new(exp, gold, treasures)
  205.     # Set wait count
  206.     @phase5_wait_count = 100
  207.   end
  208. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement