For R/S/E version, go here.
movement_script.pks | |
File Size: | 0 kb |
File Type: | pks |
So, did you have fun trying to give your player items? Well, I hope you did, because item giving is about 30% easier than today's lesson. Meaning, if you didn't understand the previous lesson, you should review it before coming here, because movement scripts will use the element of 'flags' as well. So, if you understand flags, you'll be fine.
Now, if you've played pokemon, you'll know that sometimes, when you talk to a person, the NPC can make you follow him/her (Talking to the person in Pewter City to lead you to gym is an example). This is what we will learn today (obviously). I posted an example of a movement script below the youtube video. The script below this text is NOT the script for the video.
(The script below is the script from my youtube video. Download the script file below the video for the 5 sec. video movement script.)
#dyn 0x740000
#org @main
lock
faceplayer
message @talk
callstd MSG_NORMAL
compare PLAYERFACING UP
if == call @up
compare PLAYERFACING DOWN
if == call @down
compare PLAYERFACING LEFT
if == call @left
message @bye
callstd MSG_NOCLOSE
pause 0xA
closemsg
applymovement 0x4 @walkaway
applymovement PLAYER @seeaway
pauseevent 0x0
fadedefault
disappear 0x4
setflag 0x1550
release
end
#org @up
applymovement 0x4 @leadup
applymovement PLAYER @followup
pauseevent 0x0
return
#org @down
applymovement 0x4 @leaddown
applymovement PLAYER @followdown
pauseevent 0x0
return
#org @left
applymovement 0x4 @leadleft
applymovement PLAYER @followleft
pauseevent 0x0
return
#org @talk
= Lets take a walk
#org @bye
= Bye!
#org @walkaway
m walk_down walk_left walk_left walk_up walk_left walk_up walk_up walk_up walk_up walk_up walk_up end
#org @seeaway
m look_down_delayed pause_long look_left_delayed pause_long pause_long pause_long pause_long pause_long pause_long pause_long pause_long end
#org @leadup
m walk_right walk_right walk_right walk_right end
#org @followup
m walk_up walk_right walk_right walk_right
#org @leaddown
m walk_right walk_right walk_right walk_right end
#org @followdown
m walk_down walk_right walk_right walk_right end
#org @leadleft
m walk_down walk_right walk_right walk_up walk_right walk_right end
#org @followleft
m look_down pause_long pause_long look_right pause_long pause_long walk_right walk_right end
Now, that's a lot to swallow huh? Well, this isn't really 'typical' (this was my youtube video script), but all of a movement script's basic components are in this script.
Now, we see some new things in the first paragraph.
compare PLAYERFACING UP
if == call @up
I repeat this concept 4 times, so I'll just discuss these 2 lines.
As you can see, we have a 'if-then' statement again. This time though, we are comparing 'PLAYERFACING'. So, when you talk to an NPC, you can talk to the NPC from 4 different directions.
X-NPC
Y-PLAYER
1. X
Y
2. XY
3. YX
4. Y
X
The line 'PLAYERFACING' just means 'which way is the player facing'. Now, this first part is 'UP'. So, the game will check if the 'PLAYER' is facing 'UP'. (Example 1)
Now, we have a 'call' command. This is the opposite of the 'jump' command. In a 'jump' command, we 'jump' to a new location of the script. But, in a 'call' command, we merely 'go to the location' of the script we are 'calling', but we MUST COME BACK to the main section of the script (where the 'call' line was stated).
We have a new 'callstd' value here as well. In a 'NOCLOSE' value, the message will not close. This can allow us to make stuff happen while the message box occurs. As you can see, I put a 'pause' command to 'pause' the game for a short duration. To close the message, you need a 'closemsg'. This command will 'close a NOCLOSE' when you click the A button.
applymovement 0x4 @walkaway
applymovement PLAYER @seeaway
pauseevent 0x0
These lines are the main attraction to this lesson. This is what makes the NPC or PLAYER move in a script. The line is 'applymovement 0x(person event number) (You can also use PLAYER) @(offset value)'. After the event, we must use a 'pauseevent 0x0'. This is like the 'end' command of a script, but used for 'events'. If you don't have this command, your game will crash.
Fadedefault will make the game return to the state before you talked to the NPC. So, if you had a music change, or you changed the map (both you will learn in future lessons), a 'fadedefault' will return the game to the original music and map.
disappear 0x4
setflag 0x1550
As you can see, flags have returned. In my script, after you walk with the NPC, the NPC walks back home. However, you don't see him walk all the way (he exits the game's borders), so I removed him as soon as he left the screen. This is done with a 'disappear' command. The value is the person event number. I set a flag here to make sure the NPC doesn't reappear when you walk a step. Make this flag number the NPC's ID number.
If you go to one of the offset values that you 'called' in the 1st paragraph, you notice that the last line is 'return'. As I said before, 'calling' just 'borrows' the script, so you do not stay in the new paragraph, like in a 'jump' command. So, you have to 'return'.
If you go to the movement offset values, you can see some differences with a message offset value.
#org @talk
= Lets take a walk
#org @walkaway
m walk_down walk_left walk_left walk_up walk_left walk_up walk_up walk_up walk_up walk_up walk_up end
So, for a movement offset value, don't use a '='. Use a 'M' (for Movement). Then you will enter the movements. Here are the general commands you can use (there are more which I will not discuss for now).
walk_(direction up, down, left, right) will make you/NPC walk 1 step in the direction you picked.
run_(direction up, down, left, right) will make you/NPC run 1 step in the direction you picked. This is different from walk, since when you run, you move faster. So, a run will make you get to your destination faster.
look_(direction up, down, left, right) will make you/NPC look in the direction you picked. You will not move from the spot.
say_(expression !, !!, =), X) will make you/NPC say an expression (that box thing that appears above your head).
You can use the movement generator with PKSV-UI. Go to Tools, and select 'Movement Helper' (Or click Control+M).
Note: For R/S/E users, the movement generator WILL NOT WORK! This is only compatible for FR/LG. R/S/E uses different codes for movement scripts.
Okay, so now we got all that explanations out of the way. Lets make a simple movement script.
Scenario: When you talk to a person from any direction, this person will lead you to a house. (Mine will lead the player to Oak's Lab). Afterward, the NPC will walk off the screen, and disappear.
Now, if you've played pokemon, you'll know that sometimes, when you talk to a person, the NPC can make you follow him/her (Talking to the person in Pewter City to lead you to gym is an example). This is what we will learn today (obviously). I posted an example of a movement script below the youtube video. The script below this text is NOT the script for the video.
(The script below is the script from my youtube video. Download the script file below the video for the 5 sec. video movement script.)
#dyn 0x740000
#org @main
lock
faceplayer
message @talk
callstd MSG_NORMAL
compare PLAYERFACING UP
if == call @up
compare PLAYERFACING DOWN
if == call @down
compare PLAYERFACING LEFT
if == call @left
message @bye
callstd MSG_NOCLOSE
pause 0xA
closemsg
applymovement 0x4 @walkaway
applymovement PLAYER @seeaway
pauseevent 0x0
fadedefault
disappear 0x4
setflag 0x1550
release
end
#org @up
applymovement 0x4 @leadup
applymovement PLAYER @followup
pauseevent 0x0
return
#org @down
applymovement 0x4 @leaddown
applymovement PLAYER @followdown
pauseevent 0x0
return
#org @left
applymovement 0x4 @leadleft
applymovement PLAYER @followleft
pauseevent 0x0
return
#org @talk
= Lets take a walk
#org @bye
= Bye!
#org @walkaway
m walk_down walk_left walk_left walk_up walk_left walk_up walk_up walk_up walk_up walk_up walk_up end
#org @seeaway
m look_down_delayed pause_long look_left_delayed pause_long pause_long pause_long pause_long pause_long pause_long pause_long pause_long end
#org @leadup
m walk_right walk_right walk_right walk_right end
#org @followup
m walk_up walk_right walk_right walk_right
#org @leaddown
m walk_right walk_right walk_right walk_right end
#org @followdown
m walk_down walk_right walk_right walk_right end
#org @leadleft
m walk_down walk_right walk_right walk_up walk_right walk_right end
#org @followleft
m look_down pause_long pause_long look_right pause_long pause_long walk_right walk_right end
Now, that's a lot to swallow huh? Well, this isn't really 'typical' (this was my youtube video script), but all of a movement script's basic components are in this script.
Now, we see some new things in the first paragraph.
compare PLAYERFACING UP
if == call @up
I repeat this concept 4 times, so I'll just discuss these 2 lines.
As you can see, we have a 'if-then' statement again. This time though, we are comparing 'PLAYERFACING'. So, when you talk to an NPC, you can talk to the NPC from 4 different directions.
X-NPC
Y-PLAYER
1. X
Y
2. XY
3. YX
4. Y
X
The line 'PLAYERFACING' just means 'which way is the player facing'. Now, this first part is 'UP'. So, the game will check if the 'PLAYER' is facing 'UP'. (Example 1)
Now, we have a 'call' command. This is the opposite of the 'jump' command. In a 'jump' command, we 'jump' to a new location of the script. But, in a 'call' command, we merely 'go to the location' of the script we are 'calling', but we MUST COME BACK to the main section of the script (where the 'call' line was stated).
We have a new 'callstd' value here as well. In a 'NOCLOSE' value, the message will not close. This can allow us to make stuff happen while the message box occurs. As you can see, I put a 'pause' command to 'pause' the game for a short duration. To close the message, you need a 'closemsg'. This command will 'close a NOCLOSE' when you click the A button.
applymovement 0x4 @walkaway
applymovement PLAYER @seeaway
pauseevent 0x0
These lines are the main attraction to this lesson. This is what makes the NPC or PLAYER move in a script. The line is 'applymovement 0x(person event number) (You can also use PLAYER) @(offset value)'. After the event, we must use a 'pauseevent 0x0'. This is like the 'end' command of a script, but used for 'events'. If you don't have this command, your game will crash.
Fadedefault will make the game return to the state before you talked to the NPC. So, if you had a music change, or you changed the map (both you will learn in future lessons), a 'fadedefault' will return the game to the original music and map.
disappear 0x4
setflag 0x1550
As you can see, flags have returned. In my script, after you walk with the NPC, the NPC walks back home. However, you don't see him walk all the way (he exits the game's borders), so I removed him as soon as he left the screen. This is done with a 'disappear' command. The value is the person event number. I set a flag here to make sure the NPC doesn't reappear when you walk a step. Make this flag number the NPC's ID number.
If you go to one of the offset values that you 'called' in the 1st paragraph, you notice that the last line is 'return'. As I said before, 'calling' just 'borrows' the script, so you do not stay in the new paragraph, like in a 'jump' command. So, you have to 'return'.
If you go to the movement offset values, you can see some differences with a message offset value.
#org @talk
= Lets take a walk
#org @walkaway
m walk_down walk_left walk_left walk_up walk_left walk_up walk_up walk_up walk_up walk_up walk_up end
So, for a movement offset value, don't use a '='. Use a 'M' (for Movement). Then you will enter the movements. Here are the general commands you can use (there are more which I will not discuss for now).
walk_(direction up, down, left, right) will make you/NPC walk 1 step in the direction you picked.
run_(direction up, down, left, right) will make you/NPC run 1 step in the direction you picked. This is different from walk, since when you run, you move faster. So, a run will make you get to your destination faster.
look_(direction up, down, left, right) will make you/NPC look in the direction you picked. You will not move from the spot.
say_(expression !, !!, =), X) will make you/NPC say an expression (that box thing that appears above your head).
You can use the movement generator with PKSV-UI. Go to Tools, and select 'Movement Helper' (Or click Control+M).
Note: For R/S/E users, the movement generator WILL NOT WORK! This is only compatible for FR/LG. R/S/E uses different codes for movement scripts.
Okay, so now we got all that explanations out of the way. Lets make a simple movement script.
Scenario: When you talk to a person from any direction, this person will lead you to a house. (Mine will lead the player to Oak's Lab). Afterward, the NPC will walk off the screen, and disappear.
movement_script_answer.pks | |
File Size: | 1 kb |
File Type: | pks |
Note: For the flag, you should use your own if you assigned another flag for the ID number.
Stuff Learned in This Lesson:
Disappear
Movement (Main Lesson)
Difference between a text offset (use '=') and a movement offset (use 'M')
Writing movement scripts can help a player find a certain location. However, you usually don't use a movement script when you talk to someone. A movement usually occurs when you A. Step on a certain spot/tile B. Ask a question about where to go C. Trigger an event. In the next lesson, we will go over 'level scripts', and move away from these 'basic scripts'. So, master these four lessons before we begin the 'intermediate' side of PKSV-UI.
Stuff Learned in This Lesson:
Disappear
Movement (Main Lesson)
Difference between a text offset (use '=') and a movement offset (use 'M')
Writing movement scripts can help a player find a certain location. However, you usually don't use a movement script when you talk to someone. A movement usually occurs when you A. Step on a certain spot/tile B. Ask a question about where to go C. Trigger an event. In the next lesson, we will go over 'level scripts', and move away from these 'basic scripts'. So, master these four lessons before we begin the 'intermediate' side of PKSV-UI.