• 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.
  • Eevee Expo's webhost has been having technical issues since Nov. 20th and you might be unable to connect to our site. Staff are also facing issues connecting, so please send a DM to Cat on-site or through Discord directly for faster service!
Resource icon

Resource Automatic Level Scaling 1.6.0

hostman

Trainer
Member
Joined
Aug 24, 2023
Posts
70
1708527658625.png

I have these options activated, however the enemy pokemon continue to evolve automatically despite having it set to false. What I can do?
 

Benitex

Trainer
Member
Joined
Nov 7, 2020
Posts
81
View attachment 26289
I have these options activated, however the enemy pokemon continue to evolve automatically despite having it set to false. What I can do?
There are multiple possible causes for this problem, I'll list some of them.
  • Parameter names seem to be written without the _ between words, which would cause a syntax error.
  • I see you change the difficulty before changing settings with setSettings, if you're not doing this for a specific battle and you want to change the settings globally, please change the settings in the 002_Settings.rb file instead, because setting them in an event would trigger then only once the event is activated (which might be another cause for the issue) and settings would reset after the player restarts the game.
  • You might be looking for the functionality of includeNextStages instead of automaticEvolutions. automaticEvolutions makes the plugin not change the stage set in the PBS in any way, while includeNextStages would stop evolution in a certain evolutionary stage. For example, imagine the player finds a level 17 Ivysaur set in the PBS while his party is around level 15, if automaticEvolutions is disabled, the pokemon would still be an Ivysaur, while if includeNextStages was disabled, it would revert to a Bulbasaur.
I hope this explanation can help you fix your issue. If you have any questions, please don't hesitate to ask.
 

Benitex

Trainer
Member
Joined
Nov 7, 2020
Posts
81
I would also like to add, for current users of the plugin, that in a future update (which would come with the need to fix some issues or implement a new feature and not right away), I will probably change the name of some of the settings and methods so that they can be a little bit more intuitive, and easier to understand for new users.
I was already interested in doing this in the last update, but I was not sure because I didn't want to make the updating process longer or more complicated. The solution I'm thinking about using is changing the default method and setting names, but also keeping the old ones as aliases. I honestly really don't want to remove the old ones completely, because I know finding and changing all of them in projects being made now would use a lot of time and would cause bugs wherever they are not updated. I would also change their names on the overview page and all other documentation, but I think this would not be a problem for people who are already used to the old names and their functionality.
Also, if you disagree and think this would not be a good idea, or you think this could be creating other problems, please tell me about your opinion.
 

hostman

Trainer
Member
Joined
Aug 24, 2023
Posts
70
There are multiple possible causes for this problem, I'll list some of them.
  • Parameter names seem to be written without the _ between words, which would cause a syntax error.
  • I see you change the difficulty before changing settings with setSettings, if you're not doing this for a specific battle and you want to change the settings globally, please change the settings in the 002_Settings.rb file instead, because setting them in an event would trigger then only once the event is activated (which might be another cause for the issue) and settings would reset after the player restarts the game.
  • You might be looking for the functionality of includeNextStages instead of automaticEvolutions. automaticEvolutions makes the plugin not change the stage set in the PBS in any way, while includeNextStages would stop evolution in a certain evolutionary stage. For example, imagine the player finds a level 17 Ivysaur set in the PBS while his party is around level 15, if automaticEvolutions is disabled, the pokemon would still be an Ivysaur, while if includeNextStages was disabled, it would revert to a Bulbasaur.
I hope this explanation can help you fix your issue. If you have any questions, please don't hesitate to ask.
1708622152657.png


thank you! I did the thing to modify them directly from 002_Settings.rb, however I can't find the variable for updates moves (the others do). Can you tell me if it is somewhere else?
 

Benitex

Trainer
Member
Joined
Nov 7, 2020
Posts
81
View attachment 26329

thank you! I did the thing to modify them directly from 002_Settings.rb, however I can't find the variable for updates moves (the others do). Can you tell me if it is somewhere else?
Oh, yes, there's no global setting for update_moves, because you'll probably prefer to let the plugin define moves in at least some scenarios, like with wild pokemon, because you can't set their moves manually in the PBS and it could be weird seeing them using weaker moves when they are already in a higher level. If you are sure you will set move sets for the pokemon of every trainer in your game, you can add this line of code: AutomaticLevelScaling.setTemporarySetting("updateMoves", false) in the on_trainer_load EventHandlers at the 004_Event_Handlers.rb file. It will look like this:
Ruby:
Expand Collapse Copy
# Activates script when a trainer pokemon is created
EventHandlers.add(:on_trainer_load, :automatic_level_scaling,
  proc { |trainer|
    id = pbGet(LevelScalingSettings::TRAINER_VARIABLE)
    next if !trainer || id == 0
    AutomaticLevelScaling.difficulty = id
    AutomaticLevelScaling.setTemporarySetting("updateMoves", false)

    avarage_level = 0
    trainer.party.each { |pokemon| avarage_level += pokemon.level }
    avarage_level /= trainer.party.length

    for pokemon in trainer.party do
      AutomaticLevelScaling.setNewLevel(pokemon, pokemon.level - avarage_level)
    end
  }
)
If you only want to manually define some of the move sets, you can use the same line in an event command just before the specific battle (which is what I generally recommend unless you are making a game with trainers that only use competitive teams).
 

Chadofy

Rookie
Member
Joined
Feb 26, 2024
Posts
2
Hello, thanks for this plugin. I love to use it, especially with trainers.

However I would like to make a difficulty level where Pokemons go from level 1 to the maximum level of your strongest Pokemon in your party.
I tried with this but it doesn't work ☹️

5 => Difficulty.new(fixed_increase: 0, random_increase: -GameData::GrowthRate.max_level)

Do you know how i could change that?
 
Last edited:

Benitex

Trainer
Member
Joined
Nov 7, 2020
Posts
81
Hello, thanks for this plugin. I love to use it, especially with trainers.

However I would like to make a difficulty level where Pokemons go from level 1 to the maximum level of your strongest Pokemon in your party.
I tried with this but it doesn't work ☹️

5 => Difficulty.new(fixed_increase: 0, random_increase: -GameData::GrowthRate.max_level)

Do you know how i could change that?
Hello, thank you for the appreciation. Unfortunately, there is no easy way to make a difficulty as you described in the 002_Settings.rb file because the highest level and the scaled party level are not constant values. However, I found a way to implement this feature in the :on_trainer_load EventHandlers at the 004_Event_Handlers.rb file, here's the code snippet:
Ruby:
Expand Collapse Copy
# Activates script when a trainer pokemon is created
EventHandlers.add(:on_trainer_load, :automatic_level_scaling,
  proc { |trainer|
    id = pbGet(LevelScalingSettings::TRAINER_VARIABLE)
    next if !trainer || id == 0
    AutomaticLevelScaling.difficulty = id

    if id == 5
      LevelScalingSettings::DIFFICULTIES[5].fixed_increase = 0
      LevelScalingSettings::DIFFICULTIES[5].random_increase = 0
      LevelScalingSettings::DIFFICULTIES[5].fixed_increase = -AutomaticLevelScaling.getScaledLevel

      highest_level = 0
      $player.party.each { |pokemon|
        highest_level = pokemon.level if pokemon.level > highest_level
      }
      LevelScalingSettings::DIFFICULTIES[5].random_increase = highest_level
    end

    avarage_level = 0
    trainer.party.each { |pokemon| avarage_level += pokemon.level }
    avarage_level /= trainer.party.length

    for pokemon in trainer.party do
      AutomaticLevelScaling.setNewLevel(pokemon, pokemon.level - avarage_level)
    end
  }
)
Just add the highlighted lines to the function in your script version. As for the setting in the 002_Settings.rb, you can leave it in any way you want, because its values are overwritten before each trainer battle.
 

Chadofy

Rookie
Member
Joined
Feb 26, 2024
Posts
2
Hello, thank you for the appreciation. Unfortunately, there is no easy way to make a difficulty as you described in the 002_Settings.rb file because the highest level and the scaled party level are not constant values. However, I found a way to implement this feature in the :on_trainer_load EventHandlers at the 004_Event_Handlers.rb file, here's the code snippet:
Ruby:
Expand Collapse Copy
# Activates script when a trainer pokemon is created
EventHandlers.add(:on_trainer_load, :automatic_level_scaling,
  proc { |trainer|
    id = pbGet(LevelScalingSettings::TRAINER_VARIABLE)
    next if !trainer || id == 0
    AutomaticLevelScaling.difficulty = id

    if id == 5
      LevelScalingSettings::DIFFICULTIES[5].fixed_increase = 0
      LevelScalingSettings::DIFFICULTIES[5].random_increase = 0
      LevelScalingSettings::DIFFICULTIES[5].fixed_increase = -AutomaticLevelScaling.getScaledLevel

      highest_level = 0
      $player.party.each { |pokemon|
        highest_level = pokemon.level if pokemon.level > highest_level
      }
      LevelScalingSettings::DIFFICULTIES[5].random_increase = highest_level
    end

    avarage_level = 0
    trainer.party.each { |pokemon| avarage_level += pokemon.level }
    avarage_level /= trainer.party.length

    for pokemon in trainer.party do
      AutomaticLevelScaling.setNewLevel(pokemon, pokemon.level - avarage_level)
    end
  }
)
Just add the highlighted lines to the function in your script version. As for the setting in the 002_Settings.rb, you can leave it in any way you want, because its values are overwritten before each trainer battle.
Thank you very much!

It works for Wild Pokemons as well. 🥳
 

hostman

Trainer
Member
Joined
Aug 24, 2023
Posts
70
1709047726307.png
I have another question, when creating the pokemon in this way to add the movements. It does not affect the automatic level climber. Do you know why it can be?
 

Attachments

  • 1709046928836.png
    1709046928836.png
    83.3 KB · Views: 15

Benitex

Trainer
Member
Joined
Nov 7, 2020
Posts
81
View attachment 26488I have another question, when creating the pokemon in this way to add the movements. It does not affect the automatic level climber. Do you know why it can be?
You can add AutomaticLevelScaling.setNewLevel(pkmn) (before teaching the new moves and after creating the new pokemon) to scale it according to the current settings. You could also use AutomaticLevelScaling.getScaledLevel in the level parameter (like this: Pokemon.new(:SHAYMIN, AutomaticLevelScaling.getScaledLevel)), but AutomaticLevelScaling.setNewLevel would also evolve the pokemon and apply other settings.
 

RegalSword

Pokemon Itinerant Developer
Member
Joined
Feb 13, 2021
Posts
522
Hello. The trainer side of things works fine, but when a wild encounter tries to load itself I receive this error:
Code:
Expand Collapse Copy
=================

[2024-06-30 00:00:41 -0700]
[Pokémon Essentials version 20.1]
[v20.1 Hotfixes 1.0.7]

Exception: RuntimeError
Message: No difficulty with id "[]" was provided in the DIFFICULTIES Hash of Settings.

Backtrace:
[Automatic Level Scaling] 003_Script.rb:33:in `difficulty='
[Automatic Level Scaling] 004_Event_Handlers.rb:11:in `block in <main>'
Event_Handlers:89:in `block in trigger'
Event_Handlers:89:in `each_value'
Event_Handlers:89:in `trigger'
Event_HandlerCollections:63:in `trigger'
Overworld_WildEncounters:449:in `pbGenerateWildPokemon'
Overworld_BattleStarting:412:in `block in generate_foes'
Overworld_BattleStarting:404:in `each'
Overworld_BattleStarting:404:in `generate_foes'
What could I be doing wrong?
 

Benitex

Trainer
Member
Joined
Nov 7, 2020
Posts
81
Hello. The trainer side of things works fine, but when a wild encounter tries to load itself I receive this error:
Code:
Expand Collapse Copy
=================

[2024-06-30 00:00:41 -0700]
[Pokémon Essentials version 20.1]
[v20.1 Hotfixes 1.0.7]

Exception: RuntimeError
Message: No difficulty with id "[]" was provided in the DIFFICULTIES Hash of Settings.

Backtrace:
[Automatic Level Scaling] 003_Script.rb:33:in `difficulty='
[Automatic Level Scaling] 004_Event_Handlers.rb:11:in `block in <main>'
Event_Handlers:89:in `block in trigger'
Event_Handlers:89:in `each_value'
Event_Handlers:89:in `trigger'
Event_HandlerCollections:63:in `trigger'
Overworld_WildEncounters:449:in `pbGenerateWildPokemon'
Overworld_BattleStarting:412:in `block in generate_foes'
Overworld_BattleStarting:404:in `each'
Overworld_BattleStarting:404:in `generate_foes'
What could I be doing wrong?

This error usually happens when the Wild difficulty variable (number 100 by default) is not initiated properly, or its value is changed by some other method.
In this case, I believe this variable might be used in another place in your game since its value in the error message is an array. You can use another variable by changing the WILD_VARIABLE setting in the 002_Settings.rb file.
Maybe another plugin is using this variable too, if you find out this is the case, please tell me which one it is so that I can put a warning on the overview page.
I hope this solves the issue!
 

RegalSword

Pokemon Itinerant Developer
Member
Joined
Feb 13, 2021
Posts
522
This error usually happens when the Wild difficulty variable (number 100 by default) is not initiated properly, or its value is changed by some other method.
In this case, I believe this variable might be used in another place in your game since its value in the error message is an array. You can use another variable by changing the WILD_VARIABLE setting in the 002_Settings.rb file.
Maybe another plugin is using this variable too, if you find out this is the case, please tell me which one it is so that I can put a warning on the overview page.
I hope this solves the issue!
You were right. Changing the Wild difficulty variable fixed the issue. Thanks! I wasn't able to figure out which plugin might have been causing the issue, but I'll let you know if I ever find it!
 

Benitex

Trainer
Member
Joined
Nov 7, 2020
Posts
81
Some extra details about the update and further explanation about the new settings:

- Add the save_trainer_parties setting
With this setting enabled, a scaled trainer party is saved after the first fight. I decided to add this setting because sometimes players get defeated by an opponent and decide to grind a little to become stronger and come back to battle, only to find the opponent is also stronger and to get defeated again. This setting allows players to grind a little bit and come back when they feel ready.
This setting is enabled by default but like all other settings, you can disable it in 002_Settings.rb or disable it for a single battle (maybe an important trainer like a rival or gym leader) using AutomaticLevelScaling.setSettings.

- Add the use_map_level_for_wild_pokemon setting
This is a different method to scale wild pokemon, which feels more similar to the mainline games. Instead of scaling wild pokemon every time a battle happens, the script will define a level for the whole map the first time the player enters it. All wild pokemon will be in that level (while still applying the difficulty randomness). As a consequence, there will always be lower-level pokemon in the first maps and higher-level ones the further the player goes into the game.
This setting is disabled by default. I did not include a setting for trainer pokemon because I feel like battles would become very easy with later trainers, especially in bigger maps. Please send me a message asking for it if you're interested though.

- Add class overrides, moving methods to the Pokemon class
This is a pretty big code change, I moved most of the code for scaling and evolving pokemon to the 005_Class_Overrides.rb file, overriding the Pokemon class with those methods. I think this will make the plugin easier to customize and use in other places, while also making everything more organized and following object-oriented principles better.
If you prefer using the original static methods or don't want to update all your custom scripts, the original methods will stay available.
 

ardicoozer

Cooltrainer
Member
Joined
Sep 29, 2020
Posts
180
Hello! What exactly do you want to add to the the options menu? Difficulties? Please give me some more details so I can help you set it up.
Yeah, I want to set difficult plugins like a Screen Size works in Option menu, but I don't know how to set it up.
 

Benitex

Trainer
Member
Joined
Nov 7, 2020
Posts
81
Yeah, I want to set difficult plugins like a Screen Size works in Option menu, but I don't know how to set it up.
You can change the options menu in the file 015_UI_Options.rb, in the 016_UI folder. You could add this feature in some different ways. I'll tell you a simple one, but with the downside of not being able to change the difficulty if you're accessing the options menu from the load menu. A more elaborate option would require some extra changes to the way the plugin reads the selected difficulty, which could be hard depending on your coding knowledge. Let me show you the simple way:

At the PokemonSystem class, add an attr_accessor to represent the setting, for example, difficulty. Then, in the initialize method, initialize the attribute according to the difficulties I explain below. In the end, the class might look like this:
Ruby:
Expand Collapse Copy
class PokemonSystem
  attr_accessor :textspeed
  attr_accessor :battlescene
  attr_accessor :battlestyle
  attr_accessor :sendtoboxes
  attr_accessor :givenicknames
  attr_accessor :frame
  attr_accessor :textskin
  attr_accessor :screensize
  attr_accessor :language
  attr_accessor :runstyle
  attr_accessor :bgmvolume
  attr_accessor :sevolume
  attr_accessor :textinput
  attr_accessor :difficulty

  def initialize
    @textspeed     = 1     # Text speed (0=slow, 1=medium, 2=fast, 3=instant)
    @battlescene   = 0     # Battle effects (animations) (0=on, 1=off)
    @battlestyle   = 0     # Battle style (0=switch, 1=set)
    @sendtoboxes   = 0     # Send to Boxes (0=manual, 1=automatic)
    @givenicknames = 0     # Give nicknames (0=give, 1=don't give)
    @frame         = 0     # Default window frame (see also Settings::MENU_WINDOWSKINS)
    @textskin      = 0     # Speech frame
    @screensize    = (Settings::SCREEN_SCALE * 2).floor - 1   # 0=half size, 1=full size, 2=full-and-a-half size, 3=double size
    @language      = 0     # Language (see also Settings::LANGUAGES in script PokemonSystem)
    @runstyle      = 0     # Default movement speed (0=walk, 1=run)
    @bgmvolume     = 80    # Volume of background music and ME
    @sevolume      = 100   # Volume of sound effects
    @textinput     = 0     # Text input mode (0=cursor, 1=keyboard)
    @difficulty    = 0     # Automatic Level Scaling difficulty id
  end
end

Then, you also need to add a new MenuHandlers, you can add one in the same file, and see some other examples. I'll show an example, but you should change it according to your game:
Ruby:
Expand Collapse Copy
MenuHandlers.add(:options_menu, :difficulty, {
  "name"        => _INTL("Difficulty"),
  "order"       => 130,
  "type"        => EnumOption,
  "parameters"  => [_INTL("Easy"), _INTL("Medium"), _INTL("Hard")],
  "description" => _INTL("Choose the difficulty."),
  "get_proc"    => proc { next $PokemonSystem.difficulty },
  "set_proc"    => proc { |value, _scene|
    next if $game_variables.nil?
    $PokemonSystem.difficulty = value
    case value
    when 0
      pbSet(LevelScalingSettings::TRAINER_VARIABLE, 1)
      pbSet(LevelScalingSettings::WILD_VARIABLE, 1)
    when 1
      pbSet(LevelScalingSettings::TRAINER_VARIABLE, 2)
      pbSet(LevelScalingSettings::WILD_VARIABLE, 2)
    when 2
      pbSet(LevelScalingSettings::TRAINER_VARIABLE, 3)
      pbSet(LevelScalingSettings::WILD_VARIABLE, 3)
    end
  }
})
In this code, 0 Is the Easy, 1 is Medium, etc. This is also the values you use to initialize the difficulty in the initialize method. You can add or remove difficulties if you prefer. The important part is changing the pbSet calls according to the difficulty ID from the DIFFICULTIES hash at the 002_Settings.rb file. Keep in mind: In this setup, changing only the number in PokemonSystem.difficulty will not change the difficulty by itself.

This is all necessary for the option to be added, but it will cause bugs if changed from the load menu, as I said. So, I recommend disabling the options menu from the load screen, by commenting some lines in the 013_UI_Load.rb file (adding a # at the beginning of the line). Line 285: # cmd_options = -1, and 298: # commands[cmd_options = commands.length] = _INTL("Options"). I'd be happy to help you if you have any other questions.
 
Back
Top