Definitly has to do with the packets sent when a NPC is clicked (specifically the first menu option from dropdown menu - this has a unique packet ID). You should search this packet and see if everything is correctly handled. If it doesn't work, put output messages inbetween the NPC attacking code so that you know when your code doesn't work anymore.