<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
<!-- v1.0 --> 						

							 <!-- NOTE:  -->
				<!-- THIS WAS DESIGNED FOR LEVEL 1 ALTS  -->
	<!-- IF deleteOrMove IS SET TO "delete" THEN IT WILL DELETE ALL -->
	  <!-- ITEMS IN BACKPACK EXCEPT THOSE ON THE keepItemId LIST! -->
	  
--============== Character list	==============================--

SetCharList({{
				{account=87, chars= {3,4,5,6,7}},
				{account=88, chars= {3,4,5,6,7}},
				{account=89, chars= {3,4,5,6,7}},
				},
				{
				{account=90, chars= {}},
				{account=91, chars= {}},
				{account=92, chars= {}},
				{account=93, chars= {}},
				},
				{
				{account=94, chars= {}},
				{account=95, chars= {}},
				{account=96, chars= {}},	
				{account=97, chars= {}},
			}})
			
			
--============================================================--

local deleteOrMove = "move" -- "delete" makes it delete ALL items in bags. Change to "move" if you only want to move IS items to IS Bag.

--========== Item's to keep if deleteOrMove = "delete" =========--
--=============== EVERYTHING else will be thrown! ============--

keepItemId = {206824, 243215, 203178, 203487, 208932, 202928, 202929, 202930, 243216}

-- {Ancient Jade Box, Jage Key, Ancient Key, 1xCharge, 5xCharge, 10xCharge, 50xCharge, 100xCharge, Ancient Treasure Chest of Splendor} --

--============================================================--

-- change value to see if you can go faster --
-- if cast bar never gets interrupted then reduce number --

local tweakit = 100

--============================================================--


local chestLootedCounter = 0		
														
	if getZoneId() == 2 then
		__WPL:setWaypointIndex(1);
	end
 
function logchest()
   local path = {
{X= -139 , Z= -291, Y= 5 },
{X= -106 , Z= -253, Y= 4 },
{X= -73 , Z= -219, Y= 5 },
{X= -38 , Z= -184, Y= 6 },
{X= -5 , Z= -147, Y= 7 },
{X= 30 , Z= -110, Y= 8 },
{X= 67 , Z= -78, Y= 10 },
{X= 101 , Z= -38, Y= 13 },
{X= 135 , Z= -4, Y= 15 },
{X= 169 , Z= 33, Y= 13 },
{X= 101 , Z= 104, Y= 14 },
{X= 66 , Z= 68, Y= 15 },
{X= 32 , Z= 32, Y= 14 },
{X= -2 , Z= -4, Y= 12 },
{X= -35 , Z= -39, Y= 9 },
{X= -70 , Z= -74, Y= 6 },
{X= -104 , Z= -110, Y= 4 },
{X= -140 , Z= -148, Y= 4 },
{X= -173 , Z= -183, Y= 5 },
{X= -208 , Z= -220, Y= 7 },
{X= -286 , Z= -154, Y= 8 },
{X= -252 , Z= -118, Y= 7 },
{X= -216 , Z= -79, Y= 7 },
{X= -182 , Z= -43, Y= 8 },
{X= -148 , Z= -8, Y= 9 },
{X= -111 , Z= 27, Y= 10 },
{X= -81 , Z= 60, Y= 12 },
{X= -44 , Z= 99, Y= 15 },
{X= -9 , Z= 134, Y= 16 },
}
   local starttime = os.time()
   local tablechest = {}
   
   local function openchest()
      local tablechest = {}
      local objectList = CObjectList();
      objectList:update();
      local objSize = objectList:size()
      for i = 0,objSize do
         local obj = objectList:getObject(i);
         if obj.Id == 123536 then
            obj.distance = distance(obj,player)
            table.insert(tablechest, table.copy(obj))
         end
      end
      -- sort by distance
      local function distancesortfunc(a,b)
         return b.distance > a.distance
      end
      table.sort(tablechest, distancesortfunc)
      for i = 1, 2 do
         if (os.time() - starttime) > 60 then break end
         local ttkeeper = os.time()
         if 30 > tablechest[i].distance then
            player:target(tablechest[i].Address)
            yrest(50)
            Attack()
            yrest(500)
            if i == 1 then
               yrest(250+tweakit)
            else
               yrest(400+tweakit)
            end
            chestLootedCounter = chestLootedCounter + 1
         end
      end
   end
   for i = 1, #path do
      if (os.time() - starttime) > 60 then break end
      teleport(path[i].X,path[i].Z,path[i].Y)
      openchest(true)
   end
   	local chestIgnore
	local chest
	teleport(-23,150,16)
	chest = player:findNearestNameOrId(123536)
	if chest ~= nil then
		repeat
			if chest.Address == chestIgnore then
				chest = false
			end
			if chest then
				teleport(chest.X,chest.Z,chest.Y)
				player:target_Object(123536);
				chestIgnore = chest.Address
				chestLootedCounter = chestLootedCounter + 1
			end
			chest = player:findNearestNameOrId(123536, chest.Address)
		until not chest
		cprintf(cli.purple,"\nTotal # chests looted: "..chestLootedCounter.."\n")
	end
	teleport(-140,-302,5)
	player:target_NPC(123562) -- Kekonee
	ChoiceOption(1)
	waitForLoadingScreen()
end

function ChoiceOption(_num)
	CurrentChoiceOption = RoMScript("GetSpeakOption(".._num..")")
	repeat
		if CurrentChoiceOption == RoMScript("GetSpeakOption(".._num..")") then
			sendMacro("ChoiceOption(".._num..");");
			yrest(1000);
		end
	until CurrentChoiceOption ~= RoMScript("GetSpeakOption(".._num..")") or not RoMScript("SpeakFrame:IsVisible()") or memoryReadBytePtr(getProc(),addresses.loadingScreenPtr, addresses.loadingScreen_offset) ~= 0
end
	
gotJamie = false
Dir = "FORWARD"

function checkForJamie(_distance)
	if _distance == nil or 1 > _distance then
		_distance = 1
	end
	foundJamie = player:findNearestNameOrId(123584)
	if foundJamie and _distance > distance(player, foundJamie) then
		player:moveTo(foundJamie);
		player:target_NPC(123584);
		ChoiceOption(1);
		gotJamie = true
		__WPL:setDirection(WPT_BACKWARD);
		Dir = "BACKWARD"
	end
end

function locateJamie()
		local goToPos = 10000
		local coordListX = {3500, 3623, 3930, 4055}
		local coordListZ = {-664, -819, -352, -519}
		foundJamie = player:findNearestNameOrId(123584)
		for i=1, 4 do
			jamiePos = distance(coordListX[i], coordListZ[i], foundJamie.X, foundJamie.Z)
			if goToPos > jamiePos then
				goToPos = jamiePos
				jamieAt = i
			end
		end
		--print(jamieAt);
		if jamieAt == 1 then
			print("Jamie found at close right")
			__WPL:setWaypointIndex(__WPL:findWaypointTag("FCR"));
		elseif jamieAt == 2 then
			print("Jamie found at far right")
			__WPL:setWaypointIndex(__WPL:findWaypointTag("FFR"));
		elseif jamieAt == 3 then
			print("Jamie found at close left")
			__WPL:setWaypointIndex(__WPL:findWaypointTag("FCL"));
		elseif jamieAt == 4 then
			print("Jamie found at far left")
			__WPL:setWaypointIndex(__WPL:findWaypointTag("FFL"));
		end	
		__WPL:setDirection(WPT_FORWARD);
		Dir = "FORWARD"
end		

function clearAll()
	inventory:update()
	for i = 61,240 do
		if string.lower(deleteOrMove) == "delete" then
			throwItem = true
			local item = inventory.BagSlot[i]
			for i = 1, #keepItemId do
				if item.Id == keepItemId[i] then
					throwItem = false
					print("Will not delete: "..item.Name.."");
					break
				end
			end
			if throwItem == true and item.Id ~= 0 then
				item:delete()
				--print("Deleting: "..item.Name.."");
			end
		elseif string.lower(deleteOrMove) == "move" then
			local item = inventory.BagSlot[i]
			if item.ItemShopItem then
				item:moveTo("itemshop")
				--print("Moved "..item.Name.." to Item Shop Bag")
			end
		end
	end
end

</onLoad>
		<!-- #  1 --><waypoint x="3410" z="174" y="44">
			player:target_NPC(123583) -- Kekonee
			if (RoMScript("GetNumSpeakOption()") > 1) then
				ChoiceOption(1)
				waitForLoadingScreen()
			else
				clearAll()
				LoginNextChar()
				loadProfile()
				loadPaths("SecretGarden");
			end
	</waypoint>
	<!-- #  2 --><waypoint x="-150" z="-331" y="6">
			player:target_NPC(123562) -- Kekonee
			ChoiceOption(2)
			yrest(1000);
			logchest()
	</waypoint>
	<!-- #  1 --><waypoint x="3370" z="128" y="44">
	if gotJamie == true then
		__WPL:setWaypointIndex(__WPL:findWaypointTag("next"));
	end
	</waypoint>
	<!-- #  2 --><waypoint x="3354" z="30" y="44">	</waypoint>
	<!-- #  3 --><waypoint x="3453" z="-155" y="44">
		if gotJamie == false then
			checkForJamie(200)
		end
	</waypoint>
	<!-- #  4 --><waypoint x="3536" z="-275" y="44">
		if gotJamie == false then
			checkForJamie(200)
		end
	</waypoint>
	<!-- #  5 --><waypoint x="3597" z="-357" y="44">
		if gotJamie == false then
			checkForJamie(200)
		end
	</waypoint>
	<!-- #  1 --><waypoint x="3667" z="-452" y="44" tag="MAIN">
			if gotJamie == false then
				checkForJamie(200)
				if gotJamie == false then
					locateJamie()
				end
			else
				__WPL:setDirection(WPT_BACKWARD);
			end
	</waypoint>
	
	<!-- #  2 --><waypoint x="3650" z="-527" y="44"	tag="FCR">	 -- Close Right
		if gotJamie == false then
			checkForJamie(100)
		end
		if Dir == "BACKWARD" then
			__WPL:setWaypointIndex(__WPL:findWaypointTag("MAIN"));
		end
			</waypoint>
	<!-- #  3 --><waypoint x="3614" z="-570" y="44">	
		if gotJamie == false then
			checkForJamie(100)
		end
		if Dir == "BACKWARD" then
			__WPL:setDirection(WPT_BACKWARD);
		end	
	</waypoint>
	<!-- #  4 --><waypoint x="3551" z="-629" y="44">	
		if gotJamie == false then
			checkForJamie(100)
		end
		if Dir == "BACKWARD" then
			__WPL:setDirection(WPT_BACKWARD);
		end	
	</waypoint>
	<!-- #  5 --><waypoint x="3504" z="-675" y="44"	tag="LCR">	
		if gotJamie == false then
			checkForJamie(150)
		end
		if gotJamie == false then
			__WPL:setWaypointIndex(__WPL:findWaypointTag("LFR"));
		end
	</waypoint>
	<!-- #  6 --><waypoint x="3745" z="-601" y="44"	tag="FFR"> -- Far Right
		if gotJamie == false then
			checkForJamie(200)
		end
		if Dir == "BACKWARD" then
			__WPL:setWaypointIndex(__WPL:findWaypointTag("MAIN"));
		end
	</waypoint>
	<!-- #  7 --><waypoint x="3729" z="-714" y="44">	
		if gotJamie == false then
			checkForJamie(100)
		end
		if Dir == "BACKWARD" then
			__WPL:setDirection(WPT_BACKWARD);
		end	
	</waypoint>
	<!-- #  8 --><waypoint x="3661" z="-782" y="44">	
		if gotJamie == false then
			checkForJamie(100)
		end
		if Dir == "BACKWARD" then
			__WPL:setDirection(WPT_BACKWARD);
		end	
	</waypoint>
	<!-- #  9 --><waypoint x="3594" z="-828" y="44" tag="LFR">
		if gotJamie == false then
			checkForJamie(150)
			Dir = "BACKWARD"
			__WPL:setDirection(WPT_BACKWARD);
		end
	</waypoint>
	<!-- # 10 --><waypoint x="3771" z="-461" y="44"	tag="FCL">	  -- Close Left	
		if gotJamie == false then
			checkForJamie(150)
		end
		if Dir == "BACKWARD" then
			__WPL:setWaypointIndex(__WPL:findWaypointTag("MAIN"));
		end	
	</waypoint>
	<!-- # 11 --><waypoint x="3860" z="-413" y="44">	
		if gotJamie == false then
			checkForJamie(100)
		end
		if Dir == "BACKWARD" then
			__WPL:setDirection(WPT_BACKWARD);
		end	
	</waypoint>
	<!-- # 12 --><waypoint x="3947" z="-354" y="44"	tag="LCF">
		if gotJamie == false then
			checkForJamie(150)
			Dir = "BACKWARD"
			__WPL:setDirection(WPT_BACKWARD);
		end
	</waypoint>
	<!-- # 13 --><waypoint x="3797" z="-555" y="44"	tag="FFL">     -- Far Left	
		if gotJamie == false then
			checkForJamie(200)
		end
		if Dir == "BACKWARD" then
			__WPL:setWaypointIndex(__WPL:findWaypointTag("MAIN"));
		end	
	</waypoint>
	<!-- # 14 --><waypoint x="3925" z="-579" y="44">		
		if gotJamie == false then
			checkForJamie(100)
		end
		if Dir == "BACKWARD" then
			__WPL:setDirection(WPT_BACKWARD);
		end	
	</waypoint>
	<!-- # 15 --><waypoint x="4024" z="-513" y="44"	tag="LFL">	
		if gotJamie == false then
			checkForJamie(150)
		end
		if gotJamie == false then
			__WPL:setWaypointIndex(__WPL:findWaypointTag("LCF"));
		end
	</waypoint>
	<!-- #  1 --><waypoint x="3410" z="174" y="44" tag="next">
			clearAll()
			LoginNextChar()
			loadProfile()
			loadPaths("SecretGarden");
	</waypoint>
</waypoints>