• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Tool] Trouble with Jpan's hacked tool

82
Posts
6
Years
Hello all, as the title says i am having trouble with this tool. I am trying to add dynamic trainer levels. Some one told me i can use the tool on a regular rom instead of jpans patched rom. I am doing this so i dont have to rebuild the entire game from scratch. The documentation says:

"0x0yy -> nothing, default setting
0x1yy -> gets the highest leveled pokémon in the party and sets all trainers
pokémon/wild pokémon levels to that value."

If i type "0x1yy' i get an invalid box
If i type "0x100" the prompt disappears and reappears on a different area of my screen but its the same prompt. I can type 0x100 several times and nothing happens.
If i type "0x4100" it works! kind of.

Take this line for example:
"0xfyy -> Sets the pokémon level to yy"
If i type "0xf22" for level 22, nothing happens
if i type into the prompt "0x4f22" the squirtles(rivals beginning pokemon in oaks lab) is level 57 ._.
if i type "0x5f22" my rivals mon level is 5 .-.

How do i use this tool or specifically this box? I am so lost. Any help would be appreciated.
 
146
Posts
11
Years
  • CO
  • Seen Mar 16, 2023
Hello all, as the title says i am having trouble with this tool. I am trying to add dynamic trainer levels. Some one told me i can use the tool on a regular rom instead of jpans patched rom. I am doing this so i dont have to rebuild the entire game from scratch. The documentation says:

"0x0yy -> nothing, default setting
0x1yy -> gets the highest leveled pokémon in the party and sets all trainers
pokémon/wild pokémon levels to that value."

If i type "0x1yy' i get an invalid box
If i type "0x100" the prompt disappears and reappears on a different area of my screen but its the same prompt. I can type 0x100 several times and nothing happens.
If i type "0x4100" it works! kind of.

Take this line for example:
"0xfyy -> Sets the pokémon level to yy"
If i type "0xf22" for level 22, nothing happens
if i type into the prompt "0x4f22" the squirtles(rivals beginning pokemon in oaks lab) is level 57 ._.
if i type "0x5f22" my rivals mon level is 5 .-.

How do i use this tool or specifically this box? I am so lost. Any help would be appreciated.



What page in the documentation are you speaking of if I may ask?
I might be able to help you then as I can't find any reference to "dynamic trainer levels" in the documentation.


Edit:
Oh I know what you are talking about.
The Change Battled Pokémon Level on page 31 of the documentation...
Change Battled Pokémon Level

This command is one useful command. Basically, it allows you to choose the level of the pokémon you're about to encounter to your liking.
Never found it annoying when wild pokémon around you are always 20 levels below your main pokémon? Never got into the situation that was the best place to train? Want to present constant challenge to your player?
Well, this code is just for you. Mind it, there are two different ones:

One code is set by the content of variable 0x4051. That is the Wild Pokémon Level Switch.
The other is set by the contents of variable 0x4052. That is the Trainer Battle Level Switch.

I kept those two apart because I can see situations where you want the trainers to have a standing point, but also one where all you want is a level difference, something of the like "Trainers are at your level, Gym trainers are one or two above, Gym leaders are five above and the Elite Four is at least seven levels above your strongest pokémon"

How do they work (for you)? Simply set the variable to one of these combinations and you're good to go. Reason I placed these in variables it's because I see how these can be used as a "Difficulty Level" that should be maintained stable throughout the game, even after the game is saved and later resumed from that save.

0x0yy --> nothing, default setting
0x1yy --> gets the highest leveled pokémon in the party and sets all trainers pokémon/wild pokémon levels to that value.
0x2yy --> gets the highest leveled pokémon in the party and sets all trainers pokémon/wild pokémon levels to that value plus yy.
0x3yy --> gets the highest leveled pokémon in the party and sets all trainers pokémon/wild pokémon levels to that value minus yy.
0x4yy --> gets the lowest leveled pokémon in the party and sets all trainers pokémon/wild pokémon levels to that value.
0x5yy --> gets the lowest leveled pokémon in the party and sets all trainers pokémon/wild pokémon levels to that value plus yy.
0x6yy --> gets the lowest leveled pokémon in the party and sets all trainers pokémon/wild pokémon levels to that value minus yy.
0x7yy --> adds up all the pokémon levels in your party, makes a weighted average and sets all trainers pokémon/wild pokémon levels to that value.
0x8yy --> adds up all the pokémon levels in your party, makes a weighted average and sets all trainers pokémon/wild pokémon levels to that value plus yy.
0x9yy --> adds up all the pokémon levels in your party, makes a weighted average and sets all trainers pokémon/wild pokémon levels to that value minus yy.
0xfyy --> Sets the pokémon level to yy.

Also, the Wild variable accepts these settings:
0xayy --> calculates a random number between highest and lowest party level, and makes that the pokémon level.
0xbyy --> calculates a random number between highest - yy and highest + yy , and makes that the pokémon level.
0xcyy --> calculates a random number between lowest - yy and lowest + yy, and makes that the pokémon level.
0xdyy --> calculates a random number between average - yy and average + yy, and makes that the pokémon level.

The reason these last modes don't appear on the Trainer level hack is because, not only the idea of randomly-leveled trainers seems a bit off, the Randomization routine is part of the Wild Pokémon Level routine that Nintendo made, and it seemed pointless at the time.

The 'yy' represents the number you chose from 0x1-0x64 (in decimal 1-100).
Just set the the vars accordingly.

If you need any more help just PM me.
 
Last edited:

DrFuji

[I]Heiki Hecchara‌‌[/I]
1,691
Posts
14
Years
Hello all, as the title says i am having trouble with this tool. I am trying to add dynamic trainer levels. Some one told me i can use the tool on a regular rom instead of jpans patched rom. I am doing this so i dont have to rebuild the entire game from scratch. The documentation says:

"0x0yy -> nothing, default setting
0x1yy -> gets the highest leveled pokémon in the party and sets all trainers
pokémon/wild pokémon levels to that value."

The part of the documentation that you're reading about is relating to how you would write the script, not how you would insert the routine. The document is assuming that you're using the patch rather than the tool and is therefore explaining how you can use the changes in-game.

If i type "0x1yy' i get an invalid box
If i type "0x100" the prompt disappears and reappears on a different area of my screen but its the same prompt. I can type 0x100 several times and nothing happens.
If i type "0x4100" it works! kind of.

0x1YY isn't a variable and 0x100 isn't recognised by the program as it would be writing to a protected part of the RAM. 0x4100 might be accepted by the program but shouldn't be used as it overwrites data in the RAM. I'm not sure if JPAN was aware of this when he made the tool all those years ago otherwise I'm sure he would have blocked that variable from being accepted as well. This thread details which variables should and shouldn't be used.

Take this line for example:
"0xfyy -> Sets the pokémon level to yy"
If i type "0xf22" for level 22, nothing happens
if i type into the prompt "0x4f22" the squirtles(rivals beginning pokemon in oaks lab) is level 57 ._.
if i type "0x5f22" my rivals mon level is 5 .-.

How do i use this tool or specifically this box? I am so lost. Any help would be appreciated.

Its probably easiest to just use the variables (0x4052 and 0x4053) that were used in the patch so there is no confusion and if you ever forget which ones you were using you only need to read the document. They do have minor uses in game so just read the thread I linked earlier and decide if you want to use different ones. For the rest of this post I'll just assume that you're using the two default ones. Anyway, just write '0x4052' into the box (Including the '0x' part) and then '0x4053' when the second box appears. It should have different instructions so you know you're doing it correctly. A third box will then pop-up saying that you've inserted the routine.

Now that you've done that its time to get to scripting. Open up XSE (Or your editor of choice) and start writing a new script. For example, if I want a trainer battle where all of their Pokemon are exactly 25 levels higher than my strongest one I would write:

Code:
#dynamic 0x800000

#org @start
setvar 0x4053 0x219
trainerbattle 0x0 0x65 0x0 @before @after
msgbox @later 0x2
release
end

#org @before
= ?

#org @after
= !

#org @later
= [...]

Notice that I set the variable 0x4053 to 0x19 rather than 0x25. This is because the number is in HEX notation, rather than decimal. XSE has a nifty calculator that can quickly and easily translate between the two systems. To disable the system just set variable 0x4053's value to anything between 0x0 and 0xFF, otherwise every trainer in the game will have their levels altered by it from that battle onwards.
 
Last edited:
82
Posts
6
Years
First off, thank you both for the replies! I appreciate you two explaining this info to me! I have successfully changed the level of a trainers pokemon but i am having several other problems. Fyi, jpans doc says 0x4052 for trainers. Not trying to correct, just saving time from you asking why i chose 0x4052

Lets start with my rom. I initially tried changing trainer 0xB6 or the first trainer you encounter on route 25 heading towards garys. I was able to get his pokemon to change level but i noticed 2 bugs. The first bug is i would step in view of him and he wouldnt battle me. I would have to talk to him to initiate battle. The second bug, which happen only 2 times, is he would notice me(get the ! over his head) and when the battle would initiate, the game would crash. I received an error saying "Game jumped to 1c101c10". First spoiler is the games script while the second is the modified script.

Spoiler:


Spoiler:


I then tried a clean rom and changed the rival battle. I used var 0x4052 and set it to 0x219 so squirtle would be level 30. It worked but after the battle the game would soft lock. Here is the script for rival. I noticed 2 things. First, the unchanged script is 316 lines of code while the updated script is only 228 but it should be 319(set var 3 times because of the 3 different possible battles). The next thing i noticed is after "trainerbattle" the "goto" changed from "81693AC" to "12121212" which i dont understand why. The spoilers below contain the scripts. The first spoiler is the games script while the second is the modified version.

Spoiler:


Spoiler:


What am i doing wrong? I even looked up setting vars. Seems pretty straight forward? I go above "trainerbattle" in XSE, click enter to open a new line, add "setvar 0x4052 0x219" and then click compile. When i click the X to exit xse it asks to save the script, i click no because im not trying to save the script outside the game. When i reload xse and the script, i see the new complied code. I believe i am doing this correct?
 

DrFuji

[I]Heiki Hecchara‌‌[/I]
1,691
Posts
14
Years
First off, thank you both for the replies! I appreciate you two explaining this info to me! I have successfully changed the level of a trainers pokemon but i am having several other problems. Fyi, jpans doc says 0x4052 for trainers. Not trying to correct, just saving time from you asking why i chose 0x4052

Whoops, I have no idea how I added one to both of the variables. Sorry about that :P

Lets start with my rom. I initially tried changing trainer 0xB6 or the first trainer you encounter on route 25 heading towards garys. I was able to get his pokemon to change level but i noticed 2 bugs. The first bug is i would step in view of him and he wouldnt battle me. I would have to talk to him to initiate battle. The second bug, which happen only 2 times, is he would notice me(get the ! over his head) and when the battle would initiate, the game would crash. I received an error saying "Game jumped to 1c101c10". First spoiler is the games script while the second is the modified script.

Spoiler:


Spoiler:


I then tried a clean rom and changed the rival battle. I used var 0x4052 and set it to 0x219 so squirtle would be level 30. It worked but after the battle the game would soft lock. Here is the script for rival. I noticed 2 things. First, the unchanged script is 316 lines of code while the updated script is only 228 but it should be 319(set var 3 times because of the 3 different possible battles). The next thing i noticed is after "trainerbattle" the "goto" changed from "81693AC" to "12121212" which i dont understand why. The spoilers below contain the scripts. The first spoiler is the games script while the second is the modified version.

Spoiler:


Spoiler:


What am i doing wrong? I even looked up setting vars. Seems pretty straight forward? I go above "trainerbattle" in XSE, click enter to open a new line, add "setvar 0x4052 0x219" and then click compile. When i click the X to exit xse it asks to save the script, i click no because im not trying to save the script outside the game. When i reload xse and the script, i see the new complied code. I believe i am doing this correct?

The reason you're getting these errors and weird overflow values is because you're not repointing your scripts. The '#org 0xYYYYYY' (Y = pointer) directive in XSE tells the tool 'Place this part of the script here', but it is not flexible or dynamic - It will always place that part of the script at that address. You've lengthened segments of your script but haven't accounted for that increase so later parts of the script will overwrite earlier parts and start writing junk code.

In order to repoint you scripts you need to use the #org directive differently. By writing '#org @texthere' you're making what we call a dynamic pointer which will search for the next instance of free space from what you specify in the '#dynamic' directive. Most FR hackers use #dynamic 0x800000 or #dynamic 0x720000 as that's where the greatest amount of free space appears in the ROM. Here's how I would rewrite the first script you posted to work with the extra line you inserted, changes in red:

Code:
[COLOR="red"]#dynamic 0x800000[/COLOR] // Tell the game to start searching for free space from this pointer

#org [COLOR="red"]@start[/COLOR] // This segment of the script will be inserted at the first instance of free space from #dynamic onwards
[COLOR="Red"]setvar 0x4052 0x19[/COLOR] // Trainer level changer
trainerbattle 0x0 0xB6 0x0 0x81893A7 0x81893EA
special2 LASTRESULT 0x39
compare LASTRESULT 0x1
if 0x1 goto 0x81A98C8
msgbox 0x81893FB MSG_NORMAL '"Drat!\nA ZUBAT bit me back in that..."
end

#org 0x1A98C8
trainerbattle 0x5 0xB6 0x0 0x81C353B 0x81893EA
msgbox 0x81893FB MSG_NORMAL '"Drat!\nA ZUBAT bit me back in that..."
end

#org 0x1893A7
= I just got down from MT. MOON,\nbut I've still got gas in the tank!

#org 0x1893EA
= You worked hard!

#org 0x1893FB
= Drat!\nA ZUBAT bit me back in that cave.

#org 0x1C353B
= I just trained up on MT. MOON,\nbut I've still got gas in the tank!

Since the first part of the script (what was previously inserted at 0x1A98A1) is the only part we're lengthening then its the only part that we need to repoint. That's why the other pointers to text and the re-battle can continue using the static pointers.

However, I neglected to mention in my last reply that you won't be able to use the setvar command on trainers that can see you from a distance and it seems like you described an instance of this happening at the start of your post. Trainers that spot you need to have the trainerbattle command as the first command in their scripts, otherwise they break and won't see you - You can still talk to them though. Although its not as clean as it could possibly be, you can circumvent this by setting 0x4052 to the value you want on a green script tile or level script before the player encounters the trainer. I'd say that the level script route is probably the easiest of the two but you may prefer to use the green S tile based on your level of experience. The hiker you were using to test the level change is this type of trainer so you will have to change the variable in a separate script before you battle him. That makes the script I rewrote above break the game but it was designed to show how you to repoint segments of scripts so just don't insert it into your hack I guess. Re-pointing will work for the Gary battle as he doesn't 'see' you - Its part of a green S tile script :P
 
82
Posts
6
Years
Thank you again for all the info! You have been very helpful! :)

I have finally got it working properly! Still learning the in's and out's. Working on it literally right now. I noticed whenever var 4051 or 4052 are used normally in the game, it resets the vars. For example, i have oaks first script (you walking into route 1 without a pokemon) set 4051 for the wild pokemon. After you turn in his parcel from the market, a script sets 4051 to 0x1 and then the wild pokemon revert back to their normal level.

Im thinking i can circumvent this in 2 ways. I can look for a clean, unused variable for the wild and trainer pokemon or i can set in the level script...every level script... to set each variable. The former seems the easiest.

I also noticed setting the var before the trainer crashes the game but setting it after works perfectly for following trainers.

Edit: Used vars 40FF and 40FE with success so far
 
Last edited:
146
Posts
11
Years
  • CO
  • Seen Mar 16, 2023
Thank you again for all the info! You have been very helpful! :)

I have finally got it working properly! Still learning the in's and out's. Working on it literally right now. I noticed whenever var 4051 or 4052 are used normally in the game, it resets the vars. For example, i have oaks first script (you walking into route 1 without a pokemon) set 4051 for the wild pokemon. After you turn in his parcel from the market, a script sets 4051 to 0x1 and then the wild pokemon revert back to their normal level.

Im thinking i can circumvent this in 2 ways. I can look for a clean, unused variable for the wild and trainer pokemon or i can set in the level script...every level script... to set each variable. The former seems the easiest.

I also noticed setting the var before the trainer crashes the game but setting it after works perfectly for following trainers.

Edit: Used vars 40FF and 40FE with success so far


Yes vars 0x40FE and 0x40FF are rather safe but if you really want safe vars and flags.
Check this thread out

Also if you do use it make sure to disable the help menu as it might cause some problems.

Edit:
You will also need Jpan's saveblock patch
 
Last edited:
82
Posts
6
Years
Yes vars 0x40FE and 0x40FF are rather safe but if you really want safe vars and flags.
Check this thread out

Also if you do use it make sure to disable the help menu as it might cause some problems.

Edit:
You will also need Jpan's saveblock patch

Is there a way to go into the routine and change the set vars or do I need to go to a back up? I ask because I've already done quite a few things with the vars. I can change it easily in the scripts but I'm not sure about the routine.

Why do I need the save block patch?
 
146
Posts
11
Years
  • CO
  • Seen Mar 16, 2023
Is there a way to go into the routine and change the set vars or do I need to go to a back up? I ask because I've already done quite a few things with the vars. I can change it easily in the scripts but I'm not sure about the routine.

Why do I need the save block patch?


Did you follow the tutorial for the Expansion of vars and flags?
And you only need the saveblock patch if you use the var and flag expansion.
 
Back
Top