-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcowKiller.class
142 lines (130 loc) · 5.41 KB
/
cowKiller.class
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
package cowKiller;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.map.Area;
import org.dreambot.api.methods.map.Tile;
import org.dreambot.api.script.AbstractScript;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
import org.dreambot.api.wrappers.interactive.GameObject;
import org.dreambot.api.wrappers.interactive.NPC;
import org.dreambot.api.wrappers.items.GroundItem;
@ScriptManifest(author = "fractal", name = "FractalCowKiller", category = Category.COMBAT, version = 1.0, description = "Kills cows, loots their hides, and banks")
public class CowKiller extends AbstractScript {
public enum actionTypes {
walking, interactive, spam, afk
}
int walkingShape;
int runningShape;
int interactiveShape;
int spamShape;
int scale;
int reaction; // minimum wait between actions
int patience; // minimum wait between running to a new spot while still running. patience is doubled while walking
int latency = 250; // how long does it take the game to register your actions? change this depending on CPU/RAM/lag
Area cowPen = new Area(new Tile(3265, 3296), new Tile(3253, 3255));
int cowHide = 1739;
int gate = 1558;
@Override
public int onLoop() {
farmHides();
return 0;
}
public void onStart(){
reaction = Calculations.random(200,400);
patience = Calculations.random(1500, 3000);
walkingShape = Calculations.random(2,5);
runningShape = Calculations.random(2,4);
interactiveShape = Calculations.random(2,4);
spamShape = 1;
scale = Calculations.random(400,1000); // proxy for variables in your physical environment affecting your attention
}
public int farmHides() {
String[] targets = {"Cow", "Cow calf"};
Integer[] loot = {cowHide};
if (getInventory().isFull()) {
bankItems(loot, true);
} else {
combatLoot(targets, loot, cowPen);
}
return 1;
}
public void combatLoot(String[] targets, Integer[] loot, Area area) {
if (!area.contains(getLocalPlayer())) {
go(area);
} else if (!getLocalPlayer().isInCombat()){
NPC target = getNpcs().closest(t -> t!= null && !t.isInCombat() && elem(t.getName(), targets));
GroundItem prize = getGroundItems().closest(loot);
if (prize != null && target != null && prize.distance(getLocalPlayer()) < target.distance(getLocalPlayer())) {
prize.interact("Take");
sleep(latency);
sleepUntil(()-> !getLocalPlayer().isMoving(), 60000);
antiban(actionTypes.interactive);
} else if (target != null && !getLocalPlayer().isInCombat()) {
GameObject g = getGameObjects().closest(o -> o.getID() == gate);
if (!area.contains(target) && g.hasAction("Open")) {
g.interact("Open");
} else if (target.interact("Attack")) {
if(!target.isOnScreen()) {
getCamera().rotateToEntity(target);
}
sleepUntil(() -> getLocalPlayer().isInCombat(), 60000);
sleepUntil(() -> !getLocalPlayer().isInCombat(), 60000);
}
antiban(actionTypes.interactive);
}
} else {
sleepUntil(() -> !getLocalPlayer().isInCombat(), 60000);
}
}
public void bankItems(Integer[] itemIDs, boolean all) {
if (!getBank().isOpen()) {
getBank().open(getBank().getClosestBankLocation());
antiban(actionTypes.interactive);
} else {
if (all) {
getBank().depositAllItems();
antiban(actionTypes.interactive);
getBank().close();
antiban(actionTypes.interactive);
} else {
getBank().depositAll(item -> elem(item.getID(), itemIDs));
antiban(actionTypes.interactive);
getBank().close();
antiban(actionTypes.interactive);
}
}
}
public boolean elem (Object elem, Object[] list){
for (int i = 0; i < list.length; i++){
if (list[i].equals(elem)){
return true;
}
}
return false;
}
public void go(Area area) {
if (!area.contains(getLocalPlayer())) {
getWalking().walk(area.getRandomTile());
antiban(actionTypes.walking);
}
}
public void antiban(actionTypes action) {
if (action == actionTypes.walking) {
if(getWalking().isRunEnabled()) {
int time = (int) (Calculations.nextGammaRandom(runningShape, scale)) + patience;
sleep(latency);
sleepUntil(() -> !getLocalPlayer().isMoving(), time);
} else {
int time = (int) (Calculations.nextGammaRandom(walkingShape, scale)) + patience * 2;
sleep(latency);
sleepUntil(() -> !getLocalPlayer().isMoving(), time);
}
} else if (action == actionTypes.interactive) {
int time = (int) (Calculations.nextGammaRandom(interactiveShape, scale)) + reaction;
sleep(time);
} else if (action == actionTypes.spam){
int time = (int) (Calculations.nextGammaRandom(spamShape, scale)) + reaction;
sleep(time);
}
}
}