Log in

View Full Version : Difference between these two functions



Element17
04-17-2012, 10:36 PM
What is the difference? Is one better than the other? These are not my functions and I am just asking the differences and which is better than the other.


Function FindChicken(Var X, Y : Integer): Boolean; //Finds Object
Var
TPA : TPointArray;
ATPA : T2DPointArray;
I, H : Integer;
Begin
FindColorsSpiralTolerance(MSCX, MSCY, TPA, ChickenColor, MSX1, MSY1, MSX2, MSY2, 15);
ATPA := TPAtoATPA(TPA, 25); //25 distance between pixels
If Length(ATPA) = 0 Then //If no points were found
Exit;
H := High(ATPA);
For I := 0 To H Do
Begin
MiddleTPAEx(ATPA[I], X, Y); //Used to get the middle of the current sorted tpa
MMouse(X, Y, 3, 3);
Wait(50 + Random(50));
If IsUpText('hicken') Then
Begin
Writeln('Found chicken!');
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Result := True;
Exit;
End;
End;
End;


Procedure FindStaris; //finds and climbs stairs
Var
MyTPA : TPointArray;
MyPoint : TPoint;
X, Y, i : Integer;

Begin
X := MSCx;
Y := MSCy;
FindColorsSpiralTolerance(x, y, MyTPA, 2961456, MSx1, MSy1, MSx2, MSy2, 10);
If Length(MyTPA) = 0 Then FindColorsSpiralTolerance(X, Y, MyTPA, Color, MSX1, MSY1, MSX2, MSY2, 10);
For i := 0 To High(MyTPA)Do
Begin
MyPoint := MyTPA[i]
MMouse (MyPoint.X, MyPoint.Y, 3, 3);
If (IsUpTextMultiCustom(['tair', 'case'])) Then
Begin
GetMousePos(x, y);
Mouse(X, Y, 0, 0, False);
ChooseOption('limb');
Wait(500+random(250));
Exit;
End;
Wait(350+random(350));
End;
End.

Sin
04-17-2012, 10:37 PM
Neither of them are using CTS2, so basically they're both the same.
Use Color Tolerance Speed 2, for the BEST results.

JuKKa
04-17-2012, 10:44 PM
what "TPAtoATPA(TPA, 25);" does is it makes alot of boxes or 25 pixel circles, from the colors you found. then you loop through them and click the middle of the box/circle.

the second function loops through every single pixel, making it slow an inaccurate if you aren't close to what ur finding.

x[Warrior]x3500
04-17-2012, 10:47 PM
first one is better.

the second one has x,y (which are not used). it also calls "high(ATPA)" way too many times. and it doesnt focus on the middle of the APTA, thus it will always click the top left of the box. - this is because it doesnt use ATPAs ;) for objects, ATPA>TPA

masterBB
04-17-2012, 10:48 PM
The second one tries to find the color(s) and stores the found points in an array. Then it moves the mouse to all those points till it finds a certain uptext. It's slow and not effecient.

The first one also stores the found colors in an array as points. The it tries to make groeps of them by check if some have a certain distance between them. It then moves the mouse to the middle of those groups, and checks for uptext.

I do not agree on Sin his comment. CTS 1 can be as powerfull as CTS 2 in some cases.

Sin
04-17-2012, 10:50 PM
The second one tries to find the color(s) and stores the found points in an array. Then it moves the mouse to all those points till it finds a certain uptext. It's slow and not effecient.

The first one also stores the found colors in an array as points. The it tries to make groeps of them by check if some have a certain distance between them. It then moves the mouse to the middle of those groups, and checks for uptext.

I do not agree on Sin his comment. CTS 1 can be as powerfull as CTS 2 in some cases.

For TPAs?
I disagree, CTS2 is much better from past experience.

masterBB
04-17-2012, 10:55 PM
For TPAs?
I disagree, CTS2 is much better from past experience.

They give different results. Though I'm aware that CTS 2 gives you more control through the hue and mod modifiers. CTS 1 can give equally or even better quality results on some cases. Just depends on the colors.

Also tpas has nothing to do with the cts method you use.

Element17
04-17-2012, 11:45 PM
Thanks for clearing a lot of that up guys. So would this one be better? Again not my function.

Function TPAFinder(var x, y: Integer): Boolean; //We'll use the x and y to return the Mouse's (you got it) x and y coordinates for actual clicking. So far, so good!
Var
CTS, I: Integer; //CTS will store the ColorToleranceSpeed before we change it, for later.
TPA: TPointArray; //The TPointArray in which all Coordinates which are found later will be stored
ATPA: Array of TPointArray;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2); //Sets the color tolerance speed to 2 so we can do HSL tolerance stuff
SetColorSpeed2Modifiers(HueMod, SatMod); //Get from putting 3-5 colors into TPA shit
FindColorsSpiralTolerance(MSCX, MSCY, TPA, YourColorHere, MSX1, MSY1, MSX2, MSY2, Tolerance); //For tolerance, put in your own tolerance. MSCX and MSCY are the starting points in the center of the mainscreen. MSX1, MSY1, etc. are the outside of the Main Screen.
ATPA := TPAToATPAEx(TPA, 15, 15); //Sorts TPAs


For I := 0 To High(ATPA) Do
Begin
MiddleTPAEx(ATPA[i], X, Y); //Returns the middle coords of the current TPA in the ATPA
MMouse(X, Y, 2, 2); //Moves mouse over the object
If(IsUpTextMultiCustom(['your uptext(s) here'])) Then
Begin
Writeln('Found Item');
GetMousePox(x, y);
Mouse(X, Y, 0, 0, False);
Result := True;
Break; //Exits the For To Do statement so it doesn't keep moving around looking for the object
End;
End;
End;