mcgluszak

Muzyka w menu pauzy

Feb 19th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.12 KB | None | 0 0
  1. ################
  2. # KONFIGURACJA #
  3. ################
  4.  
  5. module Gluszak
  6.   Menu_BGM = '012-Theme01'
  7. end
  8.  
  9. class Scene_Map
  10.   alias :fmodex_old_map_call_menu :call_menu unless $@
  11.   def call_menu
  12.     $game_temp.map_bgm_pos = FMod.bgm_position
  13.     $game_temp.map_bgs_pos = FMod.bgs_position
  14.     $game_temp.map_bgm = $game_system.playing_bgm
  15.     $game_temp.map_bgs = $game_system.playing_bgs
  16.     fmodex_old_map_call_menu
  17.     $game_system.bgm_fade 0.2
  18.     $game_system.bgs_fade 0.2
  19.     bgm = RPG::AudioFile.new(Gluszak::Menu_BGM)
  20.     $game_system.bgm_play(bgm)
  21.   end
  22. end
  23.  
  24. class Scene_Menu
  25.   alias :fmodex_old_main :main unless $@
  26.   def main
  27.     fmodex_old_main
  28.     if $scene.is_a? Scene_Map
  29.       $game_system.bgm_fade 0.2
  30.       $game_system.bgm_play($game_temp.map_bgm, $game_temp.map_bgm_pos)
  31.       $game_system.bgs_play($game_temp.map_bgs, $game_temp.map_bgs_pos)
  32.     end
  33.   end
  34. end
  35.  
  36. class Game_System
  37.   #--------------------------------------------------------------------------
  38.   # * Play Background Music
  39.   #     bgm : background music to be played
  40.   #--------------------------------------------------------------------------
  41. ############################################################################
  42. #   ADDED pos (POSITION) AS PARAMETER TO METHOD
  43. ############################################################################
  44.   def bgm_play(bgm, pos = 0)
  45.     @playing_bgm = bgm
  46.     if bgm != nil and bgm.name != ""
  47.       Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch, pos)
  48. ############################################################################
  49.     else
  50.       Audio.bgm_stop
  51.     end
  52.     Graphics.frame_reset
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # * Memorize Background Music
  56.   #--------------------------------------------------------------------------
  57.   alias :fmodex_old_system_bgm_memorize :bgm_memorize unless $@
  58.   def bgm_memorize
  59.     fmodex_old_system_bgm_memorize
  60.     @bgm_memorized_position = FMod::bgm_position
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # * Restore Background Music
  64.   #--------------------------------------------------------------------------
  65.   def bgm_restore
  66. ############################################################################
  67. #   ADDED @bgm_memorized_position AS PARAMETER TO METHOD
  68. ############################################################################
  69.     bgm_play(@memorized_bgm, @bgm_memorized_position)
  70. ############################################################################
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # * Play Background Sound
  74.   #     bgs : background sound to be played
  75.   #--------------------------------------------------------------------------
  76. ############################################################################
  77. #   ADDED pos (POSITION) AS PARAMETER TO METHOD
  78. ############################################################################
  79.   def bgs_play(bgs, pos = 0)
  80.     @playing_bgs = bgs
  81.     if bgs != nil and bgs.name != ""
  82.       Audio.bgs_play("Audio/BGS/" + bgs.name, bgs.volume, bgs.pitch, pos)
  83. ############################################################################
  84.     else
  85.       Audio.bgs_stop
  86.     end
  87.     Graphics.frame_reset
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # * Stop Background Sound
  91.   #--------------------------------------------------------------------------
  92.   def bgs_stop
  93.     @playing_bgs = nil
  94.     Audio.bgs_stop
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # * Memorize Background Sound
  98.   #--------------------------------------------------------------------------
  99.   alias :fmodex_old_system_bgs_memorize :bgs_memorize unless $@
  100.   def bgs_memorize
  101.     fmodex_old_system_bgs_memorize
  102.     @bgs_memorized_position = FMod::bgs_position
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # * Restore Background Sound
  106.   #--------------------------------------------------------------------------
  107.   def bgs_restore
  108. ############################################################################
  109. #   ADDED @bgs_memorized_position AS PARAMETER TO METHOD
  110. ############################################################################
  111.     bgs_play(@memorized_bgs, @bgs_memorized_position)
  112. ############################################################################
  113.   end
  114. end
  115.  
  116. class Game_Temp
  117.   attr_accessor :map_bgm_pos
  118.   attr_accessor :map_bgs_pos
  119.   attr_accessor :map_bgs
  120.   alias :fmodex_old_temp_initialize :initialize unless $@
  121.   def initialize
  122.     fmodex_old_temp_initialize
  123.     @map_bgm_pos = 0
  124.     @map_bgs = nil
  125.     @map_bgs_pos = 0
  126.    
  127.   end
  128. end
  129.  
  130. class Scene_Map
  131.   alias :fmodex_old_map_call_battle :call_battle unless $@
  132.   def call_battle
  133.     $game_temp.map_bgm_pos = FMod.bgm_position
  134.     fmodex_old_map_call_battle
  135.   end
  136. end
  137.  
  138. class Scene_Battle
  139.   def judge
  140.     # If all dead determinant is true, or number of members in party is 0
  141.     if $game_party.all_dead? or $game_party.actors.size == 0
  142.       # If possible to lose
  143.       if $game_temp.battle_can_lose
  144. ############################################################################
  145. #   ADDED $game_temp.map_bgm_pos AS 2ND PARAMETE TO bgm_play
  146. ############################################################################
  147.         # Return to BGM before battle starts
  148.         $game_system.bgm_play($game_temp.map_bgm, $game_temp.map_bgm_pos)
  149. ############################################################################        
  150.         # Battle ends
  151.         battle_end(2)
  152.         # Return true
  153.         return true
  154.       end
  155.       # Set game over flag
  156.       $game_temp.gameover = true
  157.       # Return true
  158.       return true
  159.     end
  160.     # Return false if even 1 enemy exists
  161.     for enemy in $game_troop.enemies
  162.       if enemy.exist?
  163.         return false
  164.       end
  165.     end
  166.     # Start after battle phase (win)
  167.     start_phase5
  168.     # Return true
  169.     return true
  170.   end
  171.  
  172.   def start_phase5
  173.     # Shift to phase 5
  174.     @phase = 5
  175. ############################################################################
  176. #   ADDED $game_temp.map_bgm_pos AS 2ND PARAMETE TO bgm_play
  177. #   AND SWITCHED PLAY ORDER SO BGM IS PLAYED FIRST
  178. ############################################################################
  179.     # Return to BGM before battle started
  180.     $game_system.bgm_play($game_temp.map_bgm, $game_temp.map_bgm_pos)
  181.     # Play battle end ME
  182.     $game_system.me_play($game_system.battle_end_me)
  183. ############################################################################
  184.     # Initialize EXP, amount of gold, and treasure
  185.     exp = 0
  186.     gold = 0
  187.     treasures = []
  188.     # Loop
  189.     for enemy in $game_troop.enemies
  190.       # If enemy is not hidden
  191.       unless enemy.hidden
  192.         # Add EXP and amount of gold obtained
  193.         exp += enemy.exp
  194.         gold += enemy.gold
  195.         # Determine if treasure appears
  196.         if rand(100) < enemy.treasure_prob
  197.           if enemy.item_id > 0
  198.             treasures.push($data_items[enemy.item_id])
  199.           end
  200.           if enemy.weapon_id > 0
  201.             treasures.push($data_weapons[enemy.weapon_id])
  202.           end
  203.           if enemy.armor_id > 0
  204.             treasures.push($data_armors[enemy.armor_id])
  205.           end
  206.         end
  207.       end
  208.     end
  209.     # Treasure is limited to a maximum of 6 items
  210.     treasures = treasures[0..5]
  211.     # Obtaining EXP
  212.     for i in 0...$game_party.actors.size
  213.       actor = $game_party.actors[i]
  214.       if actor.cant_get_exp? == false
  215.         last_level = actor.level
  216.         actor.exp += exp
  217.         if actor.level > last_level
  218.           @status_window.level_up(i)
  219.         end
  220.       end
  221.     end
  222.     # Obtaining gold
  223.     $game_party.gain_gold(gold)
  224.     # Obtaining treasure
  225.     for item in treasures
  226.       case item
  227.       when RPG::Item
  228.         $game_party.gain_item(item.id, 1)
  229.       when RPG::Weapon
  230.         $game_party.gain_weapon(item.id, 1)
  231.       when RPG::Armor
  232.         $game_party.gain_armor(item.id, 1)
  233.       end
  234.     end
  235.     # Make battle result window
  236.     @result_window = Window_BattleResult.new(exp, gold, treasures)
  237.     # Set wait count
  238.     @phase5_wait_count = 100
  239.   end
  240.  
  241.  
  242.   def update_phase5
  243.     # If wait count is larger than 0
  244.     if @phase5_wait_count > 0
  245.       # Decrease wait count
  246.       @phase5_wait_count -= 1
  247.       # If wait count reaches 0
  248.       if @phase5_wait_count == 0
  249.         # Show result window
  250.         @result_window.visible = true
  251.         # Clear main phase flag
  252.         $game_temp.battle_main_phase = false
  253.         # Refresh status window
  254.         @status_window.refresh
  255.       end
  256.       return
  257.     end
  258.     # If C button was pressed
  259.     if Input.trigger?(Input::C)
  260. ############################################################################
  261. #   REMOVED $game_system.play_bgm BECAUSE IT'S DONE AUTOMATICALLY
  262. #   WHEN ME IS DONE PLAYING
  263. ############################################################################
  264. ############################################################################
  265.       # Battle ends
  266.       battle_end(0)
  267.     end
  268.   end
  269. end
Advertisement
Add Comment
Please, Sign In to add comment