SRL Archive - SRL Archives

FindObjCustom


Harry

2008-04-06 21:32:24

I liked it better the old way. Now it doesn't work as well. I had to even include the SRL 14 version of it into my caver because the new on in rev 15 fails for finding the cave entrance. Weird. :confused: So why? And I think it should be reverted back to the old way.

Starblaster100

2008-04-07 17:54:16

It works perfectly for me.

Using the right colors, with the right tols?

Want to check through the code and see if you can point out any mistakes / improve on it?

Harry

2008-04-08 15:56:32

No idea why it fails - it just never moves the mouse, and the colors and tols are correct. It just Results False and doesn't move the mouse. :confused: Sorry, I don't have any more input on it.

Bobarkinator

2008-04-08 16:29:30

Debug it? With your specific colors and tols.

Starblaster100

2008-04-08 18:02:00

Works perfectly for everyone else I have asked.

Harry

2008-04-08 18:08:18

Try this on a willow tree.


function RandomWillowColor: integer;
begin
if not(LoggedIn) then
Exit;
Status('Picking Random Willow Tree Color.');
case Random(5) of
0: Result := 3693410;
1: Result := 2655089;
2: Result := 2315338;
3: Result := 2579794;
4: Result := 2967888;
end;
end;

if FindObjCustom(tx, ty, ['illow'], [RandomWillowColor], 4) then
WriteLn('Yay.');
and it 99% chance it will fail.

Now try this.


function FindObjCustom2(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray; Tolerance: Integer): Boolean;
var
a, b, c, i, x1, y1, x2, y2: Integer;
Start: Boolean;
begin
for b := 0 to (GetArrayLength(Color)-1) do
begin
if (FindColorSpiralTolerance(cx, cy, color[b], MSX1, MSY1, MSX2, MSY2, Tolerance)) then
begin
Start := True;
Break;
end;
end;
if(Start)then
begin
x1 := 245;
y1 := 165;
x2 := 277;
y2 := 185;
repeat
if not(LoggedIn)then break;
a := a + 1;
if (a = 1) then
c := c + 1
else if (a = 3) then
c := c + 1;
for i := 1 to c do
begin
if (a = 1) then
begin
x1 := x1 + 30;
x2 := x2 + 30;
end else
if (a = 2) then
begin
y1 := y1 - 20;
y2 := y2 - 20;
end else
if (a = 3) then
begin
x1 := x1 - 30;
x2 := x2 - 30;
end else
if (a = 4) then
begin
y1 := y1 + 20;
y2 := y2 + 20;
end;
if (x1 = 485) and (x2 = 517) then
x2 := x2 - 2;
if (y1 = 325) and (y2 = 345) then
y2 := y2 - 7;
if (x2 > 515) then
Break;
for b := 0 to (GetArrayLength(Color)-1) do
begin
if (FindColorTolerance(cx, cy, Color[b], x1, y1, x2, y2, tolerance)) then
begin
MMouse(cx, cy, 3, 3);
Wait(5+Random(10));
if (IsUpTextMultiCustom(Text)) then
begin
Result := True;
Exit;
end;
end;
end;
end;
if (a = 4) then
a := 0;
until (x2 > 515) or (Result = True);
end;
end;


function RandomWillowColor: integer;
begin
if not(LoggedIn) then
Exit;
Status('Picking Random Willow Tree Color.');
case Random(5) of
0: Result := 3693410;
1: Result := 2655089;
2: Result := 2315338;
3: Result := 2579794;
4: Result := 2967888;
end;
end;

if FindObjCustom2(tx, ty, ['illow'], [RandomWillowColor], 4) then
WriteLn('Yay.');

The first usually does not work, the second one usually does work. :confused:

n3ss3s

2008-04-10 07:56:41

So you refuse to use the piece of code I posted to your thread that uses FindObjTPA with good working params, you don't have to credit for that or anything if that's the problem, because if you seriously want to find it on the first move, use the FindObjTPA thing.

Harry

2008-04-10 13:09:32

From: n3ss3s
So you refuse to use the piece of code I posted to your thread that uses FindObjTPA with good working params, you don't have to credit for that or anything if that's the problem, because if you seriously want to find it on the first move, use the FindObjTPA thing.


Please post it here? I am not ready to dig through 109+ pages on that thread. :p

Starblaster100

2008-04-10 14:37:29

Actually you may be right about th new FindObj, we'll check into it

Harry

2008-04-10 19:21:00

From: Starblaster100
Actually you may be right about th new FindObj, we'll check into it


Yay, I discovered a bug. :p

@n3ss3s, I found it, and it is uber l33t. Thanks dude. Next version will have it. :)

Daniel

2008-04-15 21:23:33

FindObj seems to work for me, but i use FindObjEx and set my own parametres. But after using FindObjCustom it still works good. Don't see what the problem is.