npc system update and optimize