.
NPC Manipulation (Add / Remove / MOVE)
NPCs are referred to with an 8 bit number, based off of their overworld data. The hero is always 0xFF (entry 255), and the map's overworld NPCs start at 0x00+
Adding and Removing an NPC:
Overworld Add/Remove: You can add and remove an NPC based on its overworld ID.
[color="blue"]006B[/color] [color="red"]AddNPC[/color][color="green"]
- u16: NPC ID[/color]
[color="blue"]6B 00[/color] [color="green"]0A 00[/color]
Add NPC ID=0x0A
=====
[color="blue"]006C[/color] [color="red"]RemoveNPC[/color][color="green"]
- u16: NPC ID[/color]
[color="blue"]6C 00[/color] [color="green"]0A 00[/color]
Remove NPC ID=0x0A
Adding only works for NPCs that already exist in the overworld file, but aren't on the map (previously removed, or flag prevented spawn). In order to add a new NPC from scratch, use CreateNPC
[color="blue"]0069[/color] [color="red"]CreateNPC[/color][color="green"]
- u16: X coordinate
- u16: Y coordinate
- u16: Face direction
- u16: Overworld ID
- u16: Sprite Number
- u16: Movement Permission[/color]
[color="blue"]69 00[/color] [color="green"]01 00 02 00 03 00 41 00 53 00 02 00[/color]
make NPC @ (X,Y)=(1,2) facing Right, NPC ID=0x41, sprite=SuitMan, looks around randomly
Moving an NPC:
You have three methods to move NPCs.
0064
-
Applymovement
- You can tell them what movements to perform.
006D
-
RelocateNPC
- You can instantly relocate them to new coordinates.
024F
-
MoveNPC
- You can tell them to move coordinates (over a time period) from their current coordinates.
==========
0064 - Applymovement
Applymovement has many movement types. Give the NPC a movement and how many times it does that movement.
...time to move an NPC.
[color="blue"]64 00[/color] [color="green"]FF 00[/color] [color="purple"]08 00 00 00[/color] ApplyMovement 0xFF~hero (jump 0x00000008, start those movements, continue script)
[color="blue"]65 00[/color] WaitMovement
[color="blue"]1E 00[/color] [color="purple"]16 00 00 00[/color] Jump (0x00000016) past the movement instructions
[color="gold"]01 00 00 00[/color] Face Down for 0 iterations.
[color="gold"]4B 00 00 00[/color] Exclamation for 0 iterations (0 or 1 is ok)
[color="gold"]17 00 01 00[/color] Shuffle right 1 step (one can always have StoreHeroPosition -> different moves)
[color="gold"]14 00 01 00[/color] Shuffle up 1 step
[color="gold"]01 00 00 00[/color] Face Down for 0 iterations
[u]FE 00 00 00[/u] End Movement Instructions
... continue script
List of movement types
==========
006D - RelocateNPC - Used mainly for off-screen relocation of NPCs or between fadeouts.
[color="blue"]006D[/color] [color="red"]RelocateNPC[/color][color="green"]
- u16: Overworld ID
- u16: X coordinate
- u16: Y coordinate
- u16: Z coordinate
- u16: Face direction[/color]
[color="blue"]6D 00[/color] [color="green"]00 41 01 00 02 00 00 00 02 00[/color]
relocate NPC=0x41 to (X,Y,Z)=(1,2,0), facing left
==========
024F - MoveNPC
[color="blue"]024F[/color] [color="red"]MoveNPC[/color][color="green"]
- u16: Overworld ID
- u16: X coordinate
- u16: Y coordinate
- u16: Z coordinate
- u16: Rapidity (how fast)
- u16: Face Direction (not used?)[/color]
[color="blue"]4F 02 [/color] [color="green"]FF 00 19 00 0F 00 02 00 0C 00 02 00[/color]
relocate NPC=0xFF to (X,Y,Z)=(0x19,0x15,0x02), at speed 0x0C