function AISMN_VisitRanch::OnEnter(%this,%obj)
{
   SetStateVariable(%obj, 0, 0);
   if (SetPathForNearestTeamBuilding(%obj, "Ranch", $OST_PLAYER)) 
   {     
      if (%obj.isDrunk()) GetThisObject(%obj).playThread( 0, "drunkwalk");
      else GetThisObject(%obj).playThread( 0, "run");
   }
   else
   {
      SetStateVariable(%obj, 0, 1);
   }
}

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

//EXIT 0: ARRIVED AT LOCATION (FOR NON-DRUNKS)
//EXIT 1: ARRIVED AT LOCATION (FOR DRUNKS)
function AISMN_VisitRanch::Update(%this,%obj)
{
   if (!IsFollowingPath(%obj))
   {
      if(!%obj.isDrunk())
      {
         %var = GetStateVariable(%obj, 0);
         ReturnValue(%obj, %var);
      }
      else ReturnValue(%obj, 1);
      return;
   }
   ReturnValue(%obj,-1);
   return;
}
