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

Development: "Release" Specific Pokémon from Party Script

metapod23

Hardened Trainer
673
Posts
15
Years
  • Seen Aug 18, 2016
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. 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 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 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 for helping me understand the Daycare Center script.

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

Code:
#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!

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.

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

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.

Code:
#org @start2
call @menu
[spoiler]calls @menu, which brings up the select a Pokémon menu[/spoiler]
special2 LASTRESULT 0x84
[spoiler]this checks to see if you have only one Poké in your party[/spoiler]
compare LASTRESULT 0x1
if 0x1 goto @cant
[spoiler]if you have only one Poké, script goes to @cant[/spoiler]
compare 0x8004 0x6
if 0x4 goto @goback
[spoiler]this checks to see if you hit B to go back. If so, it takes you to @goback[/spoiler]
special2 LASTRESULT 0x85
[spoiler]checks to see if last Poké is an egg[/spoiler]
compare LASTRESULT 0x0
if 0x1 goto @cant
[spoiler]if your last Poké would be an egg, goes to @cant[/spoiler]
special2 0x8005 0xBA
[spoiler]this sets the Pokémon species # selected in the menu to variable 0x8005 - this is [i]very[/i]
important to this script[/spoiler]
setvar 0x8004 0x19
[spoiler]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.[/spoiler]
bufferpokemon 0x0 0x8005
[spoiler]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.[/spoiler]
comparevars 0x8005 0x8004
[spoiler]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.[/spoiler]
if 0x0 goto @notthesame
[spoiler]If the the species numbers of the Poké stored in 0x8004 and 0x8005 do not match, the
script goes to @notthesame.[/spoiler]
goto @continue
[spoiler]goes to @continue only if none of the above things occur[/spoiler]

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

'---------------
#org @cant
msgbox @add MSG_NORMAL
special 0x3C
[spoiler]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.[/spoiler]
goto @start2

'---------------
#org @goback
msgbox @no MSG_NORMAL
goto @start2
[spoiler]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.[/spoiler]


'---------------
#org @notthesame
msgbox @thatsnot MSG_NORMAL
goto @start2
[spoiler]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.[/spoiler]

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

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

'---------------
@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:

Code:
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:

Code:
#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:

Code:
#org @start
[spoiler]This is the dynamic offset for the beginning of your script :)[/spoiler]
call @pokemenu
[spoiler]calls dynamic offset for @pokemenu, which opens the Pokemon menu to select
a Pokemon from your party[/spoiler]
special2 LASTRESULT 0x84
[spoiler]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)[/spoiler]
compare LASTRESULT 0x1
if 0x1 goto @cant
[spoiler]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[/spoiler]
compare 0x8004 0x6
[spoiler]checks to see if you hit the Back button (B on GBA, X on comp)[/spoiler]
if 0x4 goto @goback
[spoiler]if you hit Back, goes to dynamic offset @goback, which ends the script[/spoiler]
special2 LASTRESULT 0x85
[spoiler]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[/spoiler]
compare LASTRESULT 0x0
if 0x1 goto @cant
[spoiler]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[/spoiler]
special2 0x8005 0xBA
[spoiler]gets the # of the Pokemon you selected and stores it in indicated variable (in this
case, variable 0x8005)[/spoiler]
bufferpokemon 0x0 0x8005
[spoiler]Buffers the name of the Pokemon you selected to the first buffer[/spoiler]
goto @continue
[spoiler]if none of the above conditions are meant, the script is safe to continue - goes to
dynamic offset @continue[/spoiler]

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

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

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

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

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

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

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

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

'---------------
#org @erase
callasm 0x800001
[spoiler]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[/b] 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 :)[/spoiler]
goto @done
[spoiler]after running HackMew's routine, goes to dynamic offset @done[/spoiler]

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

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

And there you go :)
I want to thank HackMew and his Taking Away Pokemon Routine, as well as JPAN and his Study on the Special and Special2 commands, for helping me understand some of the specials and how to get them to work.

Thanks for reading :)
 
Last edited:

LightOfTruth

Member
729
Posts
14
Years
  • Age 31
  • Seen Jul 16, 2020
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 :)
 

marcc5m

what
1,116
Posts
13
Years
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

Hardened Trainer
673
Posts
15
Years
  • Seen Aug 18, 2016
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

is an Ace Trainer.
10
Posts
12
Years
  • Seen Nov 30, 2012
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.
 
76
Posts
15
Years
  • Age 31
  • Seen Aug 8, 2021
This sounds like a silly question, but is it possible to make a script that releases a pokemon when it faints?
 

metapod23

Hardened Trainer
673
Posts
15
Years
  • Seen Aug 18, 2016
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.
 
1
Posts
11
Years
  • Seen May 24, 2016
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?
 

GoGoJJTech

(☞゚ヮ゚)☞ http://GoGoJJTech.com ☜(゚ヮ゚☜)
2,475
Posts
11
Years
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)
.....
 
1
Posts
12
Years
  • Seen Mar 4, 2021
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

Stuck in Hot Girl Summer
10,507
Posts
16
Years
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:

Spoiler:


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.
 
Back
Top