SRL Archive - SRL Archives

The "ColorSearch" - its insane ;)


TheGodfather

2007-04-21 01:38:34

Hey guys, this is my first crazy worth while function I think I've released here. I've released little ones but this is by far my best function ever.


Description:
This function here, searches for a given color in the given coordinates.
Why is this so special??
Well becuase, it's compatible with coordinates. Any coordinates. With the box that the coordinates create, this script splits it into 4 x 4 units. This makes 16 different boxes that it searches through, in a spiral motion clockwise, starting from the middle heading out.

This should make it so that it gets the coords of a color thats atleast somewhat close to the middle of the screen. Not always the closest one, but its never the furthest one.

Wrapped up within the 245 lines for this single function, it just may be useful. It's pretty easy to incorparate into w/e you're using (all you need is a color to look for and a box to look through).

Upcoming Releases:
- Tolerance (for everything)
- BitmapSearch (and a deformed search too)
- DtmSearch
- MultiColorSearch, (Looks for 3 colors close to eachother within givin pixels.)
- and many RS specealties. (SearchMMColor, ObjectSearch (with color, dtm, or bitmap) and much more…)

Post feedback please!

Oh, last but not least, the function itself!


quick sample way of using…
ColorSearch(x, y, NPCdot, MMX1, MMY1, MMX2, MMY2);


{*******************************************************************************
function ColorSearch(var cx, cy: integer; Color, x1, y1, x2, y2: integer): Boolean;
By: TheGodfather
Description: Searches for a color through 16 sections, clockwise center out.
*******************************************************************************}
function ColorSearch(var cx, cy: integer; Color, x1, y1, x2, y2: integer): Boolean;
var
Midpoint, Temp: TPoint;
sx1, sx2, sy1, sy2, SearchBoxes: Integer;
begin
result := false;
if CountColor(Color, x1, y1, x2, y2) > 0 then
begin
Temp.x := x2 - x1;
Temp.x := Temp.x div 2;
Temp.y := y2 - y1;
Temp.y := Temp.y div 2;
Midpoint.x := x1 + Temp.x;
Midpoint.y := y1 + Temp.y;
Temp.x := Temp.x div 2;
Temp.y := Temp.y div 2;
for SearchBoxes := 1 to 16 do
begin
case SearchBoxes of
1: begin
sx1 := Midpoint.x;
sy1 := Midpoint.y;
sx2 := Midpoint.x + Temp.x;
sy2 := Midpoint.y + Temp.y;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

2: begin
sx1 := Midpoint.x - Temp.x;
sy1 := Midpoint.y;
sx2 := Midpoint.x;
sy2 := Midpoint.y + Temp.y;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

3: begin
sx1 := Midpoint.x - Temp.x;
sy1 := Midpoint.y - Temp.y;
sx2 := Midpoint.x;
sy2 := Midpoint.y;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

4: begin
sx1 := Midpoint.x;
sy1 := Midpoint.y - Temp.y;
sx2 := Midpoint.x + Temp.x;
sy2 := Midpoint.y;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

5: begin
sx1 := Midpoint.x + Temp.x;
sy1 := Midpoint.y - Temp.y;
sx2 := Midpoint.x + Temp.x * 2;
sy2 := Midpoint.y;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

6: begin
sx1 := Midpoint.x + Temp.x;
sy1 := Midpoint.y;
sx2 := Midpoint.x + Temp.x * 2;
sy2 := Midpoint.y + Temp.y;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

7: begin
sx1 := Midpoint.x + Temp.x;
sy1 := Midpoint.y + Temp.y;
sx2 := Midpoint.x + Temp.x * 2;
sy2 := Midpoint.y + Temp.y * 2;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

8: begin
sx1 := Midpoint.x;
sy1 := Midpoint.y + Temp.y;
sx2 := Midpoint.x + Temp.x
sy2 := Midpoint.y + Temp.y * 2;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

9: begin
sx1 := Midpoint.x - Temp.x;
sy1 := Midpoint.y + Temp.y;
sx2 := Midpoint.x;
sy2 := Midpoint.y + Temp.y * 2;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

10: begin
sx1 := Midpoint.x - Temp.x * 2;
sy1 := Midpoint.y + Temp.y;
sx2 := Midpoint.x - Temp.x;
sy2 := Midpoint.y + Temp.y * 2;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

11: begin
sx1 := Midpoint.x - Temp.x * 2;
sy1 := Midpoint.y;
sx2 := Midpoint.x - Temp.x;
sy2 := Midpoint.y + Temp.y;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

12: begin
sx1 := Midpoint.x - Temp.x * 2;
sy1 := Midpoint.y - Temp.y;
sx2 := Midpoint.x - Temp.x;
sy2 := Midpoint.y;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

13: begin
sx1 := Midpoint.x - Temp.x * 2;
sy1 := Midpoint.y - Temp.y * 2;
sx2 := Midpoint.x - Temp.x;
sy2 := Midpoint.y - Temp.y;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

14: begin
sx1 := Midpoint.x - Temp.x;
sy1 := Midpoint.y - Temp.y * 2;
sx2 := Midpoint.x;
sy2 := Midpoint.y - Temp.y;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

15: begin
sx1 := Midpoint.x;
sy1 := Midpoint.y + Temp.y * 2;
sx2 := Midpoint.x + Temp.x;
sy2 := Midpoint.y + Temp.y;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;

16: begin
sx1 := Midpoint.x + Temp.x;
sy1 := Midpoint.y + Temp.y * 2;
sx2 := Midpoint.x + Temp.x * 2;
sy2 := Midpoint.y + Temp.y;
if FindColorSpiral(x, y, Color, sx1, sy1, sx2, sy2) then
begin
result:= true;
cx := x;
cy := y;
Exit;
end;
end;
end;
end;
end;
end;

Rune Hacker

2007-04-21 01:46:27

Wow, this would be really useful. So what it does is look for 3 colors close to eachother on the main screen? That sounds really great.

Thick As Blood

2007-04-21 01:52:56

anywhere you set the cords to look, it looks for a color inside the cords, a box basicaly.

TheGodfather

2007-04-21 01:57:10

From: Rune Hacker
Wow, this would be really useful. So what it does is look for 3 colors close to eachother on the main screen? That sounds really great.


Not yet, but I'll release soon.

TheGodfather

2007-04-21 01:58:11

From: Thick As Blood
anywhere you set the cords to look, it looks for a color inside the cords, a box basicaly.


Not only, it adds more boxes within the box you set :p

mx1000

2007-04-28 05:24:45

From: TheGodfather
Not only, it adds more boxes within the box you set :p

this would be awesome for that script where you abuse the free runes whit mule and trader thing

if u add eachother on friend list :D

TheGodfather

2007-08-27 03:00:14

old times.

amazing what HSL can do.

Santa_Clause

2007-08-27 04:27:09

Ahh…The Godfather! I remember you! I helped you once with some Pythagorean Triples :p

R0b0t1

2007-09-01 16:17:10


FindColorSpiralTolerance(x, y, color, x1, y1, x2, y2, tol);

You can say "Doh!" now.

pwnaz0r

2007-09-01 20:07:11

ha, r0b0t I don't think you quite understand. Its not the same as that. Kinda could use that but it is different ;). I'm definatly using in my WC script bc i hate it clicking colors on the edge of the screen when there is a tree right next to him -.-

Pyro

2007-09-01 20:07:43

From: r0b0t1

FindColorSpiralTolerance(x, y, color, x1, y1, x2, y2, tol);

You can say "Doh!" now.


yip yip was just thinking that. This is what your function does correct? Searches outwards to find the exact co ord in the middle? just do this….have your box as whatever in findcolorspiral then set x and y to the center of your box. Findcolorspiral "spirals" outwards from wherever the x and y are set to.

R0b0t1

2007-09-01 22:59:28

Yes, and then sets X and Y as where it found the color.

Though, you could create a function like yours and then have it findspiral all of the boxes…?


@Pwnazor - guide FTW? I looked in it befor I posted :p.

pwnaz0r

2007-09-02 00:28:44

From: r0b0t1
Yes, and then sets X and Y as where it found the color.

Though, you could create a function like yours and then have it findspiral all of the boxes…?


@Pwnazor - guide FTW? I looked in it befor I posted :p.
'

dn what you mean by guide, as in if you want me to give you one or you read one ;):p?

Pyro

2007-09-02 04:57:10

To be fair godfather. I did EXACTLY the same thing. well not same function but i made one like it as i didnt know about findcolorspiral and how it worked. But it is nice work none the less. If you modded it a bit. You could turn it into a rather good findobj

R0b0t1

2007-09-02 11:21:45

No, I mean the SCAR manual.

TheGodfather

2007-09-07 00:58:17

I made this becuase my color clickers never clicked on the middle, but I remember how much work this was back in the day.