Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- RGSS3
- Battle voice
- You can play back the voice according to the action in combat.
- =============================How to use===================================
- Create a folder called "VOICE" under the Audio folder, and place your
- voice sound files in the according folder.
- -------------------------------------------------------------------------
- You have the ability to play the voice of the item prior to the use of
- skill. Using skills which have a note box that is described as "no voice"
- makes no voice sound play for that skill.
- ==========================================================================
- =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+Main Purpose=+=+=+=+=++=+=+=+=+=+=+=+=+=+=
- ==========================================================================
- The initial state to the actor is set equal to the voice of the actor ID
- that the script has set the ID to. It is also changeable.
- --------------------------------------------------------------------------
- By running 'call script' from an event command, you can change any
- settings to those used by the voice actors.
- --------------------------------------------------------------------------
- change_voice (actor_id, voice_id)
- --------------------------------------------------------------------------
- ID of the actor you want to make change to: actor_id
- ID of the settings you want change actor_id to change to: voice_id
- --------------------------------------------------------------------------
- E.G;
- 'Change_voice (2, 14)'
- When you run the above script via the script call event command,
- "The actor with the ID 2 will be set to 14 corresponding to the voice
- actor ID"
- The setting is therefore changed, and so on.
- ==========================================================================
- ==================================Note====================================
- ---------If you do not start spitting error from the new game.------------
- ==========================================================================
- ver 1.00
- Last Update: 2012/06/10
- New: 06/10
- Http://kaisou-ryouiki.sakura.ne.jp/ furnace tube
- =end
- # ==============================================================================
- # Setting point
- # ==============================================================================
- module BattleVoice
- # ------------------------------------------------------------------------------
- # Here you can set the voice for each actor to use for combat.
- # Setting 'no voice' to actors will cause them to make no voice sound.
- # The basic format of the configuration is as follows.
- # SYNOPSIS
- #
- # x => ["Example", "Example", "Example"],
- # x = voice configuration ID (number, like 1, 2, 3, 4 ect)
- # x = In its initial state, this value corresponds to the Enemy ID or actor ID.
- # If you want to configure the voice of the Enemy make sure you add the number
- # equal to its ID, and then add "-".
- #
- # EG;
- #
- #:attack => {
- # # Normal Attack
- # -20 => ["attack", "attack2", "attack3"],
- #
- # The ID of the enemy is 20, but we must add a "-" to the number, otherwise the
- # script will read from the actor tab. Adding a "-" reads from the monster tab
- # instead.
- #
- # voice file name (string, unnecessary extension)
- # If more than one voice has been set to the same character, then a single file
- # will be selected at random to be played.
- # ------------------------------------------------- ----------------------------
- VOICE_LIST = {
- :battle_start_normal => {
- # At the start of combat: (will be played by a person chosen at random from
- # members currently alive)
- # Enemy not supported
- 1 => ["player_start","player_start2"],
- },
- :battle_start_pinch => {
- # At the start of combat: (will be played by a person chosen at random from
- # members currently alive)
- # Pinch means voice sounds will be played from non-combat members or inactive
- # party members.
- # Enemy not supported
- 1 => [],
- },
- :battle_start_surprise => {
- # At the start of combat: (will be played by a person chosen at random from
- # members survival) surprise
- # Will override the pinch.
- # Enemy not supported
- 1 => ["player_suprise"],
- },
- :battle_start_preemptive => {
- # At the start of combat: (will be played by a person chosen at random from
- # members survival) pre-emptive strike
- # Will override the pinch.
- # Enemy not supported
- 1 => ["player_pre"],
- },
- :attack => {
- # Normal attack
- 1 => ["player_attack","player_attack2","player_attack3","player_attack4"],
- },
- :guard => {
- # Defense
- 1 => [],
- },
- :damage => {
- # Damage taken
- 1 => ["player_damage","player_damage2","player_damage3"],
- },
- :evasion => {
- # Avoid
- 1 => [],
- },
- :miss => {
- # Mistake
- 1 => [],
- },
- :use_item => {
- # Use items
- # Enemy not supported
- 1 => [],
- },
- :use_skill => {
- # Using the skill
- 1 => [],
- },
- :dead => {
- # Non-combat
- 1 => [],
- },
- :recovery => {
- # Recovery from other than their own fellow
- # Recovery of HP, clear the bad state
- 1 => ["player_heal","player_heal"],
- },
- :support_state => {
- # Additional support from fellow state other than your own
- 1 => [],
- },
- :bad_state => {
- # Bad State additional
- # Release will take precedence bad state, rather than additional state support.
- 1 => [],
- },
- :victory_normal => {
- # Victory: (will be played by a person chosen at random from members currently
- # alive)
- # Enemy not supported
- 1 => ["player_win","player_win2","player_win3"],
- },
- :victory_pinch => {
- # Victory: (will be played by a person chosen at random from members currently
- # alive)
- # Playback even if you are a human pin when members of the non-combat victory
- # Enemy not supported
- 1 => [],
- },
- :victory_perfect => {
- # Victory: (will be played by a person chosen at random from members alive)
- # when no damage is taken.
- # Will override the pinch.
- # Enemy not supported
- 1 => [],
- },
- :escape => {
- # (The actors are playing members chosen at random from a human survival)
- # escape
- 1 => ["player_escape","player_escape"],
- },
- }
- # State ID silence
- # Voice of the character states that are registered here has the additional
- # Will not play. (Such as silence and sleep ....)
- SILENT_STATES = [4, 6]
- # Number switch to disable the voice playback
- # Switch that you specify here. if it is ON, the voice of all settings are no
- # longer played. (This script's functions will be disabled until the switch is
- # turned off.)
- SILENT_SWITCH = 10
- # Volume of voice
- VOICE_VOLUME = 100
- # Wait immediately after sandwiching voice playback
- # Sets the reason to there being a pause of silence such as the head of the
- # voice file.
- # (Safe is about 0 to 15) Please use it if they do not fit the timing.
- # If you do not need it to 0.
- VOICE_WAIT = 10
- end
- class Window_BattleLog < Window_Selectable
- # State definition support (such as increased system parameter ....)
- SUPPORT_STATES = [14, 15, 16, 21, 22, 23]
- # (Such as poison or paralysis ....) Bad state definition
- BAD_STATES = [2, 3, 4, 5, 6, 7, 8]
- end
- #===========================================
- # So far
- #===========================================
- $rsi ||= {}
- $rsi["battle voice"] = true
- class RPG::UsableItem < RPG::BaseItem
- def play_voice?
- !@note.include?("no voice")
- end
- end
- module BattleVoice
- module_function
- #--------------------------------------------------------------------------
- # retrieve voice renewable at random from members are alive
- #--------------------------------------------------------------------------
- def get_rand_member_id(scene_symbol)
- battler = $game_party.alive_members.select{|member|
- if !VOICE_LIST[scene_symbol].has_key?(member.voice_id)
- false
- elsif SILENT_STATES.empty?
- true
- else
- !silent_battler?(member)
- end
- }.sample
- battler ? battler.voice_id : 0
- end
- #--------------------------------------------------------------------------
- # Can not play determination voice
- #--------------------------------------------------------------------------
- def silent_battler?(battler)
- SILENT_STATES.any?{|state_id| battler.state?(state_id)}
- end
- #--------------------------------------------------------------------------
- # Obtain the name of the file to play (if nil is returned will not play)
- #--------------------------------------------------------------------------
- def get_filename(scene_symbol, key)
- if VOICE_LIST[scene_symbol][key]
- VOICE_LIST[scene_symbol][key].sample
- else
- nil
- end
- end
- #--------------------------------------------------------------------------
- # Battle playback of voice
- #--------------------------------------------------------------------------
- def play(scene_symbol, battler = nil)
- unless $game_switches[SILENT_SWITCH]
- if battler
- key = battler.actor? ? battler.voice_id : (battler.enemy_id * -1)
- return if silent_battler?(battler)
- else
- key = get_rand_member_id(scene_symbol)
- end
- filename = get_filename(scene_symbol, key)
- if filename
- Audio.se_play('Audio/VOICE/' + filename, VOICE_VOLUME, 100)
- wait(VOICE_WAIT)
- end
- end
- end
- #--------------------------------------------------------------------------
- # wait
- #--------------------------------------------------------------------------
- def wait(duration)
- SceneManager.scene.wait(VOICE_WAIT)
- end
- end
- class << BattleManager
- #--------------------------------------------------------------------------
- # ● start fighting
- #--------------------------------------------------------------------------
- alias battle_start_voice_plus battle_start
- def battle_start
- $game_temp.no_damage = true
- $game_party.on_battle_start
- if @preemptive
- BattleVoice.play(:battle_start_preemptive)
- elsif @surprise
- BattleVoice.play(:battle_start_surprise)
- elsif $game_party.pinch?
- BattleVoice.play(:battle_start_pinch)
- else
- BattleVoice.play(:battle_start_normal)
- end
- battle_start_voice_plus
- end
- #--------------------------------------------------------------------------
- # processing of victory
- #--------------------------------------------------------------------------
- alias process_victory_voice_plus process_victory
- def process_victory
- if $game_temp.no_damage
- BattleVoice.play(:victory_perfect)
- elsif $game_party.pinch?
- BattleVoice.play(:victory_pinch)
- else
- BattleVoice.play(:victory_normal)
- end
- process_victory_voice_plus
- end
- #--------------------------------------------------------------------------
- # processing redefinition getaway
- #--------------------------------------------------------------------------
- def process_escape
- $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
- success = @preemptive ? true : (rand < @escape_ratio)
- Sound.play_escape
- if success
- BattleVoice.play(:escape)
- process_abort
- else
- @escape_ratio += 0.1
- $game_message.add('\.' + Vocab::EscapeFailure)
- $game_party.clear_actions
- end
- wait_for_message
- return success
- end
- end
- class Game_Temp
- #--------------------------------------------------------------------------
- # ● public instance variable
- #--------------------------------------------------------------------------
- attr_accessor :no_damage # no damage during the battle flag
- #--------------------------------------------------------------------------
- # ● Object Initialization
- #--------------------------------------------------------------------------
- alias initialize_voice_plus initialize
- def initialize
- initialize_voice_plus
- @no_damage = true
- end
- end
- class Game_Action
- #--------------------------------------------------------------------------
- # ● defense decision
- #--------------------------------------------------------------------------
- def guard?
- item == $data_skills[subject.guard_skill_id]
- end
- end
- class Game_ActionResult
- #--------------------------------------------------------------------------
- # ● public instance variable
- #--------------------------------------------------------------------------
- attr_accessor :added_new_states
- #--------------------------------------------------------------------------
- # ● Clear status effect
- #--------------------------------------------------------------------------
- alias clear_status_effects_voice_plus clear_status_effects
- def clear_status_effects
- @added_new_states = []
- clear_status_effects_voice_plus
- end
- end
- class Game_Battler < Game_BattlerBase
- #--------------------------------------------------------------------------
- # addition of new state
- #--------------------------------------------------------------------------
- alias add_new_state_voice_plus add_new_state
- def add_new_state(state_id)
- @result.added_new_states.push(state_id).uniq!
- add_new_state_voice_plus(state_id)
- end
- end
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # public instance variable
- #--------------------------------------------------------------------------
- attr_accessor :voice_id
- #--------------------------------------------------------------------------
- # setup
- #--------------------------------------------------------------------------
- alias setup_voice_plus setup
- def setup(actor_id)
- setup_voice_plus(actor_id)
- @voice_id = @actor_id
- end
- #--------------------------------------------------------------------------
- # processing of damage taken when
- #--------------------------------------------------------------------------
- def on_damage(value)
- super(value)
- $game_temp.no_damage = false
- end
- #--------------------------------------------------------------------------
- # execution of the damage effects
- #--------------------------------------------------------------------------
- alias perform_damage_effect_voice_plus perform_damage_effect
- def perform_damage_effect
- BattleVoice.play(:damage, self) unless dead?
- perform_damage_effect_voice_plus
- end
- #--------------------------------------------------------------------------
- # HP regeneration of
- #--------------------------------------------------------------------------
- def regenerate_hp
- super
- $game_temp.no_damage = false if @result.hp_damage > 0
- end
- #--------------------------------------------------------------------------
- # execution of the collapse effect
- #--------------------------------------------------------------------------
- alias perform_collapse_effect_voice_plus perform_collapse_effect
- def perform_collapse_effect
- perform_collapse_effect_voice_plus
- BattleVoice.play(:dead, self) if $game_party.in_battle
- end
- end
- class Game_Enemy < Game_Battler
- #--------------------------------------------------------------------------
- # execution of the damage effects
- #--------------------------------------------------------------------------
- alias perform_damage_effect_voice_plus perform_damage_effect
- def perform_damage_effect
- BattleVoice.play(:damage, self) unless dead?
- perform_damage_effect_voice_plus
- end
- #--------------------------------------------------------------------------
- # execution of the collapse effect
- #--------------------------------------------------------------------------
- alias perform_collapse_effect_voice_plus perform_collapse_effect
- def perform_collapse_effect
- perform_collapse_effect_voice_plus
- BattleVoice.play(:dead, self)
- end
- #--------------------------------------------------------------------------
- # flee
- #--------------------------------------------------------------------------
- def escape
- BattleVoice.play(:escape, self)
- super
- end
- end
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # pinch state determination
- #--------------------------------------------------------------------------
- def pinch?
- !dead_members.empty?
- end
- end
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # change voice of an actor
- #--------------------------------------------------------------------------
- def change_voice(actor_id, voice_id)
- $game_actors[actor_id].voice_id = voice_id
- end
- end
- class Window_BattleLog < Window_Selectable
- #--------------------------------------------------------------------------
- # Display of damage
- #--------------------------------------------------------------------------
- alias display_damage_voice_plus display_damage
- def display_damage(target, item)
- subject = SceneManager.scene.subject
- if target.result.missed
- BattleVoice.play(:miss, subject)
- elsif target.result.evaded
- BattleVoice.play(:evasion, target)
- else
- if subject != target && subject.actor? == target.actor? && !target.dead? &&
- (target.result.hp_damage < 0 || target.result.mp_damage < 0 || target.result.tp_damage < 0)
- BattleVoice.play(:recovery, target)
- end
- end
- display_damage_voice_plus(target, item)
- end
- #--------------------------------------------------------------------------
- # View the status of the affected
- #--------------------------------------------------------------------------
- alias display_affected_status_voice_plus display_affected_status
- def display_affected_status(target, item)
- if item && target.result.status_affected?
- subject = SceneManager.scene.subject
- if subject != target
- if target.result.added_new_states.any?{|id| BAD_STATES.include?(id)}
- BattleVoice.play(:bad_state, target)
- elsif subject.actor? == target.actor?
- if target.result.removed_states.any?{|id| BAD_STATES.include?(id)}
- BattleVoice.play(:recovery, target)
- elsif target.result.added_new_states.any?{|id| SUPPORT_STATES.include?(id)}
- BattleVoice.play(:support_state, target)
- end
- end
- end
- end
- display_affected_status_voice_plus(target, item)
- end
- end
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # public instance variable
- #--------------------------------------------------------------------------
- attr_reader :subject
- #--------------------------------------------------------------------------
- # use of skills / items
- #--------------------------------------------------------------------------
- alias use_item_voice_plus use_item
- def use_item
- if @subject.current_action.attack?
- BattleVoice.play(:attack, @subject)
- elsif @subject.current_action.guard?
- BattleVoice.play(:guard, @subject)
- else
- if @subject.current_action.item.play_voice?
- case @subject.current_action.item
- when RPG::Item
- BattleVoice.play(:use_item, @subject)
- when RPG::Skill
- BattleVoice.play(:use_skill, @subject)
- end
- end
- end
- use_item_voice_plus
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement