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

[FR] Continue after losing a battle

3
Posts
7
Years
This routine allows you to continue running the script (in the case of a trainerbattle) or playing (in the case of a wildbattle) after losing with no whiteout. It is quite simple, just follow the steps!

Step 1:

First, open your favourite hex editor (I recommend HxD) and search for a free space. You will need 64 (0x40) bytes. Make sure that the offset you choose ends in 0, 4, 8 or C. Write down the offset!

Step 2:

Now, we are going to insert the routine that I wrote:

push {r0,r2}
nop @just to align
ldr r2, sub_var_8000
mov r0, #0x1
strh r0, [r2] @var 0x8000 = 0x1 // Means you have lost the battle for scripting porpouses
ldr r0, =(0x00000203) @Flag that controls the system // You can change it
ldr r2, sub_flag_decrypt
bl sub_call
cmp r0, #0x1
beq sub_flag_on
pop {r0,r2}
mov r0, #0x1 @Original response
pop {r1}
bx r1

sub_flag_on:
ldr r0, =(0x080A0059) @Heal the party
bl sub_call_2
pop {r0, r2}
mov r0, #0x0 @Hacked response
pop {r1}
bx r1

sub_call:
bx r2

sub_call_2:
bx r0

sub_flag_decrypt: .word 0x0806E6D1
sub_var_8000: .word 0x020370B8

And this is the code:

05 B4 C0 46 0B 4A 01 20 10 80 0B 48 08 4A 00 F0 0D F8 01 28 03 D0 05 BC 01 20 02 BC 08 47 07 48 00 F0 05 F8 05 BC 00 20 02 BC 08 47 10 47 00 47 D1 E6 06 08 B8 70 03 02 03 02 00 00 59 00 0A 08

That in bold is the flag (in reverse) that controls the system. Feel free to change it for any other flag.

Step 3:

Insert the code on the offset you chose in step 1. Then, add a "08" to that offset and reverse it. For example, if you chose the offset 904000, do this:

904000 => 08904000 => 08 90 40 00 => 00 40 90 08

Now, you have make your offset into a pointer. Write it down!

Step 4:

Go to the following offset: 0x800EC

You will find the same pointer to times in a row:

04 01 08 08 04 01 08 08

Replace them with your pointer two times too. For example, if your pointer is 00 40 90 08, you have to write this:

00 40 90 08 00 40 90 08

Now, you have inserted the system.

Understanding how it works:

It is quite easy. You have chosen a flag, in my case the flag 0x203.

If the flag is deactivated, the system won't be working. That means that if you lose a battle, you will be whited out as usual.

If the flag is activated, the system will be working. That means that if you lose a battle, you won't be whited out and will continue playing. In this case, var 0x8000 will be set to 0x1, that will allow you to know that you have lost the battle. So, if you want to do a trainerbattle that you can lose, add a "setvar 0x8000 0x0" before the trainerbattle command.

You have to do your script like this:

(...)
setvar 0x8000 0x0
trainerbattle (config) //you can use any type of trainerbattle
compare 0x8000 0x1
if 0x1 goto @youlost
(here what happens if you win)

#org @youlost
(here what happens if you lose)

Example:

I am spanish, so I made a tutorial in spanish that you won't be able to follow if you don't speak spanish. But you can go to the minute 11:54 if you want to see a video example of the system working.

 
Last edited:
222
Posts
6
Years
  • Age 22
  • Seen Nov 18, 2023
After poking around in emerald, I've failed to find the original routine or the pointers to it.
Is there something I'm doing wrong? Isn't that how you find pointers to things?
 
Back
Top