Advertisement
roninator2

Mr Trivel Hurt Sounds mod

Dec 5th, 2024
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.44 KB | None | 0 0
  1. # )----------------------------------------------------------------------------(
  2. # )--     AUTHOR:     Mr Trivel                                              --(
  3. # )--     NAME:       Hurt Sounds Mod by Roninator2                          --(
  4. # )--     CREATED:    2020-10-10                                             --(
  5. # )--     VERSION:    1.2                                                    --(
  6. # )--     Request by: Rimaka                                                 --(
  7. # )----------------------------------------------------------------------------(
  8. # )--                         VERSION HISTORY                                --(
  9. # )--  1.0 - Initial scream.                                                 --(
  10. # )--  1.1 - No more screaming on healing.                                   --(
  11. # )--  1.2 - Randomize and multiple sounds.                                  --(
  12. # )----------------------------------------------------------------------------(
  13. # )--                          DESCRIPTION                                   --(
  14. # )--  Enemies and actors will play Sound Effect when getting hit.           --(
  15. # )----------------------------------------------------------------------------(
  16. # )--                          INSTRUCTIONS                                  --(
  17. # )--  Add <Hurt: SE_name, volume, pitch, %chance to play, force play>       --(
  18. # )--  to your Actor or Enemy note box.                                      --(
  19. # )--  Example: <Hurt: Bite, 100, 100, 40, true>                             --(
  20. # )--  If force play is true and random chance fails to play a sound,        --(
  21. # )--  the sound that is specified as forced will play                       --(
  22. # )--  only specify one sound to force play                                  --(
  23. # )--  Place multiple tags to use more than one sound                        --(
  24. # )----------------------------------------------------------------------------(
  25. # )--                          LICENSE INFO                                  --(
  26. # )--   Free for commercial and non-commercial games as long as credit is    --(
  27. # )--   given to Mr. Trivel.                                                 --(
  28. # )----------------------------------------------------------------------------(
  29. module R2_trivel_hurt_sound
  30.     CHANCE = 35
  31. end
  32. # )----------------------------------------------------------------------------(
  33. # )--  Class: Game_Battler                                                   --(
  34. # )----------------------------------------------------------------------------(
  35. class Game_Battler < Game_BattlerBase
  36.   alias :mrts_hurt_execute_damage :execute_damage
  37.  
  38.   # )--------------------------------------------------------------------------(
  39.   # )--  Alias Method: execute_damage                                        --(
  40.   # )--------------------------------------------------------------------------(
  41.   def execute_damage(user)
  42.     mrts_hurt_execute_damage(user)
  43.     return unless @hurt_sound && @result.hp_damage > 0
  44.         for c in 0..@hurt_sound.size - 1
  45.             if @hurt_sound[c][4] == true
  46.                 play = true
  47.                 pos = c
  48.             end
  49.             num = rand(100)
  50.             s = rand(@hurt_sound.size)
  51.             if user.hp <= 0 && num < @death_sound[3]
  52.                 Audio.se_play(@death_sound[0], @death_sounds[1], @death_sound[2])
  53.                 break
  54.             end
  55.             if num < @hurt_sound[s][3]
  56.                 Audio.se_play(@hurt_sound[s][0], @hurt_sounds[s][1], @hurt_sound[s][2])
  57.                 break
  58.             elsif play == true
  59.                 Audio.se_play(@hurt_sound[pos][0], @hurt_sounds[pos][1], @hurt_sound[pos][2])
  60.             end
  61.         end
  62.   end
  63. end
  64.  
  65. # )----------------------------------------------------------------------------(
  66. # )--  Class: Game_Actor                                                     --(
  67. # )----------------------------------------------------------------------------(
  68. class Game_Actor < Game_Battler
  69.   alias :mrts_hurt_setup :setup
  70.  
  71.   # )--------------------------------------------------------------------------(
  72.   # )--  Alias Method: setup                                                 --(
  73.   # )--------------------------------------------------------------------------(
  74.   def setup(actor_id)
  75.     mrts_hurt_setup(actor_id)
  76.     results = actor.note.scan(/<Hurt:[ ]*(\w*),[ ]*(\d*),[ ]*(\d+),[ ]*(\d+),[ ]*(\w*)>/i)
  77.         results.each do |i|
  78.             @hurt_sound << ["Audio/SE/"+$1, $2.to_i, $3.to_i, $4.to_i, $5]
  79.         end
  80.     actor.note.scan(/<Death:[ ]*(\w*),[ ]*(\d*),[ ]*(\d+),[ ]*(\d+)>/i)
  81.     $1 ? @death_sound = ["Audio/SE/"+$1, $2.to_i, $3.to_i, $4.to_i] : @death_sound = nil
  82.   end
  83. end
  84.  
  85. # )----------------------------------------------------------------------------(
  86. # )--  Class: Game_Enemy                                                     --(
  87. # )----------------------------------------------------------------------------(
  88. class Game_Enemy < Game_Battler
  89.   alias :mrts_hurt_initialize :initialize
  90.  
  91.   # )--------------------------------------------------------------------------(
  92.   # )--  Alias Method: initialize                                            --(
  93.   # )--------------------------------------------------------------------------(
  94.   def initialize(index, enemy_id)
  95.     mrts_hurt_initialize(index, enemy_id)
  96.         results = enemy.note.scan[/<Hurt:[ ]*(\w*),[ ]*(\d*),[ ]*(\d+),[ ]*(\d+)>/i]
  97.         results.each do |i|
  98.           @hurt_sound << ["Audio/SE/"+$1, $2.to_i, $3.to_i, $4.to_i]
  99.         end
  100.     enemy.note.scan(/<Death:[ ]*(\w*),[ ]*(\d*),[ ]*(\d+),[ ]*(\d+)>/i)
  101.     $1 ? @death_sound = ["Audio/SE/"+$1, $2.to_i, $3.to_i, $4.to_i] : @death_sound = nil
  102.   end
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement