mcgluszak

Zmiana muzyki w menu/kontynuacja BGMa po bitwie v1.00

Feb 19th, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # Zmiana muzyki w menu/kontynuacja BGMa po bitwie
  3. #-=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=-=
  4. # Autorzy:
  5. #   Hiretsukan (Kevin Gadd) - [email protected]
  6. #   RPG/Cowlol (Firas Assad)
  7. #   ArePeeGee - AIM name
  8. #   mcgluszak (Andrzej Głuszak) - [email protected]
  9. #-=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=-=          
  10. # Wersja: 1.0
  11. #-=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=-=
  12. # Opis: Skrypt pozwala na zmienienie muzyki w menu i kontynuację poprzedniego
  13. #       BGMa i BGSa po powrocie na mapę oraz po zakończeniu bitwy.
  14. #-=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=-=
  15. # Instrukcja: Skopiuj z dema (http://www.hbgames.org/forums/viewtopic.php?t=55486)
  16. #             do projektu bibliotekę fmodex.dll oraz pierwszy skrypt ("FmodEX *")
  17. #             Ten skrypt wklej nad main.
  18. #-=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=-=
  19. # Kompatybilność: Nie testowany z SDK. Kontynuacja BGMa po bitwie może
  20. #                 nie działać z niektórymi CBS-ami.
  21. #-=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=-=
  22. # Licencja:
  23. #   Use of this script is subject to the permissive BSD-like license below.
  24. #   That basically means you could use it in any way you like as long
  25. #   as you keep the following copyright and license unchanged and available,
  26. #   and don't use name of copyright holder to promote products based on
  27. #   this software. Note, however, that this license only applies to the
  28. #   script, and not to the FMOD library. For more information about FMOD
  29. #   licenses consult FMOD website: http://www.fmod.org/index.php/sales
  30. #   It's free for non-commercial use, and they provide several types
  31. #   of licenses for different types of developers.
  32. #
  33. # Copyright (c) 2005, Kevin Gadd
  34. # All rights reserved.
  35. #
  36. # Redistribution and use in source and binary forms, with or without
  37. # modification, are permitted provided that the following conditions are met:
  38. #     * Redistributions of source code must retain the above copyright
  39. #       notice, this list of conditions and the following disclaimer.
  40. #     * Redistributions in binary form must reproduce the above copyright
  41. #       notice, this list of conditions and the following disclaimer in the
  42. #       documentation and/or other materials provided with the distribution.
  43. #     * The name of the contributors may not be used to endorse or promote
  44. #       products derived from this software without specific prior written
  45. #       permission.
  46. #
  47. # THIS SOFTWARE IS PROVIDED BY Kevin Gadd ''AS IS'' AND ANY
  48. # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  49. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  50. # DISCLAIMED. IN NO EVENT SHALL Kevin Gadd BE LIABLE FOR ANY
  51. # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  52. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  53. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  54. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  55. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  56. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  57. #-=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=--=-=-=-=-=-=
  58. # Zmiany: v1.0 (19.02.12) - wydanie skryptu
  59. # Starsza wersja: http://www.hbgames.org/forums/viewtopic.php?t=55486
  60. #==============================================================================
  61.  
  62. ################
  63. # KONFIGURACJA #
  64. ################
  65.  
  66. module Gluszak
  67.  
  68.   Zmiana_BGM_w_menu = true
  69.   Menu_BGM = '012-Theme01'
  70.   Kontynuacja_BGM_po_bitwie = true # może być niekompatybilne z CBS-ami
  71.  
  72. end
  73.  
  74. ##########
  75. # KONIEC #
  76. ##########
  77.  
  78.  
  79. #==============================================================================
  80. # ** Game_System
  81. #==============================================================================
  82. class Game_System
  83.   #--------------------------------------------------------------------------
  84.   # * Play Background Music
  85.   #--------------------------------------------------------------------------
  86.   def bgm_play(bgm, pos = 0)
  87.     @playing_bgm = bgm
  88.     if bgm != nil and bgm.name != ""
  89.       Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch, pos)
  90.     else
  91.       Audio.bgm_stop
  92.     end
  93.     Graphics.frame_reset
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # * Memorize Background Music
  97.   #--------------------------------------------------------------------------
  98.   alias :fmodex_old_system_bgm_memorize :bgm_memorize unless $@
  99.   def bgm_memorize
  100.     fmodex_old_system_bgm_memorize
  101.     @bgm_memorized_position = FMod::bgm_position
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # * Restore Background Music
  105.   #--------------------------------------------------------------------------
  106.   def bgm_restore
  107.     bgm_play(@memorized_bgm, @bgm_memorized_position)
  108.   end
  109.   #--------------------------------------------------------------------------
  110.   # * Play Background Sound
  111.   #     bgs : background sound to be played
  112.   #--------------------------------------------------------------------------
  113.   def bgs_play(bgs, pos = 0)
  114.     @playing_bgs = bgs
  115.     if bgs != nil and bgs.name != ""
  116.       Audio.bgs_play("Audio/BGS/" + bgs.name, bgs.volume, bgs.pitch, pos)
  117.     else
  118.       Audio.bgs_stop
  119.     end
  120.     Graphics.frame_reset
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # * Stop Background Sound
  124.   #--------------------------------------------------------------------------
  125.   def bgs_stop
  126.     @playing_bgs = nil
  127.     Audio.bgs_stop
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # * Memorize Background Sound
  131.   #--------------------------------------------------------------------------
  132.   alias :fmodex_old_system_bgs_memorize :bgs_memorize unless $@
  133.   def bgs_memorize
  134.     fmodex_old_system_bgs_memorize
  135.     @bgs_memorized_position = FMod::bgs_position
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # * Restore Background Sound
  139.   #--------------------------------------------------------------------------
  140.   def bgs_restore
  141.     bgs_play(@memorized_bgs, @bgs_memorized_position)
  142.   end
  143.  
  144. end
  145.  
  146. #==============================================================================
  147. # ** Game_Temp
  148. #==============================================================================
  149. class Game_Temp
  150.  
  151.   attr_accessor :map_bgm_pos
  152.   attr_accessor :map_bgs_pos
  153.   attr_accessor :map_bgs
  154.   #--------------------------------------------------------------------------
  155.   # * Initialize
  156.   #--------------------------------------------------------------------------
  157.   alias :fmodex_old_temp_initialize :initialize unless $@
  158.   def initialize
  159.     fmodex_old_temp_initialize
  160.     @map_bgm_pos = 0
  161.     @map_bgs = nil
  162.     @map_bgs_pos = 0
  163.   end
  164.  
  165. end
  166.  
  167. if Gluszak::Zmiana_BGM_w_menu
  168. #==============================================================================
  169. # ** Scene_Menu
  170. #==============================================================================
  171. class Scene_Menu
  172.   #--------------------------------------------------------------------------
  173.   # * Main
  174.   #--------------------------------------------------------------------------
  175.   alias :fmodex_old_main :main unless $@
  176.   def main
  177.     fmodex_old_main
  178.     if $scene.is_a? Scene_Map
  179.       $game_system.bgm_fade 0.2
  180.       $game_system.bgm_play($game_temp.map_bgm, $game_temp.map_bgm_pos)
  181.       $game_system.bgs_play($game_temp.map_bgs, $game_temp.map_bgs_pos)
  182.     end
  183.   end
  184.  
  185. end
  186. #==============================================================================
  187. # ** Scene_Map
  188. #==============================================================================
  189. class Scene_Map
  190.   #--------------------------------------------------------------------------
  191.   # * Call Battle
  192.   #--------------------------------------------------------------------------
  193.   alias :fmodex_old_map_call_battle :call_battle unless $@
  194.   def call_battle
  195.     $game_temp.map_bgm_pos = FMod.bgm_position
  196.     fmodex_old_map_call_battle
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # * Call Menu
  200.   #--------------------------------------------------------------------------
  201.   alias :fmodex_old_map_call_menu :call_menu unless $@
  202.   def call_menu
  203.     $game_temp.map_bgm_pos = FMod.bgm_position
  204.     $game_temp.map_bgs_pos = FMod.bgs_position
  205.     $game_temp.map_bgm = $game_system.playing_bgm
  206.     $game_temp.map_bgs = $game_system.playing_bgs
  207.     fmodex_old_map_call_menu
  208.     $game_system.bgm_fade 0.2
  209.     $game_system.bgs_fade 0.2
  210.     Audio.me_fade 0.2
  211.     bgm = RPG::AudioFile.new(Gluszak::Menu_BGM)
  212.     $game_system.bgm_play(bgm)
  213.   end
  214.  
  215. end
  216. end
  217.  
  218. if Gluszak::Kontynuacja_BGM_po_bitwie
  219. #==============================================================================
  220. # ** Scene_Battle
  221. #==============================================================================
  222. class Scene_Battle
  223.   #--------------------------------------------------------------------------
  224.   # * Judge
  225.   #--------------------------------------------------------------------------
  226.   def judge
  227.     if $game_party.all_dead? or $game_party.actors.size == 0
  228.       if $game_temp.battle_can_lose
  229.         $game_system.bgm_play($game_temp.map_bgm, $game_temp.map_bgm_pos)    
  230.         battle_end(2)
  231.         return true
  232.       end
  233.       $game_temp.gameover = true
  234.       return true
  235.     end
  236.     for enemy in $game_troop.enemies
  237.       if enemy.exist?
  238.         return false
  239.       end
  240.     end
  241.     start_phase5
  242.     return true
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # * Phase 5 Start
  246.   #--------------------------------------------------------------------------
  247.   def start_phase5
  248.     @phase = 5
  249.     $game_system.bgm_play($game_temp.map_bgm, $game_temp.map_bgm_pos)
  250.     $game_system.me_play($game_system.battle_end_me)
  251.     exp = 0
  252.     gold = 0
  253.     treasures = []
  254.     for enemy in $game_troop.enemies
  255.       unless enemy.hidden
  256.         exp += enemy.exp
  257.         gold += enemy.gold
  258.         if rand(100) < enemy.treasure_prob
  259.           if enemy.item_id > 0
  260.             treasures.push($data_items[enemy.item_id])
  261.           end
  262.           if enemy.weapon_id > 0
  263.             treasures.push($data_weapons[enemy.weapon_id])
  264.           end
  265.           if enemy.armor_id > 0
  266.             treasures.push($data_armors[enemy.armor_id])
  267.           end
  268.         end
  269.       end
  270.     end
  271.     treasures = treasures[0..5]
  272.     for i in 0...$game_party.actors.size
  273.       actor = $game_party.actors[i]
  274.       if actor.cant_get_exp? == false
  275.         last_level = actor.level
  276.         actor.exp += exp
  277.         if actor.level > last_level
  278.           @status_window.level_up(i)
  279.         end
  280.       end
  281.     end
  282.     $game_party.gain_gold(gold)
  283.     for item in treasures
  284.       case item
  285.       when RPG::Item
  286.         $game_party.gain_item(item.id, 1)
  287.       when RPG::Weapon
  288.         $game_party.gain_weapon(item.id, 1)
  289.       when RPG::Armor
  290.         $game_party.gain_armor(item.id, 1)
  291.       end
  292.     end
  293.     @result_window = Window_BattleResult.new(exp, gold, treasures)
  294.     @phase5_wait_count = 100
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # * Phase 5 Update
  298.   #--------------------------------------------------------------------------
  299.   def update_phase5
  300.     if @phase5_wait_count > 0
  301.       @phase5_wait_count -= 1
  302.       if @phase5_wait_count == 0
  303.         @result_window.visible = true
  304.         $game_temp.battle_main_phase = false
  305.         @status_window.refresh
  306.       end
  307.       return
  308.     end
  309.     if Input.trigger?(Input::C)
  310.       battle_end(0)
  311.     end
  312.   end
  313.  
  314. end
  315. end
Advertisement
Add Comment
Please, Sign In to add comment