Advertisement
roninator2

Mr Trivel Hurt Sounds SAS IV

Dec 11th, 2024
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.31 KB | None | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Mr Trivel Hurt Sounds SAS IV ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║  Play Hurt Sounds                   ╠════════════════════╣
  7. # ║ Rewrite of Mr Trivel script         ║    18 Jul 2022     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ Instructions:                                            ║
  11. # ║                                                          ║
  12. # ║   Compatibility patch for SAS IV                         ║
  13. # ║                                                          ║
  14. # ╚══════════════════════════════════════════════════════════╝
  15. # ╔══════════════════════════════════════════════════════════╗
  16. # ║ Updates:                                                 ║
  17. # ║   2022-jul-18 - Initial publish                          ║
  18. # ╚══════════════════════════════════════════════════════════╝
  19. # ╔══════════════════════════════════════════════════════════╗
  20. # ║ Terms of use:                                            ║
  21. # ║ Follow the Original Authors terms                        ║
  22. # ║                                                          ║
  23. # ║                     LICENSE INFO                         ║
  24. # ║   Free for commercial and non-commercial games as long   ║
  25. # ║   as credit is given to Mr. Trivel & Roninator2.         ║
  26. # ╚══════════════════════════════════════════════════════════╝
  27. class Sapphire_Enemy
  28.   alias :r2_hurt_initialize :initialize
  29.   attr_accessor :hurt_sound
  30.   attr_accessor :dead_sound
  31.   def initialize(event,id)
  32.     r2_hurt_initialize(event,id)
  33.     @hurt_sound = []
  34.     @dead_sound = []
  35.     results = @game_enemy.note.scan(R2_Hurt_Sound_Mod::Hurt_Regex)
  36.     results.each do |res|
  37.       @hurt_sound.push(res)
  38.     end
  39.     dresults = @game_enemy.note.scan(R2_Hurt_Sound_Mod::Dead_Regex)
  40.     dresults.each do |res|
  41.       @dead_sound.push(res)
  42.     end
  43.   end
  44. end
  45. # )----------------------------------------------------------------------------(
  46. # )--  Class: Game_Event                                                     --(
  47. # )----------------------------------------------------------------------------(
  48. class Game_Event < Game_Character
  49.   def damage_enemy(value,by_player=false)
  50.     value -= @enemy.defence
  51.     value = 0 if value < 0
  52.     @enemy.hp -= value
  53.     dead_sound = @enemy.dead_sound
  54.     hurt_sound = @enemy.hurt_sound
  55.     $game_map.show_text(self,value) unless @enemy.object
  56.     if @enemy.hp <= 0
  57.       if dead_sound.size == 0
  58.         kill_enemy(by_player)
  59.       else
  60.         i = rand(@enemy.dead_sound.size)
  61.         Audio.se_play("Audio/SE/"+dead_sound[i][0], dead_sound[i][1].to_i, dead_sound[i][2].to_i)
  62.         kill_enemy(by_player)
  63.       end
  64.     elsif by_player && @request_view
  65.       @balloon_id = 1 if Sapphire_Core::Enemy_Exclamation
  66.       @move_type = 2
  67.       @move_frequency = 6
  68.       @request_view = false
  69.     end
  70.     return unless (hurt_sound.size > 0) && (value > 0)
  71.     i = rand(hurt_sound.size)
  72.     Audio.se_play("Audio/SE/"+hurt_sound[i][0], hurt_sound[i][1].to_i, hurt_sound[i][2].to_i)
  73.   end
  74.   def skill_damage_enemy(value,by_player=false)
  75.     value -= @enemy.mdefence
  76.     value = 0 if value < 0
  77.     @enemy.hp -= value
  78.     dead_sound = @enemy.dead_sound
  79.     hurt_sound = @enemy.hurt_sound
  80.     $game_map.show_text(self,value) unless @enemy.object
  81.     if @enemy.hp <= 0
  82.       if dead_sound.size == 0
  83.         kill_enemy(by_player)
  84.       else
  85.         i = rand(@enemy.dead_sound.size)
  86.         Audio.se_play("Audio/SE/"+dead_sound[i][0], dead_sound[i][1].to_i, dead_sound[i][2].to_i)
  87.         kill_enemy(by_player)
  88.       end
  89.     elsif by_player && @request_view
  90.       @balloon_id = 1 if Sapphire_Core::Enemy_Exclamation
  91.       @move_type = 2
  92.       @move_frequency = 6
  93.       @request_view = false
  94.     end
  95.     return unless (hurt_sound.size > 0) && (value > 0)
  96.     i = rand(hurt_sound.size)
  97.     Audio.se_play("Audio/SE/"+hurt_sound[i][0], hurt_sound[i][1], hurt_sound[i][2])
  98.   end
  99.   alias r2_sas_iv_trivel_kill_enemy kill_enemy
  100. end
  101. # )----------------------------------------------------------------------------(
  102. # )--  Class: Game_Player                                                     --(
  103. # )----------------------------------------------------------------------------(
  104. class Game_Player < Game_Character
  105.   alias r2_sas_iv_trivel_player_hurt_damage damage_hero
  106.   def damage_hero(value)
  107.     r2_sas_iv_trivel_player_hurt_damage(value)
  108.     actor = $game_party.members[0]
  109.     return unless actor && value > 0
  110.     hurt_sound = []
  111.     results = actor.note.scan(R2_Hurt_Sound_Mod::Hurt_Regex)
  112.     results.each do |res|
  113.       hurt_sound.push(res)
  114.     end
  115.     return unless hurt_sound && value > 0
  116.     i = rand(hurt_sound.size)
  117.     Audio.se_play("Audio/SE/"+hurt_sound[i][0], hurt_sound[i][1].to_i, hurt_sound[i][2].to_i)
  118.     return unless actor.hp == 0
  119.     dead_sound = []
  120.     dresults = actor.note.scan(R2_Hurt_Sound_Mod::Dead_Regex)
  121.     dresults.each do |res|
  122.       dead_sound.push(res)
  123.     end
  124.     i = rand(dead_sound.size)
  125.     Audio.se_play("Audio/SE/"+dead_sound[i][0], dead_sound[i][1].to_i, dead_sound[i][2].to_i)
  126.   end
  127.   alias r2_sas_iv_trivel_player_hurt_skill skill_damage_hero
  128.   def skill_damage_hero(value)
  129.     r2_sas_iv_trivel_player_hurt_skill(value)
  130.     actor = $game_party.members[0]
  131.     return unless actor && value > 0
  132.     hurt_sound = []
  133.     results = actor.note.scan(R2_Hurt_Sound_Mod::Hurt_Regex)
  134.     results.each do |res|
  135.       hurt_sound.push(res)
  136.     end
  137.     return unless hurt_sound && value > 0
  138.     i = rand(hurt_sound.size)
  139.     Audio.se_play("Audio/SE/"+hurt_sound[i][0], hurt_sound[i][1].to_i, hurt_sound[i][2].to_i)
  140.     return unless actor.hp == 0
  141.     dead_sound = []
  142.     dresults = actor.note.scan(R2_Hurt_Sound_Mod::Dead_Regex)
  143.     dresults.each do |res|
  144.       dead_sound.push(res)
  145.     end
  146.     i = rand(dead_sound.size)
  147.     Audio.se_play("Audio/SE/"+dead_sound[i][0], dead_sound[i][1].to_i, dead_sound[i][2].to_i)
  148.   end
  149. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement