Brandon
2012-06-29 22:29:35
So I've been trying to develop some new item finding system for some time now. I thought well since I have enough knowledge now, I can succeed but now I'm failing AGAIN!
It keeps saying nothing found but if I debug the bitmap they look the EXACT SAME! I don't know what's wrong or why.. I went through all of the code line by line with a ton of debugging.
If anyone has any idea why it doesn't work let me know plox. Don't tell me it's because it's GIF's.. I looked into Simba's code and it can load it just fine as it only iterates through RGB and ignores Alpha values (Sets to Black).
It keeps saying nothing found but if I debug the bitmap they look the EXACT SAME! I don't know what's wrong or why.. I went through all of the code line by line with a ton of debugging.
If anyone has any idea why it doesn't work let me know plox. Don't tell me it's because it's GIF's.. I looked into Simba's code and it can load it just fine as it only iterates through RGB and ignores Alpha values (Sets to Black).
program ImageProc;
{$DEFINE SMART}
{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/PaintSmart.Simba}
type ItemClass = Record
ItemName: String;
ItemID: Integer;
end;
type ItemArray = Array of ItemClass;
var
Runes: TIntegerArray;
AllItems: ItemArray;
Procedure GetItem(ItemID: Integer; LocationToSaveTo: String; ItemName: String; Extension: String);
var
Image, Path: string;
FP: Integer;
begin
Image:= GetPage('http://services.runescape.com/m=itemdb_rs/3773_obj_sprite.gif?id=' + ToStr(ItemID));
Path:= Trim(LocationToSaveTo + '.' + ToStr(Extension));
FP:= CreateFile(Path);
WriteFileString(FP, Image);
CloseFile(FP);
end;
Function GetItemByID(ItemID: Integer; ItemName: String): Integer;
var
Path: String;
Item: Integer;
begin
Path:= ScriptPath + 'GeItems\' + ItemName;
If (Not FileExists(Path + '.GIF')) then
begin
if (Not DirectoryExists(ScriptPath + 'GeItems')) then
CreateDirectory(ScriptPath + 'GeItems');
GetItem(ItemId, Path, ItemName, 'GIF'); //Downloads the Image in any format!
end;
Item:= LoadBitmap(Path + '.GIF');
Result:= CopyBitmap(Item);
FreeBitmap(Item);
end;
Procedure GetAllItems;
var
I: Integer;
begin
SetLength(Runes, 6);
SetLength(AllItems, 6);
AllItems[0].ItemID := 7936;
AllItems[1].ItemID := 554;
AllItems[2].ItemID := 561;
AllItems[3].ItemID := 556;
AllItems[4].ItemID := 555;
AllItems[5].ItemID := 557;
AllItems[0].ItemName := 'PureEssence';
AllItems[1].ItemName := 'FireRune';
AllItems[2].ItemName := 'NatureRune';
AllItems[3].ItemName := 'AirRune';
AllItems[4].ItemName := 'WaterRune';
AllItems[5].ItemName := 'EarthRune';
For I:= 0 To 5 Do
Runes[I] := GetItemByID(AllItems[I].ItemID, AllItems[I].ItemName);
AddOnTerminate('FreeAllItems');
end;
Procedure FreeAllItems;
var
I, L: Integer;
begin
L:= High(Runes);
For I:= 0 To L Do
FreeBitmap(Runes[I]);
end;
Function FindAllItems(ItemsToFind: TIntegerArray; TPA: TPointArray): TBooleanArray;
var
I, L, X, Y: Integer;
Accuracy: Extended;
begin
SetLength(Result, Length(ItemsToFind));
SetLength(TPA, Length(ItemsToFind));
L:= High(ItemsToFind);
For I:= 0 To L Do
begin
Result[I]:= FindDeformedBitmapToleranceIn(ItemsToFind[I], X, Y, MIX1, MIY1, MIX2, MIY2, 10, 0, False, Accuracy);
//SMART_DRAWBITMAP(True, ItemsToFind[I], Point(250, 250));
TPA[I].X := X;
TPA[I].Y := Y;
end;
end;
var
I: Integer;
TPA: TPointArray;
ItemsFound: TBooleanArray;
Begin
Smart_Server:= 72;
Smart_Members:= True;
Smart_Signed:= True;
Smart_SuperDetail:= False;
SetupSRL;
GetAllItems;
ItemsFound := FindAllItems(Runes, TPA);
Writeln(ItemsFound);
For I:= 0 To High(TPA) Do
If (ItemsFound[I]) Then
begin
MMouse(TPA[I].X, TPA[I].Y, 0, 0);
Wait(1500);
end;
end.