ANP: How it's DoneThe ANP command is a cryptic and confusing one, yet very powerful if used correctly. It is what allows you to orchestrate cutscenes, activate objects, and do other interactions with the entities on your map. This tutorial aims to help you understand the proper use of the ANP command, what each of its parameters means, and what can and cannot be done with the command.So what's ANP mean?ANP stands for Animate NPC. However, this description of the term is a little misleading; there are no such thing as "generalized animations" in cave story. Every single NPC is essentially a finite state machine.
Some entities, like the critter, are entirely autonomous; all their states can be reached through the normal behaviour of the entity. Others, typically character NPCs, have a number of action paths they can take that don't always link together. The number in each bubble on the diagram is what I'll refer to as the entity's scriptstate. When an entity is created for the first time, it always has a scriptstate of zero, which is typically used to try and "reset" the entity. I would like to repeat that none of the animations are general. Every entity has its own set of states, and while there may be some patterns in the way Pixel designs them, there is no rule that says any one has to be like another. Well, what does ANP do?The primary function of ANP is to override the scriptstate and direction of a particular NPC (or group of NPCs), forcing it to suddenly behave in a different way. The ANP command will not change any other variables of the entity, so if the code was expecting a natural transition to the new state forcing it may have unexpected results. Most entities that are meant for use with the <ANP command have special measures to make sure that previous states won't impact a new animated state.The ParametersThe ANP command has the format <ANPXXXX:YYYY:ZZZZ
Don't forget that TSC parameters always need to be 4 characters long or you will die ExampleThis example code assumes that we have an entity of type 150 (Quote) on the map with an event number 123.#0100 This code would make Quote walk left for 50 frames, stop, look up, then turn into a door when event #0100 is run. Final considerations:For a sort-of complete list of available character animations, check anp.txt. All the values in this listing were determined empirically, so some states (such as 11 for quote) aren't necessarily "meant" to be animated to, but the result is still described.If you use assembly to write your own NPCs, the scriptstate variable is [+0x74] and the direction variable is [+0x4C]. Design with this in mind if you want to be able to use ANP with your own entities. Author: Noxid |