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

Research: Interesting TrainerBattle Command

219
Posts
16
Years
Well,I'm not sure if this thread is legal.But if this thread is legal,this forum will be one of my favorite forum^^

Most hack time,we use trainerbattle command only as trainerbattle 0x0 and trainerbattle 0x1.

But there's also an interesting trainerbattle,as trainerbattle 0x9,which is used for battle teaching.

It used just like:
Code:
trainerbattle 0x9 0x148 0x3 0x818DDEA 0x818DE1A
from FR US 0x1692F3.

This battle is interesting not only because it teaches you how to battle,but also because if you're defeat,you won't be white out.The battle will finish and you keep the script.While trainerbattle 0x0 and trainerbattle 0x1 won't let you go on your script.

Does anyone interested in this?And how to make a trainerbattle that can also go on when the player is defeat?Or even in a wildbattle?
 

ZodiacDaGreat

Working on a Mobile System
429
Posts
17
Years
trainerbattle 0x3 also allows continuation of script execution.
Code:
...
trainerbattle 0x3 0x245 0x0 0x8809DA4
...
Thing is for 0x3 type, only battle defeat text.
 

Juan

Brazilian with a bad English
92
Posts
16
Years
trainerbattle is a command that allows you to use with different parameters.


trainerbattle byte byte hword pointer1


trainerbattle byte byte hword pointer1 pointer2

trainerbattle byte byte hword pointer1 pointer2 pointer3


Some subroutines called by the command 0x5C
a1h5sm.jpg





At least in Fire Red, the maximum that can be used in the first parameter is 10(0x0-0x9).
And each of them calls a different subroutine.


Code:
ROM:08080228
ROM:08080228 @ ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
ROM:08080228
ROM:08080228
ROM:08080228 sub_8080228:                            @ CODE XREF: cmd_0x5C+6p
ROM:08080228                 PUSH    {R4,R5,LR}
ROM:0808022A                 ADD     R5, R0, #0
ROM:0808022C                 BL      sub_8080110
ROM:08080230                 LDR     R4, =0x20386AC
ROM:08080232                 ADD     R0, R5, #0
ROM:08080234                 BL      Read8bitsValue
ROM:08080238                 LSL     R0, R0, #0x18
ROM:0808023A                 LSR     R0, R0, #0x18
ROM:0808023C                 STRH    R0, [R4]
ROM:0808023E                 LDRH    R0, [R4]
ROM:08080240                 SUB     R0, #1
ROM:08080242                 CMP     R0, #8
ROM:08080244                 BHI     loc_8080318     @ 0x0 or > 0x9
ROM:08080246                 LSL     R0, R0, #2
ROM:08080248                 LDR     R1, =off_8080258
ROM:0808024A                 ADD     R0, R0, R1
ROM:0808024C                 LDR     R0, [R0]
ROM:0808024E                 MOV     PC, R0
ROM:0808024E @ ---------------------------------------------------------------------------
ROM:08080250 dword_8080250:  .long 0x20386AC         @ DATA XREF: sub_8080228+8r
ROM:08080254 off_8080254:    .long off_8080258       @ DATA XREF: sub_8080228+20r
ROM:08080254                                         @ 
ROM:08080258 off_8080258:    .long loc_808028C       @ DATA XREF: sub_8080228:off_8080254o
ROM:08080258                                         @ 0x1
ROM:0808025C                 .long loc_808028C       @ 0x2
ROM:08080260                 .long loc_808027C       @ 0x3
ROM:08080264                 .long loc_8080284       @ 0x4
ROM:08080268                 .long loc_80802D8       @ 0x5
ROM:0808026C                 .long loc_8080294       @ 0x6
ROM:08080270                 .long loc_80802AC       @ 0x7
ROM:08080274                 .long loc_8080294       @ 0x8
ROM:08080278                 .long loc_8080304       @ 0x9
ROM:0808027C @ ---------------------------------------------------------------------------
...
...
...

this forum will be one of my favorite forum^^
[2] :D

Hm, ZDG, what script is that executed in?
In fire red has scripts that use this type of script.


value
local
script type
script offset
command

Code:
0x0:
VIRIDIAN FOREST [1.0]
Person 3
0x160571
trainerbattle 0x0 0x66 0x0 0x81722C7 0x81722F9

0x1:
VIRIDIAN CITY [5.1]
Person 8
0x169ECA
trainerbattle 0x1 0x15E 0x0 0x818F352 0x818F43F 0x8169F04

0x2:
ROCKET HIDEOUT [1.42]
Person 5
0x16120A
trainerbattle 0x2 0x16A 0x0 0x817503A 0x817505A 0x8161225

0x3:
MT. MOON [1.3]
Person 3
0x1606C2
trainerbattle 0x3 0xAA 0x0 0x8172B99


0x4:
VICTORY ROAD [1.41]
Person 11
0x16115F
trainerbattle 0x4 0x1E5 0x0 0x8174D0C 0x8174D45 0x8174D96

0x5:
ROUTE 3 [3.21]
Person 2
0x1A957B
trainerbattle 0x5 0x76 0x0 0x81C15F9 0x8183891

0x6:
none

0x7:
ROUTE 8 [3.26]
Person #12
0x1AA349
trainerbattle 0x7 0x1E4 0x0 0x81C19E5 0x81845D0 0x8184616

0x8:
none

0x9:
ROUTE 22 [3.41]
Script 0
0x16828C
trainerbattle 0x9 0x149 0x0 0x8188959 0x818DE1A

OBS: copied from the dump done by HackMew
 

linkandzelda

Ex-rom hacker turned indie game developer
777
Posts
17
Years
ive used trainerbattle 0x9 before in my hack. I has two texts, the first is if you beat the trainer they say their defeat text and the second is if you loose they come back onto the battle field and say that text. and after that the script will continue. but unfortunitly if you loose it wont continue :(

Link
 
219
Posts
16
Years
trainerbattle 0x3 also allows continuation of script execution.
Code:
...
trainerbattle 0x3 0x245 0x0 0x8809DA4
...
Thing is for 0x3 type, only battle defeat text.

Is this can keep running your script and not white out?
I'll try while my computer get update...(It's broken...and I'm using my father's...)

trainerbattle is a command that allows you to use with different parameters.





Some subroutines called by the command 0x5C
a1h5sm.jpg





At least in Fire Red, the maximum that can be used in the first parameter is 10(0x0-0x9).
And each of them calls a different subroutine.


Code:
ROM:08080228
ROM:08080228 @ ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
ROM:08080228
ROM:08080228
ROM:08080228 sub_8080228:                            @ CODE XREF: cmd_0x5C+6p
ROM:08080228                 PUSH    {R4,R5,LR}
ROM:0808022A                 ADD     R5, R0, #0
ROM:0808022C                 BL      sub_8080110
ROM:08080230                 LDR     R4, =0x20386AC
ROM:08080232                 ADD     R0, R5, #0
ROM:08080234                 BL      Read8bitsValue
ROM:08080238                 LSL     R0, R0, #0x18
ROM:0808023A                 LSR     R0, R0, #0x18
ROM:0808023C                 STRH    R0, [R4]
ROM:0808023E                 LDRH    R0, [R4]
ROM:08080240                 SUB     R0, #1
ROM:08080242                 CMP     R0, #8
ROM:08080244                 BHI     loc_8080318     @ 0x0 or > 0x9
ROM:08080246                 LSL     R0, R0, #2
ROM:08080248                 LDR     R1, =off_8080258
ROM:0808024A                 ADD     R0, R0, R1
ROM:0808024C                 LDR     R0, [R0]
ROM:0808024E                 MOV     PC, R0
ROM:0808024E @ ---------------------------------------------------------------------------
ROM:08080250 dword_8080250:  .long 0x20386AC         @ DATA XREF: sub_8080228+8r
ROM:08080254 off_8080254:    .long off_8080258       @ DATA XREF: sub_8080228+20r
ROM:08080254                                         @ 
ROM:08080258 off_8080258:    .long loc_808028C       @ DATA XREF: sub_8080228:off_8080254o
ROM:08080258                                         @ 0x1
ROM:0808025C                 .long loc_808028C       @ 0x2
ROM:08080260                 .long loc_808027C       @ 0x3
ROM:08080264                 .long loc_8080284       @ 0x4
ROM:08080268                 .long loc_80802D8       @ 0x5
ROM:0808026C                 .long loc_8080294       @ 0x6
ROM:08080270                 .long loc_80802AC       @ 0x7
ROM:08080274                 .long loc_8080294       @ 0x8
ROM:08080278                 .long loc_8080304       @ 0x9
ROM:0808027C @ ---------------------------------------------------------------------------
...
...
...


[2] :D


In fire red has scripts that use this type of script.




Code:
0x0:
VIRIDIAN FOREST [1.0]
Person 3
0x160571
trainerbattle 0x0 0x66 0x0 0x81722C7 0x81722F9
 
0x1:
VIRIDIAN CITY [5.1]
Person 8
0x169ECA
trainerbattle 0x1 0x15E 0x0 0x818F352 0x818F43F 0x8169F04
 
0x2:
ROCKET HIDEOUT [1.42]
Person 5
0x16120A
trainerbattle 0x2 0x16A 0x0 0x817503A 0x817505A 0x8161225
 
0x3:
MT. MOON [1.3]
Person 3
0x1606C2
trainerbattle 0x3 0xAA 0x0 0x8172B99
 
 
0x4:
VICTORY ROAD [1.41]
Person 11
0x16115F
trainerbattle 0x4 0x1E5 0x0 0x8174D0C 0x8174D45 0x8174D96
 
0x5:
ROUTE 3 [3.21]
Person 2
0x1A957B
trainerbattle 0x5 0x76 0x0 0x81C15F9 0x8183891
 
0x6:
none
 
0x7:
ROUTE 8 [3.26]
Person #12
0x1AA349
trainerbattle 0x7 0x1E4 0x0 0x81C19E5 0x81845D0 0x8184616
 
0x8:
none
 
0x9:
ROUTE 22 [3.41]
Script 0
0x16828C
trainerbattle 0x9 0x149 0x0 0x8188959 0x818DE1A

OBS: copied from the dump done by HackMew
This is a HUGE routine,and seems much more difficult than item running.I just saw your item subject.I'm also interesting in item running.So I decide to research items first^^And research trainerbattle commands later(If I can...)
 

558122_DG

Learning how to make mistakes
737
Posts
14
Years
  • Seen May 27, 2021
trainerbattle 0x3 also allows continuation of script execution.
Code:
...
trainerbattle 0x3 0x245 0x0 0x8809DA4
...
Thing is for 0x3 type, only battle defeat text.


so are the 3 dots in the begginging and end required?


Also for the script

trainerbattle 0x3 0xXXX 0x9 @intro @defeat

is it possible to change what the person says?

I.E oak usually says:

Pushy as always, you haven't been in a trainer battle have you?

^I expect it would require some ASM though :/
 

558122_DG

Learning how to make mistakes
737
Posts
14
Years
  • Seen May 27, 2021
So, what happens in the person defeats you? Your Pokemon get healthy again or what?

I don't believe so, all that happens is the script continues BUT it will gliche up UNLESS you have a special 0x0 command in there. I.E lets say rival beats you...then the game will crash. Atleast thats what happened to me :/
 
3
Posts
15
Years
  • Seen Mar 19, 2010
I believe trainerbattle 0x3 is for the elite four.
Can someone explain how the other commands work?
 
47
Posts
15
Years
  • Seen Apr 25, 2011
I don't know if anyone else has thought of this, but could this be used in conjunction with the Safari system somehow; so that when you have no pokemon to fight with you can use stones, bait, and balls to handle wild pokemon? Maybe you could do something with trainers where some of them you don't have to battle, but others will block your path or drive you off unless you can/do battle them. That might be neat, and would solve the whole problem I've always had of "Gah! Not another psycho battle-maniac!" Plus, it might mean you could do a hack where you actually go out and catch your first pokemon, instead of being handed it...sorry, maybe I'm getting carried away. Still, I think some neat things could be done by changing the way defeat is handled.
 

trebornosliw

Learning
516
Posts
14
Years
  • Age 31
  • Seen Jul 22, 2012
Well, it says no revival limit so I'll leave a note here in case anyone comes looking.
so are the 3 dots in the begginging and end required?


Also for the script

trainerbattle 0x3 0xXXX 0x9 @intro @defeat

is it possible to change what the person says?

I.E oak usually says:

Pushy as always, you haven't been in a trainer battle have you?

^I expect it would require some ASM though :/
First, I assume you mean this:
trainerbattle 0x9 0xXXX 0x3 @victory @defeat
1. trainerbattle 0x3 is followed by only one text pointer and I have no idea what that 0x9 would do in the command you wrote.
2. the first text pointer in trainerbattle 0x9 shows if you win the battle, not at the battle's start (thus, not intro).

Second, I imagine you could go in and hex edit the text... it has to be stored somewhere. There's a tutorial about hex editing text somewhere on this forum (now I'm interested... I'm going to have to look this up).

So, what happens in the person defeats you? Your Pokemon get healthy again or what?
I've been testing, and your Pokemon will automatically be healed if you lose in trainerbattle 0x9 0x??? 0x3, but will not be healed if you win (you have to add the special 0x0). Now, if you lose a trainerbattle 0x9 0x??? 0x0 you are just sent to the last Pokemon center.
I'm trying to find some way to have a battle without Oak's dialogue where the trainer's Pokemon are still healed after a loss. Is there a list of the effects of that third variable anywhere (the one that's set as 0x3 for the Oak dialogue)?
 

tajaros

Hi I'm dawg
855
Posts
12
Years
Well, it says no revival limit so I'll leave a note here in case anyone comes looking.

First, I assume you mean this:
trainerbattle 0x9 0xXXX 0x3 @victory @defeat
1. trainerbattle 0x3 is followed by only one text pointer and I have no idea what that 0x9 would do in the command you wrote.
2. the first text pointer in trainerbattle 0x9 shows if you win the battle, not at the battle's start (thus, not intro).

Second, I imagine you could go in and hex edit the text... it has to be stored somewhere. There's a tutorial about hex editing text somewhere on this forum (now I'm interested... I'm going to have to look this up).


I've been testing, and your Pokemon will automatically be healed if you lose in trainerbattle 0x9 0x??? 0x3, but will not be healed if you win (you have to add the special 0x0). Now, if you lose a trainerbattle 0x9 0x??? 0x0 you are just sent to the last Pokemon center.
I'm trying to find some way to have a battle without Oak's dialogue where the trainer's Pokemon are still healed after a loss. Is there a list of the effects of that third variable anywhere (the one that's set as 0x3 for the Oak dialogue)?

You can edit the text using A-text.

And found something I'm using this script in my hack and used it further but it seems if you have more than 1 Pokemon the Game Freezes or Crashes.

After your first Pokemon is defeated you'll select your next Pokemon and no Sprite will appear and it will crash when the 2nd Pokemon Loses.
 
Back
Top