• 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 Help Thread (DO NOT REQUEST SCRIPTS)

Status
Not open for further replies.
275
Posts
13
Years
    • Seen Oct 9, 2019
    Do I need to call the special before EVERY check? Or is there another problem?
    Before you can check any of the Pokemon's stats, you need to decrypt the Pokemon using special 0x6.

    Basically, Pokemon data is stored in a semi-encrypted form. You use special 0x6 to decrypt a given Pokemon in the party, and then use the other specials to check or modify its attributes as necessary. When you're done making changes, you run special 0x6 again to re-encrypt the Pokemon (because the changes are made to the decrypted data).
     

    shinyabsol1

    Pokemon DarkJasper!?
    333
    Posts
    13
    Years
    • Seen Nov 23, 2022
    sheesh...ever since I started all that honey tree stuff, I've had more questions than ever before...

    Using the copybyte command, I want to copy a byte at a location into a variable. But the copybyte command doesn't allow for copying from pointer to variable. So:

    How do I find the address of a variable (any variable that I should want)?

    Thanks.
     
    275
    Posts
    13
    Years
    • Seen Oct 9, 2019
    sheesh...ever since I started all that honey tree stuff, I've had more questions than ever before...

    Using the copybyte command, I want to copy a byte at a location into a variable. But the copybyte command doesn't allow for copying from pointer to variable. So:

    How do I find the address of a variable (any variable that I should want)?
    That's a tricky task, since most variables are DMA-protected (their offsets always change).

    The easiest solution would be to use one of the game's temporary variables (whose locations don't change, ever) for copybyte, and then use copyvar to transfer the value(s) to the persistent-but-protected vars.

    Example:

    Code:
    copybyte 0x020370D0 [lower byte]
    copybyte 0x020370D1 [higher byte]
    copyvar 0x4000 0x800D

    That copies some value into LASTRESULT (0x800D), a temporary variable whose location never changes. Copyvar then transfers that value into one of the normal variables.

    Oh, and one thing to remember when copying bytes like that: for multi-byte values, the bytes are stored backwards. A value of 0x1234 is stored as "34 12".
     
    73
    Posts
    14
    Years
    • Seen Aug 31, 2014
    Before you can check any of the Pokemon's stats, you need to decrypt the Pokemon using special 0x6.

    Basically, Pokemon data is stored in a semi-encrypted form. You use special 0x6 to decrypt a given Pokemon in the party, and then use the other specials to check or modify its attributes as necessary. When you're done making changes, you run special 0x6 again to re-encrypt the Pokemon (because the changes are made to the decrypted data).


    So, to make sure I'm a) understanding you correctly, and b) understanding how it works, I should use enter this in the beginning and before every end command:

    Code:
    special 0x6

    Or am I wrong?
     

    shinyabsol1

    Pokemon DarkJasper!?
    333
    Posts
    13
    Years
    • Seen Nov 23, 2022
    DavidJCobb said:
    That's a tricky task, since most variables are DMA-protected (their offsets always change).

    The easiest solution would be to use one of the game's temporary variables (whose locations don't change, ever) for copybyte, and then use copyvar to transfer the value(s) to the persistent-but-protected vars.

    That copies some value into LASTRESULT (0x800D), a temporary variable whose location never changes. Copyvar then transfers that value into one of the normal variables.

    Oh, and one thing to remember when copying bytes like that: for multi-byte values, the bytes are stored backwards. A value of 0x1234 is stored as "34 12".

    Ok, I understand what I need to do now, but:

    In the script I am working on, LASTRESULT is being used in such a way that prevents me from using it for this situation. So is there another temporary variable that is free for me to use (and if so, what is its address)?

    On another subject, I just remembered another question that I have:

    Is there a way to make it so that a script is constantly active? What I mean is that it is always checking (and updating) itself based on something else (for example, the rtc hour byte)?

    Thanks.
     
    275
    Posts
    13
    Years
    • Seen Oct 9, 2019
    Ok, I understand what I need to do now, but:

    In the script I am working on, LASTRESULT is being used in such a way that prevents me from using it for this situation. So is there another temporary variable that is free for me to use (and if so, what is its address)?
    For vars 0x8000 to 0x800D, this formula works (thank HackMew, not me, for it):

    0x020270B6 + ([var number in hex] * 2)

    Is there a way to make it so that a script is constantly active? What I mean is that it is always checking (and updating) itself based on something else (for example, the rtc hour byte)?
    Nope. Even if you could, the script would cause performance issues because scripts cannot run asynchronously (that is, in the background without interrupting other functions).

    The best way to do it would be to have an efficient script run very frequently, i.e. every five or so steps.
     

    metapod23

    Hardened Trainer
    673
    Posts
    15
    Years
    • Seen Aug 18, 2016
    So, to make sure I'm a) understanding you correctly, and b) understanding how it works, I should use enter this in the beginning and before every end command:

    Code:
    special 0x6

    Or am I wrong?

    You would start with this:

    Code:
    setvar 0x8004 0x0
    special 0x6

    ^ This would set the first Pokemon in your party to be decrypted. Then run the check happiness script, and make sure you end with:

    Code:
    special 0x6

    again at the end, or your Pokemon could get turned into an egg.


    Ok, I understand what I need to do now, but:

    In the script I am working on, LASTRESULT is being used in such a way that prevents me from using it for this situation. So is there another temporary variable that is free for me to use (and if so, what is its address)?

    On another subject, I just remembered another question that I have:

    Is there a way to make it so that a script is constantly active? What I mean is that it is always checking (and updating) itself based on something else (for example, the rtc hour byte)?

    Thanks.

    There is a walking script in JPAN's hacked engine that basically runs a script every time you take a step. For instance, I used it to make this event:



    It's how Dodrio takes a step every time you do. It's special 0x81.
     
    73
    Posts
    14
    Years
    • Seen Aug 31, 2014
    Code:
    #org 0x81C2E0
    lock
    faceplayer
    bufferfirstpokemon 0x00
    setvar 0x8004 0x0
    special 0x6
    special2 0x8004 0xd
    compare 0x8004 0xFF
    if 0x4 goto @love
    compare 0x8004 0x96
    if 0x4 goto @adore
    compare 0x8004 0x4B
    if 0x4 goto @like
    compare 0x8004 0x28
    if 0x4 goto @meh
    msgbox @dislike 0x6
    callstd 0x6
    special 0x6
    release
    end
    
    #org @love
    msgbox @love2 0x6
    callstd 0x6
    special 0x6
    release
    end
    
    #org @love2
    = Your \v\h02 loves you!
    
    #org @adore
    msgbox @adore2 0x6
    callstd 0x6
    special 0x6
    release
    end
    
    #org @adore2
    = Your \v\h02 adores you!
    
    #org @like
    msgbox @like2 0x6
    callstd 0x6
    special 0x6
    release
    end
    
    #org @like2
    = Your \v\h02 likes you!
    
    #org @meh
    msgbox @meh2 0x6
    callstd 0x6
    special 0x6
    release
    end
    
    #org @meh2
    = Your \v\h02 is indifferent to you.
    
    #org @dislike
    = Your \v\h02 doesn't like you.

    Okay, I ran into a huge problem with this: When the script runs, it copies the pokemon in the first slot into the second slot. I can't figure out why it's doing that and how to stop it. I assume it has something to do with the goto sections.
     
    275
    Posts
    13
    Years
    • Seen Oct 9, 2019
    Okay, I ran into a huge problem with this: When the script runs, it copies the pokemon in the first slot into the second slot. I can't figure out why it's doing that and how to stop it. I assume it has something to do with the goto sections.
    Reread the documentation that came along with JPAN's engine.

    Basically, special 0x6 will do the following:

    • If a Pokemon has not already been decrypted, then the Pokemon in slot 0x8004 of the party will be decrypted.
    • If a Pokemon has already been decrypted, then it will be re-encrypted and it will overwrite slot 0x8004 of the party. The decrypted copy of the data is then deleted.
    You need to reset 0x8004 to point to the proper party slot before you call special 0x6 at the end of the script.
     

    shinyabsol1

    Pokemon DarkJasper!?
    333
    Posts
    13
    Years
    • Seen Nov 23, 2022
    DavidJCobb said:
    For vars 0x8000 to 0x800D, this formula works (thank HackMew, not me, for it):

    0x020270B6 + ([var number in hex] * 2)

    Thanks! I'm surprised I didn't find this formula when I searched...

    DavidJCobb said:
    Nope. Even if you could, the script would cause performance issues because scripts cannot run asynchronously (that is, in the background without interrupting other functions).

    The best way to do it would be to have an efficient script run very frequently, i.e. every five or so steps.


    Oh well, I knew it would be a long shot for something like this to work, but I wanted to make sure anyways.

    metapod23 said:
    There is a walking script in JPAN's hacked engine that basically runs a script every time you take a step.

    Right. This is the closest thing to a script that runs all the time. What I was hoping for was a way to make it run even when the game is turned off, which I have now been confirmed is not possible.

    metapod23 said:
    For instance, I used it to make this event:

    It's how Dodrio takes a step every time you do. It's special 0x81.

    Oh that's how it was done? I was just playing AshGray the other day and I completed that part. Good luck on your hack, metapod23!
     
    1
    Posts
    12
    Years
    • Seen Apr 6, 2014
    Working on a Fire Red rom (BPRE) with a RTC and using XSE. (probably old, 1.1.1)

    I've been trying to make a berry tree (as a signpost) which renews once everyday ala G/S/C style. My problem is that instead of giving one berry a day the tree gives one berry and then stops giving berries completely. Unless checked at 12am, where it gives berries nonstop until 2am, then goes back to giving no berries at all. However if it's not checked between 12am and 2am it goes on not giving berries at all.

    I feel like I'm missing something very simple here but i haven't been able to spot it yet. Maybe I'm even going about it the wrong way, this is the first script I've ever written and I've been trying to wrap my head around it for a couple days now to no avail. Hopefully you guys can help with this.

    Spoiler:
     
    2
    Posts
    13
    Years
    • Seen Aug 19, 2015
    So I'm having trouble with this script. Whenever I step on the box, nothing happens.
    Code:
    #org $script
    jingle
    message $hey
    $hey 1 = Hey ginchoob!
    boxset 6
    clearflag 0x1220
    showsprite 1
    applymovement 0xFF $walkup
    $walkup 1 ; #binary 0x62 0xFE
    pausemove 0
    applymovement 1 $walkdown
    $walkdown 1 ; #binary 0x10 0x10 0x10 0x10 0x10 0x10 0x03 0xFE
    pausemove 0
    message $t1
    $t1 1 = Kickback gave you a Pokemon?\n HA! That was a mistake.
    boxset 6
    trainerbattle 0x145 0x01 $win $lose
    $win 1 = How could I lose?'
    $lose 1 = Told you I'd win.
    message $t2
    $t2 1 = Hmph! I'll beat you next time.
    boxset 6
    applymovement 1 $walk
    $walk 1 ; #binary 0x11 0x11 0x11 0x11 0x11 0x11 0x01 0xFE
    pausemove 0
    removesprite 1
    setflag 0x1220
    setvar 0x6002 0x0001 
    release
    end
     
    275
    Posts
    13
    Years
    • Seen Oct 9, 2019
    Working on a Fire Red rom (BPRE) with a RTC and using XSE. (probably old, 1.1.1)

    I've been trying to make a berry tree (as a signpost) which renews once everyday ala G/S/C style. My problem is that instead of giving one berry a day the tree gives one berry and then stops giving berries completely. Unless checked at 12am, where it gives berries nonstop until 2am, then goes back to giving no berries at all. However if it's not checked between 12am and 2am it goes on not giving berries at all.

    I feel like I'm missing something very simple here but i haven't been able to spot it yet. Maybe I'm even going about it the wrong way, this is the first script I've ever written and I've been trying to wrap my head around it for a couple days now to no avail. Hopefully you guys can help with this.
    I'm just guessing here, but a quick glance at your script does reveal one problem.

    LASTRESULT, like all other script variables, is a two-byte number... But you're only modifying one byte. So if LASTRESULT was set to 0x1234 and the byte you are copying is 0xAA, LASTRESULT will be set to 0x12AA.

    The simple solution is either to copy two bytes, or to set LASTRESULT to 0x0000 before copying the single byte.
     
    4
    Posts
    12
    Years
    • Seen Dec 22, 2011
    Ive been searching around for a way to force an egg to hatch through an XSE script, and i came across Special 0x0C2. Now, special 0x0C2 is supposed to hatch an egg, nickname code an animation sequence all included. But whenever i go to test it (egg in hand), the script hatches an egg from my egg. Am i using the special wrong? any pointers?
     
    275
    Posts
    13
    Years
    • Seen Oct 9, 2019
    Ive been searching around for a way to force an egg to hatch through an XSE script, and i came across Special 0x0C2. Now, special 0x0C2 is supposed to hatch an egg, nickname code an animation sequence all included. But whenever i go to test it (egg in hand), the script hatches an egg from my egg. Am i using the special wrong? any pointers?
    How did you receive the egg? "Giveegg", your own script using special B8, or the daycare script?

    If you wrote your own script, I think you have to call special B9 after you call special B8.

    Have you tried placing a waitstate command after special 0xC2? The game's own egg-hatching script (at 0x1BF546) does this.
     

    metapod23

    Hardened Trainer
    673
    Posts
    15
    Years
    • Seen Aug 18, 2016
    Ive been searching around for a way to force an egg to hatch through an XSE script, and i came across Special 0x0C2. Now, special 0x0C2 is supposed to hatch an egg, nickname code an animation sequence all included. But whenever i go to test it (egg in hand), the script hatches an egg from my egg. Am i using the special wrong? any pointers?

    I have done this in my hack. First, you need to set variable 0x8004 to the slot # of the egg. The only problem with this is that the player may have moved the egg to any slot in his party, unless the give egg event and the hatch egg event are all part of the same script (unlikely, though).

    So here's how I did it, assuming you're using Fire Red. You will need to use JPAN's hacked engine. You will need to use the decrypt special 0x6 and then special 0x18. Special 0x18 will get the species # of the egg. Then you can have the script continue if the species # matches the Pokemon you gave as an egg to the player.

    Next use special 0x147. This will check to see if the Pokemon is an egg. It will store 0x19c in lastresult if it is, so you then compare lastresult 0x19c and if it's equal, you then proceed to use special 0xc2.

    Here's a sample of the script I used, in spoilers:

    Spoiler:


    I'm not sure it's the most efficient way to use the special, but it's the best way I could figure out.
     
    73
    Posts
    14
    Years
    • Seen Aug 31, 2014
    Okay, so I'm having (yet another) problem with the fantastic IV Checker hacked engine special.

    Code:
    #org @start
    lock
    faceplayer
    bufferfirstpokemon 0x00
    setvar 0x8004 0x0
    special 0x6
    setvar 0x8004 0x2
    special2 0x8004 0x8
    compare 0x8004 0x1E
    if 0x4 goto @best
    compare 0x8004 0x18
    if 0x4 goto @above
    compare 0x8004 0x5
    if 0x4 goto @average
    compare 0x8004 0x8
    if 0x4 goto @below
    msgbox @pathetic 0x6
    callstd 0x6
    setvar 0x8004 0x0
    special 0x6
    release
    end

    If the pokemon bypasses all the checks (Aka, has a 0-7 defense IV), the text box pops up, has a bunch of random symbols after the text, then ends itself. My Beta Tester said no noticable changes occurred: His Mankey is still a Mankey, not an egg, and none of his other people got replaced by a copy of the mankey (which was a problem I had earlier). Since this defense script is the base of all the other IV check scripts for myself, I'm trying to figure out what went wrong. I assume it's after "msgbox @pathetic 0x6".

    Before I gave out the Beta, I tested this specific script and found two things:
    1) I had put 0x5 instead of 0xF
    2) The branches worked perfectly. I tried maybe 25 times and could never get a pokemon with such a crap defense IV, but the other offshoots (30+, 25+, 15+--I think. I'm too lazy to decode the hex) never had that problem. It's only the all-checks failed branch. I'm thinking it's because I used the same variable for special 6 and special 8, but I'm not confident to rely on occum's razor.
     
    18
    Posts
    15
    Years
  • 1. In XSE, what is the differences among pokemart, pokemart2 and pokemart3?
    2. I want to make a shop which sells the decoration for secret bas only, but I can only find the list of items in the XSE script tutorial, not the decoration list. Where can I find the list of decoration?
     
    Status
    Not open for further replies.
    Back
    Top