﻿<?xml version="1.0" encoding="utf-8"?><waypoints>
<onLoad>
	--=== User Options ===--
	
	MY_CHAR_IS_VERY_STRONG=true; --[[
		true - if you have no problem killing  Fortifying Elementals when they all aggro on you
		false - if you need a special skill/combo to kill Fortifying Elemental and not aggro other mobs
			if false then you have to adjust oneHiter() function to your class combination 
	]]
	
	When_Finished = "end"
		-- "end" to end script, "relog" to log next character and "waypointfilename" to load that waypointfile.

	CharList = {}
		-- Character list to use when using the "charlist" option above. Requires my "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}},
		--		}

	--====================--

--Some of these options are copied from botromka's script
	changeProfileOption("RES_AUTOMATIC_AFTER_DEATH", false)
	changeProfileOption("TARGET_LEVELDIF_BELOW", 40);
	changeProfileOption("AUTO_ELITE_FACTOR", 10) --don't know why 10 but it works :)
	changeProfileOption("COMBAT_DISTANCE", 170)
	changeProfileOption("MAX_TARGET_DIST", 170)
	changeProfileOption("LOOT", false);
	changeProfileOption("LOOT_IN_COMBAT", false);
	changeProfileOption("LOOT_ALL", false)
	CLEAR=true;
	EventMonitorStart("sys", "SYSTEM_MESSAGE");
------------------------

--Language settings
myLang=sendMacro("GetLanguage()")
if myLang=="DE" then myLang=2
else myLang=1
end

langString={
	fire={"fire furnace","Feuerofens"},
	earth={"earth furnace","Erdofens"},
	water={"water furnace","Wasserofens"},
	wind={"wind furnace","Windofens"},
	circle={"central transport circle","Haupt-Transportkreis-Ausgang"}
}
--------------------

--checkRelog is copied from cot_tele waypoint
	if logentry==nil then logentry=" " end;
	if numshells==nil then numshells=inventory:getItemCount(240181) end;
	function checkRelog()
		-- Log result
		local filename = getExecutionPath() .. "/logs/cot.log";
		local file, err = io.open(filename, "a+");
		if file then
			file:write("Account: "..RoMScript("GetAccountName()").."\tName: " ..string.format("%-10s",player.Name ).." \tDate: " .. os.date() ..
			" \tShells gained/total: "..inventory:getItemCount(240181) - numshells.."/".. inventory:getItemCount(240181).. "\t" ..logentry .. "\n")
			file:close();
		end

		if When_Finished == "relog" then
			sendMacro("}LoginNextToon=true;a={")
			sendMacro("Logout();");
			waitForLoadingScreen();
			loadPaths("gobs try 2");
		elseif When_Finished == "charlist" then
			SetCharList(CharList)
			LoginNextChar()
			loadPaths("gobs try 2");
		elseif When_Finished == "end" then
			error("Ending script",2)
		else
			if not string.find(When_Finished,".", 1, true) then
				When_Finished = When_Finished .. ".xml"
			end
			local filename = getExecutionPath() .. "/waypoints/" .. When_Finished
			local file, err = io.open(filename, "r");
			if file then
				file:close();
				loadPaths(When_Finished)
			else
				error("'When_Finished' option is invalid",0)
			end
		end
	end

-------------------

function getTreasureChest()
	i=nil;
	shellsBefore=inventory:getItemCount(240181);
	repeat
		if i==nil then i=1 end
		player:update();
		local tChest = player:findNearestNameOrId(113137);
		if tChest~=nil then
			printf("Chest found.");
		else
			printf("Chest not found. This was "..i.." of "..n.." tries.");
			keyboardHold(key.VK_SPACE);	yrest(999);	keyboardRelease(key.VK_SPACE);
			i=i+1;
		end
		shellsAfter=inventory:getItemCount(240181);
	until ((tChest~=nil) or (i>=10)  or (shellsAfter>shellsBefore)) 
	
	repeat
		player:target_Object(113137,3000,nil,true)
		player:update()
	until not player.Casting
	printf("Chest opens. continuing.\n");
	changeProfileOption("MAX_TARGET_DIST", 17);
	CLEAR=true;
	changeProfileOption("LOOT", false);
	fly();
end
-----------
function sysCheck(phrase)
	repeat
		local time, moreToCome, msg = EventMonitorCheck("sys")
		if msg==nil then
			return false
		elseif string.find(msg,phrase) then
			return true
		end
	until moreToCome==false
	return false
end
---------------


--fire - Raging Elemental 102099
--air Howling Elemental 102098 ; lastOne = player:findNearestNameOrId(102098);
--earth Fortifying Elemental 102100
--water Surging Elemental 102101
function lastAttack(elementalID)
	if elementalID~=nil then
		local lastOne = player:findNearestNameOrId(elementalID);
		if lastOne~=nil then
			player:target(lastOne);
			for i=1,5 do
				Attack();
				printf("lastAttack\n");
				yrest(999);
			end
		end
	end
end

---------------------
function clearIgnored()
	player.Last_ignore_target_ptr=nil;
	return
end
-- Default 10 secs is too long. Bot can pass a mob and then the chest will not spawn. 
registerTimer("clearIgnored", secondsToTimer(2), clearIgnored);

------------
function oneHiter()
if MY_CHAR_IS_VERY_STRONG==true then return end;
	--[[
If not all of your attacking skills will 1-hit a mob then
 you should disable those weak skills
 and leave only the strong skills + healing/buffing skills
 
Example below cheks if your class is a Mage 
and then disables all skils
and then enables only Flame skill (the strongest) and healing skills
You must adjust this code to suit your character's skills/classes
]]

	repeat myClass=RoMScript("UnitClass('player')"); until myClass
	if myClass=="Mage" then
		local myOneHitSkills={"MAGE_FLAME","PRIEST_URGENT_HEAL","PRIEST_REGENERATE","PRIEST_HOLY_AURA"}
		for k,v in pairs(settings.profile.skills) do
			for l,m in pairs(myOneHitSkills) do
				--printf(v.Name)
				if v.Name==m then
					printf(v.Name.."=true\n")
					v.AutoUse = true;
					break;
				else
					v.AutoUse = false;
				end
			end
		end
	elseif myClass=="Rogue" then
		local myOneHitSkills={} --put here your best skill 
		for k,v in pairs(settings.profile.skills) do
			for l,m in pairs(myOneHitSkills) do
				if v.Name==m then
					printf(v.Name.."=true\n")
					v.AutoUse = true;
					break;
				else
					v.AutoUse = false;
				end
			end
		end
	end
end


</onLoad>
	<!-- #  1 --><waypoint x="3444" z="3304" y="248" tag="start">
	__WPL:setDirection(WPT_FORWARD);
	if CLEAR==false then lastAttack(102099) end;
	</waypoint>
	<!-- #  2 --><waypoint x="3279" z="3343" y="248">if CLEAR==false then lastAttack(102099) end;	</waypoint>
	<!-- #  3 --><waypoint x="3342" z="3381" y="248">if CLEAR==false then lastAttack(102099) end;	</waypoint>
	<!-- #  4 --><waypoint x="3401" z="3349" y="248">if CLEAR==false then lastAttack(102099) end;	</waypoint>
	<!-- #  5 --><waypoint x="3449" z="3323" y="248">if CLEAR==false then lastAttack(102099) end;	</waypoint>
	<!-- #  6 --><waypoint x="3514" z="3341" y="248">if CLEAR==false then lastAttack(102099) end;	</waypoint>
	<!-- #  7 --><waypoint x="3566" z="3312" y="248">if CLEAR==false then lastAttack(102099) end;	</waypoint>
	<!-- #  8 --><waypoint x="3582" z="3245" y="248">if CLEAR==false then lastAttack(102099) end;	</waypoint>
	<!-- #  9 --><waypoint x="3630" z="3180" y="248">
		if CLEAR==false then lastAttack(102099) end;
		changeProfileOption("MAX_TARGET_DIST", 100);
	</waypoint>
	<!-- # 10 --><waypoint x="3663" z="3156" y="248" tag="fire">
	if sysCheck(langString.fire[myLang])==true then
		getTreasureChest();
	else
		CLEAR=false;
		changeProfileOption("LOOT", true);
		__WPL:setDirection(WPT_BACKWARD);
	end
	
	</waypoint>
	<!-- # 11 --><waypoint x="3683" z="3100" y="248">
	__WPL:setDirection(WPT_FORWARD);
	oneHiter();
	changeProfileOption("MAX_TARGET_DIST", 170);
	if CLEAR==false then lastAttack(102100) end;
	</waypoint>
	<!-- # 12 --><waypoint x="3725" z="3068" y="248">if CLEAR==false then lastAttack(102100) end;	</waypoint>
	<!-- # 13 --><waypoint x="3742" z="3033" y="248">if CLEAR==false then lastAttack(102100) end;	</waypoint>
	<!-- # 14 --><waypoint x="3762" z="2992" y="248">if CLEAR==false then lastAttack(102100) end;	</waypoint>
	<!-- # 15 --><waypoint x="3733" z="2954" y="248">if CLEAR==false then lastAttack(102100) end;	</waypoint>
	<!-- # 16 --><waypoint x="3800" z="2928" y="248">if CLEAR==false then lastAttack(102100) end;	</waypoint>
	<!-- # 17 --><waypoint x="3731" z="2866" y="248">if CLEAR==false then lastAttack(102100) end;	</waypoint>
	<!-- # 18 --><waypoint x="3782" z="2829" y="248">if CLEAR==false then lastAttack(102100) end;	</waypoint>
	<!-- # 19 --><waypoint x="3736" z="2784" y="248">if CLEAR==false then lastAttack(102100) end;	</waypoint>
	<!-- # 20 --><waypoint x="3701" z="2769" y="248">if CLEAR==false then lastAttack(102100) end;	</waypoint>
	<!-- # 21 --><waypoint x="3713" z="2717" y="248">if CLEAR==false then lastAttack(102100) end;	</waypoint>
	<!-- # 22 --><waypoint x="3665" z="2682" y="248">if CLEAR==false then lastAttack(102100) end;	</waypoint>
	<!-- # 23 --><waypoint x="3642" z="2653" y="248">if CLEAR==false then lastAttack(102100) end;	</waypoint>
	<!-- # 24 --><waypoint x="3580" z="2637" y="248">
		if CLEAR==false then lastAttack(102100) end;
		changeProfileOption("MAX_TARGET_DIST", 100);
	</waypoint>
	<!-- # 25 --><waypoint x="3568" z="2605" y="248" tag="earth">
	if sysCheck(langString.earth[myLang])==true then
		getTreasureChest();
	else
		CLEAR=false;
		__WPL:setDirection(WPT_BACKWARD);
	end
	</waypoint>
	<!-- # 26 --><waypoint x="3509" z="2598" y="248">
	__WPL:setDirection(WPT_FORWARD);
	changeProfileOption("MAX_TARGET_DIST", 170);
	if CLEAR==false then lastAttack(102101) end;
	</waypoint>
	<!-- # 27 --><waypoint x="3465" z="2565" y="248">if CLEAR==false then lastAttack(102101) end;	</waypoint>
	<!-- # 28 --><waypoint x="3430" z="2515" y="248">if CLEAR==false then lastAttack(102101) end;	</waypoint>
	<!-- # 29 --><waypoint x="3383" z="2579" y="249">if CLEAR==false then lastAttack(102101) end;	</waypoint>
	<!-- # 30 --><waypoint x="3305" z="2521" y="249">if CLEAR==false then lastAttack(102101) end;	</waypoint>
	<!-- # 31 --><waypoint x="3261" z="2580" y="249">if CLEAR==false then lastAttack(102101) end;	</waypoint>
	<!-- # 32 --><waypoint x="3199" z="2535" y="249">if CLEAR==false then lastAttack(102101) end;	</waypoint>
	<!-- # 33 --><waypoint x="3149" z="2602" y="249">if CLEAR==false then lastAttack(102101) end;	</waypoint>
	<!-- # 34 --><waypoint x="3096" z="2661" y="249">
		if CLEAR==false then lastAttack(102101) end;
		changeProfileOption("MAX_TARGET_DIST", 100);
	</waypoint>
	<!-- # 35 --><waypoint x="3030" z="2735" y="249" tag="water">
	if sysCheck(langString.water[myLang])==true then
		getTreasureChest();
	else
		CLEAR=false;
		__WPL:setDirection(WPT_BACKWARD);
	end
	</waypoint>
	<!-- # 36 --><waypoint x="2984" z="2855" y="248">	</waypoint>
	<!-- # 37 --><waypoint x="2999" z="2806" y="249">
	__WPL:setDirection(WPT_FORWARD);
	changeProfileOption("MAX_TARGET_DIST", 170);
	if CLEAR==false then lastAttack(102098) end;
	</waypoint>
	<!-- # 38 --><waypoint x="2941" z="2842" y="249">if CLEAR==false then lastAttack(102098) end;	</waypoint>
	<!-- # 39 --><waypoint x="2970" z="2890" y="249">if CLEAR==false then lastAttack(102098) end;	</waypoint>
	<!-- # 40 --><waypoint x="2914" z="2925" y="249">if CLEAR==false then lastAttack(102098) end;	</waypoint>
	<!-- # 41 --><waypoint x="2950" z="2983" y="249">if CLEAR==false then lastAttack(102098) end;	</waypoint>
	<!-- # 42 --><waypoint x="2905" z="3011" y="249">if CLEAR==false then lastAttack(102098) end;	</waypoint>
	<!-- # 43 --><waypoint x="2946" z="3079" y="249">if CLEAR==false then lastAttack(102098) end;	</waypoint>
	<!-- # 44 --><waypoint x="2956" z="3122" y="249">if CLEAR==false then lastAttack(102098) end;	</waypoint>
	<!-- # 45 --><waypoint x="2971" z="3182" y="249">if CLEAR==false then lastAttack(102098) end;	</waypoint>
	<!-- # 46 --><waypoint x="3016" z="3203" y="249">if CLEAR==false then lastAttack(102098) end;	</waypoint>
	<!-- # 47 --><waypoint x="3079" z="3235" y="249">
		if CLEAR==false then lastAttack(102098) end;
		changeProfileOption("MAX_TARGET_DIST", 100);
	</waypoint>
	<!-- # 48 --><waypoint x="3113" z="3279" y="249" tag="wind">	
	if sysCheck(langString.wind[myLang])==true then
		getTreasureChest();
	else
		CLEAR=false;
		__WPL:setDirection(WPT_BACKWARD);
	end
	</waypoint>
	<!-- # 49 --><waypoint x="3183" z="3291" y="249">
	__WPL:setDirection(WPT_FORWARD);
	changeProfileOption("MAX_TARGET_DIST", 170)	</waypoint>
	<!-- # 50 --><waypoint x="3239" z="3310" y="249">if CLEAR==false then lastAttack(102099) end;	</waypoint>
	<!-- # 51 --><waypoint x="3284" z="3365" y="249">if CLEAR==false then lastAttack(102099) end;	</waypoint>
	<!-- # 52 --><waypoint x="3357" z="3319" y="249">if CLEAR==false then lastAttack(102099) end;	</waypoint>
	<!-- # 53 --><waypoint x="3384" z="3375" y="249">if CLEAR==false then lastAttack(102099) end;	</waypoint>
	<!-- # 54 --><waypoint x="3422" z="3308" y="249">if CLEAR==false then lastAttack(102099) end;	</waypoint>
	<!-- # 55 --><waypoint x="3486" z="3336" y="249">if CLEAR==false then lastAttack(102099) end;	</waypoint>
	<!-- # 56 --><waypoint x="3512" z="3279" y="249">
		if CLEAR==false then lastAttack(102099) end;
		changeProfileOption("MAX_TARGET_DIST", 100);
	</waypoint>
	<!-- # 57 --><waypoint x="3566" z="3303" y="249">
		if sysCheck(langString.circle[myLang])==true then
			CLEAR=true;
		else
			CLEAR=false;
			__WPL:setDirection(WPT_BACKWARD);
		end
		fly();
	</waypoint>
	<!-- # 58 --><waypoint x="3597" z="3235" y="249">	</waypoint>
	<!-- # 59 --><waypoint x="3622" z="3165" y="249">	</waypoint>
	<!-- # 60 --><waypoint x="3699" z="3061" y="249">	</waypoint>
	<!-- # 61 --><waypoint x="3745" z="2957" y="249">	</waypoint>
	<!-- # 62 --><waypoint x="3751" z="2840" y="249">	</waypoint>
	<!-- # 63 --><waypoint x="3706" z="2754" y="249">	</waypoint>
	<!-- # 64 --><waypoint x="3651" z="2687" y="249">	</waypoint>
	<!-- # 65 --><waypoint x="3582" z="2639" y="249">	</waypoint>
	<!-- # 66 --><waypoint x="3529" z="2644" y="249">	</waypoint>
	<!-- # 67 --><waypoint x="3597" z="2721" y="222">	</waypoint>
	<!-- # 68 --><waypoint x="3635" z="2786" y="197">	</waypoint>
	<!-- # 69 --><waypoint x="3661" z="2886" y="171">	</waypoint>
	<!-- # 70 --><waypoint x="3662" z="2977" y="142">	</waypoint>
	<!-- # 71 --><waypoint x="3635" z="3052" y="122">	</waypoint>
	<!-- # 72 --><waypoint x="3602" z="3113" y="106">	</waypoint>
	<!-- # 73 --><waypoint x="3544" z="3159" y="94">	</waypoint>
	<!-- # 74 --><waypoint x="3481" z="3196" y="85">__WPL:setDirection(WPT_FORWARD);	</waypoint>
	<!-- # 75 --><waypoint x="3400" z="3113" y="85">	</waypoint>
	<!-- # 76 --><waypoint x="3334" z="3028" y="85">	</waypoint>
	<!-- # 77 --><waypoint x="3335" z="2965" y="85">
	
	HammertoothIsInTheHouse=true      --added to make hammertooth always there
	if HammertoothIsInTheHouse==nil then
		HammertoothIsInTheHouse=false
	end
	if HammertoothIsInTheHouse==true then
		for i=1,5 do
			player:target_NPC({102200,113245}); -- Sirius Hammertooth/Hammerzahn
			--player:target_NPC("Sirius Hammertooth");
		end 
		sendMacro("ChoiceOption(1);");
		yrest(1111);
		sendMacro("ChoiceOption(1);");
		HammertoothIsInTheHouse=false;
		__WPL:setDirection(WPT_BACKWARD);
	else
		
		flyoff();
		unregisterTimer("clearIgnored");
		EventMonitorStop("sys");
		RoMScript("StaticPopup_OnClick(StaticPopup1, 1);");--this line is copied from botromka's script :)
		waitForLoadingScreen();
		checkRelog();
	end
	</waypoint>
</waypoints>