<?xml version="1.0" encoding="utf-8"?>
<waypoints>
	<onLoad>
		-- V 1.9
		<![CDATA[
			id_kate		= 121035
			id_magelly	= 120687
						
			-- Move to Kate Wesker and enter
			player:target_NPC(id_kate)
			
			--ChoiceOptionByName("Transport to Andor Training Range"); yrest(1000)
			ChoiceOptionByName(getTEXT("SKWERL_MOBIUS_24")) yrest(1000)
			
			waitForLoadingScreen()
			
			-- Move to Magelly Basac
			player:target_NPC(id_magelly)
			
			-- Check if we already completed
			--ChoiceOptionByName("Register for timed training"); yrest(1000)  
			ChoiceOptionByName(getTEXT("SKWERL_MOBIUS_14")) yrest(1000)
			
			--ChoiceOptionByName("Participate in training"); yrest(1000)  
			ChoiceOptionByName(getTEXT("SKWERL_MOBIUS_25")) yrest(1000)
			
			--ChoiceOptionByName("Confirm"); yrest(1000)
			ChoiceOptionByName(getTEXT("SYS_OKAY")) yrest(1000) --(might be wrong)
			
			function tort()
				local proc = getProc()
				
				local function checkclicked(address)
					local tmp = memoryReadRepeat("int", proc, address + addresses.pawnAttackable_offset) or 0;
					if bitAnd(tmp,0x8) then
						return true
					else
						return false
					end
				end

				local function one(ID)
					print("targeting: "..ID)
					local objectList = CObjectList();
					objectList:update();
					local objSize = objectList:size()
					for i = 0,objSize do 
						obj = objectList:getObject(i)
						obj:update()
						if (obj.Id == ID or ID == 106885) and checkclicked(obj.Address) then
							player:target(obj)
							RoMScript("UseExtraAction(1)")
							yrest(10)
							player:target(obj)
							RoMScript("UseExtraAction(1)")
							if ID == 106883 then
								yrest(10)
								player:target(obj)
								RoMScript("UseExtraAction(1)")	
							end
							yrest(100)
						end
					end
				end
				if player:findNearestNameOrId(106881) then
					local countt = 12
					print("resting a little before attacking, countdown starts now.")
					repeat
						print(countt)
						yrest(1000)
						countt = countt - 1
					until countt == 0
					for i = 1,6 do
						one(106882)
						one(106882)
						one(106881)
						one(106883)
						one(106884)	
					end
				end
			end
			
			repeat
				yrest(100)
			until  player:findNearestNameOrId(106881)
			print("OK event has started")
			repeat
				tort()
				player:update()
				buffed = player:getBuff(622402)
				yrest(100)
			until not player:hasBuff(622402) or buffed.Level >= 2800
			error("Event finished, end score was "..buffed.Level)
		]]>
	</onLoad>
</waypoints>
