<?xml version="1.0" encoding="utf-8"?><waypoints>
<onload>
function frog(_frog)


-- Choose frog
if player:hasBuff(622071) then
	if string.lower(_frog) == "frog" then -- Look for all cavies
		_frog = {106660}
	end
elseif player:hasBuff(622072) then
	if string.lower(_frog) == "frog" then -- Look for all cavies
		_frog = {106659}
	end
elseif player:hasBuff(622073) then
	if string.lower(_frog) == "frog" then -- Look for all cavies
		_frog = {106661}
	end
elseif player:hasBuff(622074) then
	if string.lower(_frog) == "frog" then -- Look for all cavies
		_frog = {106662}
	end
elseif player:hasBuff(622075) then
	if string.lower(_frog) == "frog" then -- Look for all cavies
		_frog = {106663}
	end
end


	
	repeat
	player:rest(5);
	player:update();
	frog = player:findNearestNameOrId(_frog);
	until frog
	printf("frog found\n")

	yrest(200); -- Make sure you've come to a complete stop.
	player:update()

	local function CalcNewPos(_trap, _frog)
		local HerdDist = 30 -- distance to herd frog
		local TrapfrogDist = distance(_trap.X, _trap.Z, _frog.X, _frog.Z)
		local Ratio = (TrapfrogDist + HerdDist) / TrapfrogDist
		local x = (_frog.X - _trap.X) * Ratio + _trap.X
		local z = (_frog.Z - _trap.Z) * Ratio + _trap.Z
		local NewPos = CWaypoint(x, z)
		NewPos.Type = 4 -- Travel
		return NewPos
	end
	
	if frog then 
		cprintf(cli.yellow,"Race started...\n")
		yrest(500)
		player:update()
		local trap = {X = "6296", Z = "-2355"}
		while true do
			frog:update()
			if frog.Id == 0 then break end -- frog is gone
			if 5 > distance(frog.X, frog.Z, trap.X, trap.Z ) then -- frog moved
				printf("frog moved 1.\n")
				memoryWriteInt(getProc(), player.Address + addresses.pawnTargetPtr_offset, frog.Address);
				break
			end
			NewPos = CalcNewPos(trap, frog)
			player:moveTo(NewPos, true)
			yrest(200)
			player:update()
		end
		player:update()
		local trap = {X = "6328", Z = "-2394"}
		while true do
			frog:update()
			if frog.Id == 0 then break end -- frog is gone
			if 5 > distance(frog.X, frog.Z, trap.X, trap.Z ) then -- frog moved
				printf("frog moved 2.\n")
				memoryWriteInt(getProc(), player.Address + addresses.pawnTargetPtr_offset, frog.Address);
				break
			end
			NewPos = CalcNewPos(trap, frog)
			player:moveTo(NewPos, true)
			yrest(200)
			player:update()
		end
		player:update()
		local trap = {X = "6587", Z = "-2244"}
		while true do
			frog:update()
			if frog.Id == 0 then break end -- frog is gone
			if 5 > distance(frog.X, frog.Z, trap.X, trap.Z ) then -- frog moved
				printf("frog moved 3.\n")
				memoryWriteInt(getProc(), player.Address + addresses.pawnTargetPtr_offset, frog.Address);
				break
			end
			NewPos = CalcNewPos(trap, frog)
			player:moveTo(NewPos, true)
			yrest(200)
			player:update()
		end
		player:update()
		local trap = {X = "6615", Z = "-2290"}
		while true do
			frog:update()
			if frog.Id == 0 then break end -- frog is gone
			if 5 > distance(frog.X, frog.Z, trap.X, trap.Z ) then -- frog moved
				printf("frog moved 4.\n")
				memoryWriteInt(getProc(), player.Address + addresses.pawnTargetPtr_offset, frog.Address);
				break
			end
			NewPos = CalcNewPos(trap, frog)
			player:moveTo(NewPos, true)
			yrest(200)
			player:update()
		end
		player:update()
		local trap = {X = "6390", Z = "-2456"}
		while true do
			frog:update()
			if frog.Id == 0 then break end -- frog is gone
			if 5 > distance(frog.X, frog.Z, trap.X, trap.Z ) then -- frog moved
				printf("frog finished\n")
				memoryWriteInt(getProc(), player.Address + addresses.pawnTargetPtr_offset, frog.Address);
				break
			end
			NewPos = CalcNewPos(trap, frog)
			player:moveTo(NewPos, true)
			yrest(200)
			player:update()
		end
	end

end
		 __WPL:setWaypointIndex(1)
</onload>
	<!-- #  1 --><waypoint x="3150" z="337" y="46">	</waypoint>
	<!-- #  2 --><waypoint x="2789" z="928" y="57">
			player:target_NPC(110755) -- Lieve
			yrest(500)
			ChoiceOptionByName(getTEXT("SC_111339_12")) -- 'Bringt mich zur Halle des Auges der Weisheit.'
		waitForLoadingScreen();
	</waypoint>
	<!-- #  3 --><waypoint x="6801" z="-2368" y="58">	</waypoint>
	<!-- #  4 --><waypoint x="6648" z="-2207" y="49">	</waypoint>
	<!-- #  5 --><waypoint x="6581" z="-2188" y="49">	</waypoint>
	<!-- #  1 --><waypoint x="6501" z="-2153" y="50" tag="register">
			player:target_NPC(120417) -- Ivan Asla
			if getTEXT("SC_DE3Y_FORG_RUN_01") then
			ChoiceOptionByName(getTEXT("SC_DE3Y_FORG_RUN_01")) -- 'Ich möchte mich für die Teilnahme anmelden.'
			else
			player:rest(30)
			__WPL:setWaypointIndex(__WPL:findWaypointTag("register"))
			end
		frog("frog")
		player:restrnd(80, 1, 5);
	</waypoint>
	<!-- #  1 --><waypoint x="6406" z="-2505" y="49">	</waypoint>
	<!-- #  2 --><waypoint x="6621" z="-2481" y="50">	</waypoint>
	<!-- #  3 --><waypoint x="6794" z="-2425" y="58">	</waypoint>
	<!-- #  4 --><waypoint x="6929" z="-2484" y="58">
			player:target_NPC(111339) -- Mevay
			yrest(500)
			ChoiceOptionByName(getTEXT("SO_110561_10")) -- 'Ich möchte zu den Toren von Varanas.'
			waitForLoadingScreen();
	</waypoint>
	<!-- #  5 --><waypoint x="2845" z="802" y="68">	</waypoint>
	<!-- #  6 --><waypoint x="3208" z="298" y="44">	</waypoint>
	<!-- #  7 --><waypoint x="3386" z="191" y="44">
		error("End",0)
	</waypoint>
</waypoints>