SRL Archive - Research & Development Lounge

FastFindMonster by n3ss3s


n3ss3s

2007-10-18 08:32:30

This time we find any monster, found hair dresser in 15ms..

MainC = maincolor of the monster, hair dresser's would be pink, then colors, fill there like [onecolor, second, etc] and Mx and My are the ones the coords return to if results true.


Function FastFindMonster(MainC: Integer; Colors: TIntegerArray; Var Mx, My: Integer): Boolean;
Var
I, C, CTS, L, X, Y, T: Integer;
Var
TPAA: TPointArrayArray;
Var
FinalTPA: TPointArray;
Begin
T := GetSystemTime;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
L := GetArrayLength(Colors);
SetArrayLength(TPAA, L);
If(FindColorTolerance(X, Y, MainC, MSX1, MSY1, MSX2, MSY2, 10))Then
begin
For I := 0 To L - 1 Do
Begin
FindColorsTolerance(TPAA[i], Colors[i], X - 15, Y - 15, X + 15, Y + 15, 10);
If(GetArrayLength(TPAA[i]) <= 0)Then
Begin
ColorToleranceSpeed(CTS);
Exit;
End;
End;
SetArrayLength(FinalTPA, L);
For C := 0 To L - 1 Do
Begin
FinalTPA[c] := MiddleTPA(TPAA[c]);
End;
MiddleTPAEx(FinalTPA, Mx, My);
Result := True;
End;
Writeln(IntToStr(GetSystemTime - T));
ColorToleranceSpeed(CTS);
End;

As usual free to use if credits to me..

mat_de_b

2007-10-18 12:05:41

Looks interesting! no use of uptext? <- important for monsters surely? and does this return the closet one to you?

n3ss3s

2007-10-18 12:58:49

The uptext is not needed, though if there are many monsters with same like colors, then you can add…

To return the closest one just add "SortTPAFrom…"

Metagen

2007-10-22 08:55:21

Looks very nice… if i ever need to find monsters ill be sure to use this (if it tests out well 4 me)

and be sure to credit you of course :p (wait am i allowed?)

n3ss3s

2007-10-22 10:55:02

Yes, you can use as long as I get the credit for it.

R0b0t1

2007-10-25 14:55:05

I'll whoop you with the plugin I'm making, N3ss3s. Just wait…


Remember? I swore to kick your ass :p.


P.S.: Yours is pretty good though, I like the 1337ne55. But remember what I said about whitespace?

EvilChicken!

2007-10-25 15:12:00

15ms, amazing. Could be used in pc scripts (where speed counts a lot).

But, yeah wtf no uptext?

But then again, wouldnt uptext slow it down a bit?:duh:

mastaraymond

2007-10-25 15:38:08

From: R0b0t1
I'll whoop you with the plugin I'm making, N3ss3s. Just wait…


Remember? I swore to kick your ass :p.


P.S.: Yours is pretty good though, I like the 1337ne55. But remember what I said about whitespace?

Plugin.. Plugin.. You can't compare Plugins with SCAR.. Plugins are way to fast.. Where SCAR takes seconds, plugin can do it in 6ms..

bullzeye95

2007-10-25 15:53:27

N3ss3s, CTS 2 isn't always the best. Sometimes it's the worst. I think you should either have the CTS as a parameter, or make it CTS 1, since that's usually in the middle: almost never best, almost never worst.

n3ss3s

2007-10-26 03:20:40

Bullzeye ofcourse I test it with the diff cts, though thanks..
Rofl @ your sig :D


Remember? I swore to kick your ass .
Lets agree with raymond, kick my ass in SCAR oke kid? :p :p :p

EDIT: Dw r0b0t, my next obj finder has white spaces ;)