-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathFallenSafeCracker.java
More file actions
2507 lines (2363 loc) · 71.1 KB
/
FallenSafeCracker.java
File metadata and controls
2507 lines (2363 loc) · 71.1 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
import org.rsbot.event.events.MessageEvent;
import org.rsbot.event.listeners.MessageListener;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.methods.Bank;
import org.rsbot.script.methods.Game;
import org.rsbot.script.methods.Skills;
import org.rsbot.script.util.Timer;
import org.rsbot.script.wrappers.*;
import org.rsbot.util.GlobalConfiguration;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.URL;
import java.util.ArrayList;
import java.util.Properties;
/* @Updated 2.15.2011.
*
* Updated the banking method.
*
* Added a temp. fix for prices.
*/
@ScriptManifest(authors = {"Fallen"}, keywords = "Thieving", name = "Fallen's Safe Cracker", version = 4.3, description = "Cracks safes at Rogue Den's.")
public class FallenSafeCracker extends Script implements PaintListener,
MessageListener, MouseListener, MouseMotionListener {
private enum State {
WALKTOSAFES, SMALLWALK, CRACK, WALKTOBANK, OPENBANK, BANK
}
// Mostly paint int's
private long runTime = 0;
private long startTime = 0;
private long timeLeft = 0;
private long seconds = 0;
private long minutes = 0;
private long millis = 0;
private long hours = 0;
private int startXP;
private int startLevel;
private int levelsGained;
private int currentLevel;
private Image title;
private int GainedProfit;
private int XPGained = 0;
private int toNextLvl;
private int nextLvl;
private int XPToLevel;
private double SuccessRate;
private boolean setTime = false;
private boolean paint = true;
private boolean RT = false;
private boolean extra = true;
private boolean renew = true;
private long timerStart = 0;
private long pauseTimer = 0;
private long tempTimer = 0;
private long tempTimer2 = 0;
private boolean defined = false, gathered = false, switching = false,
waitingForMovement = false;
private Timer switchTimer = new Timer(0);
private int browseCounter = 0;
private final boolean logIfFull = true;
private boolean UseStethoscope;
private boolean randomized = false;
private boolean North = false;
private boolean South = false;
private boolean SouthLeft = false;
private boolean SouthRight = false;
private boolean NorthLeft = false;
private boolean NorthRight = false;
private int getX;
private int getY;
private final int Percentage = 60;
private Timer expTimeOut = new Timer(1000 * 60 * 5);
private int tempExp = 0;
private int CrackState = 0;
private int Trapped = 0;
private int Cracked = 0;
private int FoodID;
private final int[] FoodIDS = {1895, 1893, 1891, 4293, 2142, 291, 2140,
3228, 9980, 7223, 6297, 6293, 6295, 6299, 7521, 9988, 7228, 2878,
7568, 2343, 1861, 13433, 315, 325, 319, 3144, 347, 355, 333, 339,
351, 329, 3381, 361, 10136, 5003, 379, 365, 373, 7946, 385, 397,
391, 3369, 3371, 3373, 2309, 2325, 2333, 2327, 2331, 2323, 2335,
7178, 7180, 7188, 7190, 7198, 7200, 7208, 7210, 7218, 7220, 2003,
2011, 2289, 2291, 2293, 2295, 2297, 2299, 2301, 2303, 1891, 1893,
1895, 1897, 1899, 1901, 7072, 7062, 7078, 7064, 7084, 7082, 7066,
7068, 1942, 6701, 6703, 7054, 6705, 7056, 7060, 2130, 1985, 1993,
1989, 1978, 5763, 5765, 1913, 5747, 1905, 5739, 1909, 5743, 1907,
1911, 5745, 2955, 5749, 5751, 5753, 5755, 5757, 5759, 5761, 2084,
2034, 2048, 2036, 2217, 2213, 2205, 2209, 2054, 2040, 2080, 2277,
2225, 2255, 2221, 2253, 2219, 2281, 2227, 2223, 2191, 2233, 2092,
2032, 2074, 2030, 2281, 2235, 2064, 2028, 2187, 2185, 2229, 6883,
1971, 4608, 1883, 1885, 15272};
private static int FoodWDAmount;
private static int EatingPoint;
private final int Stethoscope = 5560;
private final int Emerald = 1621;
private final int Sapphire = 1623;
private final int Ruby = 1619;
private final int Diamond = 1617;
private int Emeralds;
private int Rubies;
private int Sapphires;
private int Diamonds;
private int EmeraldsINV;
private int RubiesINV;
private int SapphiresINV;
private int DiamondsINV;
private final int wallsafe = 7236;
private final int BankerID = 2271;
// Item prices from G.E
private int EmeraldPrice = 0;
private int SapphirePrice = 0;
private int RubyPrice = 0;
private int DiamondPrice = 0;
// Tiles
private RSTile dest = new RSTile(3056, 4978);
private final RSTile approxBank = new RSTile(3042, 4970);
// GUI VARIABLES
private Properties OPTION_FILE;
private String GUIString;
private Object GUIString2;
private Object GUIString3;
private Object GUIString4;
private Object GUIString5;
private Object GUIString6;
private boolean TakeAShot = false;
private boolean timeLimit = false;
private boolean levelLimit = false;
private boolean worked = false;
private static int limitedHours;
private static int limitedMinutes;
private static int limitedLevel;
private boolean change = true, advSwitch = true, clickFirst = false,
up = false;
private class Spot {
public boolean free = false;
public RSTile location = null;
public Spot(RSTile t) {
this.location = t;
}
public void setFree(boolean available) {
this.free = available;
}
}
public Spot NW = new Spot(new RSTile(3055, 4970)), NE = new Spot(
new RSTile(3057, 4970)), SW = new Spot(new RSTile(3055, 4977)),
SE = new Spot(new RSTile(3057, 4977));
public ArrayList<Spot> spots = new ArrayList<Spot>();
/*-------------------------------------------------------------------
* ------------------ P A I N T -------------------------
------------------------------------------------------------------*/
@Override
public void onRepaint(Graphics g) {
if (!game.isLoggedIn() || this.isPaused() || !this.isActive()) {
if (!gathered) {
timerStart = System.currentTimeMillis();
gathered = true;
}
tempTimer = System.currentTimeMillis() - timerStart - tempTimer2;
} else {
tempTimer = 0;
tempTimer2 = 0;
gathered = false;
}
pauseTimer += tempTimer;
tempTimer2 += tempTimer;
if (startXP == 0) {
startXP = skills.getCurrentExp(Skills.THIEVING);
}
if (startLevel == 0) {
startLevel = skills.getRealLevel(Skills.THIEVING);
}
if (RT == true) {
runTime = System.currentTimeMillis() - startTime;
} else {
runTime = System.currentTimeMillis() - startTime - pauseTimer;
}
XPGained = (skills.getCurrentExp(Skills.THIEVING) - startXP);
GainedProfit = ((Emeralds * EmeraldPrice) + (Rubies * RubyPrice)
+ (Sapphires * SapphirePrice) + (Diamonds * DiamondPrice));
final int XPHR = (int) ((XPGained) * 3600000D / (runTime));
final int PROFITHR = (int) ((GainedProfit) * 3600000D / (runTime));
int attempts = Cracked + Trapped;
levelsGained = skills.getRealLevel(Skills.THIEVING) - startLevel;
currentLevel = skills.getRealLevel(Skills.THIEVING);
millis = runTime;
hours = millis / (1000 * 60 * 60);
millis -= hours * (1000 * 60 * 60);
minutes = millis / (1000 * 60);
millis -= minutes * (1000 * 60);
seconds = millis / 1000;
Point loc = mouse.getLocation();
g.setColor(new Color(170, 10, 170, 180));
g.fillRoundRect((int) loc.getX() - 10, (int) loc.getY() - 1, 21, 3, 3,
3);
g.fillRoundRect((int) loc.getX() - 1, (int) loc.getY() - 10, 3, 21, 3,
3);
if (waitingForMovement) {
long secondsR = switchTimer.getRemaining() / 1000;
long hoursR = secondsR / (60 * 60);
secondsR -= hoursR * (60 * 60);
long minutesR = secondsR / 60;
secondsR -= minutesR * 60;
g.setFont(new Font("Verdana", 0, 9));
g.setColor(Color.RED);
g.drawString("A player is under us, waiting - " + minutesR
+ " minutes, " + secondsR + " seconds.", 140, 470);
}
if (switching) {
g.setFont(new Font("Verdana", 0, 9));
g.setColor(Color.RED);
g.drawString("Switching location.", 220, 470);
}
// OPTION BOXES
/*
* if(extra) { for(Spot spot : spots) { if(spot.free) { drawTile(g,
* spot.location, new Color(20, 180, 20, 100), false, ""); } else {
* if(!getMyPlayer().getLocation().equals(spot.location)) { drawTile(g,
* spot.location, new Color(180, 20, 20, 100), false, ""); } else {
* drawTile(g, spot.location, new Color(20, 20, 180, 100), false, ""); }
* } } }
*/
g.setFont(new Font("Verdana", 0, 10));
// Paint
if (paint) {
g.setColor(new Color(20, 255, 20, 130));
} else {
g.setColor(new Color(255, 255, 255, 130));
}
g.fillRect(416, 458, 32, 15);
g.setColor(new Color(0, 0, 0, 255));
g.drawRect(416, 458, 32, 15);
g.setColor(new Color(0, 0, 0, 255));
g.drawString("Paint", 418, 470);
// Real-Time
g.setFont(new Font("Verdana", 0, 10));
if (RT == true) {
g.setColor(new Color(156, 20, 170, 130));
} else {
g.setColor(new Color(255, 255, 255, 130));
}
g.fillRect(448, 458, 32, 15);
g.setColor(new Color(0, 0, 0, 255));
g.drawRect(448, 458, 32, 15);
g.setColor(new Color(0, 0, 0, 255));
g.drawString("Time", 450, 470);
// Extra
g.setFont(new Font("Verdana", 0, 10));
if (extra == true) {
g.setColor(new Color(255, 90, 60, 130));
} else {
g.setColor(new Color(255, 255, 255, 130));
}
g.fillRect(480, 458, 32, 15);
g.setColor(new Color(0, 0, 0, 255));
g.drawRect(480, 458, 32, 15);
g.setColor(new Color(0, 0, 0, 255));
g.drawString("Extra", 482, 470);
if (paint) {
g.drawImage(title, 9, 30, null);
// Version
g.setFont(new Font("Arial", 0, 10));
g.setColor(Color.MAGENTA);
g.drawString("v 4.3", 171, 80);
// Time
g.setFont(new Font("Verdana", 0, 15));
g.setColor(Color.WHITE);
if (setTime == true) {
g.drawString(" " + hours + ":" + minutes + ":" + seconds + ".",
47, 315);
} else {
g.drawString("Loading...", 47, 315);
}
if (timeLimit == true && setTime == true) {
g.setFont(new Font("Verdana", 0, 9));
g.setColor(Color.RED);
long secondsL = timeLeft - ((runTime) / 1000);
long hoursL = secondsL / (60 * 60);
secondsL -= hoursL * (60 * 60);
long minutesL = secondsL / 60;
secondsL -= minutesL * 60;
g.drawString("Time left: " + hoursL + " hours, " + minutesL
+ " minutes.", 355, 14);
}
// Hour rates
g.setFont(new Font("Verdana", 0, 12));
g.setColor(Color.MAGENTA);
g.drawString("Exp/Hour: " + XPHR, 60, 115);
// g.setColor(Color.MAGENTA);
// g.drawString("Cracks/Hour: " + XPHR / 70, 60, 191);
g.setColor(Color.MAGENTA);
g.drawString("Profit/Hour: " + PROFITHR, 60, 212);
// Thieving exp
g.setColor(Color.WHITE);
g.setFont(new Font("Verdana", 0, 11));
// PROGRESS
g.setFont(new Font("Verdana", 0, 9));
toNextLvl = skills.getPercentToNextLevel(Skills.THIEVING);
XPToLevel = skills.getExpToNextLevel(Skills.THIEVING);
nextLvl = skills.getCurrentLevel(Skills.THIEVING) + 1;
g.setColor(new Color(0, 0, 0));
g.fillRect(19, 125, 180, 16);// Black box
g.drawRect(18, 124, 181, 17); // FRAME
g.setColor(new Color(51, 51, 51));
g.fillRect(19, 125, 180, 8);// Gray box
g.setColor(new Color(170, 10, 170, 130));
g.fillRect(20, 126, (int) (toNextLvl * 178 / 100.0), 14);
g.setColor(Color.WHITE);
g.drawString("" + toNextLvl + "% to " + nextLvl + " Thiev" + " - "
+ XPToLevel + " XP", 25, 137);
// TTNL
try {
if (XPHR > 0) {
long sTNL = (XPToLevel) / (XPHR / 3600);
long hTNL = sTNL / (60 * 60);
sTNL -= hTNL * (60 * 60);
long mTNL = sTNL / 60;
sTNL -= mTNL * 60;
g.drawString("Next level in: " + hTNL + ":" + mTNL + ":"
+ sTNL, 19, 154);
} else {
g.drawString("Next level in: 0:0:0", 19, 154);
}
} catch (Exception e) {
g.drawString("Next level in: -1:-1:-1", 19, 154);
}
g.drawString("Thieving EXP gained: " + (XPGained), 19, 174);
g.drawString("Thieving level: " + currentLevel + " ("
+ levelsGained + ")", 19, 186);
if (levelLimit == true) {
g.setFont(new Font("Verdana", 0, 9));
g.setColor(Color.RED);
g.drawString(
"Stopping at level " + limitedLevel + " Thieving.",
363, 14);
}
// Profit
g.drawString("Total profit: " + GainedProfit, 19, 234);
g.setColor(Color.BLUE);
g.drawString("Sapphires: " + Sapphires, 19, 246);
g.setColor(Color.GREEN);
g.drawString("Emeralds: " + Emeralds, 19, 258);
g.setColor(Color.RED);
g.drawString("Rubies: " + Rubies, 19, 270);
g.setColor(Color.WHITE);
g.drawString("Diamonds: " + Diamonds, 19, 282);
}
if (extra) {
// Safes Cracked
g.setFont(new Font("Verdana", 0, 9));
g.setColor(Color.WHITE);
g.drawString("Cracked: " + Cracked, 340, 310);
// Traps Triggered
g.drawString("Failed: " + Trapped, 340, 298);
// Succeessss bar
g.setFont(new Font("Verdana", 0, 9));
g.setColor(new Color(0, 0, 0));
g.fillRect(341, 316, 169, 16);
g.drawRect(340, 315, 170, 17);
g.setColor(new Color(51, 51, 51));
g.fillRect(341, 316, 169, 8);
g.setColor(new Color(200, 0, 0, 60));
g.fillRect(343, 318, 165, 12);
g.setColor(new Color(30, 255, 30, 80));
if (SuccessRate != 0) {
g.fillRect(343, 318, (int) (SuccessRate * 165 / 100.0), 12);
}
g.setColor(Color.WHITE);
g.drawString("" + Math.round(SuccessRate) + " % Success", 390, 328);
g.setColor(Color.WHITE);
if (Cracked > 0) {
SuccessRate = ((Cracked * 100.0) / (attempts));
}
// Small map
g.setFont(new Font("Verdana", 0, 9));
g.setColor(new Color(51, 51, 0));
g.fillRoundRect(448, 257, 43, 26, 8, 8);
if (South) {
g.setColor(Color.GREEN);
g.drawString("South", 455, 307);
g.drawRoundRect(450, 270, 38, 27, 10, 10);
} else {
g.setColor(Color.RED);
g.drawString("South", 455, 307);
g.drawRoundRect(450, 270, 38, 27, 10, 10);
}
if (North) {
g.setColor(Color.GREEN);
g.drawString("North", 455, 237);
g.drawRoundRect(450, 240, 38, 27, 10, 10);
} else {
g.setColor(Color.RED);
g.drawString("North", 455, 237);
g.drawRoundRect(450, 240, 38, 27, 10, 10);
}
// /////////////////////////////////////
g.setFont(new Font("Verdana", 0, 12));
// /////////////////////////////////////
if (NorthLeft) {
g.setColor(Color.GREEN);
g.drawString("W", 432, 275);
g.drawString("*", 459, 262);
} else {
g.setColor(Color.RED);
g.drawString("W", 432, 275);
g.drawString("*", 459, 262);
}
if (NorthRight) {
g.setColor(Color.GREEN);
g.drawString("E", 494, 275);
g.drawString("*", 475, 262);
} else {
g.setColor(Color.RED);
g.drawString("E", 494, 275);
g.drawString("*", 475, 262);
}
if (SouthLeft) {
g.setColor(Color.GREEN);
g.drawString("W", 432, 275);
g.drawString("*", 459, 290);
} else {
g.setColor(Color.RED);
g.drawString("W", 432, 275);
g.drawString("*", 459, 290);
}
if (SouthRight) {
g.setColor(Color.GREEN);
g.drawString("E", 494, 275);
g.drawString("*", 475, 290);
} else {
g.setColor(Color.RED);
g.drawString("E", 494, 275);
g.drawString("*", 475, 290);
}
}
}
/**
* Draws a tile with the passed color on the passed instance of
* <code>Graphics</code>.
*
* @param render The instance of <code>Graphics</code> you want to draw on.
* @param tile The instance of the tile you want to draw.
* @param color The color you want the drawn tile to be.
* @param drawCardinalDirections True if you want the cardinal directions to be drawn in each
* corner.
* @author Gnarly
*/
public void drawTile(Graphics render, RSTile tile, Color color,
boolean drawCardinalDirections, String s) {
Point southwest = calc.tileToScreen(tile, 0, 0, 0);
Point southeast = calc.tileToScreen(
new RSTile(tile.getX() + 1, tile.getY()), 0, 0, 0);
Point northwest = calc.tileToScreen(new RSTile(tile.getX(),
tile.getY() + 1), 0, 0, 0);
Point northeast = calc.tileToScreen(
new RSTile(tile.getX() + 1, tile.getY() + 1), 0, 0, 0);
if (calc.pointOnScreen(southwest) && calc.pointOnScreen(southeast)
&& calc.pointOnScreen(northwest)
&& calc.pointOnScreen(northeast)) {
render.setColor(Color.BLACK);
render.drawPolygon(new int[]{(int) northwest.getX(),
(int) northeast.getX(), (int) southeast.getX(),
(int) southwest.getX()},
new int[]{(int) northwest.getY(), (int) northeast.getY(),
(int) southeast.getY(), (int) southwest.getY()}, 4);
render.setColor(color);
render.fillPolygon(new int[]{(int) northwest.getX(),
(int) northeast.getX(), (int) southeast.getX(),
(int) southwest.getX()},
new int[]{(int) northwest.getY(), (int) northeast.getY(),
(int) southeast.getY(), (int) southwest.getY()}, 4);
if (drawCardinalDirections) {
render.setColor(Color.WHITE);
render.drawString("" + s, southwest.x, southwest.y);
}
}
}
/*------------------------------------------------------------
* ------------------ O N S T A R T ----------------------
-----------------------------------------------------------*/
@Override
public boolean onStart() {
try {
title = ImageIO.read(new URL(
"http://a.imageshack.us/img641/4190/paintv20.png"));
} catch (final java.io.IOException e) {
e.printStackTrace();
}
OPTION_FILE = new Properties();
SafeCrackerGUI = new GUI(this);
SafeCrackerGUI.setLocationRelativeTo(null);
SafeCrackerGUI.setVisible(true);
while (WaitForStart) {
sleep(20);
}
if (worked == false)
return false;
spots.add(NW);
spots.add(NE);
spots.add(SW);
spots.add(SE);
log("Retrieving item prices from the Grand Exchange...");
// SapphirePrice = grandExchange.lookup(Sapphire).getMinPrice();
// EmeraldPrice = grandExchange.lookup(Emerald).getMinPrice();
// RubyPrice = grandExchange.lookup(Ruby).getMinPrice();
// DiamondPrice = grandExchange.lookup(Diamond).getMinPrice();
SapphirePrice = getGuidePrice(Sapphire);
EmeraldPrice = getGuidePrice(Emerald);
RubyPrice = getGuidePrice(Ruby);
DiamondPrice = getGuidePrice(Diamond);
EmeraldsINV = inventory.getCount(Emerald);
RubiesINV = inventory.getCount(Ruby);
SapphiresINV = inventory.getCount(Sapphire);
DiamondsINV = inventory.getCount(Diamond);
log("... Prices retrieved!");
log(" ~ Anti-ban synchronized! ~");
log("------------------------------------------------");
log("Fallen's Safe Cracker is now running!");
startTime = System.currentTimeMillis();
timeLeft = (((limitedHours * 60 * 60 * 1000) + (limitedMinutes * 60 * 1000)) / (1000));
setTime = true;
camera.setPitch(true);
return true;
}
/*
* --------------------------------------------------------------------------
* ----------------------------------------------------
* ----------------------
* ----------------------------------------------------
* ----------------------------------------------------
* --------------------------------------- M E T H O D S
* ----------------------------------------------------
* ----------------------
* ----------------------------------------------------
* ----------------------------------------------------
* ----------------------
* ----------------------------------------------------
* ----------------------------------------------------
*/
/**
* These GE-methods aren't by me, credits to whoever made them.
*/
private int getGuidePrice(int itemID) {
try {
URL url = new URL(
"http://services.runescape.com/m=itemdb_rs/viewitem.ws?obj="
+ itemID);
BufferedReader br = new BufferedReader(new InputStreamReader(
url.openStream()));
String line = null;
while ((line = br.readLine()) != null) {
if (line.contains("<b>Current guide price:</b>")) {
line = line.replace("<b>Current guide price:</b>", "");
return (int) parse(line);
}
}
} catch (IOException e) {
}
return -1;
}
private double parse(String str) {
if (str != null && !str.isEmpty()) {
str = stripFormatting(str);
str = str.substring(str.indexOf(58) + 2, str.length());
str = str.replace(",", "");
if (!str.endsWith("%")) {
if (!str.endsWith("k") && !str.endsWith("m")) {
return Double.parseDouble(str);
}
return Double.parseDouble(str.substring(0, str.length() - 1))
* (str.endsWith("m") ? 1000000 : 1000);
}
int k = str.startsWith("+") ? 1 : -1;
str = str.substring(1);
return Double.parseDouble(str.substring(0, str.length() - 1)) * k;
}
return -1D;
}
private String stripFormatting(String str) {
if (str != null && !str.isEmpty())
return str.replaceAll("(^[^<]+>|<[^>]+>|<[^>]+$)", "");
return "";
}
private boolean failSafes() {
if (!gainedExperience()) {
Quit();
return true;
}
return false;
}
private boolean gainedExperience() {
if (!expTimeOut.isRunning()) {
if (XPGained > tempExp) {
expTimeOut = new Timer(1000 * 60 * 5);
tempExp = XPGained;
return true;
} else {
log("No experience gained withtin the past 5 minutes!");
return false;
}
}
return true;
}
private void timeToQuit() {
if (timeLimit == true) {
if (limitedHours == hours && limitedMinutes <= minutes) {
log("Time's up!");
Quit();
} else if (limitedHours < hours) {
log("Time's up!");
Quit();
}
}
if (levelLimit == true) {
if (currentLevel == limitedLevel) {
log("Achieved level: " + currentLevel);
Quit();
}
}
}
private boolean waitForIF(RSInterface iface, int timeout) {
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < timeout) {
if (iface.isValid()) {
return true;
}
sleep(100);
}
return false;
}
private boolean inRectangle(int x1, int y1, int x2, int y2) {
getX = getMyPlayer().getLocation().getX();
getY = getMyPlayer().getLocation().getY();
if (getX >= x1 && getX <= x2 && getY >= y1 && getY <= y2)
return true;
return false;
}
private boolean waitForWithdrawnItem(int item, int timeout) {
int startCount = inventory.getCount(true, item);
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < timeout) {
if (inventory.getCount(item) > startCount) {
return true;
}
sleep(100);
}
return false;
}
private boolean waitForDepositedItem(int timeout) {
int startCount = inventory.getCount(true);
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < timeout) {
if (inventory.getCount(true) < startCount) {
return true;
}
sleep(100);
}
return false;
}
private boolean waitForStateChange(int timeout) {
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < timeout) {
if (CrackState != 1
|| safeToCrack(getMyPlayer().getLocation()) == null) {
if (clickFirst && !inventory.isItemSelected()) {
useStethoscope();
}
return true;
}
sleep(100);
if (random(0, 100) > 70) {
antiBan();
}
if (random(0, 20) == random(0, 20) && clickFirst
&& !inventory.isItemSelected()) {
useStethoscope();
}
}
return false;
}
private boolean waitToStop(int timeout) {
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < timeout) {
if (!getMyPlayer().isMoving()) {
return true;
}
sleep(50);
}
return false;
}
private boolean waitForAnim(int timeout) {
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < timeout) {
if (getMyPlayer().getAnimation() != -1) {
return true;
}
sleep(50);
}
return false;
}
private boolean WD(int itemID, int count) {
int tempCount = count;
if (count == 0)
tempCount = 1;
if (count < 0)
throw new IllegalArgumentException("count < 0 (" + count + ")");
if (!bank.isOpen())
return false;
RSItem item = bank.getItem(itemID);
if (item == null || !item.isComponentValid()
|| bank.getCount(itemID) < tempCount) {
if (bank.getCount(itemID) < tempCount) {
log("Out of items - Check: 1/3.");
sleep(random(400, 600));
if (bank.getCount(itemID) < tempCount) {
log("Out of items - Check: 2/3.");
sleep(random(400, 600));
if (bank.getCount(itemID) < tempCount && bank.isOpen()) {
try {
log("Out of: " + grandExchange.getItemName(itemID)
+ " - Check 3/3.");
} catch (Exception e) {
e.printStackTrace();
log("Out of: " + itemID);
}
Quit();
return false;
}
}
}
return false;
}
switch (count) {
case 0: // Withdraw All
return item.doAction("Withdraw-All");
case 1: // Withdraw 1
return item.doClick(true);
case 5: // Withdraw 5
case 10: // Withdraw 10
return item.doAction("Withdraw-" + count);
default: // Withdraw x
if (item.doClick(false)) {
sleep(random(100, 300));
if (menu.contains("Withdraw-" + count)) {
if (menu.doAction("Withdraw-" + count)) {
sleep(random(100, 200));
return true;
}
return false;
}
if (item.doAction("Withdraw-X")) {
sleep(random(1000, 1300));
keyboard.sendText("" + count, true);
}
sleep(random(100, 200));
return true;
}
break;
}
return false;
}
private boolean doActionAtModel(RSModel model, String action) {
if (model != null) {
int iters = random(3, 6);
while (--iters > 0 && !menu.contains(action)) {
try {
mouse.move(model.getPoint());
if (menu.contains(action)) {
sleep(random(20, 100));
if (menu.contains(action)) {
break;
}
}
} catch (Exception e) {
}
}
if (menu.contains(action)) {
return menu.doAction(action);
} else {
return false;
}
}
return false;
}
private RSObject safeToCrack(RSTile t) {
RSObject[] objs = objects.getAllAt(t);
for (RSObject obj : objs) {
if (obj.getID() == wallsafe) {
return obj;
}
}
return null;
}
private boolean waitForSafe(int timeout) {
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < timeout) {
if (safeToCrack(getMyPlayer().getLocation()) != null) {
return true;
}
sleep(50);
}
return false;
}
private boolean useStethoscope() {
RSItem Steth = inventory.getItem(Stethoscope);
if (Steth != null) {
return Steth.doClick(true);
}
return false;
}
private void crackSafe() {
RSTile CurrentTile = getMyPlayer().getLocation();
if (eat()) {
return;
}
String s = "Crack";
if (clickFirst) {
s = "Use Stethoscope -> Wall safe";
if (!inventory.isItemSelected()) {
useStethoscope();
}
}
RSObject SafeToCrack = safeToCrack(CurrentTile);
RSModel SafeModel;
if (SafeToCrack != null) {
SafeModel = SafeToCrack.getModel();
} else {
return;
}
long start = System.currentTimeMillis();
boolean clicked = false;
while (!clicked && System.currentTimeMillis() - start < 5000) {
if (doActionAtModel(SafeModel, s)) {
clicked = true;
if (random(0, 100) > 70) {
mouse.moveRandomly(200);
}
CrackState = 1;
return;
}
clicked = false;
sleep(random(200, 600));
}
CrackState = 1;
}
/**
* Scans the area for your location & checks free locations.
*/
private void scanner() {
if (inRectangle(3052, 4974, 3060, 4981)) {
North = true;
South = false;
} else if (inRectangle(3052, 4966, 3060, 4973)) {
North = false;
South = true;
} else {
North = false;
South = false;
}
// CRACK LOCATION CHECK [North(Left/Right) / South(Left/Right)]
if (inRectangle(3055, 4970, 3055, 4970)) {
SouthLeft = true;
SouthRight = false;
NorthLeft = false;
NorthRight = false;
} else if (inRectangle(3057, 4970, 3057, 4970)) {
SouthLeft = false;
SouthRight = true;
NorthLeft = false;
NorthRight = false;
} else if (inRectangle(3055, 4977, 3055, 4977)) {
SouthLeft = false;
SouthRight = false;
NorthLeft = true;
NorthRight = false;
} else if (inRectangle(3057, 4977, 3057, 4977)) {
SouthLeft = false;
SouthRight = false;
NorthLeft = false;
NorthRight = true;
} else {
SouthLeft = false;
SouthRight = false;
NorthLeft = false;
NorthRight = false;
}
for (int N = 0; N < 4; N++) {
spots.get(N).setFree(true);
}
RSPlayer[] plrs = players.getAll();
for (RSPlayer plr : plrs) {
if (plr != null) {
RSTile plrL = plr.getLocation();
for (int N = 0; N < 4; N++) {
if (plrL.equals(spots.get(N).location)) {
spots.get(N).setFree(false);
}
}
}
}
}
private boolean someoneBeneathMe() {
RSTile spot = getMyPlayer().getLocation();
RSPlayer[] validPlayers = players.getAll();
for (RSPlayer player : validPlayers) {
try {
if (!player.equals(getMyPlayer())) {
if (player.getLocation().equals(spot)) {
return true;
}
}
} catch (Exception ignored) {
}
}
return false;
}
private RSTile nearestFreeSpot(boolean randomize) {
ArrayList<RSTile> list = new ArrayList<RSTile>();
int dist = 20;
RSTile nearest = null;
for (int N = 0; N < 4; N++) {
if (spots.get(N).free) {
list.add(spots.get(N).location);
int tempDist = calc.distanceTo(spots.get(N).location);
if (tempDist < dist) {
nearest = spots.get(N).location;
dist = tempDist;
}
}
}
if (randomize && random(0, 2) == random(0, 2)) {
return list.get(random(0, list.size()));
} else {
return nearest;
}