Thread: [Tutorial] Lunos' Wonder Trade System
View Single Post
Old 2nd March 2018, 12:26 PM  
Lunos
Random Uruguayan Guy
 
Lunos's Avatar
 
Join Date: Jan 2015
Location: Montevideo (Uruguay)
Posts: 12
Lunos
Default Lunos' Wonder Trade System

Hi.
In the past few days, I've been working on a Wonder Trade script after seeing the one that the user Harlee Quinn came up with.
Since it has some pretty nasty flaws and it can't be used in serious projects, I've decided to share it.
So without further ado, let's do this.

For this tutorial we'll need:
-A Pokémon Fire Red (USA) v1.0 ROM or a Pokémon Emerald (USA) ROM.
-A GBA Emulator
-Whichever text and hex editors you prefer to use.
-HackMew's Assembler which you can find right here
-HackMew's "Take Pokémon" ASM Routine which you can find right here
-Advance Map and XSE, obviously.

Instructions:
1) Compile the "Take Pokémon" Routine made by HackMew which I linked up there.
Use the Fire Red or the Emerald version depending on which ROM you're modifying.
Here's a video showing the process.

Here's the compiled routines for those who are lazy:
Fire Red:
Spoiler:
Code:
FF B5 00 25 11 4E 0F 4F 3C 78 02 2C 18 DB 33 88 A3 42 15 D2 62 1E 3A 70 01 33 E2 1A 64 25 6A 43 52 08 6B 43 08 4F F8 18 41 1B 0B DF 6C 43 3F 19 7F 1B 00 20 19 22 01 25 01 C7 01 3A 00 2A FB D1 35 82 FF BD 29 40 02 02 84 42 02 02 C0 70 03 02

Emerald:
Spoiler:
Code:
FF B5 00 25 11 4E 0F 4F 3C 78 02 2C 18 DB 33 88 A3 42 15 D2 62 1E 3A 70 01 33 E2 1A 64 25 6A 43 52 08 6B 43 08 4F F8 18 41 1B 0B DF 6C 43 3F 19 7F 1B 00 20 19 22 01 25 01 C7 01 3A 00 2A FB D1 35 82 FF BD E9 44 02 02 EC 44 02 02 E0 75 03 02


Then paste the compiled routine in an offset with at least 50 bytes of free space.
You can search one using Free Space Finder or your Hex Editor itself (lots of FF Bytes = Free Space).
Since I like to play things safe, I also suggest you to use an offset that ends in 0, 4, 8 o C. I've put it the Routine for Fire Red in 71A250 and the one for Emerald in E3CF80.

2) Go to Advance Map, choose a map and add a NPC on it with the following script, again, depending on which ROM you're modifying
Fire Red:
Spoiler:
Code:
#dynamic 0x71BBA0 #org @start faceplayer lockall msgbox @String1 0x5 compare 0x800D 0x1 if 0x1 goto @snippet1 msgbox @String2 0x6 releaseall end #org @snippet1 countpokemon compare LASTRESULT 0x1 if 0x1 goto @snippet7 msgbox @String3 0x6 special 0x9F waitstate special2 0x8003 0x147 compare 0x8003 0x19c if 0x1 goto @snippet8 compare 0x8004 0x6 if 0x4 goto @snippet3 goto @snippet4 #org @snippet3 msgbox @String2 0x6 releaseall end #org @snippet4 random 0x19C compare 0x800D 0x0 if 0x1 goto @snippet4 compare 0x800D 0xFB if 0x3 goto @snippet5 compare 0x800D 0x115 if 0x4 goto @snippet5 goto @snippet4 #org @snippet5 copyvar 0x8000 0x800D bufferpokemon 0x0 0x8000 showpokepic 0x8000 0xA 0x3 waitcry callasm 0x8FFFFFF+1 givepokemon 0x8000 0x5 0x0 0x0 0x0 0x0 pause 0x13 fanfare 0x13E msgbox @String5 0x4 waitfanfare closeonkeypress hidepokepic msgbox @String6 0x5 compare 0x800D 0x1 if 0x1 call @snippet6 msgbox @String2 0x6 releaseall end #org @snippet6 countpokemon subvar 0x800D 0x1 copyvar 0x8004 0x800D fadescreen 0x1 special 0x9E waitstate return #org @snippet7 msgbox @String7 0x6 releaseall end #org @snippet8 msgbox @String8 0x6 releaseall end #org @String1 = Wanna wonder trade? #org @String2 = Come back anytime. #org @String3 = Select the Pokémon you wanna trade. #org @String5 = [player] got a [buffer1]! #org @String6 = Wanna give it a nickname? #org @String7 = Sorry, you need two Pokémon\nto use the Wonder Trade.\pCome back anytime. #org @String8 = I'm sorry, you cannot trade\na Pokémon Egg using the\lWonder Trade System.\pCome back anytime.

Emerald:
Spoiler:
Code:
#freespace 0xFF #dynamic 0x71BBA0 #org @start faceplayer lockall msgbox @String1 0x5 compare 0x800D 0x1 if 0x1 goto @snippet1 msgbox @String2 0x6 releaseall end #org @snippet1 countpokemon compare LASTRESULT 0x1 if 0x1 goto @snippet7 msgbox @String3 0x6 special 0xA2 waitstate special2 0x8003 0x149 compare 0x8003 0x19c if 0x1 goto @snippet8 compare 0x8004 0x6 if 0x4 goto @snippet3 goto @snippet4 #org @snippet3 msgbox @String2 0x6 releaseall end #org @snippet4 random 0x19C compare 0x800D 0x0 if 0x1 goto @snippet4 compare 0x800D 0xFB if 0x3 goto @snippet5 compare 0x800D 0x115 if 0x4 goto @snippet5 goto @snippet4 #org @snippet5 copyvar 0x8000 0x800D bufferpokemon 0x0 0x8000 cry 0x8000 0x0 showpokepic 0x8000 0xA 0x3 waitcry callasm 0x8FFFFFF+1 givepokemon 0x8000 0x5 0x0 0x0 0x0 0x0 pause 0x13 fanfare 0x13E msgbox @String5 0x4 waitfanfare closeonkeypress hidepokepic msgbox @String6 0x5 compare 0x800D 0x1 if 0x1 call @snippet6 msgbox @String2 0x6 releaseall end #org @snippet6 countpokemon subvar 0x800D 0x1 copyvar 0x8004 0x800D fadescreen 0x1 special 0xA1 waitstate return #org @Snippet7 msgbox @String7 0x6 releaseall end #org @snippet8 msgbox @String8 0x6 releaseall end #org @String1 = Wanna wonder trade? #org @String2 = Come back anytime. #org @String3 = Select the Pokémon you wanna trade. #org @String5 = [player] got a [buffer1]! #org @String6 = Wanna give it a nickname? #org @String7 = Sorry, you need two Pokémon\nto use the Wonder Trade.\pCome back anytime. #org @String8 = I'm sorry, you cannot trade\na Pokémon Egg using the\lWonder Trade System.\pCome back anytime.

Note: FFFFFF+1 = Offset where you've put HackMew's Routine, +1.
As I said before I dropped it in 71A250, which means that I'll have to use "callasm 0x871A251".
In the case of Emerald I've put it in E3CF80, that means that I'll have to use "callasm 0x8E3CF81".


3) Test.

Credits
-Harlee Quinn, because her/his script inspired me to make this.
-Bela, because he told me how to check if the Player decides to cancel the special 0x9F by using the B Button.
-HackMew for all the contributions that she has made to the Pokémon ROM Hacking Community.
-Dani_SR_17 from Wahack for his suggestion to optimize the filter in #org @snippet4.
-BluRose for helping me to understand an incredibly stupid mistake that I was having while implementing said filter.
-Anonymous tester from Pokémon Shiny Gold Sigma for noticing that Eggs were tradable.
-LuHo for creating Advance Map.

Here's a quick video showcasing the result in Fire Red.


Here's a quick video showcasing the result in Emerald.


And that's it.
__________________


Last edited by Alice; 2nd March 2018 at 10:35 PM.
Lunos is offline   Reply With Quote
Likes Mystelex, Dragoondra liked this post