Setmaptile is a very nifty way to make sudden changes in the map. However, it is very limited in what it can do. Setmaptile cannot permanently change the map, and it can only change the map blocks, not the events within the map. Those jobs go to the Map Scripts of the game.
There are many type of map scripts used in the game, but for now I will only go over 2 of them (since at this point, I only know how to use 2 of them). The first one is a 'playback' map script. This map script is basically a level script that can trigger upon entering the map.
There are many type of map scripts used in the game, but for now I will only go over 2 of them (since at this point, I only know how to use 2 of them). The first one is a 'playback' map script. This map script is basically a level script that can trigger upon entering the map.
flag_setter.pks | |
File Size: | 1 kb |
File Type: | pks |
playback_script.pks | |
File Size: | 0 kb |
File Type: | pks |
Here's the flags and such I used for my playback map script.
I should probably mention right now that you must NEVER have more than 1 playback map script in one map. The game will not know which map to use, which will cause errors. However, as shown above, 3 different level script events triggered when I went downstairs. How, could 3 playback scripts, which are all different (for the most part) trigger, when I can only use 1 playback map script? You guys probably already figured out how to do this. If not, lets take a look at my scripts.
Flag-Setter Script
#dyn 0x740000
#org @main
lock
faceplayer
setvar 0x4888 0x1
message @ask
callstd MSG_YESNO
compare LASTRESULT YES
if == jump @yes
jump @no
#org @yes
setflag 0x9AAC
checkflag 0x9AAA
if true call @clearflagtwo
checkflag 0x9AAB
if true call @clearflagthree
message @eventone
callstd MSG_NORMAL
release
end
#org @no
message @askagain
callstd MSG_YESNO
compare LASTRESULT YES
if == jump @yestwo
jump @notwo
#org @yestwo
setflag 0x9AAA
checkflag 0x9AAC
if true call @clearflagone
checkflag 0x9AAB
if true call @clearflagthree
message @eventtwo
callstd MSG_NORMAL
release
end
#org @notwo
setflag 0x9AAB
checkflag 0x9AAC
if true call @clearflagone
checkflag 0x9AAA
if true call @clearflagtwo
message @eventthree
callstd MSG_NORMAL
release
end
#org @clearflagone
clearflag 0x9AAC
return
#org @clearflagtwo
clearflag 0x9AAA
return
#org @clearflagthree
clearflag 0x9AAB
return
#org @ask
= Do you want event 1?
#org @eventone
= Okay, event 1 flag set.
#org @askagain
= Then how about event 2?
#org @eventtwo
= Okay, event 2 flag set.
#org @eventthree
= Event 3 flag set then.
That's a lot to swallow huh? Well, I wrote this script this way for safety precautions. Not as in the script might crash the game, but more so that accidental errors will not occur. Lets break it down.
If you guys saw my youtube video on playback scripts, you already know that I like to trigger my playback level script events with 'doing something' in another map before going into the desired map. This script above serves to trigger the different playback level scripts I wrote in the other map of the house. The format is multiple yes/no questions to trigger desired flags for a desired event.
Depending on the event I want, I will set a certain flag. However, I also have offsets which clear certain flags. This is done to prevent errors. You will see what I mean if we examine the playback script.
Playback Script
#dyn 0x740000
#org @main
lockall
checkflag 0x9AAC
if == jump @eventone
checkflag 0x9AAA
if == jump @eventtwo
checkflag 0x9AAB
if == jump @eventthree
releaseall //Not necessary, but makes compiled script look better.
end //Not necessary, but makes compiled script look better.
#org @eventone
textcolor RED
message @talk
callstd MSG_NORMAL
clearflag 0x9AAC
addvar 0x4888 0x1
releaseall
end
#org @eventtwo
applymovement 0x1 @momdance
pauseevent 0x0
message @speak
callstd MSG_NORMAL
clearflag 0x9AAA
addvar 0x4888 0x1
releaseall
end
#org @eventthree
applymovement PLAYER @dance
pauseevent 0x0
message @say
callstd MSG_NORMAL
clearflag 0x9AAB
addvar 0x4888 0x1
releaseall
end
#org @talk
= This is event 1.
#org @speak
= This is event 2.
#org @say
= This is event 3.
#org @momdance
M walk_right jump_down jump_left jump_up jump_right walk_left end
#org @dance
M jump_left jump_up jump_right jump_down jump_left say_:) end
This is the playback map script. As you can see, it looks just like a regular level script. Essentially, that IS what a playback script is. Anyways, notice the 1st paragraph.
checkflag 0x9AAC
if == jump @eventone
checkflag 0x9AAA
if == jump @eventtwo
checkflag 0x9AAB
if == jump @eventthree
Depending on the flag I set with the 'flag-setter', I will get a different event. However, if multiple flags are set, then event 1 will always trigger. This is due to my formatting. To fix this error, I included the 'clearflag' offsets in the flag-setter script. That way, if you talk to the flag-setter multiple times without triggering the playback script (which contains clearflag lines after the event ends), you will only have the latest flag set (as shown at the end of the video above).
Other than a use of 'textcolor', everything else has been explained already. I use text, and applymovement. At the end of each event though, I clear the flag set, and I use 'addvar'.
The reason is that if I don't, the playback script will continue to play until the ROM closes. I'll try to explain why as lucid as possible.
In the flag-setter script, right after 'lock' and 'faceplayer', I have a var set. That var is my playback script's corresponding var (var = flag with a value of 1 or higher). Since playback scripts are essentially level scripts, they will trigger if the flag is set with the correct var (0x4888 0x1 in my case).
Upon entering the map, the game will check if the var is set. If it is, the playback event will trigger. If not, nothing will happen. In our case, the var is set, so the playback script triggers. After the playback script ends, the game checks AGAIN to see if the var is set. If we don't modify the var in some way (adding/subtracting the value), the flag with the correct var value will still be set, causing the playback script to trigger again. This will continue until either the var is cleared/removed, or is changed in some way. Unfortunately, we cannot change the var value after entering the playback script loop, forcing us to shut our game.
That is why I added the 'addvar' line. Addvar will add a flag's value by the value inputted. The format is
Addvar 0x(flag number) 0x(change in value). For example, 'addvar 0xAABB 0x993' will add '993' to the current value of flag 'AABB'.
There is also 'Subtractvar', which follows the same format as 'Addvar'. Only difference is that the change in value will be subtracted (as you probably guessed) by the flag's current value.
Okay, the explanations are finally done. Now comes the fun part!
Upon entering Pallet Town, let us have a jogger pass by us. He talks to us, then he runs away. Simple as that! Since Pallet Town already has a playback script, we can't create a new one. I'm going to delete their playback script, and add my own. This will break the game, but since I am just here for teaching, I don't really care. If you want to avoid this, you're going to have to modify the original script.
I prefer flags in the 4000s, with a value of 1. That is my personal choice. You can write your script a different way.
To write this script, we need some movement (obviously), and a 'flag-setter' if you are going with my format. I need a person to set my var, to trigger the playback script.
Scenario: Write a playback script where a runner runs into/next to the player, talks, and then jogs away.
The basic format will be something like this:
Flag-Setter (If you require one)
#dyn 0x740000
#org @main
lock
faceplayer
setvar
release
end
Playback Script
#dyn 0x740000
#org @main
lockall
applymovement NPC
pauseevent
message
callstd
applymovement NPC
disappear NPC
setflag 0x(NPC ID)
addvar
releaseall
end
That is the possible basic skeleton of the possible scripts you could write. Of course, it does not have to follow this. Below are my scripts.
Flag-Setter Script
#dyn 0x740000
#org @main
lock
faceplayer
setvar 0x4888 0x1
message @ask
callstd MSG_YESNO
compare LASTRESULT YES
if == jump @yes
jump @no
#org @yes
setflag 0x9AAC
checkflag 0x9AAA
if true call @clearflagtwo
checkflag 0x9AAB
if true call @clearflagthree
message @eventone
callstd MSG_NORMAL
release
end
#org @no
message @askagain
callstd MSG_YESNO
compare LASTRESULT YES
if == jump @yestwo
jump @notwo
#org @yestwo
setflag 0x9AAA
checkflag 0x9AAC
if true call @clearflagone
checkflag 0x9AAB
if true call @clearflagthree
message @eventtwo
callstd MSG_NORMAL
release
end
#org @notwo
setflag 0x9AAB
checkflag 0x9AAC
if true call @clearflagone
checkflag 0x9AAA
if true call @clearflagtwo
message @eventthree
callstd MSG_NORMAL
release
end
#org @clearflagone
clearflag 0x9AAC
return
#org @clearflagtwo
clearflag 0x9AAA
return
#org @clearflagthree
clearflag 0x9AAB
return
#org @ask
= Do you want event 1?
#org @eventone
= Okay, event 1 flag set.
#org @askagain
= Then how about event 2?
#org @eventtwo
= Okay, event 2 flag set.
#org @eventthree
= Event 3 flag set then.
That's a lot to swallow huh? Well, I wrote this script this way for safety precautions. Not as in the script might crash the game, but more so that accidental errors will not occur. Lets break it down.
If you guys saw my youtube video on playback scripts, you already know that I like to trigger my playback level script events with 'doing something' in another map before going into the desired map. This script above serves to trigger the different playback level scripts I wrote in the other map of the house. The format is multiple yes/no questions to trigger desired flags for a desired event.
Depending on the event I want, I will set a certain flag. However, I also have offsets which clear certain flags. This is done to prevent errors. You will see what I mean if we examine the playback script.
Playback Script
#dyn 0x740000
#org @main
lockall
checkflag 0x9AAC
if == jump @eventone
checkflag 0x9AAA
if == jump @eventtwo
checkflag 0x9AAB
if == jump @eventthree
releaseall //Not necessary, but makes compiled script look better.
end //Not necessary, but makes compiled script look better.
#org @eventone
textcolor RED
message @talk
callstd MSG_NORMAL
clearflag 0x9AAC
addvar 0x4888 0x1
releaseall
end
#org @eventtwo
applymovement 0x1 @momdance
pauseevent 0x0
message @speak
callstd MSG_NORMAL
clearflag 0x9AAA
addvar 0x4888 0x1
releaseall
end
#org @eventthree
applymovement PLAYER @dance
pauseevent 0x0
message @say
callstd MSG_NORMAL
clearflag 0x9AAB
addvar 0x4888 0x1
releaseall
end
#org @talk
= This is event 1.
#org @speak
= This is event 2.
#org @say
= This is event 3.
#org @momdance
M walk_right jump_down jump_left jump_up jump_right walk_left end
#org @dance
M jump_left jump_up jump_right jump_down jump_left say_:) end
This is the playback map script. As you can see, it looks just like a regular level script. Essentially, that IS what a playback script is. Anyways, notice the 1st paragraph.
checkflag 0x9AAC
if == jump @eventone
checkflag 0x9AAA
if == jump @eventtwo
checkflag 0x9AAB
if == jump @eventthree
Depending on the flag I set with the 'flag-setter', I will get a different event. However, if multiple flags are set, then event 1 will always trigger. This is due to my formatting. To fix this error, I included the 'clearflag' offsets in the flag-setter script. That way, if you talk to the flag-setter multiple times without triggering the playback script (which contains clearflag lines after the event ends), you will only have the latest flag set (as shown at the end of the video above).
Other than a use of 'textcolor', everything else has been explained already. I use text, and applymovement. At the end of each event though, I clear the flag set, and I use 'addvar'.
The reason is that if I don't, the playback script will continue to play until the ROM closes. I'll try to explain why as lucid as possible.
In the flag-setter script, right after 'lock' and 'faceplayer', I have a var set. That var is my playback script's corresponding var (var = flag with a value of 1 or higher). Since playback scripts are essentially level scripts, they will trigger if the flag is set with the correct var (0x4888 0x1 in my case).
Upon entering the map, the game will check if the var is set. If it is, the playback event will trigger. If not, nothing will happen. In our case, the var is set, so the playback script triggers. After the playback script ends, the game checks AGAIN to see if the var is set. If we don't modify the var in some way (adding/subtracting the value), the flag with the correct var value will still be set, causing the playback script to trigger again. This will continue until either the var is cleared/removed, or is changed in some way. Unfortunately, we cannot change the var value after entering the playback script loop, forcing us to shut our game.
That is why I added the 'addvar' line. Addvar will add a flag's value by the value inputted. The format is
Addvar 0x(flag number) 0x(change in value). For example, 'addvar 0xAABB 0x993' will add '993' to the current value of flag 'AABB'.
There is also 'Subtractvar', which follows the same format as 'Addvar'. Only difference is that the change in value will be subtracted (as you probably guessed) by the flag's current value.
Okay, the explanations are finally done. Now comes the fun part!
Upon entering Pallet Town, let us have a jogger pass by us. He talks to us, then he runs away. Simple as that! Since Pallet Town already has a playback script, we can't create a new one. I'm going to delete their playback script, and add my own. This will break the game, but since I am just here for teaching, I don't really care. If you want to avoid this, you're going to have to modify the original script.
I prefer flags in the 4000s, with a value of 1. That is my personal choice. You can write your script a different way.
To write this script, we need some movement (obviously), and a 'flag-setter' if you are going with my format. I need a person to set my var, to trigger the playback script.
Scenario: Write a playback script where a runner runs into/next to the player, talks, and then jogs away.
The basic format will be something like this:
Flag-Setter (If you require one)
#dyn 0x740000
#org @main
lock
faceplayer
setvar
release
end
Playback Script
#dyn 0x740000
#org @main
lockall
applymovement NPC
pauseevent
message
callstd
applymovement NPC
disappear NPC
setflag 0x(NPC ID)
addvar
releaseall
end
That is the possible basic skeleton of the possible scripts you could write. Of course, it does not have to follow this. Below are my scripts.
set_var.pks | |
File Size: | 0 kb |
File Type: | pks |
playback_script.pks | |
File Size: | 0 kb |
File Type: | pks |
The end result looks a little something like this.
What We've Learned:
Changing the values of flags
Playback Map Scripts (Main)
Playback Map Scripts are very important, as it can trigger level script events upon entering the map. Without this, you would not be able to do this. However, map scripts all involve entering the map, and playback scripts are just one aspect. Why don't you head over to the 'Entering the Map' Map script, which controls NPC and flags/vars upon entering the map?
Changing the values of flags
Playback Map Scripts (Main)
Playback Map Scripts are very important, as it can trigger level script events upon entering the map. Without this, you would not be able to do this. However, map scripts all involve entering the map, and playback scripts are just one aspect. Why don't you head over to the 'Entering the Map' Map script, which controls NPC and flags/vars upon entering the map?