check for array bounds correctly.

npc_id must not be -1 when being used as an array index.