Tootoot222
01-15-2008, 11:20 AM
well i was trying to make my ServantPlanker, and I encountered the problem of trying to find a color that has the uptext of the name of the servant, but if i tried to use FindColorSprial in a repeat loop it would never find a color that is to the left of the previous color that was found, so i made this, but it has to have the "CMouse" in it for the click.
{************************************************* ******************************
procedure CMouse(Left: Boolean);
By: Mutant Squirrle modded by Tootoot222
Description: Clicks mouse at current position.
Notes: Mutant Squirrle made this, and i just took out the "mouse" procedure
************************************************** *****************************}
procedure CMouse(Left:Boolean);
var
a,b,c: Integer;
begin
Wait(60 + Random(30));
GetMousePos(b, c);
HoldMouse(b + 1, c, left);
repeat
Wait(20 + Random(30));
a := a + 1;
until (a > 4);
GetMousePos(b, c);
ReleaseMouse(b, c, left);
Wait(100 + Random(100));
end;
{************************************************* ******************************
function FindColorSprial3(var x,y: Integer; Color,Sx,Sy,Ex,Ey,Tol,Rx,Ry: Integer; Click,Left,UsePhrase: Boolean; Phrase: String; IFrom: Integer):Boolean;
By: Tootoot222
Description: Stores the x,y coords for Color in Sx,Sy,Ex,Ey and if usePhrase = true then it checks the uptext to see if it matches Phrase, and if Click = true then it click at that point.
Use: Use like: FindColorSprial3(x,y,255,0,0,500,500,5,2,2,True,Tr ue,True,'Walk here',1);
************************************************** *****************************}
Function FindColorSprial3(var x,y: Integer; Color,Sx,Sy,Ex,Ey,Tol,Rx,Ry: Integer; Click,Left,UsePhrase: Boolean; Phrase: String; IFrom: Integer):Boolean;
var
z,t,q,w,i,TimesLooked,TimesFound: Integer;
begin
z:= Sx;
t:= Sy;
if(FindColorTolerance(q,w,Color,Sx,Sy,Ex,Ey,Tol)) then
begin
Writeln('Color is in the area spesified');
Z:= Q;
T:= W;
end else
begin
Writeln('Color is NOT in the area spesified');
GetApplication.BringToFront;
Result:= False;
Exit;
end;
repeat
repeat
Writeln('Looked for color '+IntToStr(TimesLooked)+' times, and found the color '+IntToStr(TimesFound)+'Times');
Writeln('Serching for color '+IntToStr(Color)+' At '+IntToStr(z)+','+IntToStr(t));
TimesLooked:= TimesLooked+1;
if(FindColorTolerance(q,w,Color,z,t,z,t,Tol)) then
begin
TimesFound:= TimesFound+1;
Writeln('found color at '+IntToStr(z)+','+IntToStr(t));
MMouse(q,w,Rx,Ry);
i:= 0;
repeat
Wait(165+Random(47));
i:= i+1;
until(i>=4);
if(UsePhrase) then
begin
Writeln('UpText = '+Lowercase(Copy(GetUpText,IFrom,Length(phrase)))) ;
if(Lowercase(Copy(GetUpText,IFrom,Length(phrase))) =LowerCase(Phrase)) then
begin
Result:= True;
x:= q;
y:= w;
if(Click) then
begin
CMouse(Left);
end;
Exit;
end;
end else
begin
Result:= True;
x:= q;
y:= w;
if(Click) then
begin
CMouse(Left);
end;
Exit;
end;
end else
begin
if(FindColorTolerance(q,w,Color,z+1,t,Ex,t,Tol)) then
begin
z:= q;
end else
begin
if(FindColorTolerance(q,w,Color,Sx,t+1,Ex,Ey,Tol)) then
begin
z:= q;
t:= w;
end else
begin
Writeln('Color is NOT within the area of '+IntToStr(z)+','+IntToStr(t)+' to '+IntToStr(Ex)+','+IntToStr(Ey));
Result:= False;
Exit;
end;
end;
end;
z:= z+2;
until(z>= EX);
t:= t+6;
z:= Sx;
until(Y>= Ey+1);
end;
{************************************************* ******************************
procedure CMouse(Left: Boolean);
By: Mutant Squirrle modded by Tootoot222
Description: Clicks mouse at current position.
Notes: Mutant Squirrle made this, and i just took out the "mouse" procedure
************************************************** *****************************}
procedure CMouse(Left:Boolean);
var
a,b,c: Integer;
begin
Wait(60 + Random(30));
GetMousePos(b, c);
HoldMouse(b + 1, c, left);
repeat
Wait(20 + Random(30));
a := a + 1;
until (a > 4);
GetMousePos(b, c);
ReleaseMouse(b, c, left);
Wait(100 + Random(100));
end;
{************************************************* ******************************
function FindColorSprial3(var x,y: Integer; Color,Sx,Sy,Ex,Ey,Tol,Rx,Ry: Integer; Click,Left,UsePhrase: Boolean; Phrase: String; IFrom: Integer):Boolean;
By: Tootoot222
Description: Stores the x,y coords for Color in Sx,Sy,Ex,Ey and if usePhrase = true then it checks the uptext to see if it matches Phrase, and if Click = true then it click at that point.
Use: Use like: FindColorSprial3(x,y,255,0,0,500,500,5,2,2,True,Tr ue,True,'Walk here',1);
************************************************** *****************************}
Function FindColorSprial3(var x,y: Integer; Color,Sx,Sy,Ex,Ey,Tol,Rx,Ry: Integer; Click,Left,UsePhrase: Boolean; Phrase: String; IFrom: Integer):Boolean;
var
z,t,q,w,i,TimesLooked,TimesFound: Integer;
begin
z:= Sx;
t:= Sy;
if(FindColorTolerance(q,w,Color,Sx,Sy,Ex,Ey,Tol)) then
begin
Writeln('Color is in the area spesified');
Z:= Q;
T:= W;
end else
begin
Writeln('Color is NOT in the area spesified');
GetApplication.BringToFront;
Result:= False;
Exit;
end;
repeat
repeat
Writeln('Looked for color '+IntToStr(TimesLooked)+' times, and found the color '+IntToStr(TimesFound)+'Times');
Writeln('Serching for color '+IntToStr(Color)+' At '+IntToStr(z)+','+IntToStr(t));
TimesLooked:= TimesLooked+1;
if(FindColorTolerance(q,w,Color,z,t,z,t,Tol)) then
begin
TimesFound:= TimesFound+1;
Writeln('found color at '+IntToStr(z)+','+IntToStr(t));
MMouse(q,w,Rx,Ry);
i:= 0;
repeat
Wait(165+Random(47));
i:= i+1;
until(i>=4);
if(UsePhrase) then
begin
Writeln('UpText = '+Lowercase(Copy(GetUpText,IFrom,Length(phrase)))) ;
if(Lowercase(Copy(GetUpText,IFrom,Length(phrase))) =LowerCase(Phrase)) then
begin
Result:= True;
x:= q;
y:= w;
if(Click) then
begin
CMouse(Left);
end;
Exit;
end;
end else
begin
Result:= True;
x:= q;
y:= w;
if(Click) then
begin
CMouse(Left);
end;
Exit;
end;
end else
begin
if(FindColorTolerance(q,w,Color,z+1,t,Ex,t,Tol)) then
begin
z:= q;
end else
begin
if(FindColorTolerance(q,w,Color,Sx,t+1,Ex,Ey,Tol)) then
begin
z:= q;
t:= w;
end else
begin
Writeln('Color is NOT within the area of '+IntToStr(z)+','+IntToStr(t)+' to '+IntToStr(Ex)+','+IntToStr(Ey));
Result:= False;
Exit;
end;
end;
end;
z:= z+2;
until(z>= EX);
t:= t+6;
z:= Sx;
until(Y>= Ey+1);
end;