Net4Hack Posted April 14, 2014 Share Posted April 14, 2014 So for example, we have color green and yellow, i want to make my script that search the closest yellow point by the green. Can someone help me cause i really don't know how to begin for that. Quote Link to comment Share on other sites More sharing options...
Net4Hack Posted April 14, 2014 Author Share Posted April 14, 2014 Pleas Help thx Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted April 15, 2014 Share Posted April 15, 2014 As always a picture is worth a thousand words. Based on your description we only have a vague idea of what you are trying to do. Quote Link to comment Share on other sites More sharing options...
Net4Hack Posted April 15, 2014 Author Share Posted April 15, 2014 So let's say in x1,y1,x2,y2 you have a green point and sometime yellow's. The code need's to do like this : - If find yellow point, click to the yellow point that is the closest to the green point. Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted April 16, 2014 Share Posted April 16, 2014 Picture please. There are too many variations such as: - Is the green all in one spot? Or groups of green and we need to find largest? - Does the color vary or is always exactly the same color each time? - Same questions for yellow. And so on. If you are going to ask for help at least give us something to go on. Quote Link to comment Share on other sites More sharing options...
Net4Hack Posted April 17, 2014 Author Share Posted April 17, 2014 See that ^^. But the green wil move, and sometime yellow's wil appear, and its taken then dissapear. You never playd seafight ? Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted April 17, 2014 Share Posted April 17, 2014 (edited) There are all kinds of ways to do this. Here is one. You will likely need to adjust the colors. I believe SeaFight is notorious for varying colors??? I have not tested this, but it should work. const YellowDot = 62207; // Color of yellow dots. YellowDotTol = 5; // Color tolerance for yellow dots. GreenDot = 5026082; // Color of green dots. GreenDotTol = 5; // Color tolerance for green dots. function FindYellowDotNearestGreen(const SearchArea: TBox; out Position: TPoint): Boolean; var YellowPts: TPointArray; // Locations of yellow dots. GreenPos: TPoint; // Location of green dot. begin Result := False; Position := Point(0, 0); // Find yellow dots (if any). with SearchArea do if not FindColorTolEx(YellowPts, YellowDot, X1, Y1, X2, Y2, YellowDotTol) then begin Writeln('No yellow dots found.'); Exit; end; Writeln('Found ' + IntToStr(Length(YellowPts)) + ' pixels matching yellow.'); // Find green dot. with SearchArea, GreenPos do if not FindColorTol(X, Y, GreenDot, X1, Y1, X2, Y2, GreenDotTol) then begin Writeln('Failed to find green dot.'); SetLength(YellowPts, 0); Exit; end; Writeln(Format('Found green dot at (%d,%d).', [GreenPos.X, GreenPos.Y])); // Sort yellow by distance from green and return nearest point. SortTPAEx(YellowPts, GreenPos); Position := YellowPts[0]; SetLength(YellowPts, 0); Result := True; Writeln(Format('Found yellow dot at (%d,%d).', [Position.X, Position.Y])); end; Edited April 17, 2014 by Bixby Sayz Quote Link to comment Share on other sites More sharing options...
Net4Hack Posted April 18, 2014 Author Share Posted April 18, 2014 I get an error, when i put in the last begin not in that script^^ what to do : repeat yellowpoint; until(false); end. i get een error invalid nmbrs of parameters, what need to be added? Quote Link to comment Share on other sites More sharing options...
Wanted Posted April 18, 2014 Share Posted April 18, 2014 You never playd seafight ? Should of known Quote Link to comment Share on other sites More sharing options...
Net4Hack Posted April 18, 2014 Author Share Posted April 18, 2014 Should of known Do you know why i get that error ? Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted April 18, 2014 Share Posted April 18, 2014 Hard to diagnose partial code snippets. You are showing an end without a matching begin. Hard to know what you should have without seeing the whole thing. Quote Link to comment Share on other sites More sharing options...
Net4Hack Posted April 19, 2014 Author Share Posted April 19, 2014 So the code is : begin Repeat YellowPoint; Until(false); end. Quote Link to comment Share on other sites More sharing options...
Net4Hack Posted April 20, 2014 Author Share Posted April 20, 2014 " Bump, pleas help pleas.. I tryd all ways, nothing helps.. Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted April 23, 2014 Share Posted April 23, 2014 There is nothing wrong with that particular snippet. Which means there is an extra begin/end/something elsewhere in your script. Which is why I asked to see the whole thing. Quote Link to comment Share on other sites More sharing options...
Synthex Posted October 14, 2015 Share Posted October 14, 2015 Well actually I tried it too. If I put the script, its tells me I'm missing some parameters. EG: begin Repeat FindYellowDotNearestGreen(**What needs to be in here ? **); until(false); end. Quote Link to comment Share on other sites More sharing options...
Wanted Posted October 24, 2015 Share Posted October 24, 2015 (edited) const YellowColor = 62207; // Yellow decimal color GreenColor = 5026082; // Green decimal color X1 = 0; // Left bounds Y1 = 0; // Top bounds X2 = 700; // Right bounds Y2 = 700; // Bottom bounds Tol = 1; // Color Tolerance for both green and yellow color finding function YellowPointClosestToGreen(var P: TPoint): Boolean; // P outputted yellow point, Result true if there is one found var gTPA, yTPA: TPointArray; // gTPA list of green points, yTPA list of yellow points gH, yH, I, II: Integer; // gL highest array index of gTPA, yL highest array index of yTPA, I loop 1 index, II loop 2 index // note that arrays go from 0 to length minus 1. 0 length = -1 high. 5 length = 4 high D, cD: Extended; // D distance, cD closest distance begin Result := False; // Initate Result FindColorTolEx(yTPA, YellowColor, X1, Y1, X2, Y2, Tol); // Acquire yTPA FindColorTolEx(gTPA, GreenColor, X1, Y1, X2, Y2, Tol); // Acquire gTPA yH := High(yTPA); // Acquire yH gH := High(gTPA); // Acquire gH if ((yH < 0) or (gH < 0)) then // If high for either is less than 0 than did not find at least 1 Exit; // Leave with Result false Result := True; // Result must be true at this point if we're still here cD := 9999999; // Initiate cD with an arbitrarily large number (less than MaxInteger 2 Billion) for I := 0 to yH do // Loop through yTPA with Loop 1 with I Index for II := 0 to gH do // Loop each yTPA[i] through gTPA with Loop 2 with II Index begin D := Distance(yTPA[i].X, yTPA[i].Y, gTPA[iI].X, gTPA[iI].Y); // Acquire distance between [every] green and yellow point if (D < cD) then // Check to see if it's the shortest one recorded yet begin cD := D; // Since it is record it to cD [closest distance] P := yTPA[i]; // Update this point end; // by here we should have the smallest cD recorded and Point output as P end; end; var P: TPoint; // Declare TPoint to be used with funciton begin if (YellowPointClosestToGreen(P)) then // Result is True, P recorded WriteLn('Found'); // ^ ClickMouse(P.X, P.Y, True); // Use P to click. May consider using OSI etc. for more human like antiban. end. Assuming there is only 1 green and multiple yellows or 1 yellow and multiple greens Do something as simple as FindColorSpiral http://wiki.scar-divi.com/FindColorSpiral const YellowColor = 62207; // Yellow decimal color GreenColor = 5026082; // Green decimal color X1 = 0; // Left bounds Y1 = 0; // Top bounds X2 = 700; // Right bounds Y2 = 700; // Bottom bounds Tol = 1; // Color Tolerance for both green and yellow color finding var P: TPoint; begin if (FindColorTol(P.X, P.Y, GreenColor, X1, Y1, X2, Y2, Tol)) then FindColorSpiral(P.X, P.Y, P.X, P.Y, YellowColor, X1, Y1, X2, Y2); ClickMouse(P.X, P.Y, True); end. Edited October 24, 2015 by Wanted Quote Link to comment Share on other sites More sharing options...