Find out if a chest has been opened

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
dr-nuker
Posts: 145
Joined: Sun Oct 09, 2011 7:33 am

Find out if a chest has been opened

#1 Post by dr-nuker » Sat Jan 26, 2013 4:06 pm

Hello there,

so after a longer time I've returned with a question. Of course it's easy to solve for the real professionals here, but for me it's too tricky :&

Here is my code:

Code: Select all

                player:target_NPC("Drillmaster");
                yrest(500)

                sendMacro("ChoiceOption(2);");
                repeat
                        yrest(100)
                until player:findNearestNameOrId("Destiny Box")

	local time = os.time()
        while ((5 * 60 * 1000) > os.time() - time) do
                local target = player:findNearestNameOrId("Destiny Box");
                if (target) then
                        teleport(target.X, target.Z)
                        player:target_Object("Destiny Box")
                        while(target.Name == "Destiny Box") do
                                yrest(100)
                                target:update()
                        end
                end
                player:clearTarget();
                player:update();
                local targetenemy = player:findNearestNameOrId("Obstructor of Fate");
		if (targetenemy) then
                	if (targetenemy.Name == "Obstructor of Fate") then
                  	      	local XX = player.X;
                 		local ZZ = player.Z;
                 	       	local targethelper = player:findNearestNameOrId("Drill Ground Guardian");
				repeat
					targethelper.update();
                 	       		player:moveTo(CWaypoint(targethelper.X, targethelper.Z, targethelper.Y),true)
				until 30 > (math.abs(targethelper.X - player.X) + math.abs(targethelper.Z - player.Z))
                	        player:moveTo(CWaypoint(targethelper.X+10, targethelper.Z-10, targethelper.Y),true)
                	        player:moveTo(CWaypoint(targethelper.X-10, targethelper.Z+10, targethelper.Y),true)
                	        yrest(750)
                	        teleport(XX, ZZ)
                        	targetenemy:update();
                	end
		end
                player:clearTarget();
        end
This code should do:

Find a Destiny Box wich spawns in groups of 2 up to 9, pick the closest and open it. After it is open it shall proceed to the next box until all boxes are open.
Once all are open or player found a badge the boxes vanish and new boxes spawn.
From time to time there is a chance that a Obstructor of Fate spawns. The player has to run to the Drill Ground Guardian t get rid of the mob. But the mob does not always follow, but fall into pices in place or fight the Guard. No idea how to check if the mob is hitting the bot.

So any idea how i can make the bot recognize that a box is open and go to the next one?

Br,
nuker

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

Re: Find out if a chest has been opened

#2 Post by lisa » Sat Jan 26, 2013 7:33 pm

a few ideas come to mind.

--=== option 1 ===--
I assume that when you first start to open boxes they are all there, so you could just make a table of the boxes and start to open them 1 by 1. Sounds like you will also need code to check if the box is still actually there as they dissappear?

so something like this

Code: Select all

		tiles = {}

		local objectList = CObjectList();
		objectList:update();
		local objSize = objectList:size()

		for i = 0,objSize do
			local obj = objectList:getObject(i);
			if obj.Id == 111811 or obj.Id == 111812 then
				table.insert(tiles, table.copy(obj))
			end
		end

		-- sort by address
		local function addresssortfunc(a,b)
			return a.Address > b.Address
		end
		table.sort(tiles, addresssortfunc)
object Id's would need to be changed but the idea is it looks through all objects around you and when it finds something with the correct Id it adds it to a table, you can then use the table to go from chest to chest opening them up.


--=== option 2 ===--
Another option is to check the "opened" bit value we have used a few times here and there, like in malatinas survival.

you have a function which checks if chest has been opened, can look like this.

Code: Select all

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

Code: Select all

	repeat
		chest = player:findNearestNameOrId(brownwoodenchest,nil,clickchest)
		if chest then
			fly()
			teleport(chest.X+10,chest.Z+10,18)
			repeat
				player:target_Object(chest.Id, nil, nil, true);
			until clickchest(chest.Address) ~= true
		end
	until chest == nil
That code it taken from Rock's survival. you would need to change brownwoodenchest to the Id of the chests you are trying to open.
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

barboza
Posts: 6
Joined: Wed May 22, 2013 6:30 pm

Re: Find out if a chest has been opened

#3 Post by barboza » Wed May 22, 2013 6:46 pm

Sorry for bumping an old thread, but I need help according to the above functions. Thing is there is a place where chests spawn at one place and are getting stacked.
The table works for opening them, but after a moment it takes longer and longer before it checks if the chest has loot. Is there a way to speed up the checking process trough the table so the bot would know right away which chest has loot?

Function without table doesn't target correct chest..
Any help appreciated.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests