• 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?".
  • Forum moderator applications are now open! Click here for details.
  • 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.

Creating Level Scripts

cooley

///Keepin' it simple
1,148
Posts
17
Years
How to create a Level Script
Yes, another tutorial, due to the large amount of level script questions

Note: Before reading, please learn some scripting first.

You all may think that making a level script is really hard, and categorize it in the same field as ASM hacking. Well, it isn't hard, at all.

This is what a level script looks like:

Code:
[FONT=Segoe UI][SIZE=2]#dynamic 0x800000[/SIZE]

[/FONT][FONT=Segoe UI][SIZE=2]#org @start[/SIZE]
[/FONT] [FONT=Segoe UI][SIZE=2]msgbox @string 0x6[/SIZE]
[/FONT] [FONT=Segoe UI][SIZE=2]setvar 0x4033 0x1[/SIZE]
[/FONT] [FONT=Segoe UI][SIZE=2]release[/SIZE]
[/FONT] [FONT=Segoe UI][SIZE=2]end[/SIZE]


[/FONT] [FONT=Segoe UI][SIZE=2]#org @string 0x6[/SIZE]
[/FONT] [FONT=Segoe UI][SIZE=2]= You see?\nThe level script worked![/SIZE]
[/FONT]


The most important part is the "setvar 0x4033 0x1". Without this in this 'type' of level script, then you will get a repeating level script.

Well, that's the tutorial... "I'll add more Later" xD
Nah, only joking :P


Okay, the first thing you would do is head on over to the Header Tab, in A-map. I'm pretty sure, everyone knows where that is.


If you look down a little, you will see this:
2dbmo2p.jpg


Click on add, and then click on "script type". You should see a drop-down menu like this:

efm39v.jpg



All of these are different types of Level scripts. The one you most likely want is the one that is highlighted.


"01 'setmaptile' script" is not the official name, but it's used in the Pokemart in Viridian City. It's purpose is in it's name; which is to setmaptile(s) before the map loads. It's not as fast as:


"04 Validates valus, loads handler to 0x03000F28" which is used to make something happen the instant you walk into the entrance/exit of the map. It's used in the PLAYER's Room to make him face up towards the Nintendo. The best time to use this is in houses or places you warp to, not like routes and towns where you walk into.



"03 On entering map/not on menu close" This is a multipurpose one. You can checkflags, compare vars, and other things and use them to make other things happen. There are a lot of these, so there is also a lot to learn from by decompiling Nintendo's scripts.



Last but not least, "02 Validates values, loads handler to 0x03000EB0". The one that most people use to make a level script. This one, you can literally use almost all the commands, like msgbox, applymovement, fadescreen, etc. But the catch is that I haven't found a way to use it like "checkflag 0x828/if 0x1 goto @done" because once you set the var, it's set... But don't worry, I'll find a way.


Okay, once you've clicked on "02 Validates values....." You will see the script offset and script offset 2 boxes are "$000000". Also the Flag and Value boxes should be 0000 too.

14o9501.jpg


Compile your Level script [make sure it has a setvar 0x(variable) 0x(value) in the script though]

According to score_under:
score_under said:
It does not have to be subtracted by 1. The reason we use 0x0 in the Value box is because the var starts at 0. The Value box dictates which value the var has to be to start the script. After the script, you set it to 1 (or indeed any other value if you choose to), and this means it no longer equals zero, so no longer activates.


vq1a8l.jpg


Click Save map scripts and the Script offset box contents should change.

Save from the File menu(Ctrl+S) and play your ROM.



wvbonb.jpg



Wow, the level script really worked!!!
But...
2vrss37.jpg



Advance Map overwrites the 0000 that you put into the Value box, with FFFF. And since it's subtracted by 1, and FFFF is the highest number you can insert, the level script glitches up.


To fix this, you go to the header tab, and press Ctrl+H to get professional header view. You should see an area called "Map Options". And within it you should see "Map script offset"

rshsaq.jpg


Copy the map script offset, and open your ROM in XSE.
Once done, paste the offset in the "decompile box" and click on "level script"



205cqc6.jpg

(This is the old XSE, but they both function similarly.)


After you've pasted the offset, and toggle the level script decompile feature (last button to the right) click decompile or "Shift+Ctrl+D"


a5gsk9.jpg

ATTENTION: OLD XSE! IF YOURS LOOKS LIKE THIS, THEN YOU NEED A SERIOUS UPDATE!


Code:
  [FONT=Segoe UI][SIZE=2]#org 0x71A242[/SIZE]
[/FONT] [FONT=Segoe UI][SIZE=2]#raw word 0x0[/SIZE]
[/FONT] [FONT=Segoe UI][SIZE=2]#raw word 0x0[/SIZE]
[/FONT] [FONT=Segoe UI][SIZE=2]#raw pointer 0x880007D[/SIZE]
[/FONT] [FONT=Segoe UI][SIZE=2]#raw word [B]0xFFFF[/B][/SIZE]
[/FONT]


Code:
  [FONT=Segoe UI][SIZE=2]#org 0x71A242[/SIZE]
[/FONT] [FONT=Segoe UI][SIZE=2]#raw word 0x0[/SIZE]
[/FONT] [FONT=Segoe UI][SIZE=2]#raw word 0x0[/SIZE]
[/FONT] [FONT=Segoe UI][SIZE=2]#raw pointer 0x880007D[/SIZE]
[/FONT] [FONT=Segoe UI][SIZE=2]#raw word [B]0x0[/B][/SIZE]
[/FONT]


This is the important part. The 0xFFFF needs to be 0x0 so change it to 0x0 and compile. You should see the compiler log:

2jepm3n.jpg


Now your Level script should work, no problems at all...
That was easy, right Staples?

Make a level script inactive until a certain event happens

Okay, so you've had fun with Level scripts, and you're both good friends. But... You walk into a map, and need a level script to activate, but not the first or second time you enter the map, but the 5th time!

Video Demonstration:


For this to work, you will need the cooperation of two maps. For my example I used the Player's room [PALLET TOWN (4.0)] and PALLET TOWN (3.0) map.

In the Player's room the level script is Level script type 03 "On entering map/not on menu close":
Code:
#org 0x800000
setvar 0x4010 0x1
release
end

I set the var to 0x1 so that the level script in Pallet town is deactivated. Hope you understood that.

This should clear things up. Here is the level script in Pallet Town:
Code:
'---------------
#org 0x800007
setweather 0x4
doweather
applymovement MOVE_PLAYER 0x8800052
waitmovement 0xFF
sound 0x15
pause 0x32
msgbox 0x880002B MSG_NORMAL '"Oh, boy[.]\pJust my luck, it's rai..."
setvar 0x4010 0x1
release
end


'---------
' Strings
'---------
#org 0x80002B
= Oh, boy[.]\pJust my luck, it's raining!


'-----------
' Movements
'-----------
#org 0x800052
#raw 0x62 'Exclamation Mark (!)
#raw 0xFE 'End of Movements

Pretty simple huh? Basically, the level script won't activate, because the variable has been set already.

Since you enter Your Room before exited your house into Pallet town, the level script in Pallet town wont work. [/DUMBEDDOWN]

You should be outside of your house. I assigned the Daisy(Gary's sister) in Pallet town this script, as seen in the video:

Code:
'---------------
#org 0x800054
msgbox 0x8800064 MSG_NORMAL '"Setting Variable 0x4010 back to 0x..."
setvar 0x4010 0x0
release
end


'---------
' Strings
'---------
#org 0x800064
= Setting Variable 0x4010 back to 0x0\n\c\h08ó. \c\h08ó. \c\h08ó.Done!

Don't mind the
"\c\h08ó" . That's just how I make my msgs. It doesn't affect the outcome at all, just added for special effects :P

And once you talk to DAISY, walk out her house, and it should start raining, just like in the Video :)

I guess that's that...
Anything else you need to know, ask here, I'll see if I can answer!
Thanks for reading!
 
Last edited by a moderator:

Curt_09

Also known as Chozo
557
Posts
15
Years
Great tutorial Cooley, maybe we won't have to answer so many of these in the simple questions and script help threads anymore.
 

cooley

///Keepin' it simple
1,148
Posts
17
Years
Seems this tut is a remake?
So cooley,why don't you update your XSE?
I'm a BETA tester for XSE, mine is always updating. These pics were from the other thread, and since both versions of XSE do basically the same thing... Why upload new pics?

Besides, it's not like you can find the version that I used for this tutorial anywhere, anyways..
 

Pokepal17

More cowbell~
1,519
Posts
15
Years

I was gonna make a tutorial just like this.


Good work, but it would be good to explain the other types of level scripts and the anatomy of a full level script.
 

BlitŻ1

guahh my dog is so cute
472
Posts
15
Years
hah, this helped me, I didn't know about the other level script options, such as 03 and 04 thank much ^^

but does 03 activate whenever you enter a map?
 

cooley

///Keepin' it simple
1,148
Posts
17
Years

I was gonna make a tutorial just like this.


Good work, but it would be good to explain the other types of level scripts and the anatomy of a full level script.
Well, it would be good. The other types of level scripts don't need to be explained. Nintendo doesn't really use them that much.

As for explaining the anatomy of a full level script, I'm pretty sure that all that is needed is a setvar and inserting the var into the Flag box in A-map ;)

hah, this helped me, I didn't know about the other level script options, such as 03 and 04 thank much ^^

but does 03 activate whenever you enter a map?
03 activates whenever you enter a map, but it doesn't have to do anything if you don't want it to. Take checkflag for instance, if a certain flag is not activated it doesn't have to do anything.
 

Pokepal17

More cowbell~
1,519
Posts
15
Years
Well, it would be good. The other types of level scripts don't need to be explained. Nintendo doesn't really use them that much.

As for explaining the anatomy of a full level script, I'm pretty sure that all that is needed is a setvar and inserting the var into the Flag box in A-map ;)


03 activates whenever you enter a map, but it doesn't have to do anything if you don't want it to. Take checkflag for instance, if a certain flag is not activated it doesn't have to do anything.

No what I meant was something else, but if I get the chance, I'll write the tutorial on it.
 

Surf

...
1,196
Posts
15
Years
  • Age 29
  • Rust
  • Seen Jul 31, 2011
Cooleh, is there a way to make the level script not activate until a certain event has happened?
 

Pokepal17

More cowbell~
1,519
Posts
15
Years
Cooleh, is there a way to make the level script not activate until a certain event has happened?

Yep.

Easy enough.

Put the var value for the lvl script as 0001 and put a setvar 0xvar 0x2 in the script.

And then before, you want the event to activate, do in a scipt, setvar 0xvar 0x1.
 

Reygok

Beginning Hacker
60
Posts
14
Years
  • Seen Jan 22, 2016
Hi, i just registered, only to post here^^ (and, sorry in advane, my c nearly never works)

I just want to show you my levelscript, ooley:

Spoiler:


I followed exatly you tutorial, and revised it 4 times, but I don't find the error. When I enter the map I put this level sript on, nothing happens. Do you know why? Or anyone else?

Thanky in advane

Edit: And does anybody know why some sprites have strange colors with ''showpokepic''? Bulbasaur is normal, but Charmander is black and blue ^^
 
Last edited:

cooley

///Keepin' it simple
1,148
Posts
17
Years
Hi, i just registered, only to post here^^ (and, sorry in advane, my c nearly never works)

I just want to show you my levelscript, ooley:

Spoiler:


I followed exatly you tutorial, and revised it 4 times, but I don't find the error. When I enter the map I put this level sript on, nothing happens. Do you know why? Or anyone else?

Thanky in advane

Edit: And does anybody know why some sprites have strange colors with ''showpokepic''? Bulbasaur is normal, but Charmander is black and blue ^^
Well, you shouldn't use checkflag in those type of level scripts... If you want to do something like that, see pokepal17's post above or read part two of my level script tutorial.

But for it not working, I would suggest changing the Var, to something like in the 4010-4FFF range. Post back if it doesn't work out.
 

Pokepal17

More cowbell~
1,519
Posts
15
Years
Well, you shouldn't use checkflag in those type of level scripts... If you want to do something like that, see pokepal17's post above or read part two of my level script tutorial.

But for it not working, I would suggest changing the Var, to something like in the 4010-4FFF range. Post back if it doesn't work out.

Actually use vars between 0x5000 and 0x7000. The ones that you mentioned Cooley, are used already in Fire Red and some of them store returning values from specials.
 

Reygok

Beginning Hacker
60
Posts
14
Years
  • Seen Jan 22, 2016
I really dont know what was the problem, but I tried 5555 and it worked... I had tried 4500 and some others already before, but those didnt work...And I have Sapphire, not Fire Red, so they should have worked... but they simply did not^^
ANyway, thanks cooley and Pokepal, i can finally continue with my hack...

Ah, and dont you know whats this problem with the color changing sprites when I use showpokepic? I put a Charmander, a Bulbasaur and a Mudkip, and when I klick charmander, it is black, then i click bulbasaur and mudkip, they are normal color, then charmander again, who turned into blue and white, then also bulbasaur is black... does the comand wrk different in the new version of XSE, like callstd or whats the problem?
 
Back
Top