-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBanking.scar
233 lines (197 loc) · 8.41 KB
/
Banking.scar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
{==============================================================================\
| MSI Group Scripting Include |
| Banking.scar |
|==============================================================================|
| All Banking related routines. |
| |
| * function MSI_OpenBank(): Boolean; * by Coh3n |
| * function MSI_Deposit(): Boolean; * by Naum |
| * function MSI_Withdraw(): Boolean; * by Naum |
| |
\_____________________________________________________________________________}
{******************************************************************************}
{ function MSI_OpenBank(which, walkIndex: Integer; tPin: String): Boolean; }
{ By: Coh3n }
{ Date: 10 June 2010 }
{ Description: Opens the bank 'which' (refer to bank constants). Will attempt }
{ to relocate if bank isn't found after 15 tries. }
{******************************************************************************}
function MSI_WalkToColorIndex(index: Integer): Boolean; forward;
function MSI_OpenBank(which, walkIndex: Integer; tPin: String): Boolean;
var
theBank: TMSObject;
t, x, y: Integer;
begin
if (not LoggedIn) then
Exit;
theBank := MSI_GetObject(which);
t := 0;
repeat
Inc(t);
if (MSI_FindObject(theBank, ClickRight)) then
begin
if (PinScreen) then
if (Length(tPin) = 4) then
InPin(tPin);
Result := WaitFunc(@BankScreen, 200, 10000);
end;
if (t = 15) then
if not (MSI_WalkToColorIndex(walkIndex)) then
begin
SymbolAccuracy := BANK_SYMBOL_ACCURACY;
if (FindSymbol(x, y, 'bank')) then
begin
Mouse(x, y, 5, 5, True);
FFlag(5);
Wait(RandomRange(250, 750));
end;
SymbolAccuracy := 0.8;
end;
until(Result or (t >= 30));
if (Result) then
MSI_Debug('MSI_OpenBank', 'Successfuly opened bank: ' + theBank.Name, DEBUG_FUNCTIONS)
else
MSI_Debug('MSI_OpenBank', 'Failed to open bank - ' + theBank.Name, DEBUG_FUNCTIONS);
end;
{******************************************************************************}
{ Function MSI_Deposit(Items, Amount : TIntegerArray) : Boolean }
{ By: Naum }
{ Date: 10 June 2010 }
{ Description: Deposits an Item using the TItem type. Set Amount to [] to }
{ deposit all of every item }
{******************************************************************************}
Function MSI_Deposit(Items, Amount: TIntegerArray) : Boolean;
Var ATPA2 : Array Of TPointArray; //The length is the same as items.colors
ATPA : T2DPointArray;
I, BX, BY, II, DX, DY, XX, YY, Tol : Integer;
BitmapCheck, TextCheck, DTMCheck : Boolean;
TB : TBox;
Begin
if (not LoggedIn) then
Exit;
if (Length(Amount) <= 0) then
begin
SetLength(Amount, Length(Items));
for i := 0 to High(Amount) do
Amount[i] := 28;
end;
If Not WaitFunc(@BankScreen, 70, 1300) Then //Just in case
Exit
Else begin
MSI_LoadItems(Items);
For I := 0 To High(Items) Do
Begin
Tol := 0;
Repeat
BitmapCheck := FindBitmapToleranceIn(MSI_Item[Items[I]].BMP, BX, BY, MIX1, MIY1, MIX2, MIY2, Tol);
IncEx(Tol, INC_TOL);
Until(BitmapCheck) Or (Tol >= MAX_TOL);
If Not BitmapCheck Then
Begin
SetArrayLength(ATPA2, High(MSI_Item[Items[I]].Colors)+1)
For II := 0 To High(MSI_Item[Items[I]].Colors) Do
FindColorsTolerance(ATPA2[II], MSI_Item[Items[I]].Colors[II], MIX1, MIY1, MIX2, MIY2, 15);
ATPA2[0] := MergeATPA(ATPA2);
ATPA := SplitTPA(ATPA2[0], 5);
For II := 0 To High(ATPA) Do
Begin
TB := IntToBox(ATPA[II][0].x - 50, ATPA[II][0].y - 50,
ATPA[II][0].x + 43, ATPA[II][0].y + 44);
DTMCheck := DTMRotated(MSI_Item[Items[I]].DTM, DX, DY, TB.x1, TB.y1, TB.x2, TB.y2);
MMouse(DX, DY, 2, 3);
TextCheck := WaitUpTextMulti(MSI_Item[Items[I]].UpText, 150+Random(30));
If TextCheck Then Break;
End;
End;
If BitmapCheck Or TextCheck Then
Begin
If BX + BY > 0 Then
MMouse(BX, BY, 2, 3);
TextCheck := WaitUpTextMulti(MSI_Item[Items[I]].UpText, 1200);
GetMousePos(XX, YY);
Result := TextCheck;
If Result Then
Begin
Mouse(XX, YY, 0, 0, False);
If Amount[I] >= 28 Then
Result := WaitOption('-All', 1200);
If InIntArray([1, 5, 10], Amount[I]) Then
Result := WaitOption('-'+IntToStr(Amount[I]), 1200)
Else
Begin
If WaitOption('-X', 900) Then
If WaitColor(254, 401, ClBlack, 0, 1200) Then
TypeSend(IntToStr(Amount[I]));
Result := True;
End;
If Result Then
MSI_Debug('MSI_Deposit', 'Deposited Amount '+IntToStr(Amount[I])+
' Of Item : ''' +MSI_Item[Items[I]].Name+'''', DEBUG_SMALL_DETAILS);
End;
End;
End;
end;
End;
{******************************************************************************}
{ Function MSI_Withdraw(Items, Amount : TIntegerArray) : Boolean }
{ By: Naum }
{ Date: 10 June 2010 }
{ Description: Widthraws an Item using the TItem type }
{******************************************************************************}
Function MSI_Withdraw(Items, Amount : TIntegerArray) : Boolean;
Var ATPA2 : Array Of TPointArray; //The length is the same as items.colors
ATPA : T2DPointArray;
I, BX, BY, II, DX, DY, XX, YY, Tol : Integer;
BitmapCheck, TextCheck, DTMCheck : Boolean;
WithdrawP : TPoint;
TB : TBox;
Begin
if (not LoggedIn) then
Exit;
If Not WaitFunc(@BankScreen, 70, 1300) Then //Just in case
Exit
Else begin
MSI_LoadItems(Items);
For I := 0 To High(Items) Do
Begin
Tol := 0;
Repeat
BitmapCheck := FindBitmapToleranceIn(MSI_Item[Items[I]].BMP, BX, BY, MBX1, MBY1, MBX2, MBY2, Tol);
IncEx(Tol, INC_TOL);
Until(BitmapCheck) Or (Tol >= MAX_TOL);
If Not BitmapCheck Then
Begin
SetArrayLength(ATPA2, High(MSI_Item[Items[I]].Colors)+1)
For II := 0 To High(MSI_Item[Items[I]].Colors) Do
FindColorsTolerance(ATPA2[II], MSI_Item[Items[I]].Colors[II], MBX1, MBY1, MBX2, MBY2, 15);
ATPA2[0] := MergeATPA(ATPA2);
ATPA := SplitTPA(ATPA2[0], 5);
For II := 0 To High(ATPA) Do
Begin
TB := IntToBox(ATPA[II][0].x - 50, ATPA[II][0].y - 50,
ATPA[II][0].x + 50, ATPA[II][0].y + 50);
DTMCheck := DTMRotated(MSI_Item[Items[I]].DTM, DX, DY, TB.x1, TB.y1, TB.x2, TB.y2);
MMouse(DX, DY, 2, 3);
TextCheck := WaitUpTextMulti(MSI_Item[Items[I]].UpText, 150+Random(30));
If TextCheck Then Break;
End;
End;
If BitmapCheck Or TextCheck Then
Begin
If BX + BY > 0 Then
MMouse(BX, BY, 2, 3);
TextCheck := WaitUpTextMulti(MSI_Item[Items[I]].UpText, 1200);
GetMousePos(XX, YY);
Result := TextCheck;
If Result Then
Begin
MSI_Item[Items[I]].ItemP := Point(XX, YY);
WithDrawP := MSTPointToBankPoint(Point(XX, YY));
Withdraw(WithDrawP.X, WithDrawP.Y, Amount[I]);
MSI_Debug('MSI_Withdraw', 'Withdrew Amount '+IntToStr(Amount[I])+
' Of Item : ''' +MSI_Item[Items[I]].Name+'''', DEBUG_SMALL_DETAILS);
End;
End;
End;
end;
End;