msgbox @no 0x6
msgbox 0x8172315 MSG_NORMAL '"Ssh! You'll scare the bugs away.\n..."
= Great! Let's battle our\nPOKéMON!
= No!\nCATERPIE can't hack it!
= Ssh! You'll scare the bugs away.\nAnother time, okay?
= Wanna battle?
= No? Lame!
It's close to working. The problem is, the trainer only asks if you want to battle once, so if you say no you can't change your mind and say yes until you enter another battle and come back to him. Conversely, if you say yes, the battle commences, but if you come back to him after another battle, he asks if you want to battle again, even though you already won...not sure why...
Well, the first problem is there is no "end" at the end of @begin. This can cause bytes to run together if you have, let's say another script in that same area, and it might just keep going onto the next script.
There is no need to set the trainers flag if you say no, it was already set from the start.
Lastly, play with the type of trainer battle. I think your problem lies in using the wrong type. The types range from 0-3 so give them all a try.