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 pathBeefyBillCowKiller.java
More file actions
2117 lines (1921 loc) · 59.4 KB
/
Copy pathBeefyBillCowKiller.java
File metadata and controls
2117 lines (1921 loc) · 59.4 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.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.DefaultComboBoxModel;
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.JSlider;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.rsbot.Configuration;
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.Skills;
import org.rsbot.script.util.Filter;
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.RSNPC;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSPath;
import org.rsbot.script.wrappers.RSTile;
@ScriptManifest(authors = { "Mr. Byte" }, name = "Beefy Bill Cow Killer", keywords = { "Combat" }, description = "Kills Cows, Loots Hides,"
+ " Buries Bones, Chops Trees,"
+ " Makes Fire, Cooks Looted Meat "
+ "(phew!).", version = 3.31)
public class BeefyBillCowKiller extends Script implements PaintListener,
MouseListener, MessageListener {
private enum action {
FIGHTING, LOOTING, ATTACKING, BANKING, EATING, COOKING, WALKING, CLIMBING, BANKSTAFFS;
}
public class BeefyGUI extends JFrame {
private JPanel dialogPane;
private JPanel contentPanel;
private JCheckBox guiBuryBones;
private JCheckBox guiEatFood;
private JCheckBox guiPickStaff;
private JSlider HPPercentToEat;
private JCheckBox restWhenTired;
private JCheckBox guiBankMeat;
private JCheckBox guiBankHides;
private JComboBox hideBankCount;
private JLabel howManyLabel;
private JCheckBox guiGetFood;
private JCheckBox guiCheckForUpdates;
private JLabel jLabel1;
private JCheckBox beVerbose;
private JButton runButton;
private JButton cancelButton;
public BeefyGUI() {
initComponents();
}
private void bankingMeatItemStateChanged(final ItemEvent e) {
hideBankCount.setEnabled((guiBankHides.isSelected() && !guiBankMeat.isSelected()));
howManyLabel.setEnabled(hideBankCount.isEnabled());
guiBuryBones.setEnabled(guiBankHides.isSelected()
|| guiBankMeat.isSelected());
guiBuryBones.setSelected(guiBuryBones.isSelected()
&& (guiBankHides.isSelected() || guiBankMeat.isSelected()));
}
private void cancelButtonActionPerformed(final ActionEvent e) {
guiExit = true;
gui.dispose();
return;
}
private void getHidesItemStateChanged(final ItemEvent e) {
hideBankCount.setEnabled((guiBankHides.isSelected() && !guiBankMeat.isSelected()));
howManyLabel.setEnabled(hideBankCount.isEnabled());
guiBuryBones.setEnabled(guiBankHides.isSelected()
|| guiBankMeat.isSelected());
guiBuryBones.setSelected(guiBuryBones.isSelected()
&& (guiBankHides.isSelected() || guiBankMeat.isSelected()));
}
private void HPPercentToEatStateChanged(final ChangeEvent e) {
HPPercentToEat.setBorder(new TitledBorder("Eat at "
+ HPPercentToEat.getValue() + "% HP"));
return;
}
private void iCanHazCheezBurgerActionPerformed(final ActionEvent e) {
HPPercentToEat.setEnabled(guiEatFood.isSelected());
if (inventory.containsOneOf(hatchets)
&& inventory.contains(tinderbox)) {
guiGetFood.setEnabled(guiEatFood.isSelected());
guiGetFood.setSelected(guiGetFood.isSelected()
&& guiEatFood.isSelected());
}
return;
}
private void initComponents() {
contentPanel = new JPanel();
guiBuryBones = new JCheckBox();
guiPickStaff = new JCheckBox();
guiEatFood = new JCheckBox();
HPPercentToEat = new JSlider();
restWhenTired = new JCheckBox();
guiBankMeat = new JCheckBox();
guiBankHides = new JCheckBox();
hideBankCount = new JComboBox();
howManyLabel = new JLabel();
guiGetFood = new JCheckBox();
runButton = new JButton();
cancelButton = new JButton();
setTitle("Beefy Bill Cow Killer v" + version);
setFont(new Font("Arial", Font.PLAIN, 12));
setResizable(false);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(final WindowEvent e) {
thisWindowClosing(e);
}
});
final Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
{
dialogPane = new JPanel();
contentPane.add(dialogPane, BorderLayout.CENTER);
dialogPane.setLayout(new BorderLayout());
dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
dialogPane.setFont(new Font("Arial", Font.PLAIN, 12));
dialogPane.setPreferredSize(new java.awt.Dimension(533, 450));
{
contentPanel = new JPanel();
dialogPane.add(contentPanel, BorderLayout.CENTER);
{
guiBuryBones = new JCheckBox();
contentPanel.add(guiBuryBones);
guiBuryBones.setText("Get/Bury Bones?");
guiBuryBones.setSelected(true);
guiBuryBones.setFont(new Font("Arial", Font.PLAIN, 12));
guiBuryBones.setToolTipText("The much asked for option to turn off bone grabbing. Un-check this to not grab bones.");
guiBuryBones.setBounds(12, 60, 126, 19);
}
{
guiBankHides = new JCheckBox();
contentPanel.add(guiBankHides);
guiBankHides.setText("Bank Hides?");
guiBankHides.setSelected(true);
guiBankHides.setFont(new Font("Arial", Font.PLAIN, 12));
guiBankHides.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
getHidesItemStateChanged(e);
}
});
guiBankHides.setBounds(217, 60, 103, 19);
}
{
guiBankMeat = new JCheckBox();
contentPanel.add(guiBankMeat);
guiBankMeat.setText("Banking Meat?");
guiBankMeat.setSelected(false);
guiBankMeat.setFont(new Font("Arial", Font.PLAIN, 12));
guiBankMeat.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
bankingMeatItemStateChanged(e);
}
});
guiBankMeat.setBounds(358, 60, 138, 19);
}
{
guiPickStaff = new JCheckBox();
contentPanel.add(guiPickStaff);
guiPickStaff.setText("Get Air Staffs?");
guiPickStaff.setSelected(true);
guiPickStaff.setFont(new Font("Arial", Font.PLAIN, 12));
guiPickStaff.setToolTipText("As requested by HawkenX");
guiPickStaff.setBounds(12, 90, 126, 19);
}
{
restWhenTired = new JCheckBox();
contentPanel.add(restWhenTired);
restWhenTired.setText("Rest when out of run energy");
restWhenTired.setSelected(true);
restWhenTired.setFont(new Font("Arial", Font.PLAIN, 12));
restWhenTired.setToolTipText("You'll be running alot. Rest when you're tired?");
restWhenTired.setBounds(153, 90, 200, 19);
}
{
guiEatFood = new JCheckBox();
contentPanel.add(guiEatFood);
guiEatFood.setText("Use food?");
guiEatFood.setFont(new Font("Arial", Font.PLAIN, 12));
guiEatFood.setToolTipText("Check here to eat when injured.");
guiEatFood.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
iCanHazCheezBurgerActionPerformed(e);
}
});
guiEatFood.setBounds(12, 120, 150, 19);
}
{
guiGetFood = new JCheckBox();
contentPanel.add(guiGetFood);
guiGetFood.setText("Get Food? (Requires Hatchet/Tinder)");
guiGetFood.setToolTipText("If you are holding a hatchet and tinder, you can get food.");
guiGetFood.setFont(new Font("Arial", Font.PLAIN, 12));
guiGetFood.setBounds(217, 120, 250, 19);
}
{
guiGetFood.setEnabled((guiEatFood.isSelected()
&& inventory.contains(tinderbox) && inventory.containsOneOf(hatchets)));
guiCheckForUpdates = new JCheckBox();
contentPanel.add(guiCheckForUpdates);
guiCheckForUpdates.setText("Download Updates?");
guiCheckForUpdates.setToolTipText("Enable this to download updates from Mr. Byte.");
guiCheckForUpdates.setFont(new Font("Arial", Font.PLAIN, 12));
guiCheckForUpdates.setBounds(12, 329, 145, 23);
beVerbose = new JCheckBox();
contentPanel.add(beVerbose);
beVerbose.setText("Verbose Log?");
beVerbose.setToolTipText("Enable extra Log Messages, AKA: Log SPAM!");
beVerbose.setFont(new Font("Arial", Font.PLAIN, 12));
beVerbose.setBounds(358, 329, 138, 23);
beVerbose.setDoubleBuffered(true);
}
{
HPPercentToEat = new JSlider();
contentPanel.add(HPPercentToEat);
HPPercentToEat.setMajorTickSpacing(10);
HPPercentToEat.setMinimum(50);
HPPercentToEat.setMinorTickSpacing(5);
HPPercentToEat.setPaintLabels(true);
HPPercentToEat.setPaintTicks(true);
HPPercentToEat.setSnapToTicks(true);
HPPercentToEat.setValue(75);
HPPercentToEat.setEnabled(guiEatFood.isSelected());
HPPercentToEat.setBorder(new TitledBorder("Eat at "
+ HPPercentToEat.getValue() + "% HP"));
HPPercentToEat.setFont(new Font("Arial", Font.PLAIN, 12));
HPPercentToEat.setToolTipText("Adjust to the HP% you wish to eat at.");
HPPercentToEat.setEnabled(guiEatFood.isSelected());
HPPercentToEat.addChangeListener(new ChangeListener() {
public void stateChanged(final ChangeEvent e) {
HPPercentToEatStateChanged(e);
}
});
HPPercentToEat.setBounds(10, 150, 495, 80);
}
{
hideBankCount = new JComboBox();
contentPanel.add(hideBankCount);
hideBankCount.setModel(new DefaultComboBoxModel(new String[] {
"10 Hides", "20 Hides" }));
hideBankCount.setBounds(206, 295, 110, 30);
}
{
howManyLabel = new JLabel();
contentPanel.add(howManyLabel);
howManyLabel.setText("How many cowhides will we bank each run?");
howManyLabel.setFont(new Font("Arial", Font.PLAIN, 12));
howManyLabel.setEnabled(true);
howManyLabel.setHorizontalAlignment(SwingConstants.CENTER);
howManyLabel.setBounds(10, 265, 513, 30);
}
{
runButton = new JButton();
contentPanel.add(runButton);
runButton.setText("Let's Kill Cows!");
runButton.setFont(new Font("Arial", Font.PLAIN, 12));
runButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
runButtonActionPerformed(e);
}
});
runButton.setBounds(0, 365, 177, 33);
runButton.setSize(211, 34);
}
{
cancelButton = new JButton();
contentPanel.add(cancelButton);
cancelButton.setText("NOOO! Cows are Cuuuute!");
cancelButton.setFont(new Font("Arial", Font.PLAIN, 12));
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
cancelButtonActionPerformed(e);
}
});
cancelButton.setBounds(284, 365, 211, 34);
}
{
jLabel1 = new JLabel();
contentPanel.add(jLabel1);
jLabel1.setText("Beefy Bill Cow Killer v" + version);
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setEnabled(true);
jLabel1.setFont(new java.awt.Font("Arial", 0, 28));
jLabel1.setBounds(10, 0, 513, 57);
}
contentPanel.setFont(new Font("Arial", Font.PLAIN, 12));
contentPanel.setLayout(null);
contentPanel.setPreferredSize(new java.awt.Dimension(501, 360));
}
}
this.setSize(539, 480);
setLocationRelativeTo(getOwner());
}
private void runButtonActionPerformed(final ActionEvent e) {
runButtonPushed = true;
iCanHazCheezBurger = guiEatFood.isSelected();
bankingHides = guiBankHides.isSelected();
gettingBones = guiBuryBones.isSelected();
bankingMeats = guiBankMeat.isSelected();
bankingStaffs = guiPickStaff.isSelected();
update = guiCheckForUpdates.isSelected();
verbose = beVerbose.isSelected();
if (iCanHazCheezBurger) {
whenToEat = (double) HPPercentToEat.getValue() / 100; // Convert
// 75 to
// .75
iCanCookCheezBurger = guiGetFood.isSelected();
}
if (!restWhenTired.isSelected()) {
rndEnergy = 0;
}
if (bankingHides) {
if (hideBankCount.getSelectedItem() == "20 Hides") {
hidesToBank = 20;
}
} else {
hidesToBank = 0;
}
if (bankingHides) {
loots[1] = cowhideID;
}
if (gettingBones) {
loots[2] = bones;
}
if (bankingMeats) {
loots[0] = rawMeat;
}
if (bankingStaffs) {
loots[4] = airStaff;
} else {
junk[2] = airStaff;
}
gui.dispose();
return;
}
private void thisWindowClosing(final WindowEvent e) {
if (!runButtonPushed) {
guiExit = true;
return;
}
gui.dispose();
return;
}
}
private boolean isJar = false;
private static final RSArea billPen = new RSArea(new RSTile[] {
new RSTile(3154, 3348), new RSTile(3153, 3345),
new RSTile(3152, 3325), new RSTile(3152, 3323),
new RSTile(3154, 3316), new RSTile(3156, 3314),
new RSTile(3160, 3314), new RSTile(3171, 3316),
new RSTile(3181, 3314), new RSTile(3192, 3306),
new RSTile(3215, 3308), new RSTile(3205, 3334),
new RSTile(3179, 3348) }),
gateArea = new RSArea(3175, 3312, 3178, 3315),
bankArea = new RSArea(3206, 3217, 3211, 3223),
lumStairs = new RSArea(3205, 3206, 3208, 3211),
teleLanding = new RSArea(3218, 3216, 3226, 3221);
private static final int gate = 45206;
private static final int[] lumbyStairs = { 36773, 36774, 36775 };
private static final RSArea keepOut = new RSArea(3152, 3330, 3171, 3341);
// keepOut is for keeping out of the northern pen, it's just a pain in the
// ass.
private static final RSTile[] lumBank2BillPen = { new RSTile(3205, 3209),
new RSTile(3208, 3209), new RSTile(3213, 3209),
new RSTile(3215, 3214), new RSTile(3217, 3218),
new RSTile(3223, 3219), new RSTile(3228, 3219),
new RSTile(3236, 3219), new RSTile(3236, 3226),
new RSTile(3231, 3230), new RSTile(3226, 3235),
new RSTile(3223, 3242), new RSTile(3220, 3248),
new RSTile(3217, 3252), new RSTile(3213, 3265),
new RSTile(3215, 3273), new RSTile(3213, 3277),
new RSTile(3205, 3280), new RSTile(3196, 3280),
new RSTile(3192, 3289), new RSTile(3189, 3293),
new RSTile(3189, 3299), new RSTile(3186, 3306),
new RSTile(3178, 3310), new RSTile(3177, 3315) },
landingToStairs = { new RSTile(3232, 3218), new RSTile(3224, 3218),
new RSTile(3217, 3219), new RSTile(3214, 3214),
new RSTile(3212, 3211), new RSTile(3206, 3209) };
// safespot is just north of the pen.
private static final DecimalFormat k = new DecimalFormat("#.#");
private static final DecimalFormat whole = new DecimalFormat("####");
private static final String[] skillNames$ = { "Attack", "Defense",
"Strength", "Constitution", "Range", "Prayer", "Magic" };
private static final String[] statusNames$ = { "Starting Up", "Cooking",
"Eating", "Banking", "Fighting", "Looting", "Attacking", "Resting",
"Burying", "Dumping Junk", "Returning to Pen", "Looking for a cow",
"Quitting...", "Gathering Arrows" };
private static final Color[] statusColors = { Color.GREEN.darker(),
Color.CYAN.darker(), Color.ORANGE.brighter(),
Color.GREEN.brighter(), Color.RED.brighter() };
private static final int bones = 526; // , 532, 530, 528, 3183, 2859 };
/*
* It appears that the poisoned variety of arrow is 1 greater than the
* normal one. Bronze 882 * Iron 884 * Steel 886 * Mithril 888 * Adamant 890
* * Rune 892 Bronze Bolts: 877 Training Arrows: 9706
*/
private static final int[] hatchets = { 1349, 1351, 1353, 1355, 1357, 1359,
1361, 6739 };
/*
* Training Bow: 9705
*
* Longbows: plain: 829 Oak: 845 Willow: 847 Maple: 851
*
* Shortbows: Plain: 841 Oak: 843 Maple: 849 Willow: 853
*
* Crossbow: 837
*/
private static final int[] arrows = { 877, 878, 882, 883, 884, 885, 886,
887, 888, 889, 890, 891, 892, 893, 9706 };
/*
* {conditional meat, conditional bones, conditional air staff, burnt meat,
* logs, sling, candles, cake} The 2146's at the beginning are place holders
* and harmless if never changed. The candles/cake are from the 10th anniv.
* stuff.
*/
private static final int[] bows = { 829, 837, 839, 841, 843, 845, 847, 849,
851, 853, 9705 };
private final int[] junk = { 2146, 2146, 2146, 2146, 1511, 1521, 19830,
20114, 20111 };
private static final int beefyBillID = 246;
private static final int cowhideID = 1739;
private static final int beefyBillInterface = 236;
private RSComponent cookingIface, amountIncreaseButton,
amountDecreaseButton;
private static final int[] liveTree = { 1278, 1276 };
private static final int[] logs = { 1511, 1521 };
private static final int tinderbox = 590;
private static final int litFire = 2732;
private static final int rawMeat = 2132;
private static final int cookedMeat = 2142;
private static final int airStaff = 1381;
private final int[] loots = { 0, 0, 0, 0, 0 };
private long startTime, lastTele = 0;
private int[] startXP;
private int hidesToBank = 10;
private int rndEnergy = 23;
private int status = 0, meatHeld, cookedMeatHeld, rawMeatHeld, meatSpace,
meatsLooted, meatCycles, meatsBanked, meatPrice, meatsValue;
private int hidePrice, hidesValue, hidesBanked, hidesLooted, hidesHeld,
bankCycles, hideCost = 0;
private double whenToEat = 0;
private boolean gettingBones = false;
private boolean bankingHides = true;
private boolean bankingMeats = false;
private boolean bankingStaffs = false;
private boolean needMeat = false;
private boolean guiExit = false, runButtonPushed, iCanHazCheezBurger,
iCanCookCheezBurger, update, quitNow;
private String bone$ = "Getting Bones: Yes";
private String meat$ = "Getting Meats: Yes";
private String hide$ = "Getting Hides: NO!!";
private final double version = BeefyBillCowKiller.class.getAnnotation(ScriptManifest.class).version();
public boolean verbose = false, outOfPen = false;
BeefyGUI gui;
private RSNPC cow, bill;
private RSTile me, tile;
private int searchTime = 0;
private int arrowID;
private boolean ranging;
private RSPath path;
Rectangle paintToggle = new Rectangle(390, 343, 120, 15);
public boolean showPaint = true;
public String buttonText = "Hide Paint";
public File PRICE_FILE = new File(new File(Configuration.Paths.getScriptCacheDirectory()), "GEPrices.txt");
private action action() {
meatHeld = inventory.getCount(cookedMeat) + inventory.getCount(rawMeat);
cookedMeatHeld = inventory.getCount(cookedMeat);
rawMeatHeld = inventory.getCount(rawMeat);
me = players.getMyPlayer().getLocation();
if (billPen.contains(me)) {
if (meatSpace > 0 && cookedMeatHeld < meatSpace && rawMeatHeld > 0) {
status = 1;
return action.COOKING;
} else if (iCanHazCheezBurger
&& combat.getLifePoints() < skills.getRealLevel(3) * 10
* whenToEat) {
status = 2;
return action.EATING;
} else if (bankingHides
&& inventory.getCount(cowhideID) >= hidesToBank
|| bankingMeats && inventory.getCount(rawMeat) >= 10) {
status = 3;
return action.BANKING;
} else if (players.getMyPlayer().getInteracting() != null) {
status = 4;
return action.FIGHTING;
} else if ((bankingHides || meatHeld < meatSpace || bankingMeats || gettingBones)
&& findLoot() != null) {
if (lootCheck()) {
status = 5;
return action.LOOTING;
}
}
status = 6;
if (verbose) {
log("Attacking");
}
return action.ATTACKING;
} else {
final int plane = game.getPlane();
if (lumStairs.contains(me)) {
return action.CLIMBING;
}
if (plane == 2 && bankArea.contains(me)) {
return action.BANKSTAFFS;
}
return action.WALKING;
}
}
private boolean adjustCookLevel(final int toCook) {
interfaces.getComponent(916, 17);
amountDecreaseButton = interfaces.getComponent(916, 20);
amountIncreaseButton = interfaces.getComponent(916, 19);
amountDecreaseButton.doClick(true);
sleep(250);
int count = 0;
while (Integer.parseInt("0"
+ interfaces.getComponent(916, 17).getText()) != toCook) {
if (Integer.parseInt("0"
+ interfaces.getComponent(916, 17).getText()) < toCook) {
amountIncreaseButton.doClick(true);
} else {
amountDecreaseButton.doClick(true);
}
sleep(250, 300);
count++;
if (count > 10) {
return false;
}
}
return true;
}
// Subroutines:
private void bankAtBill(final int itemID, final String name) {
while (inventory.getCount(itemID) > 0) {
inventory.getItem(itemID).doClick(true);
clickNPC(bill, "Use " + name);
sleep(1500, 1600);
if (interfaces.getComponent(beefyBillInterface, 1).doClick()) {
sleep(1500, 2000);
}
}
return;
}
private void bePrometheus() {
if (verbose) {
log("bePrometheus()");
}
int missclicks = 0;
if (!inventory.containsOneOf(logs)) {
RSObject tree = objects.getNearest(liveTree);
RSTile where = null;
if (verbose) {
log("I'm a lumberjack and I'm okay...");
}
if (tree != null) {
where = tree.getLocation();
if (!billPen.contains(where)) {
if (verbose) {
log("Tree found...but it's outside the pen, where the Spotted Al's live...");
}
tree = null;
}
}
if (tree == null) {
if (verbose) {
log("No TREE??");
}
walking.walkTileMM(walking.getClosestTileOnMap(billPen.getCentralTile()));
waitPlayerMoving();
return;
}
if (!tree.isOnScreen()) {
walking.walkTileMM(walking.getClosestTileOnMap(tree.getLocation()), 3, 3);
} else {
walking.walkTileOnScreen(tree.getLocation());
}
waitPlayerMoving();
if (getMyPlayer().getAnimation() == -1) {
final int logcount = inventory.getCount(logs);
chopTree(tree);
waitPlayerMoving();
waitPlayerActing();
if (inventory.getCount(logs) == logcount) {
missclicks++;
if (verbose) {
log("Missed: " + missclicks);
}
if (missclicks / 2.0 == missclicks / 2) {
camera.setAngle(random(1, 360));
camera.setPitch(random(1, 100));
if (missclicks == 4) {
missclicks = 0;
randomWalk();
}
}
}
}
return;
} else {
// check the tile we're on for stuff:
if (objects.getTopAt(me) != null) {
randomBump(me);
waitPlayerMoving();
return;
}
final int fc = skills.getCurrentExp(Skills.FIREMAKING);
inventory.getItem(tinderbox).doClick(true);
sleep(1000, 2000);
if (inventory.containsOneOf(logs)) {
inventory.getItem(logs).doClick(true);
}
int timer = 0;
while (fc == skills.getCurrentExp(Skills.FIREMAKING) && timer < 20) {
sleep(500);
}
timer++;
if (verbose) {
log("We have created....FIRE!");
}
return;
}
}
public int buryBones(final int oldstatus) {
status = 8;
if (verbose) {
log("Burying bones...");
}
while (inventory.contains(bones)) {
inventory.getItem(bones).doClick(true);
sleep(1000, 1500);
}
return oldstatus;
}
private void checkDest() {
if (verbose) {
log("Destination is: " + walking.getDestination());
}
if (walking.getDestination() != null
&& !billPen.contains(walking.getDestination())) {
walking.walkTileOnScreen(me);
}
}
private boolean chopTree(final RSObject obj) {
if (getMyPlayer().isMoving()) {
for (int i = 0, len = random(2, 5); i < len; ++i) {
mouse.move(obj.getModel().getPoint());
sleep(20, 100);
}
return menu.doAction("Chop");
} else {
return obj.doAction("Chop");
}
}
private boolean clickMenu(final String name, final String action) {
final String[] menuItems = menu.getItems();
if (menuItems.length == 0) {
return false;
}
for (final String menuItem : menuItems) {
if (menuItem.toLowerCase().contains(name.toLowerCase())) {
if (menuItems[0].toLowerCase().contains(action.toLowerCase())) {
mouse.click(true);
sleep(1000);
return true;
} else {
mouse.click(false);
menu.doAction(action);
sleep(1000);
return true;
}
}
}
return false;
}
private boolean clickNPC(final RSNPC npc, final String action) {
if (npc == null) {
return false;
}
final RSTile tile = npc.getLocation();
if (tile.getX() < 0 || tile.getY() < 0) {
return false;
}
try {
Point screenLoc = npc.getScreenLocation();
if (calc.distanceTo(tile) > 6 || !calc.pointOnScreen(screenLoc)) {
camera.turnTo(tile);
}
if (!calc.pointOnScreen(screenLoc)) {
walking.walkTileMM(tile);
return false;
}
for (int i = 0; i < 20; i++) {
screenLoc = npc.getScreenLocation();
if (!npc.isValid() || !calc.pointOnScreen(screenLoc)) {
return false;
}
mouse.move(randomPoint(screenLoc));
if (menu.getItems()[0].toLowerCase().contains(npc.getName().toLowerCase())) {
break;
}
}
return clickMenu(npc.getName(), action);
} catch (final Exception e) {
log.log(Level.SEVERE, "clickNPC(RSNPC, String) model error: ", e);
return false;
}
}
private void climbStairs(final String climb) {
int z = 0;
if (climb.contains("up")) {
z = 2;
}
if (game.getPlane() != z && objects.getNearest(lumbyStairs) != null) {
if (!objects.getNearest(lumbyStairs).doAction(climb)) {
climbStairs(climb);
}
sleep(750, 1500);
}
waitPlayerMoving();
return;
}
private int countCheezBurgers() {
final RSItem[] is = inventory.getItems();
int foodcount = 0;
for (final RSItem i : is) {
if (i.getComponent().getActions() == null
|| i.getComponent().getActions()[0] == null) {
continue;
}
if (i.getComponent().getActions()[0].contains("Eat")) {
foodcount++;
}
}
return foodcount;
}
private void doCook() {
if (verbose) {
log("doCook()");
}
cookedMeatHeld = inventory.getCount(cookedMeat);
rawMeatHeld = inventory.getCount(rawMeat);
meatHeld = cookedMeatHeld + rawMeatHeld;
final RSObject fire = objects.getNearest(litFire);
if (fire == null) {
return;
}
final RSTile fireTile = walking.getClosestTileOnMap(fire.getLocation());
cookingIface = interfaces.getComponent(905, 14);
final int toCook = meatSpace - cookedMeatHeld;
if (!fire.isOnScreen()) {
camera.turnTo(fire);
if (!fire.isOnScreen()) {
walking.walkTileMM(fireTile);
return;
}
}
if (inventory.getSelectedItem() == null) {
inventory.getItem(rawMeat).doAction("Use Raw beef");
}
sleep(1500, 1750);
if (inventory.getSelectedItem() == null) {
doCook();
}
if (tiles.doAction(fire.getLocation(), "Raw")) {
sleep(2500);
}
if (cookingIface.isValid()) {
if (toCook < rawMeatHeld) {
if (!adjustCookLevel(toCook)) {
return;
}
}
cookingIface.doClick();
sleep(1500, 2000);
waitPlayerActing();
}
}
private void download(final String address, final String localFileName) {
OutputStream out = null;
URLConnection conn;
InputStream in = null;
try {
final URL url = new URL(address);
out = new BufferedOutputStream(new FileOutputStream(localFileName));
conn = url.openConnection();
in = conn.getInputStream();
final byte[] buffer = new byte[1024];
int numRead;
while ((numRead = in.read(buffer)) != -1) {
out.write(buffer, 0, numRead);
}
} catch (final Exception exception) {
log("Downloading failed!");
} finally {
try {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
} catch (final IOException ioe) {
log("Downloading failed!");
}
}
}
public int dropJunk(final int oldstatus, final int... items) {
status = 9;
while (inventory.containsOneOf(items)) {
inventory.getItem(items).doAction("Drop");
sleep(1000);
}
return oldstatus;
}
private int eatFood(final int oldstatus) {
if (!iCanHazCheezBurger) {
return oldstatus; // We're not eating...
}
status = 2;
final RSItem food = iHazCheezburgers();
if (food != null) {
food.doAction("Eat ");
return oldstatus;
} else {
status = 12;
log("No More Food.");
return status;
}
}
private RSGroundItem findLoot() {
try {
RSGroundItem loot = groundItems.getNearest(loots);
if (needMeat) {
loot = groundItems.getNearest(rawMeat);
}
if (loot == null || needMeat) {
return loot;
}
if (gettingBones && bankingMeats && bankingHides
&& billPen.contains(loot.getLocation())
&& loot.isOnScreen()) {
return loot;
}
if (!billPen.contains(loot.getLocation())) {
randomWalk();
loot = null;
}
if (loot != null) {
if (!loot.isOnScreen()
&& calc.distanceTo(loot.getLocation()) > 7
|| !billPen.contains(loot.getLocation())) {
loot = null;
}
}
return loot;
} catch (final Exception e) {
log.log(Level.SEVERE, "pickup() model error: ", e);
return null;
}
}
private String format(final long time, final boolean seconds) {
if (time <= 0) {
return "--:--:--";
}
final StringBuilder t = new StringBuilder();
final long TotalSec = time / 1000;
final long TotalMin = TotalSec / 60;
final long TotalHour = TotalMin / 60;
final int second = (int) TotalSec % 60;
final int minute = (int) TotalMin % 60;
final int hour = (int) TotalHour;
if (hour < 10) {
t.append("0");
}
t.append(hour);
t.append(":");