npc patrol and chase

This is the script that I currently have. It is on the NPC and when the spawn trigger is hit the NPC is spawned with this script on it. it will turn and chase the player currently however, i want it to stay within a certain radius until the player enters that circle and then chase the player. if the player is out of that radius then I want the NPC to go back to the original spawn point. it is set with an empty game object labeled spawnpoint1.

#pragma strict
var player = Transform;
var speed : float = 2;  // well...the speed
var controller:CharacterController;

function Start(){
    controller = gameObject.GetComponent(CharacterController);
function Update(){
    transform.LookAt(GameObject.FindWithTag("Player").transform);  // the NPC looks at the player
    // Here you access the Character Controller component and move your NPC with SimpleMove() giving the speed and the direction(forward).
    //As the NPC is looking at you, forward is in your direction.
    animation.Play("WalkForwardNoGun"); //You play the animation

any thoughts as to how I can accomplish this?

I won’t write the code, but I figure pseudo code will be helpful.
So you NPC has spawned and is in the game world. Start of by him walking, so do the animations and sounds, etc.

Now, lets have him follow a path. For now just do moving forward then backward. Have the script store target as a gameobject so you know what to look for. So, drop your player using the click and drag system.
Then, check the distance. Vector3.Distance(target, transform) < 20 , so the player is within 20 units of your NPC, now have the NPC chase the target.
At this point make sure to save initial position, so you can some back to it when you are done chasing. So, if NPC is chasing, check if Vector3.Distance(target, transform) > 20 and it has been 5.0 seconds , so you don’t chase forever, meaning player is out of reach and enough time has passed for the NPC to forget about it. Then have NPC travel back to its initial position. Then from there continue patrol.

Thing you will need to make is an AI system which handles collision with obejobjects and what not. This assume no combat or anything for now. Just chases and follows.