Advertisement
diamondandplatinum3

Enemy Voices in Battle ~ RGSS3

Oct 2nd, 2013
1,055
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 27.44 KB | None | 0 0
  1. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #             Enemy Voices in Battle
  3. #             Version: 1.0
  4. #             Author: DiamondandPlatinum3
  5. #             Date: October 2, 2012
  6. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. #  Description:
  8. #
  9. #    This script grants you the ability to have your enemies talk throughout
  10. #    battle.
  11. #
  12. #    Enemies will say things when attacking/using skills/getting damaged/etc
  13. #
  14. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. #------------------------------------------------------------------------------
  16. #  Instructions:
  17. #  
  18. #   ~ This script was built off the Actor Voices in Battle Script.
  19. #     As such, most of the setup process of this script is similar.
  20. #       There is a Video Tutorial explaining the Actor Voices in Battle Script.
  21. #       You may watch it here:      http://www.youtube.com/watch?v=CaQhoZg_FgI
  22. #       Script Available Here:      http://diamondandplatinum3.net/rpg-maker-scripts/rgss3-vxa/battle-scripts/actor-voices-in-battle/
  23. #
  24. #
  25. #   ~ In the Editable Region Below, you must set a folder to which will contain
  26. #     all of your new voices.
  27. #     In addition, inside of THAT folder, you must also create a new folder for
  28. #     each enemy and name the folder by that enemy name.
  29. #     Example: Slime, Jellyfish, Angel
  30. #
  31. #
  32. #   ~ You can set up most of this script in the editable region below; you can
  33. #     set up battle voices for specific skills manually however.
  34. #     You do this by inserting the following code into the notetag of the
  35. #     Skill/Item:
  36. #
  37. #       ~EnemyVoice: ID, "Voice_Filename"
  38. #
  39. #               or
  40. #
  41. #       ~EnemyVoice: ID, "Voice_Filename", Volume, Pitch, Wait Frames
  42. #
  43. #
  44. #     Replace the ID with the id of the enemy that you are using this tag with.
  45. #     Replace the "Voice_Filename" with the filename of the SE you will be playing
  46. #
  47. #     You do not need to insert Volume, Pitch or Wait Frames afterwards, but you
  48. #     can if you wish to specify them.
  49. #     You may use this same tag on a skill twice to allow for more than one voice
  50. #     per skill or for different enemies.
  51. #
  52. #
  53. #   ~ A Screenshot example of the above may be found here:
  54. #             http://i.imgur.com/MhKFood.png    <= Notetag Example
  55. #             http://i.imgur.com/eooTs6y.png    <= Actor Voices and Enemy Voices (only if Actor Voices in Battle is imported)
  56. #
  57. #             http://i.imgur.com/Oqc9BGA.png    <= Voices Folder
  58. #             http://i.imgur.com/cq1JPBc.png    <= Individual Folders
  59. #
  60. #
  61. #
  62. #   ~ In the editable region section your enemies can have more than one thing to
  63. #     say. It the same pattern of: "filename", volume, pitch, frames_to_wait, repeat;
  64. #     until you finish it, I trust your common sense to figure out how :)
  65. #
  66. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  67. #------------------------------------------------------------------------------
  68. #  Engine Modifications:
  69. #
  70. #   ~ class Scene_Battle:
  71. #       apply_item_effects        (aliased)
  72. #
  73. #
  74. #   ~ class Game_Enemy:
  75. #       use_item                  (aliased)
  76. #       die                       (aliased)
  77. #       change_exp                (aliased)
  78. #       execute_damage            (aliased)
  79. #       on_damage                 (aliased)
  80. #
  81. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  82. ($diamondandplatinum3_scripts ||= {})[:EnemyBattleVoices] = true
  83. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  84. module DiamondandPlatinum3
  85. module EnemyBattleVoices
  86.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  87.   #                                                        -=
  88.   #                 Editable Region        ////            ==
  89.   #                                                        =-
  90.   #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  91.  
  92.   # You must create a new folder inside of your SE Audio folder and name it
  93.   # Whatever you decided to call it just below
  94.   FOLDER_DIRECTORY_NAME = "Battle_Voices"
  95.  
  96.  
  97.  
  98.   # This Event Switch when turned on will mute the voices from being played.
  99.   # They will still play, you just won't hear them
  100.   #
  101.   # If you leave the event switch id as zero, that means you can NEVER turn off the
  102.   # Enemy Battle Voices
  103.   EVENT_SWITCH_ID = 0
  104.  
  105.  
  106.   # If the enemy has been inflicted with any of these states, they will have their
  107.   # voices muted until it is cured.
  108.   # State No.4 by default is the Silence state, which is a reasonable state for muting
  109.   # someone. you can add more states after it by adding another ID number and a comma
  110.   #
  111.   # If you do not want any state to mute you, simply erase everything inside the square brackets
  112.   SILENCE_STATES = [ 4, ]
  113.  
  114.  
  115.   # Here you can choose the Skills which your Enemy Voices will not play for.
  116.   # By default, Skills 1-7 are skills which are used with certain commands.
  117.   # Some of those commands have their own specific Enemy Voice, such as Attacking.
  118.   # As such it is advisable to input the Skill ID referring to those
  119.   # commands in this option.
  120.   # If you are using the Default Skillset, you can leave this option as is.
  121.   # However if you're using custom skills, please make sure they're not being
  122.   # omitted inside of this option.
  123.   #
  124.   # You may also use this option to stop custom skills from having voices if you'd
  125.   # prefer.
  126.   SKILLS_NOT_TO_PLAY_VOICE_FOR = [ 1, 2, 3, 4, 5, 6, 7, ]
  127.  
  128.  
  129.   # If you've been playing and noticed that battle voices tend to happen a bit too often
  130.   # for your liking, you may use this Option to decrease the frequency in which they will
  131.   # say general things (like attacking, using skills, etc). Non-general voices (such as
  132.   # specific skills) will still play whenever they are used.
  133.   #
  134.   #
  135.   # This works as a percentage out of 100.
  136.   VOICE_FREQUENCY = 100
  137.  
  138.  
  139.   # If an attack has multiple hits, do you want the actor in question to keep
  140.   # screaming battle cries for each hit?
  141.   PLAY_MULTIPLE_VOICES_FOR_MULTIPLE_HITS = true
  142.  
  143.  
  144.  
  145.   #=============================================================================
  146.   #    Battle Voices
  147.   #-----------------------------------------------------------------------------
  148.   #   These voices are heard throughout the battle, such as when attacking,
  149.   #   using a skill or taking damage, etc
  150.   #=============================================================================
  151.  
  152.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  153.   # * WHEN ENEMY IS ATTACKING
  154.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  155.   ENEMY_ATTACKING = { # <= Do Not Touch This Line
  156.  
  157.     # What Enemy One (Default: Slime) Will Say when Normal Attacking
  158.     1 => [
  159.            "Attack01", 80, 100, 0,
  160.            "Attack02", 80, 100, 0,
  161.          ],
  162.  
  163.      
  164.     # What Enemy Two (Default: Bat) Will Say when Normal Attacking
  165.     2 => [
  166.            "Attack01", 80, 100, 0,
  167.            "Attack02", 80, 100, 0,
  168.            "Attack03", 80, 100, 0,
  169.          ],
  170.          
  171.    
  172.     # What Enemy Nine (Default: Jellyfish) Will Say when Normal Attacking
  173.     9 => [
  174.            "Attack01", 80, 100, 0,
  175.          ],
  176.          
  177.          
  178.     # What Enemy Twenty-Nine (Default: Demon King) Will Say when Normal Attacking
  179.     29 =>[
  180.            "Attack01", 80, 100, 0,
  181.          ],
  182.          
  183.  
  184.  
  185.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  186.   # * WHEN USING A SKILL
  187.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  188.   }; USING_SKILLS = { # <= Do Not Touch This Line
  189.  
  190.     # What Enemy Twenty-Nine (Default: Demon King) Will Say when using a generic skill
  191.     29 =>[
  192.            "Using Generic Skill01", 80, 100, 0,
  193.          ],  
  194.          
  195.          
  196.          
  197.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  198.   # * WHEN ENEMY MISSED THE ACTOR
  199.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  200.   }; MISSED_ACTOR_TARGET = { # <= Do Not Touch This Line
  201.  
  202.     # What Enemy Twenty-Nine (Default: Demon King) Will Say
  203.     29 =>[
  204.            "Missed Enemy01", 80, 100, 0,
  205.          ],
  206.  
  207.  
  208.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  209.   # * WHEN ENEMY EVADED ACTOR'S ATTACK
  210.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  211.   }; DODGED_ACTOR_ATTACK = { # <= Do Not Touch This Line
  212.  
  213.     # What Enemy Twenty-Nine (Default: Demon King) Will Say
  214.     29 =>[
  215.            "Dodged Enemy Attack01", 80, 100, 0,
  216.          ],
  217.        
  218.        
  219.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  220.   # * WHEN ENEMY TAKES LITTLE DAMAGE FROM ACTOR ATTACK
  221.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  222.   }; LITTLE_DAMAGE = { # <= Do Not Touch This Line
  223.  
  224.     # Percentage of Health that must be lost from an individual attack for these
  225.     # to be played
  226.     :ratio => 15 ,
  227.  
  228.     # What Enemy One (Default: Slime) Will Say When Hurt This Much
  229.     1 => [
  230.            "Little Damage1", 80, 100, 0,
  231.          ],
  232.  
  233.      
  234.     # What Enemy Two (Default: Bat) Will Say When Hurt This Much
  235.     2 => [
  236.            "Little Damage1", 80, 100, 0,
  237.          ],
  238.  
  239.          
  240.     # What Enemy Twenty-Nine (Default: Demon King) Will Say When Hurt This Much
  241.     29 =>[
  242.            "Little Damage1", 80, 100, 0,
  243.          ],
  244.          
  245.          
  246.          
  247.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  248.   # * WHEN ENEMY TAKES SIGNIFICANT DAMAGE FROM ACTOR ATTCK
  249.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  250.   }; SIGNIFICANT_DAMAGE = { # <= Do Not Touch This Line
  251.  
  252.     # Percentage of Health that must be lost from an individual attack for these
  253.     # to be played
  254.     :ratio => 35 ,
  255.  
  256.     # What Enemy One (Default: Slime) Will Say When Hurt This Much
  257.     1 => [
  258.            "Significant Damage1", 80, 100, 0,
  259.          ],
  260.  
  261.      
  262.     # What Enemy Two (Default: Bat) Will Say When Hurt This Much
  263.     2 => [
  264.            "Significant Damage1", 80, 100, 0,
  265.          ],
  266.  
  267.          
  268.     # What Enemy Twenty-Nine (Default: Demon King) Will Say When Hurt This Much
  269.     29 =>[
  270.            "Significant Damage1", 80, 100, 0,
  271.          ],
  272.          
  273.      
  274.          
  275.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  276.   # * WHEN ENEMY TAKES HEAVY DAMAGE FROM ACTOR ATTACK
  277.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  278.   }; HEAVY_DAMAGE = { # <= Do Not Touch This Line
  279.  
  280.     # Percentage of Health that must be lost from an individual attack for these
  281.     # to be played
  282.     :ratio => 50 ,
  283.  
  284.     # What Enemy One (Default: Slime) Will Say When Hurt This Much
  285.     1 => [
  286.            "Heavy Damage1", 80, 100, 0,
  287.          ],
  288.  
  289.      
  290.     # What Enemy Two (Default: Bat) Will Say When Hurt This Much
  291.     2 => [
  292.            "Heavy Damage1", 80, 100, 0,
  293.          ],
  294.  
  295.          
  296.     # What Enemy Twenty-Nine (Default: Demon King) Will Say When Hurt This Much
  297.     29 =>[
  298.            "Heavy Damage1", 80, 100, 0,
  299.          ],
  300.          
  301.          
  302.          
  303.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  304.   # * WHEN ENEMY TAKES MASSIVE DAMAGE FROM ACTOR ATTACK
  305.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  306.   }; MASSIVE_DAMAGE = { # <= Do Not Touch This Line
  307.  
  308.     # Percentage of Health that must be lost from an individual attack for these
  309.     # to be played
  310.     :ratio => 65 ,
  311.  
  312.  
  313.     # What Enemy One (Default: Slime) Will Say When Hurt This Much
  314.     1 => [
  315.            "Massive Damage1", 80, 100, 0,
  316.          ],
  317.  
  318.      
  319.     # What Enemy Two (Default: Bat) Will Say When Hurt This Much
  320.     2 => [
  321.            "Massive Damage1", 80, 100, 0,
  322.          ],
  323.  
  324.          
  325.     # What Enemy Twenty-Nine (Default: Demon King) Will Say When Hurt This Much
  326.     29 =>[
  327.            "Massive Damage1", 80, 100, 0,
  328.          ],
  329.          
  330.  
  331.          
  332.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  333.   # * WHEN ENEMY TAKES DAMAGE, BUT NOTHING THEY CAN'T SHRUG OFF
  334.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  335.   }; DEFAULT_DAMAGE = { # <= Do Not Touch This Line
  336.  
  337.  
  338.     # What Enemy One (Default: Slime) Will Say When Hurt This Much
  339.     1 => [
  340.            "Default Damage1", 80, 100, 0,
  341.          ],
  342.  
  343.      
  344.     # What Enemy Two (Default: Bat) Will Say When Hurt This Much
  345.     2 => [
  346.            "Default Damage1", 80, 100, 0,
  347.          ],
  348.  
  349.          
  350.     # What Enemy Twenty-Nine (Default: Demon King) Will Say When Hurt This Much
  351.     29 =>[
  352.            "Default Damage1", 80, 100, 0,
  353.          ],
  354.  
  355.          
  356.  
  357.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  358.   # * WHEN ENEMY HAS THEIR HP OR MP RESTORED, EITHER BY ITEMS OR MAGIC
  359.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  360.   }; HP_MP_RESTORE = { # <= Do Not Touch This Line
  361.  
  362.     # Allowed to speak if this enemy healed itself?
  363.     :self_heal_speak  =>  true ,
  364.    
  365.    
  366.     # What Enemy Twenty-Nine (Default: Demon King) Will Say When HP/MP is Restored
  367.     29 =>[
  368.            "HP_MP Restored1", 80, 100, 0,
  369.          ],
  370.  
  371.  
  372.          
  373.          
  374.          
  375.   #=============================================================================
  376.   #    Death & Revive Voices
  377.   #-----------------------------------------------------------------------------
  378.   #   These voices are heard when an enemy is defeated in battle
  379.   #=============================================================================
  380.  
  381.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  382.   # * WHEN ACTOR HAS JUST BEEN KO'D IN BATTLE
  383.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  384.   # Voices to play when an actor dies
  385.   }; DEATH_VOICE = { # <= Do Not Touch This Line
  386.  
  387.  
  388.     # What Enemy One (Default: Slime) Will Say When They Die
  389.     1 => [
  390.            "Death Cry1", 80, 100, 0,
  391.          ],
  392.  
  393.      
  394.     # What Enemy Two (Default: Bat) Will Say When They Die
  395.     2 => [
  396.            "Death Cry1", 80, 100, 0,
  397.          ],
  398.  
  399.          
  400.     # What Enemy Twenty-Nine (Default: Demon King) Will Say When They Die
  401.     29 =>[
  402.            "Death Cry1", 80, 100, 0,
  403.          ],
  404.                                                  
  405.          
  406.          
  407.          
  408.          
  409. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  410. #                                                        -=
  411. };    # End Of Editable Region           ////            ==
  412. #                                                        =-
  413. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.   CURRENT_VERSION = 1.0
  421.   ACTOR_VOICES_IMPORTED = !$diamondandplatinum3_scripts[:BattleVoices].nil?
  422.   #------------------------------------------------------------------------
  423.   # * New Method: Check Version Compatibility
  424.   #------------------------------------------------------------------------
  425.   def self.check_version_compatibility( version )
  426.     return :outdated_version if version > CURRENT_VERSION
  427.     return :outdated_patch   if version < CURRENT_VERSION
  428.     return :compatible
  429.   end
  430.   #------------------------------------------------------------------------
  431.   # * New Method: Play Voice
  432.   #------------------------------------------------------------------------
  433.   def self.play_voice( voice_hash, enemy_troopmember_index )
  434.     return true if !allowed_to_speak?(enemy_troopmember_index)
  435.    
  436.     # Get Voice Array
  437.     if voice_hash.is_a?(Hash)
  438.       voice_array = voice_hash[$game_troop.members[enemy_troopmember_index].enemy_id]
  439.     elsif voice_hash.is_a?(Array)
  440.       voice_array = voice_hash
  441.     end
  442.    
  443.     # If voice_array is not empty
  444.     unless voice_array.nil? || voice_array.empty?
  445.       index = rand(voice_array.size / 4) * 4
  446.       if voice_array[index].is_a?(String) && voice_array[index + 1].is_a?(Integer) && voice_array[index + 2].is_a?(Integer)
  447.        
  448.         # Get the Enemy Folder Name
  449.         folder_name = $game_troop.members[enemy_troopmember_index].enemy.name
  450.        
  451.         # Get Path to File
  452.         pathtofile = "/" + FOLDER_DIRECTORY_NAME + "/" + folder_name + "/" + voice_array[index]
  453.        
  454.         # Play Voice
  455.         RPG::SE.new(pathtofile, voice_array[index + 1], voice_array[index + 2]).play
  456.        
  457.         # Wait if necessary
  458.         SceneManager.scene.wait(voice_array[index + 3]) unless !voice_array[index + 3].is_a?(Integer) || !SceneManager.scene_is?(Scene_Battle)
  459.         return true
  460.       end
  461.     end
  462.     # We return true and false to determine whether a voice play was successful or not
  463.     return false
  464.   end
  465.   #------------------------------------------------------------------------
  466.   # * New Method: Allowed to Speak?
  467.   #------------------------------------------------------------------------
  468.   def self.allowed_to_speak?(enemy_troopmember_index)
  469.     return false if check_if_enemy_muted(enemy_troopmember_index)
  470.     return rand(100) < VOICE_FREQUENCY
  471.   end
  472.   #------------------------------------------------------------------------
  473.   # * New Method: Check For Muted Enemy
  474.   #------------------------------------------------------------------------
  475.   def self.check_if_enemy_muted(enemy_troopmember_index)
  476.     return true if $game_switches[EVENT_SWITCH_ID]
  477.     return $game_troop.members[enemy_troopmember_index].states.any? { |state| SILENCE_STATES.include?(state.id) }
  478.   end
  479.   #------------------------------------------------------------------------
  480.   # * New Method: Play "I Missed Enemy" Voice
  481.   #------------------------------------------------------------------------
  482.   def self.play_missed_enemies_voice(enemy_troopmember_index)
  483.     return play_voice(MISSED_ACTOR_TARGET, enemy_troopmember_index)
  484.   end
  485.   #------------------------------------------------------------------------
  486.   # * New Method: Play "I Evaded Enemy" Voice
  487.   #------------------------------------------------------------------------
  488.   def self.play_evaded_enemy_voice(enemy_troopmember_index)
  489.     return play_voice(DODGED_ACTOR_ATTACK, enemy_troopmember_index)
  490.   end
  491.   #------------------------------------------------------------------------
  492.   # * New Method: Play "Normal Attack" Voice
  493.   #------------------------------------------------------------------------
  494.   def self.play_normal_attack_voice(enemy_troopmember_index)
  495.     return play_voice(ENEMY_ATTACKING, enemy_troopmember_index)
  496.   end
  497.   #------------------------------------------------------------------------
  498.   # * New Method: Play "Using Skill" Voice
  499.   #------------------------------------------------------------------------
  500.   def self.play_skill_voice(enemy_troopmember_index, skill_id)
  501.     voice = []
  502.     enemy_id = $game_troop.members[enemy_troopmember_index].enemy_id
  503.     $data_skills[skill_id].note.scan(/~EnemyVoice:\s*#{enemy_id.to_s}\,*\s*\"(.+?)\"\,*\s*(\d*)\,*\s*(\d*)\,*\s*(\d*)/im).collect{ |voice_info|
  504.       unless voice_info.empty?
  505.         voice.push(voice_info[0])
  506.         voice.push(voice_info[1] != "" ? voice_info[1].to_i : 80)
  507.         voice.push(voice_info[2] != "" ? voice_info[2].to_i : 100)
  508.         voice.push(voice_info[3] != "" ? voice_info[3].to_i : 0)
  509.       end
  510.     }
  511.    
  512.     # Modify Skill Voice to Generic Skill Voice if there is no specific voice for this Skill
  513.     if voice.empty?
  514.       return true if SKILLS_NOT_TO_PLAY_VOICE_FOR.include?(skill_id)
  515.       voice = USING_SKILLS
  516.     end
  517.    
  518.     return play_voice( voice, enemy_troopmember_index )
  519.   end
  520.   #------------------------------------------------------------------------
  521.   # * New Method: Play "Death" Voice
  522.   #------------------------------------------------------------------------
  523.   def self.play_death_voice(enemy_troopmember_index)
  524.     return play_voice(DEATH_VOICE, enemy_troopmember_index)
  525.   end
  526.   #------------------------------------------------------------------------
  527.   # * New Method: Play "Restored HP/MP" Voice
  528.   #------------------------------------------------------------------------
  529.   def self.play_healed_voice(enemy_troopmember_index)
  530.     return play_voice(HP_MP_RESTORE, enemy_troopmember_index)
  531.   end
  532.   #------------------------------------------------------------------------
  533.   # * New Method: Play "Default Damage" Voice
  534.   #------------------------------------------------------------------------
  535.   def self.play_default_damage_voice(enemy_troopmember_index)
  536.     return play_voice(DEFAULT_DAMAGE, enemy_troopmember_index)
  537.   end
  538.   #------------------------------------------------------------------------
  539.   # * New Method: Play "Little Damage" Voice
  540.   #------------------------------------------------------------------------
  541.   def self.play_little_damage_voice(enemy_troopmember_index)
  542.     return play_voice(LITTLE_DAMAGE, enemy_troopmember_index)
  543.   end
  544.   #------------------------------------------------------------------------
  545.   # * New Method: Play "Significant Damage" Voice
  546.   #------------------------------------------------------------------------
  547.   def self.play_significant_damage_voice(enemy_troopmember_index)
  548.     return play_voice(SIGNIFICANT_DAMAGE, enemy_troopmember_index)
  549.   end
  550.   #------------------------------------------------------------------------
  551.   # * New Method: Play "Heavy Damage" Voice
  552.   #------------------------------------------------------------------------
  553.   def self.play_heavy_damage_voice(enemy_troopmember_index)
  554.     return play_voice(HEAVY_DAMAGE, enemy_troopmember_index)
  555.   end
  556.   #------------------------------------------------------------------------
  557.   # * New Method: Play "Massive Damage" Voice
  558.   #------------------------------------------------------------------------
  559.   def self.play_massive_damage_voice(enemy_troopmember_index)
  560.     return play_voice(MASSIVE_DAMAGE, enemy_troopmember_index)
  561.   end
  562.  
  563.  
  564. end # BattleVoices Module
  565. end # DiamondandPlatinum3 Module
  566.  
  567.  
  568.  
  569.  
  570. #==============================================================================
  571. # ** Scene_Battle
  572. #------------------------------------------------------------------------------
  573. #  This class performs battle screen processing.
  574. #==============================================================================
  575.  
  576. class Scene_Battle < Scene_Base
  577.   #--------------------------------------------------------------------------
  578.   # * Alias Listings
  579.   #--------------------------------------------------------------------------
  580.   alias dp3_ebv_scenebattle_applyitemeffects_1s098yu9j    apply_item_effects
  581.  
  582.   #--------------------------------------------------------------------------
  583.   # * Aliased Method: Apply Skill/Item Effect
  584.   #--------------------------------------------------------------------------
  585.   def apply_item_effects(*args)
  586.     # Call Original Method
  587.     dp3_ebv_scenebattle_applyitemeffects_1s098yu9j(*args)
  588.    
  589.     # If Result was a Miss, and an enemy was not targeting an enemy
  590.     if !args[0].result.hit?
  591.       if !args[0].enemy? && @subject.enemy?
  592.         DiamondandPlatinum3::EnemyBattleVoices::play_missed_enemies_voice(@subject.index)
  593.       elsif args[0].enemy? && !@subject.enemy?
  594.         DiamondandPlatinum3::EnemyBattleVoices::play_evaded_enemy_voice(args[0].index)
  595.       end
  596.     end
  597.   end
  598. end # Class
  599.  
  600.  
  601.  
  602. #==============================================================================
  603. # ** Game_Enemy
  604. #------------------------------------------------------------------------------
  605. #  This class handles enemies. It used within the Game_Troop class
  606. # ($game_troop).
  607. #==============================================================================
  608.  
  609. class Game_Enemy < Game_Battler
  610.   #--------------------------------------------------------------------------
  611.   # * Alias Listings
  612.   #--------------------------------------------------------------------------
  613.   alias dp3_gameenemy_die_1s098yu9j                     die
  614.   alias dp3_gameenemy_useitem_1s098yu9j                 use_item
  615.   alias dp3_gameenemy_executedamage_1s098yu9j           execute_damage
  616.   alias dp3_gameenemy_ondamage_1s098yu9j                on_damage
  617.  
  618.   #--------------------------------------------------------------------------
  619.   # * Aliased Method: Use Skill/Item
  620.   #--------------------------------------------------------------------------
  621.   def use_item(*args)
  622.     if args[0].is_a?(RPG::Skill)
  623.       if args[0].id == attack_skill_id
  624.         DiamondandPlatinum3::EnemyBattleVoices::play_normal_attack_voice(@index)
  625.       else
  626.         DiamondandPlatinum3::EnemyBattleVoices::play_skill_voice(@index, args[0].id)
  627.       end
  628.     end
  629.    
  630.     # Call Original Method
  631.     dp3_gameenemy_useitem_1s098yu9j(*args)
  632.   end
  633.  
  634.   #--------------------------------------------------------------------------
  635.   # * Aliased Method: Knock Out
  636.   #--------------------------------------------------------------------------
  637.   def die( *args )
  638.     DiamondandPlatinum3::EnemyBattleVoices::play_death_voice(@index)
  639.    
  640.     # Call Original Method
  641.     dp3_gameenemy_die_1s098yu9j( *args )
  642.   end
  643.  
  644.   #--------------------------------------------------------------------------
  645.   # * Aliased Method: Execute Damage
  646.   #--------------------------------------------------------------------------
  647.   def execute_damage(*args)
  648.     current_hp = self.hp
  649.     current_mp = self.mp
  650.     dp3_gameenemy_executedamage_1s098yu9j(*args)
  651.    
  652.    
  653.     # Play Healed Voice if Healed and Allowed
  654.     if current_hp < self.hp || current_mp < self.mp
  655.       if args[0].enemy?
  656.         if args[0] == self
  657.           if DiamondandPlatinum3::EnemyBattleVoices::HP_MP_RESTORE[:self_heal_speak]
  658.             DiamondandPlatinum3::EnemyBattleVoices::play_healed_voice(@index)
  659.           end
  660.         else
  661.           DiamondandPlatinum3::EnemyBattleVoices::play_healed_voice(@index)
  662.         end
  663.       end
  664.     end
  665.   end
  666.  
  667.   #--------------------------------------------------------------------------
  668.   # * Aliased Method: Processing When Suffering Damage
  669.   #--------------------------------------------------------------------------
  670.   def on_damage(*args)
  671.     dp3_play_appropriate_enemy_damage_voice( args[0] ) if args[0] > 0 && (self.hp - args[0]) > 0
  672.    
  673.     # Call Original Method
  674.     dp3_gameenemy_ondamage_1s098yu9j( *args )
  675.   end
  676.  
  677.   #--------------------------------------------------------------------------
  678.   # * New Method: Get Enemy Damage Voice Array
  679.   #--------------------------------------------------------------------------
  680.   def dp3_play_appropriate_enemy_damage_voice( value )
  681.     #~~~~~ Play Massive Damage Voice ~~~~~#
  682.     if value > self.mhp * (DiamondandPlatinum3::EnemyBattleVoices::MASSIVE_DAMAGE[:ratio] * 0.01)
  683.       DiamondandPlatinum3::EnemyBattleVoices::play_massive_damage_voice(@index)
  684.     #~~~~~ Play Heavy Damage Voice ~~~~~#
  685.     elsif value > self.mhp * (DiamondandPlatinum3::EnemyBattleVoices::HEAVY_DAMAGE[:ratio] * 0.01)
  686.       DiamondandPlatinum3::EnemyBattleVoices::play_heavy_damage_voice(@index)
  687.     #~~~~~ Play Significant Damage Voice ~~~~~#
  688.     elsif value > self.mhp * (DiamondandPlatinum3::EnemyBattleVoices::SIGNIFICANT_DAMAGE[:ratio] * 0.01)
  689.       DiamondandPlatinum3::EnemyBattleVoices::play_significant_damage_voice(@index)
  690.     #~~~~~ Play Little Damage Voice ~~~~~#
  691.     elsif value > self.mhp * (DiamondandPlatinum3::EnemyBattleVoices::LITTLE_DAMAGE[:ratio] * 0.01)
  692.       DiamondandPlatinum3::EnemyBattleVoices::play_little_damage_voice(@index)
  693.     #~~~~~ Play Pitance Damage Voice ~~~~~#
  694.     else
  695.       DiamondandPlatinum3::EnemyBattleVoices::play_default_damage_voice(@index)
  696.     end
  697.   end
  698. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement