- import com.rarebot.event.events.MessageEvent;
- import com.rarebot.event.listeners.MessageListener;
- import com.rarebot.event.listeners.PaintListener;
- import com.rarebot.script.Script;
- import com.rarebot.script.ScriptManifest;
- import com.rarebot.script.methods.Players;
- import com.rarebot.script.methods.Skills;
- import com.rarebot.script.wrappers.RSArea;
- import com.rarebot.script.wrappers.RSObject;
- import com.rarebot.script.wrappers.RSPlayer;
- import com.rarebot.script.wrappers.RSTile;
- import com.rarebot.script.wrappers.RSTilePath;
- import com.rarebot.script.wrappers.RSNPC;
- import java.awt.*;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.text.DecimalFormat;
- import java.text.NumberFormat;
- @ScriptManifest(authors = { "<html><body><b>DD<html><body><b>" }, keywords = { "Shilo Gem Miner" }, name = "BombTheGem", version = 1.0, description = "<html><body><b>Bank expensive gem at Shilo<html><body><b>")
- public class BombTheGem extends Script implements PaintListener, MouseListener, MessageListener{
- //Item
- private int[] pickaxeID = {1265, 1267, 1269, 1272, 1271, 1275, 15259};
- private int[] keep = {1621, 1623, 1617, 1619,1265, 1267, 1269, 1272, 1271, 1275, 15259};
- private int[] drop = {1625, 1627, 1629};
- int sapphireID = 1623;
- int emeraldID = 1621;
- int rubyID = 1619;
- int diamondID = 1617;
- int sapphirePrice;
- int emeraldPrice;
- int rubyPrice;
- int diamondPrice;
- private int profit;
- public final NumberFormat formatter = new DecimalFormat("###,###,###");
- private int gemsMined = 0;
- private int sapphire = 0;
- private int emerald = 0;
- private int ruby = 0;
- private int diamond = 0;
- public long runTime;
- //Objects
- private int bankerID = 499;
- private int[] rockID = {11195, 11364, 11194};
- //Walking
- RSTile[] toMine = {new RSTile(2843,2962), new RSTile(2834,2968),
- new RSTile(2828,2980), new RSTile(2824,2990),
- new RSTile(2822,3000)};
- RSTile[] toBank = {new RSTile(2822,3000),new RSTile(2824,2990), new RSTile(2828,2980),
- new RSTile(2834,2968), new RSTile(2843,2962), new RSTile(2852,2955)};
- public int w;
- public int k;
- //Area
- RSArea mineArea = new RSArea(new RSTile(2819,2997), new RSTile(2827,3005));
- RSArea bankArea = new RSArea(new RSTile(2849,2951), new RSTile(2855,2957));
- public int shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol = 0;//0= shouldn't be walking, 1= to bank, 2 = to mine
- //Paint
- public long startTime;
- final int cuttingSkill = Skills.MINING;
- int currentLevel;
- int startingLevel;
- int startingXp;
- private String status = "";
- long timeRan;
- private int showTab = 1; //1 = main, 2 = hide//
- Rectangle main = new Rectangle(422, 458, 51, 19);
- Rectangle hide = new Rectangle(468, 460, 51, 19);
- //METHODS
- //Walking
- public boolean onStart(){
- startingXp = skills.getCurrentExp(Skills.MINING);
- startTime = System.currentTimeMillis();
- sapphirePrice = grandExchange.lookup(sapphireID).getGuidePrice();
- emeraldPrice = grandExchange.lookup(emeraldID).getGuidePrice();
- rubyPrice = grandExchange.lookup(rubyID).getGuidePrice();
- diamondPrice = grandExchange.lookup(diamondID).getGuidePrice();
- startingLevel = skills.getCurrentLevel(cuttingSkill);
- return true;
- }
- public void messageReceived(MessageEvent e) {
- String msg = e.getMessage().toLowerCase();
- if (msg.contains("just mined"))
- gemsMined++;
- if (msg.contains("diamond"))
- diamond++;
- if (msg.contains("a ruby"))
- ruby++;
- if (msg.contains("a sapphire"))
- sapphire++;
- if (msg.contains("an emerald"))
- emerald++;
- }
- private boolean walkThePath(RSTile[] path){
- w = random(4,6);
- k = random(2,4);
- int b = k;
- int t = w;
- boolean D=false;
- try{
- RSTilePath pathToWalk = walking.newTilePath(path);
- RSTile next = pathToWalk.getNext();
- RSTile start = pathToWalk.getStart();
- if ((walking.getDestination() == null||calc.distanceTo(walking.getDestination()) < t ||calc.distanceBetween(next,walking.getDestination()) > b)) {
- if(!walking.walkTileMM(next)){
- if(walking.walkTileMM(start)){
- sleep(412,565);
- D=true;
- }else{
- walkToTile(walking.getClosestTileOnMap(next));
- sleep(277,562);
- }
- }else{
- sleep(299,565);
- D=true;
- }
- }
- return D;
- }catch(Exception e ){ log("Caught a Exception in pathToWalk. Saved the script from stopping!"); sleep(554,789); }
- return D;
- }
- private boolean walkToTile(RSTile tile){
- int q = k;
- int i = w;
- boolean D = false;
- try{
- if ((walking.getDestination() == null||(calc.distanceTo(walking.getDestination()) < q &&calc.distanceBetween(tile,walking.getDestination()) > i))) {
- if(calc.tileOnScreen(tile)){
- if(walking.walkTileOnScreen(tile))
- D = true;
- }else if(calc.tileOnMap(tile)){
- if(walking.walkTileMM(tile))
- D = true;
- }else{
- if(walkToTile(walking.getClosestTileOnMap(tile)))
- D = true;
- }
- sleep(389);
- }
- return D;
- }catch(Exception e){ log("Caught an Exception in walkToTile. Saved the scrpt from stopping!"); sleep(554,789); }
- return D;
- }
- private void toMine(){
- walkThePath(toMine);
- shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol = 2;
- while (players.getMyPlayer().isMoving()) {
- status = "Walking to Mine";
- sleep(500, 1000);
- }
- }
- private void toBank() {
- walkThePath(toBank);
- shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol = 1;
- while (players.getMyPlayer().isMoving()) {
- status = "Walking to Bank";
- sleep(500, 1000);
- }
- }
- ////////////////////////MINING\\\\\\\\\\\\\\\\\\\\\\\
- private void mining(){
- RSObject rock = objects.getNearest(rockID);
- sleep(random(750, 2000));
- if(players.getMyPlayer().getAnimation() == -1){
- if (rock != null) {
- sleep(100, 300);
- rock.interact("Mine");
- status = "Mining";
- }else{
- dropping();
- }
- }else{
- sleep(1000,1500);
- }
- }
- ////////////////////Banking\\\\\\\\\\\\\\\\\\
- private void bankOpen(){
- RSNPC banker = npcs.getNearest(bankerID);
- banker.interact("Bank Banker");
- status = "Depositing Gems";
- sleep(1600,2300);
- }
- private void depositGem() {
- if (bank.isOpen()) {
- sleep(600);
- bank.depositAllExcept(pickaxeID);
- sleep(random(150, 200));
- }
- }
- //////////////////Dropping\\\\\\\\\\\\\\
- private void dropping(){
- status = "Dropping useless Gems";
- inventory.dropAllExcept(keep);
- sleep(250,500);
- }
- ///////////////////AntiBan\\\\\\\\\\\\\\\\
- @SuppressWarnings("deprecation")
- public void antiban() {
- switch (random(0, 18)) {
- case 1:
- // if the random equals 5 then
- if (random(0, 20) == 5) {
- // mouse moves a bit
- mouse.moveSlightly();
- // sleeps for 50 to 100 milliseconds
- sleep(50, 100);
- // moves mouse randomly
- mouse.moveRandomly(150, 350);
- }
- break;
- case 2:
- if (random(0, 15) == 2) {
- camera.setAngle(random(30, 70));
- sleep(400, 1200);
- }
- break;
- case 3:
- if (random(0, 25) == 6) {
- mouse.moveOffScreen();
- sleep(random(600, random(1200, 2000)));
- }
- break;
- case 4:
- if (random(0, 30) == 3) {
- game.openTab(1);
- sleep(random(240, 500));
- skills.doHover(Skills.INTERFACE_MINING);
- sleep(random(1240, 1760));
- }
- break;
- case 5:
- if (random(0, 25) == 1) {
- RSPlayer player = players.getNearest(Players.ALL_FILTER);
- if (player != null && calc.distanceTo(player) != 0) {
- mouse.move(player.getScreenLocation(), 5, 5);
- sleep(random(150, 250));
- mouse.click(false);
- sleep(random(550, 600));
- mouse.move(random(10, 450), random(10, 495));
- }
- }
- break;
- case 6:
- if (random(0, 15) == 4) {
- camera.setAngle(random(1, 359));
- }
- break;
- case 7:
- if (random(0, 20) == 2) {
- final int x = (int) mouse.getLocation().getX();
- final int y = (int) mouse.getLocation().getY();
- mouse.move(x + random(-100, 100), y + random(-50, 50));
- }
- break;
- case 8:
- if (random(0, 19) == 5) {
- mouse.moveSlightly();
- sleep(50, 150);
- mouse.moveRandomly(150, 350);
- }
- break;
- case 9:
- if (random(0, 25) == 1) {
- camera.setAngle(random(30, 70));
- sleep(400, 1200);
- }
- break;
- case 10:
- if (random(0, 30) == 6) {
- mouse.moveOffScreen();
- sleep(random(600, random(1200, 2000)));
- }
- break;
- default:
- break;
- }
- }
- ///////////////////Loop\\\\\\\\\\\\\\\\\\\
- @Override
- public int loop() {
- if(mineArea.contains(players.getMyPlayer().getLocation()) && !inventory.isFull()){
- shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol=0;
- mining();
- antiban();
- }
- if(inventory.isFull()){
- shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol=0;
- dropping();
- }
- if(!inventory.containsOneOf(drop) && inventory.isFull() || shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol==1){//wait why don't you have a endint braket?
- toBank();
- }
- if(bankArea.contains(players.getMyPlayer().getLocation()) && inventory.isFull()){
- shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol=0;
- bankOpen();
- depositGem();
- }if(!inventory.isFull() && !mineArea.contains(players.getMyPlayer().getLocation()) || shouldIBeWalkingGoingToMakeThisLongJustTOPissPeopleOffLol==2){
- toMine();
- }
- return 0;
- }
- //////////////////////Paint\\\\\\\\\\\\\\\\\\\\\\\
- //START: Code generated using Enfilade's Easel
- private final Color color1 = new Color(51, 51, 0, 184);
- private final Color color2 = new Color(255, 255, 255);
- private final Color color3 = new Color(0, 0, 0);
- int ExpH;
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 9);
- private final Font font2 = new Font("Arial", 0, 11);
- public void onRepaint(Graphics g1) {
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 100;
- int ExpGained = skills.getCurrentExp(cuttingSkill) - startingXp;
- profit = ((sapphirePrice*sapphire)+(emeraldPrice*emerald)+(rubyPrice*ruby)+(diamondPrice*diamond));
- float xpsec = 0;
- xpsec = ((float) ExpGained)/(float)(seconds + (minutes*60) + (hours*60*60));
- float xpmin = xpsec * 60;
- float xphour = xpmin * 60;
- float moneysec = 0;
- moneysec = ((float) profit)/(float)(seconds + (minutes*60) + (hours*60*60));
- float moneymin = moneysec * 60;
- float moneyhour = moneymin * 60;
- Graphics2D g = (Graphics2D)g1;
- g.setColor(color1);
- g.drawRect(hide.x, hide.y, hide.width, hide.height);
- g.drawRect(main.x, main.y, main.width, main.height);
- if(showTab == 1){
- int LvlsGained = skills.getCurrentLevel(cuttingSkill) - startingLevel;
- long currentLevel = skills.getCurrentLevel(cuttingSkill);
- g.setColor(color1);
- g.fillRoundRect(8, 345, 486, 111, 16, 16);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRoundRect(8, 345, 486, 111, 16, 16);
- g.setColor(color1);
- g.fillRoundRect(494, 456, 0, 0, 16, 16);
- g.setColor(color2);
- g.drawRoundRect(494, 456, 0, 0, 16, 16);
- g.setFont(font1);
- g.drawString("Time Running :" + hours + " H " + minutes + " M "
- + seconds + " S ", 20, 358);
- g.drawString("Sapphire Mined :"+sapphire, 273, 359);
- g.drawString("Emerald Mined :"+emerald, 272, 379);
- g.drawString("Ruby Mined :"+ruby, 281, 399);
- g.drawString("Diamond Mined :"+diamond, 269, 417);
- g.drawString("Exp Gained :"+ ExpGained, 22, 391);
- // ExpH = ((int) (ExpGained * 3600000D / (System.currentTimeMillis() - startTime)));
- g.drawString("Exp/H : " + formatter.format(xphour), 31, 411);
- g.drawString("Money Gained : " + formatter.format(profit), 16, 429);
- g.drawString("Money/H : " + formatter.format(moneyhour), 25, 446);
- g.drawString("Total mined :"+gemsMined, 282, 436);
- g.setFont(font2);
- g.setColor(color3);
- g.drawString("BombTheGem - DD", 191, 334);
- g.setColor(color2);
- g.drawString("Status :" + status, 299, 453);
- g.setFont(font1);
- g.drawString("Current Lvl :" + currentLevel + "(" + LvlsGained + ")", 20, 375);
- g.drawString("Hide | Show", 443, 471);
- Point p = mouse.getLocation();
- g.setColor(Color.white);
- g1.fillRect(p.x - 5, p.y, 12, 2);
- g1.fillRect(p.x, p.y - 5, 2, 12);
- }
- if(showTab == 2){
- g1.drawString("Show", 475,471);
- }
- }
- //END: Code generated using Enfilade's Easel
- public void mouseClicked(MouseEvent e) {
- if(main.contains(e.getPoint())){
- showTab = 2;
- }
- if (hide.contains(e.getPoint())) {
- showTab = 1;
- }
- }
- public void mouseEntered(MouseEvent e) {}
- public void mouseExited(MouseEvent e) {}
- public void mousePressed(MouseEvent e) {}
- public void mouseReleased(MouseEvent e) {
- }
- }