import impsoft.bots.ColorBot; import impsoft.scripting.ibot.builtin.ocr.*; import impsoft.scripting.ibot.builtin.tabs.*; import impsoft.scripting.ibot.clusters.*; import impsoft.scripting.ibot.interfaces.*; import impsoft.scripting.ibot.gameinterfs.*; import impsoft.scripting.ibot.itemrec.*; import impsoft.scripting.ibot.objects.*; import impsoft.scripting.ibot.structs.*; import impsoft.scripting.types.*; import impsoft.utils.general.Timer; import impsoft.utils.ibot.*; import impsoft.values.constant.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.event.*; import javax.swing.plaf.*; import javax.swing.border.*; import impsoft.values.variable.SettingsManager; import java.util.*; import impsoft.bots.reflection.*; import impsoft.bots.reflection.internal.*; import impsoft.utils.general.TextFormat; import impsoft.bots.input.MouseCommand; import impsoft.scripting.ibot.objects.AryanPath; import bergCoder.*; public class BergsDEA extends ColorScript implements ChatListener,AutoPaint,CombatHandler { BergUtils util = new BergUtils(this); /****** Identification *******/ public static String name = "Berg's Drug Enforcement Agency"; public static double version = 1.4; public static String author = "Berg"; public static String description = "Kills Chaos Druids and takes their weed in their tower 'hippie compound' outside Ardougne"; public static String commands[] = {"bury bones" , "ignore bones", "power", "blood chest"}; private Timer timeran = new Timer(0); public int loot = 0; public int kills = 0; float thiefXP = 0; boolean ranged = false; boolean burybones = true; boolean power = true; boolean bloodChest = false; String rangedPickup = null; boolean agilityShortcut = false; int agilityLevel = 0; int thievingLevel = 0; int attackLevel = 0; int defenseLevel = 0; int strengthLevel = 0; int rangedLevel = 0; /****** Reflection IDs *******/ String[] hippieName = {"Chaos druid"}; int[] doorID = {2554}; AryanTile doorTile = new AryanTile(2565,3356); Object3D door3D = new Object3D(-64,-50,-64,64,0,175, false); // east edge int[] ladderUpID = {32015}; Object3D ladderUp3D = new Object3D(-55,55,-7,7,0,160, false); // north/south facing int[] ladderDownID = {1749}; Object3D ladderDown3D = new Object3D(-55,55,-7,7,0,75, false); // north/south facing int[] ladderDownEscapeID = {1759}; // Ardougne west bank booth int[] bankIDs = {34752}; //2571 is no respawn int bloodChestID = 2569; Timer bloodChestTimer = new Timer(0); AryanTile chestTile = new AryanTile(2586,9733); AryanTile teleportTile = new AryanTile(2584,3337); int[] teleportDoorID = {34811}; AryanTile teleportDoorTile = new AryanTile(2584,3339); Object3D teleportDoor3D = new Object3D(64,64,-64,-50,-0,175, false); // south edge /* 2586,9733 2569 Search for traps Chest teleported to 2584,3337 34811 Open Door South face */ /****** Tiles, Zones and Paths *****/ AryanTile logBalanceLeft = new AryanTile(2599,3336); AryanTile logBalanceRight = new AryanTile(2601,3336); // Tiles AryanTile bankTile = new AryanTile(2616,3334); AryanTile safeTile = new AryanTile(2605,3367); AryanTile leftSideLogTile = new AryanTile(2597,3336); AryanTile rightSideLogTile = new AryanTile(2604,3336); AryanTile outsideTowerTile = new AryanTile(2567,3356); AryanTile floorDown = new AryanTile(2562,9755); AryanTile floorUp = new AryanTile(102560,103357); AryanTileZone towerZone = new AryanTileZone(new AryanTile(2564,3358), new AryanTile(2560,3354)); AryanTileZone bankZone = new AryanTileZone(new AryanTile(2621,3335), new AryanTile(2612,3332)); AryanTileZone teleportRoomZone = new AryanTileZone(new AryanTile(2583,3338), new AryanTile(2585,3335)); AryanPath longPath = new AryanPath(new AryanTile[] { bankTile, new AryanTile(2613,3341), new AryanTile(2612,3358), new AryanTile(2605,3367), new AryanTile(2583,3370), new AryanTile(2583,3351), new AryanTile(2567,3356), outsideTowerTile, }, this); AryanPath agilityPath1 = new AryanPath(new AryanTile[] { bankTile, new AryanTile(2612,3340), new AryanTile(2608,3332), rightSideLogTile, }, this); AryanPath agilityPath2 = new AryanPath(new AryanTile[] { leftSideLogTile, new AryanTile(2581,3345), outsideTowerTile, }, this); // bot state public static final int GOTOHIPPIES = 1; public static final int KILLHIPPIES = 2; public static final int GOTOBANK = 3; public static final int BANK = 4; public static final int RUNFROMCOMBAT = 5; public static final int DEATHWALK = 6; public static final int CLIMBUP = 7; public static final int CLIMBDOWN = 8; public static final int BLOODCHEST = 9; public static final int TOWERESCAPE = 10; public int botState = GOTOHIPPIES; LootTable lootTable = new LootTable(); int lootDistance = 4; // distance in which we will go to pickup // loot items, used to know what to pickup and how much it is worth // sorted in order of stack // used so we can pick up our ammo when ranging public HashMap ammoHash = new HashMap(); public LootItem[] ammo = { new LootItem("Bronze bolts", 877, 0), new LootItem("Iron bolts", 9140, 0), new LootItem("Steel bolts", 9141, 0), new LootItem("Mithril bolts", 9142, 80), new LootItem("Adamantite bolts", 9143, 0), new LootItem("Runite bolts", 9144, 0), new LootItem("Kebbit bolts", 10158, 0), new LootItem("Long kebbit bolts", 10159, 0), new LootItem("Bone bolts", 8882, 0), new LootItem("Bronze arrow", 882, 0), new LootItem("Iron arrow", 884, 0), new LootItem("Steel arrow", 886, 0), new LootItem("Mithril arrow", 888, 0), new LootItem("Adamantite arrow", 890, 0), new LootItem("Runite arrow", 892, 0), new LootItem("Bronze dart", 806, 0), new LootItem("Iron dart", 807, 0), new LootItem("Steel dart", 808, 0), new LootItem("Mithril dart", 809, 0), new LootItem("Adamantite dart", 810, 0), new LootItem("Runite dart", 811, 0), new LootItem("Bronze knife", 864, 0), new LootItem("Iron knife", 863, 0), new LootItem("Black knife", 869, 0), new LootItem("Steel knife", 865, 0), new LootItem("Mithril knife", 866, 0), new LootItem("Adamantite knife", 867, 0), new LootItem("Runite knife", 868, 0), new LootItem("Broad-tipped bolt", 13281, 0), new LootItem("Broad arrow", 4150, 0) }; public LootItem[] runes = { new LootItem("Law rune", 563, 309), new LootItem("Nature rune", 561, 232), new LootItem("Air rune", 556, 13), /*, new LootItem("Earth rune", 557, 11) */ new LootItem("Blood rune", 565, 275) }; public LootItem[] gems = { new LootItem("Uncut sapphire", 1623, 584), new LootItem("Uncut emerald", 1621, 943), new LootItem("Uncut ruby", 1619, 1805), new LootItem("Uncut diamond", 1617, 3913) }; public LootItem[] misc = { new LootItem("Rune javelin", 830, 312), new LootItem("Mithril bolts", 9142, 73), new LootItem("Snape grass", 231, 321), new LootItem("Shield left half", 2366, 65900), new LootItem("Loop half of a key", 987, 7143), new LootItem("Tooth half of a key", 985, 48600), new LootItem("Dragon spear", 1249, 37450), new LootItem("Rune spear", 1247, 12220) }; public LootItem[] herbs = { new LootItem("Grimy avantoe", 211, 1899),new LootItem("Grimy cadantine", 215, 1027), new LootItem("Grimy dwarf weed", 217, 1908), new LootItem("Grimy guam", 199, 540), new LootItem("Grimy harralander", 205, 986), new LootItem("Grimy irit", 209, 1714), new LootItem("Grimy kwuarm", 213, 4156), new LootItem("Grimy lantadyme", 2485, 1180), new LootItem("Grimy ranarr", 207, 6424), new LootItem("Grimy tarromin", 203, 447), new LootItem("Grimy toadflax", 3049, 2295), new LootItem("Grimy torstol", 219, 1632), /* new LootItem("Grimy marrentill", 201, 175), */ new LootItem("Clean guam", 249, 514) }; LootItem bonesLoot = new LootItem("Bones", 526, 87); public BergsDEA(ColorBot b, String command, String args[]) { super(b); // ranged ammo reference table for(LootItem item : ammo) { ammoHash.put(item.name,item); } if (command.contains("bury")) { burybones = true; } else burybones = false; if (command.contains("power")) { power = true; } else if (command.contains("blood chest")) { power = true; bloodChest = true; } else power = false; } public void script() throws InterruptedException { try { stopRandom("PublicChatOff"); while (!theMiddleMan.isLoggedIn()) sleep(500); checkInventory(); checkStats(); setLoot(); util.setRetaliate(true); util.clickTileXOffset = 0; util.clickTileYOffset = 0; checkState(); timeran = new Timer(0); // reset for accurate lap time while (true) { util.setFastRun(true); util.mouseSpeedSwitcherAntiban(); switch (botState) { case GOTOHIPPIES: goToHippies(); break; case KILLHIPPIES: killHippies(); break; case GOTOBANK: goToBank(); break; case BANK: bank(); break; case RUNFROMCOMBAT: playerInCombat(); break; case CLIMBUP: climbUp(); break; case BLOODCHEST: bloodChest(); break; case TOWERESCAPE: towerEscape(); break; case CLIMBDOWN: climbDown(); break; } sleep(250,500); } } catch(InterruptedException e) { log("Interrupted Exception while " + util.status + " " + e.getMessage()); log("Results: hippies killed: " + kills); log("Results: loot collected: $" + loot); screenCaptureWithDebugInfo(); throw e; // we will let it do its thing } } public void checkState() throws InterruptedException { AryanTile here = getLocation(); if (theTabs.Inventory.isFull()) { botState = GOTOBANK; } else if (!theTabs.Inventory.isFull() && towerZone.isInZone(getLocation())) { botState = KILLHIPPIES; } else if (floorUp.distanceTo(getLocation()) < 10) { log("misclick on the stairwell up"); botState = CLIMBDOWN; } else if (floorDown.distanceTo(getLocation()) < 10) { log("misclick on the stairwell down"); botState = CLIMBUP; } } public void checkStats() throws InterruptedException { util.setTab("Statistics"); sleep(1000); agilityLevel = theTabs.Statistics.getStatBottom(theTabs.Statistics.STAT_AGILITY); log("Your agility level is: " + agilityLevel); if (agilityLevel >= 33) { //log("We will use the agility shortcut."); //agilityShortcut = true; } thievingLevel = theTabs.Statistics.getStatBottom(theTabs.Statistics.STAT_THIEVING); log("Your thieving level is: " + thievingLevel); if (thievingLevel < 46) { log("You need 46 thieving to enter the tower. Quiting"); shutDown(); } if (thievingLevel < 59 && bloodChest) { log("You need 59 thieving loot the blood chest. Quiting"); shutDown(); } } public void checkInventory() throws InterruptedException { util.setTab("Equipment"); sleep(1000); String weaponName = theTabs.Equipment.getWeapon(); String arrowsName = theTabs.Equipment.getArrows(); if (weaponName != null && weaponName.contains("bow") || weaponName.equals("seercull")) { ranged = true; log("Using a ranged weapon " + weaponName); if (arrowsName != null) { rangedPickup = arrowsName; log("Arrows/Bolts will be picked up: " + rangedPickup); } } else if (weaponName != null && weaponName.contains("knife") || weaponName.contains("dart") || weaponName.contains("chompa")) { ranged = true; log("Using thrown weapon " + weaponName); rangedPickup = weaponName; log("Thrown items will be picked up: " + rangedPickup); } else if (weaponName != null) { log("Using weapon " + weaponName); } } /** Sets up our loot hash for knowing what to pickup, how much money it's worth and the lootByID should be defined * in the order it stacks. */ public void setLoot() throws InterruptedException { // pickup arrow/ammo on top of stack if (ranged) { lootDistance = 6; LootItem rangedAmmo = ammoHash.get(rangedPickup); lootTable.add(rangedAmmo); } lootTable.add(misc); lootTable.add(gems); lootTable.add(runes); if(burybones) lootTable.add(bonesLoot); lootTable.add(herbs); //adjust the loot table for longer runs, remove common cheap items if (power) { removeLoot("Uncut sapphire",lootTable); removeLoot("Snape grass",lootTable); removeLoot("Clean guam",lootTable); removeLoot("Grimy guam",lootTable); removeLoot("Grimy tarromin",lootTable); } } // not finished public String[] trashNames = {"Beer", "Kebab", "Spinach roll", "Uncut sapphire", "Bones", "Strength"}; public void dropTrash() throws InterruptedException { } // this needs to be added to LootTable public void removeLoot(LootItem item, LootTable lootTable) { lootTable.lootByName.remove(item.name.toLowerCase()); lootTable.lootByID.remove(item.id); } public void removeLoot(String itemName, LootTable lootTable) { LootItem item = lootTable.get(itemName); if (item != null) { lootTable.lootByName.remove(item.name.toLowerCase()); lootTable.lootByID.remove(item.id); } } public void goToBank() throws InterruptedException { util.setStatus("Going to the bank"); if(util.isBankInterfaceUp()) { botState = BANK; } else if(towerZone.isInZone(getLocation())) { util.sleepUntilNotMoving(); util.clickBoundaryObject(doorID, doorTile, "Door", "Open", door3D); util.sleepUntilNotMoving(); } else if(bankZone.isInZone(getLocation())) { // on bank click retries don't double count loot if (ranged) { log("re-equiping ammo " + rangedPickup); theTabs.Inventory.doAction(rangedPickup, "Wield",1,true); } if (burybones) util.buryAllBones(); lootTable.add(new LootItem("Coins", 995, 1)); // we add/remove coins because we want to count it from the Bloodchest, but not pick it up loot += util.countLootValue(lootTable); removeLoot("Coins", lootTable); util.clickInteractiveObject(bankIDs, null, "Bank booth","Use-quickly",null); util.waitForBankInterface(); } else if (longPath.partialPath[0].distanceTo(getLocation()) > 50 && longPath.partialPath[longPath.partialPath.length-1].distanceTo(getLocation()) > 50) { theWorldMap.walkTo(longPath.partialPath[0]); } else if (agilityShortcut && getLocation().x < 2600) { agilityPath2.walkToStart(); util.sleepUntilNotMoving(); //logBalanceRGB.doTopText("Log Balance"); if(util.clickTile(logBalanceLeft,"Log balance","Walk-across",null)) { sleep(2000); util.sleepUntilNotMoving(); } } else if (agilityShortcut && getLocation().x >= 2600) { agilityPath1.walkToStart(); } else { longPath.walkToStart(); } } public void goToHippies() throws InterruptedException { util.setStatus("Going to the Hippie Tower"); if(towerZone.isInZone(getLocation())) { thiefXP += 37.5f; botState = KILLHIPPIES; } else if(outsideTowerTile.distanceTo(getLocation()) < 4) { util.sleepUntilNotMoving(); while(!towerZone.isInZone(getLocation())) { util.clickBoundaryObject(doorID, doorTile, "Door", "Pick-lock", door3D); util.sleepUntilNotMoving(); } } else if (longPath.partialPath[0].distanceTo(getLocation()) > 50 && longPath.partialPath[longPath.partialPath.length-1].distanceTo(getLocation()) > 50) { theWorldMap.walkTo(longPath.partialPath[longPath.partialPath.length-1]); } else if (agilityShortcut && getLocation().x > 2600) { agilityPath1.walkToEnd(); util.sleepUntilNotMoving(); //logBalanceRGB.doTopText("Log Balance"); if(util.clickTile(logBalanceRight,"Log balance","Walk-across",null)) { sleep(2000); util.sleepUntilNotMoving(); } } else if (agilityShortcut && getLocation().x <= 2600) { agilityPath2.walkToEnd(); } else { longPath.walkToEnd(); } } public void climbDown() throws InterruptedException { util.setStatus("Climbing down from misclick"); util.clickInteractiveObject(ladderDownID, null, "Ladder", "Climb-down",ladderDown3D); sleep(3000); botState = KILLHIPPIES; } public void climbUp() throws InterruptedException { util.setStatus("Climbing up from misclick"); if (getLocation().distanceTo(floorDown) > 3) util.walk(floorDown); util.clickInteractiveObject(ladderUpID, null, "Ladder", "Climb-up",ladderUp3D); sleep(3000); botState = KILLHIPPIES; } public void bank() throws InterruptedException { util.setStatus("Banking our stash"); theBank.doDepositAll(false); sleep(1000); // retry if (theTabs.Inventory.getCount() > 1) { theBank.doDepositAll(false); } // 33% chance of closing the bank instead of running off if (random(0,3) == 0) util.closeBank(); botState = GOTOHIPPIES; } public void killHippies() throws InterruptedException { util.setStatus("Killing hippies"); while(theMiniMapIndicators.getHealthPoints() > 2 && !theTabs.Inventory.isFull()) { // handle misclicks that would take us out of the floor 1 room if (floorUp.distanceTo(getLocation()) < 10) { log("misclick on the stairwell up"); botState = CLIMBDOWN; return; } else if (floorDown.distanceTo(getLocation()) < 10) { log("misclick on the stairwell down"); botState = CLIMBUP; return; } else if (!towerZone.isInZone(getLocation())) { log("misclick on the door out"); botState = GOTOHIPPIES; return; } util.setFastRun(true); if (bloodChestTimer.isUp() && bloodChest) { sleep(2000); util.collectLoot(lootTable, lootDistance, burybones, false); botState = BLOODCHEST; return; } if (botState == TOWERESCAPE) return; NPC hippie = util.getNPCByName(hippieName, null); if(hippie == null) { log("waiting for respawn"); if (!util.collectLoot(lootTable, lootDistance, burybones, false)) { if (ranged) util.checkLevelAntiban(StatisticsTab.STAT_RANGED , 3); else { util.checkLevelAntiban(StatisticsTab.STAT_ATTACK , 1); util.checkLevelAntiban(StatisticsTab.STAT_STRENGTH , 1); util.checkLevelAntiban(StatisticsTab.STAT_DEFENSE, 1); } util.checkLevelAntiban(StatisticsTab.STAT_HITPOINTS , 1); sleep(1000); } return; // in case state changes } else if (util.doNPC(hippie, "Attack")) { int swing = -1; if ((swing = util.waitForAnimation(1000)) != -1) { //sleep(2000); } else continue; // misclick no attack swing util.waitForKill(hippie, 2); kills++; util.collectLoot(lootTable, lootDistance, burybones, false); } sleep(100); } sleep(100); botState = GOTOBANK; } int fail = 0; public void bloodChest() throws InterruptedException { util.setStatus("Thieving the Blood Chest"); //util.setRetaliate(false); if (towerZone.isInZone(getLocation())) { fail = 0; util.clickInteractiveObject(ladderDownEscapeID, null, "Ladder", "Climb-down",ladderDown3D); util.sleepUntilNotMoving(); sleep(1000); } if (floorDown.distanceTo(getLocation()) < 50) { if (getLocation().distanceTo(chestTile) > 3) util.walk(chestTile); util.sleepUntilNotMoving(); if (!util.clickInteractiveObject(bloodChestID,"Chest", "Search for traps")) fail++; if (fail >= 3) { botState = CLIMBUP; bloodChestTimer = new Timer(random(240000,300000)); // 4-5 minutes return; } Timer t = new Timer(6000); while(t.isNotUp() && !teleportRoomZone.isInZone(getLocation())) sleep(250); } if(teleportRoomZone.isInZone(getLocation())) { if (!util.clickBoundaryObject(teleportDoorID, teleportDoorTile, "Door", "Open", teleportDoor3D)) return; thiefXP += 250; //util.setRetaliate(true); botState = GOTOHIPPIES; bloodChestTimer = new Timer(random(240000,300000)); // 4-5 minutes } // failsafe if (!teleportRoomZone.isInZone(getLocation()) && floorDown.distanceTo(getLocation()) > 50 && !towerZone.isInZone(getLocation())) { thiefXP += 250; botState = GOTOHIPPIES; bloodChestTimer = new Timer(random(240000,300000)); // 4-5 minutes } } /** Override the generic run from combat so we can get out of the tower by climbing down the stairs */ public boolean towerEscape() throws InterruptedException { if (towerZone.isInZone(getLocation())) { util.setRetaliate(false); util.clickInteractiveObject(ladderDownEscapeID, null, "Ladder", "Climb-down",ladderDown3D); sleep(8000,10000); log("Taking pic in the basement"); screenCaptureWithDebugInfo(); util.clickInteractiveObject(ladderUpID, null, "Ladder", "Climb-up",ladderUp3D); sleep(3000); util.setRetaliate(true); botState = KILLHIPPIES; return true; } else return false; // do the generic run if we aren't in the tower } public boolean PlayerInCombatOverride() throws InterruptedException { log("COMBAT RANDOM OVERRIDE WORKS!!!"); screenCaptureWithDebugInfo(); if (towerZone.isInZone(getLocation())) { botState = TOWERESCAPE; return true; } else return false; // do the generic run if we aren't in the tower } public void playerInCombat() throws InterruptedException { if (towerZone.isInZone(getLocation())) { util.clickInteractiveObject(ladderDownEscapeID, null, "Ladder", "Climb-down",ladderDown3D); log("Death inevitable. Saving your gear and killing the bot."); util.logOff(); } } public void paint(final Graphics g) { final StringBuilder zz = new StringBuilder(); final long runtime = timeran.timePassed(); final long TotalSec = runtime / 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 % 60; if (hour < 10) zz.append("0"); zz.append(hour); zz.append(" : "); if (minute < 10) zz.append("0"); zz.append(minute); zz.append(" : "); if (second < 10) zz.append("0"); zz.append(second); g.setColor(new Color(0, 0, 0, 120)); g.fillRoundRect(3,30,226, 24, 10, 10);//title bar background g.fillRoundRect(318,308,201, 35, 10, 10);//stats backgrnd g.setColor(new Color(57, 97, 176, 120)); g.drawRoundRect(5,32,220, 18, 10, 10);//title bar draw g.drawRoundRect(320,310,195, 30, 10, 10);//stats draw g.fillRoundRect(5,32,220, 18, 10, 10);//title bar fill g.fillRoundRect(320,310,195, 30, 10, 10);//stats fill g.setColor(Color.WHITE); g.drawString("Berg's Drug Enforcement Agency v" + version,15, 45); g.drawString("Timer: " + zz, 324, 320); g.drawString("Doing: "+ util.status, 324, 340); g.drawString("hippies killed: " + kills,340,10); if (kills > 0) { long tempTime = timeran.timePassed() / 1000 / 60; float avgTime = (float)tempTime / kills; g.drawString("Averaging " + (int)((60/avgTime)*106.6) + " xp per hour", 340, 30); } g.drawString("Total xp: " + kills*106.6, 340, 40); if (loot > 0) { long tempTime = timeran.timePassed() / 1000 / 60; float avgTime = (float)tempTime / loot; g.drawString("Averaging $" + (60/avgTime) + " per hour", 340, 50); } g.drawString("Total loot: " + loot, 340, 60); g.drawString("Thieving xp: " + thiefXP, 340, 70); double s2 = (double) runtime / 1000; double h2 = (s2 / 60) / 60; g.drawString("AryanTile: " + getLocation() + " " + getAnimation() + " combat " + inCombat(),520,165); g.setColor(Color.RED); if (util.target != null && util.targetTimer.isNotUp()) g.drawPolygon(util.target); if (util.targetPoint != null && util.targetTimer.isNotUp()) g.drawString("X",util.targetPoint.x, util.targetPoint.y); } public void chat(String s) throws InterruptedException { log(s); // this is chat coming from you if (s.startsWith(getColorBot().getHandler().getUsername())) { log("AUTORESPONDER: " + s); } // this is likely player chat, parse it for the basic stuff and auto-respond if possible else if (s.contains(":")) { //autoResponder(s); } // sandwitch lady or death else if (s.contains("You wake up some") || s.contains("dead!")) { screenCaptureWithDebugInfo(); util.logOff(); } } }