Pokémon cries no longer change pitch except when fainting, added support for separate fainting cries

This commit is contained in:
Maruno17
2021-12-14 23:19:08 +00:00
parent b706843888
commit 15b86429a2
4 changed files with 35 additions and 23 deletions

View File

@@ -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

View File

@@ -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, "_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
battler.setSE(0, cry, nil, 75) # 75 is pitch
delay = GameData::Species.cry_length(batSprite.pkmn) * 20 / Graphics.frame_rate
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")

View File

@@ -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

View File

@@ -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