<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
	<onLoad>
	function getBadgesWanted()
		BadgesWanted = 0
		repeat
			cprintf(cli.lightgreen,"\nPlease enter the number of Dreamland Badges you wish to farm -- min = 100 ->  0 (0 = no limit)\n")
			printf(" Amount > ")
			BadgesWanted = io.stdin:read()
			BadgesWanted = tonumber(BadgesWanted)
			if type(BadgesWanted) ~= "number" or (100 > BadgesWanted and BadgesWanted > 0) or (0 > BadgesWanted) then
				cprintf(cli.yellow,"\nExpected a number greater or equal to 100!\n")
			end
		until type(BadgesWanted) == "number" and (BadgesWanted == 0 or BadgesWanted >= 100)
	end
	
	getBadgesWanted();
	
	function checkWantedBadges()
		if BadgesWanted ~= 0 then
			FlawedCrystal = 0
			CrystalDust = 0
			TotalBadges = 0
			if inventory:itemTotalCount(208679) > 0 then
				FlawedCrystal = inventory:itemTotalCount(208679)
				FlawedCrystal = FlawedCrystal*2
			end
			if inventory:itemTotalCount(208682) > 0 then
				CrystalDust = inventory:itemTotalCount(208682)
				CrystalDust = math.floor(CrystalDust/5)	
			end
			TotalBadges = FlawedCrystal+CrystalDust
			if TotalBadges >= BadgesWanted then
				cprintf(cli.yellow,"\nBadge quantity reached, trading in Crystals\n")
				tradeDreamland()
			else
				cprintf(cli.yellow,"\n"..BadgesWanted-TotalBadges.." badges worth to go.\n")
			end
		end
	end	
	
	
	function settings.profile.events.onSkillCast(arg1)					-- add ID = 104924	
		local target = player:getTarget()
		if target.Name == "Hlethfir Deliriumscribe" then
			local ghostadd = player:findEnemy(nil, 104924, evalTargetDefault);
			if ghostadd and target.Id ~= 104924 then
				player:breakFight()
				while ghostadd do
					player:target(ghostadd)
					player:fight()
					ghostadd = player:findEnemy(nil, 104924, evalTargetDefault);
				end
			end
			player:target(target)
		end
	end
		
	function settings.profile.events.onDeath()		
		pauseOnDeath();
	end

	changeProfileOption("LOOT_ALL", true)
	changeProfileOption("LOOT", true)
	changeProfileOption("ANTI_KS", false)
	changeProfileOption("PARTY", true)
	changeProfileOption("PARTY_INSTANCE", true)
	changeProfileOption("MAX_TARGET_DIST", 500)
	changeProfileOption("USE_PHIRIUS_POTION", true)
	changeProfileOption("LOOT_JUMPING", false)
	changeProfileOption("LOOT_AGAIN", 2000)
	changeProfileOption("LOOT_TIME", 1000)
	changeProfileOption("LOOT_DISTANCE", 500)
	changeProfileOption("INV_AUTOSELL_ENABLE", false)
	changeProfileOption("LOOT_IGNORE_LIST_SIZE", 0	)
	
	
	npcstarter = player:findNearestNameOrId(115689)
	if npcstarter and 300 > distance(npcstarter.X, npcstarter.Z, player.X, player.Z) then
		__WPL:setWaypointIndex(1);
	end
	
	if getZoneId() ~= 356 then
		cprintf(cli.yellow,"\nNot in Dreamland!! Enter via FA or Lazzern\n")
		player:sleep();
	end
	
	RoMScript('SetLootMethod("freeforall","")')
	CommandDone = false
	repairRun = 0
	EventMonitorStart("Dreamland", "CHAT_MSG_PARTY");
	</onLoad>
	<!-- #  1 --><waypoint x="4781" z="1004" y="9" tag='Enter'>
			if repairRun == 4 then
				sendpartychat('code"repairGear()"');
				repairGear()
				repairRun = 0
			else
				repairRun = repairRun + 1
			end
			Target_NPC(115689) -- Pioneer Dawn
			checkPartyNames()
			checkWantedBadges()
			if CommandDone == false then
				sendpartychat('code"resetDreamLandHeal()"')
				CommandDone = true
			end
			if (RoMScript("GetNumSpeakOption()") > 1) then
				repeat
					yrest(1000);
					local time, moreToCome, name, msg = EventMonitorCheck("Dreamland", "4,1")
					if msg ~= nil then
						if msg == "ready" and name ~= player.Name then
							partyIsReady(name)
						elseif msg == "Out of Dreamland Dust" then
							player:sleep()
							--if inventory:findItem(208682) and inventory:itemTotalCount(208682) >= 20 then
								--local item = inventory:findItem(208682)
								--local slotitem = inventory.BagSlot[item]
								--local emptyslot = inventory:findItem(0,"bags")
								--if not emptyslot then
								--	error("Can't split stack for Dreamland Dust Trade. Inventory is full.")
								--end
								--local topickup = slotitem.ItemCount - 20
								--RoMScript("SplitBagItem("..slotitem.BagId.." ,"..topickup..")")
								--repeat yrest(500) until RoMScript("CursorHasItem()")
								--RoMScript("PickupBagItem("..emptyslot.BagId..")")
								--yrest(1500)
								--slotitem:update()
								--tradeTo(name,{"Dreamland Crystal Dust"})
							--else
								--error("Not enough Dreamland Dust to repeat - Exiting")
							--end
						end
					end
				until StartDreamland == true
				yrest(1000);
				ChoiceOption(1);
				prevcoords = {X=player.X, Z=player.Z, Y=player.Y}
				printf("Waiting for next area to appear")
				repeat
					yrest(2000);
					player:update();
				until distance(player,prevcoords) >= 50 and isInGame();
					DLApplyDpsPots()
					logEmptySlots()
				CommandDone = false
				__WPL:setWaypointIndex(__WPL:getNearestWaypoint(player.X,player.Z,player.Y))
			else
				if 20 > inventory:itemTotalCount(208682) then
					sendpartychat('code"error("Farming Completed")"')
					error("Not enough Dreamland Crystal Dust to reset");
					
				end
				__WPL:setWaypointIndex(__WPL:findWaypointTag("Reset"));
			end
	</waypoint>
	<!-- #  2 --><waypoint x="4732" z="1059" y="8" tag='Reset'>	
		</waypoint>
	<!-- #  3 --><waypoint x="4675" z="1061" y="8">
			Target_NPC(115697) -- Pioneer Frank
			ChoiceOptionByName(getTEXT("ADS_STRING04_1")) -- 'Is there any way to remove the Dreamland energy fluctuations from my body?'
			yrest(1000);
			ChoiceOptionByName("Exchange 20 units of Dreamland Crystal Dust for one Dreamland Energy Fluctuation Masking service")
			yrest(1000);
				__WPL:setWaypointIndex(__WPL:findWaypointTag("Enter"));
	</waypoint>
	<!-- #  4 --><waypoint x="6715" z="2935" y="10">
	DLKillMobs();
	</waypoint>
	<!-- #  5 --><waypoint x="1002" z="2883" y="8">
	DLKillMobs();
	</waypoint>
	<!-- #  6 --><waypoint x="963" z="879" y="8">	
	DLKillMobs();
	</waypoint>
	<!-- #  7 --><!-- <waypoint x="1044" z="935" y="8">	</waypoint> -->
	<!-- #  8 --><waypoint x="2778" z="950" y="8">
	DLKillMobs();
	</waypoint>
</waypoints>