-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBurthCow.java
More file actions
231 lines (193 loc) · 6.2 KB
/
BurthCow.java
File metadata and controls
231 lines (193 loc) · 6.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
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.awt.*;
import org.powerbot.core.event.listeners.PaintListener;
import org.powerbot.core.script.ActiveScript;
import org.powerbot.core.script.job.Task;
import org.powerbot.core.script.job.state.Node;
import org.powerbot.core.script.job.state.Tree;
import org.powerbot.game.api.Manifest;
import org.powerbot.game.api.methods.Calculations;
import org.powerbot.game.api.methods.Game;
import org.powerbot.game.api.methods.Walking;
import org.powerbot.game.api.methods.interactive.NPCs;
import org.powerbot.game.api.methods.interactive.Players;
import org.powerbot.game.api.methods.node.GroundItems;
import org.powerbot.game.api.methods.tab.Inventory;
import org.powerbot.game.api.methods.widget.Bank;
import org.powerbot.game.api.methods.widget.Camera;
import org.powerbot.game.api.methods.widget.WidgetCache;
import org.powerbot.game.api.util.Random;
import org.powerbot.game.api.util.Time;
import org.powerbot.game.api.util.Timer;
import org.powerbot.game.api.wrappers.Area;
import org.powerbot.game.api.wrappers.Tile;
import org.powerbot.game.api.wrappers.interactive.NPC;
import org.powerbot.game.api.wrappers.node.GroundItem;
import org.powerbot.game.bot.Context;
import org.powerbot.game.client.Client;
@Manifest(authors = { "Warnick" }, name = "BurthCow", version = 1.0, description = "Kills cows in Burthorpe and Loots them")
public class BurthCow extends ActiveScript implements PaintListener{
private Client client = Context.client();
private Tree jobContainer = null;
int CowsKilled;
Timer runTime = new Timer(0);
public Tile Bankc = new Tile(2892, 3530, 0);
public Tile Fieldc = new Tile(2886,3488,0);
public final Area Field = new Area(new Tile[] {
new Tile(2891, 3492, 0), new Tile(2891, 3487, 0),
new Tile(2892, 3482, 0), new Tile(2888, 3479, 0),
new Tile(2883, 3479, 0), new Tile(2880, 3483, 0),
new Tile(2879, 3488, 0), new Tile(2880, 3493, 0),
new Tile(2881, 3498, 0)
});
private final List<Node> jobsCollection = Collections
.synchronizedList(new ArrayList<Node>());
private final static int[] COW_ID = { 14997, 14999, 14998 };
private final static int[] LOOT_ID = { 1739, 526, 2132 };
public void onStart() {
provide(new Attack(), new Banking(), new Pickup(), new WalktoField());
}
public boolean NeedToLoot() {
GroundItem loot = GroundItems.getNearest(LOOT_ID);
while (loot != null) {
return true;
}
return false;
}
public class Pickup extends Node {
@Override
public void execute() {
System.out.println("Pickup Activated");
GroundItem g = GroundItems.getNearest(LOOT_ID);
if (g != null) {
if (!g.isOnScreen()) {
Walking.walk(g);
} else {
g.interact("Take", g.getGroundItem().getName());
sleep(Random.nextInt(1200, 1500));
if (Calculations.distanceTo(g.getLocation()) > 2) {
}
}
}
}
@Override
public boolean activate() {
return NeedToLoot() && Field.contains(Players.getLocal().getLocation());
}
}
public class WalktoField extends Node{
@Override
public boolean activate() {
return !Field.contains(Players.getLocal().getLocation()) && !Inventory.isFull();
}
@Override
public void execute() {
System.out.println("Walk to field actviated");
if (Players.getLocal().isIdle()) {
Walking.walk(Fieldc);
}
}
}
public class Banking extends Node {
@Override
public boolean activate() {
return Inventory.isFull();
}
@Override
public void execute() {
System.out.println("Bank Activated");
if (Bank.isOpen()) {
if (Bank.depositInventory()) {
Task.sleep(900, 1400);
if (Bank.close()) {
Task.sleep(800, 1000);
}
}
} else if (!Bank.isOpen()) {
if (Bank.getNearest() != null) {
if (!Bank.getNearest().isOnScreen()) {
if (Bankc != null) {
Camera.turnTo(Bankc);
Walking.walk(Bankc);
}
} else if (Bank.getNearest().isOnScreen()) {
if (Bank.open()) {
Task.sleep(800, 1000);
}
}
}
}
}
}
public class Attack extends Node {
@Override
public boolean activate() {
return Inventory.getCount() < 28
&& !Players.getLocal().isInCombat() && Field.contains(Players.getLocal().getLocation());
}
@Override
public void execute() {
System.out.println("Attack Activated");
NPC cow = NPCs.getNearest(COW_ID);
if (cow.isOnScreen()) {
if (!Players.getLocal().isInCombat()
&& Players.getLocal().getInteracting() == null
&& cow.getAnimation() == -1) {
cow.interact("Attack");
sleep(Random.nextInt(1500, 2000));
CowsKilled++;
}
} else {
Walking.walk(cow.getLocation());
Camera.setPitch(true);
}
}
}
@Override
public int loop() {
if (Game.getClientState() != Game.INDEX_MAP_LOADED) {
return 1000;
}
if (client != Context.client()) {
WidgetCache.purge();
Context.get().getEventManager().addListener(this);
client = Context.client();
}
if (jobContainer != null) {
final Node job = jobContainer.state();
if (job != null) {
jobContainer.set(job);
getContainer().submit(job);
job.join();
}
}
return 50;
}
public final void provide(final Node... jobs) {
for (final Node job : jobs) {
if (!jobsCollection.contains(job)) {
jobsCollection.add(job);
}
}
jobContainer = new Tree(jobsCollection.toArray(new Node[jobsCollection
.size()]));
}
private final RenderingHints antialiasing = new RenderingHints(
RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
private final Color color1 = new Color(255, 0, 0);
private final Font font1 = new Font("Arial", 0, 26);
private final Font font2 = new Font("Arial", 0, 19);
public void onRepaint(Graphics g1) {
Graphics2D g = (Graphics2D)g1;
g.setRenderingHints(antialiasing);
g.setFont(font1);
g.setColor(color1);
g.drawString("Nicks Cow Killa", 18, 425);
g.setFont(font2);
g.drawString("Total Cows Killed: "+CowsKilled, 107, 459);
g.drawString("Time Runnning: "+ Time.format(runTime.getElapsed()), 106, 486);
}
//END: Generated By OmniEasel
}