• 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✓] FR - Counting how many gym badges the player currently has?

44
Posts
6
Years
    • Seen Oct 8, 2022
    Is there a way to count how many gym badges the player currently has in Fire Red? I have looking into the script of the vicotry road guards and found the flags for (I assume) the badges. How would I generate a counter that counts if the player has, say, badge 1 and badge 5, and then does something because the user has 2 badges?

    Code:
    #org 0x1A796E
    textcolor 0x0
    applymovement 0x8009 0x81A75E7
    waitmovement 0x0
    copyvar 0x8000 0x4001
    compare 0x8000 0x1
    if 0x1 goto 0x81A79D8
    compare 0x8000 0x2
    if 0x1 goto 0x81A79E7a
    compare 0x8000 0x3
    if 0x1 goto 0x81A79F6
    compare 0x8000 0x4
    if 0x1 goto 0x81A7A05
    compare 0x8000 0x5
    if 0x1 goto 0x81A7A14
    compare 0x8000 0x6
    if 0x1 goto 0x81A7A23
    compare 0x8000 0x7
    if 0x1 goto 0x81A7A32
    compare 0x8000 0x8
    if 0x1 goto 0x81A7A41
    end
     
    7
    Posts
    5
    Years
    • Seen Mar 27, 2019
    I don't have many experience with variables in Pok?mon Scripts, but in theory it should work if you add +1 to a variable after each gym battle. Then just check the variable's value with the new script and continue the script how you want it to be.
    I can't tell you much about it, but I hope I could help though
     
    44
    Posts
    6
    Years
    • Seen Oct 8, 2022
    I don't have many experience with variables in Pok?mon Scripts, but in theory it should work if you add +1 to a variable after each gym battle. Then just check the variable's value with the new script and continue the script how you want it to be.
    I can't tell you much about it, but I hope I could help though

    Thats what I was thinking as well, however I do not know how to create a variable in pokemon scripts. In VB its easy enough as 'dim vr as variable = 0" and then "vr = vr +1". But in Pokescripts, I'm lost.
     

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • Thats what I was thinking as well, however I do not know how to create a variable in pokemon scripts. In VB its easy enough as 'dim vr as variable = 0" and then "vr = vr +1". But in Pokescripts, I'm lost.

    Yeah, pokescripting isn't a programming language and you can only use the defined commands. You don't have to declare any variables. They're all global, and all of the non-temporary ones will retain their value through saves. In scripting, to do arithmetic and variable logic, you need to use the scripting commands. So to add or subtract there are specific commands like addvar and subvar that you need to use.


    To setup a way to count:
    setvar 0x8000 0x0 ' set the value of the variable to 0, so we can start counting from 0

    checkflag 0xbadge1
    if true call @incrementvar
    checkflag 0xbadge2
    if true call @incrementvar
    checkflag 0xbadge3
    if true call @incrementvar
    ...

    To check amount of badges earned after you've counted:
    compare 0x8000 0x1
    if 0x1 goto @onebadge
    ...

    Incrementing a variable
    #org @incrementvar
    addvar 0x8000 0x1
    return


    I would recommend breaking it down into these 3 parts. Because later on, you could just do something like, "call 0xaddress_for_count_badges" and conserve ROM space.
     
    44
    Posts
    6
    Years
    • Seen Oct 8, 2022
    Yeah, pokescripting isn't a programming language and you can only use the defined commands. You don't have to declare any variables. They're all global, and all of the non-temporary ones will retain their value through saves. In scripting, to do arithmetic and variable logic, you need to use the scripting commands. So to add or subtract there are specific commands like addvar and subvar that you need to use.


    To setup a way to count:


    To check amount of badges earned after you've counted:


    Incrementing a variable



    I would recommend breaking it down into these 3 parts. Because later on, you could just do something like, "call 0xaddress_for_count_badges" and conserve ROM space.



    This is perfect! You rock! Thank you very much!
     
    Back
    Top