-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLavaDragonKiller.java
More file actions
542 lines (452 loc) · 17.9 KB
/
Copy pathLavaDragonKiller.java
File metadata and controls
542 lines (452 loc) · 17.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
import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.Arrays;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.container.impl.equipment.EquipmentSlot;
import org.dreambot.api.methods.map.Area;
import org.dreambot.api.methods.map.Tile;
import org.dreambot.api.methods.skills.Skill;
import org.dreambot.api.methods.tabs.Tab;
import org.dreambot.api.methods.walking.path.impl.LocalPath;
import org.dreambot.api.methods.walking.pathfinding.impl.obstacle.impl.DestructableObstacle;
import org.dreambot.api.script.AbstractScript;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
import org.dreambot.api.utilities.Timer;
import org.dreambot.api.wrappers.interactive.Entity;
import org.dreambot.api.wrappers.interactive.GameObject;
import org.dreambot.api.wrappers.interactive.NPC;
import org.dreambot.api.wrappers.interactive.Player;
import org.dreambot.api.wrappers.items.GroundItem;
@ScriptManifest(author = "skengrat", name = "LavaDragon killer", version = 1.1, description = "kills lava dragons", category = Category.COMBAT)
public class main extends AbstractScript{
private final String[] loot = new String[]{"Draconic visage", "Onyx bolt tips", "Shield left half", "Dragon med helm", "Dragon spear", "Rune 2h sword", "Rune kiteshield", "Rune battleaxe", "Runite bar", "Nature rune", "Rune sq shield", "Tooth half of key", "Loop half of key", "Fire orb", "Rune full helm", "Rune longsword", "Adamant platebody", "Rune med helm", "Rune dart", "Dragon javelin heads", "Lava dragon bones", "Black dragonhide", "Lava scale", "Rune javelin", "Runite bolts", "Blood rune", "Death rune", "Rune knife", "Law rune", "Rune axe", "Grimy ranarr weed", "Rune battleaxe", "Uncut diamond", "Silver ore", "Rune arrow", "Dragonstone", "Law rune", "Death rune", "Steel arrow", "Rune spear"};
public Area Bank = new Area(2531, 4711, 2564, 4722);
public Area SafeSpot = new Area(3216, 3825, 3215, 3826);
public Area DragonZone = new Area(3210, 3817, 3225, 3834);
public Area died = new Area(3225, 3227, 3219, 3204);
public Boolean dead = false;
private Timer t;
public boolean looting = false;
public boolean shouldHop = false;
public boolean full = false;
public int hopped = 0;
public ArrayList<String> wlist = new ArrayList<String>();
Area teleArea = new Area(new Tile(3153, 3925), new Tile(3156, 3925), new Tile(3156, 3922), new Tile(3154, 3922), new Tile(3153, 3923));
Area doorArea = new Area(new Tile(3222,3903), new Tile(3227,3903));
Area mageBankTele = new Area(new Tile(3090, 3955), new Tile(3090, 3958), new Tile(3092, 3956));
Tile dragIsleTile = new Tile(3200,3816);
Tile wildGate = new Tile(3224,3906);
Tile corner = new Tile(3135, 3913);
LocalPath<Tile> pathToBank = new LocalPath<Tile>(this);
Tile[] tiles = new Tile[] {dragIsleTile, wildGate, corner, mageBankTele.getRandomTile()};
LocalPath<Tile> pathToDrags = new LocalPath<Tile>(this);
Tile[] dTiles = new Tile[]{mageBankTele.getCenter(), corner, wildGate, dragIsleTile};
public String[] items = {"Air rune", "Mind rune", "Amulet of glory(4)", "Mystic robe top", "Mystic robe bottom", "Stamina potion(4)",
"Staff of fire", "Anti-dragon shield", "Lobster", "Burning amulet(4)"
};
public int[] amount = {1500, 1000, 1, 1, 1, 1, 1, 1, 8, 1}; // null = idk
public int rState = 0;
public boolean pulled= false;
public String BurnAmulet;
public String Glory;
public String Stamina;
public String rune;
// BANKERS ONDEATH BANK METHOD
public void onStart() {
new Frame(this);
t = new Timer();
pathToBank.addAll(Arrays.asList(tiles));
pathToDrags.addAll(Arrays.asList(dTiles));
getWalking().getAStarPathFinder().addObstacle(new DestructableObstacle("Web", "Slash", null, null, null));
}
public void onDeath() {
log("Bot Has Died. Returning to Mage Bank.");
if(!getBank().getClosestBankLocation().EDGEVILLE.getArea(3).contains(getLocalPlayer()) && rState == 0) {
getWalking().walk(getBank().getClosestBankLocation().EDGEVILLE.getCenter());
sleepUntil(() -> !getLocalPlayer().isMoving() || getLocalPlayer().distance(getClient().getDestination()) < 3, Calculations.random(1500,2500));
if(getBank().getClosestBankLocation().EDGEVILLE.getArea(3).contains(getLocalPlayer())) {
rState = 1;
log("Stage 1: Bot has reached Edgeville Bank.");
}
}
if(!getInventory().contains("Knife") && rState == 1) {
if(!getBank().isOpen()) {
getBank().openClosest();
sleepUntil(() -> getBank().isOpen(), 5000);
} else {
if(!getInventory().isEmpty()) {
getBank().depositAllItems();
sleepUntil(() -> getInventory().isEmpty(), 3000);
} else {
getBank().withdraw("Knife", 1);
sleepUntil(() -> getInventory().contains("Knife"), 2500);
getBank().close();
}
if(getInventory().contains("Knife")) {
rState = 2;
log("Stage 2: Knife Withdrawn - Going to Mage-Bank.");
}
}
if(getInventory().contains("Knife") && rState == 2) {
GameObject lever = getGameObjects().closest("Lever");
if(!pulled) {
lever.interact("Pull");
sleepUntil(() -> getDialogues().canContinue(), 3000);
if(getDialogues().canContinue()) {
getDialogues().continueDialogue();
sleepUntil(() -> getDialogues().getOptions() != null, 2500);
}
if(getDialogues().getOptions() != null) {
getDialogues().chooseOption(1);
sleepUntil(() -> !getDialogues().inDialogue(), 3250);
pulled = true;
}
}
if(pulled && !teleArea.contains(getLocalPlayer())) {
sleepUntil(() -> teleArea.contains(getLocalPlayer()), 10000);
}else if (pulled && teleArea.contains(getLocalPlayer())) {
log("Stage 3: Arrived In Wilderness.");
rState = 3;
pulled = false;
}
}
if(getInventory().contains("Knife") && rState == 3) {
if(!mageBankTele.contains(getLocalPlayer()) && !pulled) {
getWalking().walk(mageBankTele.getRandomTile());
sleepUntil(() -> !getLocalPlayer().isMoving() || getLocalPlayer().distance(getClient().getDestination())<3, Calculations.random(1000,2400));
} else {
GameObject lever = getGameObjects().closest("Lever");
if(!pulled) {
lever.interact("Pull");
sleepUntil(() -> mageBankTele.contains(getLocalPlayer()), 10000);
if(!mageBankTele.contains(getLocalPlayer()))
{
pulled = false;
rState = 4;
log("Stage 4: Arrived In Mage-Bank.");
log("Defaulting to Bank Method.");
}
}
}
}
}
}
public void walkToBank() {
if (pathToBank.isEmpty()) {
pathToBank.addAll(Arrays.asList(tiles));
}
if(!mageBankTele.contains(getLocalPlayer())) {
log("following the path");
pathToBank.walk();
sleep(1000, 1400);
}
if(mageBankTele.contains(getLocalPlayer())) {
GameObject lever = getGameObjects().closest("Lever");
if(!pulled) {
lever.interact("Pull");
sleepUntil(() -> mageBankTele.contains(getLocalPlayer()), 10000);
if(Bank.contains(getLocalPlayer())) {
pulled = false;
}
}
}
}
public void walkToDragons() {
if (pathToDrags.isEmpty()) {
pathToDrags.addAll(Arrays.asList(tiles));
}
if(!getLocalPlayer().equals(dragIsleTile)) {
log("Following path to dragons.");
pathToDrags.walk();
sleep(1000, 1400);
}
}
public void banking() {
if(!Bank.contains(getLocalPlayer())) {
walkToBank();
} else {
NPC gundai = getNpcs().closest("Gundai");
if(!getBank().isOpen()) {
gundai.interact("Bank");
sleepUntil(() -> getBank().isOpen(), 3500);
} else {
if(!getInventory().isEmpty()) {
getBank().depositAllItems();
getBank().depositAllEquipment();
sleep(Calculations.random(890, 1350));
} else {
for(int x = 0; x < items.length; x++) {
if(!getInventory().contains(items[x])) {
getBank().withdraw(items[x], amount[x]);
sleep(500, 1000);
}
}
getBank().close();
GameObject Lever = getGameObjects().closest("Lever");
Lever.interact("Pull");
sleep(3000, 4000);
}
}
}
if(!getBank().getClosestBankLocation().EDGEVILLE.getArea(3).contains(getLocalPlayer())) {
getWalking().walk(getBank().getClosestBankLocation().EDGEVILLE.getCenter());
sleepUntil((() -> !getLocalPlayer().isMoving() || getLocalPlayer().distance(getClient().getDestination()) < 30), Calculations.random(2000,3000));
} else {
if(!getBank().isOpen()) {
getBank().openClosest();
sleepUntil(() -> getBank().isOpen(), 2100);
} else {
getBank().depositAllItems();
getBank().withdraw("Knife", 1);
sleepUntil(() -> getInventory().contains("Knife"), 2000);
}
}
}
//BEGIN GET METHODS
public void getUseable()
{
if(getBank().contains("Burning amulet(1)")) {BurnAmulet = "Burning amulet(1)";}
else if(getBank().contains("Burning amulet(2)")) {BurnAmulet = "Burning amulet(2)";}
else if(getBank().contains("Burning amulet(3)")) {BurnAmulet = "Burning amulet(3)";}
else if(getBank().contains("Burning amulet(4)")) {BurnAmulet = "Burning amulet(4)";}
else if(getBank().contains("Burning amulet(5)")) {BurnAmulet = "Burning amulet(5)";}
else{log("Bot has ran out of Burning amulets");}
if(getBank().contains("Amulet of glory(1)")) {Glory = "Amulet of glory(1)";}
else if(getBank().contains("Amulet of glory(2)")) {Glory = "Amulet of glory(2)";}
else if(getBank().contains("Amulet of glory(3)")) {Glory = "Amulet of glory(3)";}
else if(getBank().contains("Amulet of glory(4)")) {Glory = "Amulet of glory(4)";}
else if(getBank().contains("Amulet of glory(5)")) {Glory = "Amulet of glory(5)";}
else if(getBank().contains("Amulet of glory(6)")) {Glory = "Amulet of glory(6)";}
else{log("Bot has ran out of Amulet of glories");}
if(getBank().contains("Stamina potion(1)")) {Stamina = "Stamina potion(1)";}
else if(getBank().contains("Stamina potion(2)")) {Stamina = "Stamina potion(2)";}
else if(getBank().contains("Stamina potion(3)")) {Stamina = "Stamina potion(3)";}
else if(getBank().contains("Stamina potion(4)")) {Stamina = "Stamina potion(4)";}
else{log("Bot has ran out of Stamina potions");}
}
public void getDragon()
{
if(!looting)
{
NPC Dragon = getNpcs().closest("Lava dragon");
if(DragonZone.contains(Dragon))
{
if(getLocalPlayer().isInCombat())
{
sleepUntil(() -> !getLocalPlayer().isInCombat(), 300);
}
else
{
sleepWhile(() -> Dragon.interact("Attack"), 300);
}
}
}
}
public void getLoot()
{
for(int y = 0; y < 2; y++)
{
hopifnotalone();
for(GroundItem i : getGroundItems().all()) {
for(int x = 0; x < loot.length; x++) {
if(i.getName().equalsIgnoreCase(loot[x]) && i.distance(SafeSpot.getCenter()) < 10) {
looting = true;
i.interact("Take");
sleep(300);
}
}
}
looting = false;
}
}
public Boolean getCast()
{
if(this.getSkills().getRealLevel(Skill.MAGIC)> 50)
{
rune = "Chaos rune";
return true;
}
else
{
rune = "Mind rune";
return false;
}
}
public Boolean getmystic()
{
if(this.getSkills().getRealLevel(Skill.MAGIC) > 40 && this.getSkills().getRealLevel(Skill.DEFENCE) > 20)
{
log("Bot is able to use mystic");
return true;
}
else
{
log("Bot is not able to use mystic");
return false;
}
}
//END GET METHODS
//BEGIN HOPPING STUFF
private void hopifnotalone()
{
for(Player x : getPlayers().all()) {
if(!wlist.contains(x.getName())) {
shouldHop = true;
}
}
if(getLocalPlayer().isHealthBarVisible())
{
//this way it won't log out when its bad to try logout
}
else
{
Player otherPlayer = (Player)this.getPlayers().closest(p -> !p.equals((Object)this.getLocalPlayer()) && p != null && Math.abs(p.getLevel() - this.getLocalPlayer().getLevel()) <= (this.getCombat().getWildernessLevel() + 1));
if (otherPlayer != null && otherPlayer.distance(getLocalPlayer()) < 25) {
log((String)"hopping");
this.hopworlds();
hopped++;
shouldHop = false; // this should only hop if a player thats not in the whitelist appears
}
}
}
private void hopworlds()
{
if (this.getWorldHopper().quickHop(this.p2pworld())) {
sleep((int)Calculations.random((int)100, (int)300));
sleepUntil(() -> this.getLocalPlayer().exists() && this.getClient().isLoggedIn(), (long)Calculations.random((int)300, (int)500));
}
}
private int p2pworld()
{
return this.getWorlds().getRandomWorld(w -> w.isMembers() && !w.isDeadmanMode() && !w.isPVP() && w.getMinimumLevel() < 500 && !w.isHighRisk() && w.getID() != this.getClient().getCurrentWorld()).getID();
}
//END HOPPING STUFF
//BEGIN WALKING
public void WalkToDrag()
{
//new walking method still have to find the coordinates of the Area's
}
public void WalkToBank()
{
}
//END WALKING
//BEGIN STATES
public enum State
{
BANK, WALKTODRAG, WALKTOBANK, DIED, KILLING, LOOTING, WAITING
}
public State getState()
{
hopifnotalone();
if(died.contains(getLocalPlayer()))
{
dead = true;
}
if(Bank.contains(getLocalPlayer()))
{
log("State bank");
return State.BANK;
}
else if(dead == true)
{
return State.DIED;
}
else if(full == true)
{
return State.WALKTOBANK;
}
else if(SafeSpot.contains(getLocalPlayer()))
{
log("is in the safespot area and will start killing");
return State.KILLING;
}
else
{
log("State WAITING");
return State.WALKTODRAG;
}
}
//END STATES
@Override
public int onLoop()
{
//checks incase it leveld up
if(getDialogues().inDialogue()) {
getDialogues().continueDialogue();
}
//checks if inventory == full or doesn't have runes left
if(getInventory().isFull() || !getInventory().contains(rune)) {
full = true;
} else if(Bank.contains(getLocalPlayer())) {
full = false;
}
hopifnotalone();
if (!this.getWalking().isRunEnabled() && this.getWalking().getRunEnergy() > 5) {
getWalking().toggleRun();
}
if (this.getCombat().getHealthPercent() < 75 && this.getClient().isLoggedIn() && this.getInventory().contains("Lobster")) {
this.getInventory().interact("Lobster", "Eat");
}
antiban();
switch(getState())
{
case BANK:
dead = false;
banking();
break;
case WALKTODRAG:
WalkToDrag();
break;
case KILLING:
if(getDialogues().inDialogue())
{
getDialogues().chooseOption(1);
}
getLoot();
getDragon();
break;
case LOOTING:
break;
case DIED:
onDeath();
break;
case WALKTOBANK:
WalkToBank();
break;
default:
break;
}
return 100;
}
private void antiban()
{
int random = Calculations.random((int)1, (int)5000);
if (random <= 2) {
if (!this.getTabs().isOpen(Tab.STATS)) {
this.getTabs().open(Tab.STATS);
this.getSkills().hoverSkill(Skill.MAGIC);
sleep((int)Calculations.random((int)1000, (int)2000));
this.getTabs().open(Tab.INVENTORY);
}
} else if (random <= 10) {
if (!this.getTabs().isOpen(Tab.INVENTORY)) {
this.getTabs().open(Tab.INVENTORY);
}
} else if (random <= 15) {
this.getCamera().rotateToTile(this.SafeSpot.getRandomTile());
} else if (random <= 20) {
this.getCamera().rotateToEntity((Entity)this.getLocalPlayer());
} else if (random <= 88 && this.getMouse().isMouseInScreen() && this.getMouse().moveMouseOutsideScreen()) {
sleep((int)Calculations.random((int)1500, (int)3000));
}
}
public void onPaint(Graphics g)
{
g.setColor(new Color(0, 200, 0, 150));
g.drawString("Ratz Lava ting: ", 15, 60);
g.drawString("Runtime: " + this.t.formatTime(), 15, 80);
g.drawString("hopped:" + hopped + " Hopped/hr:" + String.valueOf(t.getHourlyRate(hopped)), 15, 100);
}
}