<waypoints type="TRAVEL"><!-- Tirodel_ll v2.1.4 by Bot_romka -->

	<onLoad>
<!-- Variables -->

		-- Names table of Tier Mana stones Receivers on same account.
		TierReceiver = {"CharName1",		-- Name of Tier Receiver 1. T10 and above
						"CharName2",			-- Name of Tier Receiver 2. T4, T5 and T6
						"CharName3",			-- Name of Tier Receiver 3. T4, T5 and T6
						"CharName4",			-- Name of Tier Receiver 4. T4, T5 and T6
						"CharName5",			-- Name of Tier Receiver 5. T4, T5 and T6
						"CharName6",			-- Name of Tier Receiver 6. T7, T8 and T9
						};									<!-- Names table of Tier Mana stones Receivers. -->
		LastManaStoneSender = TierReceiver[#TierReceiver]	<!-- Set Last Mail Sender -->

		-- Messages
		Text1 = "SendMe"						<!-- Message to MailSender -->
		Text2 = "Go."							<!-- Message to Twink-MailReceiver -->

		-- for send stones
		ManaStones1 = {202843, 202844, 202845}		<!-- T4, T5 and T6 -->
		ManaStones2 = {202846, 202847, 202848}		<!-- T7, T8 and T9 -->
		ManaStones3 = {202999, 203001, 202849}		<!-- T10 and Fusion -->
		ManaStones4 = {202850, 202851, 202852}		<!-- T11, T12 and T13 -->

		-- Set Twink Client for restart. specify you client shortcut links name if it not contains *client*
		TierTwinkClient = "C_Tirodel"				<!-- Set Twink Client for restart. specify you client shortcut links name if it not contains *client* -->

		-- Set CharList. Account grope of MailSender1 must be ferst and account grope Fusion Stone Sender must be second
		-- for Set account and character number for MailSender and FusionSender
		CharList = {
					{	-- Mail Sender 1
						{account=52,chars={2}},
						},
					{	-- Fusion Stone Sender
						{account=53,chars={1}},
						},
					{	-- Mail Sender 2-4
						{account=65,chars={1,2,3,4}},
						},
					{	-- Mana Stone Sender and resivers
						{account=55,chars={}},
						},
					{	-- 2 Stat Fusion  Stone Senders
						{account=50,chars={}}, {account=51,chars={}}, {account=60,chars={}},
						},
					{	-- 2 Stat Mana Stone Senders
						{account=61,chars={}}, {account=62,chars={}}, {account=63,chars={}},
						},
					{	-- account group 1
						{account=6,chars={}}, {account=7,chars={}}, {account=8,chars={}}, {account=9,chars={}}, {account=10,chars={}},
						{account=11,chars={}}, {account=12,chars={}}, {account=13,chars={}}, {account=14,chars={}},
						},
					{	-- account group 2
						{account=25,chars={}}, {account=26,chars={}}, {account=27,chars={}}, {account=28,chars={}}, {account=29,chars={}},
						{account=30,chars={}}, {account=31,chars={}}, {account=32,chars={}}, {account=33,chars={}},
						},
					{	-- account group 3
						{account=76,chars={}}, {account=77,chars={}}, {account=78,chars={}}, {account=79,chars={}}, {account=80,chars={}},
						{account=81,chars={}}, {account=82,chars={}}, {account=83,chars={}}, {account=84,chars={}},
						},
					{	-- account group 4
						{account=95,chars={}}, {account=96,chars={}}, {account=97,chars={}}, {account=98,chars={}}, {account=99,chars={}},
						{account=100,chars={}}, {account=101,chars={}}, {account=102,chars={}}, {account=103,chars={}},
						},
					{	-- account group 5
						{account=1,chars={}}, {account=2,chars={}}, {account=3,chars={}}, {account=4,chars={}},
						},
					{	-- account group 6
						{account=20,chars={}}, {account=21,chars={}}, {account=3,chars={}}, {account=4,chars={}},
						},
					{	-- account group 7
						{account=39,chars={}}, {account=40,chars={}}, {account=41,chars={}}, {account=42,chars={}},
						},
					{	-- account group 8
						{account=71,chars={}}, {account=72,chars={}}, {account=73,chars={}}, {account=74,chars={}},
						},
					{	-- account group 9
						{account=90,chars={}}, {account=91,chars={}}, {account=92,chars={}}, {account=93,chars={}},
						},
					}
		SetCharList(CharList);
		--PrintCharList();

		-- Variants table for Send Mana Stones
		SendVariants = {--4,5,6,7,8,9,10	-- Amount of Mana Stones
						{18,6,0,0,0,0,0},	-- Variant1,  T4 and T5
						{6,18,0,0,0,0,0},	-- Variant2,  T5 and T4
						{0,18,6,0,0,0,0},	-- Variant3,  T5 and T6
						{0,6,18,0,0,0,0},	-- Variant4,  T6 and T5
						{0,0,18,6,0,0,0},	-- Variant5,  T6 and T7
						{0,0,6,18,0,0,0},	-- Variant6,  T7 and T6
						{0,0,18,0,6,0,0},	-- Variant7,  T6 and T8
						{0,0,0,18,6,0,0},	-- Variant8,  T7 and T8
						{0,0,0,24,0,6,0},	-- Variant9,  T7 and T9
						{0,0,0,6,18,0,0},	-- Variant10, T8 and T7
						{0,0,0,0,6,22,0},	-- Variant11, T9 and T8
						{0,0,0,0,18,12,0},	-- Variant12, T8 and T9
						{0,0,0,12,0,18,0},	-- Variant13, T9 and T7
						{0,0,0,0,12,18,0},	-- Variant14, T9 and T8
						{0,0,0,9,9,5,0},	-- Variant15, T7, T8 and T9
						{0,0,0,6,10,8,0},	-- Variant16, T8, T9 and T7
						{24,0,0,0,0,0,0},	-- Variant17, T4
						{0,24,0,0,0,0,0},	-- Variant18, T5
						{0,0,24,0,0,0,0},	-- Variant19, T6
						{0,0,0,24,0,0,0},	-- Variant20, T7
						{0,0,0,0,24,0,0},	-- Variant21, T8
						{0,0,0,0,0,30,0},	-- Variant22, T9
				};

		-- Variables for onClientCrash
		local currAcc = RoMScript("LogID");
		local currChar = RoMScript("CHARACTER_SELECT.selectedIndex");
		local dirPath = string.gsub( getExecutionPath()," ","\" \"" );
		local currPath = __WPL.FileName;
		local Clientlink = TierTwinkClient;		-- specify you client shortcut links name if it not contains *client*
		local AfterAllError = false;				-- set to false or true for restart after all error
		cprintf(cli.white, "Current Acc: %s, Char: %s, Path: %s, dirPath: %s, Client: %s\n\n", currAcc, currChar, currPath, dirPath, Clientlink)
		-- onClientCrash
		function onClientCrash()
			if AfterAllError then
				killClient()
			else
				yrest(5000)
			end
			if( not windowValid(getAttachedHwnd()) or  AfterAllError ) then
				-- write Crash Log
				local filename = ""..dirPath.."/logs/CrashLog.log";
				local file, err = io.open(filename, "a+");
				if file then
					file:write("Account: "..currAcc.." \tName: " ..string.format("%-10s",player.Name ).." \tDate: "..os.date().." \tPath: "..currPath.." \n")
					file:close()
				end
				-- Restart client and Bot
				os.execute("START "..dirPath.."/../../micromacro.exe "..dirPath.."/login acc:"..currAcc.." char:"..currChar.." client:"..Clientlink.." path:"..currPath.."")
				os.exit()
			end
		end;
		-- check Clientlink
		if( Clientlink ) then
			atError(onClientCrash)
		end;

		-- Start Crash Window Killer
		local name, version = "Crash Window Killer", "v0.1"
		local windowname = name.." ["..version.."] started."
		local crashwinkiller = findWindow(windowname)
		if( crashwinkiller == 0 ) then
			local a,b,c = os.execute("START "..dirPath.."/../../micromacro.exe "..dirPath.."/CrashWindowKiller.lua")
			if not a then
				error("Trouble executing file. Values returned were: "..(a or "nil")..", "..(b or "nil")..", "..(c or "nil"))
			end
		end;

<!-- For All -->
		EventMonitorStart("MSGWHISPER", "CHAT_MSG_WHISPER");
		changeProfileOption("MAX_UNSTICK_TRIALS", 4);
		UMM_SetSlotRange(61, 120);
		player.free_counter1 = 0;			-- reset counter
		local Zone_Id = getZoneId();
		BotSendedMail = 0;
		last_name = "";
		BagSpace1 = 0;
		BagSpace2 = 0;

		-- MainLevel
		function MainLevel()
			--local mainLevel, secLevel = RoMScript("UnitLevel(\'"..string.gsub("player", string.char(34), ".").."\');");
			player:update();
			mainLevel = player.Level
			cprintf(cli.white, player.Name.." MainLevel: %s\n", mainLevel)
			RoMScript("DEFAULT_CHAT_FRAME:AddMessage('|cffffff00Player name: " ..player.Name.. ".|r')")
			return mainLevel
		end;
		local MainLevel = MainLevel();

		-- Code for onUnstickFailure
		function TirodelUnstick()
			repeat zoneid = RoMScript("GetZoneID()") yrest(500) until zoneid
			if( MainLevel >= 10 and zoneid == 2 or MainLevel >= 10 and zoneid == 1002 ) then
				releaseKeys()
				sendMacro("SendWedgePointReport()")
				waitForLoadingScreen()
				player = CPlayer.new()
				loadPaths(__WPL.FileName)
				player.free_counter1 = 0			-- reset counter
				player.Unstick_counter = 0			-- reset unstick counter
				inventory:update()
				player:mount()
				__WPL:setWaypointIndex(__WPL:findWaypointTag("TwinkUnstick"))
			else
				yrest(10000)
				player = CPlayer.new()
				loadPaths(__WPL.FileName)
				player.free_counter1 = 0			-- reset counter
				player.Unstick_counter = 0			-- reset unstick counter
			end
		end;

		-- Check mainLevel and Class
		if( mainLevel > 10 and 40 > mainLevel and player.Class1 == CLASS_PRIEST )
			or ( mainLevel > 10 and Zone_Id == 11 ) then
			RoMScript("DEFAULT_CHAT_FRAME:AddMessage('|cffffff00Tirodel:You are too far from Elven Island or Final.|r')")
			cprintf(cli.lightred, "You are too far from Elven Island.\n")
			LoginNextChar()
			settings.load()
			yrest(4000)
			loadPaths(__WPL.FileName)
		end;

		-- Check Mana Stones in inventory
		function CheckManaStones(minGrad, maxGrad)
			local minGrad = minGrad or 4
			local maxGrad = maxGrad or 10
			inventory:update()
			Grad = {};
			for i = minGrad,maxGrad do
				table.insert(Grad, inventory:itemTotalCount(i+202839))
			end
			return Grad
		end;

		-- Check Count Mana Stone
		function CheckCountManaStone(stonelvl)
			local stonelvl = stonelvl or 12
			MaxManaStone = 0
			for i = 4,stonelvl do
				MaxManaStone = MaxManaStone + inventory:itemTotalCount(i+202839)
			end
			return MaxManaStone
		end;
		

<!-- 1 -->
<!-- MailSender onLoad -->
		-- Check Level and Name of MailSender
		if( player.Name == Tierrec3 ) then
			cprintf(cli.lightred, "You are too far from Howling Mountains.\n")
			sendMacro("}LoginNextToon=true;a={")
			sendMacro("Logout();")
			waitForLoadingScreen()
			player = CPlayer.new()
			settings.load()
			yrest(4000)
			loadPaths(__WPL.FileName)
		elseif( 50 > MainLevel and MainLevel > 16 and Zone_Id == 400 ) then
			cprintf(cli.lightred, "You are too far from Howling Mountains.\n")
			repeat
				player:target_NPC(110758); yrest(1000);
				sendMacro("SpeakFrame_ListDialogOption(1, 1)");
				waitForLoadingScreen(30);
				player:update();
			until getZoneId() ~= 400
			yrest(4000)
			loadPaths(__WPL.FileName)
		elseif( 50 > MainLevel and MainLevel > 16 and Zone_Id ~= 1 ) then
			error("\a\aYou are too far from Howling Mountains.")
		elseif(  MainLevel > 16 and Zone_Id == 1 and distance(player.X,player.Z,-444,-5975) > 70 )	then
			error("\a\aYou are too far from Mailbox.")
		elseif(  MainLevel > 16 and Zone_Id == 1 and 1 > inventory:itemTotalCount(203276) ) then	-- Amount of Experience Orb
			error("\a\aError. Not enough Experience Orb.");
		elseif( MainLevel > 16 and Zone_Id == 1 ) then
			-- Open Mailbox
			player:target_Object(110771,1500);							-- Логарский почтовый ящик
			RoMScript("ChoiceOption(1);"); yrest(1500);
			UMM_DeleteEmptyMail();
			if( inventory:itemTotalCount(0) >= 10 ) then
				UMM_TakeMail (); yrest(4000);
			end
			RoMScript("CloseWindows()"); yrest(500); inventory:update();
		end;

		-- Hide nuby pet
		if( mainLevel > 11 and player:hasBuff(509705)) then inventory:useItem(207051);end;

		-- get Recipient
		function getRecipient()
			local timer = os.clock()
			cprintf(cli.white, "Recipient checker started.\n")
			RoMScript("DEFAULT_CHAT_FRAME:AddMessage('|cffffff00Tirodel:Recipient checker started..|r')")
			repeat
				local time, moreToCome, name, msg = EventMonitorCheck("MSGWHISPER", "4,1")
				if( time ~= nil ) then
					if( bot.ClientLanguage == "RU" ) then msg = utf82oem_russian(msg) end
					cprintf(cli.lightred, "Time: " ..os.date().. " Char name: " ..name.. " Message: " ..msg.. "\n")
					if string.find(msg,Text1) and name ~= last_name or string.find(msg,Text1) and (os.clock() - timer) > 500 then
						RoMScript("DEFAULT_CHAT_FRAME:AddMessage('|cffffff00Tirodel:Recipient Checked: " ..name.. ".|r')")
						last_name = name
						return name
					end
				end
				if( (os.clock() - timer) > 900 ) then
					player.free_counter1 = 0
					repeat
						player.free_counter1 = player.free_counter1 + 1
						printf("\a\aError or final!\n");
						yrest(20000)
					until player.free_counter1 == 10
				end
				yrest(50)
			until false
		end;

		-- Find Variant for Send Mana Stones
		function FindVariantSendManaStones()
			-- Check Mana Stones in inventory
			local Grad = CheckManaStones()
			for i,variant in pairs(SendVariants) do
				for j,values in pairs(variant) do
					--cprintf(cli.white, "value %s, Grad %s.\n", values, Grad[j])
					if values > Grad[j] then
						break
					elseif j == #variant then
						return i, variant
					end
				end
			end
			return
		end;

		-- Print Mana Stones Send Mode
		function PrintManaStonesSendMode(variant, Table)
			local pr = {}
			for i,v in pairs(Table) do
				if v ~= 0 then pr[i] = " T"..(i+3).."-"..v.."," else pr[i] = "" end
			end
			cprintf(cli.white, "Tirodel_ll: Variant%s.%s%s%s%s%s%s\n", variant, pr[1], pr[2], pr[3], pr[4], pr[5], pr[6])
		end;

		-- Find and Send Mana Stones
		function SendManaStones(recipient)
			-- Find Variant for Send Mana Stones
			local variant, send = FindVariantSendManaStones()
			-- if Ok Send Mana Stones
			if variant then
				-- Print variant
				PrintManaStonesSendMode(variant, send)
				-- Check recipient
				Recipient = recipient or getRecipient();
				-- Selecting and Send Item
				player:target_Object(110771,1500)					-- Логарский почтовый ящик
				RoMScript("ChoiceOption(1);"); yrest(1500);
				if send[1] ~= 0 then UMM_SendByNameOrId(Recipient, 202843, send[1]); yrest(500);end		-- T4 Mana Stones
				if send[2] ~= 0 then UMM_SendByNameOrId(Recipient, 202844, send[2]); yrest(500); end		-- T5 Mana Stones
				if send[3] ~= 0 then UMM_SendByNameOrId(Recipient, 202845, send[3]); yrest(500); end		-- T6 Mana Stones
				if send[4] ~= 0 then UMM_SendByNameOrId(Recipient, 202846, send[4]); yrest(500); end		-- T7 Mana Stones
				if send[5] ~= 0 then UMM_SendByNameOrId(Recipient, 202847, send[5]); yrest(500); end		-- T8 Mana Stones
				if send[6] ~= 0 then UMM_SendByNameOrId(Recipient, 202848, send[6]); yrest(500); end		-- T9 Mana Stones
				if send[7] ~= 0 then UMM_SendByNameOrId(Recipient, 202849, send[7]); yrest(500); end		-- T10 Mana Stones
				UMM_SendByNameOrId (Recipient, 203276, 1)			-- Шар опыта: 10 000 очков
				RoMScript("CloseWindows()"); yrest(500); inventory:update();
				local Botsendedstone = send[1]+send[2]+send[3]+send[4]+send[5]+send[6]+send[7]
				BotSendedMail = BotSendedMail + Botsendedstone + 1
				BagSpace2 = inventory:itemTotalCount(0) + 1
				-- Send ChatMessage to recipient
				sendMacro("SendChatMessage(\'"..Text2.."\', 'WHISPER', 0, \'"..Recipient.."\');");
			else
				return
			end
		end;


<!-- 2 -->
<!-- MailReceiver onLoad -->
		-- Check if Level >= 20 or Level == 10 and charges == 0 then Login next toon
		repeat charges = RoMScript("GetMagicBoxEnergy()"); yrest(500) until charges
		if( MainLevel >= 20 and Zone_Id ~= 20 ) or ( MainLevel == 1 and Zone_Id ~= 12 )
			or ( mainLevel > 10 and 40 > mainLevel and player.Class1 == CLASS_PRIEST ) then
			RoMScript("DEFAULT_CHAT_FRAME:AddMessage('|cffffff00Tirodel:You are too far from Elven Island or Final.|r')")
			cprintf(cli.lightred, "You are too far from Elven Island.\n")
			LoginNextChar()
			settings.load()
			yrest(4000)
			loadPaths(__WPL.FileName)
		elseif( MainLevel >= 10 and 50 > distance(player.X,player.Z,4565,-2175) and 1 > charges and CheckCountManaStone() == 0 )
			or ( MainLevel >= 10 and 50 > distance(player.X,player.Z,31797,3597) and 1 > charges and CheckCountManaStone() == 0 ) then
			cprintf(cli.lightred, "Finished. Delete Character.\n")
			sendMacro("}Logout_CharacterDelete=true;a={");
			LoginNextChar()
			settings.load()
			yrest(4000)
			loadPaths(__WPL.FileName)
		elseif( MainLevel >= 10 and 1 > charges and 50 > distance(player.X,player.Z,31797,3597) and CheckCountManaStone() ~= 0 ) then
			cprintf(cli.lightred, "Finished. ELFMailbox2.\n")
			__WPL:setWaypointIndex(__WPL:findWaypointTag("ELFMailbox2"))
		elseif( MainLevel >= 10 and 1 > charges and 50 > distance(player.X,player.Z,4565,-2175) and CheckCountManaStone() ~= 0 ) then
			cprintf(cli.lightred, "Finished. Mailbox2.\n")
			__WPL:setWaypointIndex(__WPL:findWaypointTag("Mailbox2"))
		end;

		-- TwinkGo
		function TwinkGo()
			local timer = os.clock()
			Account = RoMScript("GetAccountName();")
			cprintf(cli.white, player.Name.."-"..Account..": Whait for command started.\n")
			RoMScript("DEFAULT_CHAT_FRAME:AddMessage('|cffffff00Tirodel:Recipient Go checker started..|r')")
			repeat
				local time, moreToCome, name, msg = EventMonitorCheck("MSGWHISPER", "4,1")
				if( time ~= nil ) then
					cprintf(cli.lightred, "Time: " ..os.date().. " Char name: " ..name.. " Message: " ..msg.. "\n")
					if string.find(msg,Text2) then
						RoMScript("DEFAULT_CHAT_FRAME:AddMessage('|cffffff00Tirodel:Command Go Checked: " ..name.. ".|r')")
						break
					end
				end
				if( (os.clock() - timer) > 180 ) then
					WhispertoMailSenders()
					player.free_counter1 = player.free_counter1 + 1
					timer = os.clock()
				end
				if( player.free_counter1 == 5 ) then
					player.free_counter1 = 0
					repeat
						player.free_counter1 = player.free_counter1 + 1
						printf("\a\aTwink. Error Error!\n")
						yrest(20000)
					until player.free_counter1 == 10
				end
				yrest(50)
			until false
		end;

		-- Whisper to MailSender
		function WhispertoMailSenders()
			sendMacro("SendChatMessage(\'"..Text1.."\', 'WHISPER', 0, \'"..TierReceiver[2].."\');"); yrest(500)
			RoMScript("SendChatMessage(\'"..Text1.."\', 'WHISPER', 0, \'"..TierReceiver[3].."\');"); yrest(500)
			RoMScript("SendChatMessage(\'"..Text1.."\', 'WHISPER', 0, \'"..TierReceiver[4].."\');"); yrest(500)
			RoMScript("SendChatMessage(\'"..Text1.."\', 'WHISPER', 0, \'"..TierReceiver[5].."\');"); yrest(500)
			RoMScript("SendChatMessage(\'"..Text1.."\', 'WHISPER', 0, \'"..TierReceiver[6].."\');"); yrest(500)
		end;

		-- Error Resive Mail
		function ErrorResiveMail(Orb)
			player.free_counter1 = player.free_counter1 + 1;
			if( Orb ) then
				printf("We receive Experience Orb error!.\n")
			else
				printf("We receive Mana Stones error!.\n")
			end
			player:target_Object(112778,1500);						-- Почтовый ящик Острова Эльфов
			RoMScript("ChoiceOption(1);"); yrest(1500);
			UMM_DeleteEmptyMail();
			UMM_SendByNameOrId(TierReceiver[2], ManaStones1)			-- T4, T5 and T6 Mana Stones
			UMM_SendByNameOrId(TierReceiver[6], ManaStones2)			-- T7, T8 and T9 Mana Stones
			UMM_SendByNameOrId(TierReceiver[6], 203276)					-- Шар опыта: 10 000 очков
			WhispertoMailSenders()
			RoMScript("CloseWindows()");
			TwinkGo(); player:rest(15);
			__WPL:setWaypointIndex(__WPL:findWaypointTag("ELFMailbox"));
		end;

		-- for test only
		--include("waypoints/Test.lua",true)
	</onLoad>

<!-- 1 -->
<!-- Auto MailSender -->
	<waypoint x="-444" z="-5975" y="20" tag="Mailbox">
		-- Open Mailbox
		player:target_Object(110771,1500);							-- Логарский почтовый ящик
		RoMScript("ChoiceOption(1);"); yrest(1500);
		UMM_DeleteEmptyMail();
		if( inventory:itemTotalCount(0) >= 10 ) then
			UMM_TakeMail (); yrest(4000);
		end;
		RoMScript("CloseWindows()"); yrest(500); inventory:update();
		BagSpace1 = inventory:itemTotalCount(0);

		-- Send Mail -->
		SendManaStones();

		-- Open Mailbox
		player:target_Object(110771,1500);								-- Логарский почтовый ящик
		RoMScript("ChoiceOption(1);"); yrest(1500);
		UMM_DeleteEmptyMail();
		if( inventory:itemTotalCount(0) >= 6 ) then
			UMM_TakeMail (); yrest(4000);
		end;
		RoMScript("CloseWindows()"); yrest(500); inventory:update();

		-- Player ReLogin for mail unstuk
		if( BotSendedMail >= 50 or BotSendedMail - 1 > (BagSpace2-BagSpace1) ) then
			cprintf(cli.white, player.Name.." BotSendedMail: %s BagSpaceDif: %s\n", BotSendedMail, BagSpace2-BagSpace1)
			cprintf(cli.white, player.Name.." ReLogin for mail unstuk.\n")
			player:updateBuffs();
			if ( not player:hasBuff(506959) ) then
				--cprintf(cli.white, "You are havnt Premium!\n")
				ChangeChar("current");
				player = CPlayer.new();
				EventMonitorStart("MSGWHISPER", "CHAT_MSG_WHISPER");
			else
				repeat
					inventory:useItem(208456); yrest(1000);
					sendMacro("SpeakFrame_ListDialogOption(1, 3)")
					waitForLoadingScreen(30);
					player:update();
				until getZoneId() == 400
				repeat
					player:target_NPC(110758); yrest(1000);
					sendMacro("SpeakFrame_ListDialogOption(1, 1)");
					waitForLoadingScreen(30);
					player:update();
				until getZoneId() ~= 400
			end
			BotSendedMail = 0
		end;

		-- Check Mana Stones
		local Grad = CheckManaStones()

		-- Report
		cprintf(cli.white, player.Name.." Mana Stones T4: %s\n", Grad[1])
		cprintf(cli.white, player.Name.." Mana Stones T5: %s\n", Grad[2])
		cprintf(cli.white, player.Name.." Mana Stones T6: %s\n", Grad[3])
		cprintf(cli.white, player.Name.." Mana Stones T7: %s\n", Grad[4])
		cprintf(cli.white, player.Name.." Mana Stones T8: %s\n", Grad[5])
		cprintf(cli.white, player.Name.." Mana Stones T9: %s\n", Grad[6])
		cprintf(cli.white, player.Name.." Mana StonesT10: %s\n", Grad[7])
		cprintf(cli.white, player.Name.." Experience Orb: %s\n", inventory:itemTotalCount(203276))
		cprintf(cli.white, player.Name.." BotSendedMail:  %s\n", BotSendedMail)
		cprintf(cli.white, player.Name.." Bag Space:      %s\n", inventory:itemTotalCount(0))
			
		-- Check Amount of Experience Orb
		if( 1 > inventory:itemTotalCount(203276) ) then					-- Amount of Experience Orb
			if( player.Name ~= LastManaStoneSender ) then
				cprintf(cli.white, player.Name.." LoginNextToon.\n")
				-- Wait for Login next toon
				loadPaths(__WPL.FileName)
				LoginNextChar()
				loadPaths(__WPL.FileName)
			else
				error("\a\a\aError. Not enough Experience Orb.");
			end
		end;

		-- Check Mana Stones
		if FindVariantSendManaStones() then									-- Find Variant for Send Mana Stones
			__WPL:setWaypointIndex(__WPL:findWaypointTag("Mailbox"));
		else
			if( player.Name ~= LastManaStoneSender ) then
				cprintf(cli.white, player.Name.." LoginNextToon.\n")
				-- Wait for Login next toon
				loadPaths(__WPL.FileName)
				LoginNextChar()
				loadPaths(__WPL.FileName)
			else
				error("\a\a\aError. Final. Not enough Mana Stones.");
			end
		end;
		__WPL:setWaypointIndex(__WPL:findWaypointTag("Mailbox"));
	</waypoint>


<!-- 2 -->
<!-- Auto MailReceiver -->
	<waypoint x="31954" z="3278" tag="StartTwink">
		-- Take Giftbag
		inventory:useItem(201843);											-- 1 Lvl Giftbag

		-- Whisper to MailSender and whait for Command Go
		WhispertoMailSenders()
		TwinkGo();

		-- Set faceDirection and Rotation
		local angle = math.atan2(31925 - player.Z, 3391 - player.X);
		local yangle = 0;
		player:faceDirection(angle, yangle);
		camera:setRotation(angle);
	</waypoint>
	<waypoint x="31925" z="3391"></waypoint>
	<waypoint x="31890" z="3511"></waypoint>
	<waypoint x="31844" z="3555"></waypoint>
	<waypoint x="31797" z="3597" tag="ELFMailbox">
		-- Check for Error
		if(player.free_counter1 > 5) then
			error("\a\a\a\a\a\a\aError. Error. Error. Error. Error.");
		end;

		-- Take Mail -->
		-- Open Mailbox and take All
		player:target_Object(112778,1500);							-- Почтовый ящик Острова Эльфов
		RoMScript("ChoiceOption(1);"); yrest(2000);
		UMM_DeleteEmptyMail();
		UMM_TakeMail(); yrest(4000);
		RoMScript("CloseWindows()"); yrest(500); inventory:update();
		player:target_Object(112778,1500);							-- Почтовый ящик Острова Эльфов
		RoMScript("ChoiceOption(1);"); yrest(2000);
		UMM_DeleteEmptyMail();
		UMM_TakeMail(); yrest(4000);
		RoMScript("CloseWindows()"); yrest(500); inventory:update();

		-- Check Received Items if not All Ok then reinit all again
		if( 1 > inventory:getItemCount(203276) and 10 > MainLevel() ) then
			ErrorResiveMail(true)
		-- Check Mana Stones if not All Ok then reinit all again
		elseif not FindVariantSendManaStones() then
			ErrorResiveMail()
		-- All Ok.
		else
			if( 10 > MainLevel() ) then
				-- Use Experience Orb.
				inventory:useItem(203276); yrest(1000);
			end
			--[[
			-- Tp to Coast of Opportunity
			RoMScript("CastSpellByName(TEXT('Sys540193_name'));");		-- Tp to Heffner Camp
			print("		Tp to Coast of Opportunity");
			waitForLoadingScreen();
			player:update();
			if ( getZoneId() ~= 13 ) then error("\a\aYou are too far from Coast of Opportunity.");end
			]]--
			-- Take Giftbags
			local starttimer = os.clock()
			repeat
				inventory:useItem(201844); yrest(2500);						-- 2 Lvl Giftbag
				player:rest(math.random(5));
				inventory:update();
				player:mount();
				player:update();
			until player.Mounted or os.clock() - starttimer > 30
			-- Random Waypoint
			local WPLtag = {"Esc1","Esc2"}
			local WPLtag = WPLtag[math.random(2)]
			cprintf(cli.white, "WPL tag:        %s\n", WPLtag)
			__WPL:setWaypointIndex(__WPL:findWaypointTag(WPLtag))		
		end;
	</waypoint>
	<waypoint x="-6323" z="-3907" tag="CoastOpp">
		-- Set faceDirection and Rotation
		local angle = math.atan2(-6388 - player.Z, -3960 - player.X)
		local yangle = 0
		player:faceDirection(angle, yangle)
		camera:setRotation(angle)

		-- Tp to Varanas
		player:target_NPC(118002); yrest(1500);						-- Упрямый снуп
		RoMScript("ChoiceOption(1);"); yrest(1000);
		RoMScript("StaticPopup_OnClick(StaticPopup1, 1);");
		print("		Tp to Varanas");
		waitForLoadingScreen(60);
		player:update();

		-- Check error
		Cur_Gold = memoryReadInt( getProc(), addresses.moneyPtr )
		if( 20 > Cur_Gold ) then
			inventory:update();
			inventory:useItem(201843); yrest(1500);					-- 1 Lvl Giftbag
			inventory:useItem(201844); yrest(1500);					-- 2 Lvl Giftbag
		end;
		if ( getZoneId() ~= 2 and getZoneId() ~= 1002 ) then
			__WPL:setWaypointIndex(__WPL:findWaypointTag("CoastOpp"));
		end;
	</waypoint>
	<waypoint x="2296" z="1161" tag="SnupVaranas">
		inventory:update();
		player:mount();

		-- Set faceDirection and Rotation
		local angle = math.atan2(2603 - player.Z, 1036 - player.X)
		local yangle = 0
		player:faceDirection(angle, yangle)
		camera:setRotation(angle)
	</waypoint>
	<waypoint x="2458" z="1107" y="40"></waypoint>
	<waypoint x="2603" z="1036" y="56"></waypoint>
	<waypoint x="2765" z="964" tag="TwinkUnstick">
		-- Check for Varanas Error
		local LieveA = player:findNearestNameOrId(110755)
		if ( not LieveA or LieveA.Y-player.Y) > 35 then TirodelUnstick() end

		-- Tp to XBZ
		if RoMScript("AdvancedMagicBoxFrame == true") or RoMScript("MagicBoxFrame == true") then
			player:target_NPC(110755);  yrest(1500);					-- Лив
			RoMScript("ChoiceOption(2);");  yrest(1500);
			RoMScript("ChoiceOption(2);");
			waitForLoadingScreen(60);
			player:update()
			__WPL:setWaypointIndex(__WPL:findWaypointTag("MakeMS"));
		else
			player:target_NPC(110755);  yrest(1500);					-- Лив
			RoMScript("ChoiceOption(1);");
			waitForLoadingScreen(60);
			player:update()
			__WPL:setWaypointIndex(__WPL:findWaypointTag("Transmutor"));
		end;
	</waypoint>

<!-- Escape1 -->
	<waypoint x="31649" z="3582" tag="Esc1"></waypoint>
	<waypoint x="31540" z="3552"></waypoint>
	<waypoint x="31497" z="3527"></waypoint>
	<waypoint x="31472" z="3420"></waypoint>
	<waypoint x="31531" z="3351"></waypoint>
	<waypoint x="31644" z="3256">__WPL:setWaypointIndex(__WPL:findWaypointTag("Escape"));</waypoint>
	
<!-- Escape2 -->
	<waypoint x="31732" z="3562" tag="Esc2"></waypoint>
	<waypoint x="31636" z="3507"></waypoint>
	<waypoint x="31558" z="3475"></waypoint>
	<waypoint x="31483" z="3434"></waypoint>
	<waypoint x="31485" z="3384"></waypoint>
	<waypoint x="31603" z="3282"></waypoint>
	<waypoint x="31734" z="3197">__WPL:setWaypointIndex(__WPL:findWaypointTag("Escape"));</waypoint>

<!-- Escape3 -->
	<waypoint x="31815" z="3604" tag="Esc3"></waypoint>
	<waypoint x="31858" z="3579"></waypoint>
	<waypoint x="31965" z="3510"></waypoint>
	<waypoint x="32055" z="3399"></waypoint>
	<waypoint x="32121" z="3288"></waypoint>
	<waypoint x="32156" z="3184"></waypoint>
	<waypoint x="32123" z="3144"></waypoint>
	<waypoint x="31981" z="3143"></waypoint>
	<waypoint x="31843" z="3156">__WPL:setWaypointIndex(__WPL:findWaypointTag("Escape"));</waypoint>	
	
<!-- Rove -->
<!-- #  1 --><waypoint x="31644" z="2752" y="43" tag="Rove">	</waypoint>
<!-- #  2 --><waypoint x="31733" z="3010" y="45">	</waypoint>
<!-- #  3 --><waypoint x="31793" z="3153" y="43">	</waypoint>
	<waypoint x="31859" z="3160"></waypoint>
	<waypoint x="32029" z="3147"></waypoint>
	<waypoint x="32143" z="3159"></waypoint>
	<waypoint x="32147" z="3207"></waypoint>
	<waypoint x="32094" z="3262"></waypoint>
	<waypoint x="32025" z="3280">__WPL:setWaypointIndex(__WPL:findWaypointTag("StartTwink"));</waypoint>

<!-- Elf_Escape -->
	<waypoint x="31780" z="3149" tag="Escape"></waypoint>
	<waypoint x="31746" z="3040"></waypoint>
	<waypoint x="31720" z="2951"></waypoint>
	<waypoint x="31608" z="2696"></waypoint>
<!-- #  4 --><waypoint x="31419" z="2384" tag="CheckError">
		-- Move to first WP if not receive 10 Level or Tier Items.
		player:update(); inventory:update();
		if( ErrorSendStone ~= true ) then
			if ( 10 > player.Level ) or ( inventory:itemTotalCount(0) > 36 ) then
				__WPL:setWaypointIndex(__WPL:findWaypointTag("Rove"));
			end
		end;
		player:mount();
</waypoint>
	<waypoint x="31336" z="2269"></waypoint>
	<waypoint x="31120" z="2134"></waypoint>
	<waypoint x="30780" z="2147"></waypoint>
	<waypoint x="30639" z="2154"></waypoint>
	<waypoint x="30422" z="2170"></waypoint>
	<waypoint x="30263" z="2259"></waypoint>
	<waypoint x="30056" z="2399"></waypoint>
	<waypoint x="29934" z="2542"></waypoint>
	<waypoint x="29817" z="2674"></waypoint>
	<waypoint x="29631" z="2883"></waypoint>
	<waypoint x="29557" z="3070"></waypoint>
	<waypoint x="29513" z="3240"></waypoint>
	<waypoint x="29474" z="3373"></waypoint>
	<waypoint x="29427" z="3510"></waypoint>
	<waypoint x="29350" z="3739"></waypoint>
	<waypoint x="29273" z="3969"></waypoint>
	<waypoint x="29173" z="4205"></waypoint>
	<waypoint x="29071" z="4441"></waypoint>
	<waypoint x="28829" z="4631"></waypoint>
	<waypoint x="28641" z="4706"></waypoint>
	<waypoint x="28382" z="4791"></waypoint>
	<waypoint x="28148" z="4518"></waypoint>
	<waypoint x="27955" z="4420"></waypoint>
	<waypoint x="27842" z="4361"></waypoint>
	<waypoint x="27860" z="4254"></waypoint>
	<waypoint x="27967" z="4212"></waypoint>
	<waypoint x="28176" z="4097"></waypoint>
	<waypoint x="28392" z="3981"></waypoint>
	<waypoint x="28416" z="3787"></waypoint>
	<waypoint x="28439" z="3589"></waypoint>
	<waypoint x="28451" z="3450"></waypoint>
	<waypoint x="28324" z="3433"></waypoint>
	<waypoint x="28189" z="3432"></waypoint>
	<waypoint x="27985" z="3430"></waypoint>
	<waypoint x="27937" z="3427">
		-- Tp to Varanas
		player:target_NPC(112797);player:rest(1);			--- Сидкло
		RoMScript("ChoiceOption(1);");
		repeat yrest(5000);loggedin = RoMScript("UnitName('player');"); until loggedin
		player:update();
	</waypoint>
	
<!-- Varanas -->
	<waypoint x="4406" z="-3621" tag="Varanas"></waypoint>
	<waypoint x="4550" z="-3508"></waypoint>
	<waypoint x="4755" z="-3529"></waypoint>
	<waypoint x="4845" z="-3541"></waypoint>
	<waypoint x="4948" z="-3624"></waypoint>
	<waypoint x="5095" z="-3735"></waypoint>
	<waypoint x="5230" z="-3850"></waypoint>

	<waypoint x="5284" z="-3927" tag="Transmutor"></waypoint>
	<waypoint x="5266" z="-3971"></waypoint>
	<waypoint x="5238" z="-4023"></waypoint>
	<waypoint x="5321" z="-4120"></waypoint>
	<waypoint x="5431" z="-4238"></waypoint>
	<waypoint x="5503" z="-4343"></waypoint>
	<waypoint x="5540" z="-4422" tag="Charges">
		-- Check for Varanas Error
		if not player:findNearestNameOrId(111367) then TirodelUnstick() end
		local Lehman = player:findNearestNameOrId(111367)
		if (Lehman.Y-player.Y) > 35 then TirodelUnstick() end

	<!-- Arcane Transmutor -->
		-- Complete Quest for Arcane Transmutor
		player:target_NPC(111367); yrest(1500);					-- Леман
		RoMScript("OnClick_QuestListButton(1, 1);");
		sendMacro("AcceptQuest()"); yrest(500);
		player:target_NPC(111367); yrest(1500);					-- Леман
		RoMScript("OnClick_QuestListButton(3, 1);");
		RoMScript("CompleteQuest()"); yrest(500);
		player.free_counter1 = player.free_counter1 + 1;

		-- Error if not find NPC. TwinkUnstick
		if( player.free_counter1 == 5 ) then
			TirodelUnstick()
		end;

		repeat MBEnergy = RoMScript("GetMagicBoxEnergy()"); yrest(500) until MBEnergy
		if 10 > MBEnergy then
			__WPL:setWaypointIndex(__WPL:findWaypointTag("Charges"));
		else
			-- Tp to Elven Island
			RoMScript("UseSkill(1,2);");					-- Tp to Elven Island
			print("		Tp to Elven Island");
			waitForLoadingScreen(60);
			player:update();
			if ( getZoneId() ~= 12 ) then 
				cprintf(cli.lightred, "You are too far from Elven Island.\n");
			else
				__WPL:setWaypointIndex(__WPL:findWaypointTag("ELF10Lvl"));
			end
		end;
	</waypoint>
	<waypoint x="5523" z="-4377"></waypoint>
	<waypoint x="5401" z="-4208"></waypoint>
	<waypoint x="5307" z="-4103"></waypoint>
	<waypoint x="5238" z="-4024"></waypoint>
	<waypoint x="5270" z="-3973"></waypoint>
	<waypoint x="5274" z="-3906">
		-- Tp to VCS
		player:target_NPC(110922); yrest(1000);						-- Лив
		RoMScript("ChoiceOption(2);");
		waitForLoadingScreen(60); yrest(2500); player:update();

		-- Check for Varanas VCS Error
		if distance(player.X,player.Z,4745,-1967) > 70 then
			--keyboardHold(key.VK_W);keyboardPress(key.VK_SPACE);keyboardRelease(key.VK_W);
			keyboardPress(key.VK_W);
			yrest(2500); player:update();
			if distance(player.X,player.Z,4745,-1967) > 70 then
				TirodelUnstick()
			end
		end;
	</waypoint>
	<waypoint x="4673" z="-2004" tag="MakeMS"></waypoint>
	<waypoint x="4621" z="-2059"></waypoint>
	<waypoint x="4595" z="-2115"></waypoint>
	<waypoint x="4575" z="-2175" tag="Mailbox2">
		-- Check for Varanas Error
		if not player:findNearestNameOrId(110538) then TirodelUnstick() end
		local Mailbox = player:findNearestNameOrId(110538)
		if (Mailbox.Y-player.Y) > 30 then TirodelUnstick() end

		-- Check for MagicBox Error
		if RoMScript("AdvancedMagicBoxFrame == nil") and RoMScript("MagicBoxFrame == nil") then
			cprintf(cli.lightred, "Time: " ..os.date().. " MagicBoxFrame == nil\n")
			TirodelUnstick()
		end;
		RoMScript("UIParent:Show()");

		-- Open Mailbox
		player:target_Object(110538,1500);							-- Почтовый ящик
		RoMScript("ChoiceOption(1);"); yrest(1500);
		UMM_DeleteEmptyMail();
		UMM_TakeMail(); yrest(1000);
		RoMScript("CloseWindows()"); yrest(500);

	<!-- Make Mana Stones -->
		retry_count = 0
		repeat MBEnergy = RoMScript("GetMagicBoxEnergy()"); yrest(500) until MBEnergy
		while( MBEnergy > 0 and 7 > retry_count ) do 
			-- Open dialogs
			if RoMScript("AdvancedMagicBoxFrame ~= nil") then
				RoMScript("AdvancedMagicBoxFrame:Show()"); yrest(2000)
			else
				RoMScript("MagicBoxFrame:Show()"); yrest(2000)
			end
			RoMScript("FusionFrame:Show()"); yrest(2000)
			-- check version of Fusion
			if RoMScript("FusionFrame1 ~= nil") then
				-- Set number to make on Fusion v1.x
				RoMScript("FusionFrameFusionNumberEditBox5:SetText('10')"); yrest(2000)
				RoMScript("FusionFrameFusionNumberEditBox6:SetText('10')"); yrest(2000)
				RoMScript("FusionFrameFusionNumberEditBox7:SetText('10')"); yrest(2000)
				RoMScript("FusionFrameFusionNumberEditBox8:SetText('10')"); yrest(2000)
				RoMScript("FusionFrameFusionNumberEditBox9:SetText('10')"); yrest(2000)
				RoMScript("FusionFrameFusionNumberEditBox10:SetText('10')"); yrest(2000)
				-- Do
				RoMScript("Fusion_QueueManastones(FusionFrame_Do)");
				repeat yrest(2000) until RoMScript("Fusion.LastGrad")==0 or RoMScript("MagicBoxFrame:IsVisible()")==false
				-- EmptyMagicBox
				RoMScript("PickupBagItem(51);"); yrest(500);
				RoMScript("PickupBagItem(Fusion_SearchEmptyBagslot(1));"); yrest(500);
				RoMScript("PickupBagItem(52);"); yrest(500);
				RoMScript("PickupBagItem(Fusion_SearchEmptyBagslot(2));"); yrest(500);
				RoMScript("PickupBagItem(53);"); yrest(500);
				RoMScript("PickupBagItem(Fusion_SearchEmptyBagslot(3));"); yrest(500);
			else
				-- on Fusion v2.0 and newer
				RoMScript("Fusion:Config_OnShow()"); yrest(500)
				RoMScript("FusionFrame_Number6EditBox:SetNumber(10)"); yrest(500)
				RoMScript("FusionFrame_Number7EditBox:SetNumber(10)"); yrest(500)
				RoMScript("FusionFrame_Number8EditBox:SetNumber(10)"); yrest(500)
				RoMScript("FusionFrame_Number9EditBox:SetNumber(10)"); yrest(500)
				RoMScript("FusionFrame_Number10EditBox:SetNumber(10)"); yrest(500)
				RoMScript("Fusion:Config_Save()"); yrest(500)
				-- Do
				RoMScript("Fusion:Do_OnClick(FusionFrame_Do)");
				repeat
					yrest(1500)
				until RoMScript("Fusion.DoQueue")~=true and RoMScript("Fusion.EmptyMagicBox") ~= true
			end
			-- close 
			yrest(2000)
			if RoMScript("AdvancedMagicBoxFrame ~= nil") then
				RoMScript("AdvancedMagicBoxFrame:Hide()"); yrest(2000)
			else
				RoMScript("MagicBoxFrame:Hide()"); yrest(2000)
			end
			inventory:update(); player:update();
			repeat MBEnergy = RoMScript("GetMagicBoxEnergy()"); yrest(500) until MBEnergy
			retry_count = retry_count + 1;
		end;
		
		-- Error if not receive Mana Stones
		repeat MBEnergy = RoMScript("GetMagicBoxEnergy()"); yrest(500) until MBEnergy
		if( MBEnergy > 0 ) then
			error("\a\a\aWe didn't receive Mana Stones.");
		end;

		-- Open Mailbox
		player:target_Object(110538,1500);							-- Почтовый ящик
		RoMScript("ChoiceOption(1);"); yrest(1500);
		UMM_DeleteEmptyMail();
		UMM_TakeMail(); yrest(1000);
		RoMScript("CloseWindows()"); yrest(500);

		-- Open Mailbox and Send Mana Stone and Gold
		local retry_count = 0;
		while( CheckCountManaStone() ~= 0 and 5 > retry_count ) do
			retry_count = retry_count + 1;
			TierReceiver1 = TierReceiver[math.random(2,5)]
			cprintf(cli.lightred, "Time: " ..os.date().. " Char name: " ..TierReceiver1.. "\n")
			-- check version of Fusion and EmptyMagicBox
			if RoMScript("FusionFrame1 ~= nil") then
				RoMScript("PickupBagItem(51);"); yrest(500);
				RoMScript("PickupBagItem(Fusion_SearchEmptyBagslot(1));"); yrest(500);
				RoMScript("PickupBagItem(52);"); yrest(500);
				RoMScript("PickupBagItem(Fusion_SearchEmptyBagslot(2));"); yrest(500);
				RoMScript("PickupBagItem(53);"); yrest(500);
				RoMScript("PickupBagItem(Fusion_SearchEmptyBagslot(3));"); yrest(500);
			end
			player:target_Object(110538,1500);								-- Почтовый ящик
			RoMScript("ChoiceOption(1);"); yrest(1500);
			UMM_SendByNameOrId (TierReceiver1, 203276)				-- Шар опыта: 10 000 очков
			UMM_SendByNameOrId(TierReceiver1, ManaStones1)			-- Камни маны ур. 4, ур. 5, и ур. 6
			UMM_SendByNameOrId(TierReceiver[6], ManaStones2) 		-- Камни маны ур. 7, ур. 8, ур. 9
			UMM_SendByNameOrId(TierReceiver[1], ManaStones3)		-- Камни маны ур. 10 и случайные
			UMM_SendByNameOrId(TierReceiver[1], ManaStones4)		-- Камни маны ур. 11 и ...
			UMM_SendByFusedTierLevel(TierReceiver[1], 4)			-- Шмотоки для тира
			RoMScript("PickupBagItem(51);"); yrest(1000)
			RoMScript("PickupBagItem(70);"); yrest(1000)
			RoMScript("CloseWindows()");
			inventory:update();
		end;

		cprintf(cli.white, "Twink T4 Mana Stone:       %s\n", inventory:itemTotalCount(202843))
		cprintf(cli.white, "Twink T5 Mana Stone:       %s\n", inventory:itemTotalCount(202844))
		cprintf(cli.white, "Twink T6 Mana Stone:       %s\n", inventory:itemTotalCount(202845))
		cprintf(cli.white, "Twink T7 Mana Stone:       %s\n", inventory:itemTotalCount(202846))
		cprintf(cli.white, "Twink T8 Mana Stone:       %s\n", inventory:itemTotalCount(202847))
		cprintf(cli.white, "Twink T9 Mana Stone:       %s\n", inventory:itemTotalCount(202849))
		cprintf(cli.white, "Twink T10 Mana Stone:      %s\n", inventory:itemTotalCount(202850))
		cprintf(cli.white, "Twink T11 Mana Stone:      %s\n", inventory:itemTotalCount(202851))
		Account = RoMScript("GetAccountName();");
		cprintf(cli.white, player.Name.."_"..Account.." Bot sended: Mana Stone.\n");

		-- Error if not Send Random Fusion Stone T4, T5, T6, T7, T8 or T9 Stone
		if( CheckCountManaStone() ~= 0 ) then    
			error("\a\a\a\a\a\a\aWe didn't Send Mana Stone.");
		end;

	<!-- Wait for Login next toon -->
			--[[
			sendMacro("}Logout_CharacterDelete=true;LoginNextToon=true;a={");
			sendMacro("Logout();");
			waitForLoadingScreen();
			player = CPlayer.new();
			settings.load();
			]]--
			sendMacro("}Logout_CharacterDelete=true;a={");
			LoginNextChar();
			settings.load();
			yrest(4000);
			loadPaths(__WPL.FileName);
	</waypoint>


<!-- 3nd Way. Make Mana Stones -->
	<waypoint x="31954" z="3278" tag="ELF10Lvl">
		-- Set faceDirection and Rotation
		local angle = math.atan2(31925 - player.Z, 3391 - player.X);
		local yangle = 0;
		player:faceDirection(angle, yangle);
		camera:setRotation(angle);
	</waypoint>
	<waypoint x="31925" z="3391"></waypoint>
	<waypoint x="31890" z="3511"></waypoint>
	<waypoint x="31844" z="3555"></waypoint>
	<waypoint x="31797" z="3597" tag="ELFMailbox2">
		-- Check for ELF Mailbox Error
		if not player:findNearestNameOrId(112778) then TirodelUnstick() end;
		local Mailbox = player:findNearestNameOrId(112778);
		if (Mailbox.Y-player.Y) > 30 then TirodelUnstick() end;

		-- Check for MagicBox Error
		if RoMScript("AdvancedMagicBoxFrame == nil") and RoMScript("MagicBoxFrame == nil") then
			cprintf(cli.lightred, "Time: " ..os.date().. " MagicBoxFrame == nil\n")
			TirodelUnstick()
		end;
		RoMScript("UIParent:Show()");

		-- Open Mailbox
		player:target_Object(112778,1500);							-- Почтовый ящик
		RoMScript("ChoiceOption(1);"); yrest(1500);
		UMM_DeleteEmptyMail();
		UMM_TakeMail(); yrest(1000);
		RoMScript("CloseWindows()"); yrest(500);

	<!-- Make Mana Stones -->
		retry_count = 0
		repeat MBEnergy = RoMScript("GetMagicBoxEnergy()"); yrest(500) until MBEnergy
		while( MBEnergy > 0 and 7 > retry_count ) do 
			-- Open dialogs
			if RoMScript("AdvancedMagicBoxFrame ~= nil") then
				RoMScript("AdvancedMagicBoxFrame:Show()"); yrest(2000)
			else
				RoMScript("MagicBoxFrame:Show()"); yrest(2000)
			end
			RoMScript("FusionFrame:Show()"); yrest(2000)
			-- check version of Fusion
			if RoMScript("FusionFrame1 ~= nil") then
				-- Set number to make on Fusion v1.x
				RoMScript("FusionFrameFusionNumberEditBox5:SetText('10')"); yrest(1000)
				RoMScript("FusionFrameFusionNumberEditBox6:SetText('10')"); yrest(1000)
				RoMScript("FusionFrameFusionNumberEditBox7:SetText('0')"); yrest(1000)
				RoMScript("FusionFrameFusionNumberEditBox8:SetText('0')"); yrest(1000)
				RoMScript("FusionFrameFusionNumberEditBox9:SetText('10')"); yrest(1000)
				RoMScript("FusionFrameFusionNumberEditBox10:SetText('10')"); yrest(1000)
				-- Do
				RoMScript("Fusion_QueueManastones(FusionFrame_Do)");
				repeat yrest(2000) until RoMScript("Fusion.LastGrad")==0 or RoMScript("MagicBoxFrame:IsVisible()")==false
				-- EmptyMagicBox
				RoMScript("PickupBagItem(51);"); yrest(500);
				RoMScript("PickupBagItem(Fusion_SearchEmptyBagslot(1));"); yrest(500);
				RoMScript("PickupBagItem(52);"); yrest(500);
				RoMScript("PickupBagItem(Fusion_SearchEmptyBagslot(2));"); yrest(500);
				RoMScript("PickupBagItem(53);"); yrest(500);
				RoMScript("PickupBagItem(Fusion_SearchEmptyBagslot(3));"); yrest(500);
			else
				-- on Fusion v2.0 and newer
				RoMScript("Fusion:Config_OnShow()"); yrest(500)
				RoMScript("FusionFrame_Number6EditBox:SetNumber(10)"); yrest(500)
				RoMScript("FusionFrame_Number7EditBox:SetNumber(10)"); yrest(500)
				RoMScript("FusionFrame_Number8EditBox:SetNumber(10)"); yrest(500)
				RoMScript("FusionFrame_Number9EditBox:SetNumber(10)"); yrest(500)
				RoMScript("FusionFrame_Number10EditBox:SetNumber(10)"); yrest(500)
				RoMScript("Fusion:Config_Save()"); yrest(500)
				-- Do
				RoMScript("Fusion:Do_OnClick(FusionFrame_Do)");
				repeat
					yrest(1500)
				until RoMScript("Fusion.DoQueue")~=true and RoMScript("Fusion.EmptyMagicBox") ~= true
			end
			-- close 
			yrest(2000)
			if RoMScript("AdvancedMagicBoxFrame ~= nil") then
				RoMScript("AdvancedMagicBoxFrame:Hide()"); yrest(2000)
			else
				RoMScript("MagicBoxFrame:Hide()"); yrest(2000)
			end
			inventory:update(); player:update();
			repeat MBEnergy = RoMScript("GetMagicBoxEnergy()"); yrest(500) until MBEnergy
			retry_count = retry_count + 1;
		end;
		
		-- Error if not receive Mana Stones
		repeat MBEnergy = RoMScript("GetMagicBoxEnergy()"); yrest(500) until MBEnergy
		if( MBEnergy > 0 ) then
			error("\a\a\aWe didn't receive Mana Stones.");
		end;

		-- Open Mailbox
		player:target_Object(112778,1500);							-- Почтовый ящик
		RoMScript("ChoiceOption(1);"); yrest(1500);
		UMM_DeleteEmptyMail();
		UMM_TakeMail(); yrest(1000);
		RoMScript("CloseWindows()"); yrest(500);

		-- Open Mailbox and Send Mana Stone and Gold
		local retry_count = 0;
		while( CheckCountManaStone() ~= 0 and 5 > retry_count ) do
			retry_count = retry_count + 1;
			TierReceiver1 = TierReceiver[math.random(2,5)]
			cprintf(cli.lightred, "Time: " ..os.date().. " Char name: " ..TierReceiver1.. "\n")
			-- check version of Fusion and EmptyMagicBox
			if RoMScript("FusionFrame1 ~= nil") then
				RoMScript("PickupBagItem(51);"); yrest(500);
				RoMScript("PickupBagItem(Fusion_SearchEmptyBagslot(1));"); yrest(500);
				RoMScript("PickupBagItem(52);"); yrest(500);
				RoMScript("PickupBagItem(Fusion_SearchEmptyBagslot(2));"); yrest(500);
				RoMScript("PickupBagItem(53);"); yrest(500);
				RoMScript("PickupBagItem(Fusion_SearchEmptyBagslot(3));"); yrest(500);
			end
			player:target_Object(112778,1500);											-- Почтовый ящик
			RoMScript("ChoiceOption(1);"); yrest(1500);
			UMM_SendByNameOrId(TierReceiver1, 203276)				-- Шар опыта: 10 000 очков
			UMM_SendByNameOrId(TierReceiver1, ManaStones1)			-- Камни маны ур. 4, ур. 5, и ур. 6
			UMM_SendByNameOrId(TierReceiver[6], ManaStones2) 		-- Камни маны ур. 7, ур. 8, ур. 9
			UMM_SendByNameOrId(TierReceiver[1], ManaStones3)		-- Камни маны ур. 10 и случайные
			UMM_SendByNameOrId(TierReceiver[1], ManaStones4)		-- Камни маны ур. 11 и ...
			UMM_SendByFusedTierLevel(TierReceiver[1], 4)			-- Шмотоки для тира
			RoMScript("PickupBagItem(51);"); yrest(1000)
			RoMScript("PickupBagItem(70);"); yrest(1000)
			RoMScript("CloseWindows()");
			inventory:update();
		end;

		cprintf(cli.white, "Twink T4 Mana Stone:       %s\n", inventory:itemTotalCount(202843))
		cprintf(cli.white, "Twink T5 Mana Stone:       %s\n", inventory:itemTotalCount(202844))
		cprintf(cli.white, "Twink T6 Mana Stone:       %s\n", inventory:itemTotalCount(202845))
		cprintf(cli.white, "Twink T7 Mana Stone:       %s\n", inventory:itemTotalCount(202846))
		cprintf(cli.white, "Twink T8 Mana Stone:       %s\n", inventory:itemTotalCount(202847))
		cprintf(cli.white, "Twink T9 Mana Stone:       %s\n", inventory:itemTotalCount(202849))
		cprintf(cli.white, "Twink T10 Mana Stone:      %s\n", inventory:itemTotalCount(202850))
		cprintf(cli.white, "Twink T11 Mana Stone:      %s\n", inventory:itemTotalCount(202851))
		Account = RoMScript("GetAccountName();");
		cprintf(cli.white, player.Name.."_"..Account.." Bot sended: Mana Stone.\n");

		-- Error if not Send Mana Stone T4, T5, T6, T7, T8 or T9 Stone
		if( CheckCountManaStone() ~= 0 ) then    
			error("\a\a\a\a\a\a\aWe didn't Send Mana Stone.");
		end;

	<!-- Wait for Login next toon -->
			--[[
			sendMacro("}Logout_CharacterDelete=true;LoginNextToon=true;a={");
			sendMacro("Logout();");
			waitForLoadingScreen();
			player = CPlayer.new();
			settings.load();
			]]--
			sendMacro("}Logout_CharacterDelete=true;a={");
			LoginNextChar();
			settings.load();
			yrest(4000);
			loadPaths(__WPL.FileName);
	</waypoint>
</waypoints>
