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

Having fun with level scripts

xGal

Mhm
241
Posts
12
Years
Hello.

Have you ever noticed that scripts aren't working when you try to put them right on the warp spot?

Well, I don't know the reason for that, but to make this work, you only need basic XSE scripting skills and minimal Advance Map skills.

This called as "Level-Script", or "Map-Script". It "tells" the game that when you enter X map, Y script will run.

What we need:
- XSE (Download it from HackMew's Tools Factory. Link: http://www.pokecommunity.com/showthread.php?t=85025)
- A-Map (I'll be using 1.95 Open Beta, you could download it from here: http://www.pokecommunity.com/showthread.php?t=124279)
- A brain (most important thing)

___________________________________________________________________________________

Oky, let's start!

[01] "setmaptile" script

This is easy. It is used for auto-setmaptile scripts... You don't understand, right?
For example, let's take RSE. On Route 111, there's a big rock WITHOUT door, which meants it's impossible unless you unlock it (I won't, and I will repeat it, I WON'T answer if you wanna find out how to unlock them). After you unlock, a door appears on the giant rock on Route 111 (and other routes I don't rememmber the full list). Well, here you go! The "setmaptile script"!

For doing that, you need some XSE knowledge... Sigh, or just use Diego's tutorial (http://www.pokecommunity.com/showthread.php?t=164276)

Okay, here's an example for a script:
Code:
#dynamic 0x800000

#org @start
setmaptile 0xX 0xY 0xTile 0xPassable/not 
release
end
That's it! No lock required!
If you want that it will be active only while a flag is on, simply put
Code:
 checkflag 0xFLAG
if 0x1 goto @pointer
Simple, wasn't it?

___________________________________________________________________________________

[02] Validates values, loads handler to 0x03000EB0 (playback)

Well, here we go...

This is to make the "real" scripts (like applymovement and stuff)...

Example for a quick script:

Code:
dynamic 0x800000

#org @start
setvar 0x7000 0x1
lockall
applymovement 0x1 @movement1
waitmovement 0x0
msgbox @1 0x6
releaseall
end

#org @movement1
#raw 0x1F 'Run Left #raw 0xFE 'End
 

#org @1
= I ran left during the\nLevel-Script!\pIsn't that awesome!?
setvar 0x(var to set) 0x(1 => Will happen once, 0 => Will happen every time you enter the map, i think so)


lockall => Locks all the events happening in the map


applymovement => Just an applymovement script, view Diego's scripting tutorial for more information.


waitmovement => Applies the applymovement, by setting a Sprite that would wait for the movement. Simply put 0x0 after it.


msgbox => Just a regular msgbox, nothing special.


releaseall => Releases all the events that were locked by the "lockall" command.


end => Ends the script.


Rememmber - You don't need the "checkflag" command here, only the "setvar" command (unless you wish a thing to happen only while a flag is on)


Alrighty, when you're done, simply compile the script. Now, open up A-Map, navigate to any map you want to have the script. Now, go to the "Header" tab. Remove ALL the scripts that are in the map and add a script "Validates values, loads handler to 0x03000EB0 (playback)". Under the text "Script offset 2", put $00[your script]. Under the text "flag", put the var you set in the script. Leave the Value box. Hit the "save map scripts" box and save the ROM. Test it. There's 99% that the script will be corrupted. Go to the "Header" tab, and press CTRL+H. You'll see lots of bytes fufufu. Look for a box called "Map script offset" and copy the script. Open up XSE again and open up your ROM. On the offset box, paste the Script from A-Map and nothing will appear. Try playing with the "Decompile" and "Level Script" buttons 'til it will. Scroll down 'til you see "#raw word 0xFFFF". simply replace the "FFFF" with "0", so you'll get "#raw word 0x0". Compile the script, test again and it should be fine!

If you don't have the latest XSE version, meants you do not have that level script function, do this:


Ros1e said:
(all this is assuming that you have already compiled your script. This is only for overwriting that FFFF thing with 0000.)

1) Open your rom in advance map and go to the header of the map that has the level script on it.
2) Press ctrl-H.
3) Copy the script offset
4) Close Advance Map and open your rom in a hex editor.
5) Go to the offset that you copied from advance map. In this case, my offset will be $6B0F84.
6) It will look something like this.
27ysi1j.png

The byte that is highlighted in blue is where the offset is.
The three bytes that are circled (FE, 09, and 6B) are a pointer to another offset (in this case that offset is 6B09FE.) Go to that offset.
7) It should look something like this.
2wf0ppd.png


Again, the blue highlighted byte is where the offset starts.
The bytes circled in red (in this case 00 00 and 80) are the pointer to the main part of your script (the part with the msgbox or whatever else you have in your script.)

8) This is the crucial part. The bytes circled in blue are the FFFF word (in a hex editor it just looks like FF FF.) Overwrite both FFs with 00s.

9) Save.

Well, this is it.

It is also used for movesprite scripts. If you wish to have a sprite to appear in another spot after you set a flag, you need to compile this script:

Let's say the flag is 2F.

Code:
#dynamic 0x800000

#org @start
checkflag 0x2F
if 0x1 goto @move
release
end

#org @move
movesprite 0x[Sprite to move] 0x[X] 0x[Y]
release
end
_______________________________________________________________________________________________


[03] On entering map/not on menu close


This isn't hard at all. Have you wondered how's that on certain maps, an OW or anything else will change his location after another script? Well, that's it. In FRLG, it is most used for "setworldmapflag".


In order to make an OW dissappear on a flag, type in that script: Let's say the flag "3A" is the flag.


Code:
#dynamic 0x800000
Code:
#org @start
checkflag 0x3A
if 0x1 goto @hide
release
end


#org @move
hidesprite 0x[Sprite to hide]
setflag 0x[Person ID]
release
end
It might be also used for "setmaptile" scripts.
Code:
dynamic 0x800000

#org @start
checkflag 0x3A
if 0x1 goto @tilechange
release
end

#org @tilechange
setmaptile 0x[X] 0x[Y] 0x[TILE] 0x[ATTRIBUTE]
special 0x8E
release
end
Gee, that was simple.


You can use it for any purpuse you want except setmaptile.


_______________________________________________________________________________________________


[04] Validates values, loads handler to 0x03000F28


Some kind of another variation for doing a "[02] Validates values, loads handler to 0x03000EB0 (playback)" script.

[/FONT]
[FONT=Courier New]05 and 07 are identical to 03, [I]except[/I] that it will also trigger on any re-draw of the Overworld [06] Unkown use, I guess.


_______________________________________________________________________________________________


Gee, I worked on that for hours.


[B]Do not copy or modify without my permission pl0x!

Credits:
[/B][CODE]Me
PJBottomz
Ros1e
Jambo51
De End!
 
Last edited:

Trev

[span="font-size: 8px; color: white;"][font="Monts
1,505
Posts
11
Years
  • Age 27
  • Seen Nov 15, 2023
Gal, movesprite does not work on the 03 level-script type. I learned this a while ago. It only works on 02 and 04. You should fix that.
 

xGal

Mhm
241
Posts
12
Years
Gal, movesprite does not work on the 03 level-script type. I learned this a while ago. It only works on 02 and 04. You should fix that.
Whoops I thought it would because that's making sense.

Thanks :)
 
10
Posts
10
Years
  • Seen Jul 20, 2016
My version of xse does not have a level script button. As one would guess, this poses a problem when trying to create a level script. Where can I get a version that has a level script button?
 

xGal

Mhm
241
Posts
12
Years
My version of xse does not have a level script button. As one would guess, this poses a problem when trying to create a level script. Where can I get a version that has a level script button?
HackMew's tool factory...
 
10
Posts
10
Years
  • Seen Jul 20, 2016
HackMew's tool factory...

No functional download link there. Looks like hackmew has been gone for quite some time. It's ok though, I found a way to fix level scripts with a hex editor, so I should be fine...
 

xGal

Mhm
241
Posts
12
Years
No functional download link there. Looks like hackmew has been gone for quite some time. It's ok though, I found a way to fix level scripts with a hex editor, so I should be fine...

Oh, really?

That's cool!

I'd be glad if you could PM me the method and I'll add to the tutorial - I will credit you ofcourse!
 

Jambo51

Glory To Arstotzka
736
Posts
14
Years
  • Seen Jan 28, 2018
"[05] & [07] another variation for a "[03] On entering map/not on menu close" scripts."

This is not true.

05 is identical to 03, except that it will also trigger on any re-draw of the Overworld (eg, after battling, or after checking your bag).

That's why it's used as a handler for hiding sprites after legendary battles. 03 doesn't execute, while 05 does.

I'm not sure about 07 though.
 

xGal

Mhm
241
Posts
12
Years
"[05] & [07] another variation for a "[03] On entering map/not on menu close" scripts."

This is not true.

05 is identical to 03, except that it will also trigger on any re-draw of the Overworld (eg, after battling, or after checking your bag).

That's why it's used as a handler for hiding sprites after legendary battles. 03 doesn't execute, while 05 does.

I'm not sure about 07 though.

Oh, I didn't know that... Thanks ^^

I added to the tutorial and put you in the credit list :3
 
Back
Top