• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Script] Emerald - checktrainerflag?

Arkayide

AKA [Insertnamehere]
12
Posts
10
Years
  • Hi ya'll, I seem to have some problems understanding how the trainer flags work in Emerald. I have this script that does some stuff, then enters a trainer battle. On future occasions, it's then supposed to use the checktrainerflag to jump in the script once the battle has already been defeated. However, even after the trainer has been defeated, the script still plays out like normal when talking to the NPC again:

    Code:
    #dynamic 0x9C0B20
    #freespace 0xFF
    
    #org @start
    lock
    faceplayer
    
    checktrainerflag 0x140
    compare LASTRESULT 0x1
    if 0x1 goto @alreadyDefeated
    
    msgbox @msg1 0x2
    setvar 0x8004 0x0
    goto @Loop
    
    #org @Loop
    special2 0x8000 0x149
    compare 0x8000 0x118
    if 0x1 goto @HaveWurmple
    addvar 0x8004 0x1
    compare 0x8004 0x6
    if 0x5 goto @Loop
    release
    end
    
    #org @HaveWurmple
    applymovement 0x5 @move
    waitmovement 0x0
    sound 0x15
    pause 0x30
    msgbox @WurmpleIsCute 0x2
    trainerbattle 0x0 0x140 0x0 @battleIntro @battleWin
    release
    end
    
    #org @alreadyDefeated
    msgbox @after 0x6
    release
    end
    
    #org @msg1
    = My favorite Pokémon is Wurmple!\nIt's sooooo cute! I really want\lone for myself, but my daddy won't\lbuy me any more Poké Balls...
    
    #org @WurmpleIsCute
    = Oh, you have one? Yay!
    
    #org @battleIntro
    = Maybe you can show it to me in a\nbattle!
    
    #org @battleWin
    = Oh no, you beat me!
    
    #org @after
    = My friend says that Wurmple is\ncreepy, but I disagree!
    
    #org @move
    #raw 0x56
    #raw 0xFE

    Could someone help me understand what I'm missing? Thanks!
     

    SIlverstanfan04

    A Pokenerd like no other
    53
    Posts
    3
    Years
    • He/They
    • UK
    • Seen yesterday
    when using the normal checkflag command you do not compare lastresult, you go straight to the if command, try removing the compare LASTRESULT command from the flag check.
    Alternatively you could just add 500 to the trainer flag and use the standard checkflag 0x(flag) (value), if 0x1 goto ...
     
    Back
    Top