Script c++ make a npc reset if he can't reach the player

Hello, I would like to add to my scripts a function (that will be called in UpdateAI()), this function would make the npc reset if he didn’t hit the player for the last X second (and of course the timer begins when he doesn’t move).

This function would prevent player to “cheat”, like if the player is flying in the air and the npc can’t hit the player, the npc would reset. I think I already saw a function that work like this but I couldn’t find it,

so I was wondering if someone could help me to figure it out.

Thanks for your help.