• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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.

[Question] How can I play the "Last Pokemon Music" with 2 or more trainers? [v16.3]

Tms_tzzn

Fire Type Pokemon Appreciator.
  • 20
    Posts
    2
    Years
    [FIXED]






    Hello, it's me, again.
    This time, I was trying to implement the mechanic of 5th gen, that plays a specific theme that is called "Last Pokemon Music", or something like that.
    The thing here is, that I was able to put it on a single trainer (a gym leader), but I tried to put it to a normal trainer, but it does not take effect. ¿Could you guys help me, please?

    This is the script that I put into PokeBattle_Battle:


    def pbSendOut(index,pokemon)
    pbSetSeen(pokemon)
    @peer.pbOnEnteringBattle(self,pokemon)
    if pbIsOpposing?(index)
    @scene.pbTrainerSendOut(index,pokemon)
    else
    @scene.pbSendOut(index,pokemon)
    end
    @scene.pbResetMoveIndex(index)

    if $game_switches[99] and pbPokemonCount(@party2)==1
    @scene.pbShowOpponent(0)
    pbBGMPlay("GymLastPKMN",100,100)
    pbDisplayPaused(_INTL("I'm not done yet, I'm still able to fight!"))
    @scene.pbHideOpponent
    end
    end


    As I said before, this script works perfect for my one and only Gym Leader, but then.


    def pbSendOut(index,pokemon)
    pbSetSeen(pokemon)
    @peer.pbOnEnteringBattle(self,pokemon)
    if pbIsOpposing?(index)
    @scene.pbTrainerSendOut(index,pokemon)
    else
    @scene.pbSendOut(index,pokemon)
    end
    @scene.pbResetMoveIndex(index)

    if $game_switches[99] and pbPokemonCount(@party2)==1
    @scene.pbShowOpponent(0)
    pbBGMPlay("GymLastPKMN",100,100)
    pbDisplayPaused(_INTL("I'm not done yet, I'm still able to fight!"))
    @scene.pbHideOpponent
    end

    if $game_switches[98] and pbPokemonCount(@party2)==1
    @scene.pbShowOpponent(0)
    pbBGMPlay("GymLastPKMN",100,100)
    pbDisplayPaused(_INTL("My fishing rod's gonna break..."))
    @scene.pbHideOpponent
    end
    end


    This one doesn't work, nothing shows up when the trainer has its last pokemon.


    If I try to put an Elsif instead of if in the line " if $game_switches[98] and pbPokemonCount(@party2)==1 " the game doesn't even start.


    So, ¿how do I fix this?

    Thanks in advance!
     
    Last edited:
  • 87
    Posts
    7
    Years
    • Seen Nov 22, 2023
    $game_switches[99] refers to Switch 99.
    Enable Switch 99 to have the music play - - check your gym leader and you'll see that switch 99 is enabled before the battle.
    This switch also has to be disabled after the battle to prevent it from affecting other trainers.

    In the snippet that you created for the other trainer (fisherman?), you used switch 98; enable switch 98 before the battle.
     

    StCooler

    Mayst thou thy peace discover.
  • 9,325
    Posts
    4
    Years
    • Seen yesterday
    I don't know much v16, but does it have the "nextBattleBGM" variable by any chance?
    In v18, you can write a line like this:
    Code:
    $PokemonGlobal.nextBattleBGM = "Your choice of music"
    before starting your battle.
     

    Tms_tzzn

    Fire Type Pokemon Appreciator.
  • 20
    Posts
    2
    Years
    $game_switches[99] refers to Switch 99.
    Enable Switch 99 to have the music play - - check your gym leader and you'll see that switch 99 is enabled before the battle.
    This switch also has to be disabled after the battle to prevent it from affecting other trainers.

    In the snippet that you created for the other trainer (fisherman?), you used switch 98; enable switch 98 before the battle.

    I have done all what you said, but it still doesn't work.
     

    Tms_tzzn

    Fire Type Pokemon Appreciator.
  • 20
    Posts
    2
    Years
    I don't know much v16, but does it have the "nextBattleBGM" variable by any chance?
    In v18, you can write a line like this:
    Code:
    $PokemonGlobal.nextBattleBGM = "Your choice of music"
    before starting your battle.

    but that code only changes the battle music for that specific trainer. What do I need is change the music in battle, like in BW2.
     

    StCooler

    Mayst thou thy peace discover.
  • 9,325
    Posts
    4
    Years
    • Seen yesterday
    Nah, no need to apologize

    As an apology I digged into your problem ^^

    So you seem to want to make a list of trainers that can change the music when they have only one Pokémon left. I suggest you make a generic function instead of reserving 50 switches for 50 different trainers.

    Use this code as the function pbSendOut, it has only one addition:
    Code:
    class PokeBattle_Battle
      def pbSendOut(index,pokemon)
        pbSetSeen(pokemon)
        @peer.pbOnEnteringBattle(self,pokemon)
        if pbIsOpposing?(index)
          @scene.pbTrainerSendOut(index,pokemon)
        else
          @scene.pbSendOut(index,pokemon)
        end
        @scene.pbResetMoveIndex(index)
        
        self.pbLastPokemonScene # This is the only addition
      end
    end

    Paste the following in a new script (it will be easier to find it if you want to edit)
    Code:
    # Here, choose two adjacent unused variables:
    LAST_POKEMON_MUSIC_VARIABLE = 100
    LAST_POKEMON_MESSAGE_VARIABLE = 101
    
    # Whenever you want a battle to have a change in music and a special message, 
    # use this BEFORE calling pbTrainerBattle:
    def pbSetLastPokemonMusic(musicname, msg)
      $game_variables[LAST_POKEMON_MUSIC_VARIABLE] = musicname
      $game_variables[LAST_POKEMON_MESSAGE_VARIABLE] = msg
    end 
    
    # This function will check the two variables you set in the previous function,
    # and if something is defined, it will do the scene / change of music.
    class PokeBattle_Battle
      def pbLastPokemonScene
        return if pbPokemonCount(@party2) != 1
        
        music = $game_variables[LAST_POKEMON_MUSIC_VARIABLE]
        msg = $game_variables[LAST_POKEMON_MESSAGE_VARIABLE]
        
        return if !music.is_a?(String) && !msg.is_a?(String)
        
        @scene.pbShowOpponent(0)
        pbBGMPlay(music,100,100) if music.is_a?(String)
        pbDisplayPaused(msg) if msg.is_a?(String)
        @scene.pbHideOpponent
        
        $game_variables[LAST_POKEMON_MUSIC_VARIABLE] = 0 
        $game_variables[LAST_POKEMON_MESSAGE_VARIABLE] = 0 
      end 
    end
    Hope that helps (and I hope it works lol, I haven't tested it)
     
  • 87
    Posts
    7
    Years
    • Seen Nov 22, 2023
    Post a screenshot of the event that doesn't work.
    If you changed anything in the script, please provide the entire script or the method to a site like pastebin.

    Also, is there any particular reason that you're not on the latest version of Essentials?
     

    Tms_tzzn

    Fire Type Pokemon Appreciator.
  • 20
    Posts
    2
    Years
    As an apology I digged into your problem ^^

    So you seem to want to make a list of trainers that can change the music when they have only one Pokémon left. I suggest you make a generic function instead of reserving 50 switches for 50 different trainers.

    Use this code as the function pbSendOut, it has only one addition:
    Code:
    class PokeBattle_Battle
      def pbSendOut(index,pokemon)
        pbSetSeen(pokemon)
        @peer.pbOnEnteringBattle(self,pokemon)
        if pbIsOpposing?(index)
          @scene.pbTrainerSendOut(index,pokemon)
        else
          @scene.pbSendOut(index,pokemon)
        end
        @scene.pbResetMoveIndex(index)
        
        self.pbLastPokemonScene # This is the only addition
      end
    end

    Paste the following in a new script (it will be easier to find it if you want to edit)
    Code:
    # Here, choose two adjacent unused variables:
    LAST_POKEMON_MUSIC_VARIABLE = 100
    LAST_POKEMON_MESSAGE_VARIABLE = 101
    
    # Whenever you want a battle to have a change in music and a special message, 
    # use this BEFORE calling pbTrainerBattle:
    def pbSetLastPokemonMusic(musicname, msg)
      $game_variables[LAST_POKEMON_MUSIC_VARIABLE] = musicname
      $game_variables[LAST_POKEMON_MESSAGE_VARIABLE] = msg
    end 
    
    # This function will check the two variables you set in the previous function,
    # and if something is defined, it will do the scene / change of music.
    class PokeBattle_Battle
      def pbLastPokemonScene
        return if pbPokemonCount(@party2) != 1
        
        music = $game_variables[LAST_POKEMON_MUSIC_VARIABLE]
        msg = $game_variables[LAST_POKEMON_MESSAGE_VARIABLE]
        
        return if !music.is_a?(String) && !msg.is_a?(String)
        
        @scene.pbShowOpponent(0)
        pbBGMPlay(music,100,100) if music.is_a?(String)
        pbDisplayPaused(msg) if msg.is_a?(String)
        @scene.pbHideOpponent
        
        $game_variables[LAST_POKEMON_MUSIC_VARIABLE] = 0 
        $game_variables[LAST_POKEMON_MESSAGE_VARIABLE] = 0 
      end 
    end
    Hope that helps (and I hope it works lol, I haven't tested it)

    So, the first part goes into the pbSendOut function, and the second one, goes into a new script, above Main and below compiler, right?
     

    StCooler

    Mayst thou thy peace discover.
  • 9,325
    Posts
    4
    Years
    • Seen yesterday
    So, the first part goes into the pbSendOut function, and the second one, goes into a new script, above Main and below compiler, right?

    The first part replaces the pbSendOut function (I only removed your addition and replaced it with only one new line), and the second part goes in a new script above Main. (In general new scripts are added right before Main).
     

    Tms_tzzn

    Fire Type Pokemon Appreciator.
  • 20
    Posts
    2
    Years
    Post a screenshot of the event that doesn't work.
    If you changed anything in the script, please provide the entire script or the method to a site like pastebin.

    Also, is there any particular reason that you're not on the latest version of Essentials?


    I want to clarify that, the code itself doesn't give me problems, the thing is that, at the battle, it is just as a normal battle, nothing shows up, just the last pokemon.


    Yes, I'm using an older version of Essentials because it's translated to my native language, so, it makes things easier to me.

    Here are all the scripts that I've tried to put in the function:

    def pbSendOut(index,pokemon)
    pbSetSeen(pokemon)
    @peer.pbOnEnteringBattle(self,pokemon)
    if pbIsOpposing?(index)
    @scene.pbTrainerSendOut(index,pokemon)
    else
    @scene.pbSendOut(index,pokemon)
    end
    @scene.pbResetMoveIndex(index)

    if $game_switches[99] and pbPokemonCount(@party2)==1
    @scene.pbShowOpponent(0)
    pbBGMPlay("Music",100,100)
    pbDisplayPaused(_INTL("Dialogue"))
    @scene.pbHideOpponent
    elsif $game_switches[98] and pbPokemonCount(@party2)==1
    @scene.pbShowOpponent(0)
    pbBGMPlay("Music",100,100)
    pbDisplayPaused(_INTL("Dialogue"))
    @scene.pbHideOpponent
    end
    end

    This one doesn't work at all, only the first one (switch 99)


    elsif isConst?(trainertext.trainertype,PBTrainers,:"trainertype")
    @scene.pbShowOpponent(0)
    pbBGMPlay("music",100,100)
    pbDisplayPaused(_INTL("Dialogue"))
    @scene.pbHideOpponent
    end

    And this one works fine, but it makes that all trainers that have the same trainertype, say the same message.

    I thought this: make every "special trainer" have its dialogue and music, and make the same code every time I want to add another "special trainer".
     

    Tms_tzzn

    Fire Type Pokemon Appreciator.
  • 20
    Posts
    2
    Years
    The first part replaces the pbSendOut function (I only removed your addition and replaced it with only one new line), and the second part goes in a new script above Main. (In general new scripts are added right before Main).

    Ok, I'll try that. Thank you so much!
     

    Tms_tzzn

    Fire Type Pokemon Appreciator.
  • 20
    Posts
    2
    Years
    The first part replaces the pbSendOut function (I only removed your addition and replaced it with only one new line), and the second part goes in a new script above Main. (In general new scripts are added right before Main).

    Im not sure of a few things. First:

    def pbSetLastPokemonMusic(musicname, msg)
    $game_variables[LAST_POKEMON_MUSIC_VARIABLE] = musicname
    $game_variables[LAST_POKEMON_MESSAGE_VARIABLE] = msg
    end

    Here, I must change "musicname" and "msg" to the music that I want to play and the message that will be displayed, right?
    or is it here?:

    music = $game_variables[LAST_POKEMON_MUSIC_VARIABLE]
    msg = $game_variables[LAST_POKEMON_MESSAGE_VARIABLE]
     

    Tms_tzzn

    Fire Type Pokemon Appreciator.
  • 20
    Posts
    2
    Years
    As an apology I digged into your problem ^^

    So you seem to want to make a list of trainers that can change the music when they have only one Pokémon left. I suggest you make a generic function instead of reserving 50 switches for 50 different trainers.

    Use this code as the function pbSendOut, it has only one addition:
    Code:
    class PokeBattle_Battle
      def pbSendOut(index,pokemon)
        pbSetSeen(pokemon)
        @peer.pbOnEnteringBattle(self,pokemon)
        if pbIsOpposing?(index)
          @scene.pbTrainerSendOut(index,pokemon)
        else
          @scene.pbSendOut(index,pokemon)
        end
        @scene.pbResetMoveIndex(index)
        
        self.pbLastPokemonScene # This is the only addition
      end
    end

    Paste the following in a new script (it will be easier to find it if you want to edit)
    Code:
    # Here, choose two adjacent unused variables:
    LAST_POKEMON_MUSIC_VARIABLE = 100
    LAST_POKEMON_MESSAGE_VARIABLE = 101
    
    # Whenever you want a battle to have a change in music and a special message, 
    # use this BEFORE calling pbTrainerBattle:
    def pbSetLastPokemonMusic(musicname, msg)
      $game_variables[LAST_POKEMON_MUSIC_VARIABLE] = musicname
      $game_variables[LAST_POKEMON_MESSAGE_VARIABLE] = msg
    end 
    
    # This function will check the two variables you set in the previous function,
    # and if something is defined, it will do the scene / change of music.
    class PokeBattle_Battle
      def pbLastPokemonScene
        return if pbPokemonCount(@party2) != 1
        
        music = $game_variables[LAST_POKEMON_MUSIC_VARIABLE]
        msg = $game_variables[LAST_POKEMON_MESSAGE_VARIABLE]
        
        return if !music.is_a?(String) && !msg.is_a?(String)
        
        @scene.pbShowOpponent(0)
        pbBGMPlay(music,100,100) if music.is_a?(String)
        pbDisplayPaused(msg) if msg.is_a?(String)
        @scene.pbHideOpponent
        
        $game_variables[LAST_POKEMON_MUSIC_VARIABLE] = 0 
        $game_variables[LAST_POKEMON_MESSAGE_VARIABLE] = 0 
      end 
    end
    Hope that helps (and I hope it works lol, I haven't tested it)

    The game doesn't boot up. The problem is in the PokeBattle_Battle section.
     
  • 87
    Posts
    7
    Years
    • Seen Nov 22, 2023
    Can you please post a screenshot of your event?
    I just want to confirm that everything is fine there.
     

    StCooler

    Mayst thou thy peace discover.
  • 9,325
    Posts
    4
    Years
    • Seen yesterday
    Im not sure of a few things. First:

    def pbSetLastPokemonMusic(musicname, msg)
    $game_variables[LAST_POKEMON_MUSIC_VARIABLE] = musicname
    $game_variables[LAST_POKEMON_MESSAGE_VARIABLE] = msg
    end

    Here, I must change "musicname" and "msg" to the music that I want to play and the message that will be displayed, right?
    or is it here?:

    music = $game_variables[LAST_POKEMON_MUSIC_VARIABLE]
    msg = $game_variables[LAST_POKEMON_MESSAGE_VARIABLE]

    In the event, you add a script right before the pbTrainerBattle script and you write:

    Code:
    pbSetLastPokemonMusic("The new music", "Your message")

    The game doesn't boot up. The problem is in the PokeBattle_Battle section.

    Can you screen the error? Also, can you screen the resulting pbSendOut code?
    Double check if there are enough "end".

    Note that for pbSendOut(index,pokemon), you should just replace your edits (the "if" you added) with the new line I added, no need to copy/paste the whole code.
     

    Tms_tzzn

    Fire Type Pokemon Appreciator.
  • 20
    Posts
    2
    Years
    In the event, you add a script right before the pbTrainerBattle script and you write:

    Code:
    pbSetLastPokemonMusic("The new music", "Your message")



    Can you screen the error? Also, can you screen the resulting pbSendOut code?
    Double check if there are enough "end".

    Note that for pbSendOut(index,pokemon), you should just replace your edits (the "if" you added) with the new line I added, no need to copy/paste the whole code.

    I've done everything, and it still doesn't work.

    Thank you for your help.
     
    Back
    Top