• 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?".
  • 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.

[Script] Scripting Trainer Pokemon to be shiny

157
Posts
7
Years
  • Age 26
  • Seen Nov 19, 2023
Just wondering if anyone knew how to script one of a trainers pokemon to be shiny, any and all help would be appreciated.
 
32
Posts
6
Years
  • Age 34
  • Seen Jan 16, 2024
I don't know, but if you check Avara's rom hack, he has a trainer with shiny pokemon in it. I think his name was eli?

You should study those scripts in advancemap and then move from there.
 
Last edited:
157
Posts
7
Years
  • Age 26
  • Seen Nov 19, 2023
Thanks for your help, I really appreciate it man. I hadn't seen that tool before.
 
157
Posts
7
Years
  • Age 26
  • Seen Nov 19, 2023
If you're hacking the third gen, you can use HackMew's Shinyizer as it's pretty simple to get working. Don't forget to read this post to learn how to use it properly.

Just wondering if i could get some further help. I have read the tutorial but have no clue where I should be inserting that code. the shinyizer tool on has a spot for a hex code an nothing else, is there something simple I'm missing here?
 

DrFuji

[I]Heiki Hecchara‌‌[/I]
1,691
Posts
14
Years
Just wondering if i could get some further help. I have read the tutorial but have no clue where I should be inserting that code. the shinyizer tool on has a spot for a hex code an nothing else, is there something simple I'm missing here?

There's no one place you must insert the routine, you just need to put it somewhere where there is enough free space. You can use HackMew's free space finder (which you can get from the link I posted earlier in the thread) to quickly find somewhere to insert it. Open up FSF and write the starting offset of your ROM's free space - I don't know R/S/E's offsets off the top of my head, but for FR this is 0x720000. You need 144 bytes of free space but since the tool defaults to searching for 256 bytes you don't need to alter that window. Click the find button and copy the resulting offset that is given to you. Paste it into the Shinizer window and click shinyize. It should now be working in game.

Don't forget to make a backup of your ROM before you start using tools you're unfamiliar with just in case something terrible happens.
 
Last edited:
157
Posts
7
Years
  • Age 26
  • Seen Nov 19, 2023
There's no one place you must insert the routine, you just need to put it somewhere where there is enough free space. You can use HackMew's free space finder (which you can get from the link I posted earlier in the thread) to quickly find somewhere to insert it. Open up FSF and write the starting offset of your ROM's free space - I don't know R/S/E's offsets off the top of my head, but for FR this is 0x720000. You need 144 bytes of free space but since the tool defaults to searching for 256 bytes you don't need to alter that window. Click the find button and copy the resulting offset that is given to you. Paste it into the Shinizer window and click shinyize. It should now be working in game.

Don't forget to make a backup of your ROM before you start using tools you're unfamiliar with just in case something terrible happens.

But I dont understand what that specifically would do, nowhere in the description do I paste the offset of the specific trainer who's pokemon I am trying to make shiny. I appreciate your patience but i've been super confused, thanks man
 

DrFuji

[I]Heiki Hecchara‌‌[/I]
1,691
Posts
14
Years
But I dont understand what that specifically would do, nowhere in the description do I paste the offset of the specific trainer who's pokemon I am trying to make shiny. I appreciate your patience but i've been super confused, thanks man

The part that I described in my last post is just setting the groundwork for events in game. Once you insert the routine using the Shinyizer you need to activate it in game via scripting. Open up XSE (or your script editor of choice) and then follow the instructions in HackMew's explanation. Here's an example of a script you can use to make a trainer battle when the trainer has three Pokemon and their first Pokemon is shiny:

Code:
#dynamic 0x800000

#org @start
setvar 0x8003 0x0403
trainerbattle 0x0 0x5B 0x0 @before @after
msgbox @later 0x2
release
end

#org @before
= ?

#org @after
= !

#org @later
= [...]

Here's a table I whipped up to better illustrate the number you need to set the first half of variable 0x8003, indicating which of the trainer's Pokemon you want to be shiny.

JMwCqWW.png


To use it, choose the row that corresponds to how many Pokemon the trainer has. Move from left to right and write down the numbers in the columns that correspond to which spot in the party you want to be shiny. Add up all of the numbers you wrote down and then convert it to hexadecimal. XSE has a nifty calculator that can freely convert between hexadecimal and decimal notation. Following the example in HackMew's tutorial, here's the spaces that I would add up if I wanted a trainer with five Pokemon whose second and third Pokemon were shiny:

oTBs0Rz.png


From there I would add 8 and 4, equalling 12. When I convert the number 12 into HEX I am given the number 0xC which is what HackMew came to in the tutorial. Add the trainer's number of Pokemon to the second half of the variable and you should be all good in game.
 
157
Posts
7
Years
  • Age 26
  • Seen Nov 19, 2023
The part that I described in my last post is just setting the groundwork for events in game. Once you insert the routine using the Shinyizer you need to activate it in game via scripting. Open up XSE (or your script editor of choice) and then follow the instructions in HackMew's explanation. Here's an example of a script you can use to make a trainer battle when the trainer has three Pokemon and their first Pokemon is shiny:

Code:
#dynamic 0x800000

#org @start
setvar 0x8003 0x0403
trainerbattle 0x0 0x5B 0x0 @before @after
msgbox @later 0x2
release
end

#org @before
= ?

#org @after
= !

#org @later
= [...]

Here's a table I whipped up to better illustrate the number you need to set the first half of variable 0x8003, indicating which of the trainer's Pokemon you want to be shiny.

JMwCqWW.png


To use it, choose the row that corresponds to how many Pokemon the trainer has. Move from left to right and write down the numbers in the columns that correspond to which spot in the party you want to be shiny. Add up all of the numbers you wrote down and then convert it to hexadecimal. XSE has a nifty calculator that can freely convert between hexadecimal and decimal notation. Following the example in HackMew's tutorial, here's the spaces that I would add up if I wanted a trainer with five Pokemon whose second and third Pokemon were shiny:

oTBs0Rz.png


From there I would add 8 and 4, equalling 12. When I convert the number 12 into HEX I am given the number 0xC which is what HackMew came to in the tutorial. Add the trainer's number of Pokemon to the second half of the variable and you should be all good in game.

Thanks for the response, unfortunately, I still cant seem to get it working. Here is my script for youngster Allen on route 102 in Emerald, Im trying to make only his first of 2 pokemon shiny. Not only are the pokemon not shiny, but the trainer battle is now a double battle from latter in the game. Notice anything wrong with it?
Spoiler:
 
Last edited:

DrFuji

[I]Heiki Hecchara‌‌[/I]
1,691
Posts
14
Years
Thanks for the response, unfortunately, I still cant seem to get it working. Here is my script for youngster Allen on route 102 in Emerald, Im trying to make only his first of 2 pokemon shiny. Not only are the pokemon not shiny, but the trainer battle is now a double battle from latter in the game. Notice anything wrong with it?
Spoiler:

I see that you're using the same offsets as the game uses, indicating that you didn't repoint the script associated with the trainer. You're adding extra information to the size of the script by adding the command 'setvar 0x8003 0x202' but not accounting for that change. This is leading to data being overwritten and corrupting the script - You should be able to see this if you reopen the script from A-Map. To properly insert a lengthened script you need to compile it somewhere where there's enough free space. Thankfully, XSE is really good at doing this. By including the pre-processing directive '#dynamic 0xYYYYYY' (where 0xYYYYYY is a pointer to where your ROM's free space begins) at the top of a script and using dynamic pointers rather than static ones like you receive when you decompile scripts. Here's your script rewritten to be dynamically inserted:

Code:
#dynamic 0xE3CF64
#freespace 0xFF

#org @start
setvar 0x8003 0x202
trainerbattle 0x0 0x14D 0x0 @before @after
msgbox @later 0x2
end

#org @before
= Did you just become a TRAINER?\nWe're both beginners!

#org @after
= I called you because I thought\nI could beat you[.]

#org @later
= I haven't won once yet[.]\nI wish I would win soon[.]

Copy the '@start' offset once you've compiled the script and give it to an event in A-Map. I've tested it and it works as intended.

If you want to know more how to insert scripts and other things like that in your Emerald ROM without corrupting it, check out this thread.
 
157
Posts
7
Years
  • Age 26
  • Seen Nov 19, 2023
No idea what I have done wrong here. Followed your script exactly and I have the exact same issues, a double battle from later in the game with no shinies.
 

DrFuji

[I]Heiki Hecchara‌‌[/I]
1,691
Posts
14
Years
No idea what I have done wrong here. Followed your script exactly and I have the exact same issues, a double battle from later in the game with no shinies.

Could you send me a patch of your game? Either post it in this thread or send me a PM (if you want to keep it private) so I can see what's going wrong.
 
157
Posts
7
Years
  • Age 26
  • Seen Nov 19, 2023
Here is the ips file. Just wanted to say regardless of whether or not I ended up getting this fixed, you have been an amazing help and I am grateful for the time you've spent trying to assist me.
 

Attachments

  • EmeraldX.ips
    23.9 KB · Views: 1

DrFuji

[I]Heiki Hecchara‌‌[/I]
1,691
Posts
14
Years
Here is the ips file. Just wanted to say regardless of whether or not I ended up getting this fixed, you have been an amazing help and I am grateful for the time you've spent trying to assist me.

Alright, I've found out what the issue was. When you have a trainer that can see you from a distance your first command in a script needs to be the trainerbattle command, otherwise the game glitches. If you load up your game and speak to the youngster from the side the battle will load correctly and his first Pokemon will be shiny. I had a feeling that this was the issue you were experiencing as I was helping another member a few days ago and we were experiencing the same problem. You essentially have two options to start shiny battle with a trainer: don't give them a view radius and untick the trainer box in A-Map or set the variable in a script before you encounter the NPC. The second option will allow you to have trainers with a view radius but will require you to use quite a few green S script tiles to ensure that the youngster is the only trainer with shiny Pokemon on that route (example). When the player gets access to Fly/ Teleport that also complicates the picture as they may be able to leave the route with variable 0x8003 left intact and encounter a trainer with unintended shiny Pokemon on another route. That would necessitate the use of level scripts in Fly locations and... It just gets really, really messy the more I think about it...

I'd definitely just keep shiny Pokemon exclusive to trainers who don't have a view radius and ones you battle in events initiated by green S script tiles like your rival on Route 110. Hopefully that sorts everything out :P

No worries, I enjoy helping people around here. I try to give as detailed an explanation as I can to remove any ambiguity and possibly help anybody else watching on the sidelines.
 
157
Posts
7
Years
  • Age 26
  • Seen Nov 19, 2023
Ahhhh that makes sense, thanks a bunch. Yeah was only trying to make that trainers pokemon shiny in a backup to test whether or not I could get it working. One final question I have is; Earlier you linked a post that discussed free space in emerald, without that patch on my rom, will I have limited amounts of free space to use for making changes?
 

DrFuji

[I]Heiki Hecchara‌‌[/I]
1,691
Posts
14
Years
Ahhhh that makes sense, thanks a bunch. Yeah was only trying to make that trainers pokemon shiny in a backup to test whether or not I could get it working. One final question I have is; Earlier you linked a post that discussed free space in emerald, without that patch on my rom, will I have limited amounts of free space to use for making changes?

I'm not an Emerald hacker so my knowledge on its free space and Emerald in general is limited, but after doing the math, according to that thread you have 0x3C92C8 bytes of free space which is just under 1/4th the size of the ROM. Its enough to work with but more is always good. It also simplifies things as you wouldn't be jumping around all over the place to get the free space dotted everywhere.
 
4
Posts
5
Years
  • Age 24
  • Seen Jun 25, 2019
Hey guys,
I'm not sure if this thread is still active but I need some help with my rom hack.
How you can make a trainer with some shiny pokemon is quite clear to me, however I am just editing existing scripts in fire red so I dont have to code in stuff like getting badges etc myself. So i was wondering how do I make a shiny in a script that looks much more difficult like this:

(Script: Lorelei pokemon Firered)

'---------------
#org 0x1625DC
lock
faceplayer
setvar 0x8004 0x9
setvar 0x8005 0x2
special 0x174
checkflag 0x4B8
if 0x1 goto 0x8162669
setvar 0x8004 0x9
setvar 0x8005 0x0
special 0x173
setvar 0x8004 0x9
setvar 0x8005 0x1
special 0x173
checkflag 0x844
if 0x0 call 0x8162641
checkflag 0x844
if 0x1 call 0x816264A
setflag 0x3
setflag 0x205
checkflag 0x844
if 0x0 call 0x8162653
checkflag 0x844
if 0x1 call 0x816265E
clearflag 0x5
goto 0x8162673

'---------------
#org 0x162669
msgbox 0x81781B0 MSG_KEEPOPEN '"You're better than I thought.\nGo ..."
release
end

'---------------
#org 0x162641
msgbox 0x8177FA4 MSG_KEEPOPEN '"Welcome to the POKéMON LEAGUE.\pI ..."
return

'---------------
#org 0x16264A
msgbox 0x8178089 MSG_KEEPOPEN '"Welcome to the POKéMON LEAGUE.\pI,..."
return

'---------------
#org 0x162653
trainerbattle 0x3 0x19A 0x0 0x8178191
return

'---------------
#org 0x16265E
trainerbattle 0x3 0x2DF 0x0 0x8178191
return

'---------------
#org 0x162673
setflag 0x4B8
call 0x81A7506
msgbox 0x81781B0 MSG_KEEPOPEN '"You're better than I thought.\nGo ..."
release
end

'---------------
#org 0x1A7506
applymovement MOVE_PLAYER 0x81A75FE
waitmovement 0x0
sound 0x8
call 0x81A7538
special 0x8E
setflag 0x4
return

'---------------
#org 0x1A7538
setmaptile 0x6 0x1 0x28E 0x1
setmaptile 0x6 0x2 0x296 0x0
return


'---------
' Strings
'---------
#org 0x1781B0
= You're better than I thought.\nGo on ahead.\pYou only got a taste of the\nPOKéMON LEAGUE's power.

#org 0x177FA4
= Welcome to the POKéMON LEAGUE.\pI am LORELEI of the ELITE FOUR.\pNo one can best me when it comes\nto icy POKéMON.\pFreezing moves are powerful.\pYour POKéMON will be at my mercy\nwhen they are frozen solid.\pHahaha!\nAre you ready?\c\h0B[Ke]À

#org 0x178089
= Welcome to the POKéMON LEAGUE.\pI, LORELEI of the ELITE FOUR,\nhave returned!\pYou know how it goes.\nNo one can best me when it comes\lto icy POKéMON.\pFreezing moves are powerful.\pYour POKéMON will be at my mercy\nwhen they are frozen solid.\pHahaha!\nAre you ready?\c\h0B[Ke]À

#org 0x178191
= [.]Things shouldn't be this way!


'-----------
' Movements
'-----------
#org 0x1A75FE
#raw 0x1C 'Delay5
#raw 0x1C 'Delay5
#raw 0xFE 'End of Movements
 
Back
Top