Page 1 of 1

InventoryScanner

Posted: Sun Dec 18, 2011 7:01 am
by demogor
Hi to all!
At 1st,thanks for creators of micromacro-there are many useful codes in it,sometimes I use alhorytms of it in my programs.
I have 1 little idea-make program,which would give me list of items in inventory and would help to sort it(C++,MFC).
I try to use item.lua for it. I can get count,dura etc.-all,whic use self.Address,but I have troubles with understanding and using self.BaseItemAddress).
I see,that this taken by GetItemAddress(id),that declared in mmorytable.lua. Ok,I try to make analog of this function in my program,but can't understand 1 thing - how to use tables: local startAddressOffsets = {0,addresses.tableStartPtrOffset, addresses.tableDataStartPtrOffset} ?
If there any analogs in C++ and what must doing memoryReadIntPtr( getProc(), tablePointer , startAddressOffsets )?

Sorry for my bad English and thanks for your attention!
Best regards,Demogor!

Re: InventoryScanner

Posted: Sun Dec 18, 2011 7:24 am
by lisa
I haven't played with C++ in a looong time so not sure how much help I can be with that.

Any reason you can't just extract the info you want from an excel sheet or such?

It is very easy to save info into log files and then you can import the info into excel without to much hassle.

It all depends on how you want the info.

Re: InventoryScanner

Posted: Sun Dec 18, 2011 7:27 am
by demogor
I wanna scan inventory and count,how many(for ex.) leather items I have.
"save info into log files " what kind of info?

Re: InventoryScanner

Posted: Sun Dec 18, 2011 7:33 am
by lisa

Code: Select all

		self.Id = 0;
		--self.BagId = bagId;
		self.Name = "<EMPTY>";
		self.ItemCount = 0;
		self.Color = "ffffff";
		self.SlotNumber = slotnumber
		self.Icon = "";
		self.ItemLink = "|Hitem:33BF1|h|cff0000ff[Empty]|r|h";
		self.Durability = 0;
		self.MaxDurability = 0;
		self.Quality = 0; -- 0 = white / 1 = green / 2 = blue / 3 = purple / 4 = orange / 5 = gold
		self.Value = 0;
		self.Worth = 0;
		self.InUse = false;
		self.BoundStatus = 1; -- 0 = bound on pickup, 1 = not bound, 2 = binds on equip 3 = binds on equip and bound
		self.RequiredLvl = 0;
		self.CoolDownTime = 0;
		self.LastTimeUsed = 0;
		self.MaxStack = 0;
		self.ObjType = 0;
		self.ObjSubType = 0;
		self.ObjSubSubType = 0;
		self.Stats = {}; -- list of named stats and their ids.
That is the item info we can get.
on top of that you can do account name, character name, server name, date and time.
It all depends on what you want =)

I believe ObjSubType is if leather or not,
2 == leather.

Code: Select all

		[2] = { Name = "Leather",
			[1] = { Name = "Upper Body Leather" },
			[2] = { Name = "Belts Leather" },
			[3] = { Name = "Lower Body Leather" },
			[4] = { Name = "Hands Leather" },
			[5] = { Name = "Feet Leather" },
			[6] = { Name = "Capes Leather" },
			[7] = { Name = "Shoulders Leather" },
			[0] = { Name = "Head Leather" },

Re: InventoryScanner

Posted: Sun Dec 18, 2011 8:03 am
by demogor
Yes,that's why I start trying to use this alhorythm.But it 1 trouble with it...

For ex.,we get count: self.ItemCount = memoryReadInt( getProc(), self.Address + addresses.itemCountOffset );
And we get obj type: self.ObjType = memoryReadInt( getProc(), self.BaseItemAddress + addresses.typeOffset );

As we can see,in frist we use self.Address,that get from
self.BagId = memoryReadUByte(getProc(), addresses.inventoryBagIds + self.SlotNumber - 1) + 1
self.Address = addresses.staticInventory + ( ( self.BagId - 61 ) * 68 ).
It's ok,I did it.

But self.BaseItemAddress is mor hard to take: GetItemAddress( self.Id );

And from this part troubles started.

function GetItemAddress(id) declared in memorytable.lua
For using it we need addressline = GetIdAddressLine(id);

And in local function GetIdAddressLine(id) I get problem-can't understand what next code must doing:

local startAddressOffsets = {0,addresses.tableStartPtrOffset, addresses.tableDataStartPtrOffset}
local dataPointer = memoryReadIntPtr( getProc(), tablePointer , startAddressOffsets ) - lineSize

startAddressOffsets - it's offset for taking dataPointer - but I can't understand,how it work(

If you can tell me,what mean it {0,addresses.tableStartPtrOffset, addresses.tableDataStartPtrOffset} and how it used in memoryReadIntPtr( getProc(), tablePointer , startAddressOffsets ) ?

Re: InventoryScanner

Posted: Sun Dec 18, 2011 8:26 am
by lisa
I think you are missing the point, all the adress code is all done in the bachground and we don't need to worry about it.

I'll give you an example.

Code: Select all

	local bags = {}
	inventory:update()
	for slot = 61, 240 do
		item = inventory.BagSlot[slot]
 	    if item.Available and  item.Name ~= "<EMPTY>" then
			table.insert(bags, {Name = item.Name, Id = item.Id, Rlevel = item.RequiredLvl, stats = item.Stats})
		end;
	end;
	table.print(bags)
This code will print to micromacro all the item
Names, Id, required levels, stats.
I didn't have to worry about any addresses as that code is already done.

So instead of doing a table.insert you could save that information to a log file for usage with what ever programme you are thinking of.

Another example is this code I added to Rock's CoT WP.

Code: Select all

		local filename = getExecutionPath() .. "/logs/shellitems.log";
		local file, err = io.open(filename, "a+");
		if file then
			inventory:update()
			for slot = 61, 240 do
				item = inventory.BagSlot[slot]
				if item.RequiredLvl >= 67 then
					file:write("Account: "..RoMScript("GetAccountName()").."\tName: " ..string.format("%-10s",player.Name ).." \tDate: " .. os.date())
					for k,v in pairs(item.Stats) do
						file:write("\n \t Name = "..item.Name.."\tStat = "..v.Name) 
						file:write("\t Durability = "..item.Durability)
					end
				file:write("\n\n")
				end
			end
			file:close()
		end
So this saves information to a file named shellitems.log
which looks like this

Code: Select all

Account: *****	Name: *****	Date: 12/18/11 01:31:59
 	 Name = Callous Wisdom Gloves	Stat = Glorious Mysticism VIII	 Durability = 98

Account: *****	Name: *****	Date: 12/18/11 01:37:40
 	 Name = Callous Vengeance Belt	Stat = Glorious Strength VIII	 Durability = 100

Account: *****	Name: *****	Date: 12/18/11 01:43:18
 	 Name = Suppression Heavy Boots of the Fort	Stat = Crimson Defense VIII	 Durability = 103

Re: InventoryScanner

Posted: Sun Dec 18, 2011 8:44 am
by demogor
Look like that I really miss the point)

I wanna take this alhorytm to my program.

You use inventory:update() for loading list of items from memory,yeah? If you wouldn't doing it,you wouldn't can get inf about item.
That's mean,that you wouldn't can't get list without GetIdAddressLine(),that return us to place,where I miss point)
Or may be I muiss with it?

Re: InventoryScanner

Posted: Sun Dec 18, 2011 8:59 am
by lisa
That is what I thought.

This forum is about the usage of Micromacro and more importantly Rombot.

If you wanted help with usage of Micromacro i would be able to help you.

You however are trying to use the code of Micromacro in your programme for what ever reason and I can't help you with that.

Good luck.

Re: InventoryScanner

Posted: Sun Dec 18, 2011 9:03 am
by demogor
Thanks for helping!
Good luck!

Re: InventoryScanner

Posted: Sun Dec 18, 2011 3:10 pm
by demogor
I did it!
Thanks for alhorytm and ideas!
If anyone would need code of the sorter,write here.