[Script] [ACE] [Battle/add-on] Actor Voices in Battle

in RPG Maker
[align=center][size=xx-large]Actor Voices in Battle 1.0[/size][/align]
[chapter]Giới thiệu[/chapter]
Lồng tiếng cho nhân vật khi chiến đấu.
VD: Khi bị thương, nhân vật hét "AAAA, Đau quá má ơi ~".
Khi sử dụng chiêu "Blah", nhân vật hô "Blah!!!"
Khi được hồi máu bởi nhân vật khác, nhân vật nói "cảm ơn bà bà"
[chapter]Tính năng[/chapter]
- Dễ dàng cài đặt
- Tùy chỉnh những file giọng nói cho mỗi trường hợp khác nhau.
- Dễ dàng cài đặt giọng nói khi xài Skill bằng notetag.
- Và nhiều tính năng khác...
[chapter]Hướng dẫn sử dụng[/chapter]
Trong Script.
[chapter]SCRIPT[/chapter]
[chapter]Credit[/chapter]
BluntSword (cho file giọng nói trong DEMO)
DiamondandPlatinum3 (cho Script)
[chapter]Điều khoản khi sử dụng[/chapter]
Không được sử dụng cho dự án thương mại
[chapter]Giới thiệu[/chapter]
Lồng tiếng cho nhân vật khi chiến đấu.
VD: Khi bị thương, nhân vật hét "AAAA, Đau quá má ơi ~".
Khi sử dụng chiêu "Blah", nhân vật hô "Blah!!!"
Khi được hồi máu bởi nhân vật khác, nhân vật nói "cảm ơn bà bà"

[chapter]Tính năng[/chapter]
- Dễ dàng cài đặt
- Tùy chỉnh những file giọng nói cho mỗi trường hợp khác nhau.
- Dễ dàng cài đặt giọng nói khi xài Skill bằng notetag.
- Và nhiều tính năng khác...
[chapter]Hướng dẫn sử dụng[/chapter]
Trong Script.
[chapter]SCRIPT[/chapter]
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Actor Voices in Battle
# Version: 1.1
# Authors: DiamondandPlatinum3
# Date: December 11, 2012
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Description:
#
# This script grants you the ability to have your actors talk throughout
# battle; it will pick an actor at random at the start of battle to say
# something relevent about what they expect from this battle.
#
# After that, the actors will get voices when attacking and when getting
# damaged, also when using a skill.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#------------------------------------------------------------------------------
# Instructions:
#
# You can set up most of this script in the editable region below; you will
# need to set up battle voices for each skill manually however. You do this
# by inserting the following code into the notetag of the skill:
#
# ~ActorVoice: ID, "Voice_Filename"
#
# or
#
# ~ActorVoice: ID, "Voice_Filename", Volume, Pitch, Wait Frames
#
#
# Replace the ID with the id of the actor who you are using this tag with.
# Replace the "Voice_Filename" with the filename of the SE you will be playing
#
# You do not need to insert Volume, Pitch or Wait Frames afterwards, but you can if you
# wish to specify them.
# You may use this same tag on a skill twice for different actors.
#
#
# A Screenshot example of the above may be found here:
# http://img4host.net/upload/1100043950c66a875cc51.png
#
#
#
# In the editable region section your actors can have more than one thing to
# say. It the same pattern of: "filename", volume, pitch, frames_to_wait, repeat;
# until you finish it, I trust your common sense to figure out how :)
#
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
module DiamondandPlatinum3
module BattleVoices
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# -=
# Editable Region //// ==
# =-
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# You must create a new folder inside of your SE Audio folder and name it
# Whatever you decided to call it just below
FOLDER_DIRECTORY_NAME = "Battle_Voices"
# This Event Switch when turned on will mute the voice being played.
# They will still play, you just won't hear them
#
# If you leave the event switch id as zero, that means you can NEVER turn off the
# Battle Voices
EVENT_SWITCH_ID = 0
# If your actor has been inflicted with any of these states, they will have their
# voices muted until it is cured.
# State No.4 by default is the Silence state, which is a reasonable state for muting
# you. you can add more states after it by adding another ID number and a comma
#
# If you do not want any state to mute you, simply erase everything inside the square brackets
SILENCE_STATES = [ 4, ]
#======================================
# Battle Start Voices ~ The Below will only be said when a battle starts
#======================================
# If The enemy troop in battle has this many MORE members than you do,
# an actor will say something about how you are outnumbered
TOO_MANY_ENEMIES_RATIO = 2
TOO_MANY_ENEMIES = [ # <= Do Not Touch This Line
# What Actor One Will Say
# "SE Filename", Volume, Pitch, Frames_to_Wait, Repeat if you want more voices
[ "Encounter Too Many Enemies1", 80, 100, 0,
"Encounter Too Many Enemies2", 80, 100, 0, ],
# What Actor Two Will Say
[ "Encounter Too Many Enemies1", 80, 100, 0,
"Encounter Too Many Enemies2", 80, 100, 0, ],
# What Actor Three Will Say
[ "theres too many of them", 80, 100, 0, ],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# If party total HP is below this Ratio, an Actor will say something about it
]; PARTY_NEEDS_HEALING_RATIO = 40
PARTY_NEEDS_HEALING = [ # <= Do Not Touch This Line
# What Actor One Will Say
[], #<= If you leave it empty like so, then no voice will be played by this actor
# What Actor Two Will Say
[ "Encounter Party Needs Healing1", 80, 100, 0, ],
# What Actor Three Will Say
[ "we cant fight like this", 80, 100, 0, ],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
#====================================================================
# Your stats are always 100%, so if the enemy troop stats are below
# the editable ratio below; that means they are considered VERY WEAK.
]; VERY_WEAK_ENEMIES_RATIO = 40
VERY_WEAK_ENEMIES = [ # <= Do Not Touch This Line
# What Actor One Will Say
[ "Encounter Very Weak Enemies1", 80, 100, 0, ],
# What Actor Two Will Say
[ "Encounter Very Weak Enemies1", 80, 100, 0, ],
# What Actor Three Will Say
[ "very weak", 80, 100, 0, ],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# What stats does the enemy need to be below for them be considered weak against you?
]; WEAK_ENEMIES_RATIO = 80
WEAK_ENEMIES = [ # <= Do Not Touch This Line
# What Actor One Will Say
[ "Encounter Weak Enemies1", 80, 100, 0, ],
# What Actor Two Will Say
[ "Encounter Weak Enemies1", 80, 100, 0, "Encounter Weak Enemies2", 80, 100, 0, ],
# What Actor Three Will Say
[ "weak", 80, 100, 0, ],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# There is no Ratio for Equal Enemies
]; EQUAL_ENEMIES = [ # <= Do Not Touch This Line
# What Actor One Will Say
[ "Encounter Equal Enemies1", 80, 100, 0,
"Encounter Equal Enemies2", 80, 100, 0,
"Encounter Equal Enemies3", 80, 100, 0, ],
# What Actor Two Will Say
[ "Encounter Equal Enemies1", 80, 100, 0,
"Encounter Equal Enemies2", 80, 100, 0, ],
# What Actor Three Will Say
[ "average", 80, 100, 0, ],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# If your stats are 100% and the enemy is 120%, they are 20% stronger than you
]; STRONG_ENEMIES_RATIO = 120
STRONG_ENEMIES = [ # <= Do Not Touch This Line
# What Actor One Will Say
[ "Encounter Strong Enemies1", 80, 100, 0,
"Encounter Strong Enemies2", 80, 100, 0, ],
# What Actor Two Will Say
[ "Encounter Strong Enemies1", 80, 100, 0,
"Encounter Strong Enemies2", 80, 100, 0, ],
# What Actor Three Will Say
[ "strong", 80, 100, 0, ],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# What Power does the enemy troop need to be to be considered very strong?
]; VERY_STRONG_ENEMIES_RATIO = 160
VERY_STRONG_ENEMIES = [ # <= Do Not Touch This Line
# What Actor One Will Say
[ "Encounter Very Strong Enemies1", 80, 100, 0,
"Encounter Very Strong Enemies2", 80, 100, 0, ],
# What Actor Two Will Say
[ "Encounter Very Strong Enemies1", 80, 100, 0,
"Encounter Very Strong Enemies2", 80, 100, 0, ],
# What Actor Three Will Say
[ "very strong", 80, 100, 0, ],
# You can make more actors voices by copy-pasting the above
#====================================================================
#======================================
# Battle Items Voices
#======================================
# These are generic things that your actors will say when using an item in battle.
# You can use note tags on specific items (same as skills), this is just for the more generic items.
#--------------------------------------------------------------------
]; USING_ITEMS = [ # <= Do Not Touch This Line
# What Actor One Will Say when using an item
[ "Using Item1", 80, 100, 10, ],
# What Actor Two Will Say when using an item
[ "Using Item1", 80, 100, 10, ],
# What Actor Three Will Say when using an item
[],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
#======================================
# Battle Scene Voices ~ These are heard throughout the battle
#======================================
]; ACTOR_ATTACKING = [ # <= Do Not Touch This Line
# What Actor One Will Say when Normal Attacking
[ "Attack01", 80, 100, 0, "Attack02", 80, 100, 0, "Attack03", 80, 100, 0,
"Attack04", 80, 100, 0, "Attack05", 80, 100, 0, "Attack06", 80, 100, 0,
"Attack07", 80, 100, 0, "Attack08", 80, 100, 0, "Attack09", 80, 100, 0,
"Attack10", 80, 100, 0, ],
# What Actor Two Will Say when Normal Attacking
[ "Attack01", 80, 100, 0, "Attack02", 80, 100, 0, "Attack03", 80, 100, 0, ],
# What Actor Three Will Say when Normal Attacking
[ "attack", 80, 100, 0, ],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# Percentage of Health that must be lost from an attack for the following voices to play
]; LITTLE_DAMAGE_RATIO = 15
LITTLE_DAMAGE = [ # <= Do Not Touch This Line
# What Actor One Will Say when Hurt this much
[ "Little Damage1", 80, 100, 10, "Little Damage2", 80, 100, 10,
"Little Damage3", 80, 100, 10, ],
# What Actor Two Will Say when Hurt this much
[ "Little Damage1", 80, 100, 10, "Little Damage2", 80, 100, 10, ],
# What Actor Three Will Say when Hurt this much
[ "small damage", 80, 100, 10, ],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# Percentage of Health that must be lost from an attack for the following voices to play
]; SIGNIFICANT_DAMAGE_RATIO = 35
SIGNIFICANT_DAMAGE = [ # <= Do Not Touch This Line
# What Actor One Will Say when Hurt this much
[ "Significant Damage1", 80, 100, 10, "Significant Damage2", 80, 100, 10,
"Significant Damage3", 80, 100, 10, ],
# What Actor Two Will Say when Hurt this much
[ "Significant Damage1", 80, 100, 10, ],
# What Actor Three Will Say when Hurt this much
[ "medium damage", 80, 100, 10, ],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# Percentage of Health that must be lost from an attack for the following voices to play
]; HEAVY_DAMAGE_RATIO = 50
HEAVY_DAMAGE = [ # <= Do Not Touch This Line
# What Actor One Will Say when Hurt this much
[ "Heavy Damage1", 80, 100, 10, "Heavy Damage2", 80, 100, 10,
"Heavy Damage3", 80, 100, 10, ],
# What Actor Two Will Say when Hurt this much
[ "Heavy Damage1", 80, 100, 10, "Heavy Damage2", 80, 100, 10, ],
# What Actor Three Will Say when Hurt this much
[ "strong damage", 80, 100, 10, ],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# Percentage of Health that must be lost from an attack for the following voices to play
]; MASSIVE_DAMAGE_RATIO = 65
MASSIVE_DAMAGE = [ # <= Do Not Touch This Line
# What Actor One Will Say when Hurt this much
[ "Massive Damage1", 80, 100, 10, ],
# What Actor Two Will Say when Hurt this much
[ "Massive Damage1", 80, 100, 10, ],
# What Actor Three Will Say when Hurt this much
[ "strong damage", 80, 100, 10, ],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# If damage taken is not equal to any of the above, the following ones will play
]; DEFAULT_DAMAGE = [ # <= Do Not Touch This Line
# What Actor One Will Say when Hurt in battle
[ "Default Damage1", 80, 100, 10, ],
# What Actor Two Will Say when Hurt in battle
[ "Default Damage1", 80, 100, 10, ],
# What Actor Three Will Say when Hurt in battle
[ "small damage", 80, 100, 10, ],
# You can make more actors voices by copy-pasting the above
#====================================================================
# What your actors will say when healed in battle, whether via an item or by magic.
# This is used for both HP & MP Restoration.
]; HP_MP_RESTORE = [ # <= Do Not Touch This Line
# What Actor One Will Say when Healed in battle
[ "HP_MP Restore1", 80, 100, 10, ],
# What Actor Two Will Say when Healed in battle
[ "HP_MP Restore1", 80, 100, 10, ],
# What Actor Three Will Say when Healed in battle
[],
# You can make more actors voices by copy-pasting the above
#====================================================================
#======================================
# Death Voices ~ These are played when an character dies in battle
#======================================
# Voices to play when an actor dies
]; DEATH_VOICE = [ # <= Do Not Touch This Line
# What Actor One Will Say when they die
[ "Death Cry1", 80, 100, 10, ],
# What Actor Two Will Say when they die
[ "Death Cry1", 80, 100, 10, "Death Cry2", 80, 100, 10, ],
# What Actor Three Will Say when they die
[ "death", 80, 100, 10, ],
# You can make more actors voices by copy-pasting the above
#====================================================================
#======================================
# Escape Voices ~ These are played when you try to escape in battle
#======================================
# Sound to play when you try to escape
]; ESCAPE_ATTEMPT_VOICE = [ # <= Do Not Touch This Line
# What Actor One Will Say when they attempt to escape battle
[ "Escape Attempt1", 80, 100, 10, "Escape Attempt2", 80, 100, 10,
"Escape Attempt3", 80, 100, 10, ],
# What Actor Two Will Say when they attempt to escape battle
[ "Escape Attempt1", 80, 100, 10, ],
# What Actor Three Will Say when they attempt to escape battle
[],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# Sound to play when you successfully escape
]; SUCCESSFUL_ESCAPE = [ # <= Do Not Touch This Line
# What Actor One Will Say when they successfully escape from battle
[ "Successful Escape1", 80, 100, 0, "Successful Escape2", 80, 100, 0, ],
# What Actor Two Will Say when they successfully escape from battle
[ "Successful Escape1", 80, 100, 0, ],
# What Actor Three Will Say when they successfully escape from battle
[],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# Sound to play when you fail to escape
]; FAILED_ESCAPE = [ # <= Do Not Touch This Line
# What Actor One Will Say when they fail to escape from battle
[ "Failed Escape1", 80, 100, 0, "Failed Escape2", 80, 100, 0, ],
# What Actor Two Will Say when they fail to escape from battle
[ "Failed Escape1", 80, 100, 0, ],
# What Actor ThreeWill Say when they fail to escape from battle
[],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
#======================================
# Battle Victory Voices ~ These are heard when you are victorious in a battle
#======================================
# By default this is 50%, so if you win a battle with 50% LESS HP than what you
# went in with, these voices will play
]; THAT_WAS_TOUGH_RATIO = 50
THAT_WAS_TOUGH = [ # <= Do Not Touch This Line
# What Actor One Will Say when this occurs
[ "That Was Tough Victory1", 80, 100, 0, "That Was Tough Victory2", 80, 100, 0, ],
# What Actor Two Will Say when this occurs
[ "That Was Tough Victory1", 80, 100, 0, ],
# What Actor Three Will Say when this occurs
[],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# By default this is 3, so if a battle took three turns or less,
# the following voices will play
]; THAT_WAS_EASY_RATIO = 3
THAT_WAS_EASY = [ # <= Do Not Touch This Line
# What Actor One Will Say when a battle didn't take too long
[ "That Was Easy Victory1", 80, 100, 0, "That Was Easy Victory2", 80, 100, 0,
"That Was Easy Victory3", 80, 100, 0, "That Was Easy Victory4", 80, 100, 0, ],
# What Actor Two Will Say when a battle didn't take too long
[ "That Was Easy Victory1", 80, 100, 0, "That Was Easy Victory2", 80, 100, 0,
"That Was Easy Victory3", 80, 100, 0, ],
# What Actor Three Will Say when a battle didn't take too long
[],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# By default this is 15, so it means the battle needs to have
# taken 15 turns or more for the following voices to be played
]; BATTLE_TOOK_AGES_RATIO = 15
BATTLE_TOOK_AGES = [ # <= Do Not Touch This Line
# What Actor One Will Say when battle took a long time
[],
# What Actor Two Will Say when battle took a long time
[ "Battle Took Ages Victory1", 80, 100, 0, ],
# What Actor Three Will Say when battle took a long time
[],
# You can make more actors voices by copy-pasting the above
#--------------------------------------------------------------------
# This is what your actors will say normally if the aboves are not met
]; NORMAL_VICTORY = [ # <= Do Not Touch This Line
# What Actor One Will Say when a battle resulted in victory
[ "Normal Victory1", 80, 100, 0, "Normal Victory2", 80, 100, 0,
"Normal Victory3", 80, 100, 0, "Normal Victory4", 80, 100, 0,
"Normal Victory5", 80, 100, 0, "Normal Victory6", 80, 100, 0, ],
# What Actor Two Will Say when a battle resulted in victory
[ "Normal Victory1", 80, 100, 0, "Normal Victory2", 80, 100, 0,
"Normal Victory3", 80, 100, 0, "Normal Victory4", 80, 100, 0,
"Normal Victory5", 80, 100, 0, "Normal Victory6", 80, 100, 0, ],
# What Actor Three Will Say when a battle resulted in victory
[],
# You can make more actors voices by copy-pasting the above
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# -=
]; # End Of Editable Region //// ==
# =-
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#------------------------------------------------------------------------
# * Play Voice
#------------------------------------------------------------------------
def self.play_voice( voice_array, actor_id )
# Check to make sure we're not Silenced
$game_actors[actor_id].states.each do |state|
SILENCE_STATES.each do |silence_id|
return true if state.id == silence_id
end
end
# If voice_array is not nil AND the mute event switch is not on
if voice_array && !$game_switches[EVENT_SWITCH_ID]
index = rand(voice_array.size / 4) * 4
if voice_array[index].is_a?(String) && voice_array[index + 1].is_a?(Integer) && voice_array[index + 2].is_a?(Integer)
pathtofile = "/" + FOLDER_DIRECTORY_NAME + "/" + $game_actors[actor_id].name + "/" + voice_array[index]
RPG::SE.new(pathtofile, voice_array[index + 1], voice_array[index + 2]).play
SceneManager.scene.wait(voice_array[index + 3]) unless !voice_array[index + 3].is_a?(Integer) || !SceneManager.scene_is?(Scene_Battle)
return true
end
end
# We return true and false because during battle start and victory, if an actor
# doesn't have a voice clip for one condition, we'll try to find another met
# condition in which the actor DOES have a voice.
return false
end
#------------------------------------------------------------------------
# * Get Random Battle Actor ID
#------------------------------------------------------------------------
def self.get_battle_actor_id()
# Get a Battle Actor ID, who is to speak
actor_ids = []
$game_party.battle_members.each do |ally|
skip = false
ally.states.each {|state| skip = true if state.id == 1 }
actor_ids[actor_ids.size] = ally.id unless skip
end
return actor_ids[rand(actor_ids.size)] - 1
end
end # BattleVoices Module
end # DiamondandPlatinum3 Module
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias dp3_scenebattle_poststart_1s098yu9j post_start
#--------------------------------------------------------------------------
# * Aliased Method: Post-Start Processing
#--------------------------------------------------------------------------
def post_start
dp3_play_battle_start_voice()
dp3_scenebattle_poststart_1s098yu9j()
end
#--------------------------------------------------------------------------
# * New Method: Play Battle Start Voice
#--------------------------------------------------------------------------
def dp3_play_battle_start_voice
actor_to_speak = DiamondandPlatinum3::BattleVoices::get_battle_actor_id()
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Party Needs Healing?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
party_total_hp = party_current_hp = 0
$game_party.battle_members.each {|ally| party_total_hp += ally.mhp }
party_current_hp = party_total_hp
$game_party.battle_members.each {|ally| party_current_hp -= (ally.mhp - ally.hp) }
if party_current_hp < party_total_hp * (DiamondandPlatinum3::BattleVoices::PARTY_NEEDS_HEALING_RATIO * 0.01)
voice = DiamondandPlatinum3::BattleVoices::PARTY_NEEDS_HEALING[actor_to_speak]
return if DiamondandPlatinum3::BattleVoices::play_voice( voice, actor_to_speak + 1 )
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Too many enemies?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if $game_troop.members.size > $game_party.members.size + DiamondandPlatinum3::BattleVoices::TOO_MANY_ENEMIES_RATIO
voice = DiamondandPlatinum3::BattleVoices::TOO_MANY_ENEMIES[actor_to_speak]
return if DiamondandPlatinum3::BattleVoices::play_voice( voice, actor_to_speak + 1 )
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Which side is stronger?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
strongest_enemy_stats = [ 0, 0, 0, 0 ]
strongest_party_stats = [ 0, 0, 0, 0 ]
$game_troop.members.each do |enemy|
strongest_enemy_stats[0] = enemy.atk if enemy.atk > strongest_enemy_stats[0]
strongest_enemy_stats[1] = enemy.def if enemy.def > strongest_enemy_stats[1]
strongest_enemy_stats[2] = enemy.mat if enemy.mat > strongest_enemy_stats[2]
strongest_enemy_stats[3] = enemy.mdf if enemy.mdf > strongest_enemy_stats[3]
end
$game_party.battle_members.each do |ally|
strongest_party_stats[0] = ally.atk if ally.atk > strongest_party_stats[0]
strongest_party_stats[1] = ally.def if ally.def > strongest_party_stats[1]
strongest_party_stats[2] = ally.mat if ally.mat > strongest_party_stats[2]
strongest_party_stats[3] = ally.mdf if ally.mdf > strongest_party_stats[3]
end
enemy_power = strongest_enemy_stats[0] + strongest_enemy_stats[1] + strongest_enemy_stats[2] + strongest_enemy_stats[3]
party_power = strongest_party_stats[0] + strongest_party_stats[1] + strongest_party_stats[2] + strongest_party_stats[3]
voice = nil
# Very Weak Enemy
if enemy_power < party_power * (DiamondandPlatinum3::BattleVoices::VERY_WEAK_ENEMIES_RATIO * 0.01)
voice = DiamondandPlatinum3::BattleVoices::VERY_WEAK_ENEMIES[actor_to_speak]
# Weak Enemy
elsif enemy_power < party_power * (DiamondandPlatinum3::BattleVoices::WEAK_ENEMIES_RATIO * 0.01)
voice = DiamondandPlatinum3::BattleVoices::WEAK_ENEMIES[actor_to_speak]
# Very Strong Enemy
elsif enemy_power > party_power * (DiamondandPlatinum3::BattleVoices::VERY_STRONG_ENEMIES_RATIO * 0.01)
voice = DiamondandPlatinum3::BattleVoices::VERY_STRONG_ENEMIES[actor_to_speak]
# Strong Enemy
elsif enemy_power > party_power * (DiamondandPlatinum3::BattleVoices::STRONG_ENEMIES_RATIO * 0.01)
voice = DiamondandPlatinum3::BattleVoices::STRONG_ENEMIES[actor_to_speak]
# Equal Enemy
else
voice = DiamondandPlatinum3::BattleVoices::EQUAL_ENEMIES[actor_to_speak]
end
DiamondandPlatinum3::BattleVoices::play_voice( voice, actor_to_speak + 1 )
end # def dp3_play_battle_start_voice
end # class
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# A battler class with methods for sprites and actions added. This class
# is used as a super class of the Game_Actor class and Game_Enemy class.
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias dp3_gamebattler_useitem_1s098yu9j use_item
alias dp3_gamebattler_die_1s098yu9j die
alias dp3_gamebattler_itemeffectrecoverhp_1s098yu9j item_effect_recover_hp
alias dp3_gamebattler_itemeffectrecovermp_1s098yu9j item_effect_recover_mp
alias dp3_gamebattler_ondamage_1s098yu9j on_damage
#--------------------------------------------------------------------------
# * Aliased Method: Use Skill/Item
#--------------------------------------------------------------------------
def use_item(item)
# Play Battle Voice for that skill/item if there is any
if @actor_id && SceneManager.scene_is?(Scene_Battle)
voice = []
#~~~~~ Using A Skill ~~~~~#
if item.is_a?(RPG::Skill)
if item.id == 1 # Attack
voice = DiamondandPlatinum3::BattleVoices::ACTOR_ATTACKING[@actor_id - 1]
else # Another skill besides Attack
$data_skills[item.id].note[/~ActorVoice:\s*#{@actor_id.to_s}\,*\s*\"(.+?)\"\,*\s*(\d*)\,*\s*(\d*)\,*\s*(\d*)/im]
if $1 && $1 != ""
voice[voice.size] = $1
voice[voice.size] = $2 != "" ? $2.to_i : 80
voice[voice.size] = $3 != "" ? $3.to_i : 100
voice[voice.size] = $4 != "" ? $4.to_i : 0
end
end
#~~~~~ Using An Item ~~~~~#
elsif item.is_a?(RPG::Item)
$data_items[item.id].note[/~ActorVoice:\s*#{@actor_id.to_s}\,*\s*\"(.+?)\"\,*\s*(\d*)\,*\s*(\d*)\,*\s*(\d*)/im]
if $1 && $1 != ""
voice[voice.size] = $1
voice[voice.size] = $2 != "" ? $2.to_i : 80
voice[voice.size] = $3 != "" ? $3.to_i : 100
voice[voice.size] = $4 != "" ? $4.to_i : 0
else
voice = DiamondandPlatinum3::BattleVoices::USING_ITEMS[@actor_id - 1]
end
end
DiamondandPlatinum3::BattleVoices::play_voice( voice, @actor_id )
end
# Call Original Method
dp3_gamebattler_useitem_1s098yu9j( item )
end
#--------------------------------------------------------------------------
# * Aliased Method: Knock Out
#--------------------------------------------------------------------------
def die( *args )
if @actor_id && SceneManager.scene_is?(Scene_Battle)
voice = DiamondandPlatinum3::BattleVoices::DEATH_VOICE[@actor_id - 1]
DiamondandPlatinum3::BattleVoices::play_voice( voice, @actor_id )
end
# Call Original Method
dp3_gamebattler_die_1s098yu9j( *args )
end
#--------------------------------------------------------------------------
# * Aliased Method: [HP Recovery] Effect
#--------------------------------------------------------------------------
def item_effect_recover_hp( *args )
if @actor_id && SceneManager.scene_is?(Scene_Battle)
voice = DiamondandPlatinum3::BattleVoices::HP_MP_RESTORE[@actor_id - 1]
DiamondandPlatinum3::BattleVoices::play_voice( voice, @actor_id )
end
# Call Original Method
dp3_gamebattler_itemeffectrecoverhp_1s098yu9j( *args )
end
#--------------------------------------------------------------------------
# * Aliased Method: [MP Recovery] Effect
#--------------------------------------------------------------------------
def item_effect_recover_mp( *args )
if @actor_id && SceneManager.scene_is?(Scene_Battle)
voice = DiamondandPlatinum3::BattleVoices::HP_MP_RESTORE[@actor_id - 1]
DiamondandPlatinum3::BattleVoices::play_voice( voice, @actor_id )
end
# Call Original Method
dp3_gamebattler_itemeffectrecovermp_1s098yu9j( *args )
end
#--------------------------------------------------------------------------
# * Aliased Method: Processing When Suffering Damage
#--------------------------------------------------------------------------
def on_damage(value)
if @actor_id
if (self.hp - value) <= 0
# Do Nothing, the 'die' method will take care of this
elsif value > 0
DiamondandPlatinum3::BattleVoices::play_voice( dp3_get_actor_damage_voice_array( value ), @actor_id)
end
end
# Call Original Method
dp3_gamebattler_ondamage_1s098yu9j( value )
end
#--------------------------------------------------------------------------
# * New Method: Get Actor Damage Voice Array
#--------------------------------------------------------------------------
def dp3_get_actor_damage_voice_array( value )
#~~~~~ Play Massive Damage Voice ~~~~~#
if value > self.mhp * (DiamondandPlatinum3::BattleVoices::MASSIVE_DAMAGE_RATIO * 0.01)
return DiamondandPlatinum3::BattleVoices::MASSIVE_DAMAGE[@actor_id - 1]
#~~~~~ Play Heavy Damage Voice ~~~~~#
elsif value > self.mhp * (DiamondandPlatinum3::BattleVoices::HEAVY_DAMAGE_RATIO * 0.01)
return DiamondandPlatinum3::BattleVoices::HEAVY_DAMAGE[@actor_id - 1]
#~~~~~ Play Significant Damage Voice ~~~~~#
elsif value > self.mhp * (DiamondandPlatinum3::BattleVoices::SIGNIFICANT_DAMAGE_RATIO * 0.01)
return DiamondandPlatinum3::BattleVoices::SIGNIFICANT_DAMAGE[@actor_id - 1]
#~~~~~ Play Little Damage Voice ~~~~~#
elsif value > self.mhp * (DiamondandPlatinum3::BattleVoices::LITTLE_DAMAGE_RATIO * 0.01)
return DiamondandPlatinum3::BattleVoices::LITTLE_DAMAGE[@actor_id - 1]
#~~~~~ Play Pitance Damage Voice ~~~~~#
else
return DiamondandPlatinum3::BattleVoices::DEFAULT_DAMAGE[@actor_id - 1]
end
end
end
#==============================================================================
# ** BattleManager
#------------------------------------------------------------------------------
# This module manages battle progress.
#==============================================================================
module BattleManager
class << self
#------------------------------------------------------------------------
# * Alias Listings
#------------------------------------------------------------------------
alias dp3_battlemanager_setup_1s098yu9j setup
alias dp3_battlemanager_processescape_1s098yu9j process_escape
alias dp3_battlemanager_processvictory_1s098yu9j process_victory
#------------------------------------------------------------------------
# * Aliased Method: Setup
#------------------------------------------------------------------------
def setup( *args )
@dp3_party_start_total_hp = 0
$game_party.battle_members.each {|ally|
@dp3_party_start_total_hp += ally.mhp
@dp3_party_start_total_hp -= (ally.mhp - ally.hp) }
# Call Original Method
dp3_battlemanager_setup_1s098yu9j( *args )
end
#------------------------------------------------------------------------
# * Aliased Method: Escape Processing
#------------------------------------------------------------------------
def process_escape( *args )
# Play Begin Escape Voice
actor_to_speak = DiamondandPlatinum3::BattleVoices::get_battle_actor_id()
voice = DiamondandPlatinum3::BattleVoices::ESCAPE_ATTEMPT_VOICE[actor_to_speak]
DiamondandPlatinum3::BattleVoices::play_voice( voice, actor_to_speak + 1 )
# Call Original Method
escaped = dp3_battlemanager_processescape_1s098yu9j( *args )
# Play Voice for either successful or unsucessful escape
if escaped
voice = DiamondandPlatinum3::BattleVoices::SUCCESSFUL_ESCAPE[actor_to_speak]
else
voice = DiamondandPlatinum3::BattleVoices::FAILED_ESCAPE[actor_to_speak]
end
DiamondandPlatinum3::BattleVoices::play_voice( voice, actor_to_speak + 1 )
# Finish Up
return escaped
end
#------------------------------------------------------------------------
# * Aliased Method: Victory Processing
#------------------------------------------------------------------------
def process_victory
dp3_play_victory_voice()
# Call Original Method
dp3_battlemanager_processvictory_1s098yu9j()
end
#------------------------------------------------------------------------
# * New Method: Play Victory Voice
#------------------------------------------------------------------------
def dp3_play_victory_voice
actor_to_speak = DiamondandPlatinum3::BattleVoices::get_battle_actor_id()
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Battle Took Ages?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if $game_troop.dp3_battlevoice_getturncount >= DiamondandPlatinum3::BattleVoices::BATTLE_TOOK_AGES_RATIO
voice = DiamondandPlatinum3::BattleVoices::BATTLE_TOOK_AGES[actor_to_speak]
return if DiamondandPlatinum3::BattleVoices::play_voice( voice, actor_to_speak + 1 )
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Party Was Badly Injured?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
party_current_hp = @dp3_party_start_total_hp
$game_party.battle_members.each {|ally| party_current_hp -= (ally.mhp - ally.hp) }
if party_current_hp < @dp3_party_start_total_hp * (DiamondandPlatinum3::BattleVoices::THAT_WAS_TOUGH_RATIO * 0.01)
voice = DiamondandPlatinum3::BattleVoices::THAT_WAS_TOUGH[actor_to_speak]
return if DiamondandPlatinum3::BattleVoices::play_voice( voice, actor_to_speak + 1 )
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Battle Was Easy?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if $game_troop.dp3_battlevoice_getturncount <= DiamondandPlatinum3::BattleVoices::THAT_WAS_EASY_RATIO
voice = DiamondandPlatinum3::BattleVoices::THAT_WAS_EASY[actor_to_speak]
return if DiamondandPlatinum3::BattleVoices::play_voice( voice, actor_to_speak + 1 )
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Default Victory Speech
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
voice = DiamondandPlatinum3::BattleVoices::NORMAL_VICTORY[actor_to_speak]
DiamondandPlatinum3::BattleVoices::play_voice( voice, actor_to_speak + 1 )
end # def
end # class
end # module
#==============================================================================
# ** Game_Troop
#------------------------------------------------------------------------------
# This class handles enemy groups and battle-related data. Also performs
# battle events. The instance of this class is referenced by $game_troop.
#==============================================================================
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# * New Method: Get Turns
#--------------------------------------------------------------------------
def dp3_battlevoice_getturncount
return @turn_count
end
end
Download DEMO (bao gồm file giọng nói mẫu)[chapter]Credit[/chapter]
BluntSword (cho file giọng nói trong DEMO)
DiamondandPlatinum3 (cho Script)
[chapter]Điều khoản khi sử dụng[/chapter]
Không được sử dụng cho dự án thương mại
Comments
Và Vx Ace tích hợp chức năng của Xp + Vx.
Và nó Khủng hơn Xp.
Nhưng vì Xp nó là huyền thoại nên mọi người vẫn xài nó.
vào soundjay.com có nhiều lắm
Chứ đi kiếm giọng nói của người khác nghe hơi khó.