<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
	--=== Rock5's version ===--
	--===  R5Version 2.51 ===--

	--=== User Options ===--
	When_Finished = "end"
		-- "end" to end script, "relog" to log next character, "charlist" to log next in 'charlist' 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}},
		--		}

	AllowSkillCastTime = 2
		-- Ignore skills with cast times longer than this value when attacking the 'trash' mobs at the beginning.
	--====================--

	aoeskills = {
		"MAGE_PURGATORY_FIRE",
		"MAGE_DISCHARGE",
		"WARRIOR_BLASTING_CYCLONE",
		"WARRIOR_MOON_CLEAVE",
		"WARRIOR_WHIRLWIND",
		"KNIGHT_WHIRLWIND_SHIELD",
	}

	include("waypoints/survivalR5onload.lua",true)

</onLoad>
	<!--    In the survival game    -->
	<!-- #  1 --><waypoint x="2519" z="2593" y="9">
		player:target_NPC(joker);
		sendMacro("ChoiceOption(2);");
	</waypoint>
	<!-- #  2 --><waypoint x="2546" z="2681" y="9">	</waypoint>
	<!-- #  3 --><waypoint x="2586" z="2789" y="9">	</waypoint>
	<!-- #  4 --><waypoint x="2606" z="2843" y="9">
		logentry = "Ran out of time." -- default
		createTileTable() -- do it here as you can't see the pawns until you start the event.
		local trash = player:findNearestNameOrId({bizarremechanism,guardianrockspirit},nil, function(addr) return CPawn(addr).HP > 4 end) -- check for spawns
		local tiles =  player:findNearestNameOrId(treasuretile, nil, clicktile) -- check if any tiles need opening

		if trash then -- add in options for aoe and ranged here
			trashmelee() -- clears trash
		elseif trash == nil and spawns == nil and tiles ~= nil then
			breaktiles() -- start breaking tiles
		elseif tiles == nil then
			chests() -- open chests
		end

		if 1 > player.HP or not player.Alive then
			RoMScript("UseSelfRevive();");	-- first try self revive
			yrest(500);
			RoMScript("BrithRevive();");
			if waitForLoadingScreen(30) then
				-- Give chance to run back from rez point.
				yrest(5000)
				__WPL:setWaypointIndex(__WPL:getNearestWaypoint(player.X, player.Z, player.Y))
				return
			end
		else
			waitForLoadingScreen(10)
		end

		checkRelog()
	</waypoint>

	<!--    Return from res point    -->
	<!-- #  1 --><waypoint x="2273" z="1801" y="53">	</waypoint>
	<!-- #  2 --><waypoint x="2376" z="1697" y="33">	</waypoint>
	<!-- #  3 --><waypoint x="2433" z="1618" y="19">	</waypoint>
	<!-- #  4 --><waypoint x="2481" z="1524" y="0">	</waypoint>
	<!-- #  5 --><waypoint x="2507" z="1432" y="-2">	</waypoint>
	<!-- #  6 --><waypoint x="2535" z="1297" y="12">	</waypoint>
	<!-- #  7 --><waypoint x="2582" z="1204" y="24">	</waypoint>
	<!-- #  8 --><waypoint x="2674" z="1071" y="44">	</waypoint>
	<!-- #  9 --><waypoint x="2762" z="970" y="53">
		player:target_NPC("Lieve"); yrest(1000)
		sendMacro("ChoiceOption(2);"); yrest(500)
		sendMacro("ChoiceOption(2);");
		waitForLoadingScreen(10)
	</waypoint>
	<!-- # 12 --><waypoint x="4765" z="-1955" y="115">	</waypoint>
	<!-- # 13 --><waypoint x="4798" z="-1919" y="109">	</waypoint>
	<!-- # 14 --><waypoint x="4857" z="-1914" y="109">
		if logentry ~= nil then
			checkRelog()
			return
		end

		local Malatina = GetIdName(111813)
		if 50 > player.Level and (player.Level2 >= 50 or player.Level3 >= 50) then
			-- Wait for user to change class
			cprintf(cli.yellow,"If you want to earn Phirius Shells, change to your 50+ class before continuing.\n")
			player:sleep()
		end
		if inventory:itemTotalCount(240181) > 970 then
			-- Wait for user to use some shells.
			cprintf(cli.yellow,"Reaching the maximum number of Phirius Shells (1000). Please spend some before continuing.\n")
			player:sleep()
			numshells = inventory:getItemCount(240181)
		end
		local empties = inventory:itemTotalCount(0)
		if 20 > empties then
			-- Wait for user to make some space in inventory.
			cprintf(cli.yellow,"Not much space left in inventory. Are you sure you want to continue with only %d spaces left?\n",empties)
			player:sleep()
		end
		if 30 > inventory:itemTotalCount(203038) then
			print("Not enough Phirius Token Coins.")
			logentry = "Not enough Phirius Token Coins."
			checkRelog()
			return
		end

		player:target_NPC(Malatina) yrest(1000)

		if 2 > RoMScript("GetNumSpeakOption()") then -- try again
			player:target_NPC(Malatina) yrest(1000)
		end

		sendMacro("ChoiceOption(1);");
		yrest(2000)

		if RoMScript("GetNumSpeakOption()") > 0 then -- enter game
			sendMacro("ChoiceOption(1);");
			if not waitForLoadingScreen(30) then
				print("Failed to teleport into Survival")
				logentry = "Failed to teleport into Survival."
				checkRelog()
			end
		else
			print("This character already did Survival.")
			logentry = "Already did Survival."
			checkRelog()
		end
	</waypoint>
</waypoints>
