SRL Archive - SRL Archives

CloseWindow


Naum

2009-05-19 19:12:22

CloseWindow had a few problems of closing a window and making it click on the ground aswell, I have made my own CloseWindow which is shorter + Faster and works for any window. It also works for the new Equipment stats window, please test.

This is the cleaned version outputted from the combined efforts of Nava2 and Narcle.

Function CloseWindow : Boolean;
Var
Col : TIntegerArray;
A, B : TPointArray;
Pa : TBox;
I : Integer;

Begin
Col := [1909802, 9678265, {Main typ 1}
8042720, 4160933, {Skill}
6854059, 2902100, {Quest}
10070193, 2503226]; {Main typ 2}
For I := 0 To (High(Col) Div 2) Do
Begin
FindColorsTolerance(A, Col[i*2], MSX1, MSY1, MSX2, MSY2, 1);
FindColorsTolerance(B, Col[i*2+1], MSX1, MSY1, MSX2, MSY2, 1);
If ((High(a) + High(b)) > 0) Then
Begin
Pa := GetTPABounds(CombineTPA(A, B));
Mouse(RandomRange(Pa.x1, Pa.x2), RandomRange(Pa.y1, Pa.y2), 0, 0, True);
Result := (Pa.x1 >= 100);
Exit;
End;
End;
End;

Nadeem

2009-05-19 19:30:31

Looks real nice :D And works like a charm!! :)



~NS

Dynamite

2009-05-19 20:17:25

Works great. Thanks :)

T~M

Naum

2009-05-19 23:25:33

Thanks guys :). I don't know if it can be shortened, but can someone give it a once over and hopefully it will be commited ;)

Home

2009-05-20 00:32:39

Works great and yes "Old" CloseWindow had some Flaws :) Thanks for this, this is how SRL works :) Everyone puts thei thoughts together and we make most powerful and best cheating tool :)

~Home
Edit: Yes i tested it :) ( And it works :) )

Nava2

2009-05-20 00:33:26

I think it can be sped up.

Let me take a crack at it..

Function CloseWindow : Boolean;
Var
Col : array [0..1] of TIntegerArray;
GTPA : Array [0..3] Of TPointArray;
TPA: array [0..1] of TPointArray;
Pa : TBox;
I : Integer;
Begin
Col := [TIntegerArray(8042720, 4160933), {Skill}
TIntegerArray(6854059, 2902100), {Quest}
TIntegerArray(1909802, 9678265), {Main typ 1}
TIntegerArray(10070193, 2503226)];{Main typ 2}
For I := 0 To 3 Do
Begin
FindColorsTolerance(TPA[0], Col[I][0], MSX1, MSY1, MSX2, MSY2, 1);
FindColorsTolerance(TPA[1], Col[I][1], MSX1, MSY1, MSX2, MSY2, 1);
GTPA[I] := CombineTPA(TPA[0], TPA[1]);
End;

For I := 0 to 3 Do
If (High(GTPA[i]) > -1) Then
Begin
Pa := GetTPABounds(GTPA[i]);
Mouse(RandomRange(Pa.x1, Pa.x2), RandomRange(Pa.y1, Pa.y2), 0, 0, True);
Result := True;
Exit;
End;
Result := False;
End;

Could someone please test this?

Naum

2009-05-20 00:46:18

Cool, lets test with TimeMarks :)!

Will it be committed then?

Nava2

2009-05-20 05:37:33

From: NaumanAkhlaQ
Cool, lets test with TimeMarks :)!

Will it be committed then?


So, mine works?

If so, I will commit mine, but I won't take any credit. You did it :) I just cleaned.. got out the broom etc.

Narcle

2009-05-20 10:29:35

and mine heh
Function CloseWindow : Boolean;
Var
Col : TIntegerArray;
A, B : TPointArray;
Pa : TBox;
I : Integer;
Begin
Col := [8042720, 4160933, {Skill}
6854059, 2902100, {Quest}
1909802, 9678265, {Main typ 1}
10070193, 2503226];{Main typ 2}
For I := 0 To 3 Do
Begin
FindColorsTolerance(A, Col[i*2], MSX1, MSY1, MSX2, MSY2, 1);
FindColorsTolerance(B, Col[i*2+1], MSX1, MSY1, MSX2, MSY2, 1);
If (High(CombineTPA(A, B)) > 0) Then
Begin
Pa := GetTPABounds(CombineTPA(A, B));
Mouse(RandomRange(Pa.x1, Pa.x2), RandomRange(Pa.y1, Pa.y2), 0, 0, True);
Result := True;
Exit;
End;
End;
End;

Naum

2009-05-20 11:56:16

Lol, theres also another way I did it which was to use only 1 loop :).
With everything in it a bit like Narcle's

Wizzup?

2009-05-20 15:47:40

From: Narcle
and mine heh
Function CloseWindow : Boolean;
Var
Col : TIntegerArray;
A, B : TPointArray;
Pa : TBox;
I : Integer;
Begin
Col := [8042720, 4160933, {Skill}
6854059, 2902100, {Quest}
1909802, 9678265, {Main typ 1}
10070193, 2503226];{Main typ 2}
For I := 0 To 3 Do
Begin
FindColorsTolerance(A, Col[i*2], MSX1, MSY1, MSX2, MSY2, 1);
FindColorsTolerance(B, Col[i*2+1], MSX1, MSY1, MSX2, MSY2, 1);
If (High(CombineTPA(A, B)) > 0) Then
Begin
Pa := GetTPABounds(CombineTPA(A, B));
Mouse(RandomRange(Pa.x1, Pa.x2), RandomRange(Pa.y1, Pa.y2), 0, 0, True);
Result := True;
Exit;
End;
End;
End;


Try to use CombineTPA only once :)

Nava2

2009-05-20 16:58:39

Function CloseWindow : Boolean;
Var
Col : TIntegerArray;
A, B : TPointArray;
Pa : TBox;
I : Integer;
Begin
Col := [1909802, 9678265, {Main type 1}
10070193, 2503226, {Main type 2}
8042720, 4160933, {Skill}
6854059, 2902100]; {Quest}
For I := 0 To 3 Do
Begin
FindColorsTolerance(A, Col[i*2], MSX1, MSY1, MSX2, MSY2, 1);
FindColorsTolerance(B, Col[i*2+1], MSX1, MSY1, MSX2, MSY2, 1);
If ((High(a) + High(b)) > 0) Then
Begin
Pa := GetTPABounds(CombineTPA(A, B));
Mouse(RandomRange(Pa.x1, Pa.x2), RandomRange(Pa.y1, Pa.y2), 0, 0, True);
Result := True;
Exit;
End;
End;
End;

I fixed the two Combine TPA's, no need as Wizzup said. And rearranged the colours, might as well put the most common ones first.

Naum

2009-05-20 18:23:33

There was an error, so I fixed it abit, also MainType 2 is the least commonest one ;). So I re - ordered them :)

Function CloseWindow : Boolean;
Var
Col : TIntegerArray;
A, B : TPointArray;
Pa : TBox;
I : Integer;

Begin
Col := [1909802, 9678265, {Main typ 1}
8042720, 4160933, {Skill}
6854059, 2902100, {Quest}
10070193, 2503226]; {Main typ 2}
For I := 0 To (High(Col) Div 2) Do
Begin
FindColorsTolerance(A, Col[i*2], MSX1, MSY1, MSX2, MSY2, 1);
FindColorsTolerance(B, Col[i*2+1], MSX1, MSY1, MSX2, MSY2, 1);
If ((High(a) + High(b)) > 0) Then
Begin
Pa := GetTPABounds(CombineTPA(A, B));
Mouse(RandomRange(Pa.x1, Pa.x2), RandomRange(Pa.y1, Pa.y2), 0, 0, True);
Result := (Pa.x1 >= 100);
Exit;
End;
End;
End;

Nadeem

2009-05-20 19:21:38

lol, again gj! xD I'll be using this in my scripts soon. Btw, has this been added to SRL yet?



~NS

Narcle

2009-05-20 23:52:47

From: Wizzup?
Try to use CombineTPA only once :)


Yeah I thought about it, then I didn't care.

noidea

2009-05-21 00:20:08

Lol, battle of the Close windows :p

Nava2

2009-05-21 14:44:20

From: noidea
Lol, battle of the Close windows :p


It creates the best one.

Question, are the placement of boxes static? For sure, they are always in the right hand corner though, yes?

Naum

2009-05-21 16:02:38

Yup, except for sounds, which is in the middle. The Pa.X co-ord is always greater than 100 which Is why I've used that as a result :)
I guess you could lower the search area. Except that the colours I have used are only found where the box is, which means that it reduces the number of occurances.

Ofcourse the colors I have used are unique but are only 2*2 pixels, so they might change in which case you might have to use the brown color instead of the white pixel and use a RemovePointsInBox outside the close sign. However this may be slower, whereas; the first one finds it in one click.


Updated first post :)

Nava2

2009-05-21 19:28:37

function CloseWindow: Boolean;
var
Col: TIntegerArray;
A, B: TPointArray;
Pa: TBox;
I: Integer;
begin
Col := [1909802, 9678265, {Main typ 1}
8042720, 4160933, {Skill}
6854059, 2902100, {Quest}
10070193, 2503226]; {Main typ 2}
for I := 0 to 3 do
begin
FindColorsTolerance(A, Col[i*2], MSX1, MSY1, MSX2, MSY2, 1);
FindColorsTolerance(B, Col[i*2+1], MSX1, MSY1, MSX2, MSY2, 1);
if ((High(a) + High(b)) > 0) then
begin
Pa := GetTPABounds(CombineTPA(A, B));
Result := (Pa.x1 >= 100);
if Result then
begin
Mouse(RandomRange(Pa.x1, Pa.x2), RandomRange(Pa.y1, Pa.y2), 0, 0, True);
Exit;
end;
end;
end;
end;

Moar fixes.

I THINK I'm satisfied.

Naum

2009-05-21 19:36:04

Yup it works :)

Nava2

2009-05-22 07:03:16

The dev svn has the finished product. One thing, what is an example of a type 2 window?

Da 0wner

2009-05-22 07:18:25

From: Nava2
So, mine works?

If so, I will commit mine, but I won't take any credit. You did it :) I just cleaned.. got out the broom etc.


From: Text.scar
function CloseWindow: Boolean;
By: NaumanAkhlaQ, Narcle, and Nava2

:rolleyes:?

Naum

2009-05-22 11:48:16

lol, type 2 is the 'Equipment you keep on death' window, the closebox is bigger and has a different black color :)

Also Da0wner these guys did modify it alot :).

Btw, are you sure that the finished version works ?

Edit: Won't all the TPA sorting make it slower in the final version. The first version finds the window accurately from what I know

Edit2: You might want to change the contents of Text.scar ;), becuase it still says procedure closewindow

Nava2

2009-05-22 15:39:33

Nah the sorting is really quick. At max, only two hundred points. I just need to check the type two one.

The others all work great.

I had to change your colours nauman so that it closes the bank as well. One of your colours was the background of the scroll bar.

Naum

2009-05-22 15:55:30

Whoops didn't test it on the bank, my bad :(

Sir R. M8gic1an

2009-05-22 16:51:37

wouldn't combineTPA give an error if one of the TPAs is empty? Try…Except perhaps?

edit:

if ((High(a) > 0)and(High(b) > 0)) then
begin
Pa := GetTPABounds(CombineTPA(A, B));
Result := (Pa.x1 >= 100);

//or

if ((High(a) + High(b)) > 0) then
begin
try Pa := GetTPABounds(CombineTPA(A, B)); except exit; end;
Result := (Pa.x1 >= 100);
~RM

Naum

2009-05-22 17:02:13

I dont think so, it will combine 0 and whatever it should not result an error becuase it is used in findfight aswell :). Apart from that I use it in a procedure where usually 0 comes from combining two TPA's (which I have yet to fix :p) but the script still carries on.

Naum

2009-05-22 18:52:01

PLEASE READ, THE CLOSE WINDOW IN SRL OPENDEV DOESN'T WORK FOR THE SKILLS WINDOW atm.

Da 0wner

2009-05-23 02:02:32

CombineTPA does not error if there is an empty TPA.

Nava2

2009-05-23 04:41:00

Ugh I'm trying to fix this.. there are more issues than anticipated.

Naum

2009-05-23 10:28:08

Works fine good job :)