<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>


--====== User Options ======--

	usepot = true			-- set to true if you want the script to use mount speed pot in your inventory if it finds one. It doesn't matter if you set this to true even if you don't have any pots. This switch is just for people who might wanna save their pots for something else so they don't want the script to use it. Anything other than true will make it default to false.

	gethighestreward = false	-- set to true if you want to complete the quest ONLY when you're going to get five certificates (meaning, you had a fast run and completed it with more than 2.5 minutes left). The script will cancel the quest and redo it until it gets a fast time. Setting this to anything other than true will make it default to false.

	npctalktime = nil		-- this is only relevant if you set gethighestreward to true. You will have to account for how many seconds it takes your character to talk to the npc and complete the quest. If you have high ping, then make sure this number is set high enough, do some testing to make sure. If set to nil, it will default to 5.

	nextwp = ""			-- sets the next waypoint file you want to load after this waypoint finishes.

--==========================--



	
questid = 422917
drunk = 620787
chill = 620789
npc = 111452 -- Pechores
pot = inventory:findItem(207204)
claimreward = getTEXT("SC_BEERDAY_29")	-- ChoiceOption(2)
exchange = getTEXT("SC_BEERDAY_32")	-- ChoiceOption(1)

function toboolean(arg)
	return type(arg) == "string" and arg == "true" or type(arg) == "boolean" and arg == true
end


gethighestreward = toboolean(gethighestreward)
usepot = toboolean(usepot)
npctalktime = tonumber(npctalktime) or 5
limit = 150 + npctalktime

	
function drink()
	player:updateBuffs()
	yrest(10)	
	local juice = inventory:findItem(240506)
	if juice and not player:hasBuff(drunk) then
		for i = 1, 9 do
			juice:use()
			yrest(250)
		end
		printf("Your current Speed is %s.\n",math.floor(mSpeed()))
	end
end


function quest()
	return getQuestStatus(questid)
end


function cancel()
	printf("Canceling quest.\n")
	CancelQuest(questid)
	yrest(500)
end


function mSpeed()
	local mountAddress = memoryReadInt(getProc(), playerAddress + addresses.game_root.pawn.mount_ptr);
	local speed = 50.0;
	
	if( mountAddress ~= nil ) then
		speed = memoryReadFloat(getProc(), mountAddress + addresses.game_root.pawn.base_speed) or 50.0;
	end
	return speed;
end


player:update()
yrest(500)

if 2 > inventory:itemTotalCount(0) then
	cprintf(cli.lightred,"\nThere Is Not Enough Bag Space For The Quest Item/s.\n\n")
	error("Not enough Bag Space.")
end

if usepot and pot then
	pot:use()
	yrest(500)
end

if not player.Mounted then
	repeat
		player:mount()
		yrest(500)
		player:updateMounted()
		yrest(500)
	until player.Mounted
end

cancel()

__WPL:setWaypointIndex(1)

</onLoad>
	<!-- #  1 --><waypoint x="-29103" z="29327" y="-141">
	if quest() == "not accepted" then
		local retries = 0
		repeat		
			player:target_NPC(npc); 
			yrest(500)
			AcceptQuestByName(questid)
			yrest(500)
			retries = retries + 1
		until quest() ~= "not accepted" or retries == 8
		if retries == 8 then
			print("Seems like the char has already done the quest for today.")
			loadPaths(nextwp)
		else
			registerTimer("Drink", 100, drink);
		end
	end
	</waypoint>
	<!-- #  2 --><waypoint x="-29506" z="29136" y="-86">	</waypoint>
	<!-- #  3 --><waypoint x="-30239" z="29139" y="-84">	</waypoint>
	<!-- #  4 --><waypoint x="-31113" z="29157" y="-86">	</waypoint>
	<!-- #  5 --><waypoint x="-31307" z="28949" y="-85">
		player:target_NPC(119194); -- Juice Party Station Employee
	</waypoint>
	<!-- #  6 --><waypoint x="-31490" z="29204" y="-116">	</waypoint>
	<!-- #  7 --><waypoint x="-32058" z="29255" y="-136">	</waypoint>
	<!-- #  8 --><waypoint x="-32468" z="29263" y="-135">
		player:target_NPC(119194);
	</waypoint>
	<!-- #  9 --><waypoint x="-32460" z="29627" y="-136">	</waypoint>
	<!-- # 10 --><waypoint x="-32795" z="29848" y="-136">	</waypoint>
	<!-- # 11 --><waypoint x="-32996" z="30161" y="-136">	</waypoint>
	<!-- # 12 --><waypoint x="-33184" z="30194" y="-136">
		player:target_NPC(119194);
	</waypoint>
	<!-- # 13 --><waypoint x="-32971" z="30140" y="-136">	</waypoint>
	<!-- # 14 --><waypoint x="-32738" z="29790" y="-136">	</waypoint>
	<!-- # 15 --><waypoint x="-32455" z="29628" y="-134">	</waypoint>
	<!-- # 16 --><waypoint x="-32446" z="28892" y="-136">	</waypoint>
	<!-- # 17 --><waypoint x="-32845" z="28585" y="-136">	</waypoint>
	<!-- # 18 --><waypoint x="-32727" z="28137" y="-171">	</waypoint>
	<!-- # 19 --><waypoint x="-32208" z="27609" y="-136">	</waypoint>
	<!-- # 20 --><waypoint x="-32416" z="27245" y="-136">
		player:target_NPC(119194);
	</waypoint>
	<!-- # 21 --><waypoint x="-32582" z="27197" y="-136">	</waypoint>
	<!-- # 22 --><waypoint x="-32578" z="26936" y="-136">	</waypoint>
	<!-- # 23 --><waypoint x="-32336" z="26696" y="-136">	</waypoint>
	<!-- # 24 --><waypoint x="-32332" z="26074" y="-136">	</waypoint>
	<!-- # 25 --><waypoint x="-32362" z="25807" y="-134">
		player:target_NPC(119194);
	</waypoint>
	<!-- # 26 --><waypoint x="-32321" z="26163" y="-136">	</waypoint>
	<!-- # 27 --><waypoint x="-32359" z="26732" y="-136">	</waypoint>
	<!-- # 28 --><waypoint x="-32646" z="27002" y="-135">	</waypoint>
	<!-- # 29 --><waypoint x="-32651" z="27477" y="-170">	</waypoint>
	<!-- # 30 --><waypoint x="-32452" z="27756" y="-170">	</waypoint>
	<!-- # 31 --><waypoint x="-32570" z="27960" y="-171">	</waypoint>
	<!-- # 32 --><waypoint x="-32761" z="28162" y="-171">	</waypoint>
	<!-- # 33 --><waypoint x="-32872" z="28538" y="-136">	</waypoint>
	<!-- # 34 --><waypoint x="-32438" z="28904" y="-136">	</waypoint>
	<!-- # 35 --><waypoint x="-32367" z="29152" y="-136">	</waypoint>
	<!-- # 36 --><waypoint x="-31904" z="29239" y="-136">	</waypoint>
	<!-- # 37 --><waypoint x="-30986" z="29188" y="-84">	</waypoint>
	<!-- # 38 --><waypoint x="-30095" z="29126" y="-84">	</waypoint>
	<!-- # 39 --><waypoint x="-29439" z="29163" y="-92">	</waypoint>
	<!-- # 40 --><waypoint x="-29103" z="29327" y="-141">
	if quest() == "complete" then
		if gethighestreward and player:hasBuff(chill) and limit > player:getBuff(chill).TimeLeft  then
			cancel()
			printf("Couldn't do quest fast enough. Redoing Quest.\n")
			loadPaths(__WPL.FileName)
		end
		repeat		
			player:target_NPC(npc);
			yrest(500)
			CompleteQuestByName(questid)
			yrest(500)
		until quest() ~= "complete"
		unregisterTimer("Drink");
		if inventory:itemTotalCount(205941) >= 15 then  -- Juice Festival Attendance Certificate
			repeat
				player:target_NPC(121361); -- Juice Festival Reward Commissioner
				yrest(500)
				ChoiceOptionByName(claimreward)
				yrest(1000)
				ChoiceOptionByName(exchange)			
			until 15 > inventory:itemTotalCount(205941)
		end
		loadPaths(nextwp)  						
	else
		if quest() == "incomplete" then
			cancel()
			printf("Something went wrong during the run. Reloading WP.\n")
		end
		loadPaths(__WPL.FileName)
	end
	</waypoint>
</waypoints>