SRL Archive - SRL Site Discussion

BMP database?


tank phobia

2008-10-04 02:15:18

Ok on runescape pro's suggestion I have changed the idea to a DTM database. DTM's aren't hard to make but when you are not on runescape or don't have the item you want a DTM of it can get a little frustrating.

Wouldn't it be nice to just jump on srl and be confronted with a database of tested DTM's ready for your use? This is my suggestion.

Buckleyindahouse

2008-10-04 02:23:51

like

LoadDTMFromDB("Net");

and it loads a dtm from srl's database?

if so, wouldn't that become laggy to people on dial up or slow connections and cost SRL alot of money from people constantly downloading the dtm's and bmp's over and over because I believe alot of scripters release their resources right after their done.

Runescape Pro

2008-10-04 02:42:26

I think he means just a database with bmp's of everything available for download. So you wont have to make one if one is already made. That's just my guess and i think this would be rejected due to the fact the bmp's aren't very reliable for item finding. A DTM database would be cool though.

tank phobia

2008-10-04 02:50:59

From: Runescape Pro
I think he means just a database with bmp's of everything available for download. So you wont have to make one if one is already made. That's just my guess and i think this would be rejected due to the fact the bmp's aren't very reliable for item finding. A DTM database would be cool though.


Yeah that's what I meat. You're right, DTM's are more reliable, having a database of DTM's would mean that for those people who aren't on rs at the time or don't have the item they want a DTM of they could simply navigate through a few main categories to find the DTM's they want. The database would be filled very quickly too as those who didn't find the DTM they want could just make it themselves and post it once they are done.

This would make script making just that little bit quicker, and scripters know that when you are on a roll you don't want to be stopping every time you need another DTM.

Runescape Pro

2008-10-04 02:56:18

From: tank phobia
Yeah that's what I meat. You're right, DTM's are more reliable, having a database of DTM's would mean that for those people who aren't on rs at the time or don't have the item they want a DTM of they could simply navigate through a few main categories to find the DTM's they want. The database would be filled very quickly too as those who didn't find the DTM they want could just make it themselves and post it once they are done.

This would make script making just that little bit quicker, and scripters know that when you are on a roll you don't want to be stopping every time you need another DTM.

Wow… That's a great idea. Also, for a newcomer, you are very sophisticated. Having a DTM section under a sub forum such as scripting help would be a great idea IMO.

Santa_Clause

2008-10-04 03:15:40

There's already a bitmap database as part of the SRL include…

NiCbaZ

2008-10-04 03:34:40

Yes there is but a bigger DTM one would be nice…

tank phobia

2008-10-04 05:14:36

From: Runescape Pro
Wow… That's a great idea. Also, for a newcomer, you are very sophisticated. Having a DTM section under a sub forum such as scripting help would be a great idea IMO.


Thanks Runescape Pro. :D

From: Santa_Clause
There's already a bitmap database as part of the SRL include…


Sorry have edited my original post to make this clearer now, I have changed the idea to a database of DTMs instead. As far as there being a database of BMPs in the srl include I was completely oblivious to that so thanks for enlightening me!

yettti

2008-10-04 06:24:10

DTMs are a great idea, they would be easy to store in a database as you could have a max of say 20 points, so you would need 21 colums, quite easyly ahievable with mysql

Wizzup?

2008-10-04 07:59:58

Nice idea. Maybe it would be better to collect information like the items Outline pixels count. (Black outline), it's reference color, approximate tolerance and approximate colors that should be found to identify the item.
Also Width and Height based on outline. And what about the item's total pixel count?

Tniffoc

2008-10-04 08:55:42

From: Wizzup?
Nice idea. Maybe it would be better to collect information like the items Outline pixels count. (Black outline), it's reference color, approximate tolerance and approximate colors that should be found to identify the item.
Also Width and Height based on outline. And what about the item's total pixel count?


Ooh I like the colors idea. I always just close rs and then find I need to find colors again!

EDIT: Make sure to state the standard brightness though…

Narcle

2008-10-04 09:47:57

From: Wizzup?
Nice idea. Maybe it would be better to collect information like the items Outline pixels count. (Black outline), it's reference color, approximate tolerance and approximate colors that should be found to identify the item.
Also Width and Height based on outline. And what about the item's total pixel count?


Isn't there a way to get all the colors found in an area? Also couldn't we designate that area by using the Black color of the outline then you have the inner parts still?

ZephyrsFury

2008-10-04 09:50:00

Whats faster? Comparing colour count and colours at certain points or using a DTM?

Wizzup?

2008-10-04 10:20:49

From: ZephyrsFury
Whats faster? Comparing colour count and colours at certain points or using a DTM?


Comparing outlines, then determine further is easier, faster and better than DTM's. DTM's are all encrypted, and this is just plain data.
Also, TPA's > DTM's. They are faster, more dynamic and you can principally do anything with it.

ZephyrsFury

2008-10-04 10:28:23

Rightio its a good idea then.

Naum

2008-10-04 10:28:45

Oh what I thought of was make it link to a website to find the picture of the item then create a bitmap or dtm from it like

Function CreateItems(Item : String; WhatType : String) : Integer;
Begin
Case Lowercase(WhatType) Of
'Bitmap' : Begin
//OpenWebPage ('www.runescapeitems.com/' + lowercase(Item));
//MakeBitmap 5*5 pixels
Result := //thing? bitmap
end;
'DTM' : //Same as bitmap except makedtm instead of makebitmap
Result := //thing? dtm
end;

Procedure FindNet;
Begin
If FindBitmap(CreateItems('net', 'dtm'),x, y) Then
WriteLn('Found');
end;

^ example..

nielsie95

2008-10-04 11:19:02

From: Wizzup?
Nice idea. Maybe it would be better to collect information like the items Outline pixels count. (Black outline), it's reference color, approximate tolerance and approximate colors that should be found to identify the item.
Also Width and Height based on outline. And what about the item's total pixel count?


What about runes or other common stacks?

ZephyrsFury

2008-10-04 11:23:42

From: nielsie95
What about runes or other common stacks?


Use a pixel or several pixels from the middle of the rune or something to identify them.

EDIT: Or are you talking about the text covering part of the image?

nielsie95

2008-10-04 11:34:45

Yes, it would be nice if the system also worked in a store or bank.

Tniffoc

2008-10-04 12:04:27

Ok guys, I've got a new idea. There should be a new section of the website where we have a database of 4-5 colors from every object in the game. Everyone would have to help in order to complete the project, and it would be incomplete almost always. For example, if you want to use willow logs in your script and it isn't in the database, then you could add it yourself! Sorry if I didn't explain it too well…

Narcle

2008-10-04 12:16:09

Logs would be a problem as well… Very close in color. TPA count of the black outline would be good. Problem is now identifying similar shapes that have same count? You think also having the color inside the item that is most abundant & best average?

Edit: TPA count of both colors. With near perfect color counts +-1?

Wizzup?

2008-10-04 14:31:22

From: nielsie95
What about runes or other common stacks?


A simple color (count) will be able to distinguish them. I'll make an example later. :)

nielsie95

2008-10-04 14:35:58

I meant the outline length differs also.

tank phobia

2008-10-04 17:40:46

Wow guys you have really expanded the idea much further than I thought. I'm not going to lie and say I understand what you guys are talking about for the most part, will go and read up on TPA's etc now so I can be a little more helpful .

ZephyrsFury

2008-10-05 01:34:06

From: tank phobia
Wow guys you have really expanded the idea much further than I thought. I'm not going to lie and say I understand what you guys are talking about for the most part, will go and read up on TPA's etc now so I can be a little more helpful .


They're talking about using things that make the image of the item unquie such as the number of black pixels surrounding the item image, the maximum width and height of the item and colours that make similar images (such as logs, runes, cooked, uncooked and burnt fish) different.

tank phobia

2008-10-05 01:41:01

From: ZephyrsFury
They're talking about using things that make the image of the item unquie such as the number of black pixels surrounding the item image, the maximum width and height of the item and colours that make similar images (such as logs, runes, cooked, uncooked and burnt fish) different.


That clears it up, thanks Zephyr. That would be great to have in a database on SRL!

bullzeye95

2008-10-05 02:07:00

From: Wizzup?
And what about the item's total pixel count?


How would you go about doing that?

tank phobia

2008-10-05 03:37:13

From: bullzeye95
How would you go about doing that?


I am not as good with scar as you others are but at a guess you could get the dimensions and multiply them to get total area less the number of black pixels. This would give a pixel count less the outline obviously but this is the only way I can think of.

Runescape Pro

2008-10-05 03:51:02

From: tniffoc
Ok guys, I've got a new idea. There should be a new section of the website where we have a database of 4-5 colors from every object in the game. Everyone would have to help in order to complete the project, and it would be incomplete almost always. For example, if you want to use willow logs in your script and it isn't in the database, then you could add it yourself! Sorry if I didn't explain it too well…


I agree. This is a great idea. And it could become a great community project.

tank phobia

2008-10-05 03:56:44

After reading through this thread there are actually alot of ideas people have come up with. I am not experienced enough with scar to know which ideas would be the most useful so could some experience scripters have a read through and say what they think would be the best project to implement and any other relevant details?

Wizzup?

2008-10-05 06:27:08

From: bullzeye95
How would you go about doing that?


Split the TPA for each X, with SplitTPAEx(X = 1, Y = InvYBound). Then get the min and max Y for each line, then get the count for those lines. Add it all.

mixster

2008-10-05 06:36:23

function OutlineLength(slot: Integer): Integer;
var
inBx: TBox;
begin
inBx := InvBox(slot);
Result := CountColor(65536, inBx.x1, inBx.y1, inBx.x2, inBx.y2);
end;

function MainColor(slot: Integer): Integer;
var
inBx: TBox;
x, y, i, c: Integer;
s: Boolean;
cols, count: TIntegerArray;
begin
inBx := InvBox(slot);
for y := inBx.y1 to inBx.y2 do
begin
s := False;
for x := inBx.x1 to inBx.x2 do
begin
c := GetColor(x, y);
if not s then
s := c = 65536
else
s := c <> 65536
if not s then
Continue;
for i := 0 to High(cols) do
if c = cols[i] then
begin
Inc(count[i]);
Break;
end;
if c <> cols[i] then
begin
i := High(cols) + 1;
SetArrayLength(cols, c + 1);
cols[i] := c;
SetArrayLength(count, c + 1);
count[i] := 1;
end;
end;
end;
for i := 0 to High(cols) do
if count[i] > count[Result] then
Result := i;
Result := cols[Result];
end;
Anything like those for a first couple of item details? (No idea if it actually even compiles, but I would think/hope it does :))

mastaraymond

2008-10-05 06:49:25

Wasn't boreas working on a project like this? Ol' times ^_^.

yettti

2008-10-05 07:54:33

i would be happy to handle the web side of things if u guys need it LOL databases are my thing… :-)

ZephyrsFury

2008-10-05 07:57:10

Heres just something I quick made up:


program New;
{.include SRL/SRL.scar}

var
I: Integer;

type
TItemDef = record
Name: string;
Count, W, H: Integer;
UniquePts: TPointArray;
UniqueCols: TIntegerArray;
end;

const
cTol = 10; //Tolerance for the unique colour points

function LoadItemDef(ItemNo: Integer): TItemDef;
begin
case ItemNo of
0: with Result do
begin
Name := 'Iron Scimitar';
Count := 71;
W := 26;
H := 29;
UniquePts := [Point(15, 12), Point(4, 23)];
UniqueCols := [5132116, 1818328];
end;
end;
end;

function FindItem(var x, y: Integer; Item: TItemDef; x1, y1, x2, y2: Integer): Boolean;
var
bPts: TPointArray;
bATPA: T2DPointArray;
II, G: Integer;
TB: TBox;
begin
x := 0; y := 0;
if (FindColorsTolerance(bPts, 65536, x1, y1, x2, y2, 0)) then
begin
bATPA := SplitTPAEx(bPts, 42, 36);
for II := 0 to High(bATPA) do
begin
if (Length(bATPA[II]) <> Item.Count) then Continue;
TB := GetTPABounds(bATPA[II]);
if (TB.x2 - TB.x1 <> Item.W) then Continue;
if (TB.y2 - TB.y1 <> Item.H) then Continue;
for G := 0 to High(Item.UniquePts) do
begin
try
Result := SimilarColors(GetColor(TB.x1 + Item.UniquePts[G].x, TB.y1 + Item.UniquePts[G].y), Item.UniqueCols[G], cTol);
except
WriteLn('No of Pts don''t match number of colours.');
end;
end;
if (Result) then
begin
x := (TB.x2 - TB.x1) shr 1;
y := (TB.x2 - TB.x1) shr 1;
Break;
end;
end;
end;
end;

function FindItems(var Points: TPointArray; Item: TItemDef; x1, y1, x2, y2: Integer): Boolean;
var
tBool: Boolean;
II, G: Integer;
bPts: TPointArray;
bATPA: T2DPointArray;
TB: TBox;
begin
SetLength(Points, 0);
if (FindColorsTolerance(bPts, 65536, x1, y1, x2, y2, 0)) then
begin
bATPA := SplitTPAEx(bPts, 50, 50);
for II := 0 to High(bATPA) do
begin
if (Length(bATPA[II]) <> Item.Count) then Continue;
TB := GetTPABounds(bATPA[II]);
if (TB.x2 - TB.x1 <> Item.W) then Continue;
if (TB.y2 - TB.y1 <> Item.H) then Continue;
for G := 0 to High(Item.UniquePts) do
begin
try
tBool := SimilarColors(GetColor(TB.x1 + Item.UniquePts[G].x, TB.y1 + Item.UniquePts[G].y), Item.UniqueCols[G], cTol);
except
WriteLn('No of Pts don''t match number of colours.');
end;
end;
if (tBool) then
begin
SetLength(Points, Length(Result) + 1);
Points[High(Points)] := Point((TB.x2 - TB.x1) shr 2, (TB.x2 - TB.x1) shr 2);
end;
end;
end;
Result := Length(Points) > 0;
end;

procedure CaptureImage(x1, y1, x2, y2: Integer);
var
Pts: TPointArray;
TB: Tbox;
BMP: INteger;
begin
if (FindColorsTolerance(Pts, 65536, x1, y1, x2, y2, 0)) then
begin
Tb := GetTPABounds(Pts);
BMP := BitmapFromString(TB.x2 - tb.x1, tb.y2 - tb.y1, '');
CopyCanvas(GetClientCanvas, GetBitmapCanvas(BMP), Tb.x1, tb.y1, tb.x2, tb.y2, 0, 0, tb.x2-tb.x1, tb.y2-tb.y1);
DisplayDebugImgWindow(tb.x2 - tb.x1, tb.y2 - tb.y1);
CopyCanvas(GetBitmapCanvas(BMP), GetDebugCanvas, 0, 0, tb.x2-tb.x1, tb.y2-tb.y1, 0, 0, tb.x2-tb.x1, tb.y2-tb.y1);
WriteLn('Count: ' + IntToStr(Length(Pts)));
Writeln('W: ' + Inttostr(tb.x2-tb.x1) + ', H: ' + inttostr(tb.y2-tb.y1));
end;
end;

var
AirRune: TItemDef;
x, y: integer;
begin
SetupSRL;
//ActivateClient;
Wait(100);
//CaptureIMage(562, 211, 599, 250);
AirRune := LoadItemDef(0);
i := getsystemtime;
if (FindItem(x, y, AirRune, 555, 211, 731, 458)) then
Writeln('woot');
writeln(inttostr(getsystemtime - i));
end.

I think thats the basic idea. Count and W and H might not work for stacks but we can still use points and colours. It works for Iron Scimmy at least.

Santa_Clause

2008-10-05 08:47:50

Ehh, this may just become too messy and hard to handle if it's a community project.

Tniffoc

2008-10-05 08:49:36

Hey, I just thought of something, doesn't runehq have a database with pictures for all the items :eek:!

nielsie95

2008-10-05 09:07:15

We can get the pictures from the GE site :)

yettti

2008-10-05 09:07:55

yes, yes they do… that would make things so much easer a simple program tyo phrase there item section of the site for images a bit of processing and wallah

Tniffoc

2008-10-05 09:08:55

From: nielsie95
We can get the pictures from the GE site :)


Wow, that just owned my idea. :)

nielsie95

2008-10-05 09:15:42


program New;

const
NonMembsOnly = True;

function FixName(s: string): string;
var
r: TStringArray;
i: Integer;
begin
r := [' ', '''', '(', ')', '-'];
Result := Replace(s, '+', 'PP');
for i := 0 to High(r) do
Result := Replace(Result, r[i], '_');
Result := Replace(Result, '__', '_');
while (Result[1] = '_') do
Delete(Result, 1, 1);
while (Result[Length(Result)] = '_') do
Delete(Result, Length(Result), 1);
end;

var
Page, img, Name, Members, ID: string;

procedure ProcessPic;
var
a, w, h,
i, k, mn, mx, m,
q, r, s, x, y, z: Integer;
p: TPointArray;
c: TIntegerArray;
b: TBox;
begin
a := LoadBitmap(AppPath + 'tmp.gif');
GetBitmapSize(a, w, h);
DisplayDebugImgWindow(w * 3, h * 3);
FastReplaceColor(a, 2105392, 0);
try
SetTargetBitmap(a);
FindColorsTolerance(p, 65536, 0, 0, w, h, 0);
b := GetTPABounds(p);
b.y1 := Max(b.y2 - 20, b.y1);
Swap(b.x1, b.x2);
mn := b.x1;
mx := b.x2;
m := Max(b.y1 + 3, b.y2 - 10);
for i := 0 to High(p) do
if (p[i].y > b.y1) then
begin
Inc(k);
if (p[i].x < b.x1) then
b.x1 := p[i].x
else if (p[i].x > b.x1) then
b.x2 := p[i].x;
if (p[i].y = m) then
if (p[i].x < mn) then
mn := p[i].x
else if (p[i].x > mx) then
mx := p[i].x;
end;
//WriteLn('Count: '+IntToStr(k)+' w: '+IntToStr(b.x2 - b.x1));
FindColorsTolerance(p, clWhite, mn, m, mx, m, 441);
c := GetColors(p);
ClearSameIntegersAndTPA(c, p);
mn := 0;
mx := 0;
for i := 1 to High(c) do
if (c[i] < c[mn]) then
mn := i
else if (c[i] > c[mx]) then
mx := i;
if (Length(c) = 0) then
WriteLn(Padr(' '+FixName(Name)+' := InvItem('+IntToStr(k)+', '+IntToStr(b.x2 - b.x1)+', -1, Point(-1, -1), Point(-1, -1), -1);', 95)+'//'+Name)
else
begin
ColorToRGB(c[mn], q, r, s);
ColorToRGB(c[mx], x, y, z);
//WriteLn('Difference: '+IntToStr((iAbs(q - x) + iAbs(r - y) + iAbs(s - z) / 3))+' at: ('+IntToStr(p[mn].x - b.x1)+', '+IntToStr(b.y2 - p[mn].y)+') and ('+IntToStr(p[mx].x - b.x1)+', '+IntToStr(b.y2 - p[mx].y)+')');
WriteLn(Padr(' '+FixName(Name)+' := InvItem('+IntToStr(k)+', '+IntToStr(b.x2 - b.x1)+', '+IntToStr((iAbs(q - x) + iAbs(r - y) + iAbs(s - z) / 3))+', Point('+IntToStr(p[mn].x - b.x1)+', '+IntToStr(b.y2 - p[mn].y)+'), Point('+IntToStr(p[mx].x - b.x1)+', '+IntToStr(b.y2 - p[mx].y)+'), -1);', 95)+'//'+Name);
end;
FastReplaceColor(a, 0, clFuchsia);
CopyCanvas(GetBitmapCanvas(a), GetDebugCanvas, 0, 0, w, h, 0, 0, w * 3, h * 3);
finally
FreeBitmap(a);
end;
end;

var
Letter, PageCount, curPage: Integer;
a, b, c: Integer;
f: Integer;
begin
ClearDebug;
for Letter := Ord('A') to Ord('Z') + 1 do
begin
if (Letter = (Ord('Z') + 1)) then
Page := GetPage('http://itemdb-rs.runescape.com/results.ws?query=&sup=Initial%20Letter&sub=All&cvis=1&vis=0&sortby=name&order=1&cat=Other')
else
Page := GetPage('http://itemdb-rs.runescape.com/results.ws?query=&sup=Initial%20Letter&cat='+Chr(Letter)+'&sub=All&page=1&vis=1&order=1&sortby=name&price=&members=');
a := Pos('">Last ', Page);
b := LastPosEx('<a href="', Page, a);
if (a > 0) and (b > 0) then
PageCount := StrToIntDef(Between('page=', '&amp;', Copy(Page, b, a - b)), -1)
else
PageCount := -1;
for curPage := 1 to PageCount do
begin
//WriteLn('<--'+Chr(Letter)+': '+IntToStr(curPage)+'/'+IntToStr(PageCount)+'-->');
if (curPage > 1) then
Page := GetPage('http://itemdb-rs.runescape.com/results.ws?query=&sup=Initial%20Letter&cat='+Chr(Letter)+'&sub=All&page='+IntToStr(curPage)+'&vis=1&order=1&sortby=name&price=&members=');
a := Pos('search_results_table', Page);
if (a < 1) then
Continue;
a := PosEx('<img src="http://itemdb-rs.runescape.com/', Page, a);
b := PosEx('>', Page, a);
while (a > 0) and (b > 0) do
begin
Name := Between('alt="', '"', Copy(Page, a, b - a));
img := Between('src="', '"', Copy(Page, a, b - a));
if (Name = '') or (img = '') then
Break;
c := PosEx('title=', Page, b);
if (c > 0) then
Members := Between('title="', '"', Copy(Page, c, PosEx('>', Page, c)))
else
Members := '';
if NonMembsOnly then
if (Pos('Members', Members) > 0) then
begin
a := PosEx('<img src="http://itemdb-rs.runescape.com/', Page, b);
b := PosEx('>', Page, a);
Continue;
end;
ID := Between('id=', '"', Copy(Page, a, b - a));
img := GetPage(img);
if (img <> '') then
begin
f := RewriteFile(AppPath + 'tmp.gif', False);
if (f >= 0) then
begin
WriteFileString(f, img);
CloseFile(f);
ProcessPic;
end
else
Break;
//WriteLn(FixName(Name)+' ('+ID+')');
end;
a := PosEx('<img src="http://itemdb-rs.runescape.com/', Page, b);
b := PosEx('>', Page, a);
end;
end;
end;
end.

Use the above to get the values.
The following can be used to find the item:


program New;

Function InvBox(i :Integer): TBox;
var
row, col: Integer;

begin
if (i < 1) or (i > 28) then
begin
// srl_Warn('InvBox', 'Incorrect index: ' + IntToStr(i), warn_AllVersions);
exit;
end;
row :=i mod 4; if row = 0 then row := 4;
col := i / 4 ; if i mod 4 <> 0 then Inc(col);
Result.x1 := 518 + (row * 42); // First X coord - 42 - 5 for proper Tbox
Result.y1 := 172 + (col * 36); // First Y coord - 36 - 5 for proper Tbox
Result.x2 := 560 + (row * 42);
Result.y2 := 210 + (col * 36);
end;

Function BankIndexToMSPoint(Index: Integer): TPoint;

Begin
Index := Index - 1;
Result := Point(38 + (Index Mod 10) * 44, 90 + Floor(Index Div 10) * 45);
End;

Function BankIndexToMSBox(Index: Integer): TBox;

Var
P: TPoint;
Begin
P := BankIndexToMSPoint(Index);
Result.X1 := P.X;
Result.Y1 := P.Y;
Result.X2 := Result.X1 + 31;
Result.Y2 := Result.Y1 + 32;
End;

type
TInvItem = record
OutLine, Width, ColDif, Color: Integer;
MinPoint, MaxPoint: TPoint;
end;

function InvItem(cOutLine, cWidth, cColDif: Integer; cMinPoint, cMaxPoint: TPoint; cColor: Integer): TInvItem;
begin
with Result do
begin
OutLine := cOutLine;
Width := cWidth;
ColDif := cColDif;
MinPoint := cMinPoint;
MaxPoint := cMaxPoint;
Color := cColor;
end;
end;

function FindInvItem(var Box: TBox; Item: TInvItem; Tolerance: Integer): Boolean;
var
i, k, mn, mx, m,
r1, g1, b1,
r2, g2, b2: Integer;
p: TPointArray;
c: TIntegerArray;
b: TBox;
begin
Result := False;
FindColorsTolerance(p, 65536, Box.x1, Box.y1, Box.x2, Box.y2, 0);
b := GetTPABounds(p);
Box := b;
b.y1 := Max(b.y2 - 20, b.y1);
Swap(b.x1, b.x2);
mn := b.x1;
mx := b.x2;
m := Max(b.y1 + 3, b.y2 - 10);
for i := 0 to High(p) do
if (p[i].y > b.y1) then
begin
Inc(k);
if (p[i].x < b.x1) then
b.x1 := p[i].x
else if (p[i].x > b.x1) then
b.x2 := p[i].x;
if (p[i].y = m) then
if (p[i].x < mn) then
mn := p[i].x
else if (p[i].x > mx) then
mx := p[i].x;
end;
if (k <> Item.OutLine) or ((b.x2 - b.x1) <> Item.Width) then
Exit;
FindColorsTolerance(p, clWhite, mn, m, mx, m, 441);
c := GetColors(p);
ClearSameIntegersAndTPA(c, p);
mn := 0;
mx := 0;
for i := 1 to High(c) do
if (c[i] < c[mn]) then
mn := i
else if (c[i] > c[mx]) then
mx := i;
if (Item.ColDif > -1) then
begin
if (Length(c) = 0) then Exit;
if ((p[mn].x - b.x1) <> Item.MinPoint.x) or ((b.y2 - p[mn].y) <> Item.MinPoint.y) then Exit;
if ((p[mx].x - b.x1) <> Item.MaxPoint.x) or ((b.y2 - p[mx].y) <> Item.MaxPoint.y) then Exit;
ColorToRGB(c[mn], r1, g1, b1);
ColorToRGB(c[mx], r2, g2, b2);
//Writeln(IntToStr(iAbs(Item.ColDif - (iAbs(r1 - r2) + iAbs(g1 - g2) + iAbs(b1 - b2) / 3))));
if (iAbs(Item.ColDif - (iAbs(r1 - r2) + iAbs(g1 - g2) + iAbs(b1 - b2) / 3)) > 35) then Exit;
end;
if (Item.Color > -1) then
if (not FindColorTolerance(mn, mx, Item.Color, Box.x1, Box.y1, Box.x2, Box.y2, Tolerance)) then Exit;
Result := True;
end;

var
a: TBox;
b: TInvItem;
i, t: Integer;
begin
t := GetTickCount;
b := InvItem(49, 17, 120, Point(1, 10), Point(15, 10), -1);
for i := 1 to 28 do
begin
a := InvBox(i);
WriteLn('Inv('+IntToStr(i)+'): '+BoolToStr(FindInvItem(a, b, 10)));
end;
for i := 1 to 40 do
begin
a := BankIndexToMSBox(i);
WriteLn('Bank('+IntToStr(i)+'): '+BoolToStr(FindInvItem(a, b, 10)));
end;
WriteLn(IntToStr(GetTickCount - t));
end.

You can change the item on line 124. This should also work with stacks. For things that look a lot like each other (adam g and adam t full helm) there should be added an extra color.


Adam_full_helm_g := InvItem(50, 10, 136, Point(14, 10), Point(5, 10), -1); //Adam full helm(g)
Adam_full_helm_t := InvItem(50, 10, 136, Point(14, 10), Point(5, 10), -1); //Adam full helm (t)

So the -1 at the end would become a unique color for that item.

EDIT:
Added the output of the first script as .rar file. It contains all the images of f2p tradeable items and it contains a list of all the InvItems you can use with the second script.

ZephyrsFury

2008-10-05 09:43:54

From: Santa_Clause
Ehh, this may just become too messy and hard to handle if it's a community project.


We just need one system then everyone can help get the data for the item.

Tniffoc

2008-10-05 09:57:37

From: ZephyrsFury
We just need one system then everyone can help get the data for the item.


You mean like SRL-Stats?

mixster

2008-10-05 10:13:44

Nielsie: Nice, now you just have to change the .gif's to .bmp as I don't think Scar can open gif's :)
May be able to do it through TPicture, but not sure since it seems to be different in Scar than Delphi, so quite hard to get it working. A plugin would work great though using a Delphi Open Source Gif handler.

nielsie95

2008-10-05 10:21:35

It already works (using loadbitmap)…

Wizzup?

2008-10-05 11:06:26

I already quite some this code ready. Maybe we should settle on what we will exactly make first, then make code? :)

Also, I don't think we should make everything "Auto-Get_It_All", as it in some cases simply won't work as good as the human eyes and mind. :)

Tniffoc

2008-10-05 12:49:53

From: Wizzup?
I already quite some this code ready. Maybe we should settle on what we will exactly make first, then make code? :)

Also, I don't think we should make everything "Auto-Get_It_All", as it in some cases simply won't work as good as the human eyes and mind. :)


I think that we'll still be using our minds because we still have to
  • Solve Randoms
  • Develop Failsafes

tank phobia

2008-10-05 17:28:52

From: mixster
Nielsie: Nice, now you just have to change the .gif's to .bmp as I don't think Scar can open gif's :)
May be able to do it through TPicture, but not sure since it seems to be different in Scar than Delphi, so quite hard to get it working. A plugin would work great though using a Delphi Open Source Gif handler.


This could easily be done.

Niesli your idea of using the ge would work fantastically! That would mean this database could be brought up to date 100x quicker than I thought and when new items are brought out it would be a breeze to add them to the database!

Da 0wner

2008-10-05 19:07:20

We could create something that would be like this. You create a site that you will be able to upload text files with the DTMs in the file. Then you can create a get dtm function like this.


function GetDTM(var DTM : integer; Name : string) : boolean;
begin
DTM := StrToInt(GetPage('http://www.SRL-Forums.com/DTMDB/' + Lowercase(Name) + '.txt'));
Result := True;
If IntToStr(DTM) = '' then Result := False;
end;
Now of course that is a very crude function but if we actually made this I could help with the function. But I can see this in the future because I believe it can be made.

mastaraymond

2008-10-06 08:21:10

From: Da 0wner
We could create something that would be like this. You create a site that you will be able to upload text files with the DTMs in the file. Then you can create a get dtm function like this.


function GetDTM(var DTM : integer; Name : string) : boolean;
begin
DTM := StrToInt(GetPage('http://www.SRL-Forums.com/DTMDB/' + Lowercase(Name) + '.txt'));
Result := True;
If IntToStr(DTM) = '' then Result := False;
end;
Now of course that is a very crude function but if we actually made this I could help with the function. But I can see this in the future because I believe it can be made.

Then the bandwidth of SRL would increase rapidly..

Narcle

2008-10-06 10:26:26

Better to just throw all the Items into a .scar file with a name attached to em. Probably could make a neat section for the TPA Items list.

tank phobia

2008-10-06 16:07:04

I never intended for this script to be a database that scripts would fetch DTMs etc from, I mean for script writers they could come online and grab they DTMs they need then add them to their script, but as Narcle says it could be a big scar file too, personally I would prefer an online version as it would be updated more often and easier to navigate through as with DTMs there could be thousands if people start making them from road sections etc.

Narcle

2008-10-06 17:27:13

From: tank phobia
I never intended for this script to be a database that scripts would fetch DTMs etc from, I mean for script writers they could come online and grab they DTMs they need then add them to their script, but as Narcle says it could be a big scar file too, personally I would prefer an online version as it would be updated more often and easier to navigate through as with DTMs there could be thousands if people start making them from road sections etc.


"TPA Item" Section.

So you can add new items to ur ItemsTPA.scar (example name) to use.


But as I was asking Wizzup about trying to push for this. If a good system comes out then it probably will be pushed.

Updating
Recording
Using
Versatility