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

[Other✓] Can i set a var value back to 0 in fire red?

  • 14
    Posts
    10
    Years
    • Seen Feb 26, 2016
    Basically what i want to do is have a header script which will only activates once a certain event has happened. i thought of using a checkflag, but when i had the string for when the flag is not set it would just keep repeating the script over and over so the player cant do anything anymore. i then thought of setting the var value of the script to be not 0000 so that it wouldnt play normally. that part works, but when i insert "setvar 0x409a 0x0" into a script it doesnt work. can anyone help me? even if there is another way to do this effect (like some way of making the checkflag system work) that would be great. thanks.
     
    Basically what i want to do is have a header script which will only activates once a certain event has happened. i thought of using a checkflag, but when i had the string for when the flag is not set it would just keep repeating the script over and over so the player cant do anything anymore. i then thought of setting the var value of the script to be not 0000 so that it wouldnt play normally. that part works, but when i insert "setvar 0x409a 0x0" into a script it doesnt work. can anyone help me? even if there is another way to do this effect (like some way of making the checkflag system work) that would be great. thanks.

    Can you show us the header/level script?

    From what I understood, if for example your level script's variable and value are set to 0x409A and 0x1, assuming 409A's initial value is 0, the level script will not be executed until you set its value to 0x1 in a different script. In your level script, you should make sure 409A's value is set to anything other than 1, 2 for example, otherwise the script will keep executing.
     
    Im not sure what you mean. i thought that a script would not play if the var value was anything other than 0?
     
    Yeah, you're right. If the variable of your level script is 0x409A, you have to set the value of this var to a value different from 0, before you enter on the map.

    If you set the value of the var 0x409A to 0, your level script will be executed.
     
    thats what i thought, and thats what isnt working. i am inserting "setvar 0x409A 0x0" into the script i want to run first but it doesn't seem to work. i know that the script works on its own as i set the var value to start at 0 to test it. is there anything else i should be doing? the script i want to run is:

    #dynamic 0x803700

    #org @start
    setvar 0x409a 0x1
    applymovement 0x1 @move1
    waitmovement 0x0
    msgbox @1 0x2
    trainerbattle 0x9 0x059 0x0 @won @lost
    msgbox @2 0x2
    applymovement 0x1 @move2
    waitmovement 0x0
    release
    end

    (i have the first string there because i dont want the script to repeat regardless of if i win or lose the battle)
     
    thats what i thought, and thats what isnt working. i am inserting "setvar 0x409A 0x0" into the script i want to run first but it doesn't seem to work. i know that the script works on its own as i set the var value to start at 0 to test it. is there anything else i should be doing? the script i want to run is:

    #dynamic 0x803700

    #org @start
    setvar 0x409a 0x1
    applymovement 0x1 @move1
    waitmovement 0x0
    msgbox @1 0x2
    trainerbattle 0x9 0x059 0x0 @won @lost
    msgbox @2 0x2
    applymovement 0x1 @move2
    waitmovement 0x0
    release
    end

    (i have the first string there because i dont want the script to repeat regardless of if i win or lose the battle)
    Try checking the variable yourself
    Code:
    #dynamic 0x803700
    
    #org @start
    compare 0x409A 0x1
    if 0x1 jump @done
    setvar 0x409a 0x1
    applymovement 0x1 @move1
    waitmovement 0x0
    msgbox @1 0x2
    trainerbattle 0x9 0x059 0x0 @won @lost
    msgbox @2 0x2
    applymovement 0x1 @move2
    waitmovement 0x0
    jump @done
    
    #org @done
    release
    end
     
    Im not sure what you mean. i thought that a script would not play if the var value was anything other than 0?

    In AdvanceMap, you can set which value the variable should have in order to be executed. It's usually 0, but you could also set it to 1, for example, and then the script would only play if the variable's value was 1.
     
    @fbi
    I was using a checkflag to do it like that, but the problem i was having was that if it went to the @done part it was just constantly looping so the player couldnt move. i know this because i tested it by putting a msgbox as part of the @done script and it was just opening the msgbox as soon as i closed it.

    @christos
    i think i understand now, is that what is being set when i input a var value in advance map?

    so i tried setting the varvariable for 409A to 0x1 and using the string "setvar 0x409A 0x1" in the previous script, but what happens is the screen just goes black as soon as i enter the map with the header script.

    i just tested the script on a script tile instead of a header and it worked so the script seems ok. when i use header script type [02] it will lock the player and have a message box with constant gibberish when the script is set to not run, amd when i use header script type [04] it just freezes on a black screen when the script is set to run. im really at a loss.
     
    Last edited by a moderator:
    i just tested the script on a script tile instead of a header and it worked so the script seems ok. when i use header script type [02] it will lock the player and have a message box with constant gibberish when the script is set to not run, amd when i use header script type [04] it just freezes on a black screen when the script is set to run. im really at a loss.

    Oh, you need to remove the raw 0xFFs at the start of your script.
    A few things before:

    1) Make sure in amap flag = 409a, and value = 0000
    2) ctrl + H to go into advance header
    3) Copy the map script offset and decompile it in a script editor
    4) you should see a #raw word 0xFFFF hanging about change this to #raw word 0x0
     
    Be happy to have a look at the problem if you PM me your mod.

    I'll make sure you have your var's communicating properly and check the raw 0xFFFFs as stated above.
     
    Oh, you need to remove the raw 0xFFs at the start of your script.
    A few things before:

    1) Make sure in amap flag = 409a, and value = 0000
    2) ctrl + H to go into advance header
    3) Copy the map script offset and decompile it in a script editor
    4) you should see a #raw word 0xFFFF hanging about change this to #raw word 0x0

    I followed your advice but when i decompile the script it just has:

    #org 0x71A294
    end

    also i dont want the value to be 0000 because i dont want the script to run until another script has happened. Am i trying to do that in the wrong way?

    to add to that, it does run perfectly when the value is 0000 but then it also runs the first time i enter the map which i dont want.
     
    I followed your advice but when i decompile the script it just has:

    #org 0x71A294
    end

    also i dont want the value to be 0000 because i dont want the script to run until another script has happened. Am i trying to do that in the wrong way?

    to add to that, it does run perfectly when the value is 0000 but then it also runs the first time i enter the map which i dont want.
    Make it 0000. Set it to 0x1 in the script.
     
    Make it 0000. Set it to 0x1 in the script.

    Thanks, I have it working now. I have the script 409A var set to 0000 (which means the script would run the first time i enter the map). Then i have a script which runs before i get to that particular map which includes the line "setvar 0x409A 0x1" to make it so that the 409A script wont run. Then i use the line "setvar 0x409A 0x0" in the script i want to run before this, which means that the script will now run. I assume that was how you were suggesting to do it?
     
    Bit unnecessary but it's essentially the same what you've done.

    You could have just had script 409A var set to 0001. 409A would by default be 0000, so it wouldn't run the script until you later changed setvar 4091 to 0x1.
     
    Back
    Top