<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
	<onLoad>
		player:update()

		-- in-game object names -- obtained from ID# for multi-language usage
		yourself 	= GetIdName(422241)	-- Quest "Getting to Know Yourself"
		others 		= GetIdName(422623)	-- Quest "Helping Others"
		grow 		= GetIdName(422340)	-- Quest "Helping Them Grow"
		gamunhan 	= GetIdName(112793)	-- NPC "Gamunhan"
		dqMgr 		= GetIdName(112949)	-- NPC "Daily Quest Manager"
		blinsik 	= GetIdName(112794)	-- NPC "Blinsik"
		tokenIdName = GetIdName(203038) -- Item "Phirius Token Coin"
		
		-- io stream
		TODAY = os.date("%m_%d_%Y")
		nameMaxLength = 16 		-- hard in-game character limit for RoM player name
		logpath = "/logs/elfdaily/daily_log_"..TODAY..".txt"
		logfile = getExecutionPath()..logpath
		
		--SetCharList({
		--	{account=1, chars={}},
		--	{account=2, chars={}},
		--	{account=3, chars={}},
		--},{
		--	{account=5, chars={}},
		--	{account=6, chars={}},
		--	{account=7, chars={}},
		--})

		function kill_stupid_newbie_pet()
			if player:findNearestNameOrId(113199) then  -- search vicinity for Newbie Pet
				inventory:update()
				if (inventory:itemTotalCount(207051) > 0) then
					inventory:useItem(207051)
					local newbEgg = inventory:findItem(207051); -- Newbie Pet Egg
					if newbEgg ~= nil then
						inventory:deleteItemInSlot(newbEgg.SlotNumber)
					end
				end
			end
		end

		function save_daily_log()
			inventory:update()
			local tokenQty = inventory:itemTotalCount(203038)

			-- Employ spaces after the dividing hash mark so that token quantities line up perfectly
			local numspaces = 0
			if 10 > tokenQty then numspaces = 3 elseif 100 > tokenQty then numspaces = 2 elseif 1000 > tokenQty then numspaces = 1 end
			
			-- Create and append data to log file (logs/elfdaily/daily_log_TODAY.txt)
			local file = io.open(logfile, "a+") -- append data to the end of log file
			local name = string.rep(" ", nameMaxLength - #player.Name)..player.Name
			if file then
				if table_find_word(lines_from(logfile), player.Name) then
					file:close()
					cprintf(cli.lightblue,"!! Data already exists in "..logpath.."\n")
				else
					file:write(name.." - "..string.rep(" ",numspaces)..tokenQty.." "..tokenIdName.."\n")
					file:close()
					cprintf(cli.lightblue,"Data saved to "..logpath.."\n")
				end
			else
				printf("Unable to open file to save\n\n")
			end

			sort_log()
		end

		function sort_log()
			local logdata = lines_from(logfile)
			table.sort(logdata)

			-- Remove old blank rows from current log so they don't pile up
			while table_contains_element(logdata,"") do
				for key,value in ipairs(logdata) do
					if value == "" then
						table.remove(logdata,key)
					end
				end
			end
			local sortfile = io.open(logfile,"w") -- overwrite contents of log file in place
			if sortfile then
				for key,value in ipairs(logdata) do
					sortfile:write(value.."\n")
					if key % 8 == 0 then
						sortfile:write("\n") -- Insert a blank line after 8 rows (one whole account)
					end
				end
				sortfile:close()
				cprintf(cli.yellow,"Data successfully cleaned and saved to "..logpath.."\n\n")
			else
				printf("Unable to open file to save\n\n")
			end
		end
	</onLoad>

	<!-- #  1 --><waypoint x="31953" z="3272" y="22">
		player:target_NPC(gamunhan)
		AcceptQuestByName(yourself)
		player:target_NPC(gamunhan)
		CompleteQuestByName(yourself)
	</waypoint>
	<!-- #  8 --><waypoint x="31987" z="3368" y="6">  </waypoint>
	<!-- # 22 --><waypoint x="32061" z="3391" y="5">  </waypoint>
	<!-- # 23 --><waypoint x="32212" z="3354" y="28"> </waypoint>
	<!-- # 24 --><waypoint x="32288" z="3346" y="28"> 
		kill_stupid_newbie_pet()
		player:target_NPC(dqMgr)
		AcceptQuestByName(others)
		player:target_NPC(dqMgr)
		CompleteQuestByName(others)
	</waypoint>
	<!-- # 29 --><waypoint x="32264" z="3338" y="28"> </waypoint>
	<!-- # 30 --><waypoint x="32157" z="3403" y="12"> </waypoint>
	<!-- # 31 --><waypoint x="31897" z="3886" y="12"> </waypoint>
	<!-- # 32 --><waypoint x="31842" z="4150" y="32"> </waypoint>
	<!-- # 33 --><waypoint x="31847" z="4230" y="37"> </waypoint>
	<!-- # 34 --><waypoint x="31939" z="4360" y="33"> </waypoint>
	<!-- # 35 --><waypoint x="31966" z="4437" y="15"> </waypoint>
	<!-- # 36 --><waypoint x="31921" z="4517" y="6">  </waypoint>
	
	<!-- #  1 --><waypoint x="31847" z="4592" tag="Blinsik">
		if getQuestStatus(grow) == "complete" then
			player:target_NPC(blinsik)
			CompleteQuestByName(grow)
			cprintf(cli.lightblue,"=-=-= "..player.Name.." - "..RoMScript("Daily_count()").." daily quests completed. =-=-=\n")
		end

		if RoMScript("Daily_count()") == 10 then
			save_daily_log()
			ChangeChar()
			-- LoginNextChar()
			waitForLoadingScreen()
			loadPaths(__WPL:getFileName())
		else
			kill_stupid_newbie_pet()
			player:target_NPC(blinsik)
			AcceptQuestByName(grow)
		end
	</waypoint>
	<!-- #  4 --><waypoint x="31878" z="4692"> </waypoint>
	<!-- #  2 --><waypoint x="31812" z="4849"> </waypoint>
	<!-- #  3 --><waypoint x="31415" z="5720" tag="Crystal">
		if getQuestStatus(grow) == "incomplete" then
			player:target_Object(112976,500) -- Cleaning Crystal
			__WPL:setWaypointIndex(__WPL:findWaypointTag("Crystal"))
		end
	</waypoint>
	<!-- #  4 --><waypoint x="31878" z="4692"> </waypoint>
	<!-- #  5 --><waypoint x="31843" z="4593"> 
		__WPL:setWaypointIndex(__WPL:findWaypointTag("Blinsik"))
	</waypoint>
</waypoints>