Long and short, I'm trying to get the method to change trainer battle music to work specifically with trainerbattle 0x9 - for example, to give the rival their own music.
Simplified snippet from my code:
I cut out some stuff, but basically it's setting up the music with special 0x3B and playsong 0x14A (inserted track), but what's happening is bizarre. The fight executes correctly, with the right music and trainerbattle 0x9 functionality (it lets you lose without a whiteout if you toggle the 3rd byte to 0x3, has win and loss quote pointers, etc.) but the immediately afterwards, it repeats the battle - losing that fight causes a whiteout, but the win/loss quotes are still there.
As a test, I tried it once without the conditional stuff in between playsong and trainerbattle with the same results, and then I also tried moving special 0x3B to after the trainerbattle line to see how it behaves*:
What happens then is it does the 0x9 battle with default music, followed by another with the correct music. I think what's happening is it's reading from a buffered trainer, but doesn't activate until there is one - in this case, the first battle in the game occurs and it activates immediately, again. I don't believe this issue occurs with anything but trainerbattle 0x9, but I haven't tried others yet - judging by what people say though, the standard is to use 0x0.
Does anyone know if there's a buffertrainer command/method that I can use to "store" the 0x9 battle first, and then use special 0x3B to activate it? Or more directly, just getting trainerbattle 0x9 to work in this way? If all else fails, I know there's a patch out there to assign music by trainer class, I just feel like that's overkill for what I'm trying to do at this moment.
*EDIT:
Even stranger, when doing it in the 0x9 -> 0x3B order, the player's pokemon seems to be at full again even if it was damaged or even fainted in the 0x9 battle, even when I remove special 0x0. But since that's the "wrong" way to do it in the first place I won't speculate until I can dig into the ASM itself...
Simplified snippet from my code:
Code:
msgbox @rivalA_battlechat1 0x6
special 0x3B
playsong 0x14A 0x0
compare 0x4031 0x0 'Player: grass starter
if 0x1 goto @rivalB_battle1
compare 0x4031 0x1 'Player: fire starter
if 0x1 goto @rivalB_battle2
compare 0x4031 0x2 'Player: water starter
if 0x1 goto @rivalB_battle3
...
#org @rivalA_battle1
trainerbattle 0x9 0x3D 0x3 @rivalA_defeat @rivalA_win
goto @postbattle
I cut out some stuff, but basically it's setting up the music with special 0x3B and playsong 0x14A (inserted track), but what's happening is bizarre. The fight executes correctly, with the right music and trainerbattle 0x9 functionality (it lets you lose without a whiteout if you toggle the 3rd byte to 0x3, has win and loss quote pointers, etc.) but the immediately afterwards, it repeats the battle - losing that fight causes a whiteout, but the win/loss quotes are still there.
As a test, I tried it once without the conditional stuff in between playsong and trainerbattle with the same results, and then I also tried moving special 0x3B to after the trainerbattle line to see how it behaves*:
Code:
msgbox @rivalA_battlechat1 0x6
compare 0x4031 0x0 'Player: grass starter
if 0x1 goto @rivalB_battle1
compare 0x4031 0x1 'Player: fire starter
if 0x1 goto @rivalB_battle2
compare 0x4031 0x2 'Player: water starter
if 0x1 goto @rivalB_battle3
...
#org @rivalA_battle1
trainerbattle 0x9 0x3D 0x3 @rivalA_defeat @rivalA_win
goto @postbattle
...
#org @postbattle
special 0x3B
playsong 0x14A 0x0
What happens then is it does the 0x9 battle with default music, followed by another with the correct music. I think what's happening is it's reading from a buffered trainer, but doesn't activate until there is one - in this case, the first battle in the game occurs and it activates immediately, again. I don't believe this issue occurs with anything but trainerbattle 0x9, but I haven't tried others yet - judging by what people say though, the standard is to use 0x0.
Does anyone know if there's a buffertrainer command/method that I can use to "store" the 0x9 battle first, and then use special 0x3B to activate it? Or more directly, just getting trainerbattle 0x9 to work in this way? If all else fails, I know there's a patch out there to assign music by trainer class, I just feel like that's overkill for what I'm trying to do at this moment.
*EDIT:
Even stranger, when doing it in the 0x9 -> 0x3B order, the player's pokemon seems to be at full again even if it was damaged or even fainted in the 0x9 battle, even when I remove special 0x0. But since that's the "wrong" way to do it in the first place I won't speculate until I can dig into the ASM itself...
Last edited: