function AISMN_WaitUntilTargetVisible::OnEnter(%this,%obj)
{   
   StopMoving(%obj);
   if(%obj.isDrunk())
      GetThisObject(%obj).playThread( 0, "drunkroot");
   else
      GetThisObject(%obj).playThread( 0, "root");   
}

function AISMN_WaitUntilTargetVisible::OnExit(%this,%obj)
{
   return;
}

//EXIT 0: TARGET IS WITHIN SIGHT RANGE
//EXIT 1: WAITED FOR 10 SECONDS
function AISMN_WaitUntilTargetVisible::Update(%this,%obj)
{   
   if(TargetIsVisible(%obj,GetParameterTarget(%obj)))
      ReturnValue(%obj,0);
   else if(TimeInNode(%obj) >= 10)
      ReturnValue(%obj,1);
   else
      ReturnValue(%obj,-1);
   return;
}