Making NPCs Move On Demand

Animations are the most complex part of TSC. An animation command goes like this:
<ANP(npc event number):(animation method):(direction)
Create a Kanpachi NPC (NPC 226) and give him event number 704 and option 0x2000. Put the following code into the TSC script:
When you interact with Kanpachi by pressing down, he will walk right for a short time. In fact, Kanpachi has no walk-left sprite, so even if you set the direction to 0000 (which is left instead of right), he will still walk right. Kanpachi is so awesome that in order to walk left, he just runs around the world once until he reaches his destination.

The reason animations are a difficult part of TSC is because each NPC has a different set of animation methods. An animation method for one NPC might not work for another.
Animations actually control a variable within the NPC known as the 'ScriptState'. You will be familiar with the ScriptState if you've done any Cave Story ASM hacking.

By using <ANP, you modify the ScriptState of the NPC and change its behavior.

To see a list of ANP methods, see the ANP file.

Previous Lesson: Flags
Next Lesson: Music
Table of Contents