<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onload> 
	--=== 	NoobBotter's Kashaylan Eoj Script Version 2.0									===--
	--===	Does only channels 1, 2, will start on whichever channel you're on 			===--
	--===	and then does the next channel, then waits till next round and goes from there. ===--
	
	--===  User Settings  ===--
	local objectClickRest = 200 -- this is the delay time (in milliseconds) that it wait when clicking on one of the flasks. Higher ping time may need a higher value.
	local disableSkills = true 	-- set to true to disable skills, or false to keep skills enabled
	local maxEoj = 4000			-- set to the maximum amount of eoj's you want to have. Script will stop when you reach this amount. I believe in-game maximum is 4000.
	local maxMinutes = 50		-- Maximum amount of time (in minutes) to run the script for. 999 (or greater) will run indefinitely.
								-- the time check is performed between event rounds so if max time is passed during an event, it will complete that event before stopping. 
	
	local restTime = 120			-- this is how many minutes the bot will rest after reaching maxMinutes. A setting of 0 will cause the bot to never start back up after reaching max minutes.
		--=== Examples:					
			-- if you want the bot to run for 2 hours and then take a 3 hour break, set the following settings:
			-- local maxMinutes = 120
			-- local restTime = 180
			
			-- if you want the bot to run for 12 hours and then stop until you manually restart it, set the following:
			-- local maxMinutes = 720
			-- local restTime = 0
	
	When_Finished = "end"
		-- "end" to end script, "relog" to log next character, "charlist" to log next in 'charlist', or filename for next waypoint to load (without .xml).							
	
	CharList = {}
		-- Character list to use when using the "charlist" option above. Requires Rock5's "userfunction_LoginNextChar" userfunction.
		-- Find it here. http://www.solarstrike.net/phpBB3/viewtopic.php?p=10350
		--		eg.
		--		CharList = {
		--			{account=4,chars={}},
		--			{account=8,chars={1}},
		--			{account=7,chars={1,2,5}}
		--		}
		
	
	-- NO NEED TO EDIT BELOW THIS LINE.
	local QuestID = 427058
	startChannel = RoMScript("GetCurrentParallelID()")
	yrest(500)
	if startChannel == 3 then
		RoMScript("ChangeParallelID(1)")
		repeat
			yrest(4000)
		until RoMScript("GetCurrentParallelID()") == 1
	end
	
	--============= FUNCTIONS ===============--
	
	--============= function to check player location +==============--
	local function locationCheck()
		local myitem = player:findNearestNameOrId(123561) -- Jenn Shadoli
		if myitem then
			if distance(myitem, player) > 50 then
				print("%s is not close enough to start location for this eoj quest.\n")
				checkRelog()
			end
		else
			print("Cannot locate eoj quest giver Jenn Shadoli (ID: 123561).\n")
			checkRelog()
		end
	end
	
	
	--============= function to disable pet and skills for this quest ===============--
	
	function setSkills()
		if disableSkills == true then
			settings.profile.options.EGGPET_ENABLE_ASSIST = false
			for k,v in pairs(settings.profile.skills) do
				v.AutoUse = false
			end
		end
	end
	
	--=== relog function from Rock5's scripts ===--
	function checkRelog()
		
		-- Log result
		local filename = getExecutionPath() .. "/logs/eoj.log";
		local file, err = io.open(filename, "a+");
		if file then
			file:write("Acc: "..RoMScript("GetAccountName()").."\tName: " ..string.format("%-10s",player.Name ).." \tDate: " .. os.date() ..
			"\tEnergy of Justice Gained:"..totalEojEarned.." \tTotal EoJ on character: "..getCurrency("eoj").."\n")
			file:close();
		end

		if When_Finished == "relog" then
			ChangeChar()
			waitForLoadingScreen();
			yrest(3000)
			loadProfile()
			loadPaths(__WPL.FileName);
		elseif When_Finished == "charlist" then
			SetCharList(CharList)
			LoginNextChar()
			loadProfile()
			loadPaths(__WPL.FileName);
		elseif When_Finished == "end" then
			DN_AutoQuest(QuestID,"off")
			error("EOJ Script is complete")
		else
			DN_AutoQuest(QuestID,"off")
			loadProfile() -- Because we messed with the skills
			loadPaths(When_Finished)
		end
	end
	
	--=== Function to change channels when needed ===--
	function changeChannel()
		if RoMScript("GetCurrentParallelID()") == 1 then
			RoMScript("ChangeParallelID(2)")
		else
			RoMScript("ChangeParallelID(1)")
		end
		print("waiting 28 secs to change chan")
		yrest(28000)
		print("moving 1 step forward then waiting 1 second to stand up")
		keyboardPress(key.VK_W)
		yrest(1000)
	end
	
	
	--===  Function to target the objects very quickly in succession ===--
	function fastTarget(_objid, waittime)
		obj = player:findNearestNameOrId(_objid)
		player:target(obj.Address)
		yrest(100)
		Attack()
		yrest(waittime)
	end
	
	
	--== main function that loops over, and over, and over ===--
	local function mainfunction()
		setSkills()
		--============= create variables ===============--
		local gomsg = getTEXT("SC_ZONE_PE_3TH_ST1START")
		local endmsg = getTEXT("SC_ZONE_PE_3TH_FAIL")
		local endmsg2 = getTEXT("SC_ZONE_PE_3TH_ST1OVER")
		local roundStartTime = os.time()
		local nextRound = 0
		local roundTime = 0
		local roundCount = 1
		local eventFinished = false
		local eojs = getCurrency("eoj") 
		yrest(500)
		local neweoj = eojs
		local gained = neweoj-eojs
		local totalEojEarned = 0
		local roundendedtime = os.time()
		local EventComplete = false
		local firstRun = true
		DN_AutoQuest(QuestID) 	-- activate DailyNotes Autoquest 
		
		repeat				-- Loops once per event.
			eojs = getCurrency("eoj") 
			roundTime = (os.time()-roundStartTime)/60
			nextRound = 20-roundTime
			if firstRun == false then
				if nextRound > 5 and EventComplete == false then -- if more than 5 minutes remaining in round, change channel:
					cprintf(cli.yellow,"\r%0.1f minutes until next round starts... Changing channel.", nextRound)
					changeChannel()
					
				else
					repeat
						roundTime = (os.time()-roundStartTime)/60
						nextRound = 20-roundTime
							
						--============= insert option to change channel and continue =====--
						if 1 > nextRound then
							roundCount = 1
							cprintf(cli.yellow,"\rTime till next round start: %0.1f seconds.",nextRound/60)
						else
							
							cprintf(cli.yellow,"\rTime till next round start: %0.1f minutes.",nextRound)
						end
						
						yrest(500)
					until getLastWarning("|cffffff80"..gomsg.."|r", 10)
				end
			end
						
			repeat
				player:target_NPC(123561) -- Jenn Shadoli
				yrest(200)
				fastTarget(123369,objectClickRest);
				fastTarget(123368,objectClickRest);
				fastTarget(123508,objectClickRest);
				yrest(200)
				player:target_NPC(123561) -- Jenn Shadoli
				yrest(200)
				if getLastWarning("|cffffff80"..endmsg.."|r", 10) then
					eventFinished = true
				end
				if getLastWarning("|cffffff80"..endmsg2.."|r", 10) then
					eventFinished = true
					
				end			
				printf("Time since started this round: %0.1f \tBeen running for %0.1f minutes.\n", (os.time()-roundStartTime)/60,(os.time()-scriptStartTime)/60)
			until eventFinished == true 
			roundCount = roundCount + 1
			if roundCount >= 3 then
				roundCount = 1
				EventComplete = true
			end
			eventFinished = false
			inventory:update()
			yrest(1000)
			neweoj = getCurrency("eoj")
			gained = neweoj-eojs
			totalEojEarned = totalEojEarned + gained
			roundendedtime = os.time()
			roundTime = (roundendedtime-roundStartTime)/60
			cprintf(cli.red,"Round took %s Minutes. EOJ's Gained this round: %s.\t\tCurrent Energy of Justice: %s. \n",roundTime, gained, neweoj)
			
			--=== At start of script, I don't have a timer for when the event will start.                   ===--
			--=== but after first event completes, this variable is set to false so it can display a timer  ===--
			--=== for when the next event will start, located in waitevent() function.                      ===--
			if firstRun == true then  
				firstRun = false
			end
			if neweoj >= maxEoj then
				print("You have reached your maximum number of EoJ's as per the maxEoj variable.\n")
				checkRelog()
			end
			--== section to determine max run time, and rest time ==--
			if 999 > maxMinutes then
				if (roundendedtime-scriptStartTime)/60 >= maxMinutes then
					if restTime == 0 then
						print("Maximum run time has been exceeded.")
						checkRelog()
					else
						printf("Now resting for %s minutes.\n", restTime)
						repeat
							local doneResting = ((roundendedtime/60)+restTime)-os.time()/60
							yrest(6000)
							cprintf(cli.yellow,"\rTime till done resting: %0.1f minutes.",doneResting)
						until 0 >= doneResting
						
						scriptStartTime = os.time()
					end
				end
			end
		until 5 == 1
	end
	
	locationCheck()
	scriptStartTime = os.time() 	-- to determine total script run time
	mainfunction()

</onload>
</waypoints>