mcgluszak

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

Mar 13th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 12.53 KB | None | 0 0
  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.01
  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. #         v1.01 (13.01.12) - poprawiono kilka bugów
  60. # Starsza wersja: http://www.hbgames.org/forums/viewtopic.php?t=55486
  61. #==============================================================================
  62.  
  63. ################
  64. # KONFIGURACJA #
  65. ################
  66.  
  67. module Gluszak
  68.  
  69.   Zmiana_BGM_w_menu = true
  70.   Menu_BGM = '012-Theme01'
  71.   Kontynuacja_BGM_po_bitwie = true # może być niekompatybilne z CBS-ami
  72.  
  73. end
  74.  
  75. ##########
  76. # KONIEC #
  77. ##########
  78.  
  79.  
  80. #==============================================================================
  81. # ** Game_System
  82. #==============================================================================
  83. class Game_System
  84.   attr_accessor :playing_bgm
  85.   attr_accessor :playing_bgs
  86.   #--------------------------------------------------------------------------
  87.   # * Play Background Music
  88.   #--------------------------------------------------------------------------
  89.   def bgm_play(bgm, pos = 0)
  90.     @playing_bgm = bgm
  91.     if bgm != nil and bgm.name != ""
  92.       Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch, pos)
  93.     else
  94.       Audio.bgm_stop
  95.     end
  96.     Graphics.frame_reset
  97.   end
  98.   #--------------------------------------------------------------------------
  99.   # * Memorize Background Music
  100.   #--------------------------------------------------------------------------
  101.   alias :fmodex_old_system_bgm_memorize :bgm_memorize unless $@
  102.   def bgm_memorize
  103.     fmodex_old_system_bgm_memorize
  104.     @bgm_memorized_position = FMod::bgm_position
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # * Restore Background Music
  108.   #--------------------------------------------------------------------------
  109.   def bgm_restore
  110.     bgm_play(@memorized_bgm, @bgm_memorized_position)
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # * Play Background Sound
  114.   #     bgs : background sound to be played
  115.   #--------------------------------------------------------------------------
  116.   def bgs_play(bgs, pos = 0)
  117.     @playing_bgs = bgs
  118.     if bgs != nil and bgs.name != ""
  119.       Audio.bgs_play("Audio/BGS/" + bgs.name, bgs.volume, bgs.pitch, pos)
  120.     else
  121.       Audio.bgs_stop
  122.     end
  123.     Graphics.frame_reset
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   # * Stop Background Sound
  127.   #--------------------------------------------------------------------------
  128.   def bgs_stop
  129.     @playing_bgs = nil
  130.     Audio.bgs_stop
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # * Memorize Background Sound
  134.   #--------------------------------------------------------------------------
  135.   alias :fmodex_old_system_bgs_memorize :bgs_memorize unless $@
  136.   def bgs_memorize
  137.     fmodex_old_system_bgs_memorize
  138.     @bgs_memorized_position = FMod::bgs_position
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # * Restore Background Sound
  142.   #--------------------------------------------------------------------------
  143.   def bgs_restore
  144.     bgs_play(@memorized_bgs, @bgs_memorized_position)
  145.   end
  146.  
  147. end
  148.  
  149. #==============================================================================
  150. # ** Game_Temp
  151. #==============================================================================
  152. class Game_Temp
  153.  
  154.   attr_accessor :gluszak_map_bgm
  155.   attr_accessor :gluszak_map_bgm_pos
  156.   attr_accessor :gluszak_map_bgs
  157.   attr_accessor :gluszak_map_bgs_pos
  158.   #--------------------------------------------------------------------------
  159.   # * Initialize
  160.   #--------------------------------------------------------------------------
  161.   alias :fmodex_old_temp_initialize :initialize unless $@
  162.   def initialize
  163.     fmodex_old_temp_initialize
  164.     @glsuzak_map_bgm = nil
  165.     @gluszak_map_bgm_pos = 0
  166.     @glsuzak_map_bgs = nil
  167.     @gluszak_map_bgs_pos = 0
  168.   end
  169.  
  170. end
  171.  
  172. if Gluszak::Zmiana_BGM_w_menu
  173. #==============================================================================
  174. # ** Scene_Menu
  175. #==============================================================================
  176. class Scene_Menu
  177.   #--------------------------------------------------------------------------
  178.   # * Main
  179.   #--------------------------------------------------------------------------
  180.   alias :fmodex_old_main :main unless $@
  181.   def main
  182.     fmodex_old_main
  183.     if $scene.is_a? Scene_Map
  184.       $game_system.bgm_fade 1
  185.       $game_system.bgm_play($game_temp.gluszak_map_bgm, $game_temp.gluszak_map_bgm_pos)
  186.       $game_system.bgs_play($game_temp.gluszak_map_bgs, $game_temp.gluszak_map_bgs_pos)
  187.     end
  188.   end
  189.  
  190. end
  191. #==============================================================================
  192. # ** Scene_Map
  193. #==============================================================================
  194. class Scene_Map
  195.   #--------------------------------------------------------------------------
  196.   # * Call Menu
  197.   #--------------------------------------------------------------------------
  198.   alias :fmodex_old_map_call_menu :call_menu unless $@
  199.   def call_menu
  200.     $game_temp.gluszak_map_bgm_pos = FMod.bgm_position
  201.     $game_temp.gluszak_map_bgs_pos = FMod.bgs_position
  202.     $game_temp.gluszak_map_bgm = $game_system.playing_bgm
  203.     $game_temp.gluszak_map_bgs = $game_system.playing_bgs
  204.     fmodex_old_map_call_menu
  205.     $game_system.bgm_fade 2
  206.     $game_system.bgs_fade 2
  207.     Audio.me_fade 2
  208.     bgm = RPG::AudioFile.new(Gluszak::Menu_BGM)
  209.     $game_system.bgm_play(bgm)
  210.     $game_system.playing_bgm = $game_temp.gluszak_map_bgm
  211.     $game_system.playing_bgs = $game_temp.gluszak_map_bgs
  212.   end
  213.  
  214. end
  215. end
  216.  
  217. if Gluszak::Kontynuacja_BGM_po_bitwie
  218. #==============================================================================
  219. # ** Scene_Map
  220. #==============================================================================
  221. class Scene_Map
  222.   #--------------------------------------------------------------------------
  223.   # * Call Battle
  224.   #--------------------------------------------------------------------------
  225.   alias :fmodex_old_map_call_battle :call_battle unless $@
  226.   def call_battle
  227.     $game_temp.map_bgm_pos = FMod.bgm_position
  228.     fmodex_old_map_call_battle
  229.   end
  230. end
  231. #==============================================================================
  232. # ** Scene_Battle
  233. #==============================================================================
  234. class Scene_Battle
  235.   #--------------------------------------------------------------------------
  236.   # * Judge
  237.   #--------------------------------------------------------------------------
  238.   def judge
  239.     if $game_party.all_dead? or $game_party.actors.size == 0
  240.       if $game_temp.battle_can_lose
  241.         $game_system.bgm_play($game_temp.map_bgm, $game_temp.map_bgm_pos)    
  242.         battle_end(2)
  243.         return true
  244.       end
  245.       $game_temp.gameover = true
  246.       return true
  247.     end
  248.     for enemy in $game_troop.enemies
  249.       if enemy.exist?
  250.         return false
  251.       end
  252.     end
  253.     start_phase5
  254.     return true
  255.   end
  256.   #--------------------------------------------------------------------------
  257.   # * Phase 5 Start
  258.   #--------------------------------------------------------------------------
  259.   def start_phase5
  260.     @phase = 5
  261.     $game_system.bgm_play($game_temp.map_bgm, $game_temp.map_bgm_pos)
  262.     $game_system.me_play($game_system.battle_end_me)
  263.     exp = 0
  264.     gold = 0
  265.     treasures = []
  266.     for enemy in $game_troop.enemies
  267.       unless enemy.hidden
  268.         exp += enemy.exp
  269.         gold += enemy.gold
  270.         if rand(100) < enemy.treasure_prob
  271.           if enemy.item_id > 0
  272.             treasures.push($data_items[enemy.item_id])
  273.           end
  274.           if enemy.weapon_id > 0
  275.             treasures.push($data_weapons[enemy.weapon_id])
  276.           end
  277.           if enemy.armor_id > 0
  278.             treasures.push($data_armors[enemy.armor_id])
  279.           end
  280.         end
  281.       end
  282.     end
  283.     treasures = treasures[0..5]
  284.     for i in 0...$game_party.actors.size
  285.       actor = $game_party.actors[i]
  286.       if actor.cant_get_exp? == false
  287.         last_level = actor.level
  288.         actor.exp += exp
  289.         if actor.level > last_level
  290.           @status_window.level_up(i)
  291.         end
  292.       end
  293.     end
  294.     $game_party.gain_gold(gold)
  295.     for item in treasures
  296.       case item
  297.       when RPG::Item
  298.         $game_party.gain_item(item.id, 1)
  299.       when RPG::Weapon
  300.         $game_party.gain_weapon(item.id, 1)
  301.       when RPG::Armor
  302.         $game_party.gain_armor(item.id, 1)
  303.       end
  304.     end
  305.     @result_window = Window_BattleResult.new(exp, gold, treasures)
  306.     @phase5_wait_count = 100
  307.   end
  308.   #--------------------------------------------------------------------------
  309.   # * Phase 5 Update
  310.   #--------------------------------------------------------------------------
  311.   def update_phase5
  312.     if @phase5_wait_count > 0
  313.       @phase5_wait_count -= 1
  314.       if @phase5_wait_count == 0
  315.         @result_window.visible = true
  316.         $game_temp.battle_main_phase = false
  317.         @status_window.refresh
  318.       end
  319.       return
  320.     end
  321.     if Input.trigger?(Input::C)
  322.       battle_end(0)
  323.     end
  324.   end
  325.  
  326. end
  327. end
Advertisement
Add Comment
Please, Sign In to add comment