From 15b86429a2a400db080440220fac11eafb5543ae Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Tue, 14 Dec 2021 23:19:08 +0000 Subject: [PATCH] =?UTF-8?q?Pok=C3=A9mon=20cries=20no=20longer=20change=20p?= =?UTF-8?q?itch=20except=20when=20fainting,=20added=20support=20for=20sepa?= =?UTF-8?q?rate=20fainting=20cries?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../002_PBS data/009_Species_Files.rb | 35 +++++++++++-------- .../004_Scene/008_Battle_Scene_Animations.rb | 15 +++++--- .../003_UI_EggHatching.rb | 4 +-- .../004_UI_Evolution.rb | 4 +-- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb b/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb index 1ac5fde5f..469f6c34f 100644 --- a/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb +++ b/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb @@ -174,23 +174,23 @@ module GameData #=========================================================================== - def self.check_cry_file(species, form) + def self.check_cry_file(species, form, suffix = "") species_data = self.get_species_form(species, form) return nil if species_data.nil? if form > 0 - ret = sprintf("Cries/%s_%d", species_data.species, form) + ret = sprintf("Cries/%s_%d%s", species_data.species, form, suffix) return ret if pbResolveAudioSE(ret) end - ret = sprintf("Cries/%s", species_data.species) + ret = sprintf("Cries/%s%s", species_data.species, suffix) return (pbResolveAudioSE(ret)) ? ret : nil end - def self.cry_filename(species, form = 0) - return self.check_cry_file(species, form) + def self.cry_filename(species, form = 0, suffix = "") + return self.check_cry_file(species, form || 0, suffix) end - def self.cry_filename_from_pokemon(pkmn) - return self.check_cry_file(pkmn.species, pkmn.form) + def self.cry_filename_from_pokemon(pkmn, suffix = "") + return self.check_cry_file(pkmn.species, pkmn.form, suffix) end def self.play_cry_from_species(species, form = 0, volume = 90, pitch = 100) @@ -199,37 +199,42 @@ module GameData pbSEPlay(RPG::AudioFile.new(filename, volume, pitch)) rescue nil end - def self.play_cry_from_pokemon(pkmn, volume = 90, pitch = nil) + def self.play_cry_from_pokemon(pkmn, volume = 90, pitch = 100) return if !pkmn || pkmn.egg? filename = self.cry_filename_from_pokemon(pkmn) return if !filename - pitch ||= 75 + (pkmn.hp * 25 / pkmn.totalhp) + pitch ||= 100 pbSEPlay(RPG::AudioFile.new(filename, volume, pitch)) rescue nil end - def self.play_cry(pkmn, volume = 90, pitch = nil) + def self.play_cry(pkmn, volume = 90, pitch = 100) if pkmn.is_a?(Pokemon) self.play_cry_from_pokemon(pkmn, volume, pitch) else - self.play_cry_from_species(pkmn, nil, volume, pitch) + self.play_cry_from_species(pkmn, 0, volume, pitch) end end - def self.cry_length(species, form = 0, pitch = 100) + def self.cry_length(species, form = 0, pitch = 100, suffix = "") + pitch ||= 100 return 0 if !species || pitch <= 0 pitch = pitch.to_f / 100 ret = 0.0 if species.is_a?(Pokemon) if !species.egg? - filename = pbResolveAudioSE(GameData::Species.cry_filename_from_pokemon(species)) + filename = self.cry_filename_from_pokemon(species, suffix) + filename = self.cry_filename_from_pokemon(species) if !filename && !nil_or_empty?(suffix) + filename = pbResolveAudioSE(filename) ret = getPlayTime(filename) if filename end else - filename = pbResolveAudioSE(GameData::Species.cry_filename(species, form)) + filename = self.cry_filename(species, form, suffix) + filename = self.cry_filename(species, form) if !filename && !nil_or_empty?(suffix) + filename = pbResolveAudioSE(filename) ret = getPlayTime(filename) if filename end ret /= pitch # Sound played at a lower pitch lasts longer - return (ret * Graphics.frame_rate).ceil + 4 # 4 provides a buffer between sounds + return ret end end end diff --git a/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb b/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb index d3b0d92f5..7e975eff7 100644 --- a/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb +++ b/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb @@ -659,11 +659,18 @@ class Battle::Scene::Animation::BattlerFaint < Battle::Scene::Animation # Animation # Play cry delay = 10 - cry = GameData::Species.cry_filename_from_pokemon(batSprite.pkmn) - if cry - battler.setSE(0, cry, nil, 75) # 75 is pitch - delay = GameData::Species.cry_length(batSprite.pkmn) * 20 / Graphics.frame_rate + cry = GameData::Species.cry_filename_from_pokemon(batSprite.pkmn, "_faint") + if cry # Play a specific faint cry + battler.setSE(0, cry) + delay = (GameData::Species.cry_length(batSprite.pkmn, nil, nil, "_faint") * 20).ceil + else + cry = GameData::Species.cry_filename_from_pokemon(batSprite.pkmn) + if cry # Play the regular cry at a lower pitch (75) + battler.setSE(0, cry, nil, 75) + delay = (GameData::Species.cry_length(batSprite.pkmn, nil, 75) * 20).ceil + end end + delay += 2 # Sprite drops down shadow.setVisible(delay,false) battler.setSE(delay,"Pkmn faint") diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb index eebc65839..665e6717a 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb @@ -96,9 +96,9 @@ class PokemonEggHatch_Scene @sprites["pokemon"].tone=Tone.new(0,0,0) @sprites["overlay"].opacity=0 # Finish scene - frames = GameData::Species.cry_length(@pokemon) + frames = (GameData::Species.cry_length(@pokemon) * Graphics.frame_rate).ceil @pokemon.play_cry - updateScene(frames) + updateScene(frames + 4) pbBGMStop() pbMEPlay("Evolution success") @pokemon.name = nil diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb b/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb index 4373f860a..0192bfab5 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb @@ -569,10 +569,10 @@ class PokemonEvolutionScene def pbEvolutionSuccess $stats.evolution_count += 1 # Play cry of evolved species - frames = GameData::Species.cry_length(@newspecies, @pokemon.form) + frames = (GameData::Species.cry_length(@newspecies, @pokemon.form) * Graphics.frame_rate).ceil pbBGMStop Pokemon.play_cry(@newspecies, @pokemon.form) - frames.times do + (frames + 4).times do Graphics.update pbUpdate end