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

[XSE] Scripting Tutorial

148
Posts
17
Years
    • Age 29
    • Seen Nov 21, 2023
    I have a question. I'm pretty new to scripting, but I'm slowly getting it. So I want to have a script where somebody enters the building while you're talking to somebody. So they'll appear right at the entrance. How do I keep the sprite hidden so I can still walk through the space as if they were there, but have them appear during the script? Would I do a hidepsrite and a showsprite? Or a movesprite?
     
    1,309
    Posts
    12
    Years
    • She/Her
    • Seen Nov 24, 2023
    I have a question. I'm pretty new to scripting, but I'm slowly getting it. So I want to have a script where somebody enters the building while you're talking to somebody. So they'll appear right at the entrance. How do I keep the sprite hidden so I can still walk through the space as if they were there, but have them appear during the script? Would I do a hidepsrite and a showsprite? Or a movesprite?
    Hi! Where does the sprite appear from - are they already on the map? Having them randomly appear out of nowhere at the entrance of the building might not look too natural. If you want to keep the NPC hidden until you want them to appear, you could set the flag that serves as their person event ID in AdvanceMap (this part outlined in red below).
    PVhooGB.png

    Then when you want them to appear, use clearflag and showsprite, have them enter the building, and then hidesprite and setflag again. Whether or not you need movesprite depends on where the NPC is located in the first place.
     
    148
    Posts
    17
    Years
    • Age 29
    • Seen Nov 21, 2023
    Hi! Where does the sprite appear from - are they already on the map? Having them randomly appear out of nowhere at the entrance of the building might not look too natural. If you want to keep the NPC hidden until you want them to appear, you could set the flag that serves as their person event ID in AdvanceMap (this part outlined in red below).
    PVhooGB.png

    Then when you want them to appear, use clearflag and showsprite, have them enter the building, and then hidesprite and setflag again. Whether or not you need movesprite depends on where the NPC is located in the first place.
    Yeah it's supposed to look like he's entering the building halfway through the script, so he'll have to appear at the entrance.
     
    1,309
    Posts
    12
    Years
    • She/Her
    • Seen Nov 24, 2023
    Yeah it's supposed to look like he's entering the building halfway through the script, so he'll have to appear at the entrance.
    Ooh sorry, should have elaborated on "are they already on the map" - I meant whether they were supposed to be located somewhere close to the building and then walk up to the door first before entering the building or just appear, but you've clarified that now anyway haha. Well, if you want the NPC to be completely hidden until you make them show up and you want it to appear right at the entrance when you do, then have it placed outside the building, hidden with the set flag. Then in your script where the player is talking to the person, do the clearflag then showsprite to make them show up, have them enter the building, then hidesprite and set the flag again. If I'm correctly understanding exactly what it is you want to happen.
     
    11
    Posts
    5
    Years
    • Seen Sep 3, 2020
    Hi I'm pretty new to scripting. I need some help I wanna make a basic npc healing your party script. Can anyone help please?
     
    1,309
    Posts
    12
    Years
    • She/Her
    • Seen Nov 24, 2023
    Hi I'm pretty new to scripting. I need some help I wanna make a basic npc healing your party script. Can anyone help please?

    Hi! You'll want to use special 0x0 in your script, that'll heal the player's party for you. =)
     
    2
    Posts
    5
    Years
  • i need help with this

    #dynamic 0x800000

    #org @inicio
    lockall
    setvar 0x4067 0x1
    special 0x113
    applymovement 0x7F @entrada
    waitmovement 0x7F
    special 0x114
    applymovement 0x7F @terremoto
    waitmovement 0x7F
    special 0x114
    sound 0x6A
    fadescreen 0x3
    hidesprite 0x3
    fadescreen 0x2
    movesprite 0x2 0xA 0x9
    releaseall
    end

    #org @entrada
    #raw 0x11
    #raw 0x11
    #raw 0x11
    #raw 0x11
    #raw 0x11
    #raw 0x11

    #org @terremoto
    #raw 0x0A
    #raw 0x0B
    #raw 0x0B
    #raw 0x0A
    #raw 0x0A
    #raw 0x0B
    #raw 0x0B
    #raw 0x0E
    #raw 0x0E
    #raw 0x0F
    #raw 0x0F
    #raw 0x0E
    #raw 0x0E
    #raw 0x0F
    #raw 0x0F
    #raw 0x012
    #raw 0x012
    #raw 0x013
    #raw 0x013
    #raw 0x012
    #raw 0x012
    #raw 0x013
    #raw 0x013
    #raw 0x01F
    #raw 0x01F
    #raw 0x020
    #raw 0x020
    #raw 0x01F
    #raw 0x01F
    #raw 0x020
    #raw 0x020
    #raw 0x01F
    #raw 0x01F
    #raw 0x020
    #raw 0x020
    #raw 0x01F
    #raw 0x01F
    #raw 0x020
    #raw 0x020
    #raw 0x01F
    #raw 0x01F
    #raw 0x020
    #raw 0x020
    #raw 0x01F
    #raw 0x01F
    #raw 0x020
    #raw 0xFE



    The problem is that movesprite doesn´t work. I´ve also tried with movesprite2, applymovement, hide/showsprite (my mini didn´t disappear at the begining so i couldn´t use showsprite)
    I also have another problem: when the script finish, i control the camera, but not the player
     
    1,309
    Posts
    12
    Years
    • She/Her
    • Seen Nov 24, 2023
    i need help with this

    ...

    The problem is that movesprite doesn´t work. I´ve also tried with movesprite2, applymovement, hide/showsprite (my mini didn´t disappear at the begining so i couldn´t use showsprite)
    I also have another problem: when the script finish, i control the camera, but not the player

    Hey! Sorry, I'm having a bit of trouble understanding exactly what it is you're wanting to happen or what the exact issues are - you want to move a sprite to a specific location at the end of the script, is that right?

    Firstly, you were missing a raw 0xFE on one of your movements and also you had an extra special 0x114 line that you didn't need, I've fixed that for you in the spoiler so you can see what I mean.

    If you want to move a sprite to a particular location by the time the var is set/the script has finished running you'll want to use movesprite2 for that - this page explains how to use it in more detail. The change in location usually only happens upon re-entering the map, it's been a while since I hacked FR but if I recall correctly special 0x8E refreshes the screen, you could try that after your showsprite line and see if that works better for you?

    Spoiler:
     
    8
    Posts
    12
    Years
    • Seen Feb 24, 2022
    I'm copying this into an rtf file with the images and everything for my own perusal and to add it to my .chm help file for modding I'm working on for personal use...hey if you want once im finished I'll compile this tutorial into an interactive executable and upload it and link you to it...more tutorials should be this in depth and this beautiful...I wish an asm tutorial was this well put together...but oh well...


    honestly a group of seasoned modders should write a comprehensive set of high quality tutorials...then convert it into an executable file with search functions and interlinked pages...a library of modding knowledge that could be launched and explored...that would work well on the PGE external programs menu...one button to launch a library of knowledge for beginning hackers and veterans alike...just an idea...an offline modding wiki executable
     
    Last edited:
    1,309
    Posts
    12
    Years
    • She/Her
    • Seen Nov 24, 2023
    I'm copying this into an rtf file with the images and everything for my own perusal and to add it to my .chm help file for modding I'm working on for personal use...hey if you want once im finished I'll compile this tutorial into an interactive executable and upload it and link you to it...more tutorials should be this in depth and this beautiful...I wish an asm tutorial was this well put together...but oh well...


    honestly a group of seasoned modders should write a comprehensive set of high quality tutorials...then convert it into an executable file with search functions and interlinked pages...a library of modding knowledge that could be launched and explored...that would work well on the PGE external programs menu...one button to launch a library of knowledge for beginning hackers and veterans alike...just an idea...an offline modding wiki executable

    Thank you! What you're working on sounds really interesting. I'm still adding little bits to this here and there, but I'd love to have a link when you're done, an interactive guide that could be used offline sounds great, thanks for letting me know. <3
     
    1,309
    Posts
    12
    Years
    • She/Her
    • Seen Nov 24, 2023
    Trigger Scripts
    What's a trigger script, you might be wondering? By a "trigger script", I mean those little green "S" tiles visible in AdvanceMap's Events tab. When your player steps on these, the script it contains will run. I'll show you how to set these up step by step!

    First of all, you'll have to choose a variable to use. For example purposes, we'll be using var 0x4050. I'll draw your attention to the "Var value" box, outlined in red below:

    GHvkvb1.png

    Currently, the value is set to 0. This means that the script will only run while var 4050 has a value of 0. Let's say we want the script to run only once:
    Code:
    #dynamic 0x800000
    
    #org @main
    lock
    msgbox @msg 0x6
    setvar 0x4050 0x1
    release
    end
    
    #org @msg
    = This is a trigger.
    In this script, we've set var 0x4050's value to 1. Since the variable's value is no longer 0, the script will not run again.

    If you want your trigger script to repeat itself until the variable is set somewhere else in another script, you can do this too. Maybe you want it to act as a roadblock until your player has completed a certain event.
    Code:
    #dynamic 0x800000
    
    #org @main
    lock
    msgbox @msg 0x6
    applymovement 0xff @stepdown
    waitmovement 0x0
    setvar 0x4050 0x0
    release
    end
    
    #org @msg
    = This is a trigger.
    
    #org @stepdown
    #raw 0x08
    #raw 0xfe
    Since this time we're keeping the variable as 0, that means this script will run every time the player steps on the "S" tile until the variable has a new value other than 0.

     
    1,309
    Posts
    12
    Years
    • She/Her
    • Seen Nov 24, 2023
    Screen Colour Filters
    FireRed has a nice little quirk that allows you to change the screen's colours to sepia tones or black and white after a warp.
    If you're hacking Emerald you won't be able to use these.

    For a black & white filter, you'd use the following.
    Code:
    writebytetooffset 0x1 0x2036E28
    [[URL="https://www.pokecommunity.com/showpost.php?p=9773697&postcount=17"]Type Of Warp[/URL]] 0x[Map Bank] 0x[Map Number] 0x[Warp Number] 0x0 0x0
    A fuller demonstration script:
    Code:
    '---------------
    #dynamic 0x800000
    
    #org @start
    lock
    faceplayer
    msgbox @msg 0x4
    closeonkeypress
    writebytetooffset 0x1 0x2036E28
    warpmuted 0x3 0x1 0x0 0x0 0x0
    release
    end
    
    #org @msg
    = Applying black and white filter.
    I1vu96t.gif

    For a sepia filter, you'd use this.
    Code:
    writebytetooffset 0x2 0x2036E28
    [[URL="https://www.pokecommunity.com/showpost.php?p=9773697&postcount=17"]Type Of Warp[/URL]] 0x[Map Bank] 0x[Map Number] 0x[Warp Number] 0x0 0x0
    And again, a more detailed example:
    Code:
    '---------------
    #dynamic 0x800000
    
    #org @start
    lock
    faceplayer
    msgbox @msg 0x4
    closeonkeypress
    writebytetooffset 0x2 0x2036E28
    warpmuted 0x3 0x1 0x0 0x0 0x0
    release
    end
    
    #org @msg
    = Applying sepia filter.
    qmtQQMS.gif

    To go back to normal, just substitute the value following writebytetooffset to 0x0:
    Code:
    writebytetooffset 0x0 0x2036E28
    [[URL="https://www.pokecommunity.com/showpost.php?p=9773697&postcount=17"]Type Of Warp[/URL]] 0x[Map Bank] 0x[Map Number] 0x[Warp Number] 0x0 0x0

    0ETs6g9.gif

     
    1,309
    Posts
    12
    Years
    • She/Her
    • Seen Nov 24, 2023
    Fadescreen Effects
    Just when it seems as if I'm getting closer to being finished with this tutorial, I think of something else I should have added!
    It's easy to give the overworld a "fading out" effect - useful for cutscenes and such - by using the fadescreen command which looks like this:
    Code:
    fadescreen 0x[Fade Type Number]
    What do I mean by "fade type number"? Here are the numbers for fading out to black and then reverting to normal:
    Avara said:
    fadescreen 0x1 – Screen fades to black.
    fadescreen 0x0 - Screen fades from black back to normal.
    Time for an example script and gif so you can see how it looks in-game!
    Code:
    '---------------
    #dynamic 0x800000
    
    #org @start
    lock
    faceplayer
    msgbox @msg 0x6
    fadescreen 0x1
    fadescreen 0x0
    release
    end
    
    #org @msg
    = Screen fading to black.
    f6x4s67.gif

    It's also possible to create a white version of the same effect by swapping out the 0x1 and 0x0 for 0x3 and 0x2 respectively.
    Code:
    '---------------
    #dynamic 0x800000
    
    #org @start
    lock
    faceplayer
    msgbox @msg 0x6
    fadescreen 0x3
    fadescreen 0x2
    release
    end
    
    #org @msg
    = Screen fading to white.
    ZdB4Rcu.gif

    To serve as a reminder, here is a list of all the fadescreen types for quick reference:
    Avara said:
    0x3 – Screen fades to white.
    0x2 – Screen fades from white back to normal.

    0x1 – Screen fades to black.
    0x0 - Screen fades from black back to normal.
     
    142
    Posts
    10
    Years
  • is there any way to check the weather and do things based on it? for example i would like a trainer to use a different team depending on if the weather is sunny or rainy.
    so with a hypothetical command "checkweather" it would be

    checkweather
    if 0xC goto blabla

    or

    checkweather 0xC
    if 0x1 goto blabla
     
    1
    Posts
    5
    Years
    • Seen Sep 7, 2019
    I Am trying to make a command to work after i am talking to an other sprite (person), for exaple:

    I want 0x1200 to say a msg @talk1 0x6
    Then when i talk to an other person 0x1201,
    Then 0x1200 @talk1 0x6 stops and @talk2 0x5 starts, then stops and @talk3 0x6 starts, then @talk3 stop and @talk1 0x6 starts.
    When i talk to an other sprite (person) 0x1202,
    Then 0x1200 @talk1 0x6 stops and @talk2 0x5 starts, then stops and
    @talk4 0x6 starts, then @talk4 0x6 stop and @talk1 0x6 starts.
    Then 0x1200 When i talk to an other sprite (person) 0x1203,
    @talk1 0x6 stop and @talk2 0x5 starts, then stops and
    @talk5 0x6 starts, then @talk4 0x6 stop and @talk1 0x6
    starts.

    Can someone helps me please?
     
    Last edited:
    3
    Posts
    4
    Years
    • Seen Mar 1, 2020
    Hello, this is a great tutorial but I am having an issues I was hoping you could help with. The problem is that I have having an NPC ignore my "lock" command in a longer script. The script is for him to give me a Pokemon, then a notification appears and a fanfare plays, then I can nickname the Pokemon, and finally he tells me to take good care of his Pokemon. But when the notification appears, the NPC is released from the "lock" and starts walking around. So, when he tells me to take good care of his Pokemon, he isn't standing by me anymore, which is weird. How can I get him to stay locked until the script is totally complete? Here is my code:
    Code:
    #dynamic 0x800000
    #org @givepokemon
    lock
    faceplayer
    checkflag 0x100
    if 0x0 goto @give
    msgbox @2 0x2
    end
    
    #org @give
    msgbox @1 0x6
    givepokemon 0x7B 0x5 0x44 0x0 0x0 0x0
    fanfare 0x13E             //Plays the player received pokemon fanfare
    msgbox @notify 0x4
    setflag 0x828
    waitfanfare
    closeonkeypress 
    setflag 0x100
    msgbox @qname 0x5         //Asks the player if they want to nickname their pokemon
    compare LASTRESULT 0x1    //Checks to see if the player selected 'Yes'
    if 0x1 gosub @nickname    //If yes then the @nickname script will run and then return
    msgbox @3 0x6
    release
    end
    
    #org @nickname
    countpokemon              // Stores 0x1 in LASTRESULT since we only have one pokemon now
    subvar LASTRESULT 0x1     // Subtracts 0x1 from the value stored in LASTRESULT, so LASTRESULT is now 0x0
    copyvar 0x8004 LASTRESULT // Copies LASTRESULT into 0x8004. Both are now 0x0
    fadescreen 0x1
    special 0x9E              // 0x8004 is needed for special 0x9E
    waitstate
    return
    
    #org @1
    = Please take care of my Scyther\nfor me.
    
    #org @2
    = How is my Scyther doing [player]?
    
    #org @notify
    = [Player] received SCYTHER!
    
    #org @qname
    = Would you like to give SCYTHER a\nnickname?
    
    #org @3
    = Take good care of my Scyther!
     
    124
    Posts
    8
    Years
    • Seen Apr 5, 2024
    I guess if u kno when the npc isnt locked anymore, then add the lock command after you receive the item/pokemon...i had a similar issue, but i think when u closemsg/closeonkeypress u also release anything else thats locked...u should just add another lock, no harm in doing so
     
    Last edited:
    3
    Posts
    4
    Years
    • Seen Mar 1, 2020
    That is what I wound up doing, and it worked.

    Code:
    #org @give
    msgbox @1 0x6
    lock
    givepokemon 0x7B 0x5 0x44 0x0 0x0 0x0
    fanfare 0x13E             //Plays the player received pokemon fanfare
    msgbox @notify 0x4

    I don't know why that msgbox unlocked him but it did. Kinda painful to figure out what was going on. Thanks for chiming in.
     
    Last edited:
    4
    Posts
    4
    Years
    • Seen Aug 5, 2020
    Hi there, I'm having trouble with XSE. When I write a script then go to compile it the scripts I'm writing are changing.
    for example here's what I scripted.
    Spoiler:

    But when I compile the script and open it again it comes out like this
    Spoiler:

    I've "highlighted" the changes so it's easier to see.
    Please help
     
    Last edited:

    Burtle

    Discord: Burtle#6904
    30
    Posts
    4
    Years
    • Seen Dec 8, 2019
    Please help

    Try
    Code:
    #org 0x800A00
    lock
    faceplayer
    msgbox 0x8800A85 MSG_FACE '"Huh oh hi my name's BELL\poh you h..."
    removeitem 0x15D 0x1
    msgbox 0x8800AF6 MSG_FACE '"Thank you\pOh, I know have this I ..."
    giveitem 0x6D 0x1 MSG_OBTAIN
    msgbox 0x8800B76 MSG_FACE '"Well I should be off now, bye!"
    applymovement MOVE_PLAYER 0x8800C6C
    waitmovement 0x0
    applymovement 0x3 0x8800C70
    waitmovement 0x0
    hidesprite 0x3
    setflag 0x39
    showsprite 0x4
    clearflag 0x32
    applymovement 0x4 0x8800FB5
    waitmovement 0x0
    applymovement MOVE_PLAYER 0x880107A
    waitmovement 0x0
    msgbox 0x8800D61 MSG_FACE '"Hello there, that Item your\nholdi..."
    trainerbattle 0x3 0x8 0x0 0x8800EFC
    msgbox 0x8800F1E MSG_FACE '"Well now\pI guess I'll take my lea..."
    applymovement 0x4 0x8800FC6
    waitmovement 0x0
    setflag 0x35
    goto @end
    
    #org @end
    releaseall
    end
    ?
     
    Back
    Top