How to work with an object table

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Rickster
Posts: 291
Joined: Sun Oct 24, 2010 4:23 pm

How to work with an object table

#1 Post by Rickster » Fri Feb 15, 2013 7:07 am

Hello,

I just try to work on that event on Varanas bridge, where you have to throw off these animals.

I try to gather some attributes of the objects around me, manipulate them and work with changed and unchanged attributes.
But this drives me kinda crazy.

Just for a test exsample I use this function

Code: Select all

function printList()
	
	local objectList = CObjectList()
	objectList:update()
	local objSize = objectList:size()

	for i=0,objSize do 
		obj = objectList:getObject(i) 
		if obj.Id == 120386 or obj.Id == 120385 or obj.Id == 120384 then 
			if obj.Marker == nil then obj.Marker = false end
			cprintf_ex(" ID: %s, Attk: %s, Marker: %s \n", obj.Id, obj.Attackable, obj.Marker)
			obj.Marker = true
			cprintf_ex(" ID: %s, Attk: %s, Marker: %s \n", obj.Id, obj.Attackable, obj.Marker)
			cprintf_ex(" ------\n")
		end 
	end	
end
It updates an object table, walks through all objects and on every object with a special ID ist does
  • look if there is a member "Marker", if not defined sets it to false
  • print out some information about it
  • sets "Marker" to true
  • print out the changed info
Important thing is, that I want to keep an information for an object which persists also after the next objectList:update().
But when running the function once again, all changed information about an object is lost and the added member "Marker" no longer exists, so that I can not ask for the information I changed, when I called the function last time.
Has someone an idea how to keep information about an object?
... some thing comes to my mind right now: building an own table to keep objects info ... will give that a try, but I am curious about your ideas.

Minor thing is, the Attackable flag is always false at the animals, although I can throw at them. Maybe its because its not realy fighting them, but using a special atack.
But I also see, that objects like direction signs in Silverspring have Attackable set to true ... strange thing and not realy helpful for finding objects to realy fight against ... not only in the above case.

Ric

Jandrana
Posts: 187
Joined: Thu Jul 05, 2012 5:53 am

Re: How to work with an object table

#2 Post by Jandrana » Fri Feb 15, 2013 7:41 am

But when running the function once again, all changed information about an object is lost
This is behavior by design. Look at the implementation of CObjectList:update():

Code: Select all

function CObjectList:update()
	self.Objects = {}; -- Flush all objects.
	local size = memoryReadInt(getProc(), addresses.staticTableSize);

	for i = 0,size do
		local addr = memoryReadUIntPtr(getProc(), addresses.staticTablePtr, i*4);
		if( addr and addr > 0) then
			self.Objects[i] = CObject(addr);
		end
	end
end
In your case I would copy all relevant objects to an extra list. I haven't done a lot with ObjectList, but I think you can run into problems, if you move your char and the client will remove some objects from memory.

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

Re: How to work with an object table

#3 Post by rock5 » Fri Feb 15, 2013 8:40 am

The unique identifiable value is the address. If the address matches then it's the same object. I'd probable save the marked objects in a separate table by address, saves you having to search through it. eg.

Code: Select all

if obj.Id == 120386 or obj.Id == 120385 or obj.Id == 120384 then
    Marked[obj.Address] = obj
end
Then later, when you want to know if an obj is marked just do

Code: Select all

if Marked[obj.Address] then
    -- Object mark
else
    -- Object not marked
end
  • 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

Rickster
Posts: 291
Joined: Sun Oct 24, 2010 4:23 pm

Re: How to work with an object table

#4 Post by Rickster » Sat Feb 16, 2013 3:50 pm

Thanx Jandrana and Rock!
rock5 wrote:The unique identifiable value is the address. If the address matches then it's the same object. I'd probable save the marked objects in a separate table by address, saves you having to search through it. eg.

Code: Select all

if obj.Id == 120386 or obj.Id == 120385 or obj.Id == 120384 then
    Marked[obj.Address] = {}
end
I am doing it like Rock told, but do not save the whole object. All I need is the object address in the table, to know if I already worked on it.

Works as I need it :)
Thanx

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests