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

[Custom Feature Question] Increasing wild encounter levels depending on variables

  • 16
    Posts
    4
    Years
    • Seen Aug 1, 2023
    How do I increase the levels of wild encountered pokemon depending on variable?

    I've been debating for a while now if I wanted to make a open world game or a linear game. The thing that keeps popping up is the difficulty curve.

    If i were make an open world game, I could use level scaling, but in that case I could just breed a pokemon with an egg move "dragon rage" and beat the whole game with a team of level ones.

    Linear, is well, linear. No exploration, or finding great things, or catching your favorite pokemon first. No freedom.

    So I came to conclusion, that it would be better if the wild encounter and trainers level would increase depending on variables.

    For example: in my game, during chapter 2, you'll need to collect 3 items. I want it so you can collect any items in any order. However you'll need to complete a trial to get each items. Then after completing a trial, a variable will increase by 1. So the wild pokemons and trainers in the other routes leading to the other 2 trials have their levels increased. However, the route where you already completed trial remains the same.

    The trainers are easy to make with conditional branches. But I need help on the wild encounter. So is possible? If so, then please help. :)

    P.S. I wanted the levels in the completed area to remain the same because you can always come back and train weaker pokemon there.

    Thank you.
     
  • 277
    Posts
    15
    Years
    Changing a wild Pokemon's level is actually quite easy.

    First open your script editor and find PField_EncounterModifiers.

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

    and add the following code in between the "end" and the "}"
    Code:
        if $game_variables[X]==1
         pokemon.level=L+rand(R)
       elsif $game_variables[X]==2
         pokemon.level=L+rand(R)
       else
         pokemon.level=L+rand(R)
       end

    Change X to the variable you want to use to control the levels.
    Change L to the lowest level you want to find the pokemon at. Let's say you want to find Pokemon at levels 12-16 then L needs to be 12.
    Change R to be the difference between your desired lowest level (in this example 12) and your highest level (in this example 16) and then add 1.
    So the difference between 12 and 16 is 4, then add 1 to make R=5. This is because rand(5) will never give you 5, but instead give a random number from 0 to 4.

    This is what the whole script should look like with a few example numbers thrown in.
    Code:
    Events.onWildPokemonCreate+=proc {|sender,e|
       pokemon=e[0]
       if $game_switches[SHINY_WILD_POKEMON_SWITCH]
         pokemon.makeShiny
       end
        if $game_variables[99]==1
         pokemon.level=10+rand(5)
       elsif $game_variables[99]==2
         pokemon.level=18+rand(5)
       else
         pokemon.level=2+rand(5)
       end
    }

    of course you add more level options by adding more elsif statements.

    Now you can modify the levels of the Pokemon in the wild!
    But lets go a step further.

    Lets say example variable is set to 2 and now you can find Pokemon in the wild between the levels 18 and 22.
    If you go to a route where you can find Rattata then they will all be in that level range.... But Rattata evolves at level 20. So let's make pokemon evolve in the wild!

    Code:
    Events.onWildPokemonCreate+=proc {|sender,e|
       pokemon=e[0]
       if $game_switches[SHINY_WILD_POKEMON_SWITCH]
         pokemon.makeShiny
       end
        if $game_variables[99]==1
         pokemon.level= 10 + rand(5)
       elsif $game_variables[99]==2
         pokemon.level= 18 + rand(5)
         if pokemon.species==PBSpecies::RATTATA && pokemon.level>19
           pokemon.species=PBSpecies::RATICATE
         end
       else
         pokemon.level= 2 + rand(5)
       end
    }

    I have added an extra check to the example code above to determine if the wild Pokemon is a Rattata and if it is level 20 or higher.
    If the wild Pokemon meets those requirements then a Raticate will spawn instead of the Rattata.

    Alternatively, you could add a new Pokemon. If you replace PBSpecies::RATICATE with PBSpecies::PIKACHU then Rattata will continue to spawn at level 19 or lower, but a Pikachu will spawn at level 20 or above instead (replacing 1 rat with another).
    There are many more modifier you can use to make the Pokemon really feel like they are progressing with the player such as modifying what attacks the Pokemon know, spawn with their hidden ability, perfect IVs and so much more!

    Edit: I completely overlooked where you said you wanted completed areas to stay the same level, for that you would need a variable for each location.
     
    Last edited:
  • 16
    Posts
    4
    Years
    • Seen Aug 1, 2023
    Changing a wild Pokemon's level is actually quite easy.

    First open your script editor and find PField_EncounterModifiers.

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

    and add the following code in between the "end" and the "}"
    Code:
        if $game_variables[X]==1
         pokemon.level=L+rand(R)
       elsif $game_variables[X]==2
         pokemon.level=L+rand(R)
       else
         pokemon.level=L+rand(R)
       end

    Change X to the variable you want to use to control the levels.
    Change L to the lowest level you want to find the pokemon at. Let's say you want to find Pokemon at levels 12-16 then L needs to be 12.
    Change R to be the difference between your desired lowest level (in this example 12) and your highest level (in this example 16) and then add 1.
    So the difference between 12 and 16 is 4, then add 1 to make R=5. This is because rand(5) will never give you 5, but instead give a random number from 0 to 4.

    This is what the whole script should look like with a few example numbers thrown in.
    Code:
    Events.onWildPokemonCreate+=proc {|sender,e|
       pokemon=e[0]
       if $game_switches[SHINY_WILD_POKEMON_SWITCH]
         pokemon.makeShiny
       end
        if $game_variables[99]==1
         pokemon.level=10+rand(5)
       elsif $game_variables[99]==2
         pokemon.level=18+rand(5)
       else
         pokemon.level=2+rand(5)
       end
    }

    of course you add more level options by adding more elsif statements.

    Now you can modify the levels of the Pokemon in the wild!
    But lets go a step further.

    Lets say example variable is set to 2 and now you can find Pokemon in the wild between the levels 18 and 22.
    If you go to a route where you can find Rattata then they will all be in that level range.... But Rattata evolves at level 20. So let's make pokemon evolve in the wild!

    Code:
    Events.onWildPokemonCreate+=proc {|sender,e|
       pokemon=e[0]
       if $game_switches[SHINY_WILD_POKEMON_SWITCH]
         pokemon.makeShiny
       end
        if $game_variables[99]==1
         pokemon.level= 10 + rand(5)
       elsif $game_variables[99]==2
         pokemon.level= 18 + rand(5)
         if pokemon.species==PBSpecies::RATTATA && pokemon.level>19
           pokemon.species=PBSpecies::RATICATE
         end
       else
         pokemon.level= 2 + rand(5)
       end
    }

    I have added an extra check to the example code above to determine if the wild Pokemon is a Rattata and if it is level 20 or higher.
    If the wild Pokemon meets those requirements then a Raticate will spawn instead of the Rattata.

    Alternatively, you could add a new Pokemon. If you replace PBSpecies::RATICATE with PBSpecies::PIKACHU then Rattata will continue to spawn at level 19 or lower, but a Pikachu will spawn at level 20 or above instead (replacing 1 rat with another).
    There are many more modifier you can use to make the Pokemon really feel like they are progressing with the player such as modifying what attacks the Pokemon know, spawn with their hidden ability, perfect IVs and so much more!

    Edit: I completely overlooked where you said you wanted completed areas to stay the same level, for that you would need a variable for each location.

    I̶'̶m̶ ̶n̶o̶t̶ ̶a̶t̶ ̶m̶y̶ ̶c̶o̶m̶p̶u̶t̶e̶r̶ ̶r̶i̶g̶h̶t̶ ̶n̶o̶w̶,̶ ̶b̶u̶t̶ ̶t̶h̶a̶t̶ ̶d̶o̶e̶s̶ ̶l̶o̶o̶k̶ ̶p̶r̶o̶m̶i̶s̶i̶n̶g̶.̶ ̶I̶'̶l̶l̶ ̶t̶e̶s̶t̶ ̶i̶t̶ ̶o̶u̶t̶ ̶w̶h̶e̶n̶ ̶I̶ ̶g̶e̶t̶ ̶t̶o̶ ̶m̶y̶ ̶c̶o̶m̶p̶u̶t̶e̶r̶.̶ ̶O̶n̶e̶ ̶o̶t̶h̶e̶r̶ ̶q̶u̶e̶s̶t̶i̶o̶n̶,̶ ̶h̶o̶w̶ ̶d̶o̶ ̶I̶ ̶d̶e̶t̶e̶r̶m̶i̶n̶e̶ ̶v̶a̶r̶i̶a̶b̶l̶e̶ ̶f̶o̶r̶ ̶e̶a̶c̶h̶ ̶m̶a̶p̶?̶ ̶F̶r̶o̶m̶ ̶t̶h̶e̶ ̶l̶o̶o̶k̶s̶ ̶o̶f̶ ̶i̶t̶ ̶(̶a̶g̶a̶i̶n̶ ̶h̶a̶v̶e̶n̶'̶t̶ ̶t̶e̶s̶t̶ ̶i̶t̶ ̶y̶e̶t̶)̶ ̶i̶t̶ ̶l̶o̶o̶k̶s̶ ̶l̶i̶k̶e̶ ̶m̶y̶ ̶w̶h̶o̶l̶e̶ ̶r̶e̶g̶i̶o̶n̶ ̶w̶i̶l̶l̶ ̶b̶e̶ ̶a̶f̶f̶e̶c̶t̶e̶d̶.̶
    Edit: OKay I tested it, it affected my whole region.

    When I was trying to figure this out. I took a more complicated alternative route. I decided to make new encounters instead. When the variable reach a certain number, the wild encounter will switch to the new encounter. That way I can individually modify the encounters for each map, while the "route 1" pokemon stay weak. But, by doing it this way I have to add a lot more different variables than just using 1. (̶W̶i̶l̶l̶ ̶p̶o̶s̶t̶ ̶s̶c̶r̶e̶e̶n̶s̶h̶o̶t̶ ̶l̶a̶t̶e̶r̶ ̶o̶f̶ ̶w̶h̶a̶t̶ ̶I̶ ̶m̶e̶a̶n̶t̶)̶

    Increasing wild encounter levels depending on variables

    Notices how I added more variables. The other Trial Leaders will have a similar script. Each Trial Leaders will have a "+=0" to each of their correlated variable. Example in the image above, the Tidal Trial Leader has a "+=0" for the "TidalCrater" variables.

    Code:
    enctype = EncounterTypes::Land
          enctype = EncounterTypes::MtPyreOne if self.hasEncounter?(EncounterTypes::MtPyreOne) && $game_variables[28]==1
          enctype = EncounterTypes::MtPyreThree if self.hasEncounter?(EncounterTypes::MtPyreThree) && $game_variables[28]==3
          enctype = EncounterTypes::IcePeakOne if self.hasEncounter?(EncounterTypes::IcePeakOne) && $game_variables[29]==1
          enctype = EncounterTypes::IcePeakThree if self.hasEncounter?(EncounterTypes::IcePeakThree) && $game_variables[29]==3
          enctype = EncounterTypes::TidalOne if self.hasEncounter?(EncounterTypes::TidalOne) && $game_variables[30]==1
          enctype = EncounterTypes::TidalThree if self.hasEncounter?(EncounterTypes::TidalThree) && $game_variables[30]==3
          enctype = EncounterTypes::LandNight if self.hasEncounter?(EncounterTypes::LandNight) && PBDayNight.isNight?(time)
          enctype = EncounterTypes::LandDay if self.hasEncounter?(EncounterTypes::LandDay) && PBDayNight.isDay?(time)
          enctype = EncounterTypes::LandMorning if self.hasEncounter?(EncounterTypes::LandMorning) && PBDayNight.isMorning?(time)
          if pbInBugContest? && self.hasEncounter?(EncounterTypes::BugContest)

    The script above is just an portion of what I'm trying to achieve, it's not the whole thing. These are new encounter types. I made these encounters dependent on their respected variables. I left variable "$game_variables[]==2" out for a reason. After you completed the second Trial Leader, it will "+=2" to the other variables except itself, so it's variable stayed at "1." Meaning it'll have the $game_variable[]==1 encounter. The completed first Trial, which was "0," will now increased by "2," since there is no define encounter for it, it'll default back into the original encounters. For the third Trial, it's variable was at 1, because of the first trial, and after the second trial, it will +2 and changed into 3. Now the $game_variables[]==3 will kick in and replace the $game_variables[]==1. All there's left is to edit the encounter.txt to whatever it necessary. I'm still trying to figure out how to do the "cave" and "water" encounter. This is a very complex method. I'm hoping there might be an easier way.
     
    Last edited:
  • 277
    Posts
    15
    Years
    I have reworked the code for you.
    This new version checks the map your on and changes the level of the wild Pokemon to that of whatever variable you have set for that location.
    Simply change the map IDs to match the maps in your game, and set the game variables to the lowest level you want the wild Pokemon to be found at.

    Code:
    Events.onWildPokemonCreate+=proc {|sender,e|
       pokemon=e[0]
       if $game_switches[SHINY_WILD_POKEMON_SWITCH]
         pokemon.makeShiny
       end
        if $game_map.map_id == 1 || $game_map.map_id == 2 || $game_map.map_id == 3
         pokemon.level = $game_variables[A] + rand(5)
       elsif $game_map.map_id == 4 || $game_map.map_id == 5 || $game_map.map_id == 6
         pokemon.level = $game_variables[B] + rand(5)
       elsif $game_map.map_id == 7 || $game_map.map_id == 8 || $game_map.map_id == 9
         pokemon.level = $game_variables[C] + rand(5)
       elsif $game_map.map_id == 10 || $game_map.map_id == 11 || $game_map.map_id == 12
         pokemon.level = $game_variables[D] + rand(5)
       elsif $game_map.map_id == 13 || $game_map.map_id == 14 || $game_map.map_id == 15
         pokemon.level = $game_variables[E] + rand(5)
       elsif $game_map.map_id == 16 || $game_map.map_id == 17 || $game_map.map_id == 18
         pokemon.level = $game_variables[F] + rand(5)
       elsif $game_map.map_id == 19 || $game_map.map_id == 20 || $game_map.map_id == 21
         pokemon.level = $game_variables[G] + rand(5)
       elsif $game_map.map_id == 22 || $game_map.map_id == 23 || $game_map.map_id == 24
         pokemon.level = $game_variables[H] + rand(5)
       end
    }

    Since your wanting the levels to match what order you beat the gyms, simply change the variables after the player completes a gym.
    This can be done by only changing the variables that will effect the area around the newly competed gyms if you want the pokemon to scale after the gyms, but if you want all the Pokemon in locations where a gym hasn't been completed to scale simply change the variables of the uncompleted gyms.
     
    Last edited:
  • 16
    Posts
    4
    Years
    • Seen Aug 1, 2023
    I have reworked the code for you.
    This new version checks the map your on and changes the level of the wild Pokemon to that of whatever variable you have set for that location.
    Simply change the map IDs to match the maps in your game, and set the game variables to the lowest level you want the wild Pokemon to be found at.

    Code:
    Events.onWildPokemonCreate+=proc {|sender,e|
       pokemon=e[0]
       if $game_switches[SHINY_WILD_POKEMON_SWITCH]
         pokemon.makeShiny
       end
        if $game_map.map_id == 1 || $game_map.map_id == 2 || $game_map.map_id == 3
         pokemon.level = $game_variables[A] + rand(5)
       elsif $game_map.map_id == 4 || $game_map.map_id == 5 || $game_map.map_id == 6
         pokemon.level = $game_variables[B] + rand(5)
       elsif $game_map.map_id == 7 || $game_map.map_id == 8 || $game_map.map_id == 9
         pokemon.level = $game_variables[C] + rand(5)
       elsif $game_map.map_id == 10 || $game_map.map_id == 11 || $game_map.map_id == 12
         pokemon.level = $game_variables[D] + rand(5)
       elsif $game_map.map_id == 13 || $game_map.map_id == 14 || $game_map.map_id == 15
         pokemon.level = $game_variables[E] + rand(5)
       elsif $game_map.map_id == 16 || $game_map.map_id == 17 || $game_map.map_id == 18
         pokemon.level = $game_variables[F] + rand(5)
       elsif $game_map.map_id == 19 || $game_map.map_id == 20 || $game_map.map_id == 21
         pokemon.level = $game_variables[G] + rand(5)
       elsif $game_map.map_id == 22 || $game_map.map_id == 23 || $game_map.map_id == 24
         pokemon.level = $game_variables[H] + rand(5)
       end
    }

    Since your wanting the levels to match what order you beat the gyms, simply change the variables after the player completes a gym.
    This can be done by only changing the variables that will effect the area around the newly competed gyms if you want the pokemon to scale after the gyms, but if you want all the Pokemon in locations where a gym hasn't been completed to scale simply change the variables of the uncompleted gyms.

    YES! IT WORKS! Thank you so much!!!
     
    Back
    Top