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

Help Thread: Script Help Thread

Status
Not open for further replies.
10,078
Posts
15
Years
    • UK
    • Seen Oct 17, 2023

    If this script is only meant to run once, you don't need the countpokemon/compare bits. Once the variable is set that part won't run at all anyway (the variable should be 0x4050 by the way, not 4050).

    The flag you're setting for your hidesprite command is way too high. Check out safe flags (and variables) here.

    In terms of actual commands - lock/lockall should come first in your script, before the applymovements. You don't need faceplayer as this is a script tile, not a person event. Your msgbox @talk2 should be box 0x4 not 0x6 - as that one stays open until closeonkeypress.

    Oh and your givepokemon says lv 8 rather than lv 9 - guess that's a typo!

    Hope this helps~
     
    8
    Posts
    9
    Years
    • Seen Apr 7, 2015
    Hello,

    So I'm trying to make a warp script that makes you use an item when warped, but I really have no idea how.. I want it to use a key item. Here is my working warp script so far (using XSE) :

    Spoiler:


    Yeah, its a super simple script so far. So, is there any way I can make it to where a key item (bike for example) is activated after being warped? Please help! :(
     
    8
    Posts
    9
    Years
    • Seen Apr 7, 2015
    Well, I realized I don't need any of that.. All I need to do is call the bikes routine in my script, right? I checked 2 different item editors for its routine location, which is at 0x0A122D. And I know it has to be it because if you call an offset with no routine it just freezes. I didn't add a one on the end cause I didn't think you would have to since thats the offset it gave me. I called it in a script, and when I activated it in game, the screen just fades to black (doesnt freeze, music still plays, just fades black). My guess is because I didn't put the other required commands in the script that I would probably need (like vars or flags or something) but I don't know what :(
    Could someone please tell me what I might be doing wrong, or what to add to my script? Its urgent! ;'( My script so far is literally just:


    Spoiler:



    Yeah...
     

    metapod23

    Hardened Trainer
    673
    Posts
    15
    Years
    • Seen Aug 18, 2016
    Well, I realized I don't need any of that.. All I need to do is call the bikes routine in my script, right? I checked 2 different item editors for its routine location, which is at 0x0A122D. And I know it has to be it because if you call an offset with no routine it just freezes. I didn't add a one on the end cause I didn't think you would have to since thats the offset it gave me. I called it in a script, and when I activated it in game, the screen just fades to black (doesnt freeze, music still plays, just fades black). My guess is because I didn't put the other required commands in the script that I would probably need (like vars or flags or something) but I don't know what :(
    Could someone please tell me what I might be doing wrong, or what to add to my script? Its urgent! ;'( My script so far is literally just:


    Spoiler:



    Yeah...

    It depends on what item you want to activate and what it's supposed to do. If you wanted the player to appear on his bike after the warp, you would use a header script with special 0x157 (for Fire Red). Is that what you want? For the player to appear on his bike after he is warped?

    Edit: To do that, you would need to make a script that sets a variable before the warp. Say, setvar 0x5000 0x1.

    Be sure to save a backup of your rom before you do any of this.

    So your script would be:

    Code:
    lock
    setvar 0x5001 0x1
    warp 0x4 0x0 0xFF 0x2 0x3
    waitstate
    end

    or something like that (don't forget the waitstate).

    Then you will need a seperate header script in the map you are warping the player to. In the header of the map, go to Map Script and add 02 Validates values ...

    Flag is your var #, in my example 5000 and value is 0001 in my example. You would need a second script like:

    Code:
    lock
    special 0x157
    setvar 0x5000 0x2
    release
    end

    And you would put the offset to that script in the section that says Script Offset 2.

    Lastly you need to fix the script's first offset, because A-Map has a glitch with headers when it compiles them. I use a Hex Editor because my XSE doesn't decompile the script right for me. In a Hex Editor navigate to the script offset 1 for your header.

    Your data should be about 28 #'s long if I'm not mistaken and at the end you should see some F's. Change the first four F's you see to 0's. Save and test your script.
     
    Last edited:

    metapod23

    Hardened Trainer
    673
    Posts
    15
    Years
    • Seen Aug 18, 2016
    Please review https://www.pokecommunity.com/showthread.php?t=302347 this document, the variable 5000 is by no means safe and you should avoid using it at all costs.

    I have used a bunch of different vars/flags that the document says are unsafe, and they seem to usually end up with creation of bad eggs, which isn't ideal, but I haven't found anything game breaking. I didn't remember which ones I used (I only documented using various ones through 6000 -7100 so far), and I don't recall what happens when you use 0x5000, so I can't say if you're exaggerating when you say it should be avoided at all costs.

    Edit: Actually, I have used var 5000 in my game, early on in Viridian City. I have not really found any ill effects from using it. Maybe the creation of a bad egg, idk, but I wouldn't say avoid it all costs. From what I've seen, it hasn't caused any real damage to the game.


    Actually, I hadn't seen that tut, but the info there will be very useful. I might have to go back and change some of the vars I've used if I apply it.
     
    8
    Posts
    9
    Years
    • Seen Apr 7, 2015
    It depends on what item you want to activate and what it's supposed to do. If you wanted the player to appear on his bike after the warp, you would use a header script with special 0x157 (for Fire Red). Is that what you want? For the player to appear on his bike after he is warped?

    Edit: To do that, you would need to make a script that sets a variable before the warp. Say, setvar 0x5000 0x1.

    Be sure to save a backup of your rom before you do any of this.

    So your script would be:

    Code:
    lock
    setvar 0x5001 0x1
    warp 0x4 0x0 0xFF 0x2 0x3
    waitstate
    end

    or something like that (don't forget the waitstate).

    Then you will need a seperate header script in the map you are warping the player to. In the header of the map, go to Map Script and add 02 Validates values ...

    Flag is your var #, in my example 5000 and value is 0001 in my example. You would need a second script like:

    Code:
    lock
    special 0x157
    setvar 0x5000 0x2
    release
    end

    And you would put the offset to that script in the section that says Script Offset 2.

    Lastly you need to fix the script's first offset, because A-Map has a glitch with headers when it compiles them. I use a Hex Editor because my XSE doesn't decompile the script right for me. In a Hex Editor navigate to the script offset 1 for your header.

    Your data should be about 28 #'s long if I'm not mistaken and at the end you should see some F's. Change the first four F's you see to 0's. Save and test your script.

    After quite a long process... I got it to work! There is only one problem I'm wondering if you know the answer to. When I warp, I appear as my normal overworld for about half a second THEN hop on the bike. I'm trying to make it so that when you appear in the new location, you're there on your bike. How could I do this? Would I have to change the order of the scripts or something to make the bike come first? I used the exact same scripts you used, by the way. Only thing I changed was the var 5001, since it wouldn't work unless both scripts were the same var (I used 5000 on both).
     
    16
    Posts
    9
    Years
    • Seen Nov 28, 2015
    For this script, the issue is that the nicknaming portion (#org @name) just brings up a bunch of weird text that doesn't make any sense. If you avoid nicknaming the Pokemon, the script will continue on with the professor and Milton going through the door and hiding away to give off the illusion that they went into the lab. This is the huge issue I am having. Rather than having the main character walk to the doors and warp inside the lab, he instantly warps to the map location and appears on the outside of the building, not even the inside. Does anyone know how to fix this? (Also, I tried to make a script happen off of interacting with a Poke-Ball instead of stepping on a script tile. If that is the issue, than how do I make long scripts like this happen off of interacting with a Poke-Ball?)

    Spoiler:
     
    Last edited:

    metapod23

    Hardened Trainer
    673
    Posts
    15
    Years
    • Seen Aug 18, 2016
    After quite a long process... I got it to work! There is only one problem I'm wondering if you know the answer to. When I warp, I appear as my normal overworld for about half a second THEN hop on the bike. I'm trying to make it so that when you appear in the new location, you're there on your bike. How could I do this? Would I have to change the order of the scripts or something to make the bike come first? I used the exact same scripts you used, by the way. Only thing I changed was the var 5001, since it wouldn't work unless both scripts were the same var (I used 5000 on both).

    I would actually maybe try changing it to 04 validates values ... in the header first. I think 04 does things more instantly, but doesn't execute full scripts or something, so this one should work with it. Let me know if that works.
     
    8
    Posts
    9
    Years
    • Seen Apr 7, 2015
    I would actually maybe try changing it to 04 validates values ... in the header first. I think 04 does things more instantly, but doesn't execute full scripts or something, so this one should work with it. Let me know if that works.

    Hmm... When changing the 02 to 04 setting, when I go on the warp it just gives me a black sceeen when warping into the house. But the palette town music still plays... Any idea?
     

    metapod23

    Hardened Trainer
    673
    Posts
    15
    Years
    • Seen Aug 18, 2016
    Hmm... When changing the 02 to 04 setting, when I go on the warp it just gives me a black sceeen when warping into the house. But the palette town music still plays... Any idea?

    It should work. It's basically the same thing it does in Fire Red to put you on the bike automatically when you are on the bike path. I'd make sure the FF's at the end of the line of data didn't make a re-appearance for Script offset 1, and make sure it ends with four 0's.

    Edit:
    And to make sure everything is correct, if you open the offset for script offset 1 in XSE and go to Tools > Hex Viewer, it should look like this if you are using 0x5001 ...

    Code:
    01 50 00 00 XX XX XX 08 00 00

    With the X's being numbers that equate (reversed) to the offset for your script.
     
    Last edited:
    8
    Posts
    9
    Years
    • Seen Apr 7, 2015
    It should work. It's basically the same thing it does in Fire Red to put you on the bike automatically when you are on the bike path. I'd make sure the FF's at the end of the line of data didn't make a re-appearance for Script offset 1, and make sure it ends with four 0's.

    Edit:
    And to make sure everything is correct, if you open the offset for script offset 1 in XSE and go to Tools > Hex Viewer, it should look like this if you are using 0x5001 ...

    Code:
    01 50 00 00 XX XX XX 08 00 00

    With the X's being numbers that equate (reversed) to the offset for your script.

    Well I checked script 1's offset in a hex editor, and the 0's were still there. So then I checked it in XSE, and the hex was all correct, except instead of: 01 50 00 00 at the beginning like you said, it was 01 50 01 00. There was an 01 after the 50. But im guessing its because 50+01= 5001, my var #. Idk what could be the problem..
     

    metapod23

    Hardened Trainer
    673
    Posts
    15
    Years
    • Seen Aug 18, 2016
    Well I checked script 1's offset in a hex editor, and the 0's were still there. So then I checked it in XSE, and the hex was all correct, except instead of: 01 50 00 00 at the beginning like you said, it was 01 50 01 00. There was an 01 after the 50. But im guessing its because 50+01= 5001, my var #. Idk what could be the problem..

    Actually, that 01 is for the variable's value, which is correct, since we want it to only activate when variable 0x5001 is set to 0001. I had just forgotten. Honestly I'm not sure what could be causing it to not work. Try to recompile the script without the lock and release commands. That could be screwing it up and probably isn't necessary for the 04 script.

    Code:
    special 0x157
    setvar 0x5001 0x2
    end
     
    8
    Posts
    9
    Years
    • Seen Apr 7, 2015
    Actually, that 01 is for the variable's value, which is correct, since we want it to only activate when variable 0x5001 is set to 0001. I had just forgotten. Honestly I'm not sure what could be causing it to not work. Try to recompile the script without the lock and release commands. That could be screwing it up and probably isn't necessary for the 04 script.

    Code:
    special 0x157
    setvar 0x5001 0x2
    end

    Oh my gosh! This did it, it was because of those two commands! The script works perfectly now, the bike appears instantly after the warp is done! All I need to fix is the fact that the overworld faces forward down when warped, but of course he needs to be facing up (this could easily be done with applymovement though).
    Again, thank you soo much for your help!
     

    metapod23

    Hardened Trainer
    673
    Posts
    15
    Years
    • Seen Aug 18, 2016
    Oh my gosh! This did it, it was because of those two commands! The script works perfectly now, the bike appears instantly after the warp is done! All I need to fix is the fact that the overworld faces forward down when warped, but of course he needs to be facing up (this could easily be done with applymovement though).
    Again, thank you soo much for your help!

    No problem. Glad we got it to work the way you wanted it to.
     
    282
    Posts
    9
    Years
    • Seen Nov 28, 2021
    If this script is only meant to run once, you don't need the countpokemon/compare bits. Once the variable is set that part won't run at all anyway (the variable should be 0x4050 by the way, not 4050).

    The flag you're setting for your hidesprite command is way too high.

    In terms of actual commands - lock/lockall should come first in your script, before the applymovements. You don't need faceplayer as this is a script tile, not a person event. Your msgbox @talk2 should be box 0x4 not 0x6 - as that one stays open until closeonkeypress.

    Oh and your givepokemon says lv 8 rather than lv 9 - guess that's a typo!

    Hope this helps~

    Thank you :D :D
     
    417
    Posts
    9
    Years
    • Seen Nov 20, 2016
    Noob question incoming.

    I am using Jpan's Hacked Engine, I used the IPS instead of the tool so I should have everything, if that matters. I was attempting to add the regular Oak's Lab starter scripts in, nearly the same as they are in the original game. But I'm running into a problem where after you look at your Pokemon's stats/after you battle Gary, the game glitches up. Your sprite can't move, but the camera can pan one spot left and one spot right. Furthermore, the sprites get all messed up. Oak's sprite changes into one of his aides, gary becomes the pokedex, the pokedexes get hair on their top, weird image stuff like that.

    I tested out taking away the script where Gary battles you so I can leave the lab. Once I'm out of the lab, I can look at my Pokemon's stats and battle wild Pokemon without anything happening. But even without that battle trap script in the lab, if I look at Pokemon while in Oak's lab, the game does that glitch. This leads me to believe it has something to do with the level scripts triggered on entering the lab, but those are almost copied directly from the original game as well.

    Anyhow, here are the scripts on Pksv:

    Spoiler:


    Aaaand the second map script:

    Spoiler:


    And that's it. Any idea of what could be wrong?
    Also, I used professional header view to get the map script offset, decompile it, and change the 0xFFFF to 0x0. So it isn't that. Thanks in advance!
     
    Last edited:
    282
    Posts
    9
    Years
    • Seen Nov 28, 2021
    Sorry guys I'm back again. I scripted my first trainer battle this evening, and for some reason, XSE keeps adding the number '8' on to the beginning of my offsets.

    For example

    Spoiler:


    Becomes:

    Spoiler:


    What am I doing wrong please?
     

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • Noob question incoming.

    I am using Jpan's Hacked Engine, I used the IPS instead of the tool so I should have everything, if that matters. I was attempting to add the regular Oak's Lab starter scripts in, nearly the same as they are in the original game. But I'm running into a problem where after you look at your Pokemon's stats/after you battle Gary, the game glitches up. Your sprite can't move, but the camera can pan one spot left and one spot right. Furthermore, the sprites get all messed up. Oak's sprite changes into one of his aides, gary becomes the pokedex, the pokedexes get hair on their top, weird image stuff like that.

    I tested out taking away the script where Gary battles you so I can leave the lab. Once I'm out of the lab, I can look at my Pokemon's stats and battle wild Pokemon without anything happening. But even without that battle trap script in the lab, if I look at Pokemon while in Oak's lab, the game does that glitch. This leads me to believe it has something to do with the level scripts triggered on entering the lab, but those are almost copied directly from the original game as well.

    Anyhow, here are the scripts on Pksv:

    Spoiler:


    Aaaand the second map script:

    Spoiler:


    And that's it. Any idea of what could be wrong?
    Also, I used professional header view to get the map script offset, decompile it, and change the 0xFFFF to 0x0. So it isn't that. Thanks in advance!

    Make sure no one has the property "look down" in advancemap, it's bugged. Use No movement instead.

    Sorry guys I'm back again. I scripted my first trainer battle this evening, and for some reason, XSE keeps adding the number '8' on to the beginning of my offsets.

    For example

    Spoiler:


    Becomes:

    Spoiler:


    What am I doing wrong please?

    It's not something wrong. "0x8" signifies that the offset is in the ROM. XSE, when it's decompiling scripts, doesn't check and remove the starting "08" prefix (and it really shouldn't anyways).

    EDIT: Also you cannot use trainer battles in the way you are using it. Try trainerbattle 0x1 0xE 0x0 instead. Also, if you're using that:
    Code:
    trainerbattle 0x1 0xID 0x0 @begin @lost @after
    release
    end
    Where @after will be a script that is run after the battle (rather than a string). Look at Gym leader's scripts and you'll see what I mean.
     
    Status
    Not open for further replies.
    Back
    Top