View Single Post
  #7955    
Old February 26th, 2013 (07:30 PM).
FBI agent's Avatar
FBI agent FBI agent is online now
If my PM box is full, VM instead :x
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 829
Quote originally posted by Noossab Blue:
I'm trying to create a simple yes/no trainer battle. Here is what I have:

Spoiler:
#dynamic 0x800000
#org @begin
lock
faceplayer
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
release
end

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


'---------
' 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.

Spoiler:

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

#org @done
msgbox @after
callstd MSG_NORMAL
release
end

#org @no
msgbox @tired
callstd MSG_NORMAL
release
end

#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.
__________________
...

My name forum name is FBI Agent, though you can call me FBI because it's shorter.

Some of my stuff:
ASM request/resource thread
ASM tutorials thread
ASM Workshop