The wiki says a lot of things, but doesn't say how easy (or difficult, usually) it would be to do them.
It will be possible to use
pbBalancedLevel for trainer Pokémon as well as wild Pokémon, but there's a lot of things to consider (special movesets, possible underlevelled Pokémon, strangely overlevelled unevolved Pokémon, etc. etc.).
For starters, go into the script section
PokemonTrainers and find the def
pbLoadTrainer (it's right at the top). Find the following lines and change the red one:
Code:
for poke in trainer[3]
species=poke[0]
[COLOR=Red]level=pbBalancedLevel($Trainer.party)-2+rand(5)[/COLOR]
pokemon=PokeBattle_Pokemon.new(species,level,opponent)
iv=poke[2]
This should set all trainer Pokémon's levels to the weighted mean level of the player's party, plus or minus 2 for randomness.
There's plenty of scope for improving this. When defining the trainer Pokémon, instead of the level you could put a given value which is then added to, say, "pbBalancedLevel-10", so that you have some sort of control over the difficulty of each Pokémon. Alternatively, make the defined level be a minimum level only. You could make the level changing apply only to certain trainers, or only while on certain maps. With a fair amount of effort, you could evolve overlevelled Pokémon (the chance of evolving them increases the more overlevelled they are) - this would allow you to define the Pokémon as the lowest evolutions, and let the scripts take care of evolving them where necessary, which avoids the underlevelled problem. And there's many other ideas too.
You'll need to watch out for trainers that you can rebattle, since it's possible their Pokémon may
lose levels if the player changes their party. You'll also need to watch out for min-maxing, to make sure a player doesn't breeze through with one really powerful Pokémon and a stack of Level 2 Pidgeys.
Essentially, what you're doing here is letting the player influence the difficulty of the trainers, and that's open for abuse. You also need to thoroughly make sure the system works well, as I suggested in my "scope for improvement" paragraph.