Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Crisis Voice Lines
- # By: TheoAllen @ 2021
- # Commissioned Work
- module AED
- VoiceLines = {
- # Actor ID => [
- # ["VoiceFile", volume, pitch],
- # ["VoiceFile", volume, pitch],
- # ]
- 1 => [
- ["ThisIsBad", 90, 100],
- ["OutOfControl", 95, 100],
- ["OutOfControl2", 95, 100],
- ],
- 2 => [
- ["IsntGood", 95, 100],
- ],
- }
- VoiceChance = 1.0 # <-- Chance here (put between 0.0 to 1.0)
- CrisisValue = 0.25 # <-- Value of HP (put between 0.0 to 1.0)
- end
- class Game_Party
- attr_accessor :crisis_actor
- attr_accessor :in_crisis
- attr_accessor :voice_actors
- attr_accessor :already_crisis
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- alias :initialze_ffs_new_crisis_voice :initialize
- def initialize
- initialze_ffs_new_crisis_voice
- @crisis_actor = true
- @in_crisis = false
- @voice_actors = []
- @already_crisis = []
- end
- def crisis?
- #~ hp_rate < AED::CrisisValue
- for i in members
- i.crisis?
- end
- end
- #~
- #~ def hp_rate
- #~ all_members.inject(0.0) {|r,n| n.hp_rate + r}/all_members.size.to_f
- #~ end
- #~
- #~ def crisis_rate
- #~ hp_rate / AED::CrisisValue
- #~ end
- def update_crisis
- crisis?
- p sprintf("VA: %s ; AC: %s", @voice_actors, @already_crisis)
- if @voice_actors != []
- play_crisis_voices
- end
- #~ if @crisis_actor
- #~ @crisis_actor = false
- #~ last_crisis = @in_crisis
- #~ @in_crisis = crisis?
- #~ p sprintf("crisis?: %s", crisis?)
- #~ p sprintf("last_crisis: %s ; in_crisis: %s", last_crisis, @in_crisis)
- #~ p sprintf("!last_crisis && in_crisis: %s", (!last_crisis && @in_crisis))
- #~ if !last_crisis && @in_crisis
- #~ play_crisis_voices
- #~ end
- #~ end
- end
- def play_crisis_voices
- p sprintf("VA: %s ; AC: %s", @voice_actors, @already_crisis)
- if rand <= AED::VoiceChance
- @voice_actors = @voice_actors - @already_crisis
- for rid in 0...@voice_actors.length
- id = @voice_actors[rid]
- if id && !$game_actors[id].crisis_talk?
- len = AED::VoiceLines[id].size
- line = AED::VoiceLines[id][rand(len)]
- RPG::SE.new(*line).play
- @voice_actors.delete(id)
- $game_actors[id].set_crisis_talk
- end
- end
- end
- end
- alias on_btlstart_crisis on_battle_start
- def on_battle_start
- on_btlstart_crisis
- @in_crisis = $game_party.crisis?
- @already_crisis = $game_party.get_crisis
- end
- def get_crisis
- al_crysis = @voice_actors
- @voice_actors = []
- return al_crysis
- end
- end
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # * Setup
- #--------------------------------------------------------------------------
- alias :ffs_setup_crisis_voice :setup
- def setup(actor_id)
- ffs_setup_crisis_voice(actor_id)
- @already_talked_crisis = false
- end
- #--------------------------------------------------------------------------
- # * Set Crisis Talk
- #--------------------------------------------------------------------------
- def set_crisis_talk(bool=true)
- @already_talked_crisis = bool
- end
- #--------------------------------------------------------------------------
- # * Crisis Talk?
- #--------------------------------------------------------------------------
- def crisis_talk?
- @already_talked_crisis
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- alias :aed2_crisis_refresh :refresh
- def refresh
- aed2_crisis_refresh
- if hp_rate > AED::CrisisValue
- $game_party.crisis_actor = true
- $game_party.voice_actors.delete(@actor_id)
- $game_party.already_crisis.delete(@actor_id)
- set_crisis_talk(false)
- end
- end
- #--------------------------------------------------------------------------
- # * Crisis?
- #--------------------------------------------------------------------------
- def crisis?
- p sprintf("Actor: %s, in range?: %s ; if: %s", name, (hp_rate <= AED::CrisisValue),
- (!$game_party.voice_actors.include?(@actor_id) && !$game_party.already_crisis.include?(@actor_id) && !crisis_talk?))
- if hp_rate <= AED::CrisisValue
- if !$game_party.voice_actors.include?(@actor_id) && !$game_party.already_crisis.include?(@actor_id) && !crisis_talk?
- $game_party.voice_actors.push(@actor_id)
- end
- if @states.include?(1)
- $game_party.voice_actors.delete(@actor_id)
- end
- end
- end
- end
- class Scene_Battle
- alias crisis_voice_lines_tsbs_end tsbs_action_end
- def tsbs_action_end(targets, item, subj)
- crisis_voice_lines_tsbs_end(targets, item, subj)
- $game_party.update_crisis
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement