Vlue

Basic Message SE

Sep 26th, 2013
1,794
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Basic Message SE v1.2
  2. #----------#
  3. #Features: Let's you have a sound effect play every so-so letters while a
  4. #           message is being displayed. Fancy!
  5. #
  6. #Usage:    Plug and play, script calls to change details in game:
  7. #
  8. #           message_freq(value)      - changes the frequency of the se
  9. #           message_se("string")     - name of the se to play
  10. #           message_volume(value)    - volume of the se to play
  11. #           message_pitch([min,max]) - pitch variance between min and max
  12. #           message_set(se,volume,pitch) - sets them all at once
  13. #           message_set(se,volume,pitch,freq) - same as above but with freq
  14. #
  15. #----------#
  16. #-- Script by: V.M of D.T
  17. #
  18. #- Questions or comments can be:
  19. #    given by email: sumptuaryspade@live.ca
  20. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  21. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  22. #
  23. #- Free to use in any project with credit given, donations always welcome!
  24.  
  25. class Window_Message < Window_Base
  26.  
  27.   DEFAULT_SE_FREQ = 5
  28.   DEFAULT_AUDIO_SOUND = "Cancel2"
  29.   DEFAULT_AUDIO_VOLUME = 75
  30.   DEFAULT_AUDIO_PITCH = [75,125]
  31.  
  32.   DISABLE_SOUND_SWITCH = 29
  33.  
  34.   attr_accessor  :se
  35.   attr_accessor  :freq
  36.   attr_accessor  :volume
  37.   attr_accessor  :pitch
  38.  
  39.   alias mse_clear_instance_variables clear_instance_variables
  40.   def clear_instance_variables
  41.     mse_clear_instance_variables
  42.     @key_timer = 0
  43.   end
  44.   def process_normal_character(c, pos)
  45.     super
  46.     if !$game_options.nil?
  47.       return wait_for_one_character unless $game_options.message_se
  48.     end
  49.     return wait_for_one_character if $game_switches[DISABLE_SOUND_SWITCH]
  50.       se_det = $game_party.message_se_details
  51.     if @key_timer % se_det[:freq] == 0
  52.       Audio.se_play("Audio/SE/" + se_det[:se], se_det[:volume], rand(se_det[:pitch][1]-se_det[:pitch][0]) + se_det[:pitch][0])
  53.     end
  54.     @key_timer += 1
  55.     wait_for_one_character
  56.   end
  57. end
  58.  
  59. class Game_Party
  60.     attr_accessor   :message_se_details
  61.     def message_se_details
  62.         reset_se_details unless @message_se_details
  63.         @message_se_details
  64.     end
  65.     def reset_se_details
  66.         @message_se_details = {
  67.       :se => Window_Message::DEFAULT_AUDIO_SOUND,
  68.       :freq => Window_Message::DEFAULT_SE_FREQ,
  69.       :volume => Window_Message::DEFAULT_AUDIO_VOLUME,
  70.       :pitch => Window_Message::DEFAULT_AUDIO_PITCH
  71.     }
  72.     end
  73. end
  74.  
  75. class Game_Interpreter
  76.   def message_set(string, value, array, freq = -1)
  77.     message_se(string)
  78.     message_volume(value)
  79.     message_pitch(array)
  80.     message_freq(freq) if freq >= 0
  81.   end
  82.   def message_freq(value)
  83.     $game_party.message_se_details.freq = value
  84.   end
  85.   def message_se(string)
  86.     $game_party.message_se_details.se = string
  87.   end
  88.   def message_pitch(array)
  89.     $game_party.message_se_details.pitch = array
  90.   end
  91.   def message_volume(value)
  92.     $game_party.message_se_details.volume = value
  93.   end
  94.   def message_reset
  95.     $game_party.message_se_details.reset_se_details
  96.   end
  97. end
RAW Paste Data