daily pastebin goal
60%
SHARE
TWEET

RPG Maker VX Ace - Text Sound Effect v3

Zerbu Apr 4th, 2013 7,773 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # Text Sound Effect (version 2)
  3. # NEW FEATURE: Switch to turn off sound effect
  4. #------------------------------------------------------------------------------
  5. # by Zerbu
  6. #==============================================================================
  7. module Text_Sound_Effect
  8.   #--------------------------------------------------------------------------
  9.   # Options
  10.   #--------------------------------------------------------------------------
  11.   # The sound effect to play
  12.   MESSAGE_SOUND = RPG::SE.new("Knock", 70, 80)
  13.  
  14.   # The number of characters to display before each time the sound plays
  15.   # The default is 3, it's recommended you keep it as this unless you
  16.   # know what you're doing
  17.   MESSAGE_SOUND_FRAMES = 3
  18.  
  19.   # Switch to disable sound effect
  20.   # If you need to turn off the sound effect for any part of the game,
  21.   # turn this switch on
  22.   # Set to nil to disable this feature
  23.   MESSAGE_SOUND_DISABLE = nil
  24.  
  25. end
  26.  
  27. class Window_Message < Window_Base
  28.   include Text_Sound_Effect
  29.   #--------------------------------------------------------------------------
  30.   # alias method: process_characer
  31.   #--------------------------------------------------------------------------
  32.   alias textsound_process_character_normal process_character
  33.   def process_character(c, text, pos)
  34.     if !MESSAGE_SOUND_DISABLE or !$game_switches[MESSAGE_SOUND_DISABLE]
  35.       #---
  36.       if !defined?(@sound_frames)
  37.         @sound_frames = 0
  38.       end
  39.       #---
  40.       if @sound_frames == 0
  41.         MESSAGE_SOUND.play
  42.       end
  43.       #---
  44.       @sound_frames+=1
  45.       #---
  46.       if @sound_frames == MESSAGE_SOUND_FRAMES
  47.         @sound_frames = 0
  48.       end
  49.       #---
  50.     end
  51.     textsound_process_character_normal(c, text, pos)
  52.   end
  53.   #---
  54. end
RAW Paste Data
Top