SRL Archive - Research & Development Lounge

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


n3ss3s

2007-10-13 15:50:22

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

2007-10-13 16:48:00

be cool, and explain it line by line and then i can learn somthing from it :)
pls please i beg you!

Timer

2007-10-13 16:57:22

Hmm… Very Nice! :)

nielsie95

2007-10-13 17:38:05


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

2007-10-13 18:13:05

Nice! :) JW, why was SRL down? Was JagSex DOSing us? :rolleyes:

Pancakes

2007-10-13 22:22:30

Probably :p

PwNZoRNooB

2007-10-14 02:35:21

I'll prolly use the fountain finder soon. We'll see.

Rikje

2007-10-14 04:41:11

they look nice :).

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

ShowerThoughts

2007-10-14 04:42:57

man i am still sooooooooooooooooo confused about hsl and rgb and a little bit tpa :s

n3ss3s

2007-10-14 05:13:23

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

2007-10-14 05:50:24

I created a almost identical function, But for a range.

-GJ!

n3ss3s

2007-10-14 05:57:54

Hehe thanks…

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