Does anyone know how to make an Npc drain 10 prayer everytime it attacks you and even if it hits nothing or misses?

Help would be nice. thanks in advanced if you try.