PDA

View Full Version : While SRL down I made 2 functions just to post em :)



n3ss3s
10-13-2007, 07:50 PM
Yeah, SRL was down about half an hour (?), and I was bored since I wasnt able to view threads, so I made two finding functions.

1. FastFindAnvil - Finds anvil in ~78 milliseconds.
2. FastFindVarrockFountain - Finds fountain in ~30 milliseconds.

Anvil finder is good for smithing scripts and fountain one for clay softeners etc.

Both pretty simple, both work even better.


Function FastFindAnvil(Var Ax, Ay: Integer): Boolean;
Var
TPA, TPA2: TPointArray;
Var
I, CTS, M: Integer;
Var
TP: TPoint;
Begin
If(Not(LoggedIn))Then Exit;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
M := GetSystemTime;
FindColorsTolerance(TPA2, 5987683, MSX1, MSY1, MSX2, MSY2, 10);
For I := 0 To GetArrayLength(TPA2) - 1 Do
Begin
TP := TPA2[i];
FindColorsTolerance(TPA, 5987683, TP.x - 15, TP.y - 15, TP.x + 15, TP.y + 15, 10);
If(GetArrayLength(TPA) >= 20)Then
Begin
TP := MiddleTPA(TPA);
Result := True;
Ax := TP.x;
Ay := TP.y;
Break;
End;
End;
ColorToleranceSpeed(CTS);
Writeln('Found anvil in '+IntToStr(GetSystemTime - M));
End;
End;

Function FastFindVarrockFountain(Var Fx, Fy: Integer): Boolean;
Var
X, Y, I, C, CTS, M: Integer;
Var
TPA: TPointArray;
Var
TP: TPoint;
Begin
If(Not(LoggedIn))Then Exit;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
M := GetSystemTime;
FindColorTolerance(X, Y, 9405792, MSX1, MSY1, MSX2, MSY2, 10);
FindColorsTolerance(TPA, 9405792, X - 20, Y - 20, X + 20, Y + 20, 10);
If(Not(GetArrayLength(TPA) >= 100))Then Exit;
Begin
TP := MiddleTPA(TPA);
Fx := TP.x;
Fy := TP.y;
Result := True;
End;
ColorToleranceSpeed(CTS);
Writeln('Found fountain in '+IntToStr(GetSystemTime - M));
End;
End;


Enjoy ;)

You are free to use them, but only if you credit me.

ShowerThoughts
10-13-2007, 08:48 PM
be cool, and explain it line by line and then i can learn somthing from it :)
pls please i beg you!

Timer
10-13-2007, 08:57 PM
Hmm... Very Nice! :)

nielsie95
10-13-2007, 09:38 PM
TP := MiddleTPA(TPA);
Result := True;
Ax := TP.x;
Ay := TP.y;


>>


Result := MiddleTPAEx(TPA, Ax, Ay);


And do you actually try if CTS 2 is the best comparision method, or do you just hope it's better? :p

Harry
10-13-2007, 10:13 PM
Nice! :) JW, why was SRL down? Was JagSex DOSing us? :rolleyes:

Pancakes
10-14-2007, 02:22 AM
Probably :p

PwNZoRNooB
10-14-2007, 06:35 AM
I'll prolly use the fountain finder soon. We'll see.

Rikje
10-14-2007, 08:41 AM
they look nice :).

while reading that i learned a little but more about TPA etc. thank you :).

ShowerThoughts
10-14-2007, 08:42 AM
man i am still sooooooooooooooooo confused about hsl and rgb and a little bit tpa :s

n3ss3s
10-14-2007, 09:13 AM
And do you actually try if CTS 2 is the best comparision method, or do you just hope it's better? None, I KNOW that it is better ;)

JuKKa
10-14-2007, 09:50 AM
I created a almost identical function, But for a range.

-GJ!

n3ss3s
10-14-2007, 09:57 AM
Hehe thanks...

Btw, Smithing.scar doesnt have an Anvil finder - *pick mine, pick mine :p *