SRL Archive - SRL Archives

Deposit Fix


Richard

2009-04-18 03:09:46

I saw a thread with someone saying the deposit was clicking "deposit-x" instead of "deposit-all" so I make a quick fix:

Procedure Deposit(SlotFrom, SlotTo: Integer; vType: Variant);

Var
DepositX: Boolean;
All: Variant;
I, T, x, y: Integer;

Begin
If Not BankScreen Then
Exit;
If vType = 2 Then
srl_Warn('Deposit', '2 now means store per 2, not ''All''', 15);
DepositX := False;
Case VarType(vType) Of
3: Begin
DepositX := InIntArray([1, 5, 10], vType);
If vType = 1 Then
All := False
Else
All := True;
End;
11: All := vType;
End;
For I := SlotFrom To SlotTo Do
Begin
If Not ExistsItem(I) Then
Continue;
MouseItem(I, Not All);
If DepositX Then
Begin
ChooseOption('Deposit-X');
T := GetSystemTime;
While (Not FindColor(x, y, 8388608, MCX1, MCY1, MCX2, MCY2)) And (GetSystemTime - T < 3000) Do
Wait(100);
TypeSend(vType);
End Else If VarType(vType) = 3 Then
ChooseOption('Deposit-' + vType)
Else
ChooseOption('Deposit-All');
T := GetSystemTime;
Wait(RandomRange(200, 300));
While ExistsItem(I) And (GetSystemTime - T < 2000) Do
Wait(50);
End;
End;

mormonman

2009-04-18 03:32:33

its doing the same with withdraw. What did you change?

Richard

2009-04-18 03:44:16

DepositX := Not InIntArray([1, 5, 10], vType);

to

DepositX := InIntArray([1, 5, 10], vType);

I'll look into the withdraw function, I only knew about the deposit one.

Cazax

2009-04-18 03:45:05

SRL should also check 'Withdraw/Deposit - Last number entered' so for example every time a script withdraws or deposits it will look more human like or make it faster. I used that once in my clay softener, few seconds do count :)

Richard

2009-04-18 03:50:01

That is genius!

So wouldn't it go something like this:

Procedure CazaxCleverness(number: Integer);
B: Boolean;
Begin
If not(B) then
Begin
Mouse({Item coords here});
ChooseOption('X');
TypeSend(IntToStr(number);
B := True;
end else
Begin
Mouse({Item coords here});
ChooseOption(IntToStr(number));
end;
end;

I know thats a bad version, but you get the general gist.

I have it has not(B) because booleans are default false, am I right?

EDIT: With the withdraw function, are you sure you're typing 0 for it to withdraw all?

Cazax

2009-04-18 03:54:01

Lol :p but this is what I made(should be in SRL IMO):
Function IsOption(Text : String): Boolean;
Var
TPA : TPointArray;
Box : TBox;
X, Y : Integer;
Begin
FindColorsTolerance(TPA, 4674653, 0, 0, 764, 502, 0);
Box := GetTPABounds(TPA);
Result := FindText(X, Y, Text, UpChars, Box.X1, Box.Y1, Box.X2, Box.Y2);
End;
And then you call
If IsOption('26') Then
ChooseOption('26')//Just an example
Else
ChooseOption('X');
//TypeSend stuff...etc

Richard

2009-04-18 03:56:59

You don't need that cos ChooseOption is a boolean already :p.

So something more like this:

Procedure CazaxCleverness(number: integer);
Begin
If not(ChooseOption(IntToStr(number))) then
Begin
ChooseOption('X');
Typesend(IntToStr(number));
end;
end;

A lot simpler.

Cazax

2009-04-18 04:03:47

ChooseOption moves the mouse away making it to close the popup menu. That's why I made IsOption :)

Richard

2009-04-18 04:05:15

:o, didn't know that, might just have to break into that include as well.

I was trying my hand at the SRLPlayerForm but, like Zeph said, its now made me hate forms :p

EDIT: Here's a new way for the ChooseOptionMultiEx (which means you've have to set the 3rd param on everything to false if you wanted to use your method):

function ChooseOptionMultiEx(Texts: TStringArray; TextType: String; MoveMouseIfFalse: Boolean): Boolean;
var
B, T: TBox;
TPA, TextTPA: TPointArray;
aTPA: T2DPointArray;
I, C, H, HH, ii, L: Integer;
P: TPoint;
Occurances: array [0..4] of TPointArray;
Colors: TIntegerArray;
begin
Result := False;
GetClientDimensions(B.X2, B.Y2);
B.X1 := 0;
B.Y1 := 0;
FindColorsTolerance(TPA, 4674653, B.X1, B.Y1, B.X2, B.Y2, 0);
If Length(TPA) < 10 Then
Exit;
B.X2 := 0;
B.Y2 := 0;

P := TPA[0];
H := High(TPA);
Dec(H);
For I := 0 To H Do
If TPA[i].X = TPA[I+1].X - 1 Then
Begin
If C > 5 Then
Begin
B.X1 := P.X;
B.Y1 := P.Y;
Break;
End Else
C := C + 1;
End
Else
Begin
P := TPA[I + 1];
C := 0;
End;
If I = Length(TPA) Then
Begin
WriteLn('Choose Option Menu Getting Failed');
Exit;
End;
InvertTPA(TPA);
C := 0;
P := TPA[0];
H := High(TPA);
Dec(H);
For I := 0 To H Do
If TPA[i].X = TPA[I+1].X + 1 Then
Begin
If C > 5 Then
Begin
B.X2 := P.X;
B.Y2 := P.Y;
Break;
End Else
C := C + 1;
End Else
Begin
P := TPA[I + 1];
C := 0;
End;
If I = Length(TPA) Then
Begin
WriteLn('Choose Option Menu Getting Failed');
Exit;
End;

TPA := [];
Colors := [16777215, 4231423, 2070783, 65535, 16776960];
case LowerCase(TextType) of
'action', 'player': FindColorsTolerance(Occurances[0], Colors[0], B.x1, B.y1, B.x2, B.y2, 3);
'item' : begin
FindColorsTolerance(Occurances[1], Colors[1], B.x1, B.y1, B.x2, B.y2, 3);
FindColorsTolerance(Occurances[2], Colors[2], B.x1, B.y1, B.x2, B.y2, 3);
end;
'npc' : FindColorsTolerance(Occurances[3], Colors[3], B.x1, B.y1, B.x2, B.y2, 3);
'object': FindColorsTolerance(Occurances[4], Colors[4], B.x1, B.y1, B.x2, B.y2, 3);
else
begin
FindColorsTolerance(Occurances[0], 4674653, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(Occurances[1], clBlack, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(Occurances);
TPA := ReturnPointsNotInTPA(TPA, B);
end;
end;
if High(TPA) < 1 then TPA := MergeATPA(Occurances);
aTPA := SplitTPAEx(TPA, 7, 1);
SortATPAFromFirstPoint(aTPA, Point(B.x1, B.y1));

H := High(Texts);
L := High(aTPA);
// for i := 0 to L do
// DebugTPA(atpa[i], inttostr(i));

For I :=0 To H do
begin
TextTPA := LoadTextTPA(Texts[I], UpChars, HH);
for ii := 0 to L do
If FindTextTPAInTPA(HH, TextTPA, aTPA[ii], TPA) Then
Begin
T := GetTPABounds(TPA);
Result := True;
Mouse(B.X1 + 5, T.y1 - 2, B.X2 - B.X1 - 5, T.Y2 - T.Y1, True);
Exit;
End;
end;
If MouseMouseIfFalse then
MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
Wait(200 + Random(100));
end;

Nooby way of doing it :p

ZephyrsFury

2009-04-18 11:13:34

From: Richard
DepositX := Not InIntArray([1, 5, 10], vType);

to

DepositX := InIntArray([1, 5, 10], vType);

I'll look into the withdraw function, I only knew about the deposit one.


I don't know what the bug is but that won't fix it.


DepositX := Not InIntArray([1, 5, 10], vType);

makes sure that it will only click DepositX if there is a number which isn't 1, 5, or 10. 1, 5, and 10 have their own options rather than Deposit-X.

Richard

2009-04-18 13:42:12

From: ZephyrsFury
I don't know what the bug is but that won't fix it.


DepositX := Not InIntArray([1, 5, 10], vType);

makes sure that it will only click DepositX if there is a number which isn't 1, 5, or 10. 1, 5, and 10 have their own options rather than Deposit-X.


Well I was just changing little bits and that seemed to fix it.

Nava2

2009-04-18 16:36:17

As Zeph said your fix makes no sense, but it could be with my ChooseOption.

Also, what scar are you all using?

ZEPH POWA ABOOsEs!

EDIT: Grammar… :rolleyes:

Edit: Jerk, this is my post, not yours.

Dark Arcana

2009-04-18 17:25:13

I just noticed when I use depositall with Scar 3.15b it uses the deposit button, and when I use Scar 3.20 it right clicks on the item to deposit.

Frt

2009-04-18 17:36:50

From: Dark Arcana
I just noticed when I use depositall with Scar 3.15b it uses the deposit button, and when I use Scar 3.20 it right clicks on the item to deposit.


Could be due to different revisions.

Dark Arcana

2009-04-18 17:38:02

Nope they were both rev32, but it might just be me.

noidea

2009-04-19 02:58:57

No, ChooseOption seems to not be working. Just then, my script was trying to right click a tree and click cut, but it would mis it every time.

Edit: Just tried again, and it worked. Weird.
Edit2: Just restarted again, and it DIDNT work =\ I think its clicking like 1 pixel to low.
Edit3: it moves the mouse, its in the right spot to click, then it moves the mouse 1 or 2 pixels away and clicks. There for, missing the option.

Shuttleu

2009-04-19 03:24:09

like i said in my thread i made
it could have something to do with the ChooseOption
http://www.villavu.com/forum/showthread.php?t=44294

~shut

Nava2

2009-04-19 18:32:17

I think it is in my new chooseoption.

Try this:

{*******************************************************************************
function ChooseOptionMultiEx(Texts: TStringArray; TextType: String): Boolean;
By: Wizzup?, Nava2, and modified by N1ke!
Description: Finds Popup menu, then clicks on it.
Will look for the first string first and so on.
It will search for the Text Type you input valid arguments are
'action', 'player': The white text
'npc': The yellow text
'object': The cyan text
'all': Searches for all colors of text.
Will default to 'all'.
*******************************************************************************}
function ChooseOptionMultiEx(Texts: TStringArray; TextType: String): Boolean;
var
B, T: TBox;
TPA, TextTPA: TPointArray;
aTPA: T2DPointArray;
I, C, H, HH, ii, L: Integer;
P: TPoint;
Occurances: array [0..4] of TPointArray;
Colors: TIntegerArray;
begin
Result := False;
GetClientDimensions(B.X2, B.Y2);
B.X1 := 0;
B.Y1 := 0;
FindColorsTolerance(TPA, 4674653, B.X1, B.Y1, B.X2, B.Y2, 0);
If Length(TPA) < 10 Then
Exit;
B.X2 := 0;
B.Y2 := 0;

P := TPA[0];
H := High(TPA);
Dec(H);
For I := 0 To H Do
If TPA[i].X = TPA[I+1].X - 1 Then
Begin
If C > 5 Then
Begin
B.X1 := P.X;
B.Y1 := P.Y;
Break;
End Else
C := C + 1;
End
Else
Begin
P := TPA[I + 1];
C := 0;
End;
If I = Length(TPA) Then
Begin
WriteLn('Choose Option Menu Getting Failed');
Exit;
End;
InvertTPA(TPA);
C := 0;
P := TPA[0];
H := High(TPA);
Dec(H);
For I := 0 To H Do
If TPA[i].X = TPA[I+1].X + 1 Then
Begin
If C > 5 Then
Begin
B.X2 := P.X;
B.Y2 := P.Y;
Break;
End Else
C := C + 1;
End Else
Begin
P := TPA[I + 1];
C := 0;
End;
If I = Length(TPA) Then
Begin
WriteLn('Choose Option Menu Getting Failed');
Exit;
End;

TPA := [];
Colors := [16777215, 4231423, 2070783, 65535, 16776960];
case LowerCase(TextType) of
'action', 'player': FindColorsTolerance(Occurances[0], Colors[0], B.x1, B.y1, B.x2, B.y2, 3);
'item' : begin
FindColorsTolerance(Occurances[1], Colors[1], B.x1, B.y1, B.x2, B.y2, 3);
FindColorsTolerance(Occurances[2], Colors[2], B.x1, B.y1, B.x2, B.y2, 3);
end;
'npc' : FindColorsTolerance(Occurances[3], Colors[3], B.x1, B.y1, B.x2, B.y2, 3);
'object': FindColorsTolerance(Occurances[4], Colors[4], B.x1, B.y1, B.x2, B.y2, 3);
else
begin
FindColorsTolerance(Occurances[0], 4674653, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(Occurances[1], clBlack, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(Occurances);
TPA := ReturnPointsNotInTPA(TPA, B);
end;
end;
if High(TPA) < 1 then TPA := MergeATPA(Occurances);
aTPA := SplitTPAEx(TPA, 7, 1);
SortATPAFromFirstPoint(aTPA, Point(B.x1, B.y1));

H := High(Texts);
L := High(aTPA);
// for i := 0 to L do
// DebugTPA(atpa[i], inttostr(i));

For I :=0 To H do
begin
TextTPA := LoadTextTPA(Texts[I], UpChars, HH);
for ii := 0 to L do
If FindTextTPAInTPA(HH, TextTPA, aTPA[ii], TPA) Then
Begin
T := GetTPABounds(TPA);
Result := True;
Mouse(B.X1 + 5, T.y1 - 2, B.X2 - B.X1 - 5, T.Y2 - T.Y1 - 3, True);
Exit;
End;
end;

MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
Wait(200 + Random(100));
end;

I just made it so it doesn't click as low. As that seems to be the problem. Let me know please.

Shuttleu

2009-04-20 20:09:17

ok i will test right now

~shut

EDIT: that just makes my mouse go into a huge spasm