Hey there!
I had to move your post to this forum since you posted your question in an incorrect area.
About your question. It is a simple as using a flag and check its status to start a different battle based on that flag
You can read this tutorial for further information about scripting and flags
https://www.pokecommunity.com/showthread.php?t=164276