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 pathAaimistersChickenKiller.java
More file actions
2125 lines (1981 loc) · 68.9 KB
/
AaimistersChickenKiller.java
File metadata and controls
2125 lines (1981 loc) · 68.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @author Aaimister
* @version 1.26 ©2010-2011 Aaimister, No one except Aaimister has the right to
* modify and/or spread this script without the permission of Aaimister.
* I'm not held responsible for any damage that may occur to your
* property.
*/
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.net.URLConnection;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Scanner;
import javax.imageio.ImageIO;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
import javax.swing.border.MatteBorder;
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.util.Filter;
import org.rsbot.script.wrappers.RSArea;
import org.rsbot.script.wrappers.RSGroundItem;
import org.rsbot.script.wrappers.RSItem;
import org.rsbot.script.wrappers.RSNPC;
import org.rsbot.script.wrappers.RSPlayer;
import org.rsbot.script.wrappers.RSTile;
@ScriptManifest(authors = { "Aaimister" }, name = "Aaimisters Chicken Killer v1.26", keywords = "Combat", version = 1.26, description = ("Kills chickens."))
public class AaimistersChickenKiller extends Script implements MessageListener, PaintListener, MouseListener {
private RSTile InPen;
private RSArea Pen;
private RSArea ChickenPenF = new RSArea(new RSTile(3014, 3282), new RSTile(
3020, 3297));
private RSArea ChickenPenLum = new RSArea(new RSTile(3225, 3295),
new RSTile(3236, 3301));
private RSArea ChickenPenFout = new RSArea(new RSTile(3026, 3282), new RSTile(3037, 3291));
private RSArea Champion = new RSArea(new RSTile(3195, 3351), new RSTile(3199, 3360));
private final String[] locationstring = { "Falador Pen", "Falador Porch", "Lumbridge Pen", "Champion's Guild" };
private final String[] statstring = { "Attack", "Strength", "Defence", "Range", "Magic" };
private final String[] colorstring = { "Black", "Blue", "Brown", "Cyan", "Green", "Lime", "Orange", "Pink", "Purple", "Red", "White", "Yellow" };
private String url = "http://922d1ef9.any.gs";
private long nextBreak = System.currentTimeMillis();
private long nextLength = 60000;
private long totalBreakTime;
private long antiBanRandom = random(15000, 90000);
private long antiBanTime = System.currentTimeMillis() + antiBanRandom;
private long lastBreakTime;
private long nextBreakT;
private long startTime;
private long runTime;
private long now;
private ArrayList<Integer> loot = new ArrayList<Integer>();
AaimistersGUI g = new AaimistersGUI();
public final File settingsFile = new File(getCacheDirectory(), "AaimistersCKillerSettings.txt");
NumberFormat formatter = new DecimalFormat("#,###,###");
Font Cam10 = new Font("Cambria Math", Font.BOLD, 10);
Font Cam = new Font("Cambria Math", Font.BOLD, 12);
Color PercentGreen = new Color(0, 163, 4, 150);
Color PercentRed = new Color(163, 4, 0, 150);
Color White150 = new Color(255, 255, 255, 150);
Color White90 = new Color(255, 255, 255, 90);
Color White = new Color(255, 255, 255);
Color Background = new Color(219, 200, 167);
Color UpGreen = new Color(0, 169, 0);
Color LineColor = new Color(0, 0, 0);
Color ClickC = new Color(187, 0, 0);
Color UpRed = new Color(169, 0, 0);
Color Black = new Color(0, 0, 0);
Color MainColor;
Color ThinColor;
Color BoxColor;
final NumberFormat nf = NumberFormat.getInstance();
boolean currentlyBreaking;
boolean randomBreaks;
boolean waitForLoot;
boolean useSetting;
boolean antiBanOn;
boolean showPaint = true;
boolean painting;
boolean doBreak;
boolean checked;
boolean checkAmmo;
boolean outofAmmo;
boolean clicked;
boolean logTime;
boolean closed;
boolean wait;
boolean skip;
//Paint Buttons
boolean xButton;
boolean StatC;
boolean StatP;
boolean StatM;
boolean StatI;
boolean Main = true;
private String currentChic = "Chic Lvl 1";
private String currentStat = "";
private String status = "";
private String penType = "";
int drop[] = { 1925, 1944, 2138 };
int Chickens[] = { 1017, 41 };
int runEnergy = (random(40, 75));
int all[] = { 882, 314, 526 };
int arrow = 882;
int feathers = 314;
int bones = 526;
int stopLevel = 99;
int random;
int pickItem;
int stat;
int barStat;
int priceFeather;
int totalGP;
int featherHour;
int gpHour;
int totalFeather;
int errorCount;
int checkFea;
int i;
int chicToLvl;
int chicHour;
int xpGained;
int xpHour;
int buriedBones;
int totalChic;
int xpChic;
int maxBetween;
int minBetween;
int maxLength;
int minLength;
//Chosen Stat
int sxpHour;
int scurrentXP;
int stimeToLvl;
int sgainedLvl;
int sstartXP;
int sxpGained;
int sxpToLvl;
//Constution
int cxpHour;
int ccurrentXP;
int ctimeToLvl;
int cgainedLvl;
int cstartXP;
int cxpGained;
int cxpToLvl;
//Prayer
int pxpHour;
int pcurrentXP;
int ptimeToLvl;
int pgainedLvl;
int pstartXP;
int pxpGained;
int pxpToLvl;
private enum State { BACKTOCHICK, ATTACK };
private State getState() {
if (!atPen()) {
return State.BACKTOCHICK;
} else {
return State.ATTACK;
}
}
public double getVersion() {
return 1.26;
}
@Override
public boolean onStart() {
status = "Starting up...";
URLConnection url = null;
BufferedReader in = null;
//Check right away...
try {
//Open the version text file
url = new URL("http://aaimister.webs.com/scripts/AaimistersRoachVersion.txt").openConnection();
//Create an input stream for it
in = new BufferedReader(new InputStreamReader(url.getInputStream()));
//Check if the current version is outdated
if (Double.parseDouble(in.readLine()) > getVersion()) {
if (JOptionPane.showConfirmDialog(null, "Please visit the thread: " +
"http://www.powerbot.org/vb/showthread.php?t=644016") == 0) {
//If so, tell to go to the thread.
openThread();
if (in != null) {
in.close();
}
return false;
}
} else {
JOptionPane.showMessageDialog(null, "You have the latest version.");
//User has the latest version. Tell them!
if (in != null) {
in.close();
}
}
} catch (IOException e){
log("Problem getting version. Please visit the forums.");
return false; //Return false if there was a problem
}
try {
settingsFile.createNewFile();
} catch (final IOException ignored) {
}
createAndWaitforGUI();
if (closed) {
log.severe("The GUI window was closed!");
return false;
}
if (doBreak) {
breakingNew();
}
return true;
}
private void createAndWaitforGUI() {
if (SwingUtilities.isEventDispatchThread()) {
g.AaimistersGUI.setVisible(true);
} else {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
g.AaimistersGUI.setVisible(true);
}
});
} catch (InvocationTargetException ite) {
} catch (InterruptedException ie) {
}
}
sleep(100);
while (g.AaimistersGUI.isVisible()) {
sleep(100);
}
}
public void openThread(){
if (java.awt.Desktop.isDesktopSupported()) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
log("Can't open thread. Something is conflicting.");
return;
}
try {
java.net.URI uri = new java.net.URI(url);
desktop.browse(uri);
} catch (Exception e) {
}
}
}
public void onFinish() {
runTime = (System.currentTimeMillis() - startTime) - totalBreakTime;
long totalTime = System.currentTimeMillis() - startTime;
final String formattedTime = formatTime((int) totalTime);
log("Thanks for using Aaimister's Chicken Killer!");
if (loot.contains(bones)) {
log("In " + formattedTime + " You killed " + formatter.format(totalChic) + " chickens, gained " + formatter.format(sgainedLvl) + " Level(s), and buried " + formatter.format(buriedBones) + " bones!");
} else {
log("In " + formattedTime + " You killed " + formatter.format(totalChic) + " chickens, and gained " + formatter.format(sgainedLvl) + " Level(s)!");
}
}
private String getLocation() {
if (atPen()) {
return penType;
} else if (calc.distanceTo(InPen) > 100) {
if (!game.isLoggedIn()) {
return "Login Screen";
} else {
return "Unknown";
}
} else {
return "Close to Pen";
}
}
private void breakingNew(){
if (randomBreaks){
long varTime = random(3660000, 10800000);
nextBreak = System.currentTimeMillis() + varTime;
nextBreakT = varTime;
long varLength = random(900000, 3600000);
nextLength = varLength;
} else {
int diff = random(0, 5) * 1000 * 60;
long varTime = random((minBetween * 1000 * 60) + diff, (maxBetween * 1000 * 60) - diff);
nextBreak = System.currentTimeMillis() + varTime;
nextBreakT = varTime;
int diff2 = random(0, 5) * 1000 * 60;
long varLength = random((minLength * 1000 * 60) + diff2, (maxLength * 1000 * 60) - diff2);
nextLength = varLength;
}
logTime = true;
}
private boolean breakingCheck(){
if (nextBreak <= System.currentTimeMillis()){
return true;
}
return false;
}
private boolean atPen() {
return Pen.contains(getMyPlayer().getLocation());
}
private boolean idle() {
if (getMyPlayer().getAnimation() == -1) {
return true;
}
return false;
}
public boolean checkLog() {
if (getMyPlayer().isOnScreen() && game.isLoggedIn() && calc.distanceTo(InPen) < 20) {
return true;
} else {
return false;
}
}
public boolean dyingChic() {
for (RSNPC i : npcs.getAll()) {
if (i.getAnimation() == 5389 && calc.distanceTo(i.getLocation()) < 2 && getMyPlayer().isInCombat()) {
return true;
}
}
return false;
}
public void bury(boolean leftToRight, int... items) {
while (inventory.getCount(items) != 0) {
if (!leftToRight) {
for (int c = 0; c < 4; c++) {
for (int r = 0; r < 7; r++) {
boolean found = false;
for (int i = 0; i < items.length && !found; ++i) {
found = items[i] == inventory.getItems()[c + r * 4]
.getID();
}
if (!found) {
buryItem(c, r);
}
}
}
} else {
for (int r = 0; r < 7; r++) {
for (int c = 0; c < 4; c++) {
boolean found = true;
for (int i = 0; i < items.length && found; ++i) {
found = items[i] == inventory.getItems()[c + r * 4]
.getID();
}
if (found) {
buryItem(c, r);
}
}
}
}
sleep(random(500, 800));
}
}
public void buryItem(int col, int row) {
if (interfaces.get(210).getComponent(2).getText()
.equals("Click here to continue")) {
sleep(random(800, 1300));
if (interfaces.get(210).getComponent(2).getText()
.equals("Click here to continue")) {
interfaces.get(210).getComponent(2).doClick();
sleep(random(150, 200));
}
}
if (game.getCurrentTab() != 4
&& !interfaces.get(762).isValid()
&& !interfaces.get(620).isValid()) {
game.openTab(4);
}
if (col < 0 || col > 3 || row < 0 || row > 6)
return;
if (inventory.getItems()[col + row * 4].getID() == -1)
return;
Point p;
p = mouse.getLocation();
if (p.x < 563 + col * 42 || p.x >= 563 + col * 42 + 32
|| p.y < 213 + row * 36 || p.y >= 213 + row * 36 + 32) {
mouse.hop(inventory.getInterface().getComponents()[row * 4 + col]
.getCenter(), 10, 10);
}
mouse.click(false);
sleep(100, 200);
menu.doAction("Bury");
sleep(25, 50);
}
private void setCamera() {
if (camera.getPitch() < 10) {
camera.setPitch(true);
sleep(1000, 1600);
}
}
private void setRun() {
if (!walking.isRunEnabled()) {
if (walking.getEnergy() >= 50) {
walking.setRun(true);
sleep(1000, 1600);
}
}
}
private RSGroundItem arrow() {
return groundItems.getNearest(new Filter<RSGroundItem>() {
public boolean accept(RSGroundItem g) {
return g.getItem().getID() == arrow && Pen.contains(g.getLocation());
}
});
}
private RSGroundItem feather() {
return groundItems.getNearest(new Filter<RSGroundItem>() {
public boolean accept(RSGroundItem g) {
return g.getItem().getID() == feathers && Pen.contains(g.getLocation());
}
});
}
private RSGroundItem bones() {
return groundItems.getNearest(new Filter<RSGroundItem>() {
public boolean accept(RSGroundItem g) {
return g.getItem().getID() == bones && Pen.contains(g.getLocation());
}
});
}
private RSNPC newNPC() {
RSNPC interacting = interactingNPC();
return interacting != null ? interacting : npcs.getNearest(new Filter<RSNPC>() {
public boolean accept(RSNPC npc) {
return npc.getName().equals("Chicken") && npc.getHPPercent() > 0 && !npc.isInCombat() && Pen.contains(npc.getLocation());
}
});
}
private RSNPC interactingNPC() {
return npcs.getNearest(new Filter<RSNPC>() {
public boolean accept(RSNPC n) {
return n.getInteracting() != null && n.getInteracting().equals(players.getMyPlayer()) && Pen.contains(n.getLocation());
}
});
}
private RSPlayer playerNear() {
RSPlayer me = myPlayer();
return me != null ? me : players.getNearest(new Filter<RSPlayer>() {
public boolean accept(RSPlayer p) {
return !p.isMoving() && p.isOnScreen();
}
});
}
private RSPlayer myPlayer() {
final String myName = players.getMyPlayer().getName();
return players.getNearest(new Filter<RSPlayer>() {
public boolean accept(RSPlayer p) {
return p.getName() == myName;
}
});
}
@Override
public int loop() {
if (breakingCheck() && doBreak) {
status = "Breaking...";
long endTime = System.currentTimeMillis() + nextLength;
totalBreakTime += (nextLength + 5000);
lastBreakTime = (totalBreakTime - (nextLength + 5000));
currentlyBreaking = true;
while (game.isLoggedIn()) {
game.logout(false);
sleep(50);
}
log("Taking a break for " + formatTime((int) nextLength));
while (System.currentTimeMillis() < endTime && currentlyBreaking == true){
sleep(1000);
}
currentlyBreaking = false;
while (!game.isLoggedIn()) {
try {
breakingNew();
game.login();
} catch (Exception e) {
return 10;
}
sleep(50);
}
return 10;
}
if (!game.isLoggedIn()) {
status = "Breaking...";
return 3000;
}
if (startTime == 0 && skills.getCurrentLevel(stat) != 0) {
startTime = System.currentTimeMillis();
sstartXP = skills.getCurrentExp(stat);
scurrentXP = skills.getExpToNextLevel(stat);
cstartXP = skills.getCurrentExp(3);
ccurrentXP = skills.getExpToNextLevel(3);
pstartXP = skills.getCurrentExp(5);
pcurrentXP = skills.getExpToNextLevel(5);
if (loot.contains(feathers)) {
priceFeather = getGuidePrice(feathers);
log("Price of feathers: " + priceFeather);
}
}
if (i < 1) {
checkFea = inventory.getCount(true, 314);
i++;
}
if (logTime) {
log("Next Break In: " + formatTime((int) nextBreakT) + " For: " + formatTime((int) nextLength) + ".");
logTime = false;
}
setCamera();
setRun();
mouse.setSpeed(random(4, 9));
if (skills.getCurrentLevel(stat) >= stopLevel) {
log.severe("You have reached level " + stopLevel + "! Stopping Script...");
game.logout(false);
stopScript();
}
switch (getState()) {
case ATTACK:
if (atPen()) {
if (checkAmmo) {
checkAmmo = false;
RSItem wield = inventory.getItem(arrow);
if (game.getCurrentTab() != 4) {
game.openTab(4);
} else {
if (inventory.contains(arrow)) {
wield.doAction("Wield");
return random(800, 1000);
} else {
outofAmmo = true;
}
}
}
if (players.getMyPlayer().getInteracting() != null) {
if (interfaces.canContinue()) {
interfaces.clickContinue();
}
if (loot.contains(feathers) || loot.contains(bones) || loot.contains(arrow)) {
wait = true;
skip = false;
}
return random(200, 555);
}
if ((dyingChic() || waitForLoot) && wait && !skip) {
sleep(2750, 3000);
}
try {
RSNPC chic = newNPC();
if (chic != null && !wait) {
status = "Killing chickens...";
if (players.getMyPlayer().isMoving()) {
return random(400, 600);
}
if (chic.isOnScreen()) {
chic.doAction("Attack " + chic.getName());
return random(1000, 1600);
} else if (!chic.isOnScreen()) {
RSTile chicT = walking.getClosestTileOnMap(chic.getLocation()).randomize(-1, 1);
if (Pen.contains(chicT)) {
walking.walkTileMM(chicT);
} else {
return 100;
}
return random(1100, 1500);
}
} else {
if (inventory.containsOneOf(drop)) {
status = "Dropping junk...";
RSItem d = inventory.getItem(drop);
d.doAction("Drop");
return random(350, 600);
} else if (inventory.isFull()) {
while (inventory.contains(bones)) {
status = "Burying bones...";
bury(true, bones);
sleep(600, 1350);
}
} else {
if (Pen.contains(getMyPlayer().getLocation()) && !loot.isEmpty()) {
skip = true;
while (feather() != null && loot.contains(feathers) && checkLog()) {
status = "Looting feathers...";
if (feather().isOnScreen()) {
feather().doAction("Take " + feather().getItem().getName());
sleep(800, 1200);
totalFeather = inventory.getCount(true, 314) - checkFea;
return 1;
} else {
walking.walkTileMM(feather().getLocation().randomize(1, 1));
return random(1000, 1350);
}
}
while (arrow() != null && loot.contains(arrow) && checkLog()) {
status = "Picking up arrows...";
if (arrow().isOnScreen()) {
arrow().doAction("Take " + arrow().getItem().getName());
return random(800, 1200);
} else {
walking.walkTileMM(arrow().getLocation().randomize(1, 1));
return random(1000, 1350);
}
}
while (bones() != null && loot.contains(bones) && checkLog()) {
status = "Looting bones...";
if (bones().isOnScreen()) {
bones().doAction("Take " + bones().getItem().getName());
if (newNPC() != null) {
wait = false;
}
return random(800, 1200);
} else {
walking.walkTileMM(bones().getLocation().randomize(1, 1));
return random(1000, 1350);
}
}
wait = false;
} else {
wait = false;
}
}
}
} catch (Exception e) {
}
if (antiBanTime <= System.currentTimeMillis()) {
doAntiBan();
return random(1000, 1600);
}
}
break;
case BACKTOCHICK:
status = "Finding pen...";
if (!atPen()) {
if (!idle() || getMyPlayer().isInCombat()) {
return random(1000, 1500);
}
if (idle() && !getMyPlayer().isInCombat()) {
RSTile Next = walking.getClosestTileOnMap(InPen).randomize(-2, 2);
walking.walkTileMM(Next);
sleep(1000, 1500);
} else {
return random(1000, 1600);
}
}
break;
}
return (random(650, 1050));
}
//Credits Aion
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;
}
//Credits Aion
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;
}
public void doAntiBan() {
if (antiBanOn == false) {
return;
}
antiBanRandom = random(15000, 90000);
antiBanTime = System.currentTimeMillis() + antiBanRandom;
int action = random(0, 6);
switch (action) {
case 0:
rotateCamera();
sleep(200, 400);
break;
case 1:
mouse.moveRandomly(100, 900);
sleep(200, 400);
break;
case 2:
checkPlayer();
sleep(200, 400);
break;
case 3:
rotateCamera();
sleep(200, 400);
break;
case 4:
checkEXP();
sleep(200, 400);
break;
case 5:
mouse.moveOffScreen();
sleep(200, 400);
break;
case 6:
randomTile();
sleep(200, 400);
break;
}
}
public void randomTile() {
RSTile random = InPen.randomize(-5, 5);
if (Pen.contains(random)) {
if (idle()) {
walking.walkTileMM(walking.getClosestTileOnMap(random));
sleep(1200, 1500);
}
} else {
mouse.moveRandomly(900);
}
}
public void checkPlayer() {
RSPlayer near = playerNear();
if (near != null) {
if (!getMyPlayer().isMoving()) {
if (near.getScreenLocation() != null) {
if (mouse.getLocation() != near.getScreenLocation()) {
mouse.move(near.getScreenLocation());
sleep(300, 550);
}
mouse.click(false);
sleep(300, 500);
if (menu.contains("Follow")) {
Point menuu = menu.getLocation();
int Mx = menuu.x;
int My = menuu.y;
int x = Mx + random(3, 120);
int y = My + random(3, 98);
mouse.move(x, y);
sleep(2320, 3520);
mouse.moveRandomly(100, 900);
sleep(50);
if (menu.isOpen()) {
mouse.moveRandomly(100, 900);
sleep(50);
}
if (menu.isOpen()) {
mouse.moveRandomly(100, 900);
sleep(50);
}
} else {
mouse.moveRandomly(100, 900);
}
}
} else {
return;
}
} else {
mouse.moveRandomly(100, 900);
}
}
public void checkEXP() {
if (game.getCurrentTab() != 2) {
game.openTab(2);
sleep(500, 900);
}
if (stat == 0) {
mouse.move(random(551, 604), random(214, 233));
sleep(3000, 5500);
game.openTab(4);
sleep(50, 100);
mouse.moveRandomly(50, 900);
} else if (stat == 1) {
mouse.move(random(551, 604), random(269, 289));
sleep(3000, 5500);
game.openTab(4);
sleep(50, 100);
mouse.moveRandomly(50, 900);
} else if (stat == 2) {
mouse.move(random(551, 604), random(241, 261));
sleep(3000, 5500);
game.openTab(4);
sleep(50, 100);
mouse.moveRandomly(50, 900);
} else if (stat == 4) {
mouse.move(random(551, 604), random(298, 316));
sleep(3000, 5500);
game.openTab(4);
sleep(50, 100);
mouse.moveRandomly(50, 900);
} else if (stat == 6) {
mouse.move(random(553, 604), random(353, 370));
sleep(3000, 5500);
game.openTab(4);
sleep(50, 100);
mouse.moveRandomly(50, 900);
}
}
public void rotateCamera() {
final char[] LR = new char[] { KeyEvent.VK_LEFT,
KeyEvent.VK_RIGHT };
final char[] DU = new char[] { KeyEvent.VK_DOWN,
KeyEvent.VK_UP };
int x = random(0, 2);
int key = 0;
keyboard.pressKey(LR[x]);
if (getMyPlayer().getAnimation() != -1) {
keyboard.pressKey(DU[1]);
key = 0;
}
sleep(500, 1000);
keyboard.releaseKey(DU[key]);
keyboard.releaseKey(LR[x]);
}
private String stripFormatting(String str) {
if (str != null && !str.isEmpty())
return str.replaceAll("(^[^<]+>|<[^>]+>|<[^>]+$)", "");
return "";
}
@Override
public void messageReceived(MessageEvent e) {
if (e.getMessage().contains("You bury the bones")) {
clicked = false;
buriedBones++;
}
if (stat == 0) {
if (e.getMessage().contains("You've just advanced an Attack")) {
sgainedLvl++;
}
} else if (stat == 1) {
if (e.getMessage().contains("You've just advanced a Defence")) {
sgainedLvl++;
}
} else if (stat == 2) {
if (e.getMessage().contains("You've just advanced a Strength")) {
sgainedLvl++;
}
} else if (stat == 4) {
if (e.getMessage().contains("You've just advanced a Ranged")) {
sgainedLvl++;
}
if (e.getMessage().contains("There is no ammo")) {
checkAmmo = true;
if (outofAmmo) {
log("Out of ammo. =/");
stopScript();
}
}
} else if (stat == 6) {
if (e.getMessage().contains("You've just advanced a Ma")) {
sgainedLvl++;
}
}
if (e.getMessage().contains("You've just advanced a Prayer")) {
pgainedLvl++;
}
if (e.getMessage().contains("You've just advanced a Con")) {
cgainedLvl++;
}
}
public void drawMe(final Graphics g) {
if (getMyPlayer().isOnScreen()) {
final RSTile t = getMyPlayer().getLocation();
final RSTile tx = new RSTile (t.getX() + 1, t.getY());
final RSTile ty = new RSTile (t.getX(), t.getY() + 1);
final RSTile txy = new RSTile (t.getX() + 1, t.getY() + 1);
calc.tileToScreen(t);
calc.tileToScreen(tx);
calc.tileToScreen(ty);
calc.tileToScreen(txy);
final Point pn = calc.tileToScreen(t, 0, 0, 0);
final Point px = calc.tileToScreen(tx, 0, 0, 0);
final Point py = calc.tileToScreen(ty, 0, 0, 0);
final Point pxy = calc.tileToScreen(txy, 0, 0, 0);
if (calc.pointOnScreen(pn) && calc.pointOnScreen(px) && calc.pointOnScreen(py) && calc.pointOnScreen(pxy)) {
g.setColor(Black);
g.drawPolygon(new int[] { py.x, pxy.x, px.x, pn.x }, new int[] {
py.y, pxy.y, px.y, pn.y }, 4);
g.setColor(ThinColor);
g.fillPolygon(new int[] { py.x, pxy.x, px.x, pn.x }, new int[] {