The ability to move NPC around the map not only keeps the programmer sane after a hard work, but also saves time by not requiring multiple versions of the same NPC.
pallet_town_map_script.pks | |
File Size: | 0 kb |
File Type: | pks |
npc_speech.pks | |
File Size: | 0 kb |
File Type: | pks |
Allow me to explain this map script a bit more in depth. This is a special script because it only allows certain commands. This map's intention is to manage the flags and vars (set/clear upon entering the map), and modify the NPC. This means that using other commands, such as message and applymovement, will not only not work, but also crash your game. Avoid using normal commands you usually use, and stay strictly to flag/var and sprite based commands.
I rewrote Pallet Town's map script for this event, so you guys can compile that script if you want to use it. If you plan on tinkering with Pallet Town in the future (like I will), I suggest you keep a copy of the map script I posted. Of course, if you don't, it will always be here for you to download.
Anyways, don't edit the already compiled map script. Compile my rewritten one. If you want to make changes to the map script, change the rewritten one, not the compiled one. When you add extra commands and such to a compiled script, you are adding data to a region in the game that already has other data, which will result in a error in your script. Okay, lets get to my script.
Our main focus will be Pallet Town's map script. If you go to where it says "@myevent", that is the addition I made. Flag 0x800 must be set in order to jump to offset "@myevent". The NPC in the house was just a message plus a setflag, so I didn't feel like I had to upload the script. In Pallet Town, the person who looks just like you transfers to a different location, and does a different movement type after the flag has been set. This is the capability of "Upon Entering the Map" map scripts, which I will now call Map Script 03 (sounds better and shorter).
Here are the new commands you use in map script 03.
setworldflag 0x(something) - Sets a world flag. I don't know much about this, but this is irrelevant to what we will be learning.
movesprite2 0x(person event #) 0x(new X coordinate) 0x(new Y coordinate) - Moves an NPC to a new location upon entering the map, if the conditions have been fulfilled.
spritebehave 0x(person event #) 0x(new movement type) - Changes the movement type of an NPC. To find the different movement types, click on the event in A-map, and find the 'movement type' area on the right. Use the values in brackets to indicate the movement type you want.
Everything else is old stuff. Okay, lets write another map script 03. Use the non-compiled version of Pallet Town's map script.
Scenario: When we talk to a person inside our house, we will see a person randomly appear outside our door. He/She says that he/she is a ghost who is just visiting our house, and will leave soon. When we go back in the house to talk to the person we originally talked to, and then go back outside, the ghost will be gone.
This scenario requires tricky placement of the "Ghost". This is actually very similar to a custom requested script, found here. Use it as a reference.
The ending result should look something like this. Scripts can be found below. The "Ghost" only had the message, so it's very easy to write.
I rewrote Pallet Town's map script for this event, so you guys can compile that script if you want to use it. If you plan on tinkering with Pallet Town in the future (like I will), I suggest you keep a copy of the map script I posted. Of course, if you don't, it will always be here for you to download.
Anyways, don't edit the already compiled map script. Compile my rewritten one. If you want to make changes to the map script, change the rewritten one, not the compiled one. When you add extra commands and such to a compiled script, you are adding data to a region in the game that already has other data, which will result in a error in your script. Okay, lets get to my script.
Our main focus will be Pallet Town's map script. If you go to where it says "@myevent", that is the addition I made. Flag 0x800 must be set in order to jump to offset "@myevent". The NPC in the house was just a message plus a setflag, so I didn't feel like I had to upload the script. In Pallet Town, the person who looks just like you transfers to a different location, and does a different movement type after the flag has been set. This is the capability of "Upon Entering the Map" map scripts, which I will now call Map Script 03 (sounds better and shorter).
Here are the new commands you use in map script 03.
setworldflag 0x(something) - Sets a world flag. I don't know much about this, but this is irrelevant to what we will be learning.
movesprite2 0x(person event #) 0x(new X coordinate) 0x(new Y coordinate) - Moves an NPC to a new location upon entering the map, if the conditions have been fulfilled.
spritebehave 0x(person event #) 0x(new movement type) - Changes the movement type of an NPC. To find the different movement types, click on the event in A-map, and find the 'movement type' area on the right. Use the values in brackets to indicate the movement type you want.
Everything else is old stuff. Okay, lets write another map script 03. Use the non-compiled version of Pallet Town's map script.
Scenario: When we talk to a person inside our house, we will see a person randomly appear outside our door. He/She says that he/she is a ghost who is just visiting our house, and will leave soon. When we go back in the house to talk to the person we originally talked to, and then go back outside, the ghost will be gone.
This scenario requires tricky placement of the "Ghost". This is actually very similar to a custom requested script, found here. Use it as a reference.
The ending result should look something like this. Scripts can be found below. The "Ghost" only had the message, so it's very easy to write.
pallet_town_map_script_revised.pks | |
File Size: | 0 kb |
File Type: | pks |
person_script.pks | |
File Size: | 0 kb |
File Type: | pks |
With this, our map script lessons are done (for now). There are more map scripts, and I will add them as I explore more. However, everything we've been doing up to now has all been "scripted". We know the outcome, and that can get quite boring. What if we added a "random" element into our script? Well, check out the next lesson and find out!