<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad><![CDATA[

--[v1.1 beta]--

local npc = {}
local activitydone = false
local claimreward = getTEXT("SC_BEERDAY_29")	-- ChoiceOption(2)
local exchange = getTEXT("SC_BEERDAY_32")	-- ChoiceOption(1)
local over = getTEXT("SC_BEERDAY_23")
local points = getTEXT("SC_DANCEFES_KORS_ARR_05")
local participate = getTEXT("SC_BEERDAY_12")
local previous = getTEXT("SO_BACK")
local bottoms, golden, apple, ugh = getTEXT("SC_BEERDAY_17"):gsub("<",""):gsub(">",""):gsub("/",""):gsub("CY",""):gsub("CB",""):gsub("CS",""), getTEXT("SC_BEERDAY_18"):gsub("<",""):gsub(">",""):gsub("/",""):gsub("CY",""):gsub("CB",""):gsub("CS",""), getTEXT("SC_BEERDAY_19"):gsub("<",""):gsub(">",""):gsub("/",""):gsub("CY",""):gsub("CB",""):gsub("CS",""), getTEXT("SC_BEERDAY_20"):gsub("<",""):gsub(">",""):gsub("/",""):gsub("CY",""):gsub("CB",""):gsub("CS","")
local id = 113608
for i = 1,6 do
	npc[i] = GetIdName(id)
	id = id +1
end


local function certs()
	return inventory:itemTotalCount(205941) -- Juice Festival Attendance Certificate
end


local function getReward()
	repeat
		player:target_NPC(113462)	-- Andy Yanith
		yrest(500)
		ChoiceOptionByName(claimreward)
		yrest(1000)
		ChoiceOptionByName(exchange)
	until 15 > certs()		
end


if player:target_NPC(111707) then -- Shobot Glan
	yrest(1000)
else
	error("Could Not Find Shela Berit.")
end

ChoiceOptionByName(participate)
if ChoiceOptionByName(previous) then
	print("Seems like the character has already done this activity.")
	activitydone = true
end


EventMonitorStart("SFAD", "CHAT_MSG_SAY");

player:moveTo(CWaypoint(5033, -2372))

yrest(3000)

if not activitydone then

	repeat	

	   	local time, _, name, msg = EventMonitorCheck("SFAD", "4,1")
		if msg then
			msg = msg:gsub("|offffff00",""):gsub("|cffff0000",""):gsub("|r","")
		end
		local age;
		if time then
			age = getGameTime() - time
		end
	
	
	  	if msg and age and 2 >= age then
			print(msg)
			if name and (name == npc[1] or name == npc[2] or name == npc[3] or name == npc[4] or name == npc[5] or name == npc[6]) then
				local npc = player:findNearestNameOrId(name)
				if npc then
					cprintf(cli.green, language[136], npc.Name);	-- we successfully target NPC
					if( distance(player, npc) > 32 ) then
						player:moveInRange(CWaypoint(npc.X, npc.Z), 32, true)
					end
				end
				player:target(npc.Address)
				Attack(); yrest(50); Attack(); yrest(100)
			end
			if msg:find(bottoms) then
	   			RoMScript("UseExtraAction(1)")
				printf("Used Cheer on %s.\n", name)
	   		elseif msg:find(golden) then
	   			RoMScript("UseExtraAction(2)")
				printf("Used Golden juice on %s.\n", name)
	   		elseif msg:find(apple) then
	   			RoMScript("UseExtraAction(3)")
				printf("Used Apple Juice on %s.\n", name)
	   		elseif msg:find(ugh) then
	   			RoMScript("UseExtraAction(4)")
				printf("Used Barf bag on %s.\n", name)
			end
			yrest(1000)
			player:clearTarget();
	  	end
	
		yrest(500)

	until getLastWarning("|cfffff266"..over.."|r",10) or getLastWarning("|cfffff266"..points.." 31",10)

	EventMonitorStop("SFAD");
	
	if getLastWarning("|cfffff266"..points.." 31",10) then
		if certs() > 12 and 15 > certs() then
			player:moveTo(CWaypoint( 5106, -2455))
		elseif certs() >= 15 then
			getReward()
		end
	end

	if not getLastWarning("|cfffff266"..over.."|r",180) then
		repeat
			yrest(1000)	-- wait for the game to be officially over so the certificates can get in your bag
		until getLastWarning("|cfffff266"..over.."|r",10)
	end

	yrest(2000)

end


if certs() >= 15 then
	getReward()		
end


]]></onLoad>
</waypoints>