• 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] Setting Encounter Pokemon In The Scripts?

311
Posts
4
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?
     
    226
    Posts
    8
    Years
    • Seen Jul 19, 2023
    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