• 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!
  • It's time to vote for your favorite Pokémon Battle Revolution protagonist in our new weekly protagonist poll! Click here to cast your vote and let us know which PBR protagonist you like most.
  • 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] Setting Encounter Pokemon In The Scripts?

  • 311
    Posts
    5
    Years
    I was just wondering if there was a way to set the encounter Pokemon in the game's scripts, rather than in the encounter.txt. Would this be possible?
     
    It's possible, although where you will do it depends on what you want to achieve. Most of the time you will probably use the script section PField_EncounterModifiers (it exists for that purpose). This is the example that comes with Essentials and that forces shiny pokemon to be generated: it indicates the structure to follow:

    Code:
    Events.onWildPokemonCreate+=proc {|sender,e|
       pokemon=e[0]
       if $game_switches[SHINY_WILD_POKEMON_SWITCH]
         pokemon.makeShiny
       end
    }

    Another use would be to change the form of the wild Pokemon encountered on a specific map:

    Code:
    Events.onWildPokemonCreate+=proc {|sender,e|
       pokemon=e[0]
       if $game_switches[X] && $game_map.map_id == X
         pokemon.form = 1
         pokemon.resetMoves
         pokemon.calcStats
       end
    }

    You can also entirely overwrite the encounters table defined in the encounters.txt file, if a specific switch is active, like this:

    Code:
    Events.onWildPokemonCreate+=proc {|sender,e|
       pokemon=e[0]
       if $game_switches[X]  && $game_map.map_id == X
         proba = rand(10) 
           if proba <3 
             newspecies = PBSpecies::RATTATA
           elsif proba >=3 && proba <6
             newspecies = PBSpecies::CATERPIE
           elsif probal >=6 && proba <8 
             newspecies = PBSpecies::PIDGEY
           else 
             newspecies = PBSpecies::SPEAROW
           end
          pokemon.species = newspecies
          pokemon.level = 5 + rand(3)
          pokemon.name = PBSpecies.getName(newspecies)
          pokemon.resetMoves
          pokemon.calcStats
       end
    }
     
    Last edited:
    Back
    Top