<?xml version="1.0" encoding="utf-8"?><waypoints>
<onLoad>
--120910,120917 green
--120911,120918 blue
--120912,120919 red
tEnergyBalls={120910,120911,120912,120917,120918,120919}
torbs = {3095,3099,3126,3164,3197}
	function nomouse()
		-- x axis
		local addressX1 = addresses.functionMousePatchAddr
		local addressX2 = addresses.functionMousePatchAddr + addresses.mousePatchX2_offset
		local addressX3 = addresses.functionMousePatchAddr + addresses.mousePatchX3_offset
		memoryWriteString(getProc(), addressX1, string.char(0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90)); -- left of window
		memoryWriteString(getProc(), addressX2, string.char(0x90, 0x90, 0x90, 0x90, 0x90, 0x90)); -- right of window
		memoryWriteString(getProc(), addressX3, string.char(0x90, 0x90, 0x90, 0x90, 0x90, 0x90)); -- over window

		-- y axis
		local addressY1 = addresses.functionMousePatchAddr + addresses.mousePatchY1_offset
		local addressY2 = addresses.functionMousePatchAddr + addresses.mousePatchY2_offset
		local addressY3 = addresses.functionMousePatchAddr + addresses.mousePatchY3_offset
		memoryWriteString(getProc(), addressY1, string.char(0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90)); -- above window
		memoryWriteString(getProc(), addressY2, string.char(0x90, 0x90, 0x90, 0x90, 0x90, 0x90)); -- below window
		memoryWriteString(getProc(), addressY3, string.char(0x90, 0x90, 0x90, 0x90, 0x90, 0x90)); -- over window
	end

	-- Unfreeze mouse function
	function unnomouse()
		-- x axis
		local addressX1 = addresses.functionMousePatchAddr
		local addressX2 = addresses.functionMousePatchAddr + addresses.mousePatchX2_offset
		local addressX3 = addresses.functionMousePatchAddr + addresses.mousePatchX3_offset
		memoryWriteString(getProc(), addressX1, string.char(unpack(addresses.functionMouseX1Bytes)));
		memoryWriteString(getProc(), addressX2, string.char(unpack(addresses.functionMouseX2Bytes)));
		memoryWriteString(getProc(), addressX3, string.char(unpack(addresses.functionMouseX3Bytes)));

		-- y axis
		local addressY1 = addresses.functionMousePatchAddr + addresses.mousePatchY1_offset
		local addressY2 = addresses.functionMousePatchAddr + addresses.mousePatchY2_offset
		local addressY3 = addresses.functionMousePatchAddr + addresses.mousePatchY3_offset
		memoryWriteString(getProc(), addressY1, string.char(unpack(addresses.functionMouseY1Bytes)));
		memoryWriteString(getProc(), addressY2, string.char(unpack(addresses.functionMouseY2Bytes)));
		memoryWriteString(getProc(), addressY3, string.char(unpack(addresses.functionMouseY3Bytes)));
	end
	
function useskill(target)
	local wwidth = 0.5
	local wheight = 0.5

	if target.X == 3197 then --  very left
	wwidth = 0.257
	wheight = 0.535
	end
	if target.X == 3164 then -- left
	wwidth = 0.335
	wheight = 0.561
	end
	if target.X == 3126 then -- middle
	wwidth = 0.486
	wheight = 0.578
	end
	if target.X == 3099 then -- right
	wwidth = 0.657
	wheight = 0.558
	end	
	if target.X == 3095 then -- very right
	wwidth = 0.745
	wheight = 0.518
	end	
	
	memoryWriteFloat(getProc(), camera.Address + addresses.camY_offset, 86.77);
	memoryWriteFloat(getProc(), camera.Address + addresses.camY_offset, 86.77);	
	memoryWriteFloat(getProc(), camera.Address + addresses.camY_offset, 86.77);

	www = memoryReadIntPtr(getProc(),addresses.staticbase_char,addresses.windowSizeX_offset)
	wwh = memoryReadIntPtr(getProc(),addresses.staticbase_char,addresses.windowSizeY_offset)
	clickXw = math.ceil(www*wwidth)
	clickYw = math.ceil(wwh*wheight)
	nomouse()
	yrest(50)
	memoryWriteIntPtr(getProc(),addresses.staticbase_char,addresses.mouseX_offset,clickXw)
	memoryWriteIntPtr(getProc(),addresses.staticbase_char,addresses.mouseY_offset,clickYw)
	yrest(50)
	RoMScript("SpellTargetUnit()")
	--print("casting skill")
	yrest(50)
	unnomouse()
	yrest(500)
end

function faceele()
local objectList = CObjectList();
objectList:update();
local objSize = objectList:size()
for i = 0,objSize do 
	local obj = objectList:getObject(i)
	if obj.Id == 120905 then
		local dist = distance(player.X, player.Z, obj.X, obj.Z)
		if closestele == nil then
			distele = dist
			closestele = obj;
		else
			if distele > dist   then
				closestele = obj;
			end			
		end
	end
end
local angle = math.atan2(closestele.Z - player.Z, closestele.X - player.X);
camera:setRotation(angle)
end
--faceele()
local angle = math.atan2((-57 - player.Z), 3158 - player.X);
camera:setRotation(angle)
while true do
	for k,v in ipairs(torbs) do
		local objectList = CObjectList();
		objectList:update();
		local objSize = objectList:size();
		for i = 0,objSize do 
			obj = objectList:getObject(i);
			if obj.X == v then
				if obj.Id == 120917 then
					RoMScript("UseExtraAction(1)")
					--print("skill 1 X: "..obj.X)					
					useskill(obj)
				end
				if obj.Id == 120918 then		
					RoMScript("UseExtraAction(2)")
					--print("skill 2 X: "..obj.X)					
					useskill(obj)
				end
				if obj.Id == 120919 then		
					RoMScript("UseExtraAction(3)")
					--print("skill 3 X: "..obj.X)					
					useskill(obj)
				end
			end
		end
	end
	yrest(500)
end

</onLoad>
</waypoints>
