#===============================================================================
# Rinobi: Actor Damage Sounds
#-------------------------------------------------------------------------------
# Damage sound effects can now be assigned for specific weapons and armors.
#-------------------------------------------------------------------------------
# Instructions:
#
# Paste below Materials and above Main Process. See 'Settings Module'.
#-------------------------------------------------------------------------------
# Version History:
#
# @ 1.0 [12/05/2015] Completed 
# @ 1.1 [12/06/2015] ATB Compatability Update
# @ 1.2 [12/08/2015] Fixed occasional crash when enemy attacks.
# @ 1.3 [12/09/2015] Fixed crash when actor is damaged without equipped armor.
# @ 1.7 [12/10/2015] Major update. Fixed double sound effect bug.
#                    Added sound options for barehanded and no armor.
#                    Shield Armor types have priority while guarding.
#                    Sensible default settings for making easy distinctions.
# @ 1.8 [01/07/2016] Option to include/exclude weapon SE from skills added.
#-------------------------------------------------------------------------------
# Compatibility:
#
# Modules:
#  @ ActorSound < RINOBI
#
# Alias Methods:
#  @ prepare                in Game_Action
#  @ perform_damage_effect  in Game_Actor
#  @ perform_damage_effect  in Game_Enemy
#===============================================================================
module RINOBI module ActorSound # No Touchie!
#===============================================================================
# ** Settings Module
#-------------------------------------------------------------------------------
# Controls which sounds play for each type of equipment
#===============================================================================
  # The slot id for armor. Recommended settins 2 or 3. This controls which
  # equipment slot the sound effects relate to.
  # Weapon = 0 , Shield = 1 , Head = 2 , Body = 3 , Accessory = 4
  ArmorSlot = 3 # Default 3, Ignored if guarding with a shield.
  GuardSlot = 1 # Default 1, Has priority while guarding with a shield.
  Affect_Skills = false # SE is also used for non normal attacks if set to true.
	
  # Sound effect played when an actor recieves damage.
  # Sound effect file names found in (Project_Name)/Audio/SE
  ActorArmor = {
  0 => {:File => "Damage3", :Volume => 99, :Pitch => 100}, # Naked
  1 => {:File => "Damage3", :Volume => 95, :Pitch => 120}, # General Armor
  2 => {:File => "Damage2", :Volume => 90, :Pitch => 150}, # Magic Armor
  3 => {:File => "Damage4", :Volume => 85, :Pitch => 110}, # Light Armor
  4 => {:File => "Damage1", :Volume => 80, :Pitch => 150}, # Heavy Armor
  } # Don't Touch!
	
  # Sound effect played when an enemy recieves damage.
  # Sound effect file names found in (Project_Name)/Audio/SE
  ActorWeapon = {
  0  => {:File => "Blow3"  , :Volume => 87, :Pitch => 125}, # Barehanded
  1  => {:File => "Slash1" , :Volume => 99, :Pitch =>  95}, # Axe
  2  => {:File => "Slash2" , :Volume => 70, :Pitch => 150}, # Claw
  3  => {:File => "Slash10", :Volume => 80, :Pitch => 130}, # Spear
  4  => {:File => "Sword3" , :Volume => 78, :Pitch => 150}, # Sword
  5  => {:File => "Flash2" , :Volume => 85, :Pitch => 150}, # Katana
  6  => {:File => "Bow3"   , :Volume => 80, :Pitch => 100}, # Bow
  7  => {:File => "Slash1" , :Volume => 65, :Pitch => 150}, # Dagger
  8  => {:File => "Blow8"  , :Volume => 99, :Pitch =>  90}, # Hammer
  9  => {:File => "Blow3"  , :Volume => 72, :Pitch => 125}, # Staff
  10 => {:File => "Gun1"   , :Volume => 90, :Pitch => 100}, # Gun
  } # Don't Touch!
#===============================================================================
# ** End of Settings
#-------------------------------------------------------------------------------
# Editing beyond this area may result in unfathomable terror.
#===============================================================================
end end # No Touchie!
$imported = {} if $imported.nil?
$imported[:RIN_ADamageSounds] = true
#===============================================================================
# ** Class: Game_Action
#===============================================================================
class Game_Action
  #--------------------------------------------------------------------------
  # * Alias Method: prepare
  #--------------------------------------------------------------------------
  alias :se_prepare :prepare
  def prepare ; se_prepare = $acting = @subject end # prepare
end # Game_Action
#===============================================================================
# ** Class: Game_Actor < Game_Battler
#===============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Method: perform_damage_effect
  #--------------------------------------------------------------------------
  alias :rinse_damage_effect :perform_damage_effect
  def perform_damage_effect
    return unless $game_party.in_battle
    unless RINOBI::ActorSound::Affect_Skills
      return rinse_damage_effect unless $acting.current_action.attack? end
    if guard? && equips[RINOBI::ActorSound::GuardSlot].is_a?(RPG::Armor)
      armor = equips[RINOBI::ActorSound::GuardSlot].atype_id
    else if equips[RINOBI::ActorSound::ArmorSlot].nil? then armor = 0
      else armor = equips[RINOBI::ActorSound::ArmorSlot].atype_id end end
    if !RINOBI::ActorSound::ActorArmor.include?(armor)
      return rinse_damage_effect end
    file   = RINOBI::ActorSound::ActorArmor[armor][:File]
    volume = RINOBI::ActorSound::ActorArmor[armor][:Volume]
    pitch  = RINOBI::ActorSound::ActorArmor[armor][:Pitch] 
    RPG::SE.new(file, volume, pitch).play
  end # perform_damage_effect
end # Game_Actor < Game_Battler
#===============================================================================
# ** Class: Game_Enemy < Game_Battler
#===============================================================================
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Method: perform_damage_effect
  #--------------------------------------------------------------------------
  alias :rinse_damage_effect :perform_damage_effect
  def perform_damage_effect
    return rinse_damage_effect unless $acting.is_a?(Game_Actor)
    unless RINOBI::ActorSound::Affect_Skills
      return rinse_damage_effect unless $acting.current_action.attack? end
    if $acting.equips[0].nil? then weapon = 0
    else weapon = $acting.equips[0].wtype_id end
    if !RINOBI::ActorSound::ActorWeapon.include?(weapon)
      return rinse_damage_effect end
    file   = RINOBI::ActorSound::ActorWeapon[weapon][:File]
    volume = RINOBI::ActorSound::ActorWeapon[weapon][:Volume]
    pitch  = RINOBI::ActorSound::ActorWeapon[weapon][:Pitch]
    RPG::SE.new(file, volume, pitch).play
  end # perform_damage_effect
end # Game_Enemy < Game_Battler