• 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.

[Other Question] [v19.1] Wild Battle Music Depending on Generation

sonicfan7895

Just a dude, I guess
122
Posts
13
Years
  • Hello! Fairly new to 19.1, and I've finally begun the migration process over from 16.2, and I had an idea for my project that I don't know how to execute.

    I wanted to have different wild battle themes play depending on the generation the pokemon originated from, but I don't know how to go about it.

    I can only guess it would have something to do with pulling from the "Species" class of the PBS Data script, but I wanted some advice before I fundamentally break my project.

    Any help would be greatly appreciated!
     
    124
    Posts
    3
    Years
  • Hello! Fairly new to 19.1, and I've finally begun the migration process over from 16.2, and I had an idea for my project that I don't know how to execute.

    I wanted to have different wild battle themes play depending on the generation the pokemon originated from, but I don't know how to go about it.

    I can only guess it would have something to do with pulling from the "Species" class of the PBS Data script, but I wanted some advice before I fundamentally break my project.

    Any help would be greatly appreciated!

    This should be straightforward using encounter modifiers. In v19, you can access a Pokémon's "generation" using GameData::Species.get(:SPECIES).generation
     
    Last edited:

    sonicfan7895

    Just a dude, I guess
    122
    Posts
    13
    Years
  • So since this has to do with encounter modifiers, this particular method would go in "Overworld_EncounterModifiers" instead? Or would this go some place else?
     
    311
    Posts
    4
    Years
  • That sounds like a decent place to start. Unfortunately, the game doesn't automatically know which Pokemon are in each generation by default, so you'll need to find a way, whether through arrays or something similar.
     
    124
    Posts
    3
    Years
  • Actually, generation was added as a property to the Pokémon PBS in v19. It can be accessed using the method I put above.

    Yes, Overworld_EncounterModifiers is where you would go to do what you want. You could use a `case when` statement to set the battle BGM according to the generation of the Pokémon. Thinking about it now, I don't know what would happen in a double/triple battle with Pokémon from different generations. I assume one Pokémon would take priority.
     

    sonicfan7895

    Just a dude, I guess
    122
    Posts
    13
    Years
  • Actually, generation was added as a property to the Pokémon PBS in v19. It can be accessed using the method I put above.

    Yes, Overworld_EncounterModifiers is where you would go to do what you want. You could use a `case when` statement to set the battle BGM according to the generation of the Pokémon. Thinking about it now, I don't know what would happen in a double/triple battle with Pokémon from different generations. I assume one Pokémon would take priority.

    Perhaps... so I'm guessing it would look something close to this...

    Code:
    # Events.onWildPokemonCreate += proc { |_sender, e|
    #  pokemon = e[0]
    #  case pokemon.generation
    #     when 1 $PokemonGlobal.nextBattleBGM = "Battle wild.mid"
    #     when 2 $PokemonGlobal.nextBattleBGM = "GSC Battle.mid"
    #  end

    I'm not even gonna bother questioning if this is coded correctly. I know it's not, but I'm guessing that's the basic gist of how it would look were it coded correctly.

    I'm trying to get back into coding in Ruby and remembering the syntaxes, so I sincerely apologize for my seeming lack of expertise
     

    sonicfan7895

    Just a dude, I guess
    122
    Posts
    13
    Years
  • Actually, generation was added as a property to the Pokémon PBS in v19. It can be accessed using the method I put above.

    Yes, Overworld_EncounterModifiers is where you would go to do what you want. You could use a `case when` statement to set the battle BGM according to the generation of the Pokémon. Thinking about it now, I don't know what would happen in a double/triple battle with Pokémon from different generations. I assume one Pokémon would take priority.

    One thing I did see was a VERY old post from FL made many years ago addressing this exact issue:

    Untested. Change the 'def pbGetWildBattleBGM(species)' to
    Code:
    def pbGetWildBattleBGM(species)
      if $PokemonGlobal.nextBattleBGM
        return $PokemonGlobal.nextBattleBGM.clone
      end
      playertrainer=pbGetPlayerTrainerType
      music = case playertrainer
        when 0 then "RBY_-_Wild" # First male trainer
        when 1 then "RSE_-_Wild" # First female trainer
        when 2 then "DPP_-_Wild"
      end
      ret=nil
      ret=pbStringToAudioFile(music) if music && music!=""
      ret=pbStringToAudioFile("002-Battle02") if !ret
      return ret
    end

    I know the code is horribly outdated, but this looks more like what I'd be doing than what I initially posted
     
    124
    Posts
    3
    Years
  • You could try editing that method that FL mentions. I'm not familiar with it myself.

    Here's how you could do it using encounter modifiers:
    Code:
    Events.onWildPokemonCreate += proc { |_sender, e|
      pokemon = e[0]
      data = GameData::Species.get_species_form(pokemon.species, pokemon.form)
      case data.generation
      when 1
        $PokemonGlobal.nextBattleBGM = "022-Field05.mid"
      when 4
        $PokemonGlobal.nextBattleBGM = "018-Field01.mid"
      when 7
        $PokemonGlobal.nextBattleBGM = "021-Field04_n.mid"
      end
    }
     

    sonicfan7895

    Just a dude, I guess
    122
    Posts
    13
    Years
  • You could try editing that method that FL mentions. I'm not familiar with it myself.

    Here's how you could do it using encounter modifiers:
    Code:
    Events.onWildPokemonCreate += proc { |_sender, e|
      pokemon = e[0]
      data = GameData::Species.get_species_form(pokemon.species, pokemon.form)
      case data.generation
      when 1
        $PokemonGlobal.nextBattleBGM = "022-Field05.mid"
      when 4
        $PokemonGlobal.nextBattleBGM = "018-Field01.mid"
      when 7
        $PokemonGlobal.nextBattleBGM = "021-Field04_n.mid"
      end
    }

    That's kind of how I was planning on going about it, I just wasn't sure whether or not to put "data.generation" or "pokemon.generation" as the case. That really helps out a lot! And I also apologize if it seemed like you just did it for me, I actually started to attempt it by commenting everything out, but I was stumped and genuinely needed help... Thank you so much!
     
    Back
    Top