MrTrivel

MrTS_Hurt_Sounds

Jun 30th, 2014
825
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # )----------------------------------------------------------------------------(
  2. # )--     AUTHOR:     Mr Trivel                                              --(
  3. # )--     NAME:       Hurt Sounds                                            --(
  4. # )--     CREATED:    2014-06-30                                             --(
  5. # )--     VERSION:    1.1                                                    --(
  6. # )--     Request by: Rimaka                                                 --(
  7. # )----------------------------------------------------------------------------(
  8. # )--                         VERSION HISTORY                                --(
  9. # )--  1.0 - Initial scream.                                                 --(
  10. # )--  1.1 - No more screaming on healing.                                   --(
  11. # )----------------------------------------------------------------------------(
  12. # )--                          DESCRIPTION                                   --(
  13. # )--  Enemies and actors will play Sound Effect when getting hit.           --(
  14. # )----------------------------------------------------------------------------(
  15. # )--                          INSTRUCTIONS                                  --(
  16. # )--  Add <Hurt: SE_name, volume, pitch> to your Actor or Enemy note box.   --(
  17. # )--  Example: <Hurt: Bite, 100, 100>                                       --(
  18. # )----------------------------------------------------------------------------(
  19. # )--                          LICENSE INFO                                  --(
  20. # )--   Free for commercial and non-commercial games as long as credit is    --(
  21. # )--   given to Mr. Trivel.                                                 --(
  22. # )----------------------------------------------------------------------------(
  23.  
  24. # )----------------------------------------------------------------------------(
  25. # )--  Class: Game_Battler                                                   --(
  26. # )----------------------------------------------------------------------------(
  27. class Game_Battler < Game_BattlerBase
  28.   alias :mrts_hurt_execute_damage :execute_damage
  29.  
  30.   # )--------------------------------------------------------------------------(
  31.   # )--  Alias Method: execute_damage                                        --(
  32.   # )--------------------------------------------------------------------------(
  33.   def execute_damage(user)
  34.     mrts_hurt_execute_damage(user)
  35.     return unless @hurt_sound && @result.hp_damage > 0
  36.     Audio.se_play(@hurt_sound[0], @hurt_sound[1], @hurt_sound[2])
  37.   end
  38. end
  39.  
  40. # )----------------------------------------------------------------------------(
  41. # )--  Class: Game_Actor                                                     --(
  42. # )----------------------------------------------------------------------------(
  43. class Game_Actor < Game_Battler
  44.   alias :mrts_hurt_setup :setup
  45.  
  46.   # )--------------------------------------------------------------------------(
  47.   # )--  Alias Method: setup                                                 --(
  48.   # )--------------------------------------------------------------------------(
  49.   def setup(actor_id)
  50.     mrts_hurt_setup(actor_id)
  51.     actor.note[/<Hurt:[ ]*(\w*),[ ]*(\d*),[ ]*(\d+)>/i]
  52.     $1 ? @hurt_sound = ["Audio/SE/"+$1, $2.to_i, $3.to_i] : @hurt_sound = nil
  53.   end
  54. end
  55.  
  56. # )----------------------------------------------------------------------------(
  57. # )--  Class: Game_Enemy                                                     --(
  58. # )----------------------------------------------------------------------------(
  59. class Game_Enemy < Game_Battler
  60.   alias :mrts_hurt_initialize :initialize
  61.  
  62.   # )--------------------------------------------------------------------------(
  63.   # )--  Alias Method: initialize                                            --(
  64.   # )--------------------------------------------------------------------------(
  65.   def initialize(index, enemy_id)
  66.     mrts_hurt_initialize(index, enemy_id)
  67.     enemy.note[/<Hurt:[ ]*(\w*),[ ]*(\d*),[ ]*(\d+)>/i]
  68.     $1 ? @hurt_sound = ["Audio/SE/"+$1, $2.to_i, $3.to_i] : @hurt_sound = nil
  69.   end
  70. end
RAW Paste Data