<?xml version="1.0" encoding="utf-8"?><waypoints>

<!--        Rock5's Millers Ranch Chickens run        -->
<!--           By Rock5(v2.0)   MOD Version 1.11      -->
<!-- www.solarstrike.net/phpBB3/viewtopic.php?p=12139 -->
<!--	MODDED by jduartedj	thx to fobsauce	      -->

<onLoad>

--only gold NEVER DELIVERS but keeps eggs so it can deliver later
	changeProfileOption("HARVEST_DISTANCE", 150);
	changeProfileOption("QUICK_TURN", true);
	repeat questname=RoMScript("TEXT('Sys422386_name')"); yrest(500) until questname -- ie. "An Easy Lay?"
	repeat npcname=RoMScript("TEXT('Sys114930_name')"); yrest(500) until npcname -- ie. "Jenna Miller"
	
	repeat zoneid = RoMScript("GetZoneID()") until zoneid
	if zoneid ~= 304 then -- not at Miller's Ranch
		-- Try to find Sorrun and teleport in
		if player:target_NPC("Sorrun") then
			sendMacro("ChoiceOption(3)") yrest(1000)
			sendMacro("ChoiceOption(1)")
			waitForLoadingScreen()
		else
			error("You are too far from Miller's Ranch")
		end
	end

	function feedHenEvalFunc(address)
		hen = CObject(address)

		-- Don't target hens in coop
		if hen.Z > 3240 then return false end -- Hen in coop

		-- Don't target moving hens
		oldX = hen.X; oldZ = hen.Z
		yrest(250);
		hen:update()
		if distance(hen.X,hen.Z,oldX,oldZ) > 2 then return false end

		return true
	end

	function coopHenEvalFunc(address)
		-- Only target coop Hens
		if 3240 > CObject(address).Z then return false end

		return true
	end
</onLoad>
	<!-- #  1 --><waypoint x="4033" z="3450">	</waypoint>
	<!-- #  2 --><waypoint x="4029" z="3327">	</waypoint>
	<!-- #  3 --><waypoint x="4016" z="3172">	</waypoint>
	<!-- #  4 --><waypoint x="3948" z="3107" tag="Main">
			local target;
			local queststate = getQuestStatus(questname);
		if queststate ~= "incomplete" and queststate ~="complete" then --needs to get the quest before harvesting
			-- Accept quest
			player:target_NPC(npcname);
			sendMacro("AcceptQuest()"); yrest(2000);
			__WPL:setWaypointIndex(__WPL:findWaypointTag("Main"))
		else
			
			while inventory:itemTotalCount(204789) > 0 and 	player:target_Object(112955,4500,false,true,feedHenEvalFunc) do -- Feed Hens
			end
			-- Out of feed or hens
			if 1 > inventory:itemTotalCount(204789) then -- Get more feed
				if distance(player.X,player.Z,3940,3055)>128 then
					teleport(3948,3107); -- back to main
					yrest(100);
				end
				__WPL:setWaypointIndex(__WPL:findWaypointTag("Get Feed"));
				teleport(3940,3055);
			else
				if distance(player.X,player.Z,3928,3185)>128 then
					teleport(3948,3107); -- back to main
					yrest(100);
				end
				__WPL:setWaypointIndex(__WPL:findWaypointTag("Get Eggs"))
				teleport(3928,3185);
			end
		end
	</waypoint>
	<!-- #  2 --><waypoint x="3940" z="3055" tag="Get Feed">teleport(3937,2978);	</waypoint>
	<!-- #  4 --><waypoint x="3937" z="2978" tag="Get FeedT">
	player:target_Object(112956,4500,true);
	teleport(3940,3055);
	</waypoint>
	<!-- #  5 --><waypoint x="3940" z="3055" tag="Get FeedR">teleport(3948,3107);__WPL:setWaypointIndex(__WPL:findWaypointTag("Main"));	</waypoint>
	
	
	<!-- #  6 --><waypoint x="3928" z="3185" tag="Get Eggs">teleport(3929,3261);	</waypoint>
	<!-- #  8 --><waypoint x="3929" z="3261" tag="Get EggsT">
		--changeProfileOption("HARVEST_DISTANCE", 40)
		while player:target_Object(112955,1500,nil,true,coopHenEvalFunc) do -- Check for hens
			yrest(500)
			player:target_Object(112958,nil,true) -- Get Fresh Eggs
			player:target_Object(114931,nil,true) -- Get Golden Eggs
		end
		-- changeProfileOption("HARVEST_DISTANCE", 150)
		teleport(3926,3198);
	</waypoint>
	<!-- #  9 --><waypoint x="3926" z="3198">teleport(3948,3107);__WPL:setWaypointIndex(__WPL:findWaypointTag("Main"));	</waypoint>
</waypoints>
