<?xml version="1.0" encoding="utf-8"?><waypoints>
<onLoad>

	cprintf(cli.pink, "\n\n\nWaypoint create by Kuripot\n\n\n")
	loadProfile("Main")
	setwindow(206879)
	changeProfileOption("INV_AUTOSELL_FROMSLOT", 1)
	changeProfileOption("INV_AUTOSELL_TOSLOT", 30)
	changeProfileOption("EGGPET_ENABLE_ASSIST", "true")
	changeProfileOption("INV_AUTOSELL_ENABLE", "true")
	changeProfileOption("AUTO_ELITE_FACTOR", 1000)
	settings.profile.friends = {"Incomplete Bloody Beast"}
	dura = 0.9
	Magic_Tambourine = true
	Magic_Guitar = true
	__WPL:setWaypointIndex(__WPL:findWaypointTag("start"))
	Count = 0
	Zid = 0
	BuffCount = 0
	srun = 1

	if not eventparty then
	function eventparty()
	checkeventparty()
	end
	end

function Cooldown()
item = inventory:findItem(instrumentID)
if item then
    if item.SlotNumber > 60 then
        _slot = item.SlotNumber - 60
        func = "GetBagItemCooldown"
    elseif 51 > item.SlotNumber then
        _slot = item.SlotNumber
        func = "GetGoodsItemCooldown"
    else
        error("There is no cooldown function for the magic box. Take the item out of the box.")
    end
end
repeat
    local maxCD, CurrentCD = RoMScript(func.."(".._slot..");")
    yrest(1000) -- 1 second rest
until CurrentCD == 0
end

	function CleanBagDOD()
	   for i, item in pairs(inventory.BagSlot) do
		if item.SlotNumber >= settings.profile.options.INV_AUTOSELL_FROMSLOT + 60 and
 	        settings.profile.options.INV_AUTOSELL_TOSLOT + 60 >= item.SlotNumber then

	         if item:isType("Materials") then
	            item:delete()
	         end
	         if item:isType("Arrows") then
	            item:delete()
	         end
	         if item:isType("Projectiles") then
	            item:delete()
	         end
	         if ( item:isType("Weapons") or item:isType("Armor") ) and (1000 > item.Worth and 5 > item.Quality)then
	            item:delete()
	         end
		if item:isType("Equipment Enhancement") then
	            item:delete()
	         end
		if item.Name  == "Wild Boar Meat" then
	            item:delete()
	         end 
		if item:isType("Potions") then
	            item:delete()
	         end          
	      end
	   end
	end  

	function Boss_buff()

	if Magic_Tambourine == true then
		if inventory:itemTotalCount(204463) >= 1 then
			inventory:useItem(204463) -- 3 days
			yrest(5500)
		elseif inventory:itemTotalCount(204571) >= 1 then
			inventory:useItem(204571) -- 7 days
			yrest(5500)
		elseif inventory:itemTotalCount(206420) >= 1 then
			inventory:useItem(206420) -- 30 days
			yrest(5500)
		end
		elseif Magic_Tambourine == party_true then
			yrest(5500)
		end
	if Magic_Guitar == true then
		if inventory:itemTotalCount(204461) >= 1 then
			inventory:useItem(204461) -- 3 days
			yrest(5500)
		elseif inventory:itemTotalCount(206418) >= 1 then
			inventory:useItem(206418) -- 7 days
			yrest(5500)
		elseif inventory:itemTotalCount(204569) >= 1 then
			inventory:useItem(204569) -- 30 days
			yrest(5500)
		end
		elseif Magic_Tambourine == party_true then
			yrest(5500)
		end
		changeProfileSkill("MAGE_FLAME", "AutoUse", true);
		changeProfileSkill("MAGE_FIREBALL", "AutoUse", true);
		changeProfileSkill("MAGE_FLAME", "Priority", 90);
		changeProfileSkill("MAGE_FIREBALL", "Priority", 100);
		useGoodie("matt");
		useGoodie("mdmg2");
		useGoodie("mdmg");
		useGoodie("matt3");
		useGoodie("casting");
		useGoodie("speed");
		useGoodie("defense");
		useGoodie("luck");
		player:cast("MAGE_ESSENCE_OF_MAGIC");
		player:cast("PRIEST_MAGIC_BARRIER");
		player:cast("MAGE_ENERGY_INFLUX");
		player:cast("MAGE_ELECTROSTATIC_CHARGE");
		player:cast("MAGE_INTENSIFICATION");
		player:cast("MAGE_ELEMENTAL_CATALYSIS");
		player:cast("PRIEST_REGENERATE");
	end


	function Memoscount()
		   Memosbeforeloot = inventory:getItemCount(206879)
		end


	function trash_boss()
		local target = player:getTarget()
		local _tb = false
		local spawnboss = player:findNearestNameOrId("Okander \"Mad Man\" Mallen")
		if spawnboss then
			Boss_buff()
			player:target(spawnboss)
		if target.HP > 0 then
			player:update();
			player:cast("MAGE_FLAME");
			yrest(1000);
			cprintf(cli.pink, "Kame Hame Wave!!!\n")
		if( arg1.Name == "MAGE_FLAME" ) then
			player:cast("MAGE_FLAME");
			cprintf(cli.pink, "Kame Hame Wave!!!!!\n")
			yrest(1000);
			end
			player:cast("MAGE_FLAME");
			yrest(1000);
			cprintf(cli.pink, "Kame Hame Wave!!!\n")
			player:cast("MAGE_FLAME");
			yrest(1000);
			  _tb = false
			else
 			   _tb = true
			end
			else
			  _tb = true
			end
			  return _tb
			end

					function Countround()
						Count = Count+1;
						cprintf(cli.pink, "Round Number: %s\n\n", Count)
					end
					
					function checkdura()
						if dura > inventory:getMainHandDurability() then
							__WPL:setWaypointIndex(__WPL:findWaypointTag("mech"))
						end

						local bcount = inventory:getItemCount(0)
						if(  5 > bcount ) then
							__WPL:setWaypointIndex(__WPL:findWaypointTag("mech"))
						end
					end

					function findzi()
						local getinlvl = sendMacro('GetInstanceLevel("normal")')
						if getinlvl == ("easy") then
							zid = 128
						elseif getinlvl == ("normal") then
							zid = 127
						elseif getinlvl == ("hard") then
							zid = RoMScript("GetZoneID()");
							sendMacro('SetInstanceLevel("easy")');
							cprint(cli.blue, "Instance Lvl change to easy\n")
						end					
						keyboardHold( settings.hotkeys.MOVE_FORWARD.key )
						yrest(400)
						keyboardPress(settings.hotkeys.JUMP.key)
						yrest(1000)
						keyboardRelease( settings.hotkeys.MOVE_FORWARD.key )
						waitForLoadingScreen(30)
						yrest(500)
					end

					function ireset()
						SlashCommand("rdd")
						yrest(500)
						SlashCommand("rdi")
						yrest(1000)
						SlashCommand("aid normal")
						end
</onLoad>
				<waypoint x="1645" z="-4908" y="752" tag="start" type="TRAVEL">
					checkdura()
					ireset()
				</waypoint>
				<waypoint x="1649" z="-5018" y="761" tag="enter" type="TRAVEL">
				</waypoint>
				<waypoint x="1637" z="-5094" y="760">
				</waypoint>
				<waypoint x="1672" z="-5137" y="762" type="TRAVEL">
					findzi()
					--player:update
					local zoneid = RoMScript("GetZoneID()")
					if zoneid == 209 then
						__WPL:setWaypointIndex(__WPL:findWaypointTag("enter"))
					else
						__WPL:setWaypointIndex(__WPL:findWaypointTag("instance"))
					end
				</waypoint>
				<waypoint x="1793" z="2880" y="433" tag="instance">
					Countround()
					fly()
				__WPL:setForcedWaypointType("TRAVEL")				</waypoint>
				<waypoint x="1889" z="2880" y="560">				</waypoint>
				<waypoint x="1952" z="2814" y="560">teleportToWP()		</waypoint>
				<waypoint x="2019" z="2737" y="560">teleportToWP()		</waypoint>
				<waypoint x="2061" z="2675" y="463">teleportToWP()		</waypoint>
				<waypoint x="2124" z="2597" y="463">flyoff()			</waypoint>
				<waypoint x="2123" z="2598" y="432">teleportToWP()		</waypoint>
				<waypoint x="2192" z="2526" y="401">				</waypoint>
				<waypoint x="2204" z="2510" y="401" tag="boss">
					__WPL:setForcedWaypointType("NORMAL")
							trash_boss()
							player:lootAll()
					</waypoint>
				<waypoint x="2192" z="2526" y="401" type="TRAVEL">
					settings.profile.friends = {"Incomplete Bloody Beast"}
					useGoodie("godspeed");
					CleanBagDOD()
					fly()
				</waypoint>
				<waypoint x="2123" z="2598" y="432">teleportToWP()			</waypoint>
				<waypoint x="2061" z="2675" y="463">teleportToWP()			</waypoint>
				<waypoint x="2019" z="2737" y="560">teleportToWP()			</waypoint>
				<waypoint x="1952" z="2814" y="560">teleportToWP()			</waypoint>	
				<waypoint x="1889" z="2880" y="560">flyoff()				</waypoint>
				<waypoint x="1891" z="2876" y="433" tag="exit" type="TRAVEL">		</waypoint>
				<waypoint x="1700" z="2886" y="433" type="TRAVEL">
					findzi()
					local zoneid = RoMScript("GetZoneID()")
						if zoneid == zid then
							ireset()
							waitForLoadingScreen()
							__WPL:setWaypointIndex(__WPL:findWaypointTag("return"))
						else
							__WPL:setWaypointIndex(__WPL:findWaypointTag("start"))
						end
				</waypoint>
				<waypoint x="1707" z="-4755" y="752" tag="mech" type="TRAVEL">
					local bcount = inventory:getItemCount(0)
					player:update()
					player:merchant(115536)				--== no more works on Chapter IV ==--
					yrest(500)
					local cbcount = inventory:getItemCount(0)
					if bcount == cbcount then
						if player:openStore(115536) then
							for i, item in pairs(inventory.BagSlot) do
							if item.SlotNumber >= settings.profile.options.INV_AUTOSELL_FROMSLOT +60 and settings.profile.options.INV_AUTOSELL_TOSLOT +60 >= item.SlotNumber then
								item:use() -- sells it to the store
							end
						end
					end
				end
				__WPL:setWaypointIndex(__WPL:findWaypointTag("start"))
		</waypoint>
		<waypoint x="-3812" z="5117" y="30" tag="return">
			player:update()
			flyoff()
			__WPL:setForcedWaypointType("TRAVEL")
			if not player.Mounted then
				player:mount()
			end
			yrest(6000)
		</waypoint>
		<waypoint x="-3382" z="5466" y="23" type="TRAVEL">
		</waypoint>
		<waypoint x="-3100" z="5624" y="14" type="TRAVEL">
		</waypoint>
		<waypoint x="-2918" z="5898" y="25" type="TRAVEL">
		</waypoint>
		<waypoint x="-2627" z="6184" y="23" type="TRAVEL">
		</waypoint>
		<waypoint x="-2482" z="6432" y="28" type="TRAVEL">
		</waypoint>
		<waypoint x="-2490" z="6534" y="43" type="TRAVEL">
		</waypoint>
		<waypoint x="-2602" z="6606" y="62" type="TRAVEL">
		</waypoint>
		<waypoint x="-2836" z="6756" y="52" type="TRAVEL">
		</waypoint>
		<waypoint x="-2859" z="6949" y="52" type="TRAVEL">	
		</waypoint>
		<waypoint x="-2904" z="7219" y="-84" type="TRAVEL">
		</waypoint>
		<waypoint x="-2977" z="7237" y="-88" type="TRAVEL">
			waitForLoadingScreen()
		</waypoint>
		<waypoint x="51" z="-890" y="869" type="TRAVEL">
			player:dismount()
			yrest(1000)
			player:target_NPC("Jake Wallanda")
			sendMacro("ChoiceOption(1);")
			waitForLoadingScreen()
			__WPL:setWaypointIndex(__WPL:findWaypointTag("start"))
		</waypoint>
</waypoints>
