How can I create an ENTITY pointer which must be LOCAL for a certain entity. I need this for my AI - every NPC has a target1 ponter which must lead to a detected enemy.
Here is the code:

Code:
action ally()
{
ENTITY*target1;
if (my.status==attacking) 
{................}
........
my.event=detect_target;
}

function detect_target ()
{
	 if (event_type == EVENT_DETECT) 
  {
  	if (you.skill2==1)  // enemy detected
  	{
     my.status=attacking; target1=you;       }
   }
}



But the functions just can't recognize the pointer because it is local.

Any ideas how to make this little pointer local BUT recognized by the other functions?