/
bankscreen.simba
773 lines (643 loc) · 18.6 KB
/
bankscreen.simba
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
(*
BankScreen
==========
This file stores all methods that are used in the bankscreen-iterface.
All methods here are called with the bankscreen ``BankScreen`` variable.
.. code-block:: pascal
Writeln(BankScreen.IsOpen());
*)
type
EBankButton = (bbSwap, bbInsert, bbItem, bbNote, bbPlaceholder, bbSearch,
bbDepositInv, bbDepositWorn, bbMenu, bbClose);
EBankLocation = (blYanille, blAlKharid,
blVarrockWest, blVarrockEast,
blFaladorEast, blFaladorWest);
EBankerColor = (bcBlue, bcGray);
TRSBankScreen = record (TInterfaceBase)
FSlots: TBoxArray;
FButtons: array [EBankButton] of TBox;
end;
TRSPinScreen = record (TInterfaceBase)
FSlots: TBoxArray;
end;
var
BankScreen: TRSBankScreen;
PinScreen: TRSPinScreen;
const
WITHDRAW_ALL = -1;
WITHDRAW_ALL_BUT_ONE = -2;
{$IFNDEF CodeInsight}
procedure TRSBankScreen.__Setup();
var
slotBounds:TBox = [73, 83, 456, 298];
TextBtn:TBox = [0,0,75,21];
IconBtn:TBox = [0,0,35,35];
begin
with Self do
begin
SetBounds(Box(16, 6, 503, 336));
SetName('Bankscreen');
SetStatic(True);
FSlots := slotBounds.Partition(6,8);
FSlots.ModifySide('x2',-16);
FSlots.ModifySide('y2',-4);
with Self.GetBounds() do
begin
FButtons[bbSwap] := TextBtn.OffsetEx([X1+5, Y2-26]);
FButtons[bbInsert] := TextBtn.OffsetEx([X1+81, Y2-26]);
FButtons[bbItem] := TextBtn.OffsetEx([X1+164, Y2-26]);
FButtons[bbNote] := TextBtn.OffsetEx([X1+240, Y2-26]);
FButtons[bbPlaceholder] := IconBtn.OffsetEx([X2-164, Y2-41]);
FButtons[bbSearch] := IconBtn.OffsetEx([X2-121, Y2-41]);
FButtons[bbDepositInv] := IconBtn.OffsetEx([X2-78, Y2-41]);
FButtons[bbDepositWorn] := IconBtn.OffsetEx([X2-42, Y2-41]);
FButtons[bbMenu] := Box(X2-36, Y1+42, X2-12, Y1+66);
FButtons[bbClose] := Box(X2-27, Y1+7, X2-7, Y1+27);
end;
end;
end;
procedure TRSPinScreen.__Setup();
begin
with Self do
begin
FSlots := Box(37, 107, 318, 320).Partition(3,3);
FSlots.ModifySide('x2',-30);
FSlots.ModifySide('y2',-6);
FSlots.Append(Box(309, 107, 372, 170));
end;
end;
{$ENDIF}
function TRSBankScreen._ExpectText(txt:String; B:TBox; font:TFontSet; cfg:TCompareRules; maxWait:Int32=6000): Boolean;
var
t:UInt64;
begin
t := GetTickCount64() + maxWait;
while GetTickCount64() < t do
if Pos(txt, ocr.Recognize(B, cfg, font)) <> 0 then
Exit(True)
else
Wait(20);
end;
function TRSBankScreen.IsUpText(SubStrs: TStringArray; WaitTime: UInt32 = 350): Boolean;
var
TimeOut: UInt64;
begin
Result := False;
TimeOut := GetTickCount64() + (WaitTime + Random(-20, 50));
while (TimeOut >= GetTickCount64()) do
begin
if (IsArrInStr(SubStrs, Self.GetUpText())) then
Exit(True);
Wait(Random(35, 75));
end;
end;
function TRSBankScreen.GetUpText(): String;
const
OCR_RULES_UPTEXT: TCompareRules = [-1, 85, True, 85];
var
client:T2DIntArray;
bmp:Int32;
begin
bmp := BitmapFromClient(mainscreen.UpTextArea);
FastReplaceColor(bmp, 2070783, 3424329);
//FastReplaceColor(bmp, 0, 3424329);
//ShowBitmap(bmp);
client := BitmapToMatrix(bmp);
Result := OCR.RecognizeEx(client, OCR_RULES_UPTEXT, UpFont);
FreeBitmap(bmp);
{$IFDEF UPTEXT_DEBUG}
srl.Writeln('UpText found: ' + Result);
{$ENDIF}
end;
procedure TRSBankScreen._Debug();
var
BMP, i, c: Integer;
begin
BMP := BitmapFromClient(GetClientBounds());
c := 255;
for i:=0 to High(FButtons) do
begin
DrawTPABitmap(BMP, EdgeFromBox(fButtons[i]), c);
c := i + ((c * 128) and $FFFFFF);
WriteLn(c);
end;
for i:=0 to High(FSlots) do
DrawTPABitmap(BMP, EdgeFromBox(fSlots[i]), $00FF00);
ShowBitmap(BMP);
FreeBitmap(BMP);
end;
function TRSBankScreen._Find(): Boolean;
const
TEXT_COL = 2070783;
var
p: TPoint;
begin
Result := srl.FindText(p, 'Rearrange mode', 'SmallChars', TEXT_COL, 0, Box(22,292,378,330));
if not Result then
Result := srl.FindText(p, 'Withdraw as', 'SmallChars', TEXT_COL, 0, Box(22,292,378,330));
end;
(*
BankScreen.IsOpen
~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.IsOpen(): Boolean;
returns True if the bankscreen is open
*)
function TRSBankScreen.IsOpen(WaitTime: UInt32 = 0): Boolean;
var
t: UInt64;
begin
t := GetTickCount64() + WaitTime;
repeat
if (Self._Find()) then
Exit(True)
else if (WaitTime > 0) then
Wait(Random(25, 50));
until (GetTickCount64() >= t);
end;
function TRSBankScreen.OpenAt(pt: TPoint): Boolean;
var
Text: String;
begin
Mouse.Move(pt);
if (MainScreen.IsUpText(['Bank Bank', 'Bank booth', 'to Banker', 'nk booth'])) then
begin
Wait(Random(50, 80));
Text := Mainscreen.GetUpText();
if (Pos('booth', Text) > 0) and (Random(3) = 0) then
Result := Mouse.Click(ctRed)
if (not Result) then
Result := (ChooseOption.Open()) and (ChooseOption.Select(['Bank Bank']));
if (Result) then
begin
Minimap.WaitFlag();
Result := Bankscreen.IsOpen(Random(4000, 5000));
end;
end;
end;
function TRSBankScreen._OpenYanille: Boolean;
const
colMiddle: TCTS2Color = [5660003, 10, 0.63, 0.79]; // grey
colEdge: TCTS2Color = [277329, 10, 0.07, 2.23]; // brown
var
TPA, Edge: TPointArray;
ATPA: T2DPointArray;
i, j, W, H, Matches: Integer;
begin
if (srl.FindColors(TPA, colMiddle, Mainscreen.GetBounds()) > 20) then
begin
ATPA := ClusterTPAEx(TPA, 3, 3);
SortATPAFromMidPoint(ATPA, Mainscreen.GetMiddle());
for i := 0 to High(ATPA) do
begin
ATPA[i].MinAreaRectEx(W, H);
if (W > 15) and (W < 30) and (H >= 6) and (H <= 15) then
begin
Matches := 0;
Edge := FindTPAEdges(ATPA[i]);
for j := 0 to High(Edge) do
if (NearbyPointInArrayEx(Edge[i], 1, 1, ATPA[i])) then
if (Inc(Matches) >= 40) then
Break;
if (Matches >= 30) and (Self.OpenAt(MiddleTPA(ATPA[i]).Random(-5, 5))) then
Exit(True);
end;
end;
end;
end;
function TRSBankScreen._OpenNPC(Typ: EBankerColor; Area: TBox): Boolean;
const
colBlue: TCTS2Color = [4533549, 18, 0.75, 0.96];
colGray: TCTS2Color = [6513771, 9, 0.35, 0.10];
var
TPA: TPointArray;
ATPA: T2DPointArray;
i: Integer;
b: TBox;
begin
case Typ of
bcBlue: srl.FindColors(TPA, colBlue, Area);
bcGray: srl.FindColors(TPA, colGray, Area);
end;
if (Length(TPA) > 0) then
begin
ATPA := ClusterTPAEx(TPA, 3, 3);
SortATPAFromMidPoint(ATPA, MiddleBox(Area));
for i := 0 to High(ATPA) do
begin
b := GetTPABounds(ATPA[i]);
if (b.Width >= 8) and (b.Height >= 8) then
if (Self.OpenAt(MiddleTPA(ATPA[i]).Random(-4, -4))) then
Exit(True);
end;
end;
end;
(*
BankScreen._MagicalBankerFinder
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen._MagicalBankerFinder(BoothTopColor: TCTS2Color; BankerColor: EBankerColor; Offset: TPoint): Boolean;
Calculates and finds where a bank NPC should be based from the bank booth.
*)
function TRSBankScreen._MagicalBankerFinder(BoothTopColor: TCTS2Color; BankerColor: EBankerColor; Offset: TPoint): Boolean;
var
Rect: TRectangle;
TPA: TPointArray;
ATPA: T2DPointArray;
b: TBox;
i, W, H: Integer;
pt, Mid: TPoint;
begin
if (srl.FindColors(TPA, BoothTopColor, Mainscreen.GetBounds()) > 5) then
begin
ATPA := ClusterTPAEx(TPA, 3, 3);
SortATPAFromMidPoint(ATPA, Mainscreen.GetMiddle());
for i := 0 to High(ATPA) do
begin
Mid := ATPA[i].MinAreaRectEx(W, H).Mean();
if (W >= 15) and (W <= 30) and (H <= 8) then
begin
pt := [Mid.X + Offset.X, Mid.Y + Offset.Y];
pt := pt.Rotate(Minimap.GetCompassAngle(False), Mid);
b := [pt.X - 28, pt.Y - 28, pt.X + 28, pt.Y + 28];
b.LimitTo(Mainscreen.GetBounds());
if (Self._OpenNPC(BankerColor, b)) then
Exit(True);
end;
end;
end;
end;
(*
BankScreen.Open
~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.Open(Loc: EBankLocation): Boolean;
Opens the bankscreen at the selected bank location.
*)
function TRSBankScreen.Open(Loc: EBankLocation): Boolean;
begin
if (Self.isOpen()) then
Exit(True);
case Loc of
blYanille: Exit(Self._OpenYanille());
blVarrockWest: Exit(Self._MagicalBankerFinder([4144964, 10, 0.47, 0.28], bcBlue, [30, 0]));
blVarrockEast: Exit(Self._MagicalBankerFinder([2171173, 10, 0.00, 0.50], bcBlue, [0, 40]));
blFaladorEast: Exit(Self._MagicalBankerFinder([2171173, 10, 0.00, 0.50], bcGray, [0, 40]));
blFaladorWest: Exit(Self._MagicalBankerFinder([4144964, 10, 0.47, 0.28], bcGray, [0, 40]));
blAlKharid: Exit(Self._MagicalBankerFinder([4144964, 10, 0.47, 0.28], bcGray, [-30, 0]));
end;
end;
(*
BankScreen.Close
~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.Close(): Boolean;
Closes the bankscreen, returns True on success
*)
function TRSBankScreen.Close(): Boolean;
var
t: UInt64;
begin
if (not Self.IsOpen()) then
Exit(True);
if (srl.CloseInterfacesWithEscape) then
begin
Keyboard.PressKey(VK_ESCAPE);
t := GetTickCount64() + Random(4000, 5000);
while (t > GetTickCount64()) do
begin
if (not Self.IsOpen()) then
Exit(True);
end;
srl.ToggleCloseInterfacesWithEscape(False);
end;
Self.ClickButton(bbClose);
t := GetTickCount64() + Random(4000, 5000);
while (t > GetTickCount64()) do
begin
if (not Self.IsOpen()) then
Exit(True);
end;
end;
(*
BankScreen.ClickButton
~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.ClickButton(btn: EBankButton; clickType: Integer = mouse_Left): Boolean;
Toggles the button
*)
function TRSBankScreen.ClickButton(btn: EBankButton; clickType: Integer = mouse_Left): Boolean;
begin
Result := Self.IsOpen();
if (Result) then
Mouse.Click(Self.fButtons[btn], clickType);
end;
(*
BankScreen.IsToggled
~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.IsToggled(btn: EBankButton; minMatch:Int32=50): Boolean;
Checks if the given button is red/toggled
*)
function TRSBankScreen.IsToggled(btn: EBankButton; minMatch:Int32=50): Boolean;
begin
Result := Self.IsOpen();
if Result then
Result := CountColorTolerance(1777019, Self.fButtons[btn], 30) > minMatch;
end;
{ Scrolls up to the top of the bank, so slots are aligned.}
procedure TRSBankScreen.FixSlots();
var
t: UInt64;
begin
if (not Self.IsOpen()) then
Exit;
t := GetTickCount64() + Random(7000, 8000);
while (GetColor(491, 99) <> 65536) and (t > GetTickCount64()) do
Mouse.Scroll(IntToBox(73, 83, 497, 292), Random(2, 5), False);
end;
function TRSBankScreen.GetSlotBox(Slot: UInt32): TBox;
begin
if InRange(Slot, 0,High(Self.FSlots)) then
Result := fSlots[Slot]; // range check.
end;
(*
BankScreen.ItemIn
~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.ItemIn(Slot: UInt32): Boolean;
Returns True if there's an item in the given slot.
*)
function TRSBankScreen.ItemIn(Slot: UInt32): Boolean;
begin
Result := CountColor($010000, self.GetSlotBox(slot)) <> 0;
end;
(*
BankScreen.DepositAll
~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.DepositAll(): Boolean;
Depositis your inventory by clicking the deposit inventory button
*)
function TRSBankScreen.DepositAll(): Boolean;
begin
if (Inventory.Count = 0) then
Exit(True);
Result := Self.ClickButton(bbDepositInv);
end;
(*
Depeosit a single item, or all of it's kind from inventory.
*)
function TRSBankScreen.DepositItem(slot:Int32; depositAll:Boolean): Boolean;
begin
if not(self.IsOpen()) or (not InRange(slot,0,27)) then
Exit();
Result := not inventory.IsSlotUsed(slot);
if not(Result) then
begin
Mouse.Move(inventory.GetSlotBox(slot));
srl.NormalWait(30,70);
if depositAll then
begin
ChooseOption.Open();
Exit(ChooseOption.Select(['Deposit-All']));
end else
begin
Mouse.Click(mouse_left);
Result := True;
end;
end;
end;
(*
Deposit all your items, retries two times.
*)
function TRSBankScreen.Deposit(slotArr:TIntegerArray): Boolean;
var
i,j:Int32;
t:UInt64;
begin
if not(self.IsOpen()) then
Exit();
for j:=0 to 1 do
begin
Result := True;
for i:=0 to High(slotArr) do
if inventory.IsSlotUsed(slotArr[i]) then
begin
self.DepositItem(slotArr[i], False);
srl.NormalWait(6,25);
end;
for i:=0 to High(slotArr) do
if InRange(slotArr[i],0,27) then
begin
t := GetTickCount64() + 200;
repeat
Result := not(inventory.IsSlotUsed(slotArr[i]));
until (GetTickCount64() > t) or Result;
end;
if Result then
Break
else
srl.NormalWait(180,265); //wait a bit before round 2
end;
end;
(*
BankScreen.RearrangeMode
~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.RearrangeMode(mode:EBankButton): Boolean;
Changes the way items are moved around, valid options are ``bbSwap`` and ``bbInsert``.
*)
function TRSBankScreen.RearrangeMode(mode:EBankButton): Boolean;
begin
if not(mode in [bbSwap,bbInsert]) then
RaiseException('Invalid rearrange mode: '+ToString(mode));
Result := self.IsToggled(mode) or Self.ClickButton(mode);
end;
(*
BankScreen.WithdrawAs
~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.WithdrawAs(mode:EBankButton): Boolean;
Changes the way items are withdrawn. Valid options are ``bbItem`` and ``bbNote``
*)
function TRSBankScreen.WithdrawAs(mode:EBankButton): Boolean;
begin
if not(mode in [bbItem,bbNote]) then
RaiseException('Invalid withdraw mode: '+ToString(mode));
Result := self.IsToggled(mode) or Self.ClickButton(mode);
end;
(*
BankScreen.Search
~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.Search(item:String): Boolean;
Search for an item using the search option in the bank.
*)
function TRSBankScreen.Search(item:String): Boolean;
const
TEXT_AREA:TBox = [70,394,450,412];
begin
if (not Self.IsOpen()) then
Exit(False);
if not(self.IsToggled(bbSearch) or Self.ClickButton(bbSearch)) then
Exit(False);
Result := self._ExpectText('Show items',TEXT_AREA,UpFont,FontSetting(0,2));
keyboard.Send(item,VK_RETURN);
end;
(*
BankScreen.Withdraw
~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function TRSBankScreen.Withdraw(slot, amount:Int32; upText:TStringArray=[]; withdrawMode:EBankButton=bbItem): Boolean;
Withdraws the the amount ``amount`` from the bank slot ``slot``. If it fails to withdraw it will return False
Extra vaild constants for ``amount`` are:
- ``WITHDRAW_ALL = -1;``
- ``WITHDRAW_ALL_BUT_ONE = -2;``
.. note:: by slacky
Example:
.. code-block:: pascal
// withdraw 28 items from slot 1 if uptext matches
bankscreen.Withdraw(1, 28, ['Iron']);
// withdraw 500 items as notes from slot 1 if uptext matches
bankscreen.Withdraw(1, 500, ['Iron'], bbNote);
// withdraw all items from slot 10 if uptext matches
bankscreen.Withdraw(10, WITHDRAW_AMOUNT_ALL, ['Iron']);
// withdraw 28 items from slot 1 and will *ignore* uptext
bankscreen.Withdraw(1, 28);
*)
function TRSBankScreen.Withdraw(slot, amount:Int32; upText:TStringArray=[]; withdrawMode:EBankButton=bbItem): Boolean;
var
b:TBox;
const
TEXT_AREA:TBox = [200,393,450,412];
begin
if (not Self.IsOpen()) then
Exit(False);
b := self.GetSlotBox(slot);
if not self.ItemIn(slot) then
Exit(False);
self.WithdrawAs(withdrawMode);
srl.NormalWait(90,170);
mouse.Move(b);
srl.NormalWait(90,170);
if (upText <> []) and not(BankScreen.IsUptext(upText)) then
Exit(False);
if (amount = 1) then
begin
Mouse.Click(mouse_left);
Exit(True);
end else
begin
ChooseOption.Open();
if amount = WITHDRAW_ALL then
Result := ChooseOption.Select(['Withdraw-All'])
else if amount = WITHDRAW_ALL_BUT_ONE then
Result := ChooseOption.Select(['Withdraw-All-but'])
else if ChooseOption.Select(['Withdraw-'+ToString(amount)+' '],,False) then // space after amount so it can't find "2" in 28
Result := True
else if ChooseOption.Select(['Withdraw-X']) and
self._ExpectText('Enter amount',TEXT_AREA,UpFont,FontSetting(0,2)) then
begin
keyboard.Send(ToString(amount),VK_RETURN);
Result := True;
end;
end;
end;
function TRSPinScreen._Find(): Boolean;
var
P: TPoint;
begin
Result := srl.FindText(P, 'Bank of RuneScape', 'UpChars07_s', 255, 0, Box(21, 30, 151, 50));
end;
function TRSPinScreen.IsOpen(WaitTime: UInt32 = 0): Boolean;
var
t: UInt64;
begin
t := GetTickCount64() + WaitTime;
repeat
if (Self._Find()) then
Exit(True)
else
if (WaitTime > 0) then
Wait(Random(25, 50));
until (GetTickCount64() >= t);
end;
function TRSPinScreen.EnterPin(): Boolean;
var
I, J, F, Start: Int32;
TSA: TStringArray = ['First', 'Now', 'Time', 'Finally'];
t: UInt64;
P: TPoint;
function __EnterPin(): Boolean;
begin
T := GetTickCount64() + RandomRange(4000, 8000);
while (CountColor(32767, 37, 107, 372, 318) <> 322) do//waiting for the numbers to load
begin
Wait(RandomRange(100, 400));
if (GetTickCount64() > T) then
Exit(False);
end;
for Start := 1 to 4 do
begin
if srl.FindText(p, TSA[Start - 1], 'UpChars07_s', Box(160, 80, 350, 100)) then
Break;
end;
for J := Start to 4 do
begin
p := [0, 0];
if srl.FindText(p, Players.GetCurrent()^.BankPin[J], 'UpChars07_s', Box(37, 107, 372, 318)) then
begin
for I := Low(FSlots) to High(FSlots) do
begin
if PointInBox(p, FSlots[I]) then
begin
Mouse.Click(FSlots[I], mouse_Left);
Break;
end;
end;
end else
begin
GetMousePos(p.X, p.Y);
for I := Low(FSlots) to High(FSlots) do
begin
if PointInBox(p, FSlots[I]) then
begin
Mouse.Click(FSlots[I], mouse_Left);
Break;
end;
end;
end;
T := GetTickCount64() + RandomRange(4000, 8000);
while srl.FindText(p, TSA[J - 1], 'UpChars07_s', Box(160, 80, 350, 100)) and (CountColor(32767, 37, 107, 372, 318) <> 332) do
begin
Wait(RandomRange(300, 600));
if (GetTickCount64 > T) then
Exit(False);
end;
Wait(RandomRange(600, 1200));
end;
end;
begin
if not __EnterPin() then
Exit(False);
t := GetTickCount64() + RandomRange(15000, 20000);
while not BankScreen.IsOpen() do
begin
if ChatBox.ClickContinue() then
begin
Inc(F);
if (F > 2) then
srl.WriteLn('Your pin is wrong!', dtFatal);
__EnterPin();
end;
Wait(RandomRange(40, 200));
if (GetTickCount64() > t) then
Exit(False);
end;
Result := BankScreen.IsOpen(RandomRange(2000, 6000));
end;
begin
BankScreen.__Setup();
PinScreen.__Setup();
end;