As I speculated, your problem was not using dynamic offsets.
Let's explain your problem thoroughly:
Offsets:
Whenever you type the line "#org [anything]" you're specifying an offset. That means, where the code to run the script will be written in the game's memory.
You can write "#org 0xE3E63A" and that would work fine with careful planning.
However,
dynamic offsets are when you use XSE's free space function instead.
Using dynamic offsets is easy. Look at my example from the last post.
Basically instead of writing 0xE3E63A you type @intro
And whenever you would reference the message box there you would again type @intro
You of course do this whenever you would write "#org something"
Look here for more info:
https://www.pokecommunity.com/threads/164276
It's the thread I suggested last time, unfortunately you haven't done what I said last time because otherwise you problem would have been solved.
Last but not least, I have no idea what trainerbattle 0x2 is
If I'm not mistaken:
0x0 is regular trainer
0x1 is with a script after you win
0x4 double battle
0x6 double battle with script after you win
All in all your problems are annoying yet minimal. The thread I've supplied should be able to supply answers to all of your questions within the next month
only by itself if you look for long enough.
Hope this fixes your problem, good luck.