PDA

View Full Version : "Release" Specific Pokémon from Party Script


metapod23
March 6th, 2010, 12:44 PM
Note: This is a tutorial for Fire Red only.

A couple of people have asked about this, so I'm going to post a tutorial on it. It's a bit of a complicated script, but nothing too earth-shattering.

There are two ways to do this - the first way is without compiling any ASM codes and using the Daycare Center code that is already in the game. The second is by using HackMew's ASM code (http://www.pokecommunity.com/showthread.php?t=167889). Both work, but for a Pokemon you want to erase forever, the latter is the way to go, and it's very easy to assemble and put in your game if you know what you're doing. To understand how to do that, I recommend HackMew's Knowledge (http://www.pokecommunity.com/showthread.php?t=117917#ASM1) as a tut.

[alink id="daycare"]Release Pokemon with Daycare Script (No ASM compiling)[/alink id]

[alink id="asm"]Release Pokemon with HackMew's Routine (ASM Compiling Required)[/alink id]

So first I will give you the Daycare Center way of doing it:

[A ID]daycare[/A ID]Releasing Pokemon with the Daycare Center Script

First, be aware that in order to use this script, you have to use the Pokémon Daycare Center script. So you'll need to remove Daycare Center from the game or alter the Daycare script itself. Otherwise, you'll need to learn ASM and use this this thread (http://www.pokecommunity.com/showthread.php?t=167889) to create a custom routine. Otherwise, for those who are ASM-deficient (like me) this is probably the best way to do this.

The script I'll be posting as a tutorial also checks to make sure you're releasing only a specific Pokémon. This is important if you're trying to create an event where a specific Pokémon needs to be taken from the player's party and not just any Pokémon selected by the player from his party. An example of this is in my AshGray hack, where I had to release Butterfree and only Butterfree, as Ash did in the Anime. If it can be any Poké, then just use the Daycare Center script, or compile that ASM routine thingie posted above.

Thanks to this thread (http://www.pokecommunity.com/showthread.php?t=167263) for helping me understand the Daycare Center script.

First, the whole script in all its glory, then the explanation:

#org @start
setvar 0x8004 0x19
special2 LASTRESULT 0x17C
compare LASTRESULT 0x1
if 0x1 goto @start2
release
end

'---------------
#org @start2
call @menu
special2 LASTRESULT 0x84
compare LASTRESULT 0x1
if 0x1 goto @cant
compare 0x8004 0x6
if 0x4 goto @goback
special2 LASTRESULT 0x85
compare LASTRESULT 0x0
if 0x1 goto @cant
special2 0x8005 0xBA
setvar 0x8004 0x19
bufferpokemon 0x0 0x8005
comparevars 0x8005 0x8004
if 0x0 goto @notthesame
goto @continue

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

'---------------
#org @cant
msgbox @add MSG_NORMAL
special 0x3C
goto @start2

'---------------
#org @goback
msgbox @no MSG_NORMAL
goto @start2


'---------------
#org @notthesame
msgbox @thatsnot MSG_NORMAL
goto @start2

'---------------
#org @continue
special 0x176
cmdc3 0x2F
goto @release

'---------------
#org @release
msgbox @bye MSG_NORMAL
fanfare 0x101
waitfanfare
release
end

'---------------
@add
= Please add another Pokemon to your\nparty first!

'---------------
@no
= Come on! Don't you want to give up\nPikachu?

'---------------
@thatsnot
= Huh? That's ! Not Pikachu!

'---------------
@bye
= Goodybe, Pikachu!

Now for the explanation (in spoilers):

This first part is needed if you want to force the player to give up a specific Pokémon. First thing we have to do is make sure that Poké is in their party! For this example, I'll use Pikachu as the Poké we want to check for. Pikachu is 0x19 in hex.

#org @start
setvar 0x8004 0x19
Sets a Pokémon species # to variable 0x8004. In this case it's Pikachu, since we used 0x19.
special2 LASTRESULT 0x17C
compare LASTRESULT 0x1
if 0x1 goto @start2
This checks to see if the player has said Poké in his party. If so it goes to @start2.
release
end
If the player doesn't have said Poké in his party, the script ends.

Now that we know the player has the Poké we want him to give up in his party, we can move on to the script that will have him "release" it by storing it in Daycare.

#org @start2
call @menu
calls @menu, which brings up the select a Pokémon menu
special2 LASTRESULT 0x84
this checks to see if you have only one Poké in your party
compare LASTRESULT 0x1
if 0x1 goto @cant
if you have only one Poké, script goes to @cant
compare 0x8004 0x6
if 0x4 goto @goback
this checks to see if you hit B to go back. If so, it takes you to @goback
special2 LASTRESULT 0x85
checks to see if last Poké is an egg
compare LASTRESULT 0x0
if 0x1 goto @cant
if your last Poké would be an egg, goes to @cant
special2 0x8005 0xBA
this sets the Pokémon species # selected in the menu to variable 0x8005 - this is very
important to this script
setvar 0x8004 0x19
This sets a Pokemon species to variable 0x8004. For this example I'm using
Pikachu, who's Pokémon species # is 0x19. This is the particular Pokémon you
want to make sure the player releases.
bufferpokemon 0x0 0x8005
This stores the name of the Poké selected from the menu in a buffer. Only necessary if
you're writing a dialogue in which that Poké's name will be spoken.
comparevars 0x8005 0x8004
This compares the information in variables 0x8005 and 0x8004 to each other. If you'll
recall, the info for the Pokémon species selected from the menu was stored in 0x8005,
and the info for the Pokémon species we want to be taken from the player was stored
in 0x8004.
if 0x0 goto @notthesame
If the the species numbers of the Poké stored in 0x8004 and 0x8005 do not match, the
script goes to @notthesame.
goto @continue
goes to @continue only if none of the above things occur

'---------------
#org @menu
special 0x9F
waitstate
lock
faceplayer
copyvar 0x800A 0x8004
return
This part of the script pretty much brings up the Pokémon selection menu

'---------------
#org @cant
msgbox @add MSG_NORMAL
special 0x3C
this special opens up the Pokémon PC - only use this if it's imperative to give
away the Poké at this time. Otherwise just have the script release and end here.
goto @start2

'---------------
#org @goback
msgbox @no MSG_NORMAL
goto @start2
This is the script for if the player chooses to hit B and go back when he's in the
Pokémon selection menu. If forcing the player to give away a certain Pokémon, then
have this script return to the beginning. If not, then have it end here.


'---------------
#org @notthesame
msgbox @thatsnot MSG_NORMAL
goto @start2
This is the script for if the Poké selected doesn't match the one we want the player to
give up. Again, if it's imperative that the player give up the Poké, have him go back to the
beginning. If not, have the script end.

'---------------
#org @continue
special 0x176
cmdc3 0x2F
goto @release
This code puts the Pokémon selected in the Daycare, then goes to @release.

'---------------
#org @release
msgbox @bye MSG_NORMAL
fanfare 0x101
waitfanfare
release
end
shows the @bye message, plays a fanfare, and ends the script. Yep, the Pokémon you
wanted the player to release is definitely gone!

'---------------
@add
= Please add another Pokemon to your\nparty first!

'---------------
@no
= Come on! Don't you want to give up\nPikachu?

'---------------
@thatsnot
= Huh? That's [buffer1]! Not Pikachu!

'---------------
@bye
= Goodybe, Pikachu!

Okay, so that's the script! Now, because the Poké released isn't actually released, but just in daycare, it can be retrieved, in case you have an event where you have to give a Poké and receive it again later. This part of the Daycare script seems to do that:

setvar 0x8004 0x0
special2 LASTRESULT 0x17A
special 0xC6
copyvar 0x8008 LASTRESULT
countpokemon
subvar LASTRESULT 0x1

Just keep in mind, if you release a Poké by storing it in Daycare, and then release another Poké by storing it in Daycare later, the previous one is lost forever (which is essentially the same as releasing it - am I right? :)) - so it can only be retrieved if no other Pokémon are "released" in the same manner.

Now, moving on to the more efficient way using HackMew's erase Pokemon assembly code:

[A ID]asm[/A ID]Release Specific Pokemon with HackMew's ASM

For this, I will just assume that you placed the ASM code at offset 0x800000. If not, just remember to add a 1 to whatever offset you put the ASM code at when using it in the script. Also, I will assume you want to release Pikachu, whose # is 0x19.

And now, the script:

#org @start
call @pokemenu
special2 LASTRESULT 0x84
compare LASTRESULT 0x1
if 0x1 goto @cant
compare 0x8004 0x6
if 0x4 goto @goback
special2 LASTRESULT 0x85
compare LASTRESULT 0x0
if 0x1 goto @cant
special2 0x8005 0xBA
bufferpokemon 0x0 0x8005
goto @continue

'---------------
#org @pokemenu
special 0x9F
waitstate
return

'---------------
#org @cant
msgbox @cant2 MSG_NORMALOKéM..."
release
end

#org @cant2
= You can't release your last\nPOKéMON!

'---------------
#org @goback
msgbox @goback2 MSG_NORMAL
end

#org @goback2
= I'd rather not release Pikachu [.]

'---------------
#org @continue
compare 0x8005 0x19
if 0x1 goto @erase
goto @notpikachu

'---------------
#org @notpikachu
msgbox @notpikachu2 MSG_NORMAL
end

#org @notpikachu2
= That's a [buffer1], not a Pikachu!

'---------------
#org @erase
callasm 0x800001
goto @done

'---------------
#org @done
msgbox @done2 MSG_KEEPOPEN
closeonkeypress
release
end

#org @done2
= [player] released [buffer1]!\nGoodbye, [buffer1]!

Now, a brief explanation of how it works:

#org @start
This is the dynamic offset for the beginning of your script :)
call @pokemenu
calls dynamic offset for @pokemenu, which opens the Pokemon menu to select
a Pokemon from your party
special2 LASTRESULT 0x84
special 0x84 counts the # of Pokemon in your party (countpokemon could
probably work here as well) and stores it in variable indicated (in this case - lastresult)
compare LASTRESULT 0x1
if 0x1 goto @cant
this compares the # stored in lastresult (# of Pokemon in party) to 0x1 - if you
only have 1 Pokemon, takes you to dynamic offset @cant, which ends the script
compare 0x8004 0x6
checks to see if you hit the Back button (B on GBA, X on comp)
if 0x4 goto @goback
if you hit Back, goes to dynamic offset @goback, which ends the script
special2 LASTRESULT 0x85
special 0x85 gets Pokemon data and stores it in the selected variable (lastresult
in this case) - it's used for determining if your last Pokemon would be an egg
compare LASTRESULT 0x0
if 0x1 goto @cant
determine the data gotten from special 0x85 is an egg or not. If the last pokemon
would be an egg, goes to dynamic offset @cant, which ends the script
special2 0x8005 0xBA
gets the # of the Pokemon you selected and stores it in indicated variable (in this
case, variable 0x8005)
bufferpokemon 0x0 0x8005
Buffers the name of the Pokemon you selected to the first buffer
goto @continue
if none of the above conditions are meant, the script is safe to continue - goes to
dynamic offset @continue

'---------------
#org @pokemenu
special 0x9F
waitstate
return
special 0x9f opens the Pokemon menu and (with waitstate) waits for you to make
a selection

'---------------
#org @cant
msgbox @cant2 MSG_NORMAL
release
end
exits the Pokemon menu and plays @cant2 message

#org @cant2
= You can't release your last\nPOKéMON!

'---------------
#org @goback
msgbox @goback2 MSG_NORMAL
end
exits the Pokemon menu and plays @goback2 message

#org @goback2
= I'd rather not release Pikachu [.]

'---------------
#org @continue
compare 0x8005 0x19
compares the Pokemon you selected from the Pokemon menu to see if it is
a Pikachu
if 0x1 goto @erase
If it is Pikachu, goes to dynamic offset @erase
goto @notpikachu
Otherwise, goes to dynamic offset @notpikachu

'---------------
#org @notpikachu
msgbox @notpikachu2 MSG_NORMAL
end
exits the Pokemon menu and plays @notpikachu2 message

#org @notpikachu2
= That's a [buffer1], not a Pikachu!

'---------------
#org @erase
callasm 0x800001
calls HackMew's ASM routine for erasing Pokemon. Normally we would have to
set 0x8004 to the correct slot # in our party, making things difficult, but luckily [b]special
0x9f has already stored the slot # of the Pokemon we selected in variable 0x8004 for
us. With the slot # already stored in the correct variable by this special, we can just call
HackMew's ASM to erase the Pokemon we selected :)
goto @done
after running HackMew's routine, goes to dynamic offset @done

'---------------
#org @done
msgbox @done2 MSG_KEEPOPEN
closeonkeypress
release
end
plays the @done2 message and ends the script

#org @done2
= [player] released [buffer1]!\nGoodbye, [buffer1]!

And there you go :)
I want to thank HackMew and his Taking Away Pokemon Routine (http://www.pokecommunity.com/showthread.php?t=206138), as well as JPAN and his Study on the Special and Special2 commands (http://www.pokecommunity.com/showthread.php?t=184273), for helping me understand some of the specials and how to get them to work.

Thanks for reading :)

Giga Universe
March 16th, 2010, 10:27 AM
You don't need to learn ASM to remove Pokémon. Several ASM hackers have done it already, all you have to do is assemble their code, and compile a much shorter and more easy to understand script. Here is a link to HackMew's routine, for all versions.
http://www.pokecommunity.com/showthread.php?t=206138
You don't even need to understand it to get it to work.

LightOfTruth
February 17th, 2011, 08:57 AM
Why would one would want a script to remove Pokemon from there party if they can remove Pokemon via the PC. I think I would rather have the daycare so its not for me. Unless its just for a certain length of time like the S zone :)

Crimson5M
February 17th, 2011, 09:25 AM
Why would one would want a script to remove Pokemon from there party if they can remove Pokemon via the PC. I think I would rather have the daycare so its not for me. Unless its just for a certain length of time like the S zone :)

Because this way permanently removes the Pokemon. For instance, you could have a sidequest where you have to take a Pokemon somewhere and give it to someone, or a thief steals your Pokemon.

metapod23
February 22nd, 2011, 06:37 PM
Why would one would want a script to remove Pokemon from there party if they can remove Pokemon via the PC. I think I would rather have the daycare so its not for me. Unless its just for a certain length of time like the S zone :)

I've needed it countless times for my hack. Storing it in the PC wouldn't work for events where the Pokemon is stolen, released, given away, etc.

And also, I added a second tutorial that shows you how to do this with HackMew's custom ASM, which would allow you to not use the Daycare Center script. I just left the Daycare tutorial for anyone who might need to know how to do this for a script in which they need the Pokemon taken away and then returned again afterward.

Roboto-kun
May 22nd, 2011, 10:05 PM
Hey, Metapod! Uhm, Pikachu is 0x19... How do you know it's 0x19? Can you give me a list or something? o.O As far as I know, Pikachu is 25 in Pokedex. Thanks. :]

Edit: Uhm, nevermind. They're hex numbers.

Leafbarrett
October 25th, 2011, 08:53 AM
This sounds like a silly question, but is it possible to make a script that releases a pokemon when it faints?

metapod23
October 26th, 2011, 02:33 PM
This sounds like a silly question, but is it possible to make a script that releases a pokemon when it faints?

It may be possible with JPAN's hacked engine and only scripting (as opposed to using ASM, in which it should be doable, but much harder to execute).

You could try using the walking script, activate it and write a script that checks each Pokemon in your party's HP and if it's zero, erase it. You could also have the same script execute at the end of each battle by just writing it into each trainer battle script. Lastly, you could edit the healing scripts (the script that activates when all your Pokemon have fainted in Centers or with healers) to do the same check and erase those Pokemon.

The walking script and the healing scripts might be the most practical, as it doesn't require adding anything extra to battles and should (for the most part) do the trick. To make it perfect with just scripting, you'd have to include a script at the conclusion of each battle, though, and this still wouldn't erase the Pokemon right away after wild battles (you'd have to take one step if the walking script is activated).

ASM would be the optimal way of doing it, but I can't help with that.

agentL
March 25th, 2013, 10:48 AM
Sorry if this is a stupid question.

but I tryed to use hackmew's script, but I didn't work. :/
How do I do this callasm thing? Isn't there someone a guide for this?

wael96
January 16th, 2014, 04:40 AM
(Maybe my question is childlike)May I know the purpose of variables from 0x8000 to 0x8009?

Merak
January 16th, 2014, 04:33 PM
(Maybe my question is childlike)May I know the purpose of variables from 0x8000 to 0x8009?



I don't know if this is the thread to ask that sort of question. Perhaps try the simple questions thread instead?

GoGoJJTech
January 16th, 2014, 06:00 PM
Sorry if this is a stupid question.

but I tryed to use hackmew's script, but I didn't work. :/
How do I do this callasm thing? Isn't there someone a guide for this?

Xse script
.....
Callasm 0x(offset+1)
.....

Rhysy27
March 23rd, 2014, 04:17 PM
I know the script ends if the chosen pokemon is the only one you have but is there a way for it to work in that sense? I want the only pokemon that the player has to be stolen. Is that possible?

machomuu
April 22nd, 2014, 03:54 PM
I know the script ends if the chosen pokemon is the only one you have but is there a way for it to work in that sense? I want the only pokemon that the player has to be stolen. Is that possible?
Let me help you here. The part of the script that checks to see if you have only one pokemon is in bold:

#org @start
setvar 0x8004 0x19
special2 LASTRESULT 0x17C
compare LASTRESULT 0x1
if 0x1 goto @start2
release
end

'---------------
#org @start2
call @menu
special2 LASTRESULT 0x84
compare LASTRESULT 0x1
if 0x1 goto @cant
compare 0x8004 0x6
if 0x4 goto @goback
special2 LASTRESULT 0x85
compare LASTRESULT 0x0
if 0x1 goto @cant
special2 0x8005 0xBA
setvar 0x8004 0x19
bufferpokemon 0x0 0x8005
comparevars 0x8005 0x8004
if 0x0 goto @notthesame
goto @continue

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

'---------------
#org @cant
msgbox @add MSG_NORMAL
special 0x3C
goto @start2

'---------------
#org @goback
msgbox @no MSG_NORMAL
goto @start2


'---------------
#org @notthesame
msgbox @thatsnot MSG_NORMAL
goto @start2

'---------------
#org @continue
special 0x176
cmdc3 0x2F
goto @release

'---------------
#org @release
msgbox @bye MSG_NORMAL
fanfare 0x101
waitfanfare
release
end

'---------------
@add
= Please add another Pokemon to your\nparty first!

'---------------
@no
= Come on! Don't you want to give up\nPikachu?

'---------------
@thatsnot
= Huh? That's [buffer1]! Not Pikachu!

'---------------
@bye
= Goodybe, Pikachu!

The first line in bold checks to see if you only have one pokemon in your party and the latter two end the script should the first one be true. Try omitting those lines and see how it works out for you.