NKN
12-04-2012, 09:15 PM
function OpenGate(color,tolerance,X1,Y1,X2,Y2:Integer;hue,s at:extended;SidewaysGate:Boolean):Boolean;
var
cts:integer;
TPA:TPointArray;
ATPA:T2DPointArray;
Pnt:TPoint;
Box:TBox;
begin
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(hue,sat);
if(FindColorsSpiralTolerance(MSCX,MSCY,TPA,color,X 1,Y1,X2,Y2,tolerance))then
begin
SMART_DrawDotsEx(True,TPA,clPurple);
ATPA := SplitTPA(TPA,3);
writeln(High(ATPA));
SortATPASize(ATPA,True);
SMART_DebugATPA(True,ATPA);
Box := GetTPABounds(ATPA[0]);
if(SidewaysGate) then
begin
if((Box.X2 - Box.X1) > (Box.Y2 - Box.Y1)) then
begin
Pnt := MiddleTPA(ATPA[0]);
Mouse(Pnt.x,Pnt.y,4,4,1);
FFLag(0);
while(IsMoving) do
wait(100);
result := true;
ColorToleranceSpeed(cts);
SetColorSpeed2Modifiers(0.2,0.2);
exit;
end else
result := true;
end else
if((Box.X2 - Box.X1) < (Box.Y2 - Box.Y1)) then
begin
Pnt := MiddleTPA(ATPA[0]);
Mouse(Pnt.x,Pnt.y,4,4,1);
FFLag(0);
while(IsMoving) do
wait(100);
result := true;
ColorToleranceSpeed(cts);
SetColorSpeed2Modifiers(0.2,0.2);
exit;
end else
result := true;
end;
ColorToleranceSpeed(cts);
SetColorSpeed2Modifiers(0.2,0.2);
end;
Basically, it uses CTS2 color finding to find the gate, then splits the TPA of the colors into a ATPA. Then it arranges the ATPA from largest to smallest, largest should be the gate(I would limit the area it searches for.) It has a debug in it, so you can see each TPA in the ATPA. Then based on SidewaysGate, checks if it's wider or longer than it should be (Closed gate wil be either longer or wider, because it's a 90 degree on the gate.) This then predicts if the gate is closed, and if it is, clicks somewhere in the middle of the gate.
Great use for a backup to gate opening
The gate should be listed under 0(The white one)
If gate is below your character, set SidewaysGate to true(The last parameter in it), and if it's above you(Mainscreen center). If the gate is to the side of you, set it to false.
var
cts:integer;
TPA:TPointArray;
ATPA:T2DPointArray;
Pnt:TPoint;
Box:TBox;
begin
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(hue,sat);
if(FindColorsSpiralTolerance(MSCX,MSCY,TPA,color,X 1,Y1,X2,Y2,tolerance))then
begin
SMART_DrawDotsEx(True,TPA,clPurple);
ATPA := SplitTPA(TPA,3);
writeln(High(ATPA));
SortATPASize(ATPA,True);
SMART_DebugATPA(True,ATPA);
Box := GetTPABounds(ATPA[0]);
if(SidewaysGate) then
begin
if((Box.X2 - Box.X1) > (Box.Y2 - Box.Y1)) then
begin
Pnt := MiddleTPA(ATPA[0]);
Mouse(Pnt.x,Pnt.y,4,4,1);
FFLag(0);
while(IsMoving) do
wait(100);
result := true;
ColorToleranceSpeed(cts);
SetColorSpeed2Modifiers(0.2,0.2);
exit;
end else
result := true;
end else
if((Box.X2 - Box.X1) < (Box.Y2 - Box.Y1)) then
begin
Pnt := MiddleTPA(ATPA[0]);
Mouse(Pnt.x,Pnt.y,4,4,1);
FFLag(0);
while(IsMoving) do
wait(100);
result := true;
ColorToleranceSpeed(cts);
SetColorSpeed2Modifiers(0.2,0.2);
exit;
end else
result := true;
end;
ColorToleranceSpeed(cts);
SetColorSpeed2Modifiers(0.2,0.2);
end;
Basically, it uses CTS2 color finding to find the gate, then splits the TPA of the colors into a ATPA. Then it arranges the ATPA from largest to smallest, largest should be the gate(I would limit the area it searches for.) It has a debug in it, so you can see each TPA in the ATPA. Then based on SidewaysGate, checks if it's wider or longer than it should be (Closed gate wil be either longer or wider, because it's a 90 degree on the gate.) This then predicts if the gate is closed, and if it is, clicks somewhere in the middle of the gate.
Great use for a backup to gate opening
The gate should be listed under 0(The white one)
If gate is below your character, set SidewaysGate to true(The last parameter in it), and if it's above you(Mainscreen center). If the gate is to the side of you, set it to false.