Advertisement
diamondandplatinum3

Collision Sound ~ RGSS3

Jan 18th, 2013
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.56 KB | None | 0 0
  1. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #             Collision Sound
  3. #             Author: DiamondandPlatinum3
  4. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. #  Description:
  6. #
  7. #    This script plays a collision sound when you try walking on to an
  8. #    non-passable space. This is not used if you have 'through' checked on your
  9. #    player on the other hand.
  10. #    Collision sound only works for the Player, it does not play for other
  11. #    events if they try to walk into something they shouldn't.
  12. #
  13. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  14. #------------------------------------------------------------------------------
  15. #  Instructions:
  16. #  
  17. #     Editable Region, simply replace the Filename, VOlume & Pitch for the
  18. #     Collision_SE. You must also set a wait timer until it can be heard again.
  19. #     This is because the collision sound can play many many times if you keep
  20. #     attempting to walk into a wall, so this option sets the cooldown time until
  21. #     it can be heard again.
  22. #
  23. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  24.  
  25. class Game_Player < Game_Character
  26.  
  27.   #----------------------------------------
  28.   #     Editable Region
  29.   #----------------------------------------
  30.   Collision_SE          = [ "Bite", 80, 100 ]   # The Collision Sound you wish to play, volume, pitch.
  31.   Collision_Wait_Timer  = 60                    # Wait Timer (in frames) until next collision sound.
  32.   #----------------------------------------
  33.  
  34.  
  35.  
  36.   #--------------------------------------------------------------------------
  37.   # * Frame Update
  38.   #--------------------------------------------------------------------------
  39.   alias dp3_collisionsound_gameplayer_update_sevt       update
  40.   def update
  41.     dp3_collisionsound_gameplayer_update_sevt()
  42.     @collision_sound_timer  = 0 unless @collision_sound_timer != nil
  43.     @collision_sound_timer -= 1 unless @collision_sound_timer == 0
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # * Determine if Passable
  47.   #--------------------------------------------------------------------------
  48.   alias dp3_collisionsound_gameplayer_passable_sevt       passable?
  49.   def passable?( *args )
  50.     passable = dp3_collisionsound_gameplayer_passable_sevt( *args )
  51.     unless passable == true || @collision_sound_timer > 0
  52.       RPG::SE.new(*Collision_SE).play
  53.       @collision_sound_timer = Collision_Wait_Timer
  54.     end
  55.     return passable
  56.   end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement