Rock5's Ancient Treasure

Additional botting resources. Addons may be either for the game itself or for the RoM bot.
Forum rules
Only post additional bot resources here. Please do not ask unrelated questions.
Message
Author
kuripot
Posts: 493
Joined: Mon Nov 07, 2011 9:14 pm

Re: Rock5's Ancient Treasure

#41 Post by kuripot » Sat Mar 17, 2012 1:59 am

can be manual buying... only check if already "Ancient Treasures Investigation Record" and if has, then use and re do ancient treasure.. even no getting reward from medal

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Rock5's Ancient Treasure

#42 Post by rock5 » Sat Mar 17, 2012 2:23 am

I think I will implement a buying function. It will just be an extra option where you choose what you want to exchange. It will do the buying on the way in. At the end of the game, if it has a "Record" then it will repeat it. I've never used one so I'll probably need someone to test it for me.

The way I'm going to deal with wanting to do different things with different characters is by making it possible to make copies of the AT script so you can have different settings for differnt characters. So, for example, in one file (you could call it "atmain.xml"), you could have a character list of your main characters and have it collects every chest and get the backpack tickets and in the other file (you could call it "atalts.xml") you could have a character list of your alts and have it collect only the mat chests and exchange the medals for repeats in AT.

How does that sound?
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

kuripot
Posts: 493
Joined: Mon Nov 07, 2011 9:14 pm

Re: Rock5's Ancient Treasure

#43 Post by kuripot » Sat Mar 17, 2012 2:51 am

i have 4 char that has a lot of medal

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Rock5's Ancient Treasure

#44 Post by rock5 » Sat Mar 17, 2012 7:12 am

Try this version and let me know how it goes.
AT.xml
Version 3.6 b1
(16.68 KiB) Downloaded 220 times
Changes:
  • - Option to buy stuff with medals
    - Uses "Records" if you have any and repeats the game. (Needs testing).
    - Small change that allows you to rename the file or make copies of it.
    - Extra teleport when entering chest room to make sure it goes in the right order.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

kuripot
Posts: 493
Joined: Mon Nov 07, 2011 9:14 pm

Re: Rock5's Ancient Treasure

#45 Post by kuripot » Sun Mar 18, 2012 12:40 am

did i doing wrong?? i received ancient record but it will not use...

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
	--= Ancient Treasure  =--
	--=== version 3.6b1 ===--
	-- www.solarstrike.net/phpBB3/viewtopic.php?p=35357

	--=== User Options ===--

	CollectFragments       = true	-- If you want to collect the Stone Totem Fragments
	CollectMatChests       = true	-- If you want to open the materials Chests
	CollectRunesChests     = false	-- If you want to to open the Rune chests
	CollectMountChests     = true	-- If you want to open the Mount chests
	ExchangeFragments      = true	-- If you want to exchange Stone Totem Fragments for Ruins Investigation Team Medals before entering.
	PutMaterialsIn     = "itemshop"	-- "guild" to donate materials to guild or "itemshop" to put them in itemshop backpack.
	ExitBeforeNextFile     = true	-- If you want it to exit game before loading next "waypointfilename".
	ExchangeForMedals      = "atrepeat"	-- Item you want to exchange for Medals - "hammer", "card", "matchest", "runechest", "backpack" or "atrepeat"

	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}},
		--		}

	--====================--
	local medalshop = {
		hammer = {price = 1, option = 1},
		card = {price = 3, option = 2},
		matchest = {price = 3, option = 3},
		runechest = {price = 5, option = 4},
		backpack = {price = 5, option = 5},
		atrepeat = {price = 7, option = 6},
	}
	local numshells = inventory:getItemCount(240181)
	local startwaittime = nil

	if fly == nil or teleport == nil then
		error("This waypoint cannot run without the 'swimhack' and 'teleport' userfunctions.")
	end

	local downwards = {[1] ={ X=4132, Z=4303, Y=7},[2] ={ X=3327, Z=3834, Y=7},[3] ={ X=4109, Z=3397, Y=7},[4] ={ X=3708, Z=4289, Y=7}}
	for k,v in pairs(settings.profile.skills) do
	      v.AutoUse = false
	end

	local elemental = GetIdName(113614) -- Elemental Candstick
	local luke = GetIdName(113622) -- Luke Xavi
	local ange = GetIdName(113689) -- Ange Rasa
	local totem = GetIdName(114080) -- Ancient Stone Totem (item to click)
	local tran = GetIdName(113615) -- Transport Candlestick
	local frag = GetIdName(206422) -- Stone Totem Fragment (item in bag)
	local fragquest = GetIdName(422959) -- Gather Stone Totem Fragments
	local proceedquest = GetIdName(422958) -- Proceed to the Scar of Despair Camp
	local medals = GetIdName(206423) -- Ruins Investigation Team Medal
	local records = GetIdName(206426) -- Ancient Treasures Investigation Record

	function checkRelog()
		flyoff()

		-- Log result
		local filename = getExecutionPath() .. "/logs/at.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() ..
			"\tCoins:"..inventory:itemTotalCount(203038).." \tShells gained/total: "..inventory:getItemCount(240181) - numshells.."/".. inventory:getItemCount(240181).. "\t" ..logentry .. "\n")
			file:close();
		end

		if When_Finished == "relog" then
			ChangeChar()
			waitForLoadingScreen();
			yrest(3000)
			loadProfile()
			loadPaths(__WPL.FileName);
		elseif When_Finished == "charlist" then
			SetCharList(CharList)
			LoginNextChar()
			loadProfile()
			loadPaths(__WPL.FileName);
		elseif When_Finished == "end" then
			error("Ending script",2)
		else
			player:update()

			-- Leave before loading next waypoint file.
			if ExitBeforeNextFile == true then
				if player:target_Object(tran) then
					RoMScript("StaticPopup_OnClick(StaticPopup1, 1);")
					waitForLoadingScreen();
					yrest(3000)
				end
			end

			if not string.find(When_Finished,".", 1, true) then
				When_Finished = When_Finished .. ".xml"
			end
			loadProfile() -- Because we messed with the skills

			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

	local function buyitems()
		-- no option. Return
		if ExchangeForMedals == "" or ExchangeForMedals == nil or ExchangeForMedals == "nil" then
			return
		end

		-- Invalid option
		if not medalshop[ExchangeForMedals] then
			error("Invalid value used for 'ExchangeForMedals': "..(ExchangeForMedals or "nil"))
		end

		local option = medalshop[ExchangeForMedals].option
		local price = medalshop[ExchangeForMedals].price

		-- Buy items
		while math.floor(inventory:itemTotalCount(medals)/price) > 0 do
			if player:target_NPC(ange) then
				RoMScript("ChoiceOption(2)") yrest(500)
				RoMScript("ChoiceOption(" .. 2 + option ..")") yrest(500)
				yrest(1000)
			end
		end
	end

	local function UpThroughFloor()
		local rightheight = 18.5
		local dir = 3.14
		repeat
			if dir == 0 then dir = 3.14 else dir = 0 end -- Alternate direction
			teleport(nil,nil,rightheight) yrest(700)
			player:faceDirection(dir,-1.3) yrest(300)
			keyboardHold(settings.hotkeys.MOVE_FORWARD.key) yrest(300)
			keyboardRelease(settings.hotkeys.MOVE_FORWARD.key) yrest(1000)
			player:update()
		until player.Y > rightheight
	end

	local function UpThroughRoof(op)
		player:update()
		if player.Y > 105 then -- already above roof.
			return
		end

		local startpos, steps
		if op == 1 then -- in Luke room
			startpos = 74
			steps = 12
		elseif op == 2 then -- Hallways
			startpos = 91
			steps = 12
		else -- When not sure which
			startpos = 74
			steps = 30
		end

		for i = 0,steps,1 do teleport(nil,nil,startpos+i) player:turnDirection(1) yrest(50) end
		yrest(1000)
		teleport(nil,nil,120)
		player:update()
	end

	local function evalClickable(address)
		local chest = memoryReadRepeat("byte", getProc(), address + 0x2F0) or 0
		if chest ~= 0 then
			return true
		else
			return false
		end
	end

	local function HarvestItem(ID)
		local stt = os.time()
		repeat
			yrest(1)
		until player:target_Object(ID,3) or os.time() - stt > 5
		if startwaittime == nil then
			if (GetIdName(ID) == elemental and (player:hasBuff(505596) or not player:hasBuff(505594))) or
			   (player:findNearestNameOrId(113617) ~= nil) then
				startwaittime = os.clock()
			end
		end
	end

	local function First2Fragments()
		print("Doing first 2 "..totem)
		player:update()
		if player.Y > 105 then
			player:moveTo(CWaypoint(3716,4288,120),true)
		else
			player:moveTo(CWaypoint(3716,4288,7),true)
		end
		teleport(nil,nil,7)
		local tmptotem = player:findNearestNameOrId(114080,nil,evalClickable)
		if (not tmptotem) or distance(player.X,player.Z,tmptotem.X,tmptotem.Z) > 200 then
			print("First 2 ".. totem .. " already collected.")
			return
		end
		print("Moving to "..totem)
		player:moveTo(CWaypoint(3700,4192,7),true)
		UpThroughFloor()
		player:moveTo(CWaypoint(3652,4204,34),true)
		HarvestItem(114080)
		UpThroughRoof(2)
		print("Moving to "..totem)
		player:moveTo(CWaypoint(3702,4289,120),true)
		teleport(nil,nil,7)
		player:moveTo(CWaypoint(3716,4155,7),true)
		player:moveTo(CWaypoint(3665,4110,7),true)
		player:moveTo(CWaypoint(3637,4124,7),true)
		teleport(3637,4124,7)
		UpThroughFloor()
		player:moveTo(CWaypoint(3609,4183,45),true)
		HarvestItem(114080)
		UpThroughRoof(2)
	end

	local function getunder()
		print("Going under.")
		player:update()
		if player.Y > 105 then
			local dist,bestdist,bestX,bestZ
			for k,v in pairs(downwards) do
				--table.print(v)
				dist = distance(player.X,player.Z,v.X,v.Z)
				if bestdist == nil then
					bestdist = dist
					bestX = v.X
					bestZ = v.Z
				else
					if bestdist > dist then
						bestdist = dist
						bestX = v.X
						bestZ = v.Z
					end
				end
			end

			player:moveTo(CWaypoint(bestX,bestZ),true)
		end

		teleport(nil,nil,7) yrest(1000)
		player:moveTo(CWaypoint(3890,3788,7),true) -- under instance in the middle
	end

	local function sortpath(initialtable)
		player:update()
		local returnedtable = {
			{X=player.X,Z=player.Z}, -- Where yuo're starting from
			{X=3838,Z=3994}, -- Where you're ending. Where it waits for mobs to despawn.
		}

		for __, obj in pairs (initialtable) do
			local bestintertplace
			local addeddist

			-- Find best place to insert
			for place = 2,#returnedtable do
				local currdist = distance(returnedtable[place-1].X,returnedtable[place-1].Z,returnedtable[place].X,returnedtable[place].Z)
				local newdist = distance(returnedtable[place-1].X,returnedtable[place-1].Z,obj.X,obj.Z) +
								 distance(obj.X,obj.Z,returnedtable[place].X,returnedtable[place].Z)
				if addeddist then
					if addeddist > newdist - currdist then
						bestintertplace = place
						addeddist = newdist - currdist
					end
				else
					bestintertplace = place
					addeddist = newdist - currdist
				end
			end

			-- Intert into new location
			table.insert(returnedtable,bestintertplace,obj)
		end

		-- remove first and last to return only initial points
		table.remove(returnedtable,1)
		table.remove(returnedtable,#returnedtable)

		return returnedtable
	end

	local function getcandles()

		local function candlelist()
			yrest(1500)
			local chestsappeared = player:findNearestNameOrId(113617) ~= nil
			local tmpcandles = {}
			local objectList = CObjectList();
			objectList:update();
			local objSize = objectList:size()
			for i = 0,objSize do
				obj = objectList:getObject(i);
				if ((not chestsappeared) and obj.Name == elemental) or
					(CollectFragments and obj.Name == totem and evalClickable(obj.Address) and 4000 > obj.Z) then -- Also easy to get fragments
					table.insert(tmpcandles, obj)
				end
			end

			return tmpcandles
		end

		local candles = candlelist()

		while #candles > 0 do
			candles = sortpath(candles)
			--for k,v in pairs(candles) do printf("%d X = %d, Z = %d\n",k,v.X,v.Z) end

			for k,v in pairs(candles) do
				print("Moving to ".. v.Name)
				player:moveTo(CWaypoint(v.X,v.Z,7),true)
				teleport(nil,nil,12)
				keyboardPress(settings.hotkeys.STRAFF_RIGHT.key)
				keyboardPress(settings.hotkeys.STRAFF_LEFT.key)
				HarvestItem(v.Id)
				teleport(nil,nil,7)
			end

			player:moveTo(CWaypoint(3838,3994),true)
			candles = candlelist()
		end

		player:moveTo(CWaypoint(3838,3994),true)

		local waittime = 12
		if startwaittime then
			waittime = waittime - (os.clock() - startwaittime)
		end

		if waittime > 0 then
			printf("Waiting %ds for mobs to despawn.\n",waittime)
			yrest(waittime*1000) -- 10 seconds to let mobs despawn
		end

		print("Going to chest room.")
		UpThroughFloor()

		teleport(3842,3838,49) -- get to chest room
		teleport(3880,3867,55)
	end

	local function getchests()

		--=== Open chests ===--
		function matchests()
			local matchest
			repeat
				matchest = player:findNearestNameOrId(113617,nil,evalClickable)
				if matchest then
					teleport(matchest.X,matchest.Z+3,matchest.Y+6)
					keyboardPress(settings.hotkeys.STRAFF_RIGHT.key)
					keyboardPress(settings.hotkeys.STRAFF_LEFT.key)
					repeat
						player:target_Object(matchest.Id, nil, nil, true, evalClickable);
					until evalClickable(matchest.Address) ~= true
				end
			until matchest == nil

			if type(PutMaterialsIn) == "string" then
				if string.lower(PutMaterialsIn) == "guild" then
					local guild = RoMScript("GetGuildInfo()")
					if GuildDonate == nil then
						print("Unable to donate to guild. Need \"GuildDonate\" userfunction.")
					elseif guild == nil or guild == "" then
						print("Unable to donate to guild. Character not a member of a guild.")
					else
						yrest(1000)
						inventory:update()
						GuildDonate(nil,8)
					end
				elseif string.lower(PutMaterialsIn) == "itemshop" then
					yrest(1000)
					inventory:update()
					for i = 61,240 do
						local item = inventory.BagSlot[i]
						if (not item.Empty) and item.Available and (item:isType("Ores") or item:isType("Wood") or item:isType("Herbs")) then
							item:moveTo("itemshop")
							yrest(1000)
						end
					end
				end
			end
		end

		function runechests()
			local runechest
			repeat
				runechest = player:findNearestNameOrId(113618,nil,evalClickable)
				if runechest then
					teleport(runechest.X,runechest.Z,runechest.Y+6)
					keyboardPress(settings.hotkeys.STRAFF_RIGHT.key)
					keyboardPress(settings.hotkeys.STRAFF_LEFT.key)
					repeat
						player:target_Object(runechest.Id, nil, nil, true, evalClickable);
					until evalClickable(runechest.Address) ~= true
				end
			until runechest == nil
		end
		function mountchests()
			local mountchest
			repeat
				mountchest = player:findNearestNameOrId(113619,nil,evalClickable)
				if mountchest then
					teleport(mountchest.X,mountchest.Z,mountchest.Y+6)
					keyboardPress(settings.hotkeys.STRAFF_RIGHT.key)
					keyboardPress(settings.hotkeys.STRAFF_LEFT.key)
					repeat
						player:target_Object(mountchest.Id, nil, nil, true, evalClickable);
					until evalClickable(mountchest.Address) ~= true
				end
			until mountchest == nil
		end
		if CollectMatChests then
			print("Opening Material chests.")
			matchests()
		end
		if CollectRunesChests then
			print("Opening Rune chests.")
			runechests()
		end
		if CollectMountChests then
			print("Opening Mount chests.")
			mountchests()
		end
	end

	repeat
		player:update()
		if getZoneId() ~= 355 then
			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
				print("Too many Phirius Shells. Skipping.")
				logentry = "Too many Phirius Shells. Skipping."
				numshells = inventory:getItemCount(240181)
				checkRelog()
				return
			end
			local empties = inventory:itemTotalCount(0)
			if 2 > 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

			if player:target_NPC(ange) then
				CompleteQuestByName(proceedquest)
			end

			if ExchangeFragments and player.Level > 20 then
				while inventory:itemTotalCount(frag) > 4 do
					AcceptQuestByName(fragquest)
					CompleteQuestByName(fragquest)
					yrest(500)
				end
			end

			buyitems()

			if player:target_NPC(ange) then
				yrest(2000);
				sendMacro("ChoiceOption(4);");
				yrest(2000);
				sendMacro("ChoiceOption(1);");
				yrest(1000);
				if not waitForLoadingScreen(10) then
					print("Failed to teleport into Ancient Treasure. Maybe you already done it today.")
					logentry = "Failed to teleport into Ancient Treasure. Maybe you already done it today."
					checkRelog()
					return
				end
			else
				print("Too far from Ange Rasa")
				logentry = "Too far from Ange Rasa"
				checkRelog()
				return
			end
		end

		fly()

		if not RoMScript("TimeKeeperFrame:IsVisible()") then -- no timer so click NPC and start it
			if player:target_NPC(luke) then
				yrest(2000);
				sendMacro("ChoiceOption(3);");
				yrest(2000);
				sendMacro("ChoiceOption(1);");
				yrest(5000);
				player:clearTarget()
				UpThroughRoof(1)
			else
				print("Can't find Luke Xavi")
				logentry = "Can't find Luke Xavi"
				checkRelog()
				return
			end
		end

		player:update()
		if player.Y > 15 then
			UpThroughRoof()
		end

		if CollectFragments then
			First2Fragments()
		end

		getunder()
		getcandles()
		getchests()

		local secondsleft = RoMScript("TimeKeeperFrame.startTime-GetTime()")
		local mm = string.format("%2s", math.floor(secondsleft/ 60))
		local ss = string.format("%02s", math.floor(math.mod(secondsleft, 60)))
		printf("Succeeded with %s:%s remaining.\n",mm,ss)
		logentry = string.format("Succeeded with %s:%s remaining.",mm,ss)

		if inventory:itemTotalCount(records) > 0 then
			-- Exit to repeat AT
			if player:target_Object(tran) then
				RoMScript("StaticPopup_OnClick(StaticPopup1, 1);")
				waitForLoadingScreen();
				yrest(3000)
			end
		else
			checkRelog()
			return
		end
	until false
</onLoad>
</waypoints>

kuripot
Posts: 493
Joined: Mon Nov 07, 2011 9:14 pm

Re: Rock5's Ancient Treasure

#46 Post by kuripot » Sun Mar 18, 2012 12:47 am

did i forgot something??
Attachments
after collecting chest
after collecting chest

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Rock5's Ancient Treasure

#47 Post by rock5 » Sun Mar 18, 2012 4:09 am

Hm... maybe I was using the wrong item. Could you check it for me? Put the ancient record in the first slot of your bag, start the bot commandline file (just doubleclick the "StartCommandLine.bat" file), and type the following

Code: Select all

i=inventory.BagSlot[61] print(i.Id,i.Name)
Tell me what it prints.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

kuripot
Posts: 493
Joined: Mon Nov 07, 2011 9:14 pm

Re: Rock5's Ancient Treasure

#48 Post by kuripot » Sun Mar 18, 2012 7:40 am

same as you have
Attachments
commandline.JPG

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Rock5's Ancient Treasure

#49 Post by rock5 » Sun Mar 18, 2012 8:41 am

Hm. I'm not sure what's going on. The fact that it prints "Swimhack deactivated" means that it did the relog() function, which means inventory:itemTotalCount(records) was not more that 0. I don't know how it could miss that you have one in your inventory. I did notice something else though. The script doesn't actually use the record. So that needs to be added as well as figuring out why it isn't detecting the record.

Try adding at around line 553,

Code: Select all

print("records = "..records, inventory:itemTotalCount(records))
just before this line

Code: Select all

if inventory:itemTotalCount(records) > 0 then
Tell me what it prints.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Rock5's Ancient Treasure

#50 Post by rock5 » Sun Mar 18, 2012 9:52 am

Lisa, I'm thinking about adding a "slowteleport" option for setting

Code: Select all

		teleport_SetStepSize(25)
		teleport_SetStepPause(1500)
When does it need to start and when can I return it to default? I noticed collecting chests goes really slow because of the 1.5 second delays between chest. Is it necessary when collecting chests?
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Rock5's Ancient Treasure

#51 Post by lisa » Sun Mar 18, 2012 11:33 am

chests are fine at normal settings.
Only need it slowed down for when doing the candles and the fragments you get from underneath.
It helps stop the issue of the character teleporting to high and getting back into the instance when just trying to click the candles/fragments.

If you are really worried about the extra time you could literally change the setting before teleporting up prior to clicking objects and then changing it back after going down. Doing this would only add like 10 seconds to the entire WP.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Rock5's Ancient Treasure

#52 Post by rock5 » Sun Mar 18, 2012 11:42 am

So there is no problem with fast teleporting when going through the roof or floor?

Edit: Also that means, then, that the step size has no effect as 7 to 12 height is less than your setting of 25. It's just the pause. I could even just add pauses to the script instead of changing the teleport settings back and forth.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Rock5's Ancient Treasure

#53 Post by lisa » Sun Mar 18, 2012 7:03 pm

Hard to say without testing it =)
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

kuripot
Posts: 493
Joined: Mon Nov 07, 2011 9:14 pm

Re: Rock5's Ancient Treasure

#54 Post by kuripot » Mon Mar 19, 2012 5:10 pm

rock5 wrote:Hm. I'm not sure what's going on. The fact that it prints "Swimhack deactivated" means that it did the relog() function, which means inventory:itemTotalCount(records) was not more that 0. I don't know how it could miss that you have one in your inventory. I did notice something else though. The script doesn't actually use the record. So that needs to be added as well as figuring out why it isn't detecting the record.

Try adding at around line 553,

Code: Select all

print("records = "..records, inventory:itemTotalCount(records))
just before this line

Code: Select all

if inventory:itemTotalCount(records) > 0 then
Tell me what it prints.
still not using the record,,, just buying

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
	--= Ancient Treasure  =--
	--=== version 3.6b1 ===--
	-- www.solarstrike.net/phpBB3/viewtopic.php?p=35357

	--=== User Options ===--

	CollectFragments       = true	-- If you want to collect the Stone Totem Fragments
	CollectMatChests       = true	-- If you want to open the materials Chests
	CollectRunesChests     = false	-- If you want to to open the Rune chests
	CollectMountChests     = true	-- If you want to open the Mount chests
	ExchangeFragments      = true	-- If you want to exchange Stone Totem Fragments for Ruins Investigation Team Medals before entering.
	PutMaterialsIn     = "itemshop"	-- "guild" to donate materials to guild or "itemshop" to put them in itemshop backpack.
	ExitBeforeNextFile     = true	-- If you want it to exit game before loading next "waypointfilename".
	ExchangeForMedals      = "atrepeat"	-- Item you want to exchange for Medals - "hammer", "card", "matchest", "runechest", "backpack" or "atrepeat"

	When_Finished = "at to cot"
		-- "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}},
		--		}

	--====================--
	local medalshop = {
		hammer = {price = 1, option = 1},
		card = {price = 3, option = 2},
		matchest = {price = 3, option = 3},
		runechest = {price = 5, option = 4},
		backpack = {price = 5, option = 5},
		atrepeat = {price = 7, option = 6},
	}
	local numshells = inventory:getItemCount(240181)
	local startwaittime = nil

	if fly == nil or teleport == nil then
		error("This waypoint cannot run without the 'swimhack' and 'teleport' userfunctions.")
	end

	local downwards = {[1] ={ X=4132, Z=4303, Y=7},[2] ={ X=3327, Z=3834, Y=7},[3] ={ X=4109, Z=3397, Y=7},[4] ={ X=3708, Z=4289, Y=7}}
	for k,v in pairs(settings.profile.skills) do
	      v.AutoUse = false
	end

	local elemental = GetIdName(113614) -- Elemental Candstick
	local luke = GetIdName(113622) -- Luke Xavi
	local ange = GetIdName(113689) -- Ange Rasa
	local totem = GetIdName(114080) -- Ancient Stone Totem (item to click)
	local tran = GetIdName(113615) -- Transport Candlestick
	local frag = GetIdName(206422) -- Stone Totem Fragment (item in bag)
	local fragquest = GetIdName(422959) -- Gather Stone Totem Fragments
	local proceedquest = GetIdName(422958) -- Proceed to the Scar of Despair Camp
	local medals = GetIdName(206423) -- Ruins Investigation Team Medal
	local records = GetIdName(206426) -- Ancient Treasures Investigation Record

	function checkRelog()
		flyoff()

		-- Log result
		local filename = getExecutionPath() .. "/logs/at.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() ..
			"\tCoins:"..inventory:itemTotalCount(203038).." \tShells gained/total: "..inventory:getItemCount(240181) - numshells.."/".. inventory:getItemCount(240181).. "\t" ..logentry .. "\n")
			file:close();
		end

		if When_Finished == "relog" then
			ChangeChar()
			waitForLoadingScreen();
			yrest(3000)
			loadProfile()
			loadPaths(__WPL.FileName);
		elseif When_Finished == "charlist" then
			SetCharList(CharList)
			LoginNextChar()
			loadProfile()
			loadPaths(__WPL.FileName);
		elseif When_Finished == "end" then
			error("Ending script",2)
		else
			player:update()

			-- Leave before loading next waypoint file.
			if ExitBeforeNextFile == true then
				if player:target_Object(tran) then
					RoMScript("StaticPopup_OnClick(StaticPopup1, 1);")
					waitForLoadingScreen();
					yrest(3000)
				end
			end

			if not string.find(When_Finished,".", 1, true) then
				When_Finished = When_Finished .. ".xml"
			end
			loadProfile() -- Because we messed with the skills

			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

	local function buyitems()
		-- no option. Return
		if ExchangeForMedals == "" or ExchangeForMedals == nil or ExchangeForMedals == "nil" then
			return
		end

		-- Invalid option
		if not medalshop[ExchangeForMedals] then
			error("Invalid value used for 'ExchangeForMedals': "..(ExchangeForMedals or "nil"))
		end

		local option = medalshop[ExchangeForMedals].option
		local price = medalshop[ExchangeForMedals].price

		-- Buy items
		while math.floor(inventory:itemTotalCount(medals)/price) > 0 do
			if player:target_NPC(ange) then
				RoMScript("ChoiceOption(2)") yrest(500)
				RoMScript("ChoiceOption(" .. 2 + option ..")") yrest(500)
				yrest(1000)
			end
		end
	end

	local function UpThroughFloor()
		local rightheight = 18.5
		local dir = 3.14
		repeat
			if dir == 0 then dir = 3.14 else dir = 0 end -- Alternate direction
			teleport(nil,nil,rightheight) yrest(700)
			player:faceDirection(dir,-1.3) yrest(300)
			keyboardHold(settings.hotkeys.MOVE_FORWARD.key) yrest(300)
			keyboardRelease(settings.hotkeys.MOVE_FORWARD.key) yrest(1000)
			player:update()
		until player.Y > rightheight
	end

	local function UpThroughRoof(op)
		player:update()
		if player.Y > 105 then -- already above roof.
			return
		end

		local startpos, steps
		if op == 1 then -- in Luke room
			startpos = 74
			steps = 12
		elseif op == 2 then -- Hallways
			startpos = 91
			steps = 12
		else -- When not sure which
			startpos = 74
			steps = 30
		end

		for i = 0,steps,1 do teleport(nil,nil,startpos+i) player:turnDirection(1) yrest(50) end
		yrest(1000)
		teleport(nil,nil,120)
		player:update()
	end

	local function evalClickable(address)
		local chest = memoryReadRepeat("byte", getProc(), address + 0x2F0) or 0
		if chest ~= 0 then
			return true
		else
			return false
		end
	end

	local function HarvestItem(ID)
		local stt = os.time()
		repeat
			yrest(1)
		until player:target_Object(ID,3) or os.time() - stt > 5
		if startwaittime == nil then
			if (GetIdName(ID) == elemental and (player:hasBuff(505596) or not player:hasBuff(505594))) or
			   (player:findNearestNameOrId(113617) ~= nil) then
				startwaittime = os.clock()
			end
		end
	end

	local function First2Fragments()
		print("Doing first 2 "..totem)
		player:update()
		if player.Y > 105 then
			player:moveTo(CWaypoint(3716,4288,120),true)
		else
			player:moveTo(CWaypoint(3716,4288,7),true)
		end
		teleport(nil,nil,7)
		local tmptotem = player:findNearestNameOrId(114080,nil,evalClickable)
		if (not tmptotem) or distance(player.X,player.Z,tmptotem.X,tmptotem.Z) > 200 then
			print("First 2 ".. totem .. " already collected.")
			return
		end
		print("Moving to "..totem)
		player:moveTo(CWaypoint(3700,4192,7),true)
		UpThroughFloor()
		player:moveTo(CWaypoint(3652,4204,34),true)
		HarvestItem(114080)
		UpThroughRoof(2)
		print("Moving to "..totem)
		player:moveTo(CWaypoint(3702,4289,120),true)
		teleport(nil,nil,7)
		player:moveTo(CWaypoint(3716,4155,7),true)
		player:moveTo(CWaypoint(3665,4110,7),true)
		player:moveTo(CWaypoint(3637,4124,7),true)
		teleport(3637,4124,7)
		UpThroughFloor()
		player:moveTo(CWaypoint(3609,4183,45),true)
		HarvestItem(114080)
		UpThroughRoof(2)
	end

	local function getunder()
		print("Going under.")
		player:update()
		if player.Y > 105 then
			local dist,bestdist,bestX,bestZ
			for k,v in pairs(downwards) do
				--table.print(v)
				dist = distance(player.X,player.Z,v.X,v.Z)
				if bestdist == nil then
					bestdist = dist
					bestX = v.X
					bestZ = v.Z
				else
					if bestdist > dist then
						bestdist = dist
						bestX = v.X
						bestZ = v.Z
					end
				end
			end

			player:moveTo(CWaypoint(bestX,bestZ),true)
		end

		teleport(nil,nil,7) yrest(1000)
		player:moveTo(CWaypoint(3890,3788,7),true) -- under instance in the middle
	end

	local function sortpath(initialtable)
		player:update()
		local returnedtable = {
			{X=player.X,Z=player.Z}, -- Where yuo're starting from
			{X=3838,Z=3994}, -- Where you're ending. Where it waits for mobs to despawn.
		}

		for __, obj in pairs (initialtable) do
			local bestintertplace
			local addeddist

			-- Find best place to insert
			for place = 2,#returnedtable do
				local currdist = distance(returnedtable[place-1].X,returnedtable[place-1].Z,returnedtable[place].X,returnedtable[place].Z)
				local newdist = distance(returnedtable[place-1].X,returnedtable[place-1].Z,obj.X,obj.Z) +
								 distance(obj.X,obj.Z,returnedtable[place].X,returnedtable[place].Z)
				if addeddist then
					if addeddist > newdist - currdist then
						bestintertplace = place
						addeddist = newdist - currdist
					end
				else
					bestintertplace = place
					addeddist = newdist - currdist
				end
			end

			-- Intert into new location
			table.insert(returnedtable,bestintertplace,obj)
		end

		-- remove first and last to return only initial points
		table.remove(returnedtable,1)
		table.remove(returnedtable,#returnedtable)

		return returnedtable
	end

	local function getcandles()

		local function candlelist()
			yrest(1500)
			local chestsappeared = player:findNearestNameOrId(113617) ~= nil
			local tmpcandles = {}
			local objectList = CObjectList();
			objectList:update();
			local objSize = objectList:size()
			for i = 0,objSize do
				obj = objectList:getObject(i);
				if ((not chestsappeared) and obj.Name == elemental) or
					(CollectFragments and obj.Name == totem and evalClickable(obj.Address) and 4000 > obj.Z) then -- Also easy to get fragments
					table.insert(tmpcandles, obj)
				end
			end

			return tmpcandles
		end

		local candles = candlelist()

		while #candles > 0 do
			candles = sortpath(candles)
			--for k,v in pairs(candles) do printf("%d X = %d, Z = %d\n",k,v.X,v.Z) end

			for k,v in pairs(candles) do
				print("Moving to ".. v.Name)
				player:moveTo(CWaypoint(v.X,v.Z,7),true)
				teleport(nil,nil,12)
				keyboardPress(settings.hotkeys.STRAFF_RIGHT.key)
				keyboardPress(settings.hotkeys.STRAFF_LEFT.key)
				HarvestItem(v.Id)
				teleport(nil,nil,7)
			end

			player:moveTo(CWaypoint(3838,3994),true)
			candles = candlelist()
		end

		player:moveTo(CWaypoint(3838,3994),true)

		local waittime = 12
		if startwaittime then
			waittime = waittime - (os.clock() - startwaittime)
		end

		if waittime > 0 then
			printf("Waiting %ds for mobs to despawn.\n",waittime)
			yrest(waittime*1000) -- 10 seconds to let mobs despawn
		end

		print("Going to chest room.")
		UpThroughFloor()

		teleport(3842,3838,49) -- get to chest room
		teleport(3880,3867,55)
	end

	local function getchests()

		--=== Open chests ===--
		function matchests()
			local matchest
			repeat
				matchest = player:findNearestNameOrId(113617,nil,evalClickable)
				if matchest then
					teleport(matchest.X,matchest.Z+3,matchest.Y+6)
					keyboardPress(settings.hotkeys.STRAFF_RIGHT.key)
					keyboardPress(settings.hotkeys.STRAFF_LEFT.key)
					repeat
						player:target_Object(matchest.Id, nil, nil, true, evalClickable);
					until evalClickable(matchest.Address) ~= true
				end
			until matchest == nil

			if type(PutMaterialsIn) == "string" then
				if string.lower(PutMaterialsIn) == "guild" then
					local guild = RoMScript("GetGuildInfo()")
					if GuildDonate == nil then
						print("Unable to donate to guild. Need \"GuildDonate\" userfunction.")
					elseif guild == nil or guild == "" then
						print("Unable to donate to guild. Character not a member of a guild.")
					else
						yrest(1000)
						inventory:update()
						GuildDonate(nil,8)
					end
				elseif string.lower(PutMaterialsIn) == "itemshop" then
					yrest(1000)
					inventory:update()
					for i = 61,240 do
						local item = inventory.BagSlot[i]
						if (not item.Empty) and item.Available and (item:isType("Ores") or item:isType("Wood") or item:isType("Herbs")) then
							item:moveTo("itemshop")
							yrest(1000)
						end
					end
				end
			end
		end

		function runechests()
			local runechest
			repeat
				runechest = player:findNearestNameOrId(113618,nil,evalClickable)
				if runechest then
					teleport(runechest.X,runechest.Z,runechest.Y+6)
					keyboardPress(settings.hotkeys.STRAFF_RIGHT.key)
					keyboardPress(settings.hotkeys.STRAFF_LEFT.key)
					repeat
						player:target_Object(runechest.Id, nil, nil, true, evalClickable);
					until evalClickable(runechest.Address) ~= true
				end
			until runechest == nil
		end
		function mountchests()
			local mountchest
			repeat
				mountchest = player:findNearestNameOrId(113619,nil,evalClickable)
				if mountchest then
					teleport(mountchest.X,mountchest.Z,mountchest.Y+6)
					keyboardPress(settings.hotkeys.STRAFF_RIGHT.key)
					keyboardPress(settings.hotkeys.STRAFF_LEFT.key)
					repeat
						player:target_Object(mountchest.Id, nil, nil, true, evalClickable);
					until evalClickable(mountchest.Address) ~= true
				end
			until mountchest == nil
		end
		if CollectMatChests then
			print("Opening Material chests.")
			matchests()
		end
		if CollectRunesChests then
			print("Opening Rune chests.")
			runechests()
		end
		if CollectMountChests then
			print("Opening Mount chests.")
			mountchests()
		end
	end

	repeat
		player:update()
		if getZoneId() ~= 355 then
			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
				print("Too many Phirius Shells. Skipping.")
				logentry = "Too many Phirius Shells. Skipping."
				numshells = inventory:getItemCount(240181)
				checkRelog()
				return
			end
			local empties = inventory:itemTotalCount(0)
			if 2 > 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

			if player:target_NPC(ange) then
				CompleteQuestByName(proceedquest)
			end

			if ExchangeFragments and player.Level > 20 then
				while inventory:itemTotalCount(frag) > 4 do
					AcceptQuestByName(fragquest)
					CompleteQuestByName(fragquest)
					yrest(500)
				end
			end

			buyitems()

			if player:target_NPC(ange) then
				yrest(2000);
				sendMacro("ChoiceOption(4);");
				yrest(2000);
				sendMacro("ChoiceOption(1);");
				yrest(1000);
				if not waitForLoadingScreen(10) then
					print("Failed to teleport into Ancient Treasure. Maybe you already done it today.")
					logentry = "Failed to teleport into Ancient Treasure. Maybe you already done it today."
					checkRelog()
					return
				end
			else
				print("Too far from Ange Rasa")
				logentry = "Too far from Ange Rasa"
				checkRelog()
				return
			end
		end

		fly()

		if not RoMScript("TimeKeeperFrame:IsVisible()") then -- no timer so click NPC and start it
			if player:target_NPC(luke) then
				yrest(2000);
				sendMacro("ChoiceOption(3);");
				yrest(2000);
				sendMacro("ChoiceOption(1);");
				yrest(5000);
				player:clearTarget()
				UpThroughRoof(1)
			else
				print("Can't find Luke Xavi")
				logentry = "Can't find Luke Xavi"
				checkRelog()
				return
			end
		end

		player:update()
		if player.Y > 15 then
			UpThroughRoof()
		end

		if CollectFragments then
			First2Fragments()
		end

		getunder()
		getcandles()
		getchests()

		local secondsleft = RoMScript("TimeKeeperFrame.startTime-GetTime()")
		local mm = string.format("%2s", math.floor(secondsleft/ 60))
		local ss = string.format("%02s", math.floor(math.mod(secondsleft, 60)))
		printf("Succeeded with %s:%s remaining.\n",mm,ss)
		logentry = string.format("Succeeded with %s:%s remaining.",mm,ss)
		print("records = "..records, inventory:itemTotalCount(records))

		if inventory:itemTotalCount(records) > 0 then
			-- Exit to repeat AT
			if player:target_Object(tran) then
				RoMScript("StaticPopup_OnClick(StaticPopup1, 1);")
				waitForLoadingScreen();
				yrest(3000)
			end
		else
			checkRelog()
			return
		end
	until false
</onLoad>
</waypoints>

kuripot
Posts: 493
Joined: Mon Nov 07, 2011 9:14 pm

Re: Rock5's Ancient Treasure

#55 Post by kuripot » Mon Mar 19, 2012 5:14 pm

how to make function like daily quest reset ticket??

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Rock5's Ancient Treasure

#56 Post by rock5 » Mon Mar 19, 2012 10:58 pm

kuripot wrote:still not using the record,,, just buying
Yes, but what did it print?
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

kuripot
Posts: 493
Joined: Mon Nov 07, 2011 9:14 pm

Re: Rock5's Ancient Treasure

#57 Post by kuripot » Mon Mar 19, 2012 11:52 pm

rock5 wrote:
kuripot wrote:still not using the record,,, just buying
Yes, but what did it print?
Attachments
print.JPG

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Rock5's Ancient Treasure

#58 Post by rock5 » Tue Mar 20, 2012 1:27 am

That time it didn't say "Swimhack deactivated" and instead targeted the Transport Candle correctly. So it worked correctly. All that is left is to use the Record, which I told you previously, I'd forgotten to add.

When is the best time to use it? After leaving the game? Does it take time to use or is it instant?
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

kuripot
Posts: 493
Joined: Mon Nov 07, 2011 9:14 pm

Re: Rock5's Ancient Treasure

#59 Post by kuripot » Tue Mar 20, 2012 3:24 am

it's good to use after leaving the game... and it is instant like daily quest reset ticket

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Rock5's Ancient Treasure

#60 Post by rock5 » Tue Mar 20, 2012 4:29 am

Ok try this.
AT.xml
Version 3.6 b2
(16.91 KiB) Downloaded 191 times
This version also includes slower teleports when clicking the candles so should work better on slower pcs. Lisa please test that this works. And guild donate has been fixed.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest