-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMonkSkenger.java
More file actions
239 lines (207 loc) · 9.47 KB
/
Copy pathMonkSkenger.java
File metadata and controls
239 lines (207 loc) · 9.47 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
package MonkSkenger;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.skills.Skill;
import org.dreambot.api.script.AbstractScript;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
import java.util.concurrent.TimeUnit;
import javax.imageio.ImageIO;
import org.dreambot.api.randoms.RandomEvent;
import org.dreambot.api.utilities.Timer;
import org.dreambot.api.wrappers.interactive.NPC;
import org.dreambot.api.wrappers.widgets.WidgetChild;
import java.awt.*;
import java.io.IOException;
import java.net.URL;
@ScriptManifest(category = Category.COMBAT, name = "MonkSkenger", author = "skengrat", version = 1.5)
public class MonkSkenger extends AbstractScript {
public boolean isruning;
public boolean inCombatBool = false;
private int beginningXP;
private int currentXp;
private int xpGained;
private static final String EVENT_RPG = "Event rpg";
private Timer timer = new Timer();
private Image mainPaint = getImage("https://i.imgur.com/JY38qJe.png");
// ONSTART() METHOD
public void onStart() {
getRandomManager().disableSolver(RandomEvent.DISMISS);
beginningXP = getSkills().getExperience(Skill.DEFENCE);
hasDefaultZoom();
getClient().getInstance().setDrawMouse(false);
isruning = true;
Thread t = new Thread(() -> {
int x = 0;
while (isruning) {
if ((getLocalPlayer().isInCombat() && getLocalPlayer().getInteractingCharacter() != null) || getLocalPlayer().getAnimation() != -1) {
inCombatBool = true;
x=0;
} else if (x > 8) {
inCombatBool = false;
x = 0;
}
x++;
// log(String.valueOf(inCombatBool));
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
t.start();
//antiafk thread
Thread k = new Thread(() -> {
int x = 0;
while (isruning) {
if ((getLocalPlayer().isInCombat() && getLocalPlayer().getInteractingCharacter() != null) || getLocalPlayer().getAnimation() != -1) {
//anti afk here
log((String)"antiafk");
getMouse().getMouseSettings().setWordsPerMinute(Calculations.random(22, 122));
getKeyboard().type("l", false);
sleep(Calculations.random(22042, 522073));
x=0;
} else if (x > 8) {
//nothn
x = 0;
}
x++;
// log(String.valueOf(inCombatBool));
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
k.start();
}
// ONLOOP() METHOD
@Override
public int onLoop() {
//if (getEquipment().isSlotEmpty(EquipmentSlot.WEAPON.getSlot())){
// if(getInventory().contains(EVENT_RPG)) {
// getInventory().interact(EVENT_RPG, "Wield");
// }else{
if (!inCombatBool) {
alltaken();
sleep(Calculations.random(3000, 8000));
// }
// currentNpc = getNpcs().closest(npc -> npc != null && npc.getName() != null && npc.getName().equals(npcName) && !npc.isInCombat() && npc.getInteractingCharacter() == null);
// if(currentNpc != null) { //does the npc exist?
// if(!getLocalPlayer().isInCombat() && getLocalPlayer().getInteractingCharacter() == null) { //Make sure we aren't in combat or interacting with something
// if(currentNpc.interact("Attack")) { //currentNpc will return true if we succesfully attacked the rat, if that happens we want to wait a bit to make sure we are in combat
// sleepUntil(() -> getLocalPlayer().isInCombat() || getLocalPlayer().getInteractingCharacter() != null, 2000); //Wait a max of 2 seconds or until we are in combat
// }
// return 100;
// } else {
// return 100;
// }
// }
// return 100;
}//}
// }
return 0;
}
public void attack() {
//NPC slayerTask = getNpcs().closest(npc = npc.getName("Monk") && !npc.isInCombat());
currentNpc = getNpcs().closest(npc -> npc != null && npc.getName() != null && npc.getName().equals(npcName) && !npc.isInCombat() && npc.getInteractingCharacter() == null);
if(currentNpc != null) { //does the npc exist?
if(!getLocalPlayer().isInCombat() && getLocalPlayer().getInteractingCharacter() == null) { //Make sure we aren't in combat or interacting with something
if (currentNpc.interact("Attack")) {
changeStatus("Attacking");
sleepUntil(() -> getLocalPlayer().isInCombat() || getLocalPlayer().getInteractingCharacter() != null, Calculations.random(5000, 7000));
}
}
}
}
public void alltaken() {
currentNpc = getNpcs().closest(npc -> npc != null && npc.getName() != null && npc.getName().equals(npcName) && !npc.isInCombat() && npc.getInteractingCharacter() == null);
if(currentNpc != null) {
//if no monk hop world
log((String)"monk here");
attack();
}else {
if (!inCombatBool) {
log((String)"all taken, hopping");
this.hopworlds();
}
}
}
private void hopworlds()
{
if (this.getWorldHopper().hopWorld(this.f2pworld())) {
sleep((int)Calculations.random((int)100, (int)300));
sleepUntil(() -> this.getLocalPlayer().exists() && this.getClient().isLoggedIn(), (long)Calculations.random((int)300, (int)500));
}
}
private int f2pworld()
{
return this.getWorlds().getRandomWorld(w -> w.isF2P() && !w.isDeadmanMode() && !w.isPVP() && w.getMinimumLevel() < 500 && !w.isHighRisk() && w.getID() != this.getClient().getCurrentWorld()).getID();
}
public void onExit() {
super.onExit();
isruning = false;
}
private final Color[] COLORS = {Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA};
@Override
public void onPaint(Graphics g) {
((Graphics2D) g).setRenderingHint(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.drawImage(mainPaint, 0, 339, null);
currentXp = getSkills().getExperience(Skill.DEFENCE);
xpGained = currentXp - beginningXP;
// g.drawString("XP Gained: " + xpGained, 1, 1);
g.setFont(new Font("Arial", Font.BOLD, 12));
g.setColor(Color.BLACK);
g.drawString("World: " + getClient().getCurrentWorld(), 20, 392);
g.drawString("Runtime: " + timer.formatTime(), 20, 365);
//g.drawString("State: " + status.name(), 25, 55);
g.drawString("XP Gained: " + xpGained, 20, 410);
g.drawString("Defence LVL: "+ getSkills().getRealLevel(Skill.DEFENCE), 20, 435);
//g.drawString("XP/h: " + getSkillTracker().getGainedExperiencePerHour(Skill.DEFENCE) , 25, 395);
Graphics2D graphics2D = (Graphics2D) g;
graphics2D.setStroke(new BasicStroke(3));
final Point location = getMouse().getPosition();
for (int i = COLORS.length - 1; i >= 0; i--) {
graphics2D.setColor(COLORS[i]);
graphics2D.drawLine(location.x - i, location.y + i, location.x + i, location.y - i);
graphics2D.drawLine(location.x + i, location.y + i, location.x - i, location.y - i);
}
}
private void changeStatus(String attacking) {
}
private Image getImage(String url){
try {
return ImageIO.read(new URL(url));
}catch (IOException e){
return null;
}
}
public boolean hasDefaultZoom() {
WidgetChild zoomBtn = getWidgets().getWidgetChild(261,13);
return zoomBtn.getX() == 626 && zoomBtn.getY() == 265;
}
private String ft(long duration)
{
String res = "";
long days = TimeUnit.MILLISECONDS.toDays(duration);
long hours = TimeUnit.MILLISECONDS.toHours(duration)
- TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
- TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
.toHours(duration));
long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
- TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
.toMinutes(duration));
if (days == 0) {
res = (hours + ":" + minutes + ":" + seconds);
} else {
res = (days + ":" + hours + ":" + minutes + ":" + seconds);
}
return res;
}
private NPC currentNpc; //Let's make this a global variable so we dont have to create a new one each loop :)
public String npcName = "Monk"; //This will be changed with our GUI later on
}