• 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] How to activate a flag after a trainer battle

Jehowi

Your Master Superior
61
Posts
15
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.
     

    Phantom Phoenix

    Lost on the road of life
    167
    Posts
    8
    Years
    • Age 27
    • ???
    • Seen Jul 1, 2020
    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 .
     

    Jehowi

    Your Master Superior
    61
    Posts
    15
    Years
  • 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