C++ question

Hi, i want to make custom scripted boss, witch summon vile spirits in last phase. Here is hte problem because vile spirits from lk wont work so i need to make new custom vile spirit npc with own script, so i did it … but … how i can check if npc is near player then to explode- cuz for now vile spirits explode, but away from player… will be nice some 1 to share with me only method - how to check did npc is near some player or not

here is the script atm

#include <ScriptPCH.h>
class VileSpirit : public CreatureScript{
	VileSpirit() : CreatureScript("CustomVileSpirit"){}
	struct VileSpiritAI : public ScriptedAI{
		uint32 TARGET_DELAY;
		VileSpiritAI(Creature* c) : ScriptedAI(c){}
		void JustDied(Unit * /* killer */){
		void Reset(){
			TARGET_DELAY = 3000;
		void UpdateAI(uint32 diff){
			if (TARGET_DELAY <= diff){
				if (Unit *trg = SelectTarget(SELECT_TARGET_NEAREST, 2)){
						// deal 8k dmg
                                                // here i want to check did NPC is near player or not
                                                DoCast(me, 58455);
						me->DealDamage(trg, 8000, 0);
						me->Kill(me, false);
				TARGET_DELAY = 3000;
				TARGET_DELAY -= diff;

	CreatureAI* GetAI(Creature* creature) const
		return new VileSpiritAI(creature);
void AddSC_CustomVileSpirit(){
	new VileSpirit();