Advertisement
diamondandplatinum3

Sound Message System Add-on ~ RGSS3

Sep 28th, 2012
1,174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.75 KB | None | 0 0
  1. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #             Sound Message System Add-on
  3. #             Version: 1.0
  4. #             Authors: DiamondandPlatinum3, Modern Algebra
  5. #             Date: September 23, 2012
  6. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. #  Description:
  8. #
  9. #    This script adds on to the default message system allowing you to use
  10. #    a new escape character to generate an SE whilst displaying text and to
  11. #    have a constant SE play whilst scrolling through text.
  12. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. #------------------------------------------------------------------------------
  14. #  Instructions:
  15. #  
  16. #     -  If you want to have an SE play whilst your text is progressing, then
  17. #        edit your options in the editable region
  18. #
  19. #     -  In order to have an SE play during text, you simply enter an escape
  20. #        code similar to the colour code.
  21. #
  22. #           \se[]
  23. #
  24. #        Inside the brackets you input the sound effect that you want to play.
  25. #        Examples:
  26. #
  27. #             \se[Jump1]
  28. #             \se["Jump1"]
  29. #             \se[Jump1, 80, 100]         <= Including Volume and Pitch
  30. #             \se["Jump1", 20, 140]
  31. #
  32. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  33. module DP3_SoundMessageCodes
  34. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  35. #                                                        -=
  36. #                 Editable Region        ////            ==
  37. #                                                        =-
  38. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  39.  
  40.  
  41.   # If this switch ID is turned on, your Message boxes will play
  42.   # The SE you have selected as your text progresses
  43.   TurnOnCharacterSE_SwitchID = 10
  44.  
  45.  
  46.  
  47.  
  48.   SEtoPlayWhenDisplayingText = "Bow1"
  49.   SEVolume                   = 80
  50.   SEPitch                    = 80..120 # This means that a pitch between 80-120
  51.                                        # will play on each hit.
  52.                                        # If you want a difinitive number, you can
  53.                                        # give it a normal number same as volume.
  54.  
  55.  
  56.  
  57.  
  58.   # It sounds pretty bad to hear it play on EVERY single character,
  59.   # so here you get to choose how many characters along it must be before
  60.   # playing the TextDisplaySE  
  61.   Position_For_SEtoPlay = 5
  62.  
  63.  
  64. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  65. end # of Editable Region
  66. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  67. #---------------------------------------------------------
  68. # No touchie past here unless you know what you are
  69. # doing. Failure to heed this warning could cause your
  70. # computer to yell and scream at you.
  71. #
  72. # Edit at your own risk.
  73. #--------------------------------------------------------
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85. #==============================================================================
  86. # ** Window_Base
  87. #------------------------------------------------------------------------------
  88. #  This is a super class of all windows within the game.
  89. #==============================================================================
  90.  
  91. class Window_Base < Window
  92.   #--------------------------------------------------------------------------
  93.   # * Alias Listings
  94.   #--------------------------------------------------------------------------
  95.   alias dp3_procmessound_winbase_procesccode_idkg57     process_escape_character
  96.   #--------------------------------------------------------------------------
  97.   # * Control Character Processing
  98.   #--------------------------------------------------------------------------
  99.   def process_escape_character(code, text, pos)
  100.     case code.upcase
  101.     when 'SE'
  102.       #!---------- Code By Modern Algebra ----------!#
  103.       text.sub!(/\[\s*\"?([^\",\]]+)\"?(.*?)\]/, "")
  104.      filename = $1
  105.      digits = $2.scan(/\d+/).collect {|i| i.to_i }
  106.      digits = digits[0, 2] if digits.size > 2
  107.      RPG::SE.new( filename, *digits ).play
  108.      #!--------------------------------------------!#
  109.    else
  110.      # Call Original Method
  111.      dp3_procmessound_winbase_procesccode_idkg57(code, text, pos)
  112.    end # Case
  113.  end # Function
  114. end # Class
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121. #==============================================================================
  122. # ** Window_Message
  123. #------------------------------------------------------------------------------
  124. #  This message window is used to display text.
  125. #==============================================================================
  126.  
  127. class Window_Message < Window_Base
  128.  #--------------------------------------------------------------------------
  129.  # * Alias Listings
  130.  #--------------------------------------------------------------------------
  131.  alias dp3_procmessound_winmes_init_idkg57          initialize
  132.  alias dp3_procmessound_winmes_procalltxt_idkg57    process_all_text
  133.  alias dp3_procmessound_winmes_procnormchar_idkg57  process_normal_character
  134.  #--------------------------------------------------------------------------
  135.  # * Object Initialization
  136.  #--------------------------------------------------------------------------
  137.  def initialize    
  138.    # Call Original Method
  139.    dp3_procmessound_winmes_init_idkg57
  140.    
  141.    # Initialise text count
  142.    @dp3_soundmessage_textcount = 0
  143.  end
  144.  #--------------------------------------------------------------------------
  145.  # * Process All Text
  146.  #--------------------------------------------------------------------------
  147.  def process_all_text
  148.    
  149.    # Call Original Method
  150.    dp3_procmessound_winmes_procalltxt_idkg57
  151.    
  152.    # Set Count Back to Zero
  153.    @dp3_soundmessage_textcount = 0
  154.  end
  155.  #--------------------------------------------------------------------------
  156.  # * Normal Character Processing
  157.  #--------------------------------------------------------------------------
  158.  def process_normal_character(*args)
  159.    
  160.    # Call original Method
  161.    dp3_procmessound_winmes_procnormchar_idkg57(*args)
  162.    
  163.    # Increment text position
  164.    @dp3_soundmessage_textcount += 1
  165.    
  166.    # Are we allowed to play an SE?
  167.    if $game_switches[DP3_SoundMessageCodes::TurnOnCharacterSE_SwitchID]
  168.      # Find out if position is equal to one specified
  169.      if @dp3_soundmessage_textcount == DP3_SoundMessageCodes::Position_For_SEtoPlay
  170.        @dp3_soundmessage_textcount = 0
  171.        se  = DP3_SoundMessageCodes::SEtoPlayWhenDisplayingText
  172.        vol = DP3_SoundMessageCodes::SEVolume
  173.        pit = DP3_SoundMessageCodes::SEPitch
  174.        pit = rand(pit.max - pit.min) + pit.min if pit.is_a?(Range)
  175.        RPG::SE.new(se, vol, pit).play
  176.      end # If Position == TextCount
  177.    end # If $game_switches Statement
  178.  end # Function
  179. end # Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement