class 1 petfix : default_npc
{
handler:
	EventHandler CREATED()
	{
		myself::AddTimerEx(1,1000);
	}

	EventHandler TIMER_FIRED_EX(timer_id,i0)
	{
		if( myself.sm.alive == 0 )
		{
			myself::AddTimerEx(1,10000);
			return;
		}
		i0 = myself::FloatToInt(myself::DistFromMe(myself.master));
		if( i0 > 1400 )
		{
			if( timer_id == 1 )
			{
				myself::RemoveAllDesire();
				myself::AddTimerEx(2,5000);
			}
			else if( timer_id == 2 )
			{
				myself::AddPetDefaultDesire_Follow(2000000);
				myself::AddTimerEx(3,25000);
			}
			else if( timer_id == 3 )
			{
				myself::InstantTeleport(myself.sm,myself::FloatToInt(myself.master.x),myself::FloatToInt(myself.master.y),myself::FloatToInt(myself.master.z));
				myself::AddTimerEx(3,1000);
			}
		}
		else if( timer_id == 3 )
		{
			myself::RemoveAllDesire();
			myself::AddTimerEx(1,10000);
		}
		else
		{
			myself::AddTimerEx(1,10000);
		}
	}

}
