tank phobia
2008-10-04 02:15:18
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.
2008-10-04 02:15:18
2008-10-04 02:23:51
2008-10-04 02:42:26
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.
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.
2008-10-04 03:15:40
2008-10-04 03:34:40
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.
From: Santa_Clause
There's already a bitmap database as part of the SRL include…
2008-10-04 06:24:10
2008-10-04 07:59:58
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?
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?
2008-10-04 09:50:00
2008-10-04 10:20:49
From: ZephyrsFury
Whats faster? Comparing colour count and colours at certain points or using a DTM?
2008-10-04 10:28:23
2008-10-04 10:28:45
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;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?
2008-10-04 11:23:42
From: nielsie95
What about runes or other common stacks?
2008-10-04 11:34:45
2008-10-04 12:04:27
2008-10-04 12:16:09
2008-10-04 14:31:22
From: nielsie95
What about runes or other common stacks?
2008-10-04 14:35:58
2008-10-04 17:40:46
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 .
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.
2008-10-05 02:07:00
From: Wizzup?
And what about the item's total pixel count?
2008-10-05 03:37:13
From: bullzeye95
How would you go about doing that?
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…
2008-10-05 03:56:44
2008-10-05 06:27:08
From: bullzeye95
How would you go about doing that?
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 :))
2008-10-05 06:49:25
2008-10-05 07:54:33
2008-10-05 07:57:10
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.
2008-10-05 08:47:50
2008-10-05 08:49:36
2008-10-05 09:07:15
2008-10-05 09:07:55
2008-10-05 09:08:55
From: nielsie95
We can get the pictures from the GE site :)
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=', '&', 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.
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.
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)
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.
2008-10-05 09:57:37
From: ZephyrsFury
We just need one system then everyone can help get the data for the item.
2008-10-05 10:13:44
2008-10-05 10:21:35
2008-10-05 11:06:26
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. :)
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.
2008-10-05 19:07:20
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.
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.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.
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;
2008-10-06 10:26:26
2008-10-06 16:07:04
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.