View Single Post
Old February 26th, 2013 (7:30 PM).
FBI's Avatar
FBI FBI is offline
Free supporter
  • Silver Tier
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,739
Originally Posted by Noossab Blue View Post
I'm trying to create a simple yes/no trainer battle. Here is what I have:

#dynamic 0x800000
#org @begin
checktrainerflag 0x66
compare lastresult 0x0
if 0x1 goto @finished
msgbox @ask 0x5
compare lastresult 0x0
if 0x1 goto @nope
trainerbattle 0x0 0x66 0x0 0x81722C7 0x81722F9
goto @finished

#org @nope
msgbox @no 0x6
settrainerflag 0x66

#org @finished
msgbox 0x8172315 MSG_NORMAL '"Ssh! You'll scare the bugs away.\n..."

' Strings
#org 0x1722C7
= Great! Let's battle our\nPOKéMON!

#org 0x1722F9
= No!\nCATERPIE can't hack it!

#org 0x172315
= Ssh! You'll scare the bugs away.\nAnother time, okay?

#org @ask
= Wanna battle?

#org @no
= 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...
Lets see here.
checktrainerflag 0x66 'Set when trainer is battled
compare lastresult 0x0 'Check if flag is not set (i.e not battled)
if 0x1 goto @finished 'If it's not battled goto @finish

It's only working because you can't do that, and it runs anyways (Atleast not in PKSV's new version. Just do checkflag, if true.) :P

What you should do is:
checktrainerflag 0x66
if 0x1 goto @finished

Also, logically you're setting the trainerflag if you haven't battled (which is wrong). Here's a PKSV representation of what it should look like.


#dynamic 0x740000
#org @start
checktrainerflag 0x66
if TRUE jump @done
msgbox @question
callstd MSG_YESNO
if != jump @no
settrainerflag 0x66
msgbox @openbattle
callstd MSG_NORMAL
trainerbattle 0x3 0x66 0x1 @defeat
jump @done

#org @done
msgbox @after
callstd MSG_NORMAL

#org @no
msgbox @tired
callstd MSG_NORMAL

#org @question
= Do you want to battle?

#org @tired
= Next time then.

#org @after
= That was a good battle!

#org @openbattle
= Prepare for battle!

#org @defeat
= Damn I lost

Try that PKSV version, you can convert it to XSE easily, if you wish.