Thread: [Tutorial] XSE Scripting Tutorial
View Single Post
Old 1st March 2018, 10:28 PM  
Avara
Beginner
 
Join Date: Nov 2013
Posts: 33
Avara
Default

Pokémon Battle Scripts

First, we're going to learn how to make a wild Pokémon battle, useful for legendary encounters and such. We'll cover trainer battles a little later! The wildbattle command is set up like this:
Code:
wildbattle 0x[Pokémon] 0x[Level In Hex] 0x[Held Item]
Imagine we wanted to battle a level 50 Milotic holding Mystic Water:
Quote:
Originally Posted by Avara
#dynamic 0x800000

#org @main
...
wildbattle 0x149 0x32 0xD1
...
0x149 is Milotic's ID, 0x32 is 50 in hex, and 0xD1 is the item Mystic Water's ID. Click here for Pokémon/Item hex IDs if needed. Reminder that if you make use of the header files "stdpoke.rbh" and "stditems.rbh", you could have this instead:
Quote:
Originally Posted by Avara
#include stdpoke.rbh
#include stditems.rbh

#dynamic 0x800000

#org @main
...
wildbattle PKMN_MILOTIC 0x32 ITEM_MYSTICWATER
...
Checking The Result Of A Wild Battle


Wild Battle Result Check: [FR]
Code:
wildbattle 0x[Pokémon] 0x[Level In Hex] 0x[Held Item]
special2 LASTRESULT 0xB4
compare LASTRESULT 0x1
if 0x1 goto @DefeatedPointer
compare LASTRESULT 0x4
if 0x1 goto @RanPointer
hidesprite LASTTALKED
setflag 0x[OW's Person ID in A-Map]
release
end
special2 LASTRESULT 0xB4 returns a value. In this case if the returned value is 1, the script will goto @DefeatedPointer if the player accidentally fainted the Pokémon during the battle; good for letting them have another chance at capturing it. @RanPointer will be jumped to if, you guessed it, the player ran from the encounter. Aaand here's the equivalent for Emerald:

Wild Battle Result Check: [EM]
Code:
wildbattle 0x[Pokémon] 0x[Level In Hex] 0x[Held Item]
special2 LASTRESULT 0xB7
compare LASTRESULT 0x1
if 0x1 goto @DefeatedPointer
compare LASTRESULT 0x4
if 0x1 goto @RanPointer
hidesprite LASTTALKED
setflag 0x[OW's Person ID in A-Map]
release
end

Last edited by Avara; 29th December 2018 at 08:55 PM.
Avara is offline   Reply With Quote
Likes Lunos liked this post