PDA

View Full Version : FindDucks - a general duckfinder



n3ss3s
01-23-2008, 02:51 PM
FindDucks - a general duckfinder

This function doesn't work, but does compile, and would be /is really slow.

I posted it so people could learn :)


Function FindDuck(Var Dx, Dy: Integer; Safe: Boolean): Boolean;
Var
CTS, I, L, X, Y, z, II, S, Ll: Integer;
TPAA, ATPA : Array of TPointArray;
TPA, dTPA: TPointArray;
TP: TPoint;
TB: TBox;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 11241076, MSX1, MSY1, MSX2, MSY2, 0);
TPAA := SplitTPAEx(TPA, 1, 1);
SortATPASize(TPAA, True);
If GetArrayLength(TPA) < 1 Then
Exit;
SetArrayLength(TPA, 0);
TPA := TPAA[0];
ATPA := TPAToATPAEx(TPA, 40, 40);
Ll := High(ATPA);
For S := 0 To L Do
Begin
TPA := ATPA[s];
TPAA := FindGapsTPA(TPA, 18);
L := High(TPAA);
For I := 0 To L Do
TPA := CombineTPA(TPA, TPAA[i]);
TB := GetTPABounds(TPA);
TP.x := TB.x2 - TB.x1 shr 1;
TP.y := TB.y2 - TB.y1 shr 1;
SetColorSpeed2Modifiers(0.4, 0.4);
FindColorsSpiralTolerance(TP.x, TP.y, dTPA, 8822696, TB.x1, TB.y1, TB.x2, TB.y2, 15);
SetColorSpeed2Modifiers(0.2, 0.2);
SetArrayLength(TPAA, 0);
TPAA := TPAToATPAEx(dTPA, 15, 15);
L := High(TPAA);
For I := 0 To L Do
Begin
TB := GetTPABounds(TPAA[i]);
TP.x := TB.x2 - TB.x1 shr 1;
TP.y := TB.y2 - TB.y1 shr 1;
SortTPAFrom(dTPA, TP);
SetArrayLength(TPA, 64);
For II := 0 To 63 Do
Try
TPA[ii] := dTPA[i];
z := z + 1;
Except
Break;
End;
SetArrayLength(TPA, z);
If Z > 24 Then
Begin
MiddleTPAEx(TPA, Dx, Dy);
If FindColorTolerance(X, Y, 3229752, Dx - 12, Dy - 12, Dx + 12, Dy + 12, 20) Then
Result := True // Male duck, and also a definite duck.
Else
If Safe Then
Begin
MMouse(Dx, Dy, 2, 2);
If Not IsUpTextMulti('Duck', 'Duc', 'uck') Then
Continue;
End;
Result := Not(FindColor(X, Y, 65280, Dx - 15, Dy - 20, Dx + 15, Dy + 10));
If Result Then
Result := Not(FindColor(X, Y, 255, Dx - 15, Dy - 20, Dx + 15, Dy + 10));
If Result Then
Break;
End;
End;
End;
ColorToleranceSpeed(CTS);
End;

nielsie95
01-23-2008, 02:55 PM
I think you mean
TP.x := TB.x2 + TB.x1 shr 1;
TP.y := TB.y2 + TB.y1 shr 1;
?

And you never reset Z to 0?


Anyway, here's my FindDuck:


function FindDuck(var dx, dy: Integer): Boolean;
var
i, c, l, cts, ms, x, y: Integer;
p, tp: TPointArray;
t: TPointArrayArray;
CheckBars: Boolean;
begin
if not LoggedIn then Exit;
cts := GetColorToleranceSpeed;
ms := MouseSpeed;
MouseSpeed := 18;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, p, 8230813, 15, 30, 510, 330, 15);
FindColorsSpiralTolerance(MSCX, MSCY, tp, 3493436, 15, 30, 510, 330, 15);
ColorToleranceSpeed(cts);
p := CombineTPA(p, tp);
t := SplitTPAEx(p, 3, 3);
SetLength(p, 0);
SetLength(tp, 0);
l := Length(t);
for c := 0 to 1 do
begin
if Result then Break;
case c of
0: CheckBars := True;
1: CheckBars := False;
end;
for i := 0 to l -1 do
if InRange(Length(t[i]), 14, 35) then
begin
MiddleTPAEx(t[i], dx, dy);
if CheckBars then
begin
if (not FindColor(x, y, 65280, dx -15, dy - 30, dx + 15, dy)) then
if (not FindColor(x, y, 255, dx -15, dy - 30, dx + 15, dy)) then
begin
MMouse(dx, dy, 2, 2);
Wait(100 + Random(100));
if IsUpText('Duck') then
begin
Result := True;
GetMousePos(dx, dy);
Break;
end;
end;
end else
begin
MMouse(dx, dy, 2, 2);
Wait(100 + Random(100));
if IsUpText('Duck') then
begin
Result := True;
GetMousePos(dx, dy);
Break;
end;
end;
end;
end;
MouseSpeed := ms;
SetLength(t, 0);
end;

n3ss3s
01-23-2008, 02:58 PM
I didn't post it to be fixed, neither to be rated in any ways x) Thx anyhow

EDIT: Thx, thats what I meant with the shr stuff

Negaal
01-23-2008, 03:00 PM
Lol'ed - FindDuck - General duckfinder...
Anyways, 1 question, what GetTPABounds(); does? And Markus said it's slow, and there should be an alternative method instead this...?

n3ss3s
01-23-2008, 03:04 PM
It gets the x1, y1, x2, y2 of the box formed by the tpa.

Dumpin
01-23-2008, 07:10 PM
FindDuck... ok, whats the use of it? aah Screw it! i learned mroe about PTA's *Cheers at N3ss3s* :D thanks

Santa_Clause
01-23-2008, 10:59 PM
What the heck, N3ss3s? How do you know about all the miscellaneous TPA functions that are in SCAR. How'd you find out about FindGapsTPA?

bullzeye95
01-24-2008, 12:15 AM
What the heck, N3ss3s? How do you know about all the miscellaneous TPA functions that are in SCAR. How'd you find out about FindGapsTPA?

Raymond added it to SRL for (I'm assuming) his new FindTalk. According to him, it shouldn't be used in object finding, also =/

If you really want to be a Master Object Finder (MOJ), you HAVE TO USE Color Speed 2 Modifiers! :p

EDIT: SHIT, I HAVE A PIMPLE ON MY FOREHEAD!

n3ss3s
01-24-2008, 01:21 PM
/tells the girls to run away from bullzeye


According to him, it shouldn't be used in object finding, also =/


Screw that, he is trying to stop creativity :p



How do you know about all the miscellaneous TPA functions that are in SCAR. How'd you find out about FindGapsTPA?

Miscellaneous eh? This is not a miscellaneous link. (http://www.srl-forums.com/srl-repos/place%20inside%20plugins%20folder/WizzyPlugin.dpr)