SRL Archive - SRL Snippets

[Snippet] OpenGate


NKN

2012-12-04 16:15:57

function OpenGate(color,tolerance,X1,Y1,X2,Y2:Integer;hue,sat: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,X1,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

2012-12-04 16:22:22

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

2012-12-04 16:23:24

From: BMWxi
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

2012-12-04 16:41:06

I used MSX1, MSX2, MSY1, MSY2 for the X1, X2, Y1, Y2 and It gave me an out of range error.

Justin

2012-12-04 17:00:39

From: bmwxi
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

2012-12-04 18:45:33

From: [J]ustin
msx1, msy1, msx2, msy2 ;)


Whoops :redface:

NKN

2012-12-04 18:48:29

From: BMWxi
Whoops :redface:


Dos et work

Ian

2012-12-04 18:58:19

From: NKN

Dos et work


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

Shatterhand

2012-12-13 11:46:11

What gates does this open?

Ian

2012-12-13 11:58:25

From: Shatterhand
What gates does this open?


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

NKN

2012-12-13 16:57:11

I got a updated version, works like, 10x more accurate now.

I'll post when I feel like doing it.

___

2012-12-13 17:06:21

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

2012-12-22 15:10:45

From: ___
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

2013-02-16 19:58:32

any updates on this open gate function cud do with this for the gate in wildy such a pain

CHEATGOD

2013-02-17 13:53:59

What gate are you trying to open sir?