Okay, we are going to move away from the 'Person event' scripts. Now, we will write level scripts. Now, what is a level script you may ask? It's Pokemon's 'event' script. When you step on a certain spot, and fulfilled a certain requirement, you trigger an event. They can be seen as 'cut scenes'. Writing the script is where the fun is.
go_through_script_npc.pks | |
File Size: | 0 kb |
File Type: | pks |
guard_npc_script.pks | |
File Size: | 0 kb |
File Type: | pks |
level_script.pks | |
File Size: | 0 kb |
File Type: | pks |
I had 3 scripts in the example above. I had the 'go through script npc', or the 'twin' in the video. He was the one who set the 'var' that I needed to trigger the event where I can pass. The guard NPC was just a basic message script. The level script itself is what we will focus on in this lesson. I'll explain both the 'twin' script and the 'level script'.
'Twin' Script:
#dyn 0x740000
#org @main
lock
faceplayer
message @done
callstd MSG_NORMAL
setvar 0x8002 0x1
release
end
#org @done
= You can go through now.
Level Script:
#dyn 0x740000
#org @main
lockall
checkflag 0x8001
if == jump @void
compare 0x8002 0x1
if == jump @pass
applymovement 0x5 @exclaim
pauseevnet 0x0
message @goback
callstd MSG_NORMAL
applymovement PLAYER @return
pauseevent 0x0
releaseall
end
#org @pass
message @good
callstd MSG_NORMAL
setflag 0x8001
releaseall
end
#org @void
releaseall
end
#org @exclaim
M say_! end
#org @return
M walk_down end
#org @goback = You can't pass.\nTalk to my twin.
#org @good = You talked to my twin.\nYou may pass.
Now, the first new line seen in here is in the 'twin' script.
setvar 0x8002 0x1
Treat this line like a 'setflag'. Just that the 'var' has to have 4 numbers, and a value after it (the 0x1. You can make it as anything). Set this var value as your level script's var value (explain this later).
Now onto the level script
compare (0x8002 0x1) is like a 'checkflag'. It checks to make sure if the var was checked or not. I generally like to put the var number for the event that is checking the var. This makes remembering which var is being checked or set, and doesn't cause a headache.
The last thing I should explain is 'lockall' and 'releaseall'. Since these scripts do not require you to directly interact with an npc, you don't need to use a 'faceplayer'. In a level script, you generally want to completely lock everything, since this is a 'trigger event'. You use 'lockall' to 'lock all', and 'releaseall', to 'release all'.
'Twin' Script:
#dyn 0x740000
#org @main
lock
faceplayer
message @done
callstd MSG_NORMAL
setvar 0x8002 0x1
release
end
#org @done
= You can go through now.
Level Script:
#dyn 0x740000
#org @main
lockall
checkflag 0x8001
if == jump @void
compare 0x8002 0x1
if == jump @pass
applymovement 0x5 @exclaim
pauseevnet 0x0
message @goback
callstd MSG_NORMAL
applymovement PLAYER @return
pauseevent 0x0
releaseall
end
#org @pass
message @good
callstd MSG_NORMAL
setflag 0x8001
releaseall
end
#org @void
releaseall
end
#org @exclaim
M say_! end
#org @return
M walk_down end
#org @goback = You can't pass.\nTalk to my twin.
#org @good = You talked to my twin.\nYou may pass.
Now, the first new line seen in here is in the 'twin' script.
setvar 0x8002 0x1
Treat this line like a 'setflag'. Just that the 'var' has to have 4 numbers, and a value after it (the 0x1. You can make it as anything). Set this var value as your level script's var value (explain this later).
Now onto the level script
compare (0x8002 0x1) is like a 'checkflag'. It checks to make sure if the var was checked or not. I generally like to put the var number for the event that is checking the var. This makes remembering which var is being checked or set, and doesn't cause a headache.
The last thing I should explain is 'lockall' and 'releaseall'. Since these scripts do not require you to directly interact with an npc, you don't need to use a 'faceplayer'. In a level script, you generally want to completely lock everything, since this is a 'trigger event'. You use 'lockall' to 'lock all', and 'releaseall', to 'release all'.
All right, we will write level scripts together. Since this is the first intermediate lesson, I feel I should start over. So, we will write a series of level scripts, 3 to be exact. Right now, I want you guys to make '8' level script boxes on A-map. To make a level script box, go to the bottom right hand corner (using scroll bar) under 'Events', and click the up arrow over 'scripts'. Click 'create event' afterwards. Now, put them down so your map will look like this.
Now, we need to put our level script's var values and var numbers. We will make the middle column of level scripts as our 'first series'. This means that the script will be triggered once we stand on the level script, regardless of anything (flags or vars) set. To make this happen, make sure that the var value of these level scripts are '0'.
Okay, now we shall make the column of level scripts closest to the rival's house as the second series of level scripts. So, what difference will this make from the first series? Well, if these level scripts are in the same 'family' (first series of level scripts will trigger another series, which triggers another series, and so on. All these level scripts will be considered as the same 'family'. In our example, the first will trigger the second, which will end at the third), we want to be consistent with the var numbers. So, don't change the var number, but to indicate that the 2nd column of level scripts will be the second series, change that var value to '1'.
Now, we still have our last series of level scripts. By now, you should know what to change.
The only thing I should mention is that underneath the var value, is 'Unknown'. Change that value to '3'. I don't really know why, but most level scripts in the game has this unknown value as '3', so I went with the flow. If I find out what the unknown value does, I'll change this page to explain the unknown value.
Anyways, that's our map format. Now comes the scripts. In this scenario, we will be known as 'god'. When the player steps on specified locations "our level scripts", we will tell the player what to do. So, in this scenario, if the player walks towards the right, and triggers our first series of level scripts, tell the player to 'walk towards the rival's house'. However, because we are programmers (or hackers if you want to classify yourself), we are going to troll the player because we can. So, when the player walks close enough towards the rival's house (triggering the second series of level scripts), we want to player to walk back towards his/her house. Now, when the player does (triggering the third series of level scripts), we're just basically going to laugh at the player for being so naive, and make the player feel stupid (not really).
Sound fun? Okay, lets start with the first series of level scripts.
First series (0x7789 0x0) var for me (if the script doesn't trigger at all, I've noticed that you should change the var number (0x followed by 4 numbers).
#dyn 0x740000
#org @main
lockall
checkflag 0xBBD
if == jump @null
message @talk
callstd MSG_NORMAL
setflag 0xBBD
setvar 0x7789 0x1
releaseall
end
#org @null
releaseall
end
#org @talk
= You should go to \v\h06's house.
Because this script is our 'first series', it will always trigger when we walk over it. How do we fix this problem? Well, I set a flag after the script is triggered. That way, if we walk over the script again, we will jump to @null, which just ends the script. The var I set, if you noticed, is just the var value and number of the next series of level scripts' value and number. I like to be consistent, so I won't have to remember a bunch of vars I set in scripts. You can make the vars set different, but that could give you a headache.
The script itself is pretty straightforward, but I'll quickly explain it.
When the script starts, we will 'lockall' or 'lock everything' because it's a 'cut scene', and we don't want anything to move unless we command it too (using applymovement).
If we have a flag known as '0xBBD' set, we will jump to location '@null'. At location '@null', we basically end the script.
However, if flag '0xBBD' is not set, we will continue with the script.
First, we will make a message box appear, with dialogue '@talk' string, which is 'You should go to \v\h06's house' (\v\h06 is a special variable in pokemon which can vary. It is the name of your rival. If your rival's name is RandompersonwhoIreallywantomurder, then the \v\h06 var will be replaced with RandompersonwhoIreallywanttomurder. Good luck getting that name though). We want the message to be normal, so nothing special will happen.
After that message, we will set the flag '0xBBD' to indicate that we do not want the script to happen again.We also want to set the var '0x7789 0x1' to trigger the next series of level scripts in the '0x7789' level script family. We then 'releaseall' to 'unlock everything', and 'end' the script.
Got all that? Well I hope. Anyways, compile the script, and put the offset value in A-map, over our first series of level scripts. Open the script to make sure the script works. We will now work on the second series.
Second series (0x7789 0x1) var for me
#dyn 0x740000
#org @main
lockall
compare 0x7789 0x1
if == jump @mainscript
releaseall
end
#org @mainscript
message @talk
callstd MSG_NORMAL
setvar 0x9001 0x2
releaseall
end
#org @talk
= Actually, go back to your house.
Notice that we didn't use a flag to check if this script will trigger again. This is because that since this is the second series of our level script family, this script will never trigger when you step on it again, unless indicated to trigger by the var '0x7789 0x1'. That is why we compare the var first, and jump to the main script, indicated by '@mainscript'. Otherwise, we will just end the script. However, since we added a flag on our first series of level scripts to make sure the script doesn't trigger again after we trigger it once, the second and third series can never be triggered again (unless you change the scripts. Feel free to do so. The more you play around with this, the better you understand and learn). I will not explain this script, since all of it is already done in our first series of level scripts.
We now go to our third and final series of level scripts.
Third series (0x7789 0x2) var for me
#dyn 0x740000
#org @main
lockall
compare 0x7789 0x2
if == jump @script
releaseall
end
#org @script
message @troll
callstd MSG_NORMAL
releaseall
end
#org @troll
= Haha, got you \v\h01!\nYou got trolled!
Everything in this script is repeated in the other 2 scripts. The only thing I shall is explain is the '\v\h01' is the variable containing the player's name. If your wondering, \v\h02-\v\h05 are variables triggered by the pokemon (these variables store pokemon names, cries, ect.). I'll explain these variables another time. For now, remember that
\v\h01 = player's name
\v\h06 = rival's name.
The final result should look something like this.
Anyways, that's our map format. Now comes the scripts. In this scenario, we will be known as 'god'. When the player steps on specified locations "our level scripts", we will tell the player what to do. So, in this scenario, if the player walks towards the right, and triggers our first series of level scripts, tell the player to 'walk towards the rival's house'. However, because we are programmers (or hackers if you want to classify yourself), we are going to troll the player because we can. So, when the player walks close enough towards the rival's house (triggering the second series of level scripts), we want to player to walk back towards his/her house. Now, when the player does (triggering the third series of level scripts), we're just basically going to laugh at the player for being so naive, and make the player feel stupid (not really).
Sound fun? Okay, lets start with the first series of level scripts.
First series (0x7789 0x0) var for me (if the script doesn't trigger at all, I've noticed that you should change the var number (0x followed by 4 numbers).
#dyn 0x740000
#org @main
lockall
checkflag 0xBBD
if == jump @null
message @talk
callstd MSG_NORMAL
setflag 0xBBD
setvar 0x7789 0x1
releaseall
end
#org @null
releaseall
end
#org @talk
= You should go to \v\h06's house.
Because this script is our 'first series', it will always trigger when we walk over it. How do we fix this problem? Well, I set a flag after the script is triggered. That way, if we walk over the script again, we will jump to @null, which just ends the script. The var I set, if you noticed, is just the var value and number of the next series of level scripts' value and number. I like to be consistent, so I won't have to remember a bunch of vars I set in scripts. You can make the vars set different, but that could give you a headache.
The script itself is pretty straightforward, but I'll quickly explain it.
When the script starts, we will 'lockall' or 'lock everything' because it's a 'cut scene', and we don't want anything to move unless we command it too (using applymovement).
If we have a flag known as '0xBBD' set, we will jump to location '@null'. At location '@null', we basically end the script.
However, if flag '0xBBD' is not set, we will continue with the script.
First, we will make a message box appear, with dialogue '@talk' string, which is 'You should go to \v\h06's house' (\v\h06 is a special variable in pokemon which can vary. It is the name of your rival. If your rival's name is RandompersonwhoIreallywantomurder, then the \v\h06 var will be replaced with RandompersonwhoIreallywanttomurder. Good luck getting that name though). We want the message to be normal, so nothing special will happen.
After that message, we will set the flag '0xBBD' to indicate that we do not want the script to happen again.We also want to set the var '0x7789 0x1' to trigger the next series of level scripts in the '0x7789' level script family. We then 'releaseall' to 'unlock everything', and 'end' the script.
Got all that? Well I hope. Anyways, compile the script, and put the offset value in A-map, over our first series of level scripts. Open the script to make sure the script works. We will now work on the second series.
Second series (0x7789 0x1) var for me
#dyn 0x740000
#org @main
lockall
compare 0x7789 0x1
if == jump @mainscript
releaseall
end
#org @mainscript
message @talk
callstd MSG_NORMAL
setvar 0x9001 0x2
releaseall
end
#org @talk
= Actually, go back to your house.
Notice that we didn't use a flag to check if this script will trigger again. This is because that since this is the second series of our level script family, this script will never trigger when you step on it again, unless indicated to trigger by the var '0x7789 0x1'. That is why we compare the var first, and jump to the main script, indicated by '@mainscript'. Otherwise, we will just end the script. However, since we added a flag on our first series of level scripts to make sure the script doesn't trigger again after we trigger it once, the second and third series can never be triggered again (unless you change the scripts. Feel free to do so. The more you play around with this, the better you understand and learn). I will not explain this script, since all of it is already done in our first series of level scripts.
We now go to our third and final series of level scripts.
Third series (0x7789 0x2) var for me
#dyn 0x740000
#org @main
lockall
compare 0x7789 0x2
if == jump @script
releaseall
end
#org @script
message @troll
callstd MSG_NORMAL
releaseall
end
#org @troll
= Haha, got you \v\h01!\nYou got trolled!
Everything in this script is repeated in the other 2 scripts. The only thing I shall is explain is the '\v\h01' is the variable containing the player's name. If your wondering, \v\h02-\v\h05 are variables triggered by the pokemon (these variables store pokemon names, cries, ect.). I'll explain these variables another time. For now, remember that
\v\h01 = player's name
\v\h06 = rival's name.
The final result should look something like this.
level_script_event_1.pks | |
File Size: | 0 kb |
File Type: | pks |
level_script_event_2.pks | |
File Size: | 0 kb |
File Type: | pks |
level_script_event_3.pks | |
File Size: | 0 kb |
File Type: | pks |
Note: If you copied my scripts exactly, make sure that the level scripts' var numbers, values, and unknowns are also exactly the same.
Level scripts allows hidden flags/vars, events, cut scenes, and much more to occur. This gives that fun feeling in Pokemon, so this is definitely required to master to make a great pokemon game. However, what's more fun than changing the map after stepping on a certain spot, to help create mazes and puzzles? Well, go ahead and learn about stepmaptile scripts in the next lesson to find out!
Level scripts allows hidden flags/vars, events, cut scenes, and much more to occur. This gives that fun feeling in Pokemon, so this is definitely required to master to make a great pokemon game. However, what's more fun than changing the map after stepping on a certain spot, to help create mazes and puzzles? Well, go ahead and learn about stepmaptile scripts in the next lesson to find out!