• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Change Battle Cry

  • 2
    Posts
    6
    Years
    • Seen May 6, 2019
    Ok, before clarifying that I do not speak English, I communicate with a translator so I would thank those who help me write their answers with complete words so the translator understands them.

    What I want to do? Well, each Pokémon has a CRY (battle cry) that uses it when it enters the battlefield and also when it dies. The CRY is in the folder AUDIO / SE / Cries, I understand that, but what I want to do is that when the pokemon appears, use the pre-determined CRY, BUT when it dies use a different CRY, that I will put it in, but I do not know how to do it.

    Here I leave the scripts I found about the battle CRY.
    PSystem_Utilities:
    def pbResolveAudioSE (file)
    return nil if! file
    if RTP.exists? ("Audio / SE /" + file, ["", ". mp3", ". wav"])
    return RTP.getPath ("Audio / SE /" + file, ["", ". wav", ". mp3"])
    end
    return nil
    end

    def pbCryFrameLength (pokemon, pitch = nil)
    return 0 if! pokemon
    pitch = 100 if! pitch
    pitch = pitch.to_f / 100
    return 0 if pitch <= 0
    playtime = 0.0
    if pokemon.is_a? (Numeric)
    pkmnwav = pbResolveAudioSE (pbCryFile (pokemon))
    playtime = getPlayTime (pkmnwav) if pkmnwav
    elsif! pokemon.isEgg?
    if pokemon.respond_to? ("chatter") && pokemon.chatter
    playtime = pokemon.chatter.time
    pitch = 1.0
    else
    pkmnwav = pbResolveAudioSE (pbCryFile (pokemon))
    playtime = getPlayTime (pkmnwav) if pkmnwav
    end
    end
    playtime / = pitch # sound is lengthened the lower pitch
    # 4 is added to provide a buffer between sounds
    return (playtime * Graphics.frame_rate) .ceil + 4
    end

    def pbPlayCry (pokemon, volume = 90, pitch = nil)
    return if! pokemon
    if pokemon.is_a? (Numeric)
    pkmnwav = pbCryFile (pokemon)
    if pkmnwav
    pbSEPlay (RPG :: AudioFile.new (pkmnwav, volume, pitch? pitch: 100)) rescue nil
    end
    elsif! pokemon.isEgg?
    if pokemon.respond_to? ("chatter") && pokemon.chatter
    pokemon.chatter.play
    else
    pkmnwav = pbCryFile (pokemon)
    if pkmnwav
    pbSEPlay (RPG :: AudioFile.new (pkmnwav, volume,
    pitch? pitch: (pokemon.hp * 0 / pokemon.totalhp) +100)) rescue nil
    end
    end
    end
    end

    def pbCryFile (pokemon)
    return nil if! pokemon
    if pokemon.is_a? (Numeric)
    filename = sprintf ("Cries /% sCry", getConstantName (PBSpecies, pokemon)) rescue nil
    filename = sprintf ("Cries /% 03dCry", pokemon) if! pbResolveAudioSE (filename)
    return filename if pbResolveAudioSE (filename)
    elsif! pokemon.isEgg?
    filename = sprintf ("Cries /% sCry_% d", getConstantName (PBSpecies, pokemon.species), (pokemon.form rescue 0)) rescue nil
    filename = sprintf ("Cries /% 03dCry_% d", pokemon.species, (pokemon.form rescue 0)) if! pbResolveAudioSE (filename)
    if! pbResolveAudioSE (filename)
    filename = sprintf ("Cries /% sCry", getConstantName (PBSpecies, pokemon.species)) rescue nil
    end
    filename = sprintf ("Cries /% 03dCry", pokemon.species) if! pbResolveAudioSE (filename)
    return filename if pbResolveAudioSE (filename)
    end
    And also thanks to ALDO who provided me with the following information:

    For that effect, you'll have to fiddle with scripts. There's one called PokeBattle_Scene, which has the lines that take care of cries. From lines 877 to 880 are the cries from Pokémon sent by an enemy trainer, 1000 to 1003 for a cry of the player's Pokémon. 2049 is for the cry of a wild Pokémon and 2738 to 2745 is the cry for a Pokémon fainting. Not sure what exactly it is that you want, so those lines are probably the first place to look for.

    That's it, I hope you can help me shortly. Thanks already
     
    Awesome, so you've found all the stuff you need.

    One thing you could do is make a copy of pbPlayCry called pbPlayCryFaint (or whatever) that calls a copy of pbCryFile called pbCryFileFaint, and make these copies look for a slightly different filename that matches the pattern you want for the fainting cries. (Or if you know how to add parameters to functions then you could add a "fainted=false" parameter to pbPlayCry and pbCryFile so that you don't have to duplicate as much stuff).

    Then you can change the code that plays the cry for a fainting Pokémon to use your new pbPlayCryFaint instead of pbPlayCry. (Or pass true for fainted if you have added a new parameter).

    Good luck!
     
    I understand what you say, but I do not know how to do it, you tell me to copy the complete pbPlayCry command and replace the name pbPlayCry with pbPlayCryFaint, right?
    I do not know how to change the type of file I want to search, because if I change here:
    filename = sprintf ("Cries /% 03dCry", pokemon.species) yes! pbResolveAudioSE (file name)
    return file name if pbResolveAudioSE (file name)
    if I change where it says "Cries" I change the folder where the audios are, but I change the folder for both, for when it dies and for when it appears. And I do not understand that "% 03dCry".
     
    I think you understand well. If you have a complete copy then you can change the folder in that copy to (e.g.) "CriesFaint". Then all you need to do is make the code that plays a cry when the Pokémon faints call the code that does CriesFaint instead of Cries (which is why you give the function copy a new name—so you can use that name in the one place you want to change the behavior).
     
    Back
    Top