• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
Resource icon

Resource Automatic Level Scaling 1.5.1

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
674
You mixed things.
This is the name of the trainer:
1689889482925.png
1689889611768.png

This is the trainer_type, the same one that goes between brackets in the trainer_types PBS:
1689889501735.png


So, since you used trainer.name, you have to make the array with the names of the trainers (the ones like in the first image).

As something I just remembered, maybe you'll need to have the array like this instead of the one I showed before, since you are making an array with names instead of IDs:
1689889718700.png


Again, maybe activating and deactivating the difficulty before and after the battle might be easier than that because I have no idea if this works.
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
674
Well, I know this works (I just noticed that trainer_type also uses a name and not an ID):
1689890042042.png

The only difference is that the check is made after the check for the trainer (and that is not checking an array) but I don't know if it affects. The only solutions I can think of are:
  • Pass the whole condition to another if right under the if trainer one.
  • Erase it and make if conditions (like the ones in the image) under the trainer one where you check if the name matches one of your gym leaders, elite four or champion (you'll need to make a check for every one of them).
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
674
Ok, I'm blind aparently. The code is .include? and not .includes?. Try it and if it still doesn't work I share the other options I made.
 

Jukes

Cooltrainer
Member
Joined
Jul 15, 2023
Posts
102
Haha well it stopped crashing but I think i see the issue. your method of

LevelScalingSettings::EXCLUDED_TRAINERS.include?(trainer.name)

is saying include this. what were trying to do is Exclude it. how can we make it !include?
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
674
Oh, right. Well, at least that is the easy part. Just put ! at the start of the condition. Like this: !LevelScalingSettings::EXCLUDED_TRAINERS.include?(trainer.name)
 

Benitex

Trainer
Member
Joined
Nov 7, 2020
Posts
77

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
674
Is there an way to set a maximum level the scaling will go to?
The minimum level is 1, and the maximum is the maximum level you define in the settings for your game. By default is 100, but you can change it to other numbers, and that will be the maximum level for all pokémon in the game, be it wild pokémon, other trainers or your own.

The plugin, though, comes with another sort of level cap: changing the configuration so the levels are only adjusted when the player's pokémon are of lower level than the defined on the encounters' or trainers' PBS. That way, the levels of wild and other trainer's pokémon will lower to adjust to the player's level, but they will not adjust if the player's party level is above the one defined for them.
 

Benitex

Trainer
Member
Joined
Nov 7, 2020
Posts
77
Is there an way to set a maximum level the scaling will go to?
You can use a variable to store the maximum level and add the following highlighted lines of code to 004_Event_Handlers.rb, in any EventHandlers you want to use maximum levels (the following example works for wild pokemon). VARIABLE_NUMBER is the variable id from RPG Maker (like TRAINER_VARIABLE and WILD_VARIABLE).

Ruby:
Expand Collapse Copy
EventHandlers.add(:on_wild_pokemon_created, :automatic_level_scaling,
  proc { |pokemon|
    id = pbGet(LevelScalingSettings::WILD_VARIABLE)
    if id != 0
      AutomaticLevelScaling.setDifficulty(id)
      AutomaticLevelScaling.setNewLevel(pokemon)

      max_level = pbGet(VARIABLE_NUMBER)
      if pokemon.level > max_level
        pokemon.level = max_level

        AutomaticLevelScaling.setNewStage(pokemon)
 
        pokemon.calc_stats
        pokemon.reset_moves
      end
    end
  }
)

You can also look for level-cap plugins, they will probably work with level scaling just fine.
 

EndlessBeat

Professionally Unprofessional
Member
Joined
Apr 2, 2021
Posts
89
Is there are way for if you have a following trainer, you can have the script set that partner trainer's Pokemon specifically? (For example, I set the difficulty for the enemy Pokemon like normal, but I also have a setting that forces the Partner Trainer to be the same level as your highest Pokemon at the same time.)
 

Benitex

Trainer
Member
Joined
Nov 7, 2020
Posts
77
Is there are way for if you have a following trainer, you can have the script set that partner trainer's Pokemon specifically? (For example, I set the difficulty for the enemy Pokemon like normal, but I also have a setting that forces the Partner Trainer to be the same level as your highest Pokemon at the same time.)
You can change the partner trainers' Pokemon using the third EventHandlers in 004_Event_Handlers.rb. If you want to use a custom difficulty for partner trainers, you can change lines 37, 38, and 39 like this:
Ruby:
Expand Collapse Copy
# Updates partner's pokemon levels after battle
EventHandlers.add(:on_end_battle, :update_partner_levels,
  proc { |_decision, _canLose|
    id = pbGet(LevelScalingSettings::TRAINER_VARIABLE)
    if $PokemonGlobal.partner != nil && id != 0
      AutomaticLevelScaling.setDifficulty(id)
      avarage_level = 0
      $PokemonGlobal.partner[3].each { |pokemon| avarage_level += pokemon.level }
      avarage_level /= $PokemonGlobal.partner[3].length

      for pokemon in $PokemonGlobal.partner[3] do
        AutomaticLevelScaling.setNewLevel(pokemon, pokemon.level - avarage_level)
      end
    end
  }
)
Just create a new constant in 002_Settings.rb like TRAINER_VARIABLE and WILD_VARIABLE, and change LevelScalingSettings::TRAINER_VARIABLE with the name of the new constant.

But, if you want all partner trainers' Pokemon levels to be the same as the trainer's Pokemon with the highest level, you can change it to be something like this:
Ruby:
Expand Collapse Copy
# Updates partner's pokemon levels after battle
EventHandlers.add(:on_end_battle, :update_partner_levels,
  proc { |_decision, _canLose|
    if $PokemonGlobal.partner != nil
      max_level = $player.party[0].level
      for pokemon in $player.party do
        max_level = pokemon.level if pokemon.level > max_level
      end

      for pokemon in $PokemonGlobal.partner[3] do
        pokemon.level = max_level
        AutomaticLevelScaling.setNewStage(pokemon)
        pokemon.calc_stats
        pokemon.reset_moves
      end
    end
  }
)
 

CarlosPR

Novice
Member
Joined
Mar 6, 2022
Posts
49
Hi is there an option to disable the plugin in some instances and have the level assigned on the PBS instead for trainers and wild pokemon?
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
674
The plugin doesn't work as long as the variables used to determine the difficulty levels for wild pokemon or trainers are 0. This means that if you turn the variable for the trainers to 0, the game will use the default levels set on the PBS file for all trainers. You will probably want to store the value of the difficulty somewhere else before that so you can restore the difficulty at any time.
 

swampus

Rookie
Member
Joined
Oct 16, 2023
Posts
5
This plugin generally works very well and I appreciate the modularity, however I'm having an issue with all 2 stage evolutions. All Pokemon with 2 stages of evolution that evolve somewhere between the default evolution levels that you have that allow Pokemon that dont evolve through level to evolve are evolving as soon as the hit the first value. So with default settings, Grimer is evolving to Muk as soon as level 20 however Pokemon like Rufflet who typically evolve after level 40 are not evolving early and evolve when they normally should. I tried to check the code out and I can't really figure out why this is happening.

EDIT: Okay I'm realizing all the Pokemon ive tested that evolve too soon are Pokemon with regional forms, I did not make that connection right away. But that definitely has something to do with it. Sorry also if this is a known issue.
 
Last edited:

Benitex

Trainer
Member
Joined
Nov 7, 2020
Posts
77
This plugin generally works very well and I appreciate the modularity, however I'm having an issue with all 2 stage evolutions. All Pokemon with 2 stages of evolution that evolve somewhere between the default evolution levels that you have that allow Pokemon that dont evolve through level to evolve are evolving as soon as the hit the first value. So with default settings, Grimer is evolving to Muk as soon as level 20 however Pokemon like Rufflet who typically evolve after level 40 are not evolving early and evolve when they normally should. I tried to check the code out and I can't really figure out why this is happening.

EDIT: Okay I'm realizing all the Pokemon ive tested that evolve too soon are Pokemon with regional forms, I did not make that connection right away. But that definitely has something to do with it. Sorry also if this is a known issue.
Thank you for reporting the issue. The problem is, I can't find a way to get the evolution level or alternative method of evolution of pokemon in their regional forms, because of this, all of them evolve like others with evolution methods different from level-up. Until I (or someone else) find a way to do this, you can use AutomaticLevelScaling.setSettings to change the default evolution levels for a single battle.
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
674
More of a workaround than a fix, really, but having something like that might work:
Ruby:
Expand Collapse Copy
EventHandlers.add(:on_wild_pokemon_created, :automatic_level_scaling,
  proc { |pokemon|
    id = pbGet(LevelScalingSettings::WILD_VARIABLE)
    if id != 0
      if pokemon.isSpecies?(:GRIMER) || pokemon.isSpecies?(:MUK)
        if pokemon.form == 0
          AutomaticLevelScaling.setTemporarySetting("firstEvolutionLevel", 10)
          AutomaticLevelScaling.setTemporarySetting("secondEvolutionLevel", 20)
        elsif pokemon.form == 1
          AutomaticLevelScaling.setTemporarySetting("firstEvolutionLevel", 20)
          AutomaticLevelScaling.setTemporarySetting("secondEvolutionLevel", 30)
        elsif pokemon.form == 2
          AutomaticLevelScaling.setTemporarySetting("firstEvolutionLevel", 30)
          AutomaticLevelScaling.setTemporarySetting("secondEvolutionLevel", 40)
        end
      end
      AutomaticLevelScaling.setDifficulty(id)
      AutomaticLevelScaling.setNewLevel(pokemon)
    end
  }
)
I'm editing both the first and second evolution levels just to show the idea. I haven't tested it with the pokemon form conditional but I have the conditional of checking for certain species to edit the rule of including previous stages (because you can't convince me that a mantike or similar baby pokemon, that need an incense in the daycare to be born from the eggs, can appear in the wild).
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
674
Sorry for the double post if it bothers anyone but I just tested the code I shared before with galarian meowth (that wasn't evolving at all) and it works.
Also, this is happening right now in my game with this plugin activated:
1697703697336.png
1697703703378.png
1697703724274.png
1697703735115.png

Grimer is in the POKEMON_WITH_REGIONAL_FORMS thing and aside from adding the checks for other level-up evolutions (levelmale, levelfemale, etc) I only added this (I think):
1697703922304.png

In the original code, it was unless other_evolving_method || regionalForm.

Edit: Ok, I think I figured out the problem with meowth. If the pokemon has 2 or more evolutions and at least 1 isn't by leveling up, the pokemon won't evolve at all. Kantonian and galarian meowth aren't evolving because of it, as well as any other regional form with new evolutions or pokemon like slowpoke.
 
Last edited:
Back
Top