import java.awt.Graphics; import com.rarebot.event.listeners.PaintListener; import com.rarebot.script.Script; import com.rarebot.script.ScriptManifest; import com.rarebot.script.wrappers.RSArea; import com.rarebot.script.wrappers.RSItem; import com.rarebot.script.wrappers.RSObject; import com.rarebot.script.wrappers.RSTile; @ScriptManifest(authors = "Nubsrevenge", keywords = "Runecrafting", name = "AstralCrafter", version = 1.0, description = "Astral Runecrafter.") public class AstralCrafter extends Script implements PaintListener{ int astralID = 9075,cosmicID = 564; RSTile altarTile = new RSTile(2156, 3863); RSTile bankTile = new RSTile(2099, 3919); RSTile teleTile = new RSTile(2112, 3915); RSArea altarArea = new RSArea(new RSTile(2152, 3869), new RSTile(2162, 3859)); int smallPouchID = 5509, mediumPouchID = 5510, largePouchID = 5512, giantPouchID = 5514, essenceID = 7936; boolean useNPCContact = false; int[] pouchesDegraded = {5511, 5513, 5515}, items = {5509, 5510, 5511, 5512, 5513, 5514, 5515, 563}; int[] mouseX = {577, 622, 663, 705, 577, 622, 663, 705, 577, 622, 663, 705, 577, 622, 663, 705, 577, 622, 663, 705, 577, 622, 663, 705, 577, 622, 663, 705}, mouseY = {227, 227, 227, 227, 265, 265, 265, 265, 302, 302, 302, 302, 340, 340, 340, 340, 375, 375, 375, 375, 410, 410, 410, 410, 447, 447, 447, 447}; NubsUtils n = new NubsUtils(this, inventory, objects, npcs, bank, calc); public boolean onStart(){ mouse.setSpeed(6); return true; } public int loop() { if(interfaces.get(750).getComponent(0).getTextureID() == 1210){//if not running if(Integer.parseInt(interfaces.get(750).getComponent(6).getText()) > 25){ mouse.click(interfaces.get(750).getComponent(0).getPoint(), true); } } else if(inventory.contains(astralID) || !inventory.contains(essenceID)) bank(); else if(inventory.isFull()) walkToAltar(); else if(altarArea.contains(getMyPlayer().getLocation())) craft(); return random(10,20); } public void bank(){ if(calc.distanceTo(bankTile) > 20) teleport(); //5514 giant, 5512 large, 5510 med, 7936 ess, 563 law while(!bank.isOpen()) { bank.open(); mouse.click(false); menu.doAction("Bank"); sleep(500); } if(getMyPlayer().getHPPercent() < 30){ log.severe("dying"); stopScript(); } if(inventory.getCount(pouchesDegraded) > 0){ bankWithdraw(astralID, 1, 1, 5000, "Out of astral runes! Stopping script..."); bankWithdraw(cosmicID, 1, 1, 5000, "Out of cosmic runes! Stopping script..."); bank.close(); repairPouches(); return; } bank.depositAllExcept(items); bankWithdraw(essenceID, 12345, 0, 3000, "Out of pure essence! Stopping script..."); sleep(500); fillAndEmptyPouch(giantPouchID, true); bankWithdraw(essenceID, 12345, 0, 3000, "Out of pure essence! Stopping script..."); sleep(500); fillAndEmptyPouch(largePouchID, true); fillAndEmptyPouch(mediumPouchID, true); bankWithdraw(essenceID, 12345, 0, 3000, "Out of pure essence! Stopping script..."); //sleep(500); /*try{ inventory.getItem(5512).interact("fill"); sleep(500); inventory.getItem(5510).interact("fill"); sleep(500); bank.withdraw(7936, 0); sleep(500); inventory.getItem(5509).interact("fill"); sleep(500);}catch(Exception e){} bank.withdraw(essenceID, 0);*/ sleep(500); } public boolean bankWithdraw(int itemID, int itemCount, int withdrawCount, int timeout, String logoutLog) { while (inventory.getCount(true, itemID) < itemCount && bank.isOpen() && !inventory.isFull()) { if (bank.getCount(itemID) > 0) { bank.withdraw(itemID, withdrawCount); long t = System.currentTimeMillis(); while (((inventory.getCount(true, itemID) < itemCount && itemCount < 12345) || (itemCount == 12345 && !inventory.isFull())) && System.currentTimeMillis() - t < timeout && !inventory.isFull()) { sleep(random(90, 110)); } } else { log(logoutLog); stopScript(); break; } } if (inventory.getCount(itemID) < itemCount) { return false; } return true; } public void walkToAltar(){ while(calc.distanceTo(altarTile) > 4){ try{ walking.newTilePath(web.generateTilePath(getMyPlayer().getLocation(), altarTile)).traverse(); }catch(Exception e){} sleep(random(200, 400)); } } public int getIndex(int itemID) { RSItem[] items = inventory.getItems(); for (int i = 0; i <= 27; i++) { if (i + 1 <= items.length) { RSItem item = items[i]; if (item != null) { if (item.getID() == itemID) { return i; } } } } return -1; } private void fillAndEmptyPouch(int pID, boolean fill) { if (inventory.contains(pID) && fill) { int pouchIndex = getIndex(pID); int generatedX = mouseX[pouchIndex] + random(0, 14) - 7; int generatedY = mouseY[pouchIndex] + random(0, 14) - 7; int generatedX2 = generatedX - 25 + random(0, 50); int generatedY2 = generatedY + random(40, 50); mouse.move(generatedX, generatedY); sleep(250, 500); if (menu.contains("pouch")) { mouse.click(false); sleep(250, 500); mouse.move(generatedX2, generatedY2); sleep(250, 500); mouse.click(true); } }else{ int pouchIndex = getIndex(pID); int generatedX = mouseX[pouchIndex] + random(0, 14) - 7; int generatedY = mouseY[pouchIndex] + random(0, 14) - 7; int generatedX2 = generatedX - 25 + random(0, 50); int generatedY2 = generatedY + random(40, 50); mouse.move(generatedX, generatedY); sleep(250, 500); if (menu.contains("pouch")) { mouse.click(true); } } } public void craft(){ //17010 altar RSObject altar = objects.getNearest(17010); while (inventory.contains(essenceID)) { if (altar != null) { mouse.move(altar.getModel().getPoint()); sleep(random(100, 200)); if (menu.contains("Craft-rune")) { mouse.click(true); sleep(random(1000, 2000)); } } } fillAndEmptyPouch(mediumPouchID, false); fillAndEmptyPouch(largePouchID, false); long t = System.currentTimeMillis(); while (inventory.getCount(essenceID) < 1 && System.currentTimeMillis() - t < 5000 && !inventory.isFull()) { sleep(random(90, 110)); } while (inventory.contains(essenceID)) { if (altar != null) { mouse.move(altar.getModel().getPoint()); sleep(random(100, 200)); if (menu.contains("Craft-rune")) { mouse.click(true); sleep(random(1000, 2000)); } } } fillAndEmptyPouch(giantPouchID, false); t = System.currentTimeMillis(); while (inventory.getCount(essenceID) < 1 && System.currentTimeMillis() - t < 5000 && !inventory.isFull()) { sleep(random(90, 110)); } while (inventory.contains(essenceID)) { if (altar != null) { mouse.move(altar.getModel().getPoint()); sleep(random(100, 200)); if (menu.contains("Craft-rune")) { mouse.click(true); sleep(random(1000, 2000)); } } } } public void teleport(){ openSpells(); while(getMyPlayer().getAnimation() == -1){ mouse.click(627, 252, 10, 10, true); sleep(200); } n.waitForNoAnimation(1000); } private void openSpells() { mouse.move(random(738, 755), random(174, 196)); sleep(random(100, 200)); if (menu.contains("Magic Spellbook")) { mouse.click(true); sleep(random(100, 200)); } } public int getIndex(int[] itemID) { RSItem[] items = inventory.getItems(); for (int i = 0; i <= 27; i++) { if (i + 1 <= items.length) { RSItem item = items[i]; if (item != null) { for (int j = 0; j <= itemID.length - 1; j++) { if (item.getID() == itemID[j]) { return i; } } } } } return -1; } private void mouseToItem(int index) { mouse.move(mouseX[index] + random(0, 14) - 7, mouseY[index] + random(0, 14) - 7); } private void repairPouches() { log("Repairing pouch"); openSpells(); mouse.move(random(600, 608), random(311, 320)); sleep(random(500, 1000)); if (menu.contains("Cast Repair")) { mouse.click(true); sleep(random(500, 1000)); } mouseToItem(getIndex(pouchesDegraded)); mouse.click(true); sleep(random(5000, 7500)); return; } @Override public void onRepaint(Graphics g) { g.drawString("", 100, 100); } }