<?xml version="1.0" encoding="utf-8"?><waypoints>
<onload>
-- approx.  12mins w/out classSwapping
-- Version 0.2 - implemented daily tickets reset (usereset function)
-- Version 0.1


	swapClass 		= false;				-- Do ClassSwapping for levelling Second Class?

	minPlayerLevel	= 79;				-- minimum PlayerLevel to accept the Quest.
	maxPlayerLevel	= 85				-- Player Level that will no longer Complete quest **only applies to dailies... Public would still do the quest. Typically, Player Level Cap
	questItemId 	= 122252;
	questGiverId 	= 122200;
	runeSensor		= 241035;
	questid 		= 426381;
	questName 		= GetIdName(questid);
	questtype 		= "daily" -- "public" or "daily";
	usereset		= true 				-- set to true if you want to use daily reset tickets
	skipHouseMaid 	= true;			-- If true, won't ride to Housemaid. Will be used dynamically in the WP (dontedit);
	time = os.time();		-- Startingtime of Waypoint
	__WPL:setForcedWaypointType("TRAVEL")


	for k,v in pairs(settings.profile.skills) do
		  v.AutoUse = false
	end



	function swClass()
		player:update();
		RoMScript("ExchangeClass("..(player.Class2+1)..","..(player.Class1+1)..")");
		yrest(250);
		player:mount();
	end
	

	function questsDone()
		local dailyQuestCount, dailyQuestsPerDay= RoMScript("Daily_count()");
		if (dailyQuestCount==dailyQuestsPerDay) then
			return true;
		else 
			return false;
		end
	end	
	
	function checkToDoMore()
      yrest(500)
      if questsDone() and questtype == "daily" then
         if usereset == true and maxPlayerLevel > player.Level then
            inventory:update();
            player:update();
            if inventory:itemTotalCount(202434) > 0 then --daily reset tickets
               inventory:useItem(202434);
               yrest(500)
               __WPL:setWaypointIndex(__WPL:findWaypointTag("questGiver"))
            else
               __WPL:setWaypointIndex(__WPL:findWaypointTag("questGiver"))
            end
         elseif publicafterdaily == true then
            questtype = "public"
            __WPL:setWaypointIndex(__WPL:findWaypointTag("questGiver"))
         else
            __WPL:setWaypointIndex(__WPL:findWaypointTag("questGiver"))
         end
      elseif questsDone() and questtype == "public" then
         __WPL:setWaypointIndex(__WPL:findWaypointTag("questGiver"))
      end
   end
	
	if getQuestStatus(questName) == "complete"  then
		direction = WPT_BACKWARD;
	else
		direction = WPT_FORWARD;
	end
	
	if  questsDone() and questtype 		== "daily" then
		error ("Dailys done for today!",0);
	end
	
	
	currentwp = __WPL:getNearestWaypoint(player.X, player.Z, player.Y);

	if  currentwp == 5 and direction == WPT_FORWARD then 
		currentwp = currentwp-1
	elseif currentwp == 1 and direction == WPT_BACKWARD then 
		currentwp = currentwp+1
	end
	print ("current: "..currentwp);
	__WPL:setWaypointIndex(currentwp);

	__WPL:setDirection(direction);

	changeProfileOption("WAYPOINT_DEVIATION",5);
	booltable={};
	booltable[true]	="yes";
	booltable[false]="no";
	addMessage ("Swap Class enabled: "..booltable[swapClass]);

	function fetchQuest()
		if questsDone() and questtype == "daily" then
			cprintf (cli.pink,"Time spend for this daily: %s Minutes\n",(os.time()-time)/60);
			error ("Dailys done for today!",0);
		else
			inventory:update();
			if getQuestStatus(questName) == "incomplete" and inventory:itemTotalCount(241035) == 0 then
				print ("Aborting malfdormed Quest; missing QuestItem!");
				CancelQuest(questName);
				yrest(150);
				fetchQuest();
			elseif getQuestStatus(questName) ~="incomplete" or  getQuestStatus(questName) =="not accepted" then
				player:target_NPC(questGiverId);
				yrest(150);
				AcceptQuestByName(questName,questtype);
			end
		end
	end
	
	function completeQuest()
		if getQuestStatus(questName) =="complete" then
			player:target_NPC(questGiverId);
			yrest(150);
			CompleteQuestByName(questName);
		end
	checkToDoMore()
	end
	
	
</onload>

	<!-- #  1 --><waypoint x="-18665" z="-2438" y="805" tag="questGiver">
	direction = WPT_FORWARD;
	__WPL:setDirection(direction)
	
	if getQuestStatus(questName) ~= "complete" and minPlayerLevel > player.Level and swapClass then
		addMessage ("Enabled riding to housemaid (#118)");	
		skipHouseMaid = false;
		if not player.Mounted then		player:mount();	end
	else
		direction =  WPT_FORWARD;
		__WPL:setDirection(direction); 
		completeQuest();
		fetchQuest();
		player:update();
		if not player.Mounted then		player:mount();	end
	end
	
	
	inventory:update();
	if inventory:itemTotalCount(runeSensor) == 0 and skipHouseMaid then
		addMessage("Failed to get "..GetIdName(runeSensor));
		skipHouseMaid = false;
		
	end
	</waypoint>

	<!-- #  2 --><waypoint x="-18326" z="-2650"  tag="skip_housemaid_backward">
	print ("WP_Tag: " .. __WPL.Waypoints[__WPL.CurrentWaypoint].Tag.."\n");		
	if direction ==  WPT_FORWARD then
		if not swapClass or skipHouseMaid then
			addMessage ("Skipping Housemaid");
			__WPL:setWaypointIndex(__WPL:findWaypointTag("skip_housemaid_forward"));
		elseif not skipHouseMaid then
			addMessage ("Riding to Housemaid for Swapping Class! (#133)");	
		end
	end
	
	print ("2");	</waypoint>
	<!-- #  3 --><waypoint x="-18045" z="-2703" tag="housemaid"> 
	print ("WP_Tag: " .. __WPL.Waypoints[__WPL.CurrentWaypoint].Tag.."\n");		
		player:target_NPC(122481)		-- Housemaid Momo Cidolph
		yrest(150);
		ChoiceOptionByName(getTEXT("SO_110581_1"));	-- "I'd like to chance class"
		yrest(150);
		swClass();
		skipHouseMaid=true;
		addMessage("Back to QuestGiver (#146)");
	direction = WPT_BACKWARD;
	__WPL:setDirection(direction)
	__WPL:setWaypointIndex(__WPL:findWaypointTag("skip_housemaid_backward"));

	</waypoint>
	<!-- #  4 --><waypoint x="-18163" z="-2765">	</waypoint>
	<!-- #  5 --><waypoint x="-18234" z="-2877" tag="skip_housemaid_forward">
	print ("WP_Tag: " .. __WPL.Waypoints[__WPL.CurrentWaypoint].Tag.."\n");		
	if direction ==  WPT_BACKWARD then
		if not swapClass and skipHouseMaid then
			addMessage ("Skipping Housemaid");
			__WPL:setWaypointIndex(__WPL:findWaypointTag("skip_housemaid_backward"));
		end
	end
	</waypoint>
	<!-- #  6 --><waypoint x="-17875" z="-2942" tag="usingItem">
		print ("WP_Tag: " .. __WPL.Waypoints[__WPL.CurrentWaypoint].Tag.."\n");		
	
		repeat 
			player:target_Object(questItemId);
			yrest(500); 
		until getQuestStatus(questName) == "complete" or inventory:itemTotalCount(241035) == 0

		yrest(200);
		player:mount();
		
		if getQuestStatus(questName) == "complete" and swapClass and player.Level > minPlayerLevel then
			addMessage("enabled riding to Housemais (#174)");
			skipHouseMaid = false
		else
			addMessage("disabled riding to Housemaid (#177)");
			skipHouseMaid = true;
		end
		
		direction =  WPT_BACKWARD;
		__WPL:setDirection(direction); 
	</waypoint>
	
</waypoints>