forked from crazyeyes-pb/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAaimistersEssenceMiner.java
More file actions
2220 lines (2062 loc) · 68 KB
/
AaimistersEssenceMiner.java
File metadata and controls
2220 lines (2062 loc) · 68 KB
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
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @author Aaimister
* @version 1.39 ©2010-2011 Aaimister, No one except Aaimister has the right to
* modify and/or spread this script without the permission of Aaimister.
* I'm not held responsible for any damage that may occur to your
* property.
*/
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Scanner;
import javax.imageio.ImageIO;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JSpinner;
import javax.swing.JTabbedPane;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
import org.rsbot.event.events.MessageEvent;
import org.rsbot.event.listeners.MessageListener;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.gui.AccountManager;
import org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.util.Filter;
import org.rsbot.script.wrappers.*;
@ScriptManifest(authors = { "Aaimister" }, website = "http://fc4ea3b7.any.gs", name = "Aaimisters Essence Miner v1.39", keywords = "Mining", version = 1.39, description = ("Mines Essence."))
public class AaimistersEssenceMiner extends Script implements PaintListener, MessageListener, MouseListener {
private static interface AM {
// Varrock
//final RSTile toBankV[] = { new RSTile(3258, 3405), new RSTile(3260, 3413), new RSTile(3253, 3420) };
final RSTile toMineV = new RSTile(3253, 3401);
final RSArea VCityArea = new RSArea(new RSTile(3234, 3387), new RSTile(3268, 3440));
final RSArea AtAubury = new RSArea(new RSTile(3250, 3399), new RSTile(3255, 3404));
final RSArea BankV = new RSArea(new RSTile(3250, 3419), new RSTile(3257, 3423));
final RSArea GateV = new RSArea(new RSTile(3252, 3398), new RSTile(3254, 3400));
final RSTile AuburyT = new RSTile(3253, 3401);
final RSTile BankTV = new RSTile(3253, 3420);
final RSTile VGateT = new RSTile(3253, 3398);
// Yanille
//final RSTile toBankY[] = { new RSTile(3602, 3093), new RSTile(2611, 3092) };
final RSTile toMineY = new RSTile(2598, 3086);
final RSArea YCityArea = new RSArea(new RSTile(2583, 3076), new RSTile(2620, 3106));
final RSArea AtWiz = new RSArea(new RSTile(2585, 3081), new RSTile(2596, 3094));
final RSArea BankY = new RSArea(new RSTile(2609, 3088), new RSTile(2616, 3097));
final RSArea GateY = new RSArea(new RSTile(2595, 3086), new RSTile(2598, 3089));
final RSTile WizT = new RSTile(2595, 3087);
final RSTile YGateT = new RSTile(2597, 3087);
final RSTile BankTY = new RSTile (2611, 3093);
}
private RSArea Bank;
private RSArea Gate;
private RSArea AtPerson;
private RSArea CityArea;
private RSTile toMine;
//private RSTile toBank[];
private RSTile PersonT;
private RSTile BankT;
private RSTile GateT;
private final String[] colorstring = { "Black", "Blue", "Brown", "Cyan", "Green", "Lime", "Orange", "Pink", "Purple", "Red", "White", "Yellow" };
private final String[] locationstring = { "Varrock", "Yanille" };
private long nextBreak = System.currentTimeMillis();
private long nextLength = 60000;
private long totalBreakTime;
private long antiBanRandom = random(15000, 90000);
private long antiBanTime = System.currentTimeMillis() + antiBanRandom;
private long lastBreakTime;
private long nextBreakT;
private long startTime;
private long runTime;
private long now;
Updater u = new Updater();
AaimistersGUI g = new AaimistersGUI();
public final File settingsFile = new File(getCacheDirectory(), "AaimistersEMinerSettings.txt");
NumberFormat formatter = new DecimalFormat("#,###,###");
Font Cam10 = new Font("Cambria Math", Font.BOLD, 10);
Font Cam = new Font("Cambria Math", Font.BOLD, 12);
Color PercentGreen = new Color(0, 163, 4, 150);
Color PercentRed = new Color(163, 4, 0, 150);
Color White150 = new Color(255, 255, 255, 150);
Color White90 = new Color(255, 255, 255, 90);
Color White = new Color(255, 255, 255);
Color Background = new Color(219, 200, 167);
Color UpGreen = new Color(0, 169, 0);
Color LineColor = new Color(0, 0, 0);
Color ClickC = new Color(187, 0, 0);
Color UpRed = new Color(169, 0, 0);
Color Black = new Color(0, 0, 0);
Color MainColor;
Color ThinColor;
Color BoxColor;
final NumberFormat nf = NumberFormat.getInstance();
private String currentOre = "";
private String status = "";
private String url = "http://fc4ea3b7.any.gs";
boolean currentlyBreaking = false;
boolean clickedPortal;
boolean randomBreaks;
boolean clickedPer;
boolean bankedOpen;
boolean antiBanOn;
boolean notChosen;
boolean useBooth;
boolean showPaint = true;
boolean painting;
boolean resting;
boolean checked;
boolean doBreak;
boolean opened;
boolean mining;
boolean check = true;
boolean rest;
boolean logTime;
boolean noClick;
boolean stop;
//Paint Buttons
boolean xButton = false;
boolean Stat = false;
boolean Main = true;
boolean varrock;
boolean closed;
int pickaxes[] = { 1265, 1267, 1269, 1273, 1271, 1275, 15259 };
int markerPlant = 9157;
int teleport[] = { 13630, 13631, 13629, 13628 };
int essence = 2491;
int Aubury = 5913;
int Wizard = 462;
int priceEssence;
int aubCount = 0;
int obs[] = { 493, 512, 494, 469, 497, 467, 455, 443, 44497, 2491 };
int dotCount;
int errorCount;
int xpEss = 5;
int currentXP;
int gainedLvl;
int timeToLvl;
int idle = 0;
int startEXP;
int essToLvl;
int xpGained;
int totalEss;
int xpToLvl;
int essHour;
int GPtotal;
int GPHour;
int banker;
int random;
int xpHour;
int bankID;
int door;
int ban;
int iness;
int maxBetween;
int minBetween;
int maxLength;
int minLength;
private enum State { TOBANK, MINE, TOMINE, PORTAL, TELE, BANK, ERROR };
private State getState() {
try {
if (inventory.isFull()) {
mining = false;
if (Bank.contains(getLocation())) {
return State.BANK;
} else if (objects.getNearest(obs) != null) {
return State.PORTAL;
} else if (CityArea.contains(getLocation()) && !Bank.contains(getLocation())) {
return State.TOBANK;
} else {
return State.ERROR;
}
} else if (!inventory.isFull()) {
if (AtPerson.contains(getLocation())) {
return State.TELE;
} else if (objects.getNearest(obs) != null) {
try {
RSObject ess = objects.getNearest(essenceID());
RSTile loc = ess.getArea().getNearestTile(getLocation());
if (!calc.canReach(loc, true) && calc.tileOnMap(ess.getLocation())) {
return State.PORTAL;
} else {
return State.MINE;
}
} catch (Exception e) {
RSObject ess = objects.getNearest(essenceID());
walking.walkTileMM(walking.getClosestTileOnMap(ess.getArea().getNearestTile(getLocation())));
}
} else if (CityArea.contains(getLocation()) && !AtPerson.contains(getLocation())) {
return State.TOMINE;
} else {
return State.ERROR;
}
}
} catch (Exception e) {
}
return State.ERROR;
}
public double getVersion() {
return 1.39;
}
public boolean onStart() {
status = "Starting up";
log("Dwarfeh showing Aaimister some love <3");
//CheckfoUpdate
if (getUpdate() > getVersion()) {
update();
if (closed || stop) {
log.severe("The GUI window was closed!");
return false;
}
}
try {
settingsFile.createNewFile();
} catch (final IOException ignored) {
}
createAndWaitforGUI();
if (closed) {
log.severe("The GUI window was closed!");
return false;
}
startEXP = skills.getCurrentExp(14);
currentXP = skills.getExpToNextLevel(14);
if (doBreak) {
if (AccountManager.isTakingBreaks(account.getName())) {
log.severe("Turn Off Bot Breaks!");
log.severe("Turning off custom breaker...");
doBreak = false;
} else {
breakingNew();
}
}
if (!isMember()) {
currentOre = "Essence";
iness = 1436;
priceEssence = getGuidePrice(iness);
} else if (isMember()) {
currentOre = "Pure Essence";
iness = 7936;
priceEssence = getGuidePrice(iness);
}
return true;
}
private void update() {
if (SwingUtilities.isEventDispatchThread()) {
u.Updater.setVisible(true);
} else {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
u.Updater.setVisible(true);
}
});
} catch (InvocationTargetException ite) {
} catch (InterruptedException ie) {
}
}
sleep(100);
while (u.Updater.isVisible()) {
sleep(100);
}
}
private void createAndWaitforGUI() {
if (SwingUtilities.isEventDispatchThread()) {
g.AaimistersGUI.setVisible(true);
} else {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
g.AaimistersGUI.setVisible(true);
}
});
} catch (InvocationTargetException ite) {
} catch (InterruptedException ie) {
}
}
sleep(100);
while (g.AaimistersGUI.isVisible()) {
sleep(100);
}
}
public double getUpdate() {
try {
BufferedReader r = new BufferedReader(new InputStreamReader(new URL("http://aaimister.webs.com/scripts/AaimistersEssMinerVersion.txt").openStream()));
double d = Double.parseDouble(r.readLine());
r.close();
return d;
} catch(Exception e) {
log("Could not check for update, sorry. =/");
}
return getVersion();
}
public void openThread(){
if (java.awt.Desktop.isDesktopSupported()) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
log("Can't open thread. Something is conflicting.");
return;
}
try {
java.net.URI uri = new java.net.URI(url);
desktop.browse(uri);
} catch (Exception e) {
}
}
}
public void onFinish() {
runTime = (System.currentTimeMillis() - startTime) - totalBreakTime;
long totalTime = System.currentTimeMillis() - startTime;
final String formattedTime = formatTime((int) totalTime);
log("Thanks for using Aaimister's Essence Miner!");
log("In " + formattedTime + " You mined " + formatter.format(totalEss) + " Ore(s) and Gained $" + formatter.format(GPtotal) + "!");
log("You Gained: " + formatter.format(gainedLvl) + " level(s) in Mining!");
}
private void breakingNew(){
if (randomBreaks){
long varTime = random(3660000, 10800000);
nextBreak = System.currentTimeMillis() + varTime;
nextBreakT = varTime;
long varLength = random(900000, 3600000);
nextLength = varLength;
} else {
int diff = random(0, 5) * 1000 * 60;
long varTime = random((minBetween * 1000 * 60) + diff, (maxBetween * 1000 * 60) - diff);
nextBreak = System.currentTimeMillis() + varTime;
nextBreakT = varTime;
int diff2 = random(0, 5) * 1000 * 60;
long varLength = random((minLength * 1000 * 60) + diff2, (maxLength * 1000 * 60) - diff2);
nextLength = varLength;
}
logTime = true;
}
private boolean breakingCheck(){
if (nextBreak <= System.currentTimeMillis()){
return true;
}
return false;
}
private boolean walkTo(RSTile tile) {
RSPath walkPath = walking.getPath(tile.randomize(1, 1));
try {
if (walkPath != null) {
if (!getMyPlayer().isMoving() || calc.distanceTo(walking.getDestination()) < 4) {
return walkPath.traverse();
}
}
} catch (Exception e) {
}
return false;
}
private void waitForArea(RSArea area) {
long start = System.currentTimeMillis();
idle = 0;
while (!area.contains(getLocation())) {
if (idle > 60) {
idle = 0;
break;
}
if (System.currentTimeMillis() >= start + 18000) {
break;
}
if (objects.getNearest(obs) != null) {
idle++;
}
sleep(50);
}
clickedPortal = false;
idle = 0;
}
private void waitForObj() {
long start = System.currentTimeMillis();
idle = 0;
while (objects.getNearest(obs) == null) {
if (idle > 60) {
idle = 0;
break;
}
if (System.currentTimeMillis() >= start + 18000) {
break;
}
if (AtPerson.contains(getLocation())) {
idle++;
}
sleep(50);
}
clickedPer = false;
idle = 0;
}
private String getDots() {
if (dotCount <= 15) {
dotCount++;
return ".";
} else if (dotCount >= 15 && dotCount <= 25) {
dotCount++;
return "..";
} else if (dotCount >= 25 && dotCount <= 35) {
dotCount++;
return "...";
} else if (dotCount >= 35 && dotCount <= 45) {
dotCount++;
return "";
} else {
dotCount = 0;
return ".";
}
}
private String Location() {
if (AtPerson.contains(getLocation())) {
if (varrock) {
return "Aubury's";
} else {
return "Wizard's";
}
} else if (Bank.contains(getLocation())) {
return "Bank";
} else if (objects.getNearest(obs) != null) {
return "Mine";
} else if (calc.distanceTo(BankT) > 100 && objects.getNearest(obs) == null) {
if (!game.isLoggedIn()) {
return "Login Screen";
} else {
return "Unknown";
}
} else {
if (varrock) {
return "Varrock";
} else {
return "Yanille";
}
}
}
private RSTile getLocation() {
return getMyPlayer().getLocation();
}
private void setCamera() {
if (camera.getPitch() < 10) {
camera.setPitch(true);
sleep(1000, 1600);
}
}
private int essenceID() {
RSObject e[] = objects.getAll();
for (int i = 0; i < e.length; i++) {
if (e[i].getName().contains("Essence")) {
return e[i].getID();
}
}
return 0;
}
private int bankerID() {
RSNPC b[] = npcs.getAll();
for (int i = 0; i < b.length; i++) {
if (b[i].getName().contains("Banker")) {
return b[i].getID();
}
}
return 0;
}
private int portalID() {
RSNPC p[] = npcs.getAll();
for (int i = 0; i < p.length; i++) {
if (p[i].getName().contains("Portal")) {
return p[i].getID();
}
}
return 0;
}
private void doRest() {
if (walking.getEnergy() < random(10, 30) && (calc.distanceTo(PersonT) >= 7) && objects.getNearest(obs) == null) {
if (!resting && !mining) {
status = "Resting";
interfaces.getComponent(750, 6).interact("Rest");
mouse.moveSlightly();
resting = true;
sleep(1500, 2000);
return;
}
}
if (resting) {
if (getMyPlayer().getAnimation() == -1) {
resting = false;
}
if (walking.getEnergy() > random(93, 100)) {
resting = false;
}
if (antiBanTime <= System.currentTimeMillis()) {
check = false;
doAntiBan();
}
}
}
private void setRun() {
if (!walking.isRunEnabled()) {
if (walking.getEnergy() >= random(45, 100)) {
walking.setRun(true);
sleep(1000, 1600);
}
} else {
if (rest) {
if ((calc.distanceTo(PersonT) >= 7) || objects.getNearest(obs) == null) {
doRest();
}
}
}
}
@Override
public int loop() {
if (breakingCheck() && doBreak) {
status = "Breaking";
long endTime = System.currentTimeMillis() + nextLength;
totalBreakTime += (nextLength + 5000);
lastBreakTime = (totalBreakTime - (nextLength + 5000));
currentlyBreaking = true;
while (game.isLoggedIn()) {
game.logout(false);
sleep(50);
}
log("Taking a break for " + formatTime((int) nextLength));
while (System.currentTimeMillis() < endTime && currentlyBreaking == true){
sleep(1000);
}
currentlyBreaking = false;
while (!game.isLoggedIn()) {
try {
breakingNew();
game.login();
} catch (Exception e) {
return 10;
}
sleep(50);
}
return 10;
}
if (!game.isLoggedIn()) {
status = "Breaking";
return 3000;
}
if (startTime == 0 && skills.getCurrentLevel(14) != 0) {
startTime = System.currentTimeMillis();
startEXP = skills.getCurrentExp(14);
currentXP = skills.getExpToNextLevel(14);
}
currentlyBreaking = false;
if (logTime) {
log("Next Break In: " + formatTime((int) nextBreakT) + " For: " + formatTime((int) nextLength) + ".");
logTime = false;
}
mouse.setSpeed(random(4, 9));
setCamera();
setRun();
if (resting) {
status = "Resting";
random = random(0, 7);
if (antiBanTime <= System.currentTimeMillis()) {
check = false;
doAntiBan();
}
if (getMyPlayer().getAnimation() == -1 && !mining) {
doRest();
sleep(200, 800);
}
return random(250, 450);
}
switch (getState()) {
case TOBANK:
clickedPortal = false;
status = "Walking to bank";
try {
if (!Bank.contains(getLocation())) {
if (AtPerson.contains(getLocation())) {
if (checkDoor() || (calc.distanceTo(GateT) > 3 && !varrock)) {
openDoor();
return random(300, 500);
} else {
walkTo(BankT.randomize(2, 2));
//walking.newTilePath(toBank).randomize(2, 2).traverse();
return random(300, 600);
}
} else {
walkTo(BankT.randomize(2, 2));
//walking.newTilePath(toBank).randomize(2, 2).traverse();
return random(300, 600);
}
}
} catch (Exception e) {
idle++;
}
break;
case MINE:
clickedPer = false;
if (idle > 7) {
mining = false;
idle = 0;
}
try {
if (getMyPlayer().getAnimation() != -1 || getMyPlayer().getAnimation() == 6752) {
if (antiBanTime <= System.currentTimeMillis()) {
doAntiBan();
}
idle = 0;
}
if (objects.getNearest(obs) != null) {
RSObject ess = objects.getNearest(essenceID());
if (ess != null) {
RSTile loc = ess.getArea().getNearestTile(getLocation());
if (!ess.isOnScreen()) {
idle++;
if (calc.distanceTo(loc) > 3 && !mining) {
status = "Walking to essence";
if (!getMyPlayer().isMoving() || calc.distanceTo(walking.getDestination()) < 4) {
walking.walkTileMM(walking.getClosestTileOnMap(loc.randomize(2, 2)));
return random(150, 300);
}
} else if (!mining) {
camera.turnTo(ess);
return random(300, 500);
}
} else {
idle++;
if (calc.distanceTo(loc) > 3) {
if (!getMyPlayer().isMoving() || calc.distanceTo(walking.getDestination()) < 4) {
walking.walkTileMM(walking.getClosestTileOnMap(loc.randomize(2, 2)));
return random(150, 300);
}
} else if (!mining) {
status = "Mining";
ess.interact("Mine");
mining = true;
idle = 0;
return random(2000, 2700);
}
}
}
}
} catch (Exception e) {
idle++;
}
break;
case TOMINE:
bankedOpen = false;
mining = false;
notChosen = true;
opened = false;
if (varrock) {
status = "Walking to Aubury";
} else {
status = "Walking to Wizard";
}
try {
if (!AtPerson.contains(getLocation())) {
if (calc.distanceTo(PersonT) <= 6) {
if (checkDoor()) {
RSObject closed = objects.getNearest(door);
if (calc.distanceTo(closed.getLocation()) > 3) {
walking.walkTileMM(closed.getLocation().randomize(1, 1));
return random(1500, 1800);
} else {
openDoor();
}
return random(300, 500);
} else {
//walkTo(PersonT.randomize(2, 2));
//walking.newTilePath(toMine).randomize(2, 2).traverse();
walkTo(toMine);
return random(300, 600);
}
} else {
//walkTo(PersonT.randomize(2, 2));
//walking.newTilePath(toMine).randomize(2, 2).traverse();
walkTo(toMine);
return random(300, 600);
}
}
} catch (Exception e) {
idle++;
}
break;
case TELE:
try {
if (idle > 15) {
if (objects.getNearest(obs) == null) {
RSNPC per = perNPC();
if (interfaces.getComponent(620, 18).isValid()) {
close();
}
if (per != null) {
per.interact("Teleport");
sleep(2000, 3000);
} else {
RSNPC plant = plantNPC();
plant.interact("Teleport");
sleep(2000, 3000);
}
} else {
return 10;
}
idle = 0;
}
if (interfaces.getComponent(620, 18).isValid()) {
close();
sleep(300);
clickedPer = false;
return 350;
}
if (!clickedPer) {
RSNPC per = perNPC();
if (per != null) {
idle++;
if (!clickedPer) {
per.interact("Teleport");
clickedPer = true;
} else {
waitForObj();
}
} else {
RSNPC plant = plantNPC();
idle++;
if (!clickedPer) {
plant.interact("Teleport");
clickedPer = true;
} else {
waitForObj();
}
}
} else {
idle++;
waitForObj();
}
} catch (Exception e) {
idle++;
}
break;
case PORTAL:
status = "Walking to bank";
if (idle > 7) {
clickedPortal = false;
idle = 0;
}
try {
if (!clickedPortal) {
if (portal() != null) {
RSObject p = objects.getNearest(39831);
RSTile loc = p.getArea().getNearestTile(getLocation());
if (!portal().isOnScreen()) {
if (calc.distanceTo(loc) > 3) {
walking.walkTileMM(walking.getClosestTileOnMap(loc.randomize(2, 2)));
return random(1200, 1500);
} else {
idle++;
if (calc.distanceTo(loc) > 3) {
if (!getMyPlayer().isMoving() || calc.distanceTo(walking.getDestination()) < 4) {
walking.walkTileMM(walking.getClosestTileOnMap(loc.randomize(2, 2)));
return random(150, 300);
}
} else if (!clickedPortal) {
portal().interact("Enter");
clickedPortal = true;
idle = 0;
return random(200, 500);
}
}
} else {
idle++;
if (calc.distanceTo(loc) > 2) {
if (!getMyPlayer().isMoving() || calc.distanceTo(walking.getDestination()) < 4) {
walking.walkTileMM(walking.getClosestTileOnMap(loc.randomize(2, 2)));
return random(150, 300);
}
}
if (!clickedPortal) {
portal().interact("Enter");
clickedPortal = true;
idle = 0;
waitForArea(CityArea);
}
}
}
} else {
idle++;
waitForArea(CityArea);
}
} catch (Exception e) {
idle++;
}
break;
case BANK:
status = "Banking";
if (idle > 7) {
opened = false;
notChosen = true;
bankedOpen = false;
idle = 0;
}
if (notChosen) {
if (random(0, 5) == 0 || random(0, 5) == 2) {
useBooth = false;
} else {
useBooth = true;
}
notChosen = false;
}
RSObject booth = objects.getNearest(bankID);
RSNPC bankP = banker();
try {
if (!bank.isOpen()) {
if (!booth.isOnScreen()) {
if (calc.distanceTo(booth.getLocation()) >= 4) {
if (!getMyPlayer().isMoving() || calc.distanceTo(walking.getDestination()) < 4) {
walking.walkTileMM(walking.getClosestTileOnMap(booth.getLocation()));
}
} else {
camera.turnTo(booth);
}
return random(300, 600);
} else {
idle++;
if (!opened) {
if (useBooth) {
booth.interact("Use-quickly");
} else {
bankP.interact("Bank Banker");
}
opened = true;
idle = 0;
return random(500, 1000);
}
}
} else {
opened = false;
if (inventory.containsOneOf(pickaxes)) {
idle++;
if (!bankedOpen) {
bank.depositAllExcept(pickaxes);
bankedOpen = true;
return random(100, 150);
}
} else {
idle++;
if (!bankedOpen) {
bank.depositAll();
bankedOpen = true;
return random(100, 150);
}
}
}
} catch (Exception e) {
idle++;
}
break;
case ERROR:
idle++;
if (idle > 50) {
log("Huston, we have a problem.");
game.logout(false);
sleep(1000, 1500);
stopScript();
}
break;
}
return random(300, 600);
}
private void close() {
RSComponent close = interfaces.getComponent(620, 18);
close.interact("Close");
sleep(100, 300);
}
public void openDoor() {
RSObject closed = objects.getNearest(door);
RSTile doorT = closed.getLocation();
if (Gate.contains(doorT) && calc.distanceTo(GateT) < 3) {
if (closed != null) {
if (!closed.isOnScreen()) {
walking.walkTileMM(doorT);
sleep(1200, 1500);
} else {
closed.interact("Open");
sleep(1000, 1200);
}
}
} else {
if (!getMyPlayer().isMoving() || calc.distanceTo(walking.getDestination()) < 4) {
walking.walkTileMM(walking.getClosestTileOnMap(GateT.randomize(2, 2)));
}
}
}
public boolean checkDoor() {
try {
RSObject closed = objects.getNearest(door);
if (Gate.contains(closed.getLocation())) {
return true;
} else {
return false;
}
} catch (Exception e) {
return false;
}
}
public boolean isMember() {