Open Boxes Optimization Needed

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

Open Boxes Optimization Needed

#1 Post by dr-nuker »

Hello every body!

It's time to ask a question...

I tried to make a script that helps me on picking up boxes but it needs some improvement. The issue is that the way i made it the bot opens a box and when it is open he runs to the spot where the box was. I'd prefer the bot to recognize that he clicked the box and was opening it (or someone else opened) and just click the second nearest box.

I think this has to do with the "fadig away" of opened boxes, so that they are still there even if they have been opened already.

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
<onload>
        for k,v in pairs(settings.profile.skills) do
                v.AutoUse = false
        end

while (true) do
        local target = player:findNearestNameOrId("Mysterious Treasure Chest");

        if ((target) and (100 > distance(target.X, target.Z, player.X, player.Z))) then
                local time = os.time()
                while (target and target.Name == "Mysterious Treasure Chest") do
                        player:target_Object(target.Name);
                        --target:update()
                        player:clearTarget();
                        yrest(700)
                        if (os.time() - time) > 1 then
                                cprintf(cli.yellow,"break1...\n")
                                break
                        end
                end
        else
                cprintf(cli.yellow,"No boxes around...\n")
                player:sleep()
        end
        player:clearTarget();

end

</onload>
</waypoints>
As you see in my code i tried to help myself with a yrest but this is not optimal, since it consumens time, too...

Maybe this can be done with a table?

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

Re: Open Boxes Optimization Needed

#2 Post by lisa »

In my travels I have found that most objects you click have a changed bit in memory to indicate they have been opened/clicked.

This is what I did for the survival minigame and the tiles, it also works in goblins for the chests there.

Code: Select all

	function clicktile(address)
		local tmp = memoryReadRepeat("int", getProc(), address + addresses.pawnAttackable_offset) or 0;
		if bitAnd(tmp,0x8) then
			return true
		else
			return false
		end
	end
with usage like this

Code: Select all

	--=== get any left over tiles ===--
	repeat
	tile = player:findNearestNameOrId("Treasure Tile", nil, clicktile)
		if tile then
			teleport(tile.X,tile.Z,14)
			player:target_Object({111811,111812}, nil, nil, true, clicktile);
		end
	until tile == nil
obviously the names and ID's will need to be changed but hopefully you get the idea.
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
dr-nuker
Posts: 145
Joined: Sun Oct 09, 2011 7:33 am

Re: Open Boxes Optimization Needed

#3 Post by dr-nuker »

Thanks for this!

But still it is the same. The bot behaves like in my script.

It clicks a box and opens it then it seems that he does not recognize that the box has already been opened and clicks again, which makes him move where the box dissapears.

I was hoping that it could be possible to read in all nearby boxes, sort them by distance and then click the closest.
Check if the bot is "casting" opening the box and then remove it from the list.

But well i'm way too unskilled to make that :&
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Open Boxes Optimization Needed

#4 Post by lisa »

tables are easy enough to do.

Code: Select all

	local chests = {}
	local objectList = CObjectList();
	objectList:update();
	local objSize = objectList:size()
	for i = 0,objSize do
		local obj = objectList:getObject(i);
		if obj.Name == "Mysterious Treasure Chest" then
			obj.Dist = distance(player.X,player.Z,obj.X,obj.Z)
			table.insert(chests, table.copy(obj))
		end
	end
	table.sort(chests,function(a,b) return b.Dist>a.Dist end)
	--table.print(chests)
	for k,v in ipairs(chests) do
		teleport(v.X,v.Z,v.Y)
		player:target_Object(v.Name)
		yrest(2000) -- 2 seconds
	end
you can uncomment the --table.print(chests) to make sure the table is working as intended.
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
Post Reply