• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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] How to activate a flag after a trainer battle

Jehowi

Your Master Superior
  • 61
    Posts
    16
    Years
    At the moment, I'm trying to make a script where you have to battle two other opponents before the third opponent becomes available for battle. I'm using flags for this.

    What happens now, is that I have to talk to the person I defeated first before the flag gets activated. What am I doing wrong?

    This is the script

    #dyn 0x740000
    #org @start
    '-----------------------------------
    checkflag 0x238
    if true jump @flagalreadyset
    trainerbattle 0x0 0x9 0x0 @begin @defeat
    setflag 0x238 ---> this flag only gets activated when I talk to the trainer after battle, it doesn't get activated automatically after battle.
    end

    #org @flagalreadyset
    msgbox @sensei ' You've been lucky. I...
    callstd MSG_LOCK ' Built-in lock command
    end

    #org @begin
    = You? Beat me? Hah! I can smash\nrocks with my bare fists!

    #org @defeat
    = But that doesn't make me a great\ntrainer...

    #org @sensei
    = You've been lucky. I wonder if\nyou could beat sensei too.
     
    Code:
    #dyn 0x740000
    #org @start
    '-----------------------------------
    checkflag 0x238
    if true jump @flagalreadyset
    trainerbattle [b]0x1[/b] 0x9 0x0 @begin @defeat @after
    end
    
    #org @after
    setflag 0x238
    end
    
    #org @flagalreadyset
    msgbox @sensei ' You've been lucky. I...
    callstd MSG_LOCK ' Built-in lock command
    end
    #org @begin
    = You? Beat me? Hah! I can smash\nrocks with my
    bare fists!
    #org @defeat
    = But that doesn't make me a great\ntrainer...
    #org @sensei
    = You've been lucky. I wonder if\nyou could beat
    sensei too.
    This will work.
    You have to use trainerbattle 0x1 not 0x0 if you want to do something after the battle is finished .
    0x1 will give you another parameter which I labeled as @after .
     
    Code:
    #dyn 0x740000
    #org @start
    '-----------------------------------
    checkflag 0x238
    if true jump @flagalreadyset
    trainerbattle [B]0x1[/B] 0x9 0x0 @begin @defeat @after
    end
    
    #org @after
    setflag 0x238
    end
    
    #org @flagalreadyset
    msgbox @sensei ' You've been lucky. I...
    callstd MSG_LOCK ' Built-in lock command
    end
    #org @begin
    = You? Beat me? Hah! I can smash\nrocks with my
    bare fists!
    #org @defeat
    = But that doesn't make me a great\ntrainer...
    #org @sensei
    = You've been lucky. I wonder if\nyou could beat
    sensei too.
    This will work.
    You have to use trainerbattle 0x1 not 0x0 if you want to do something after the battle is finished .
    0x1 will give you another parameter which I labeled as @after .

    Thank you so much. I figured it had something to do with that, as for a rematch, i had to change the id to 0x3. Do you have any idea what the other numbers do in the trainer code? I mean the number that has to get changed...
     
    Last edited:
    Back
    Top