# v18Random Level changes

This thread pertains to v18 of Pokémon Essentials.

#### Charizardthree

##### Cooltrainer
Member
Hi all,

Small problem but I have no clue why it is happening.
On one map in my game (only seems to happen on the same map), the levels of trainers and Pokemon do not match the PBS trainers/encounters documents.
instead it seems like the levels are randomly selected but I have no idea what has set it to do this.

I've also noticed static wild encounters are also doing the same thing. i.e. an static encounter set to level 20 has generated a Pokemon at level 15 and 25 on different occasions.

Has anyone had any issues like this or any idea on how to fix it?

Solution
What is the map ID of this particular map - is it 51? If so, then you need to go to the script section PField_EncounterModifiers and find this code:
Ruby:
# Used in the random dungeon map.  Makes the levels of all wild Pokémon in that
# map depend on the levels of Pokémon in the player's party.
# This is a simple method, and can/should be modified to account for evolutions
# and other such details.  Of course, you don't HAVE to use this code.
Events.onWildPokemonCreate += proc { |_sender, e|
pokemon = e[0]
if $game_map.map_id == 51 max_level = PBExperience.maxLevel new_level = pbBalancedLevel($Trainer.party) - 4 + rand(5)   # For variety
new_level = 1 if new_level < 1
new_level = max_level if new_level >...

#### NettoHikari

##### Cooltrainer
Member
What is the map ID of this particular map - is it 51? If so, then you need to go to the script section PField_EncounterModifiers and find this code:
Ruby:
# Used in the random dungeon map.  Makes the levels of all wild Pokémon in that
# map depend on the levels of Pokémon in the player's party.
# This is a simple method, and can/should be modified to account for evolutions
# and other such details.  Of course, you don't HAVE to use this code.
Events.onWildPokemonCreate += proc { |_sender, e|
pokemon = e[0]
if $game_map.map_id == 51 max_level = PBExperience.maxLevel new_level = pbBalancedLevel($Trainer.party) - 4 + rand(5)   # For variety
new_level = 1 if new_level < 1
new_level = max_level if new_level > max_level
pokemon.level = new_level
pokemon.calcStats
pokemon.resetMoves
end
}
And either comment out all the lines or just delete it. It's not your fault - this code is from default Essentials and assumes that map 51 is a "random dungeon" map that also came with Essentials, so it still activates even when you change the map to something else.

#### Charizardthree

##### Cooltrainer
Member
What is the map ID of this particular map - is it 51? If so, then you need to go to the script section PField_EncounterModifiers and find this code:
Ruby:
# Used in the random dungeon map.  Makes the levels of all wild Pokémon in that
# map depend on the levels of Pokémon in the player's party.
# This is a simple method, and can/should be modified to account for evolutions
# and other such details.  Of course, you don't HAVE to use this code.
Events.onWildPokemonCreate += proc { |_sender, e|
pokemon = e[0]
if $game_map.map_id == 51 max_level = PBExperience.maxLevel new_level = pbBalancedLevel($Trainer.party) - 4 + rand(5)   # For variety
new_level = 1 if new_level < 1
new_level = max_level if new_level > max_level
pokemon.level = new_level
pokemon.calcStats
pokemon.resetMoves
end
}
And either comment out all the lines or just delete it. It's not your fault - this code is from default Essentials and assumes that map 51 is a "random dungeon" map that also came with Essentials, so it still activates even when you change the map to something else.

You legend!
I thought It was something like this but I'm not that well versed with the scripts,
Now I know this I maybe able to implement it as an actual feature of the game.

Thank you so much!