SRL Archive - Help and Support

Most efficient inventory item finding?


Coh3n

2009-07-25 04:19:05

Hello everyone. :)

I just want to get everyone's opinions on this. I'm making a reflection script and I want to know what the most efficient method of finding items in the inventory. I've tried using ID's but when I use Hesus's debugger nothing comes up for inventory items. :confused:

I would just like to know if I should use Bitmaps/DTMs/ID's. Just want to hear some thoughts/advantages/disadvantages. If you said ID's please tell me how, lol because I can't seem to do it right. XD

Thanks. :)

Wanted

2009-07-25 04:25:05

DTMs, see my Intermediate tutorial for a video. (link in sig)

If you doing things like runes that have the same shape then you can change the center point to a certain color then add some tolerance (not as high as 255 though lol)

ian.

2009-07-25 04:31:53

Bitmaps are faster than DTM's in 3.20+, I believe.

noidea

2009-07-25 04:38:33

GO through each inv spot and use a count colour :D
Like this.

{*****************************************************
Function CountOre: Integer;
By: noidea
Description: Counts any ore except clay you can mine.
Use/Example: Ore := Ore + CountOre;
writeln(IntToStr(CountOre));
*****************************************************}
Function CountOre: Integer;
var
k, I: Integer;
p : TBox;
begin
if not loggedin then exit;
I := 1
While I < 29 do
begin
GetInvItemBounds(I, p);
if countcolor(65536, p.x1, p.y1, p.x1+34, p.y1+27) = 171 then
inc(k);
inc(I);
end;
Result := k;
end

Fastest method afaik :)
btw the above function is over a half year old, and I didn't know for to do loops very well back then :p

Wanted

2009-07-25 04:39:19

From: 99_ aka ian.
Bitmaps are faster than DTM's in 3.20+, I believe.


I doubt that, and it's probably only if you use them right which no one does.

TRiLeZ

2009-07-25 04:41:40

If you want item ID's, you could get it through RSBot.

Coh3n

2009-07-25 04:54:11

From: IceFire908
DTMs, see my Intermediate tutorial for a video. (link in sig)

If you doing things like runes that have the same shape then you can change the center point to a certain color then add some tolerance (not as high as 255 though lol)


I know how to use and make them. :p Just wasn't sure if it was the most efficient. :p

From: 99_ aka ian.
Bitmaps are faster than DTM's in 3.20+, I believe.


I thought so but when I try and make bitmaps it doesn't paste the image properly. It pastes it all blurry and without the black background that I added.

From: IceFire908
I doubt that, and it's probably only if you use them right which no one does.


They are the easiest IMO, at least for what I've been doing.

From: TRiLeZ
If you want item ID's, you could get it through RSBot.


I know, but I could never get RSBot working properly. XD But does it give you the ID of it in the inventory? Because Hesus's works for everything but.

senrath

2009-07-25 05:00:41

You can use the GE to get item IDs. Let's use Wines of Zamorak as an example:
http://itemdb-rs.runescape.com/viewitem.ws?obj=245

See the number at the end? That's the item's ID when it's lying on the ground. It's not quite what you want. But if you increment that number by one, then you get the inventory ID of the Wine of Zamorak.

Coh3n

2009-07-25 05:03:11

From: senrath
You can use the GE to get item IDs. Let's use Wines of Zamorak as an example:
http://itemdb-rs.runescape.com/viewitem.ws?obj=245

See the number at the end? That's the item's ID when it's lying on the ground. It's not quite what you want. But if you increment that number by one, then you get the inventory ID of the Wine of Zamorak.


Hmm I knew you could get the ID that way, but I didn't know that if you increased it by one that would be the inventory ID. I think I'm going to use that if I can get it working, either that or DTMs because I've never had any problems finding objects with DTMs in the past.

Thanks. :)

TRiLeZ

2009-07-25 05:04:01

After you download RS Bot, unzip it and compile it (compile.bat) then run it (Play-Free.bat f2p / Play.bat p2p).
You must have Java JDK to compile though so download it before you do anything.
Or I could try getting you the item ID you need.

Coh3n

2009-07-25 05:05:09

From: TRiLeZ
After you download RS Bot, unzip it and compile it (compile.bat) then run it (Play-Free.bat f2p / Play.bat p2p).
You must have Java JDK to compile though so download it before you do anything.
Or I could try getting you the item ID you need.


I think I should be able to do it using the GE method, but if I need your help I'll definitely let you know, thanks. :)

TRiLeZ

2009-07-25 05:10:42

From: senrath
You can use the GE to get item IDs. Let's use Wines of Zamorak as an example:
http://itemdb-rs.runescape.com/viewitem.ws?obj=245

See the number at the end? That's the item's ID when it's lying on the ground. It's not quite what you want. But if you increment that number by one, then you get the inventory ID of the Wine of Zamorak.


1 number after the object ID would be that item noted. I build RS Private Servers and play em so I know.
The Obj Id from the GE is the same as in the inv and ground.

senrath

2009-07-25 05:13:20

From: TRiLeZ
1 number after the object ID would be that item noted. I build RS Private Servers and play em so I know.
The Obj Id from the GE is the same as in the inv and ground.


Trust me, what I said is correct, unless they changed thins in the last month or so.

TRiLeZ

2009-07-25 05:21:24

From: senrath
Trust me, what I said is correct, unless they changed thins in the last month or so.


No no no, 1 number after would be noted.
Why would the ID in the website GE be different from the ID in the game?
Ive been coding RS Private Servers for a year and I know Im correct.

senrath

2009-07-25 05:27:18

From: TRiLeZ
No no no, 1 number after would be noted.
Why would the ID in the website GE be different from the ID in the game?
Ive been coding RS Private Servers for a year and I know Im correct.


Alright then. Run this script, log in, put a regular log in your inventory, press F12 and tell me what happens:
program New;
{.include SRL/SRL/Misc/Smart.scar}
{.include SRL/SRL.scar}
{.include SRL/SRL/Reflection/Reflection.scar}
begin
Smart_Server := 15;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupReflection;
repeat
Wait(500);
until(IsFKeyDown(12));
R_DropItem(1512); //note the ID. The ID shown by the GE is 1511
end.

TRiLeZ

2009-07-25 05:43:16

From: senrath
Alright then. Run this script, log in, put a regular log in your inventory, press F12 and tell me what happens:
program New;
{.include SRL/SRL/Misc/Smart.scar}
{.include SRL/SRL.scar}
{.include SRL/SRL/Reflection/Reflection.scar}
begin
Smart_Server := 15;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupReflection;
repeat
Wait(500);
until(IsFKeyDown(12));
R_DropItem(1512); //note the ID. The ID shown by the GE is 1511
end.


Your method only works with reflection then becasue the RS Server has the same item ids with ge, inv and ground. 1 number after an item should be noted.
I even just checked and I was right.

ian.

2009-07-25 06:16:07

From: IceFire908
I doubt that, and it's probably only if you use them right which no one does.


It's true, Freddy/multiple people have said so. And I like noidea's concept the most so far. :D (Unless you do reflection, then go with senrath).

senrath

2009-07-25 06:25:07

From: TRiLeZ
Your method only works with reflection then becasue the RS Server has the same item ids with ge, inv and ground. 1 number after an item should be noted.
I even just checked and I was right.


Well, since we're talking about reflection, mine is correct.

ZaSz

2009-07-25 06:28:32

Debugger still works, u just have to have the achievement tab open and hover over the spot of the items

senrath

2009-07-25 06:31:21

From: ZaSz
Debugger still works, u just have to have the achievement tab open and hover over the spot of the items


That makes little sense, so I'd say its understandable that Coh3n didn't figure that out.

ZaSz

2009-07-25 06:35:53

Yeh, just open the achievement gametab and user the debugger to hover over the spot it is in inv.

JPHamlett

2009-07-25 06:45:12

use this


DebugTItemArray(GetInventoryItems);

Boreas

2009-07-25 07:12:03

Blacklists are very effiecient if you need to work with a large number of items. If it's just a few then DTMs or IDs.

Coh3n

2009-07-25 07:14:59

From: Boreas
Blacklists are very effiecient if you need to work with a large number of items. If it's just a few then DTMs or IDs.


What are blacklists?

Yeah as of right now it's just a few items, but I think as the script carries on there will get to me more and more.

Boreas

2009-07-25 07:47:57

Blacklists are kinda like countcolors, except looking at the positions not just quantity, and not counting every pixel. Very fast as you can compare the contents of a slot with what you are looking for and stop as soon as they are not the same. Also, you don't have to create them manually, a function does it for you, the same way every time, so a rune ess blacklist made by one person, is exactly as the same as one made by someone else. That really comes in handy when dealing with a large number of items, even more so when you don't know the items before hand, and you need the script to 'learn' an item that it has never seen before. But if it's less than 10 items, you might as well just make a few DTMs. Or if you are sure that the only items a script will be encountering have different pixels counts, you can could use those.

@noidea:
You can make that even faster, as GetInvItemBounds contains
  FindColorsTolerance(TPA, 65536, T.x1, T.y1, T.x2, T.y2, 0);
If Length(TPA) = 0
Which is basically duplicating the work of countcolor. Also, be careful when dealing with a wide variety of items, as each item slot is 31x31, which is 961, meaning a finite number of possibilities. Now no items are a black square filling up the whole slot, nor are there items with like 10 black pixels. So if you take out the really high and really low, you get maybe 100 to 800. So maybe 700 possible countcolor answers, but there are more than 700 items.

ian.

2009-07-25 07:50:50

Boreas, you're too smart.

How do you make blacklists? :)

Coh3n

2009-07-25 08:03:11

From: Boreas
Blacklists are kinda like countcolors, except looking at the positions not just quantity, and not counting every pixel. Very fast as you can compare the contents of a slot with what you are looking for and stop as soon as they are not the same. Also, you don't have to create them manually, a function does it for you, the same way every time, so a rune ess blacklist made by one person, is exactly as the same as one made by someone else. That really comes in handy when dealing with a large number of items, even more so when you don't know the items before hand, and you need the script to 'learn' an item that it has never seen before. But if it's less than 10 items, you might as well just make a few DTMs. Or if you are sure that the only items a script will be encountering have different pixels counts, you can could use those.


Thanks for that little explanation. :)

@ian. + 1

Boreas

2009-07-25 08:04:30

Here's a tut on how. It's very old, part of another project I stopped working on when reflection had more hooks than walking. If it needs updates let me know.
http://www.villavu.com/forum/showthread.php?t=6229

ninja'd edit: no problem, link above for bigger one

ian.

2009-07-25 08:08:05

Oohh. :D Thanks, Boreas.

Coh3n

2009-07-25 08:08:18

From: Boreas
Here's a tut on how. It's very old, part of another project I stopped working on when reflection had more hooks than walking. If it needs updates let me know.
http://www.villavu.com/forum/showthread.php?t=6229

ninja'd edit: no problem, link above for bigger one


Very nice, I'm going to memorize that in the morning, sleepy time for now. :p

And I'm thinking I wont need to use blacklists anyway because you said to just use DTMs if theres less than 10 items and I'm pretty sure there's going to be less. Hopefully I can get ID's to work also. Anyway, thanks to everyone for the help, :D