check for array bounds correctly

npc_id must not be -1 when being used as an array index.
Merge pull request #376 from stefanbeller/bugfix1

check for array bounds correctly.