Wreck
2012-07-08 14:59:44
So I was bored and was thinking of an alternative to DTM/Bitmap for inventory item finding and this is what I came up with tell me what you think! :p
Should find food from a different slot every time it is run e.g.
DEBUG: Setting Up Script
DEBUG: Setup Complete
DEBUG: Shark Found - Slot(19) Co-ords(663, 375)
Successfully executed.
program Example;
{$i SRL/srl.Simba}
type
Item = record
Col, Tol: Integer;
Uptext: TStringArray;
Name: String;
end;
var
InvSlots: Array [1..28] of Integer;
Items: Array of Item;
x, y: Integer;
const
FOOD_SHARK = 0;
procedure Debug(s: String);
begin
WriteLn('DEBUG: ' + s);
end;
procedure Setup;
begin;
ClearDebug;
Debug('Setting Up Script');
SetLength(Items, 1);
with Items[0] do //Shark
begin
Col := 5794692;
Tol := 3;
Uptext := ['hark', 'at Shar'];
Name := 'Shark';
end;
Debug('Setup Complete');
end;
procedure InvRandomSlots;
var
i, ii: Integer;
begin
For i := 1 To 28 Do
begin
repeat
ii := RandomRange(1, 29);
until (not InIntArray(InvSlots, ii));
InvSlots[i] := ii;
end;
//For i := 1 To 28 Do
// Debug('InvSlots[' + IntToStr(i) + ']: ' + IntToStr(InvSlots[i]));
end;
function InvFindItem(var fx, fy: Integer; Obj: Item): Boolean;
var
i: Integer;
Box: TBox;
P: TPoint;
begin
For i := 1 To 28 Do
begin
Box := InvBox(InvSlots[i]);
if FindColorTolerance(P.x, P.y, Obj.Col, Box.X1, Box.Y1, Box.X2, Box.Y2, Obj.Tol) then
begin
P := MiddleBox(Box);
MMouse(P.x, P.y, 5, 5);
if WaitUpTextMulti(Obj.Uptext, 250 + RandomRange(100, 250)) then
begin
GetMousePos(fx, fy);
Result := True;
Debug(Obj.Name + ' Found - Slot(' + IntToStr(InvSlots[i]) + ') Co-ords(' + IntToStr(fx) + ', ' + IntToStr(fy) + ')');
Break;
end;
end;
end;
end;
begin
SetupSRL;
ActivateClient;
Setup;
InvRandomSlots;
InvFindItem(x, y, Items[FOOD_SHARK]);
end.Should find food from a different slot every time it is run e.g.
DEBUG: Setting Up Script
DEBUG: Setup Complete
DEBUG: Shark Found - Slot(19) Co-ords(663, 375)
Successfully executed.