PDA

View Full Version : [Snippet] OpenGate



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.

Ian
12-04-2012, 09:22 PM
Looks pretty nice, when I tried gate-opening myself I failed horribly :p. I'll test it now, would I need to use ACA to find the hue and saturation?

NKN
12-04-2012, 09:23 PM
Looks pretty nice, when I tried gate-opening myself I failed horribly :p. I'll test it now, would I need to use ACA to find the hue and saturation?

ACA would be best.

Ian
12-04-2012, 09:41 PM
I used MSX1, MSX2, MSY1, MSY2 for the X1, X2, Y1, Y2 and It gave me an out of range error.

Justin
12-04-2012, 10:00 PM
i used msx1, msx2, msy1, msy2 for the x1, x2, y1, y2 and it gave me an out of range error.

msx1, msy1, msx2, msy2 ;)

Ian
12-04-2012, 11:45 PM
ustin;1136754']msx1, msy1, msx2, msy2 ;)

Whoops :redface:

NKN
12-04-2012, 11:48 PM
Whoops :redface:

Dos et work

Ian
12-04-2012, 11:58 PM
Dos et work

Unfortunately I'm no longer at my computer. I'll test tomorrow though, promise :D

Shatterhand
12-13-2012, 04:46 PM
What gates does this open?

Ian
12-13-2012, 04:58 PM
What gates does this open?

I'm pretty sure it opens all of them as long as you put in the right colors.

NKN
12-13-2012, 09:57 PM
I got a updated version, works like, 10x more accurate now.

I'll post when I feel like doing it.

___
12-13-2012, 10:06 PM
This isn't always working... when I try to open a gate, it will open it, then sometimes it will click on the already opened gate.

NKN
12-22-2012, 08:10 PM
This isn't always working... when I try to open a gate, it will open it, then sometimes it will click on the already opened gate.
I got a version that checks for uptext now. I'll post it when I fine tune it.

ajg0001991
02-17-2013, 12:58 AM
any updates on this open gate function cud do with this for the gate in wildy such a pain

CHEATGOD
02-17-2013, 06:53 PM
What gate are you trying to open sir?