SRL Archive - SRL Archives

[Functions] FindMMColorMulti and FindMSColorMulti


QQu

2006-06-14 07:20:04

Hi everyone, I felt bored so I made some Functions which might be useful :rolleyes:


- FindMMColorMulti

This Function looks for the three specified colors on the MiniMap and if not found, uses a Tolerance Riser.

Function ClickMMColorMulti(Color1 : Integer; Color2 : Integer; Color3 : Integer; MaxTol : Integer): Integer;
Var Tol : Integer;

Begin
for Tol:= 0 to MaxTol do
Begin
if (FindColorSpiralTolerance(x, y, Color1, 574, 8, 724, 157, Tol )) or
FindColorSpiralTolerance(x, y, Color2, 574, 8, 724, 157, Tol ) or
FindColorSpiralTolerance(x, y, Color3, 574, 8, 724, 157, Tol ) then
Mouse(x, y, 0, 0, true);
Exit;
end;
end;


- FindMSColorMulti

This Function looks for the three specified colors on the Main Screen and if not found, uses a Tolerance Riser.

Function ClickMSColorMulti(Color1 : Integer; Color2 : Integer; Color3 : Integer; MaxTol : Integer): Integer;
Var Tol : Integer;

Begin
for Tol:= 0 to MaxTol do
Begin
if ( FindColorSpiralTolerance(x, y, Color1, 0, 0, 515, 338, Tol )) or
FindColorSpiralTolerance(x, y, Color2, 0, 0, 515, 338, Tol ) or
FindColorSpiralTolerance(x, y, Color3, 0, 0, 515, 338, Tol ) then
Mouse(x, y, 0, 0, true);
Exit;
end;
end;


Can someone please test them out?
I am pretty sure they work :D


Cheers,
Surajd ;)

XxKanexX

2006-06-14 07:37:49

It'd be better if you used arrays, so you could do more than 3 colors. Also, your functions don't return anything.


{.include SRL/SRL.scar}

function ClickColorMulti(Colors: array of Integer; xs, ys, xe, ye, MaxTol: Integer): Boolean;
var i, e: Integer;
begin
for i:= 0 to GetarrayLength(Colors)-1 do
begin
for e:= 0 to MaxTol do
begin
if (FindColorSpiralTolerance(x, y, Colors[i], xs, ys, xe, ye, e)) then
begin
Result:= True;
Mouse(x, y, 0, 0, True);
Exit;
end;
end;
end;
end;

function ClickMSColorMulti(Colors: array of Integer; MaxTol: Integer): Boolean;
begin
Result:= ClickColorMulti(Colors, MSX1, MSY1, MSX2, MSY2, MaxTol);
end;

function ClickMMColorMulti(Colors: array of Integer; MaxTol: Integer): Boolean;
begin
Result:= ClickColorMulti(Colors, MMX1, MMY1, MMX2, MMY2, MaxTol);
end;


if (ClickMMColorMulti([Col1, Col2, Col3, Col4, Col5], 15)) then
begin
Writeln('Found & Clicked on one of the colors!');
end;