refactoring piaoliu npc detection