Log in

View Full Version : My new Function for SRL Completed



the nerd
03-04-2007, 04:09 PM
For those of you who have been looking for my Function that have deleted from my previous thread. Here are my completed functions. There designed to be used together, so if you need one function then you need to copy, FindObjInBoxAdvance + that function that you need.

If there are any problems please post, or PM me. I will release new version if I need to.



{************************************************* ******************************
Function FindObjColorsInBoxAdvance(x,y:Integer;Text1,Text2, Text3:String;Color1,Color2,Color3,Tol,BoxSize,Spir alSize,PauseTime:Integer):Boolean;
By: THE NERD
Description: Looks for the three colors and if within a box specified by BoxSize
moves mouse to check to find Object name.
This is the most advance FindColorsInBox Function which you can
customize all of the variables to your own needs.
Like FindObject except removes most strange mouse movments.
************************************************** *****************************}
Function FindObjColorsInBoxAdvance(var x,y:Integer;Text1,Text2,Text3:String;Color1,Color2 ,Color3,Tol,BoxSize,SprialSize,PauseTime:Integer): Boolean;
var
I, A ,D ,E ,CX ,CY:Integer;
ColorPosx : Array [1..3] Of Integer;
ColorPosy : Array [1..3] Of Integer;
begin
Result := False;
If (FindColorTolerance(cx,cy,Color1,MSX1, MSY1, MSX2, MSY2, Tol)) Or
(FindColorTolerance(cx,cy,Color2,MSX1, MSY1, MSX2, MSY2, Tol)) Or
(FindColorTolerance(cx,cy,Color3,MSX1, MSY1, MSX2, MSY2, Tol)) Then
begin

D := SprialSize;
E := D;

Repeat

For I := 1 To 3 Do
begin
ColorPosx[I] := MSCX;
ColorPosy[I] := MSCY;
end;

If (A = 1) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := MSCX;
ColorPosy[I] := ColorPosy[I] + D;
end;
end;

If (A = 2) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] + (D div 2);
ColorPosy[I] := ColorPosy[I] + D;
end;
end;

If (A = 3) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] + D;
ColorPosy[I] := ColorPosy[I] + D;
end;
end;

If (A = 4) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] + D;
ColorPosy[I] := ColorPosy[I] + (D div 2);
end;
end;

If (A = 5) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] + D;
ColorPosy[I] := ColorPosy[I] + (D div 4);
end;
end;

If (A = 6) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] + D;
ColorPosy[I] := MSCY;
end;
end;

If (A = 7) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] + D;
ColorPosy[I] := ColorPosy[I] - (D div 4);
end;
end;

If (A = 8) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] + D;
ColorPosy[I] := ColorPosy[I] - (D div 2);
end;
end;

If (A = 9) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] + D;
ColorPosy[I] := ColorPosy[I] - D;
end;
end;

If (A = 10) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] + (D div 2);
ColorPosy[I] := ColorPosy[I] - D;
end;
end;

If (A = 11) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := MSCX;
ColorPosy[I] := ColorPosy[I] - D;
end;
end;

If (A = 12) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] - (D div 2);
ColorPosy[I] := ColorPosy[I] - D;
end;
end;

If (A = 13) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] - D;
ColorPosy[I] := ColorPosy[I] - D;
end;
end;

If (A = 14) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] - D;
ColorPosy[I] := ColorPosy[I] - (D div 2);
end;
end;

If (A = 15) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] - D;
ColorPosy[I] := ColorPosy[I] - (D div 4);
end;
end;

If (A = 16) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] - D;
ColorPosy[I] := MSCY;
end;
end;

If (A = 17) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] - D;
ColorPosy[I] := ColorPosy[I] + (D div 4);
end;
end;

If (A = 18) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] - D;
ColorPosy[I] := ColorPosy[I] + (D div 2);
end;
end;

If (A = 19) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] - D;
ColorPosy[I] := ColorPosy[I] + D;
end;
end;

If (A = 20) Then
begin
For I := 1 To 3 Do
begin
ColorPosx[I] := ColorPosx[I] - (D div 2);
ColorPosy[I] := ColorPosy[I] + D;
end;
A := 0;
D := D + E;
end;

FindColorSpiralTolerance(ColorPosx[1],ColorPosy[1],Color1,MSX1, MSY1, MSX2, MSY2, Tol)
FindColorSpiralTolerance(ColorPosx[2],ColorPosy[2],Color2,MSX1, MSY1, MSX2, MSY2, Tol)
FindColorSpiralTolerance(ColorPosx[3],ColorPosy[3],Color3,MSX1, MSY1, MSX2, MSY2, Tol)

If ((ColorPosx[1] - ColorPosx[2] < BoxSize) Or (ColorPosx[1] - ColorPosx[2] > -BoxSize)) And ((ColorPosy[1] - ColorPosy[2] < BoxSize) Or (ColorPosy[1] - ColorPosy[2] > -BoxSize)) Then
begin
If ((ColorPosx[2] - ColorPosx[3] < BoxSize) Or (ColorPosx[2] - ColorPosx[3] > -BoxSize)) And ((ColorPosy[2] - ColorPosy[3] < BoxSize) Or (ColorPosy[2] - ColorPosy[3] > -BoxSize)) Then
begin
If ((ColorPosx[3] - ColorPosx[1] < BoxSize) Or (ColorPosx[3] - ColorPosx[1] > -BoxSize)) And ((ColorPosy[3] - ColorPosy[1] < BoxSize) Or (ColorPosy[3] - ColorPosy[1] > -BoxSize)) Then
begin
MMouse(ColorPosx[1],ColorPosy[1],3,3);
Wait(PauseTime);
If (IsUpTextMulti(Text1,Text2,Text3)) Then
begin
Result := True;
Sleep(1);
getmousepos(x,y);
end;
end;
end;
end;
A := A + 1;
B := B + 1;
Until (Result = True) Or (B > ((MSCX * 20) / E) )
end;
end;

{************************************************* ******************************
Function FindObjColorsInBoxTol(rx,ry:Integer;Text:String;Co lor1,Color2,Color3,Tol,BoxSize:Integer):Boolean;
By: THE NERD
Description: Looks for the three colors with tol and if within a box specified
by BoxSize moves mouse to check to find Object name.
Like FindObject except removes most strange mouse movments.
************************************************** *****************************}
Function FindObjColorsInBoxTol(var x,y:Integer;Text:String;Color1,Color2,Color3,Tol,B oxSize:Integer):Boolean;
begin
Result := FindObjColorsInBoxAdvance(x,y,Text,Text,Text,Color 1,Color2,Color3,Tol,BoxSize,5,100);
end;

{************************************************* ******************************
Function FindObjColorsInBoxMultiTol(rx,ry:Integer;Text1,Tex t2,Text3:String;Color1,Color2,Color3,Tol,BoxSize:I nteger):Boolean;
By: THE NERD
Description: Looks for the three colors with Tol and if within a box specified
by BoxSize moves mouse to check to find Object name.
Like FindObject except removes most strange mouse movments.
************************************************** *****************************}
Function FindObjColorsInBoxMultiTol(var x,y:Integer;Text1,Text2,Text3:String;Color1,Color2 ,Color3,Tol,BoxSize:Integer):Boolean;
begin
Result := FindObjColorsInBoxAdvance(x,y,Text1,Text2,Text3,Co lor1,Color2,Color3,Tol,BoxSize,5,100);
end;

{************************************************* ******************************
Function FindColorsInBox(rx,ry,Color1,Color2,Color3,Tol,Box Size:Integer):Boolean;
By: THE NERD
Description: Looks for the three colors and returns the coords of the colors if
they are all found within a box specified by BoxSize.
************************************************** *****************************}
Function FindColorsInBox(var x,y,Color1,Color2,Color3,BoxSize:Integer):Boolean;
begin
Result := FindColorsInBoxTol(x,y,Color1,Color2,Color3,0,BoxS ize);
end;

{************************************************* ******************************
Function FindObjColorInBox(rx,ry:Integer;Text:String;Color1 ,Color2,Color3,Tol,BoxSize:Integer):Boolean;
By: THE NERD
Description: Looks for the three colors and if within a box specified by BoxSize
moves mouse to check to find Object name.
Like FindObject except removes most strange mouse movments.
************************************************** *****************************}
Function FindObjColorsInBox(var x,y:Integer;Text:String;Color1,Color2,Color3,BoxSi ze:Integer):Boolean;
begin
Result := FindObjColorsInBoxTol(x,y,Text,Color1,Color2,Color 3,0,BoxSize);
end;

{************************************************* ******************************
Function FindObjColorsInBoxMultiTol(rx,ry:Integer;Text1,Tex t2,Text3:String;Color1,Color2,Color3,Tol,BoxSize:I nteger):Boolean;
By: THE NERD
Description: Looks for the three colors with Tol and if within a box specified
by BoxSize moves mouse to check to find Object name.
Like FindObject except removes most strange mouse movments.
************************************************** *****************************}
Function FindObjColorsInBoxMulti(var x,y:Integer;Text1,Text2,Text3:String;Color1,Color2 ,Color3,BoxSize:Integer):Boolean;
begin
Result := FindObjColorsInBoxMultiTol(x,y,Text1,Text2,Text3,C olor1,Color2,Color3,0,BoxSize);
end;

Bobarkinator
03-04-2007, 08:23 PM
Great functions. What would be a good boxsize? Like if I wanted a 1 square inch box on the Runescape screen what would I put for boxsize?

Boreas
03-04-2007, 08:39 PM
Check out cases.

TheGodfather
03-04-2007, 09:09 PM
Check out cases.

haha, he's right, you'd make it easier on yourself. Great job on helping out.

Smartzkid
03-04-2007, 09:15 PM
Check out cases.

Umm...cases?

TheGodfather
03-04-2007, 09:26 PM
Umm...cases?



Function X: Boolean;

Var
i: Integer;

Begin
For I := 1 To 4 Do
Begin
Case I Of
1: If X Then
Result := True;

2: If X Then
Result := True;

3: If X Then
Result := True;

4: If X Then
Result := True;
End;

Thats just an example, those can be procedures, w/e...

the nerd
03-06-2007, 12:35 PM
i will think about removing the "IF"'s an replacing them with cases, but right now it works and thats all that matters