To create a yes/no battle script you could use something like this:
#dynamic 0x800000
#org @start
lock
faceplayer
msgbox @Talk 0x5 '----------------- A type 0x5 message box is a Yes/No one, and here we are asked if we want to battle.
compare lastresult 0x1 '----------------- Comparing if we chose yes or no.
if 0x1 goto @Battle '----------------- If we chose yes go to battle, else, say that we can't.
msgbox @CantBattle 0x6
release
end
'-----------------
#org @Battle '----------------- The script goes here if we say yes
trainerbattle 0x0 0x1 0x0 @Challenge @Defeat
hidesprite 0x1 '----------------- hidesprite is used to hide person events, and if your person event number is one, you write 0x1, if it's two, you'll
setflag 0x205 '----------------- use 0x2 and so on. Setflag is used to permanently hide the NPC from the map, and you need to associate a
release '----------------- number to it, and here I used flag 0x205. You can use a safe flag value from 0x200 to 0x2FF and you'll have to
end '----------------- place this number in the person ID box in Advance Map.
'----------------- Below is the code for all the text that's displayed with message boxes.
#org @Talk
= Hi there!, do you perhaps want to\nbattle?
#org @CantBattle
= Ok, I guess you don't want to.
#org @Challenge
= Okay, let's go!
#org @Defeat
= Wow, you defeated me?
'-----------------
I used ('-----------------) to write comments in the code, and it is not necessary for the code to work.