hirokimura

Miltank's Fanboy Number One

Age 25
Male
France
Seen 1 Week Ago
Posted 1 Week Ago
136 posts
2.7 Years
This script will allow you to use switch to determine level capacity for pokemons without making them disobedient. Once the switch is activated, the player's pokemon wont gain any experience if they're above the specified level. You can put the wanted level depending on what you want to do with this.

First I have to say thank you to Mamba in Pokecommunity who helped in a thread and gave me what I needed to make this work please check credits.
Second, I have to thanks MGriffin who helped a lot by suggesting another way to make it work !

So there will be two versions, for two slightly different purposes :

First version using switchs with defined level capacitys. That's useful for example if like me you have a specific building in which your player can farm experience but you don't want him to train too hard. You can gradually unlock the level cap in the specific building while letting the remaining level available for him to train low level pokemons.
To use the switch version, do the following.
Spoiler:

Use Ctrl + Maj + F looking for "# Now calculate EXP for the participants " and just after this :
if haveexpall
showmessage=true
Paste this :

#Disable Experience message depending on level
if $game_switches[252]==true
showmessage=false
end
if $game_switches[253]==true
showmessage=false
end
if $game_switches[254]==true
showmessage=false
end
if $game_switches[255]==true
showmessage=false
end
This will disable the "Gardevoir gains 5000XP" message after making a foe faints.
Note : You can change the switches numbers, and you can remove or add any switch you want. Just keep in mind each switch function start with the "If" and ends with "end" if you're cutting one.

Then, look for "growthrate=thispoke.growthrate " and after this :
newexp=PBExperience.pbAddExperience(thispoke.exp,exp,growthrate)
exp=newexp-thispoke.exp
Paste this :

#Disable Exp Gain depending on level
if $game_switches[252]==true && thispoke.level>9
exp=0
end
if $game_switches[253]==true && thispoke.level>19
exp=0
end
if $game_switches[254]==true && thispoke.level>29
exp=0
end
if $game_switches[255]==true && thispoke.level>39
exp=0
end
#--------------------------------------------------
This way, if switch 252 is ON and your battler is above level 9 (so 10 or higher) it wont gain any exp by battling. As above, you can add or modify any switch to scale your level capacity as you like. Just edit the level or add another switch. You can name them whatever you want, but if you add a switch in the list, make sure to both disable the experience gain message and the experience gained. So you need to copy, paste and edit two things.

If you're using it in a training building like me, you'll have to event it like this :

-> Ask the player to choose a level cap using a conditional branch. Depending on the choice, you'll activate the needed switch.
-> In each trainer event, you'll need one page for each level the player can train on. For example if you have level 10,20,30,40 you'll need 4 pages with the same trainer, but changing the switch condition for it to appear with the switch you created. Then you have to edit the trainer itself and match his team with the level capacity.
-> At the end of the training room, in the event that will teleport the player back to the main room, add an event that turn every level cap switches off.

Bonus: If you want your NPC trainers to reset themselves after the player leaves the room, instead on turning on their self switch, put this :
setTempSwitchOn("A")
In a script and use switch 21 "s:tsOn?("A") to make it unable to battle again. That will reset the self switch when the player is gonna leave the room and he will be able to battle them again if he returns.


Now for the second method. It's using a variable you can customize as you like during the whole game. It's better used to easily determine a level capacity that will evolve with plot checkpoints such as badges, as it will take only 1 variable and 1 switch to control your whole game.

Spoiler:

Again, Use Ctrl + Maj + F looking for "# Now calculate EXP for the participants " and just after this :
if haveexpall
showmessage=true
But this time, Paste this :

if $game_switches[268]==true && thispoke.level>$game_variables[262]
showmessage=false
end
It's the same process as mentionned above. You define a switch (268 in the example, which you can change to a free switch you have) and if the switch is activated and the pokemon level is above the number contained in the variable (You can change the variable's number by anything you want as well), the experience message won't be displayed.
Now look for "growthrate=thispoke.growthrate " and after this :
newexp=PBExperience.pbAddExperience(thispoke.exp,exp,growthrate)
exp=newexp-thispoke.exp
Paste this :

if $game_switches[268]==true && thispoke.level>$game_variables[262]
exp=0
end
Same customizations available as above, but this time it's for avoiding the experience gained.
Once you pasted that, you'll follow those steps:

- When your game start, you have to activate the switch through an event, and add a value to the variable through an event as well.
- At each plot checkpoint, you have to modify the variable's value by an event. For example if it changes with the badge, don't forget to change the value of the variable in the same event in which the player is receiving the badge.


Hope it will help !

No need to credit me, however please credit Mamba since he helped me with his help in this thread https://www.pokecommunity.com/showpost.php?p=9962175&postcount=16, and Mgriffin who helped me developing the second version who is the more handful and clean for general usage.

mgriffin

Seen 3 Hours Ago
Posted 1 Day Ago
1,326 posts
6.5 Years
This is neat! Can I recommend looking into using a variable to control the maximum level that is allowed to gain exp? I think it would be a little more elegant than having a bunch of variables.

hirokimura

Miltank's Fanboy Number One

Age 25
Male
France
Seen 1 Week Ago
Posted 1 Week Ago
136 posts
2.7 Years
Well, you can do it by using only 1 switch. I put many switches in there because I have a building dedicated to training in which I gradually unlock levels that can train in it, so you just have to put one switch if you want only 1 value, unless I'm mistaken with what you want ^^

mgriffin

Seen 3 Hours Ago
Posted 1 Day Ago
1,326 posts
6.5 Years
I mean having something along these lines:
#Disable Exp Gain depending on level
if thispoke.level>$game_variables[xxx]
  exp=0
end
#--------------------------------------------------
You only need to have a single variable where you needed multiple switches, because you can put a number into a variable. You could gradually unlock levels by simply assigning a new maximum level to the variable.

hirokimura

Miltank's Fanboy Number One

Age 25
Male
France
Seen 1 Week Ago
Posted 1 Week Ago
136 posts
2.7 Years
That's true indeed ! I didn't think about it because I need the player to be able to train pokemon with limits 10 per 10 to be able to train low level as well, but it would indeed be easier to implement this ! I'll add this tomorrow as it's midnight now xD
Thanks for the tip, I appreciate it :)

mgriffin

Seen 3 Hours Ago
Posted 1 Day Ago
1,326 posts
6.5 Years
Updated version of the script including the variable method ! I kept the first method as well for specific uses, but I clearly stated when it is optimal to use it ! I put credits to you Mgriffin, thank you for the pointer !
It looks great! Don't worry about crediting me, I'm just happy to see others doing cool things! :)