Talk:Village/@comment-16325373-20140320180428/@comment-9531161-20140320202736

Errr OK, here goes. The collision is only based on the VF cell. If you keep track of the NPC's position in terms of the VF (just like PLX and PLY for the player), you can check the map at a particular location to see if there's an obstacle. For instance, if you had NPCX and NPCY, you could do something like: IF SPCLASS(VF(NPCX,NPCY)) AND OBSTACLE THEN (DON'T MOVE) ELSE (MOVE) Remember, the SPCLASS array contains the classification of every item, and OBSTACLE is a specific value which describes obstacles. If a thing in the village can't be walked through, it'll have the OBSTACLE classification.

You can place the NPC on the screen by using a copy of the SETPLAYEROFS function. Just copy the function so it'll use an NPC VF location, and it'll translate it into screen coordinates. For instance, for the player, their position is PLX and PLY. However, this is the map location, and not the screen location. If you call SETPLAYEROFS, now PLXOFS and PLYOFS will hold the screen location which corresponds to the VF location, and you can just SPOFS to that location. Remember, you can't use the exact same function as SETPLAYEROFS, you have to change it so it uses your NPC locations (and DON'T overwrite PLXOFS and PLYOFS).