This repository was archived by the owner on Dec 30, 2025. It is now read-only.
forked from crazyeyes-pb/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKubkoWhiteBerries.java
More file actions
1122 lines (1011 loc) · 34.2 KB
/
KubkoWhiteBerries.java
File metadata and controls
1122 lines (1011 loc) · 34.2 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 java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.URL;
import javax.imageio.ImageIO;
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.Equipment;
import org.rsbot.script.methods.Game;
import org.rsbot.script.methods.GrandExchange.GEItem;
import org.rsbot.script.methods.Magic;
import org.rsbot.script.wrappers.RSArea;
import org.rsbot.script.wrappers.RSComponent;
import org.rsbot.script.wrappers.RSGroundItem;
import org.rsbot.script.wrappers.RSItem;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSTile;
@ScriptManifest(authors = { "Kubko" }, keywords = { "White", "Berry", "Picker" }, name = "KubkoWhiteBerries", description = "Pickin' up them berries.", version = 1.0, website = "http://www.powerbot.org/vb/showthread.php?t=722427", requiresVersion = 244)
public class KubkoWhiteBerries extends Script implements PaintListener,
MessageListener {
private enum STATE {
WALK_TO_BANK, LUMB_BANK, WALK_TO_LUMB_BANK, MAKE_CANOE, WORLDHOP, DEAD, WALK_TO_TELEGRAB_TILE, TELEPORT, WALK_TO_TELEGRAB, WALK_TO_GE, GO_TO_LAIR, WALK_TO_CAVE, TELEGRAB, BACK_TO_ENTRANCE, BANK, WALK_TO_SHORTCUT, SLEEP
}
public static String arrayToString2(final String[] a, final String separator) {
final StringBuffer result = new StringBuffer();
if (a.length > 0) {
result.append(a[0]);
for (int i = 1; i < a.length; i++) {
result.append(separator);
result.append(a[i]);
}
}
return result.toString();
}
int berryId;
int foodId;
double version = 1.0;
int varrockTab = 8007;
int whiteBerry = 239;
int geShortcut = 9312;
int wilderDitch = 1440;
int closedDeepGate = 1558;
int closedDeepGate2 = 1597;
int openDeepGate = 1561;
int openDeepGate2 = 1563;
boolean playerPassedShortcut;
String status = "";
int berriesPicked;
long startTime;
GEItem berry;
int berryPrice;
long millis = 0;
long hours = 0;
long minutes = 0;
long seconds = 0;
long last = 0;
int moneyPerHour;
int mode = 2;
int hatchet = 1359;
int lawRune = 554;
int fireRune = 563;
boolean needsToBank;// / TEst
int step = 0;; // /TEST
boolean compassClicked;
boolean isDead;
int spellsCasted;
boolean canoePaddled;
boolean canoeChopped;
boolean canoeFloated;
boolean canoeShaped;
boolean canoeSelected;
boolean lumbBanked;
int plane;
int airStaffId = 1381;
boolean worldHopped;;
boolean firstTeleGrab = true;
RSArea lair = new RSArea(new RSTile(2883, 4372), new RSTile(2888, 4377));
RSTile[] toGe = { new RSTile(3209, 3427), new RSTile(3208, 3431),
new RSTile(3206, 3436), new RSTile(3203, 3441),
new RSTile(3199, 3444), new RSTile(3194, 3447),
new RSTile(3189, 3448), new RSTile(3184, 3454),
new RSTile(3181, 3455), new RSTile(3175, 3459),
new RSTile(3166, 3461), new RSTile(3165, 3467),
new RSTile(3163, 3472), new RSTile(3163, 3477),
new RSTile(3161, 3482), new RSTile(3162, 3489) };
RSArea entrance = new RSArea(new RSTile(3213, 3778), new RSTile(3215, 3785));
public final RSTile[] backToEntrance = { new RSTile(3207, 3811),
new RSTile(3202, 3813), new RSTile(3198, 3819),
new RSTile(3198, 3825), new RSTile(3197, 3830),
new RSTile(3198, 3835), new RSTile(3203, 3837),
new RSTile(3204, 3843), new RSTile(3204, 3848),
new RSTile(3202, 3853), };
RSTile teleGrabTile = new RSTile(3218, 3805);
RSArea teleGrabTileArea = new RSArea(new RSTile(3214, 3790), new RSTile(3230, 3813));
public final RSTile[] backFromDragonIsle = { new RSTile(3200, 3814),
new RSTile(3201, 3819), new RSTile(3200, 3824),
new RSTile(3200, 3832), new RSTile(3200, 3837),
new RSTile(3202, 3842), new RSTile(3201, 3847),
new RSTile(3201, 3855) };
public final RSTile[] walkToIsle = { new RSTile(3201, 3853),
new RSTile(3202, 3847), new RSTile(3202, 3842),
new RSTile(3202, 3837), new RSTile(3202, 3832),
new RSTile(3201, 3827), new RSTile(3200, 3822),
new RSTile(3200, 3817), new RSTile(3204, 3814),
new RSTile(3207, 3810), new RSTile(3212, 3811),
new RSTile(3217, 3813) };
RSArea ge = new RSArea(new RSTile(3144, 3468), new RSTile(3185, 3516));
RSArea redDragonIsle = new RSArea(new RSTile(3189, 3821), new RSTile(3205, 3843));
RSArea teleGrabPlace = new RSArea(new RSTile(3211, 3790), new RSTile(3230, 3810));
public final RSArea redDragonEntrance = new RSArea(new RSTile[] {
new RSTile(3194, 3853), new RSTile(3208, 3853),
new RSTile(3209, 3858), new RSTile(3209, 3864),
new RSTile(3209, 3870), new RSTile(3207, 3875),
new RSTile(3202, 3876), new RSTile(3197, 3875) });
RSArea nearDitch = new RSArea(new RSTile(3127, 3498), new RSTile(3139, 3520));
public final RSTile[] toIsle = { new RSTile(3201, 3860),
new RSTile(3201, 3855), new RSTile(3201, 3849) };
RSTile geShortCut[] = { new RSTile(3158, 3485), new RSTile(3153, 3492),
new RSTile(3153, 3501), new RSTile(3148, 3507),
new RSTile(3145, 3510), new RSTile(3145, 3512),
new RSTile(3144, 3514) };
RSTile ditch = new RSTile(3138, 3520);
RSTile[] toLumb2 = { new RSTile(3219, 3219), new RSTile(3219, 3219),
new RSTile(3215, 3215), new RSTile(3219, 3219),
new RSTile(3215, 3215), new RSTile(3213, 3211),
new RSTile(3219, 3219), new RSTile(3215, 3215),
new RSTile(3213, 3211), new RSTile(3205, 3209) };
RSTile toBerry1[] = { new RSTile(3201, 3849), new RSTile(3201, 3843),
new RSTile(3201, 3837), new RSTile(3201, 3832),
new RSTile(3201, 3826), new RSTile(3201, 3820),
new RSTile(3196, 3812), new RSTile(3199, 3810),
new RSTile(3206, 3810) };
public final RSTile[] toFurther = { new RSTile(3200, 3856),
new RSTile(3203, 3860), new RSTile(3208, 3861),
new RSTile(3213, 3861), new RSTile(3218, 3860),
new RSTile(3223, 3860), new RSTile(3228, 3860) };
RSArea atBerries = new RSArea(new RSTile(3207, 3808), new RSTile(3221, 3820));
RSArea afterShortcut = new RSArea(new RSTile(3135, 3516), new RSTile(3138, 3516));
RSTile[] toCave = { new RSTile(3220, 3804), new RSTile(3219, 3800),
new RSTile(3218, 3795), new RSTile(3217, 3792),
new RSTile(3217, 3786), new RSTile(3214, 3783) };
RSArea varrockArea = new RSArea(new RSTile(3160, 3420), new RSTile(3232, 3476));
RSTile canoe = new RSTile(3133, 3510);
public final RSTile[] toTeleGrab = { new RSTile(3147, 3800),
new RSTile(3152, 3800), new RSTile(3157, 3800),
new RSTile(3162, 3800), new RSTile(3167, 3798),
new RSTile(3172, 3796), new RSTile(3177, 3794),
new RSTile(3183, 3792), new RSTile(3188, 3794),
new RSTile(3193, 3796), new RSTile(3198, 3797),
new RSTile(3203, 3797), new RSTile(3208, 3797),
new RSTile(3213, 3799), new RSTile(3218, 3800),
new RSTile(3222, 3803) };
RSArea lumbBank = new RSArea(new RSTile(3205, 3209), new RSTile(3212, 3225), 2);
RSArea lumb2ndFloor = new RSArea(new RSTile(3205, 3209), new RSTile(3210, 3223), 1);
RSArea lumbridgeArea = new RSArea(new RSTile(3203, 3202), new RSTile(3226, 3228), 0);
// START: Code generated using Enfilade's Easel
private final RenderingHints antialiasing = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
private final Color color1 = new Color(0, 153, 102);
private final Color color2 = new Color(0, 153, 153);
private final Color color3 = new Color(0, 0, 0);
private final Color color4 = new Color(255, 255, 0);
private final BasicStroke stroke1 = new BasicStroke(3);
private final Font font1 = new Font("Consolas", 2, 22);
private final Font font2 = new Font("French Script MT", 0, 25);
private final Image img1 = getImage("http://i51.tinypic.com/t9bd61.gif");
// script variables needed
public int maxPing = 150;
public int maxPastWorlds = 25;
public int currentWorld = 0;
public int pastWorld[] = new int[maxPastWorlds];
public int newWorld = 0;
public int hopped = 0;
public int skillTotal = -1; // the method used to count skillTotal returns
// (totalSkills + 1)
public boolean firstRun = true;
public String os = System.getProperty("os.name").toLowerCase();
public boolean atBerries() {
return atBerries.contains(getMyPlayer().getLocation());
}
boolean atDitch() {
return nearDitch.contains(getMyPlayer().getLocation());
}
// END: Code generated using Enfilade's Easel
boolean atEntrance() {
return redDragonEntrance.contains(getMyPlayer().getLocation());
}
boolean atGe() {
return ge.contains(getMyPlayer().getLocation());
}
public boolean atIsle2() {
return redDragonIsle.contains(getMyPlayer().getLocation());
}
void bank() {
}
void canoeChopping() {
final RSObject station2 = objects.getNearest(12166);
if (station2 != null && station2.isOnScreen()) {
camera.turnTo(station2);
station2.doAction("Chop-down");
log("trying to chopdown");
}
}
void canoeDestination() {
final RSComponent travel = interfaces.get(53).getComponent(45);
travel.doAction("Select");
log("trying to press travel to deep");
sleep(600, 1000);
}
void canoeFloating() {
canoeSelected = true;
status = "floating canoe";
log("trying to float");
final RSObject station2 = objects.getNearest(12166);
if (station2 != null && station2.isOnScreen()) {
station2.doAction("Float Canoe");
sleep(650);
canoeFloated = true;
sleep(3000, 4000);
step = 6;
}
}
void canoePaddling() {
canoeFloated = true;
final RSObject station2 = objects.getNearest(12166);
if (station2 != null && station2.isOnScreen()) {
station2.doAction("Paddle Canoe");
if (interfaces.get(53).getComponent(45).isValid()) {
canoePaddled = true;
}
}
}
void canoeSelecting() {
canoeShaped = true;
if (interfaces.get(52).getComponent(24).containsText("A Waka")) {
final RSComponent makeCanoe = interfaces.get(52).getComponent(24);
makeCanoe.doAction("Select");
log("WAKA WAKA");
sleep(600, 1000);
if (!interfaces.get(52).getComponent(24).isValid()) {
canoeSelected = true;
}
}
}
void canoeShaping() {
canoeChopped = true;
final RSObject station2 = objects.getNearest(12166);
if (station2 != null && station2.isOnScreen()) {
station2.doAction("Shape-canoe");
log("trying to shape");
step = 4;
}
}
void canoeToBerries() {
}
void canoeWalking() {
walking.walkTo(canoe);
firstTeleGrab = false;
step = 2;
}
private Image getImage(final String url) {
try {
return ImageIO.read(new URL(url));
} catch (final IOException e) {
return null;
}
}
private RSTile getNext(final RSTile[] path) {
boolean found = false;
for (int a = 0; a < path.length && !found; a++) {
if (calc.tileOnMap(path[path.length - 1 - a])) {
found = true;
return path[path.length - 1 - a];
}
}
return null;
}
boolean isOpen() {
final RSObject closed = objects.getNearest(closedDeepGate);
final RSObject open = objects.getNearest(openDeepGate);
final RSObject closed2 = objects.getNearest(closedDeepGate);
final RSObject open2 = objects.getNearest(openDeepGate);
if (closed == null && closed2 == null && open2 != null || open != null) {
return true;
}
return false;
}
private boolean isPastWorld(final int world) {
for (final int element : pastWorld) {
if (element == world) {
return true;
}
}
return false;
}
public int loop() {
if (game.isLoggedIn()) {
switch (states()) {
case MAKE_CANOE:
canoeWalking();
sleep(3000, 4000);
final RSObject station2 = objects.getNearest(12166);
if (station2.isOnScreen() && station2 != null) {
canoeChopping();
sleep(4000, 5000);
canoeChopped = true;
}
if (canoeChopped == true) {
canoeShaping();
sleep(4000, 6000);
if (interfaces.get(52).getComponent(24).isValid()) {
canoeShaped = true;
}
}
if (interfaces.get(52).getComponent(24).isValid()
&& canoeShaped == true) {
canoeSelecting();
sleep(7000, 8000);
}
if (canoeSelected == true) {
canoeFloating();
sleep(1500, 2000);
}
if (canoeFloated == true) {
canoePaddling();
sleep(1300, 2000);
}
if (interfaces.get(53).getComponent(45).isValid()) {
canoeDestination();
sleep(6000, 7000);
}
final RSComponent travel = interfaces.get(53).getComponent(45);
if (interfaces.get(53).getComponent(45).isValid()) {
travel.doAction("Select");
}
return 50;
case WALK_TO_LUMB_BANK:
walking.newTilePath(toLumb2);
sleep(450, 700);
final RSObject stairs = objects.getNearest(36773);
if (stairs.isOnScreen() && stairs != null) {
stairs.doAction("Climb-up");
}
if (game.getPlane() == 1) {
final RSObject stairs2 = objects.getNearest(36774);
stairs2.doAction("Climb-up");
sleep(600, 700);
}
case TELEGRAB:
if (firstTeleGrab == true) {
walking.walkTo(teleGrabTile);
firstTeleGrab = false;
}
// if (compassClicked == false){
// mouse.click(542, 24, 5, 5, true);
compassClicked = true;
if (getMyPlayer().getAnimation() == -1) {
if (!magic.isSpellSelected()) {
final RSGroundItem berryGround = groundItems.getNearest(239);
camera.turnTo(new RSTile(3216, 3806));
magic.castSpell(Magic.SPELL_TELEKINETIC_GRAB);
if (berryGround != null && berryGround.isOnScreen()) {
berryGround.doAction("Cast");
sleep(1300, 1600);
spellsCasted++;
}
} else {
final RSGroundItem berryGround2 = groundItems.getNearest(239);
if (berryGround2 != null && berryGround2.isOnScreen()) {
berryGround2.doAction("Cast");
sleep(1000, 1300);
}
}
}
return 50;
case WALK_TO_CAVE:
walking.newTilePath(toCave).traverse();
return 50;
// case CANOE_BANK:
case GO_TO_LAIR:
final RSObject entrance = objects.getNearest(38815);
if (entrance != null && entrance.isOnScreen()) {
entrance.doAction("Go-through");
sleep(600, 1000);
}
return 50;
case TELEPORT:
magic.castSpell(Magic.SPELL_VARROCK_TELEPORT);
log("teleported to varrock");
sleep(5000, 6000);
return 50;
case BACK_TO_ENTRANCE:
status = "Walking to entrance.";
walking.newTilePath(backToEntrance).traverse();
return 50;
case WALK_TO_BANK:
walking.newTilePath(backToEntrance).traverse();
return 50;
case WORLDHOP:
worldHop(true);
return 50;
case BANK:
status = "Banking";
walking.walkTo(new RSTile(3164, 3487));
sleep(1000, 2000);
bank.open();
sleep(300, 600);
if (bank.isOpen()) {
bank.depositAllExcept(hatchet, 554, 553);
berriesPicked = berriesPicked + 25;
bank.withdraw(554, 1);
sleep(300, 600);
bank.withdraw(563, 31);
if (inventory.contains(554) && inventory.contains(563)
&& inventory.contains(hatchet)) {
bank.close();
needsToBank = false;
}
}
case LUMB_BANK:
canoeFloated = false;
canoeChopped = false;
canoeSelected = false;
canoePaddled = false;
canoeShaped = false;
status = "Banking";
if (needsToBank) {
walking.walkTo(new RSTile(3208, 3220));
sleep(500, 700);
bank.open();
sleep(300, 600);
if (bank.isOpen()) {
bank.depositAllExcept(hatchet, 554, 553, 1381);
bank.withdraw(554, 1);
sleep(300, 600);
bank.withdraw(563, 31);
if (inventory.contains(554) && inventory.contains(563)
&& inventory.contains(hatchet)) {
bank.close();
needsToBank = false;
isDead = false;
final RSItem airstaff = inventory.getItem(1381);
sleep(600, 900);
if (lumbBanked == false && inventory.contains(1381)) {
airstaff.doAction("Wield");
airstaff.doAction("Wield");
airstaff.doAction("Wield");
final RSItem wielding = equipment.getItem(Equipment.WEAPON);
log("we are wielding " + wielding);
lumbBanked = true;
game.openTab(Game.TAB_EQUIPMENT);
if (equipment.getItem(Equipment.WEAPON) == airstaff) {
lumbBanked = true;
}
} else {
final RSItem airstaff2 = inventory.getItem(1381);
game.openTab(Game.TAB_EQUIPMENT);
sleep(1000, 1500);
final RSItem wielding4 = equipment.getItem(Equipment.WEAPON);
log("we are wielding " + wielding4);
if (equipment.getItem(Equipment.WEAPON) == airstaff2) {
final RSItem wielding2 = equipment.getItem(Equipment.WEAPON);
log("we are wielding " + wielding2);
lumbBanked = true;
} else {
final RSItem wielding3 = equipment.getItem(Equipment.WEAPON);
log("we are wielding " + wielding3);
log("no airstaff in inv or worn, shutting down, please have airstaff in inv OR woren");
stopScript();
}
}
}
}
}
return 50;
case WALK_TO_SHORTCUT:
status = "Walking to ge shortcut";
walking.newTilePath(geShortCut).traverse();
sleep(700, 1200);
final RSObject shortcut = objects.getNearest(geShortcut);
if (shortcut != null && shortcut.isOnScreen()) {
camera.turnTo(shortcut);
shortcut.doAction("Climb-into");
sleep(4500, 5000);
}
return 50;
case WALK_TO_GE:
walkPath(toGe);
sleep(800, 900);
return 50;
case WALK_TO_TELEGRAB:
compassClicked = false;
walking.newTilePath(toTeleGrab).traverse();
sleep(700, 900);
return 50;
case WALK_TO_TELEGRAB_TILE:
compassClicked = false;
walking.walkTo(teleGrabTile);
sleep(700, 1200);
sleep(1000, 1300);
return 50;
case SLEEP:
status = "ERROR";
log("Problem? Well, we do..");
}
}
return 1;
}
public void messageReceived(final MessageEvent e) {
final String message = e.getMessage();
if (message.contains("You don't have enough")
|| message.contains("You do not have enough")) {
needsToBank = true;
log("inv full, banking");
}
if (message.contains("Oh dear, you are dead")) {
isDead = true;
needsToBank = true;
}
if (message.contains("Too late")) {
spellsCasted--;
}
}
public void onRepaint(final Graphics g1) {
final Graphics2D g = (Graphics2D) g1;
millis = System.currentTimeMillis() - startTime;
hours = millis / (1000 * 60 * 60);
millis -= hours * 1000 * 60 * 60;
minutes = millis / (1000 * 60);
millis -= minutes * 1000 * 60;
seconds = millis / 1000;
moneyPerHour = (int) (berryPrice * berriesPicked * 3600000D / (System.currentTimeMillis() - startTime));
g.setRenderingHints(antialiasing);
g.setColor(color1);
g.fillRoundRect(5, 344, 507, 131, 16, 16);
g.setColor(color2);
g.setStroke(stroke1);
g.drawRoundRect(5, 344, 507, 131, 16, 16);
g.setFont(font1);
g.setColor(color3);
g.drawString("Kubko's WhiteBerries", 5, 367);
g.setFont(font2);
g.setColor(color4);
g.drawString("Time running: " + +hours + ":" + minutes + ":" + seconds
+ ", hopped " + hopped + " times", 6, 397);
g.drawString("Profit:" + berriesPicked * berryPrice, 5, 421);
g.drawString("Profit per hour:" + moneyPerHour + " gp", 5, 451);
g.drawImage(img1, 407, 356, null);
g.drawString("State:" + status, 226, 454);
}
public boolean onStart() {
log("Welcome to KubkoWhiteBerries v. " + version);
startTime = System.currentTimeMillis();
berry = grandExchange.lookup(whiteBerry);
berryPrice = berry.getGuidePrice();
log("Berry price is " + berryPrice + "gp");
status = "Starting up";
return true;
}
private int pingHost(final String host, final int timeout) {
long start = -1;
long end = -1;
int total = -1;
final int defaultPort = 80;
final Socket theSock = new Socket();
try {
final InetAddress addr = InetAddress.getByName(host);
final SocketAddress sockaddr = new InetSocketAddress(addr, defaultPort);
start = System.currentTimeMillis();
theSock.connect(sockaddr, timeout);
end = System.currentTimeMillis();
} catch (final Exception e) {
start = -1;
end = -1;
} finally {
if (theSock != null) {
try {
theSock.close();
} catch (final IOException e) {
}
if (start != -1 && end != -1) {
total = (int) (end - start);
log(host + "'s ping delay is " + total + "ms.");
} else {
log("Connection timed out or unable to connect to host: "
+ host);
}
}
}
return total; // returns -1 if timeout
}
private STATE states() {
if (mode == 2) {
if (game.getPlane() == 2 && lumbBanked == true
&& needsToBank == false && worldHopped == false) {
log("Wworldhopping. thanks to jtryba for world hop method");
return STATE.WORLDHOP;
}
if (isDead == true && !ge.contains(getMyPlayer().getLocation())
&& lumbBank.contains(getMyPlayer().getLocation())
&& lumbBanked == false && game.getPlane() >= 2) {
status = "banking i lumbriddge";
return STATE.LUMB_BANK;
}
if (isDead == true
&& lumbridgeArea.contains(getMyPlayer().getLocation())
|| lumb2ndFloor.contains(getMyPlayer().getLocation())
&& game.getPlane() <= 1) {
plane = game.getPlane();
status = "Walking to lumb bank";
log("our plane is: " + plane);
if (game.getPlane() == 2) {
log("WTF IS THIS FAIL BOT DOING, PLANE 3 MEANS WE SHOULD BE BANKING -.-");
}
return STATE.WALK_TO_LUMB_BANK;
}
if (teleGrabTileArea.contains(getMyPlayer().getLocation())
&& !needsToBank) {
status = "Telegrab";
return STATE.TELEGRAB;
}
if (!needsToBank
&& !redDragonIsle.contains(getMyPlayer().getLocation())
&& inventory.contains(hatchet)
&& ge.contains(getMyPlayer().getLocation())
&& !nearDitch.contains(getMyPlayer().getLocation())
&& !atEntrance() && inventory.contains(lawRune)
&& inventory.contains(fireRune)) {
status = "Walking to ShortCut";
return STATE.WALK_TO_SHORTCUT;
}
if (teleGrabPlace.contains(getMyPlayer().getLocation())
&& needsToBank) {
status = "Walking to cave";
return STATE.WALK_TO_CAVE;
}
if (nearDitch.contains(getMyPlayer().getLocation()) && !needsToBank
&& !atGe()
&& !redDragonIsle.contains(getMyPlayer().getLocation())
&& !atEntrance()) {
status = "Making canoe";
return STATE.MAKE_CANOE;
}
if (varrockArea.contains(getMyPlayer().getLocation())) {
status = "Walking to ge.";
return STATE.WALK_TO_GE;
}
if (lair.contains(getMyPlayer().getLocation()) && needsToBank
|| worldHopped == true) {
status = "teleporting to varrock";
return STATE.TELEPORT;
}
if (entrance.contains(getMyPlayer().getLocation()) && needsToBank) {
status = "going to lair.";
return STATE.GO_TO_LAIR;
}
if (ge.contains(getMyPlayer().getLocation()) && needsToBank == true
&& !lumbBank.contains(getMyPlayer().getLocation())
&& needsToBank == true || spellsCasted == 30
&& ge.contains(getMyPlayer().getLocation())) {
status = "banking";
return STATE.BANK;
}
if (!ge.contains(getMyPlayer().getLocation())
&& !lair.contains(getMyPlayer().getLocation())
&& !nearDitch.contains(getMyPlayer().getLocation())
&& !entrance.contains(getMyPlayer().getLocation())
&& !varrockArea.contains(getMyPlayer().getLocation())
&& !teleGrabPlace.contains(getMyPlayer().getLocation())
&& !needsToBank
&& !lumbBank.contains(getMyPlayer().getLocation())
&& !lumbridgeArea.contains(getMyPlayer().getLocation())) {
status = "walking to telegrab place";
return STATE.WALK_TO_TELEGRAB;
}
}
return STATE.SLEEP;
}
void teleToBerries() {
}
private boolean walkPath(final RSTile path[]) {
return walkPath(path, false);
}
/**
* Checks wether the door is open or closed.
*
* @param tile
* - any tile after the door tile, you can also use getEnd()
* method.
* @return true if the door is open, otherwise false.
*/
private boolean walkPath(final RSTile[] path, final boolean reverse) {
if (reverse) {
for (int i = 0; i < path.length; i++) {
path[i] = path[path.length - i - 1];
}
}
if (calc.distanceTo(path[path.length - 1]) > 4) {
final RSTile n = getNext(path);
if (n != null) {
walking.walkTileMM(n.randomize(2, 2));
if (random(1, 6) != 2) {
mouse.moveRandomly(20);
}
}
}
return false;
}
/**
* Hops to the first visible filtered world on the list by jtryba avoids the
* last x worlds you've been to since starting the script credits to MrByte
* for his help
*
* @param members
* <tt>true</tt> if player should hop to a members world.
* @return void
*
*/
public void worldHop(final boolean members) {
worldHop(members, 150, 2000);
}
public void worldHop(final boolean members, final int maxping) {
worldHop(members, maxping, 2000);
}
public void worldHop(final boolean members, final int maxping,
final int maxpop) {
final int LOBBY_PARENT = 906;
final int WORLD_SELECT_TAB_PARENT = 910;
final int WORLD_SELECT_COM = 77;
final int WORLD_NUMBER_COM = 69;
final int WORLD_POPULATION_COM = 71;
final int WORLD_TYPE_COM = 74;
final int WORLD_SELECT_BUTTON_COM = 188;
final int WORLD_SELECT_BUTTON_BG_COM = 12;
final int WORLD_SELECT_TAB_ACTIVE = 4671;
final int WORLD_FULL_BACK_BUTTON_COM = 233;
final int CURRENT_WORLD_COM = 11;
final int SORT_POPULATION_BUTTON_PARENT = 30;
final int SORT_PING_BUTTON_PARENT = 45;
final int SORT_LOOTSHARE_BUTTON_PARENT = 47;
final int SORT_TYPE_BUTTON_PARENT = 49;
final int SORT_ACTIVITY_BUTTON_PARENT = 52;
final int SORT_WORLD_BUTTON_PARENT = 55;
final int SCROLL_BAR_PARENT = 86;
final int HIGH_RISK_WARN_PARENT = 93;
final int PLAY_BUTTON_COM = 171;
final int RETURN_TEXT_COM = 221;
final int SUBSCRIBE_BACK_BUTTON_COM = 233;
final int CONNECT_ERROR_BACK_BUTTON_COM = 42;
final int SKILL_WORLD_BACK_BUTTON_COM = 228;
final int SKILL_WORLD_NUMBER = 113;
log("Hopping worlds");
status = "Hopping worlds";
// logout
while (game.isLoggedIn()) {
if (game.logout(true)) {
while (game.getClientState() != 7) {
sleep(random(200, 500));
}
}
}
status = "Selecting new world";
sleep(random(1500, 2000));
// click world select tab (if needed)
final RSComponent worldSelectTab = interfaces.getComponent(LOBBY_PARENT, WORLD_SELECT_BUTTON_BG_COM);
while (worldSelectTab.getBackgroundColor() != WORLD_SELECT_TAB_ACTIVE) {
if (interfaces.getComponent(LOBBY_PARENT, WORLD_SELECT_BUTTON_COM).doClick()) {
sleep(random(1500, 2000));
}
}
// get current world
final String cW = interfaces.getComponent(WORLD_SELECT_TAB_PARENT, CURRENT_WORLD_COM).getText();
final String[] cWS = cW.split(" ");
currentWorld = Integer.parseInt(cWS[1]);
newWorld = currentWorld;
// randomly sort worlds
if (random(0, 10) < 5) {
RSComponent com = null;
switch (random(0, 6)) {
case 0: // population
com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT, SORT_POPULATION_BUTTON_PARENT).getComponent(random(0, 2));
break;
case 1: // ping
com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT, SORT_PING_BUTTON_PARENT).getComponent(random(0, 2));
break;
case 2: // loot share
com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT, SORT_LOOTSHARE_BUTTON_PARENT).getComponent(random(0, 2));
break;
case 3: // type
com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT, SORT_TYPE_BUTTON_PARENT).getComponent(random(0, 2));
break;
case 4: // activity
com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT, SORT_ACTIVITY_BUTTON_PARENT).getComponent(random(0, 2));
break;
case 5: // world
com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT, SORT_WORLD_BUTTON_PARENT).getComponent(random(0, 2));
break;
}
if (com.doClick()) {
sleep(random(1250, 1500));
}
}
// check if we should sort by ptp/ftp
boolean sort = false;
final RSComponent[] wt = interfaces.getComponent(WORLD_SELECT_TAB_PARENT, WORLD_TYPE_COM).getComponents();
for (int i = 0; i < 10; i++) {
if (members && !wt[i].getText().contains("Members") || !members
&& wt[i].getText().contains("Members")) {
sort = true;
break;
}
}
// sort by ptp/ftp (if needed)
if (sort) {
status = "Sorting worlds by type";
if (interfaces.getComponent(WORLD_SELECT_TAB_PARENT, SORT_TYPE_BUTTON_PARENT).getComponent(members ? 0
: 1).doClick()) {
sleep(random(1000, 1500));
}
}
/*-PICK-NEXT-WORLD-*/
while (currentWorld == newWorld) {
RSComponent worldToHop = null;
RSComponent[] comWorldNumber = interfaces.getComponent(WORLD_SELECT_TAB_PARENT, WORLD_NUMBER_COM).getComponents();
int world = 0;
int pop = 2000;
int ping = -1;
boolean member = false;
while (worldToHop == null) {
for (int i = 0; i < comWorldNumber.length - 1; i++) {
final RSComponent[] comWorldSelect = interfaces.getComponent(WORLD_SELECT_TAB_PARENT, WORLD_SELECT_COM).getComponents();
final RSComponent[] comWorldPopulation = interfaces.getComponent(WORLD_SELECT_TAB_PARENT, WORLD_POPULATION_COM).getComponents();
final RSComponent[] comWorldType = interfaces.getComponent(WORLD_SELECT_TAB_PARENT, WORLD_TYPE_COM).getComponents();
comWorldNumber = interfaces.getComponent(WORLD_SELECT_TAB_PARENT, WORLD_NUMBER_COM).getComponents();
try {
world = Integer.parseInt(comWorldNumber[i].getText());
} catch (final NumberFormatException nfe) {
world = 0;
} catch (final ArrayIndexOutOfBoundsException aie) {
world = 0;
}
if (world == SKILL_WORLD_NUMBER && skillTotal < 1000) {
world = 0;
}
try {
pop = Integer.parseInt(comWorldPopulation[i].getText());
} catch (final NumberFormatException nfe) {
pop = 2000;
} catch (final ArrayIndexOutOfBoundsException aie) {
pop = 2000;
}
try {
if (comWorldType[i].getText().contains("Members")) {
member = true;
}
} catch (final ArrayIndexOutOfBoundsException aie) {
}
if (world != 0 && !isPastWorld(world)
&& world != currentWorld && pop < maxpop && pop > 0
&& member == members) {
ping = pingHost("world" + world + ".runescape.com", maxPing + 50);
} else {
ping = -1;
}
if (ping < maxping && ping > 0) {
log("World " + world + " selected.");
worldToHop = comWorldSelect[i];
}
if (worldToHop != null) {
break;
}
}
sleep(random(50, 150));
}
if (worldToHop != null) {
int w = -1;
String[] split = interfaces.getComponent(910, 8).getText().split(" ");
try {
w = Integer.parseInt(split[split.length - 1]);
} catch (final Exception e) {
w = -1;