SRL Archive - SRL Archives

Seriously, the LAST obj finder post, a general finder..


n3ss3s

2007-10-18 13:34:21

I apologise for all the object finders with the same template, but I had bday and I drank 1,5 litr of pommac, 1 litr of coke, ate 1/2 chocolate cake, 2 packets of cookies, and too much candy - in less than 24 hours which gives damn hyperactivity (King of Knives and Zeph know about the side effects I told them bout xD) - so if the threads pissed anyone of I can delete them all, but now this is my last object finder post and I promise not to make one atleast in 5 months, only update this one.

I made a general object finder called iSpyWithMyLittleEye.

iSpyWithMyLittleEye(ObjColors: TIntegerArray; ObjWidth, ObjHeight: Integer): TPointArray;

ObjColors are couple colors from the obj for example "[blabla, lablab, ballab]"
ObjWidth and ObjHeight are the size of the object.

This finds all instances of the object on the screen, tested on cabbage field, trees, and the pinball random, I suggest not using on monsters because they move and then you would just get bunch of useless points.

Soooo -


Function iSpyWithMyLittleEye(ObjColors: TIntegerArray; ObjWidth, ObjHeight: Integer): TPointArray;
Var
TPAA: Array of TPointArray;
Var
CTS, I, C, D, T: Integer;
Var
TPA, TPA2: TPointArray;
Var
FinalTPA: TPointArray;
Var
TP: TPoint;
Var
TB: TBox;
Begin
T := GetSystemTime;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, ObjColors[0], 20, 20, MSX2 - 20, MSY2 - 20, 10);
TPAA := TPAToATPAEx(TPA, ObjWidth, ObjHeight);
SetArrayLength(TPA, Length(TPAA));
For I := 0 To GetArrayLength(TPAA) - 1 Do
Begin
TPA[i] := MiddleTPA(TPAA[i]);
End;
SetArrayLength(TPAA, 0);
If(Not(GetArrayLength(TPA) <= 0))Then
Begin
SetArrayLength(TPAA, GetArrayLength(ObjColors));
For I := 0 To GetArrayLength(TPA) - 1 Do
Begin
TP := TPA[i];
TB.x1 := TP.x - ObjWidth;
TB.y1 := TP.y - ObjHeight;
TB.x2 := TP.x + ObjWidth;
TB.y2 := TP.y + ObjHeight;
For C := 0 To GetArrayLength(ObjColors) - 1 Do
Begin
FindColorsTolerance(TPA2, ObjColors[c], TB.x1, TB.y1, TB.x2, TB.y2, 10);
TPAA[c] := CombineTPA(TPA2, TPAA[c]);
End;
For D := 0 To GetArrayLength(TPAA) - 1 Do
Begin
FinalTPA := CombineTPA(FinalTPA, TPAA[d]);
End;
End;
Result := ReArrangeandShortenArrayEx(FinalTPA, ObjWidth, ObjHeight);
End;
Writeln(IntToStr(GetSystemTime - T));
ColorToleranceSpeed(CTS);
End;

@ Wizzy: RAaSTPA and ReArrangeandShortenArray have bugs, they dont do anything =/ had to use TPAToATPA and then MiddleTPA.



~thanks.


Sorry.

Rikje

2007-10-18 14:01:05

hurrey for you're last thread j/k :p

i looks nice :)


FindColorsSpiralTolerance(MSCX, MSCY, TPA, ObjColors[0], 20, 20, MSX2 - 20, MSY2 - 20, 10);

MSCX , MSCY start point?
TPA = the pleace where he stores the colors?
10 = Tol? :).
sorry for the qeustion, but i was looking for a function like this, but didn't found him. **shame on me**

n3ss3s

2007-10-18 14:02:48

Correct!

Welcome to the wonderful world of FindColorsSpiralTolerance ;)

*text in the other side of the manual - "DO NOT use while affected by sugar"* :D :D :D

Wizzup?

2007-10-18 14:08:19

What bugs, how did you use them?

n3ss3s

2007-10-18 14:15:38

I did "TPA := ReArrangeAndShortenArrayEx(TPA, TheX, TheY);"

It returns the rearranged tpa so I think its supposed to be used like this, atleast CombineTPA etc is…

Same with RAaSTPAEx but anyways WizzyPlugin is great job and its good I can do same thing with TPAToATPA and for loop + MiddleTPA :)

R0b0t1

2007-10-18 19:16:53

Scientists proved you can't get high on sugar, and that it takes a while for the buzz to start…

But anyway, could you comment teh codEz? I would like to learnZ.

munk

2007-10-18 20:28:00

From: n3ss3s
I did "TPA := ReArrangeAndShortenArrayEx(TPA, TheX, TheY);"

It returns the rearranged tpa so I think its supposed to be used like this, atleast CombineTPA etc is…

Same with RAaSTPAEx but anyways WizzyPlugin is great job and its good I can do same thing with TPAToATPA and for loop + MiddleTPA :)


They both work for me :/ Id say try getting rid of the assignment and just make it
ReArrangeAndShortenArrayEx(TPA, TheX, TheY);
worth a shot:D

oh yeah, and if your a speed junky, use a variable for length instead of
For I := 0 To GetArrayLength(TPAA) - 1 Do
that has to call getarraylength however many times. Adds a few ms.

just some little things. Other than that it looks sharp.

King of Knives

2007-10-18 20:34:38

Finally the last one, n3s. Promise me that you cut off your internet, and delete SCAR next time you're on a sugar rush.

Robot: Scientists prove you can't get high on sugar, but n3s (and his scripts) prove you can.

-Knives

n3ss3s

2007-10-19 02:56:09

@munk: yes, but making the var takes mouse movement of about 50 pixels and 3 button presses :D Painful

One commented version coming right on…


Function iSpyWithMyLittleEye(ObjColors: TIntegerArray; ObjWidth, ObjHeight: Integer): TPointArray;
Var
TPAA: Array of TPointArray;
Var
CTS, I, C, D, T: Integer;
Var
TPA, TPA2: TPointArray;
Var
FinalTPA: TPointArray;
Var
TP: TPoint;
Var
TB: TBox;
Begin
T := GetSystemTime; // Gets the system time
CTS := GetColorToleranceSpeed; // Saves the current color tolerance speed.
ColorToleranceSpeed(2); // Sets color comparison to hue, dear colormaster ;)
FindColorsSpiralTolerance(MSCX, MSCY, TPA, ObjColors[0], 20, 20, MSX2 - 20, MSY2 - 20, 10);
// ^^ Finds all instances of ObjColors[0] spiraling out from mainscreen center.
TPAA := TPAToATPAEx(TPA, ObjWidth, ObjHeight);
// Sorts the TPA to array of TPA's so that every "area" has their own TPA
SetArrayLength(TPA, Length(TPAA));
// Sets our TPA length to length of TPAA
For I := 0 To GetArrayLength(TPAA) - 1 Do
Begin
TPA[i] := MiddleTPA(TPAA[i]);
End;
// ^^ Gets the middle of every TPA in TPAA and saves to TPA.
SetArrayLength(TPAA, 0); // <-- "nulls" the TPAA cuz we are gonna re-use it. Dont know if necassary.
If(Not(GetArrayLength(TPA) <= 0))Then
Begin
SetArrayLength(TPAA, GetArrayLength(ObjColors));
For I := 0 To GetArrayLength(TPA) - 1 Do
Begin
TP := TPA[i];
TB.x1 := TP.x - ObjWidth;
TB.y1 := TP.y - ObjHeight;
TB.x2 := TP.x + ObjWidth;
TB.y2 := TP.y + ObjHeight; // Creates a TBox around the current point in the loop.
For C := 0 To GetArrayLength(ObjColors) - 1 Do
Begin
FindColorsTolerance(TPA2, ObjColors[c], TB.x1, TB.y1, TB.x2, TB.y2, 10);
TPAA[c] := CombineTPA(TPA2, TPAA[c]);
// Finds all the obj colors in the TBox
// Adds the points to its own TPA in TPAA
End;
For D := 0 To GetArrayLength(TPAA) - 1 Do
Begin
FinalTPA := CombineTPA(FinalTPA, TPAA[d]);
// Combines TPAA to one TPA
End;
End;
Result := ReArrangeandShortenArrayEx(FinalTPA, ObjWidth, ObjHeight);
// Creates the points of objects like one point per one obj etc..
End;
Writeln(IntToStr(GetSystemTime - T)); // Writelns the time it took
ColorToleranceSpeed(CTS); // Sets color tolerance comparison back to normal..
End; // This is where the function ends :D :D :D

Uhm, yeah gotta admit its just too leet for some minds to comprehend (Jk/Jk) :p

ShowerThoughts

2007-10-20 07:01:21

nice work, thanks for commenting, still dont get it fully :(

n3ss3s

2007-10-20 09:20:46

You need to also read some tuts, Tuts for advanced you go..

R0b0t1

2007-10-20 12:41:02

Ahh.. Thanks N3ss3s. You should learn to use whitespace between key areas. Thats why I couldn't get it :p.

n3ss3s

2007-10-20 12:49:14

The less you get it the leet it looks ;)

But usually when I do whitespace I get on a whitespacing spree, though seen them a lot in other ppls functions so I guess I should try…

Though I wanna keep longer functions together..