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 pathSneakyFarmer.java
More file actions
1014 lines (916 loc) · 39.2 KB
/
SneakyFarmer.java
File metadata and controls
1014 lines (916 loc) · 39.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 org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSNPC;
import org.rsbot.script.wrappers.RSItem;
import org.rsbot.script.wrappers.RSTile;
import org.rsbot.script.wrappers.RSArea;
import org.rsbot.event.events.MessageEvent;
import org.rsbot.event.listeners.MessageListener;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.script.methods.Magic;
import org.rsbot.script.methods.Skills;
import org.rsbot.script.util.Timer;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.imageio.ImageIO;
import java.io.IOException;
import java.net.URL;
import java.util.Random;
import java.awt.geom.GeneralPath;
import java.util.ArrayList;
@ScriptManifest(authors={"MrSneaky"}, keywords={"Farming", "mrsneaky", "herb", "farmer"}, name="SneakyFarmer", description="Farms herbs at 3 patches", version=1.60)
public class SneakyFarmer extends Script implements MessageListener, PaintListener, MouseListener {
private static String scriptVersion = "1.60";
private static int herbPlot[] = {8150,8151,8152};
private int seedID;
private int grimyID;
private int notedID;
private int startingNoteSize;
private static int rakeID = 5341;
private static int dibberID = 5343;
private static int spadeID = 952;
private static int compostID = 6034;
private static int bucketID = 1925;
private static int weedsID = 6055;
private static int plantCureID = 6036;
private static int vialID = 229;
private static int leprechaunID[] = {3021,7557};
private static int leprechaunInterface = 125;
private static int closeInterface = 34;
private int numSeedsPlanted = 0;
private int numHerbsFarmed = 0;
private int marketPriceOfHerbs;
private int marketPriceOfSeeds;
private static String rake = "Rake";
private static String pick = "Pick";
private static String inspect = "Inspect";
private static String clear = "Clear";
private String status = "Starting Script";
private String seedType;
private boolean scriptRunning = true;
private RSArea camelotFarmingArea = new RSArea(new RSTile(2804,3458), new RSTile(2815,3469));
private RSArea faladorFarmingArea = new RSArea(new RSTile(3050,3303), new RSTile(3061,3315));
private RSArea ardougneFarmingArea = new RSArea(new RSTile(2660,3370), new RSTile(2672,3381));
private RSArea camelotTeleArea = new RSArea(new RSTile(2752,3472), new RSTile(2762,3482));
private RSArea faladorTeleArea = new RSArea(new RSTile(2957,3374), new RSTile(2970,3384));
private RSArea ardougneTeleArea = new RSArea(new RSTile(2656,3298), new RSTile(2666,3311));
private Line[] camelotPath = {new Line(2755, 3481, 2755, 3475), new Line(2765, 3478, 2765, 3475), new Line(2772, 3478, 2773, 3472), new Line(2782, 3476, 2780, 3463), new Line(2790, 3473, 2789, 3463), new Line(2803, 3473, 2801, 3470), new Line(2814, 3465, 2814, 3461)};
private Line[] faladorPath = {new Line(2960, 3384, 2962, 3376), new Line(2971, 3381, 2971, 3378), new Line(2983, 3378, 2982, 3373), new Line(2988, 3373, 2986, 3370), new Line(2993, 3370, 2992, 3369), new Line(2997, 3367, 2996, 3365), new Line(3007, 3361, 3001, 3352), new Line(3008, 3349, 3006, 3349), new Line(3008, 3340, 3006, 3340), new Line(3008, 3335, 3006, 3335), new Line(3008, 3324, 3005, 3324), new Line(3009, 3322, 3006, 3317), new Line(3020, 3322, 3020, 3314), new Line(3030, 3324, 3030, 3314), new Line(3042, 3322, 3042, 3314), new Line(3052, 3318, 3052, 3313), new Line(3055, 3309, 3060, 3309)};
//private Line[] ardougnePath = {new Line(2659, 3296, 2669, 3305), new Line(2651, 3316, 2654, 3318), new Line(2648, 3324, 2651, 3324), new Line(2646, 3330, 2647, 3333), new Line(2637, 3332, 2641, 3335), new Line(2633, 3343, 2638, 3344), new Line(2635, 3351, 2638, 3351), new Line(2635, 3364, 2640, 3364), new Line(2641, 3375, 2645, 3372), new Line(2644, 3377, 2647, 3376), new Line(2646, 3382, 2649, 3379), new Line(2652, 3383, 2652, 3381), new Line(2658, 3382, 2658, 3381), new Line(2669, 3377, 2670, 3373)};
private final Line[] ardougnePath = {new Line(2653, 3311, 2653, 3298), new Line(2672,3306,2672,3304), new Line(2690,3307,2692,3305), new Line(2689,3320,2695,3321), new Line(2688,3328,2690,3328), new Line(2677,3345,2686,3347), new Line(2675,3358,2686,3363), new Line(2666,3373,2670,3377)};
private AntiBan antiBan;
private Timer runTime;
private Timer breakTimer;
private ArrayList<RSTile> pathList;
private boolean hidePaint = false;
private Rectangle closePaint = new Rectangle(425, 9, 83, 26);
private Point p;
private enum Location {CAMELOT, FALADOR, ARDOUGNE;
public String toString() {
switch(this) {
case CAMELOT: return "Camelot";
case FALADOR: return "Falador";
case ARDOUGNE: return "Ardougne";
default: throw new IllegalArgumentException();
}
}
}
private enum State {CHECK_CROPS, PICK, RAKE, COMPOST, PLANT, CLEAR, CURE, WALKING, TELEPORT, BREAK}
private Location currentLocation;
private State currentState;
public boolean onStart() {
log("Welcome to Sneaky's Herb farmer");
if(game.isLoggedIn()) {
camera.setPitch(100);
antiBan = new AntiBan(this);
antiBan.start();
} else {
log ("Please log in before starting this script.");
scriptRunning = false;
return false;
}
if (!camelotFarmingArea.contains(getMyPlayer().getLocation())) {
log("Not in Camelot farming patch. Please start the script there.");
scriptRunning = false;
return false;
}
// Start GUI to select which Herb to farm
HerbFarmerGUI GUI = new HerbFarmerGUI();
GUI.setVisible(true);
while(GUI.isVisible()){
sleep(50);
}
currentLocation = Location.CAMELOT;
currentState = State.CHECK_CROPS;
notedID = grimyID + 1;
if (inventory.contains(notedID))
startingNoteSize = inventory.getItem(notedID).getStackSize();
runTime = new Timer(0);
marketPriceOfHerbs = grandExchange.lookup(grimyID).getGuidePrice();
marketPriceOfSeeds = grandExchange.lookup(seedID).getGuidePrice();
log("You are farming " + seedType);
log("The market price of each " + seedType + " seed is: " + marketPriceOfSeeds + "gp");
log("The market price of each " + seedType + " herb is: " + marketPriceOfHerbs + "gp");
// check if inventory contains seeds, rake, dibber, spade
if (!checkInventory()) {
log("You do not have all of the required materials in your inventory");
log("(Seeds, rake, dibber, and spade). Stopping script.");
scriptRunning = false;
return false;
}
return true;
}
public void onFinish(){
log("Thank you for using Sneaky's Herb Farmer!");
env.saveScreenshot(false);
scriptRunning = false;
}
public int loop() {
if (checkInventory() || status == "Logging back in") {
if (status == "Logging back in") {
int timeout = 200;
while(game.getClientState() != 10 && timeout > 0) {
sleep(100);
timeout++;
}
if(timeout == 0)
return 100;
sleep(random(4000,5000)); // Wait while information is loaded from server
}
switch(currentState) {
case CHECK_CROPS: checkCrops(); break;
case PICK: pickHerbs(); break;
case RAKE: rakePatch(); break;
case COMPOST: compostPatch(); break;
case PLANT: plantSeed(); break;
case CLEAR: clearHerbs(); break;
case CURE: cureHerbs(); break;
case WALKING:
switch(currentLocation) {
case CAMELOT: walk(Location.FALADOR, State.CHECK_CROPS); break;
case FALADOR: walk(Location.ARDOUGNE, State.CHECK_CROPS); break;
case ARDOUGNE: walk(Location.CAMELOT, State.BREAK); break;
} break;
case TELEPORT:
switch(currentLocation) {
case CAMELOT: teleport(Location.FALADOR); break;
case FALADOR: teleport(Location.ARDOUGNE); break;
case ARDOUGNE: teleport(Location.CAMELOT); break;
} break;
case BREAK: handleBreak(); break;
}
performMaintainance();
return random(1000,2000);
}
return -1;
}
private void checkCrops() {
status = "Checking crops";
RSObject plot = objects.getNearest(herbPlot);
if (plot != null) {
if (!plot.isOnScreen() || calc.distanceTo(plot) > 3) {
walking.walkTileMM(plot.getLocation(), 1, 1);
sleep(random(3000,4000));
}
plot.doAction(inspect);
}
}
private void pickHerbs() {
status = "Picking herbs";
RSObject plot = objects.getNearest(herbPlot);
if (plot != null) {
plot.doAction(pick);
sleep(random(1250,2000));
Timer idleTimer = new Timer(random(1250,2000));
while(idleTimer.isRunning()) {
if (players.getMyPlayer().getAnimation() != -1)
idleTimer.reset();
sleep(random(50,200));
}
}
currentState = State.CHECK_CROPS;
}
private void cureHerbs() {
status = "Curing diseased herbs";
RSObject plot = objects.getNearest(herbPlot);
if (plot != null) {
if (inventory.contains(plantCureID)) {
int tmp = inventory.getCount(plantCureID);
for (int i = 0; i < 5; i++) {
if (tmp == inventory.getCount(plantCureID) && currentState == State.CURE) {
if (i > 0)
camera.setAngle(random(0,360));
inventory.getItem(plantCureID).doClick(true);
plot.doClick();
sleep(random(3000,4000));
} else break;
}
}
sleep(random(200,300));
}
currentState = State.CHECK_CROPS;
}
private void clearHerbs() {
status = "Clearing dead herbs";
RSObject plot = objects.getNearest(herbPlot);
if (plot != null) {
plot.doAction(clear);
sleep(random(1250,2000));
Timer idleTimer = new Timer(random(1250,2000));
while(idleTimer.isRunning()) {
if (players.getMyPlayer().getAnimation() != -1)
idleTimer.reset();
sleep(random(50,200));
}
}
currentState = State.CHECK_CROPS;
}
private void rakePatch() {
status = "Raking the patch";
RSObject plot = objects.getNearest(herbPlot);
if (plot != null) {
plot.doAction(rake);
sleep(random(1250,2000));
Timer idleTimer = new Timer(random(1250,2000));
while(idleTimer.isRunning()) {
if (players.getMyPlayer().getAnimation() != -1)
idleTimer.reset();
sleep(random(50,200));
}
}
currentState = State.CHECK_CROPS;
}
private void compostPatch() {
status = "Adding supercompost";
RSObject plot = objects.getNearest(herbPlot);
if (plot != null) {
if (!inventory.contains(compostID)) {
RSNPC leprechaun = npcs.getNearest(leprechaunID);
if (!leprechaun.isOnScreen() || calc.distanceTo(leprechaun) > 4) {
walking.walkTileMM(leprechaun.getLocation(), 1, 1);
sleep(random(3000,4000));
}
leprechaun.doAction("Exchange");
sleep(random(1500,2000));
mouse.click(359,265,10,10,true);
sleep(random(300,900));
interfaces.getComponent(leprechaunInterface, closeInterface).doClick();
sleep(random(200,300));
if (!plot.isOnScreen() || calc.distanceTo(plot) > 4) {
walking.walkTileMM(plot.getLocation(), 1, 1);
sleep(random(3000,4000));
}
}
if (inventory.contains(compostID)) {
int tmp = inventory.getCount(compostID);
for (int i = 0; i < 5; i++) {
if (tmp == inventory.getCount(compostID) && currentState == State.COMPOST) {
if (i > 0)
camera.setAngle(random(0,360));
if (inventory.contains(compostID)) {
inventory.getItem(compostID).doClick(true);
plot.doClick();
}
sleep(random(4000,5000));
} else break;
}
}
}
currentState = State.CHECK_CROPS;
}
private void plantSeed() {
status = "Planting seed";
RSObject plot = objects.getNearest(herbPlot);
if (plot != null && inventory.contains(seedID)) {
int tmp = inventory.getItem(seedID).getStackSize();
for (int i = 0; i < 5; i++) {
if (tmp == inventory.getItem(seedID).getStackSize() && currentState == State.PLANT) {
if (i > 0)
camera.setAngle(random(0,360));
inventory.getItem(seedID).doClick(true);
plot.doClick();
sleep(random(2000,3000));
} else {
if (currentState == State.PLANT)
numSeedsPlanted++;
break;
}
}
}
currentState = State.CHECK_CROPS;
}
private void noteHerbs() {
if(inventory.containsOneOf(grimyID)) {
status = "Noting herbs";
RSNPC leprechaun = npcs.getNearest(leprechaunID);
if (!leprechaun.isOnScreen() || calc.distanceTo(leprechaun) > 4) {
walking.walkTileMM(leprechaun.getLocation(), 1, 1);
sleep(random(3000,4000));
}
int tmp = inventory.getCount(grimyID);
for (int i = 0; i < 5; i++) {
if (tmp == inventory.getCount(grimyID)) {
inventory.getItem(grimyID).doAction("Use");
sleep(200,300);
if(inventory.isItemSelected()){
leprechaun.doAction("Use");
sleep(3000,4000);
}
} else break;
}
RSObject plot = objects.getNearest(herbPlot);
if (plot != null) {
if (!plot.isOnScreen()) {
walking.walkTileMM(plot.getLocation(), 1, 1);
sleep(random(3000,4000));
}
}
}
}
private void checkEnergy() {
if (walking.getEnergy() > random(55,80)) {
if (!walking.isRunEnabled())
walking.setRun(true);
sleep(random(200,300));
}
}
// Walk to the specified location, and set the nextState once you get there
private void walk(Location loc, State nextState) {
if(getFarmingArea(loc).contains(getMyPlayer().getLocation())) {
currentLocation = loc;
currentState = nextState; // This is the last spot of each run. Break here.
} else {
checkEnergy();
status = "Walking to " + loc.toString() + " herb patch";
step(pathList);
}
}
// Teleport to the specified location
private void teleport(Location loc) {
status = "Teleporting to " + loc.toString();
if (magic.castSpell(getSpell(loc))) {
sleep(random(9000,11000));
if(getTeleArea(loc).contains(getMyPlayer().getLocation())) { // Teleport successful if player is in the tele area
currentState = State.WALKING;
pathList = generatePath(getPath(loc));
}
}
}
private int getSpell(Location loc) {
switch (loc) {
case CAMELOT: return Magic.SPELL_CAMELOT_TELEPORT;
case FALADOR: return Magic.SPELL_FALADOR_TELEPORT;
case ARDOUGNE: return Magic.SPELL_ARDOUGNE_TELEPORT;
}
return -1; // Error
}
private Line[] getPath(Location loc) {
switch (loc) {
case CAMELOT: return camelotPath;
case FALADOR: return faladorPath;
case ARDOUGNE: return ardougnePath;
}
return new Line[]{new Line(0,0,0,0)}; // Error
}
private RSArea getFarmingArea(Location loc) {
switch (loc) {
case CAMELOT: return camelotFarmingArea;
case FALADOR: return faladorFarmingArea;
case ARDOUGNE: return ardougneFarmingArea;
}
return new RSArea(0,0,0,0); // Error
}
private RSArea getTeleArea(Location loc) {
switch (loc) {
case CAMELOT: return camelotTeleArea;
case FALADOR: return faladorTeleArea;
case ARDOUGNE: return ardougneTeleArea;
}
return new RSArea(0,0,0,0); // Error
}
private boolean checkInventory() {
return (inventory.contains(seedID) && inventory.contains(rakeID) && inventory.contains(dibberID) && inventory.contains(spadeID));
}
private void dropAll(ArrayList<Integer> ids) {
for(RSItem item : inventory.getItems()) {
if(ids.contains(item.getID())) {
if (item.doAction("Drop"))
sleep(random(500,700));
}
}
}
private void updateHerbCount() {
if (inventory.contains(notedID))
numHerbsFarmed = inventory.getItem(notedID).getStackSize() - startingNoteSize;
else
numHerbsFarmed = 0;
}
private void performMaintainance() {
ArrayList<Integer> toDrop = new ArrayList<Integer>();
toDrop.add(weedsID);
toDrop.add(bucketID);
toDrop.add(vialID);
dropAll(toDrop);
noteHerbs();
updateHerbCount();
}
private void handleBreak() {
game.logout(false);
int sleepLength = random(900000,1500000); // 15-25 minutes (grow a little then check on them)
breakTimer = new Timer(sleepLength);
status = "Breaking while herbs grow: ";
sleep(sleepLength);
status = "Logging back in";
currentState = State.CHECK_CROPS;
}
public void messageReceived(MessageEvent e) {
if (e.getID() != MessageEvent.MESSAGE_SERVER)
return;
String msg = e.getMessage();
if (msg.contains("patch is fully")) {
currentState = State.PICK;
} else if (msg.contains("infected")) {
currentState = State.CLEAR;
} else if (msg.contains("needs attending")) {
currentState = State.CURE;
} else if (msg.contains("something growing")) {
currentState = State.TELEPORT;
} else if (msg.contains("weeding")) {
currentState = State.RAKE;
} else if (msg.contains("not been treated")) {
currentState = State.COMPOST;
} else if (msg.contains("supercompost. The patch is empty")) {
currentState = State.PLANT;
}
}
//START: Code generated using Enfilade's Easel
private Image getImage(String url) {
try {
return ImageIO.read(new URL(url));
} catch(IOException e) {
return null;
}
}
private final Color color1 = new Color(0, 1, 0);
private final Color color2 = new Color(50, 110, 20);
private final Color color3 = new Color(254, 255, 254);
private final Font font1 = new Font("Arial", 1, 12);
private final Image img1 = getImage("http://dl.dropbox.com/u/4287505/RSBot/sneakyFarmer/sneakyFarmerPaint.png");
public void onRepaint(Graphics g1) {
Graphics2D g = (Graphics2D)g1;
String paintText = "Hide Paint";
if (hidePaint) {
paintText = "Show Paint";
g.setColor(color1);
g.fillRoundRect(closePaint.x, closePaint.y, closePaint.width, closePaint.height, 16, 16);
g.setColor(color3);
g.drawString(paintText, 435, 27);
} else {
g.setColor(color2);
g.fillRoundRect(closePaint.x, closePaint.y, closePaint.width, closePaint.height, 16, 16);
g.setColor(color3);
g.drawString(paintText, 438, 27);
final int skillPercent = skills.getPercentToNextLevel(Skills.FARMING);
final int skillXP = skills.getExpToNextLevel(Skills.FARMING);
final String xpToLevel;
if (skillXP >= 1000)
xpToLevel = Integer.toString(skillXP/1000) + "k";
else
xpToLevel = Integer.toString(skillXP);
final int nextLevel = skills.getRealLevel(Skills.FARMING) + 1;
final int profit = marketPriceOfHerbs * numHerbsFarmed - marketPriceOfSeeds * numSeedsPlanted;
final String profitMade;
if (profit >= 100000)
profitMade = Integer.toString(profit/1000) + "k";
else
profitMade = Integer.toString(profit);
String displayStatus = status;
if (displayStatus == "Breaking while herbs grow: ")
displayStatus += breakTimer.toRemainingString();
int mouseX, mouseY;
mouseX = (int)mouse.getLocation().getX();
mouseY = (int)mouse.getLocation().getY();
g.setColor(color1);
g.drawLine(mouseX-1000,mouseY,mouseX+1000,mouseY);
g.drawLine(mouseX,mouseY-1000,mouseX,mouseY+1000);
g.fillRect(69, 320, 450, 21);
g.setColor(color2);
g.fillRect(69, 320, 450*skillPercent/100, 21);
g.drawImage(img1, 0, 243, null);
g.setFont(font1);
g.drawString("Version: " + scriptVersion, 431, 471);
g.setColor(color3);
g.drawString(skillPercent + "% to level " + nextLevel + " (" + xpToLevel + " xp)", 216, 334);
g.setColor(color1);
g.drawString("Time Running: " + runTime.toElapsedString(), 102, 398);
g.drawString("Herbs Farmed: " + numHerbsFarmed, 319, 399);
g.drawString("Profit Made: " + profitMade, 319, 416);
g.drawString("Seeds Planted: " + numSeedsPlanted, 102, 415);
g.drawString("Seed Type: " + seedType, 102, 431);
g.drawString("Status: " + displayStatus, 102, 449);
if (currentLocation == Location.ARDOUGNE)
for(int i = 1; i < camelotPath.length; i++)
camelotPath[i].drawTo(g1, camelotPath[i-1]);
if (currentLocation == Location.CAMELOT)
for(int i = 1; i < faladorPath.length; i++)
faladorPath[i].drawTo(g1, faladorPath[i-1]);
if (currentLocation == Location.FALADOR)
for(int i = 1; i < ardougnePath.length; i++)
ardougnePath[i].drawTo(g1, ardougnePath[i-1]);
}
}
//END: Code generated using Enfilade's Easel
public void mouseClicked(MouseEvent e){
p = e.getPoint();
if(closePaint.contains(p))
hidePaint = !hidePaint;
}
public void mouseEntered(MouseEvent e){
}
public void mouseExited(MouseEvent e){
}
public void mouseReleased(MouseEvent e){
}
public void mousePressed(MouseEvent e){
}
public class HerbFarmerGUI extends JFrame {
private static final long serialVersionUID = 1L;
private JLabel label1;
private JComboBox comboBox1;
private JButton button1;
public HerbFarmerGUI() {
initComponents();
}
private void initComponents() {
label1 = new JLabel();
comboBox1 = new JComboBox();
button1 = new JButton();
//======== this ========
setTitle("SneakyFarmer");
Container contentPane = getContentPane();
contentPane.setLayout(null);
//---- label1 ----
label1.setText("Which herb to farm:");
label1.setFont(label1.getFont().deriveFont(label1.getFont().getSize() + 1f));
contentPane.add(label1);
label1.setBounds(10, 10, 125, 35);
//---- comboBox1 ----
comboBox1.setModel(new DefaultComboBoxModel(new String[] {
"Guam",
"Marrentill",
"Tarromin",
"Harralander",
"Ranarr",
"Toadflax",
"Irit",
"Avantoe",
"Kwuarm",
"Snapdragon",
"Cadantine",
"Lantadyme",
"Dwarf Weed",
"Torstol"
}));
contentPane.add(comboBox1);
comboBox1.setBounds(135, 10, 90, 35);
//---- button1 ----
button1.setText("Start Farming!");
button1.setFont(button1.getFont().deriveFont(button1.getFont().getSize() + 7f));
contentPane.add(button1);
button1.setBounds(10, 50, 215, 35);
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
startActionPerformed(e);
}
});
{ // compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < contentPane.getComponentCount(); i++) {
Rectangle bounds = contentPane.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = contentPane.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
contentPane.setMinimumSize(preferredSize);
contentPane.setPreferredSize(preferredSize);
}
pack();
setLocationRelativeTo(getOwner());
}
private void startActionPerformed(ActionEvent e) {
seedType = comboBox1.getSelectedItem().toString();
if (seedType.equals("Guam")) {
seedID = 5291;
grimyID = 199;
} else if (seedType.equals("Marrentill")) {
seedID = 5292;
grimyID = 201;
} else if (seedType.equals("Tarromin")) {
seedID = 5293;
grimyID = 203;
} else if (seedType.equals("Harralander")) {
seedID = 5294;
grimyID = 205;
} else if (seedType.equals("Ranarr")) {
seedID = 5295;
grimyID = 207;
} else if (seedType.equals("Toadflax")) {
seedID = 5296;
grimyID = 3049;
} else if (seedType.equals("Irit")) {
seedID = 5297;
grimyID = 209;
} else if (seedType.equals("Avantoe")) {
seedID = 5298;
grimyID = 211;
} else if (seedType.equals("Kwuarm")) {
seedID = 5299;
grimyID = 213;
} else if (seedType.equals("Snapdragon")) {
seedID = 5300;
grimyID = 3051;
} else if (seedType.equals("Cadantine")) {
seedID = 5301;
grimyID = 215;
} else if (seedType.equals("Lantadyme")) {
seedID = 5302;
grimyID = 2485;
} else if (seedType.equals("Dwarf Weed")) {
seedID = 5303;
grimyID = 217;
} else if (seedType.equals("Torstol")) {
seedID = 5304;
grimyID = 219;
}
setVisible(false);
dispose();
}
}
// Credits go to Unknown500 for the AntiBan skeleton code
public class AntiBan extends Thread {
private SneakyFarmer parent;
private Random randomGenerator;
AntiBan(SneakyFarmer parent) {
this.parent = parent;
this.randomGenerator = new Random();
}
public void run() {
try {
while(scriptRunning) {
if(!parent.isPaused() && parent.game.isLoggedIn() && status != "Logging back in") {
int rand = randomGenerator.nextInt(30);
switch(rand) {
case 1:
parent.camera.setAngle(parent.random(0,360));
break;
case 2:
parent.camera.setPitch(parent.random(40,100));
break;
case 3:
parent.mouse.setSpeed(parent.random(5,9));
break;
case 5:
parent.camera.setPitch(parent.random(40,100));
parent.camera.setAngle(parent.random(0,360));
break;
default:
break;
}
}
sleep(parent.random(2000, 5000));
}
}
catch(InterruptedException e) {
log(e.getMessage());
}
}
}
//Credits go to Enfilade for this walking method
private boolean tileInNextRange(RSTile t) {
return calc.distanceBetween(t, getMyPlayer().getLocation()) < nextStep;
}
private int nextStep = 12;
private int step(ArrayList<RSTile> path) {
if(calc.distanceBetween(getMyPlayer().getLocation(), path.get(path.size() - 1)) < 2)
return path.size();
RSTile dest = walking.getDestination();
int index = -1;
int shortestDist = 0, dist, shortest = -1;
if(dest != null)
for(int i = 0; i < path.size(); i++) {
dist = (int)calc.distanceBetween(path.get(i), dest);
if(shortest < 0 || shortestDist > dist) {
shortest = i;
shortestDist = dist;
}
}
for(int i = path.size() - 1; i >= 0; i--)
if(tileInNextRange(path.get(i))) {
index = i;
break;
}
if(index >= 0 && (dest == null || (index > shortest) || !getMyPlayer().isMoving())) {
walking.walkTileMM(path.get(index));
nextStep = random(12, 15);
return index;
}
return -1;
}
private ArrayList<RSTile> generatePath(Line[] lines) {
double minStep = 5, maxStep = 10, wander = 3;
if(lines.length < 2)
return null;
ArrayList<RSTile> path = new ArrayList<RSTile>();
Line l1, l2 = lines[0];
double distFromCenter = random(0, l2.getDistance()+1);
RSTile p = l2.translate((int)distFromCenter);
distFromCenter = l2.getDistance()/2 - distFromCenter;
double centerXdist, centerYdist,
line1Xdist, line1Ydist,
line2Xdist, line2Ydist;
double line1dist, line2dist, centerDist;
double x, y;
double distOnLine, last, cap1, cap2, move;
double distFromCenterX1, distFromCenterY1, distFromCenterX2, distFromCenterY2;
double force1, force2, slopeX, slopeY, slopeDist;
boolean finished;
int lastX = p.getX(), lastY = p.getY(), curX, curY;
double dist, xdist, ydist;
for(int i = 1; i < lines.length; i++) {
l1 = l2;
l2 = lines[i];
centerXdist = l2.getCenterX() - l1.getCenterX();
centerYdist = l2.getCenterY() - l1.getCenterY();
centerDist = Math.sqrt(centerXdist*centerXdist + centerYdist*centerYdist);
line1Xdist = l2.getX() - l1.getX();
line1Ydist = l2.getY() - l1.getY();
line2Xdist = l2.getX2() - l1.getX2();
line2Ydist = l2.getY2() - l1.getY2();
centerXdist /= centerDist;
centerYdist /= centerDist;
line1Xdist /= centerDist;
line1Ydist /= centerDist;
line2Xdist /= centerDist;
line2Ydist /= centerDist;
distOnLine = 0;
last = 0;
finished = false;
while(!finished) {
distOnLine += random(minStep, maxStep);
if(distOnLine >= centerDist) {
distOnLine = centerDist;
finished = true;
}
x = centerXdist * distOnLine + l1.getCenterX();
y = centerYdist * distOnLine + l1.getCenterY();
distFromCenterX1 = x-(line1Xdist * distOnLine + l1.getX());
distFromCenterY1 = y-(line1Ydist * distOnLine + l1.getY());
distFromCenterX2 = x-(line2Xdist * distOnLine + l1.getX2());
distFromCenterY2 = y-(line2Ydist * distOnLine + l1.getY2());
slopeX = distFromCenterX2 - distFromCenterX1;
slopeY = distFromCenterY2 - distFromCenterY1;
slopeDist = Math.sqrt(slopeX*slopeX + slopeY*slopeY);
slopeX /= slopeDist;
slopeY /= slopeDist;
line1dist = Math.sqrt(distFromCenterX1*distFromCenterX1 +
distFromCenterY1*distFromCenterY1);
line2dist = Math.sqrt(distFromCenterX2*distFromCenterX2 +
distFromCenterY2*distFromCenterY2);
move = (distOnLine - last)/maxStep*wander;
force1 = line1dist+distFromCenter;
force2 = line2dist-distFromCenter;
cap1 = Math.min(move, force1);
cap2 = Math.min(move, force2);
if(force1 < 0)
distFromCenter -= force1;
else if(force2 < 0)
distFromCenter += force2;
else
distFromCenter += random(-cap1, cap2);
if(finished) {
RSTile t = l2.translateFromCenter(distFromCenter);
curX = t.getX();
curY = t.getY();
} else {
curX = (int)Math.round(distOnLine*centerXdist + l1.getCenterX() + distFromCenter*slopeX);
curY = (int)Math.round(distOnLine*centerYdist + l1.getCenterY() + distFromCenter*slopeY);
}
xdist = curX - lastX;
ydist = curY - lastY;
dist = Math.sqrt(xdist*xdist + ydist*ydist);
xdist /= dist;
ydist /= dist;
for(int j = 0; j < dist; j++)
path.add(new RSTile((int)Math.round(xdist*j + lastX), (int)Math.round(ydist*j + lastY)));
last = distOnLine;
lastX = curX;
lastY = curY;
}
}
return cutUp(path);
}
public ArrayList<RSTile> cutUp(ArrayList<RSTile> tiles) {
ArrayList<RSTile> path = new ArrayList<RSTile>();
int index = 0;
while(index < tiles.size()) {
path.add(tiles.get(index));
index += random(8, 12);
}
if(!path.get(path.size()-1).equals(tiles.get(tiles.size()-1)))
path.add(tiles.get(tiles.size()-1));
return path;
}
private final Color POLY_BORDER = new Color(150, 0, 150), POLY_FILL = new Color(150, 0, 150, 80);
private class Line {
private int x, y, xdist, ydist, x2, y2, centerX, centerY;
private RSTile t1, t2;
private double dist;
public Line(int x1, int y1, int x2, int y2) {
t1 = new RSTile(x1, y1);
t2 = new RSTile(x2, y2);
x = x1;
y = y1;
this.x2 = x2;
this.y2 = y2;
xdist = x2 - x1;
ydist = y2 - y1;
centerX = x + (int)(0.5 * xdist);
centerY = y + (int)(0.5 * ydist);
dist = Math.sqrt(xdist*xdist + ydist*ydist);
}
public int getCenterX() {
return centerX;
}
public int getCenterY() {
return centerY;
}
public RSTile getRandomRSTile() {
double rand = Math.random();
return new RSTile(x + (int)(xdist*rand), y + (int)(ydist*rand));
}
public RSTile getTile1() { return t1; }
public RSTile getTile2() { return t2; }
public void drawTo(Graphics g, Line line) {
if(!calc.tileOnMap(t1) || !calc.tileOnMap(t2))
return;
if(calc.tileOnMap(line.getTile1()) && calc.tileOnMap(line.getTile2())) {
Point p1 = calc.tileToMinimap(t1);
Point p2 = calc.tileToMinimap(t2);
Point p3 = calc.tileToMinimap(line.getTile2());
Point p4 = calc.tileToMinimap(line.getTile1());
GeneralPath path = new GeneralPath();
path.moveTo(p1.x, p1.y);
path.lineTo(p2.x, p2.y);
path.lineTo(p3.x, p3.y);
path.lineTo(p4.x, p4.y);
path.closePath();
g.setColor(POLY_FILL);
((Graphics2D)g).fill(path);
((Graphics2D)g).draw(path);
}
Point last = null, p;
g.setColor(Color.ORANGE);
for(RSTile t : pathList) {
if(calc.tileOnMap(t)) {
p = calc.tileToMinimap(t);
g.fillOval(p.x-2, p.y-2, 5, 5);
if(last != null)
g.drawLine(p.x, p.y, last.x, last.y);
last = p;
} else
last = null;
}
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getX2() {
return x2;
}
public int getY2() {
return y2;
}
public int getXDistance() {
return xdist;
}
public int getYDistance() {
return ydist;
}