You can create an area/bounding box bound to the NPC, when player enters in the box, you start processing the data
The suggestions in the other answers are checking constantly checking the distance of the player and the NPC, while your game is small this is fine, but that can become slower and slower as you add NPCs.
So create an areabox class, and apply to all your NPC.
Create events on the areabox, or thresholds inner boxes, on which you can attach other events, like: if is in this area : give up.
This way you can also handle the NPC orientation cause I'm pretty sure you don't want it to attack if NPC is giving shoulders to your player.
Now depending what GL library you are using(OpenGl/DirectX), collision detection can be generalized and is way cheaper to run, also you don't need to do the math on the position all the time
tryToAttack = true; // or whatever
stopChasing = true;
follow this link for more detailed info on how to speedup collision detection
Opengl Collision detection methods