The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking
Reload this Page Script Script for NPC pokemon trade?

Notices
For all updates, view the main page.

Binary ROM Hacking Need a helping hand or just want to talk about binary ROM hacks? Get comments and answers to any ROM Hacking-related problems, questions or thoughts you have here.

Ad Content
Reply
 
Thread Tools
  #1   Link to this post, but load the entire thread.  
Old November 11th, 2016 (6:37 AM).
Scarlet D.'s Avatar
Scarlet D. Scarlet D. is offline
The Eternal
 
Join Date: Dec 2015
Location: Greece
Gender: Male
Nature: Adamant
Posts: 66
Hey guys

As the title says, I need a script that will make NPC trade certain pokemon in Fire Red Rom. I tried to read the compiled script on fire red and leaf green roms but i didn't find any sense there XD

Thanks
Reply With Quote
  #2   Link to this post, but load the entire thread.  
Old November 11th, 2016 (6:47 AM).
DizzyEgg's Avatar
DizzyEgg DizzyEgg is offline
 
Join Date: Feb 2014
Location: Poland
Age: 25
Gender: Male
Nature: Quiet
Posts: 794
Quote:
Originally Posted by Aenaos View Post
Hey guys

As the title says, I need a script that will make NPC trade certain pokemon in Fire Red Rom. I tried to read the compiled script on fire red and leaf green roms but i didn't find any sense there XD

Thanks
Show me the decompiled script and tell me which part you don't understand.
__________________
Support Pokeemerald!

Pokeemerald starter pack:
Emerald Expansion
Reply With Quote
  #3   Link to this post, but load the entire thread.  
Old November 11th, 2016 (7:26 AM).
Scarlet D.'s Avatar
Scarlet D. Scarlet D. is offline
The Eternal
 
Join Date: Dec 2015
Location: Greece
Gender: Male
Nature: Adamant
Posts: 66
Quote:
Originally Posted by DizzyEgg View Post
Show me the decompiled script and tell me which part you don't understand.
ok here is the script

Code:
'---------------
#org 0x16F602
lock
faceplayer
setvar 0x8008 0x0
call 0x81A8CAD
checkflag 0x248
if 0x1 goto 0x816F674
msgbox 0x81A597B MSG_YESNO '"I'm looking for the POKéMON\n[buff..."
compare LASTRESULT 0x0
if 0x1 goto 0x816F65C
call 0x81A8CBD
compare 0x8004 0x6
if 0x4 goto 0x816F65C
call 0x81A8CC9
comparevars LASTRESULT 0x8009
if 0x5 goto 0x816F666
call 0x81A8CD9
msgbox 0x81A59DA MSG_KEEPOPEN '"Hey, thanks!"
setflag 0x248
release
end

'---------------
#org 0x1A8CAD
copyvar 0x8004 0x8008
special2 LASTRESULT 0xFC
copyvar 0x8009 LASTRESULT
return

'---------------
#org 0x16F674
msgbox 0x81A59E7 MSG_KEEPOPEN '"Isn't my old [buffer2] great?"
release
end

'---------------
#org 0x16F65C
msgbox 0x81A59B6 MSG_KEEPOPEN '"Awww!\nOh, well[.]"
release
end

'---------------
#org 0x1A8CBD
special 0x9F
waitstate
lock
faceplayer
copyvar 0x800A 0x8004
return

'---------------
#org 0x1A8CC9
copyvar 0x8005 0x800A
special2 LASTRESULT 0xFF
copyvar 0x800B LASTRESULT
return

'---------------
#org 0x16F666
bufferpokemon 0x0 0x8009
msgbox 0x81A59C6 MSG_KEEPOPEN '"What?\nThat's no [buffer1]!"
release
end

'---------------
#org 0x1A8CD9
copyvar 0x8004 0x8008
copyvar 0x8005 0x800A
special 0xFD
special 0xFE
waitstate
lock
faceplayer
return


'---------
' Strings
'---------
#org 0x1A597B
= I'm looking for the POKéMON\n[buffer1]!\pWanna trade one for my\n[buffer2]?

#org 0x1A59DA
= Hey, thanks!

#org 0x1A59E7
= Isn't my old [buffer2] great?

#org 0x1A59B6
= Awww!\nOh, well[.]

#org 0x1A59C6
= What?\nThat's no [buffer1]!
I can't see the part that i can choose which pokemon to give and which pokemon to receive, that's all
Reply With Quote
  #4   Link to this post, but load the entire thread.  
Old November 11th, 2016 (10:01 AM).
DizzyEgg's Avatar
DizzyEgg DizzyEgg is offline
 
Join Date: Feb 2014
Location: Poland
Age: 25
Gender: Male
Nature: Quiet
Posts: 794
Quote:
Originally Posted by Aenaos View Post
ok here is the script

Code:
'---------------
#org 0x16F602
lock
faceplayer
setvar 0x8008 0x0
call 0x81A8CAD
checkflag 0x248
if 0x1 goto 0x816F674
msgbox 0x81A597B MSG_YESNO '"I'm looking for the POKéMON\n[buff..."
compare LASTRESULT 0x0
if 0x1 goto 0x816F65C
call 0x81A8CBD
compare 0x8004 0x6
if 0x4 goto 0x816F65C
call 0x81A8CC9
comparevars LASTRESULT 0x8009
if 0x5 goto 0x816F666
call 0x81A8CD9
msgbox 0x81A59DA MSG_KEEPOPEN '"Hey, thanks!"
setflag 0x248
release
end

'---------------
#org 0x1A8CAD
copyvar 0x8004 0x8008
special2 LASTRESULT 0xFC
copyvar 0x8009 LASTRESULT
return

'---------------
#org 0x16F674
msgbox 0x81A59E7 MSG_KEEPOPEN '"Isn't my old [buffer2] great?"
release
end

'---------------
#org 0x16F65C
msgbox 0x81A59B6 MSG_KEEPOPEN '"Awww!\nOh, well[.]"
release
end

'---------------
#org 0x1A8CBD
special 0x9F
waitstate
lock
faceplayer
copyvar 0x800A 0x8004
return

'---------------
#org 0x1A8CC9
copyvar 0x8005 0x800A
special2 LASTRESULT 0xFF
copyvar 0x800B LASTRESULT
return

'---------------
#org 0x16F666
bufferpokemon 0x0 0x8009
msgbox 0x81A59C6 MSG_KEEPOPEN '"What?\nThat's no [buffer1]!"
release
end

'---------------
#org 0x1A8CD9
copyvar 0x8004 0x8008
copyvar 0x8005 0x800A
special 0xFD
special 0xFE
waitstate
lock
faceplayer
return


'---------
' Strings
'---------
#org 0x1A597B
= I'm looking for the POKéMON\n[buffer1]!\pWanna trade one for my\n[buffer2]?

#org 0x1A59DA
= Hey, thanks!

#org 0x1A59E7
= Isn't my old [buffer2] great?

#org 0x1A59B6
= Awww!\nOh, well[.]

#org 0x1A59C6
= What?\nThat's no [buffer1]!
I can't see the part that i can choose which pokemon to give and which pokemon to receive, that's all
The specials are what you want.
__________________
Support Pokeemerald!

Pokeemerald starter pack:
Emerald Expansion
Reply With Quote
  #5   Link to this post, but load the entire thread.  
Old November 11th, 2016 (10:40 AM).
Scarlet D.'s Avatar
Scarlet D. Scarlet D. is offline
The Eternal
 
Join Date: Dec 2015
Location: Greece
Gender: Male
Nature: Adamant
Posts: 66
Quote:
Originally Posted by DizzyEgg View Post
The specials are what you want.
Are you trying to tell me there is no actual way to choose the pokemon you want to trade with a npc a receive? for example: I want the NPC to require Mew for the trade and if i choose mew, he will give me a rattata, something like this.
Reply With Quote
  #6   Link to this post, but load the entire thread.  
Old November 11th, 2016 (11:03 AM).
DizzyEgg's Avatar
DizzyEgg DizzyEgg is offline
 
Join Date: Feb 2014
Location: Poland
Age: 25
Gender: Male
Nature: Quiet
Posts: 794
Quote:
Originally Posted by Aenaos View Post
Are you trying to tell me there is no actual way to choose the pokemon you want to trade with a npc a receive? for example: I want the NPC to require Mew for the trade and if i choose mew, he will give me a rattata, something like this.
There is a trade table that has stuff like wanted and received pokemon, OT gender, OT name, etc. Sadly I don't have the offset of it(look at quick research forums, you may find it there).
Also, there's always a way.
__________________
Support Pokeemerald!

Pokeemerald starter pack:
Emerald Expansion
Reply With Quote
  #7   Link to this post, but load the entire thread.  
Old November 11th, 2016 (12:34 PM).
Scarlet D.'s Avatar
Scarlet D. Scarlet D. is offline
The Eternal
 
Join Date: Dec 2015
Location: Greece
Gender: Male
Nature: Adamant
Posts: 66
Quote:
Originally Posted by DizzyEgg View Post
There is a trade table that has stuff like wanted and received pokemon, OT gender, OT name, etc. Sadly I don't have the offset of it(look at quick research forums, you may find it there).
Also, there's always a way.
There is always a way but my knowledge of ASM is low... I am trying to find the topic you are reffering at but I find nothing at all :(
Reply With Quote
  #8   Link to this post, but load the entire thread.  
Old November 11th, 2016 (12:43 PM).
DizzyEgg's Avatar
DizzyEgg DizzyEgg is offline
 
Join Date: Feb 2014
Location: Poland
Age: 25
Gender: Male
Nature: Quiet
Posts: 794
Quote:
Originally Posted by Aenaos View Post
There is always a way but my knowledge of ASM is low... I am trying to find the topic you are reffering at but I find nothing at all :(
It's not too late to start learning ASM. Chances are you're gonna need it a lot of times.
I'll give you a link, but make sure you search thoroughly next time https://www.pokecommunity.com/showthread.php?p=8528011#post8528011
__________________
Support Pokeemerald!

Pokeemerald starter pack:
Emerald Expansion
Reply With Quote
  #9   Link to this post, but load the entire thread.  
Old November 11th, 2016 (1:23 PM). Edited November 11th, 2016 by Scarlet D..
Scarlet D.'s Avatar
Scarlet D. Scarlet D. is offline
The Eternal
 
Join Date: Dec 2015
Location: Greece
Gender: Male
Nature: Adamant
Posts: 66
Quote:
Originally Posted by DizzyEgg View Post
It's not too late to start learning ASM. Chances are you're gonna need it a lot of times.
I'll give you a link, but make sure you search thoroughly next time https://www.pokecommunity.com/showthread.php?p=8528011#post8528011
wow dude chill, it was in 26 page of the quick research topic ( I am still new in the forum so i thought you were mentioning the whole "reasearch and developement" category, yet i couldn't find any keywords on the search.

well, you see, the project i am participating in is simple enough and I didn't need any ASM, only some simple XSE and now it is finally ending. Ye know, it's the kind of games that story and body movements have priority

ok I saw the post but i really can't understand muk :( , I can't find the 0x26CF8C or well, even when i find it in advancedmap it shows me a givegg command. 0_o
Reply With Quote
  #10   Link to this post, but load the entire thread.  
Old November 11th, 2016 (2:54 PM).
DizzyEgg's Avatar
DizzyEgg DizzyEgg is offline
 
Join Date: Feb 2014
Location: Poland
Age: 25
Gender: Male
Nature: Quiet
Posts: 794
Quote:
Originally Posted by Aenaos View Post
wow dude chill, it was in 26 page of the quick research topic ( I am still new in the forum so i thought you were mentioning the whole "reasearch and developement" category, yet i couldn't find any keywords on the search.

well, you see, the project i am participating in is simple enough and I didn't need any ASM, only some simple XSE and now it is finally ending. Ye know, it's the kind of games that story and body movements have priority

ok I saw the post but i really can't understand **** :( , I can't find the 0x26CF8C or well, even when i find it in advancedmap it shows me a givegg command. 0_o
You need to open your rom in a hex editor(download HxD) and goto that address.
__________________
Support Pokeemerald!

Pokeemerald starter pack:
Emerald Expansion
Reply With Quote
  #11   Link to this post, but load the entire thread.  
Old November 11th, 2016 (3:46 PM).
Scarlet D.'s Avatar
Scarlet D. Scarlet D. is offline
The Eternal
 
Join Date: Dec 2015
Location: Greece
Gender: Male
Nature: Adamant
Posts: 66
Quote:
Originally Posted by DizzyEgg View Post
You need to open your rom in a hex editor(download HxD) and goto that address.
great, i had it installed already but i don't know exactly how to use it. Seems like for some reason i can't find the offset 26CF8C ... how can i see the offsets between 26CF88 and 26CF90 :/



dammit... i feel such a noob when it comes for hex values
Reply With Quote
  #12   Link to this post, but load the entire thread.  
Old November 11th, 2016 (8:32 PM).
longlostsoldier's Avatar
longlostsoldier longlostsoldier is offline
 
Join Date: Oct 2013
Gender: Other
Nature: Quiet
Posts: 200
I believe there is actually a trade editor tool out there. PGE can do it, for instance. It has a lot of tools and it's much quicker than hex. As a novice you'll probably find that easier. Heck, I can edit ASM a bit and /I/ still prefer tools most of the time when given the opportunity.
__________________
Evo-Yellow: 151 Evolve Raichu Hack, uses the Yellow Disassembly. Play as girl, ride a pokemon, special/physical, dark/fairy/steel types, new pokemon, gen 2 sprites, evolve Pikachu into Raichu and have them still follow you with new Raichu emotion sprites!
Yellow Hack Tutorial
Fire Yellow - A FireRed Hack & Yellow Remake with Following Pikachu - I am not continuing this until I get a new computer where I can use the latest disassembly. My old one can only run gen I disassemblies.
Reply With Quote
  #13   Link to this post, but load the entire thread.  
Old November 12th, 2016 (6:21 AM).
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924
Quote:
Originally Posted by Aenaos View Post
great, i had it installed already but i don't know exactly how to use it. Seems like for some reason i can't find the offset 26CF8C ... how can i see the offsets between 26CF88 and 26CF90 :/



dammit... i feel such a noob when it comes for hex values
Right, so lets go through this step by step for you.

Initially, lets understand the script first:
Code:
'---------------
#org 0x16F602
lock
faceplayer
setvar 0x8008 0x0
call 0x81A8CAD
checkflag 0x248
if 0x1 goto 0x816F674
msgbox 0x81A597B MSG_YESNO '"I'm looking for the POKéMON\n[buff..."
....
I assume you are aware of what these scripting commands do. But I will explain to you how to edit this script in the way you wish.

At the start of the script, looking past the lock and faceplayer commands, var 0x8008 is set to 0 and we call another script. When you call a script, the initial location of the call is saved and the other script is executed with all the script variables and such intact. So basically it runs this other script at 0x1A8CAD to determine something and then checks a flag.

If this flag is set, then it does goto 0x816F674 - which is to the message "My old [buffer2] is great isn't it?". So the flag is most likely to indicate that you've already had a successful trade with the npc. But even more so, you'll notice that the NPC buffer's their former Pokemon's name! That means they must have retrieved the name prior. So far we know all of what has been executed doesn't deal with retrieving then name...except for that other script that was called at the start, 0x1A8CAD!

Code:
'---------------
#org 0x1A8CAD
copyvar 0x8004 0x8008
special2 LASTRESULT 0xFC
copyvar 0x8009 LASTRESULT
return
So you can see that it sets var 0x8004 to whatever var 0x8008 was, and then launched special2 with an arguement of the lastresult. I'll butt in here and say that special2 0xFC is hardcoded to use variable 0x8004, so the fact they've passed LASTRESULT means nothing, other than this should have been coded as just be a normal special rather than special2 :P
Anyways, I'm ranting, getting back to the point, 0x8004 is 0 and the special is called. The special's function is to load the Pokemon's name and species into special buffer. Buffer2 = name, Buffer3 = species. The value in 0x8004 determines which index of the table the Pokemon trade NPC is for. So since 0x8004 == 0, then it's clearly the first trade slot.

Cool, lets look at the table data doesnt documented again:
Quote:
In-game trades in FR are at 0x26CF8C. The scripts relating to them store very little information, and just index into this table. Each entry is 0x3C bytes, used as such:

0x0 - Nickname, limited to ten characters + 0xFF.
0xC - Half-word, ID of the NPC's pokemon.
0xE - IVs, stored in HP/Atk/Def/Speed/SAtk/SDef order. One byte each.
0x14 - An entire word dedicated to the ability bit.
0x18 - NPC's trainer ID. Only the low bits are visible on the status screen.
0x1C - Five bytes; four of them are 5 and one is 0x1E. Not sure what they do if anything.
0x24 - Personality value; influences nature, gender, etc; more info here: http://bulbapedia.bulbagarden.net/wiki/Personality_value
0x28 - Hold item.
0x2A - 0x00 if the mon carries mail (only ZYNX has mail in FR), 0xFF otherwise.
0x2B - Original trainer's name. Limited to seven characters + 0xFF.
0x36 - 0x00 if original trainer is male, 0x01 if original trainer is female. Only visible in RSE.
0x37 - Always 0xA. Not sure what it controls if anything.
0x38 - Half-word, ID of the species the NPC is looking for.
0x3A - Half-word, seems unused.
He mentions that each NPC's entry in the table is 0x3C bytes, that is to say the first NPC's data is in the first 0x3C bytes and the next NPC's data is in the 0x3C bytes after that and so on. So starting we do this operation to get the starting address of the Xth trade trainer Address = (0x26CF8C) + (0x3C * X). So in the case of the 0th entry (first entry) it's going to be 0x26CF8C + (0x3C *0) = 0x26CF8C.

On the very left column he has some numbers, these are the relative addresses for each entry. For example, the nickname is at 0x0 and NPC's Pokemon is that 0xC. So to get the Species ID of the Pokemon that trainer has, we do: (0x26CF8C + 0xC)

Doing that, we know var 0x8004 == 0, so this is the first trainer, their starting address is going to be at
address = (0x26CF8C) + (0x3C * 0)
address = 0x26CF8C

now we need to know what Pokemon they have with according to the post is the 0xCth value of that entry, so we add 0xC to the starting address to get the NPC's pokemon species.
npc's species = starting_address + 0xC
npc's species = 0x26CF8C + 0xC
npc's species = 0x26CF98

go to 0x26CF98, and you'll see the 2 bytes read 0x78 0x0. That means the species they have is 00 78 = 0x78 = MrMime. To edit the species this NPC gives away, you must edit the 0x78 0x0 then.

Do the same logical operation to edit what Pokemon the NC wants. "0x38 - Half-word, ID of the species the NPC is looking for."
--

Now let me show you something about the hex editor.


Clicking a byte or highlighting it will tell you what the offset of that value is. You see in the highlight it shows the byte I've highlighted is the 0x26CF80 byte. From 0x26CF80, fine 0x26CF8C by going through the subsequent bytes. Hint in your case, the amount of bytes you have to go through is just 0x26CF8C - 0x26CF88 = 0x4 :)
__________________
...
Reply With Quote
  #14   Link to this post, but load the entire thread.  
Old November 12th, 2016 (6:22 AM). Edited November 12th, 2016 by Scarlet D..
Scarlet D.'s Avatar
Scarlet D. Scarlet D. is offline
The Eternal
 
Join Date: Dec 2015
Location: Greece
Gender: Male
Nature: Adamant
Posts: 66
Quote:
Originally Posted by longlostsoldier View Post
I believe there is actually a trade editor tool out there. PGE can do it, for instance. It has a lot of tools and it's much quicker than hex. As a novice you'll probably find that easier. Heck, I can edit ASM a bit and /I/ still prefer tools most of the time when given the opportunity.
Some heroes don't wear capes bro! You just saved my life from an eternal hex headache XD

Quote:
Originally Posted by FBI View Post
Right, so lets go through this step by step for you.
I am sorry for this FBI, PGE does the job when it comes to what you were saying. but, the guide you just wrote will make me clearly understand how the vars and hex editor values work so i will give it a try too ^^

thanks for you time!
Reply With Quote
  #15   Link to this post, but load the entire thread.  
Old November 12th, 2016 (6:34 AM).
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924
Quote:
Originally Posted by Aenaos View Post
Some heroes don't wear capes bro! You just saved my life from an eternal hex headache XD

I am sorry for this FBI, PGE does the job when it comes to what you were saying. but, the guide you just wrote will make me clearly understand how the vars and hex editor values work so i will give it a try too ^^

thanks for you time!
np, you should still try to learn it this way incase you run into something there isn't a tool for :)
__________________
...
Reply With Quote
Reply

Quick Reply

Join the conversation!

Create an account to post a reply in this thread, participate in other discussions, and more!

Create a PokéCommunity Account
Ad Content
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 9:14 AM.