SHARE
TWEET

Untitled

a guest Aug 19th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.BasicStroke;
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6.  
  7. import org.rsbot.event.events.ServerMessageEvent;
  8. import org.rsbot.event.listeners.PaintListener;
  9. import org.rsbot.event.listeners.ServerMessageListener;
  10. import org.rsbot.script.Script;
  11. import org.rsbot.script.ScriptManifest;
  12. import org.rsbot.script.methods.Game;
  13. import org.rsbot.script.methods.Skills;
  14. import org.rsbot.script.wrappers.RSArea;
  15. import org.rsbot.script.wrappers.RSObject;
  16. import org.rsbot.script.wrappers.RSTile;
  17.  
  18. @ScriptManifest(authors = "BlinkBot", name = "BonesToBanana's", version = 1.3, description = "Turn all The Bones into Banana's!")
  19. public class BonesToBananas extends Script implements PaintListener,
  20.     ServerMessageListener {
  21.  
  22.   // script \\
  23.  
  24.   int waterRuneID = 555;
  25.   int earthRuneID = 557;
  26.   int natureRuneID = 561;
  27.   int BananaID = 1963;
  28.   int waterStaffID = 1383;
  29.   int earthStaffID = 1385;
  30.   int BoneID = 526;
  31.   int BankID = 11402;
  32.   int SPELL_BONES_TO_BANANAS;
  33.   private int tries;
  34.  
  35.   // Paint \\
  36.  
  37.   private int startExp;
  38.   private int exp;
  39.   private int expPerHour;
  40.   private long startTime;
  41.   private int profit;
  42.   private int profitPerHour;
  43.   private int costBone, costBanana;
  44.   private int bananaCount;
  45.   private int bananasPerHour;
  46.   private int bonesToBananas = 0;
  47.  
  48.   // Banking System \\
  49.  
  50.   private boolean atBank() {
  51.     RSArea area = new RSArea(new RSTile(3179, 3432), new RSTile(3194, 3446));
  52.     return area.contains(getMyPlayer().getLocation());
  53.   }
  54.  
  55.   private void Bank() {
  56.     openBank();
  57.     depositBanana();
  58.     getBones();
  59.     closeBank();
  60.  
  61.   }
  62.  
  63.   private void openBank() {
  64.     RSObject bankBooth = objects.getNearest(BankID);
  65.     if (bankBooth != null && !bank.isOpen()) {
  66.       bankBooth.doAction("Use-quickly");
  67.     }
  68.   }
  69.  
  70.   private void depositBanana() {
  71.     if (bank.isOpen() && inventory.containsOneOf(BoneID, BananaID)) {
  72.       bank.depositAllExcept(waterRuneID, earthRuneID, natureRuneID, 0);
  73.       sleep(200, 500);
  74.     }
  75.   }
  76.  
  77.   private void getBones() {
  78.     if (bank.isOpen()) {
  79.       if (!inventory.contains(BoneID)) {
  80.         if (bank.getCount(BoneID) < 26) {
  81.           tries++;
  82.           log("BoneCheck: " + tries + "/3");
  83.           if (tries > 2) {
  84.             sleep(1500);
  85.             log.severe("Out of Bones, script is ending...");
  86.             stopScript(true);
  87.           }
  88.  
  89.         } else {
  90.           bank.withdraw(BoneID, 0);
  91.         }
  92.       }
  93.     }
  94.   }
  95.  
  96.   private void closeBank() {
  97.     if (bank.isOpen()) {
  98.       mouse.move(490, 36, 3, 3);
  99.       sleep(200, 500);
  100.       mouse.click(true);
  101.     }
  102.     if (bank.isOpen()) {
  103.       closeBank();
  104.     }
  105.     return;
  106.   }
  107.  
  108.   // bones to banana system \\
  109.  
  110.   private void boneToBananas() {
  111.     if (inventory.contains(BoneID)) {
  112.       magic.castSpell(magic.SPELL_BONES_TO_BANANAS);
  113.       bonesToBananas += inventory.getCount(BananaID);
  114.       sleep(random(500, 1000));
  115.       if (!inventory
  116.           .containsOneOf(natureRuneID, waterRuneID, earthRuneID)) {
  117.         log.severe("You runned out of runes, script is ending...");
  118.         stopScript(true);
  119.       }
  120.     }
  121.   }
  122.  
  123.   // anti ban system \\
  124.  
  125.   public void antiBan() {
  126.     int i = random(1, 10000);
  127.     if (i == 50) {
  128.       sleep(1200, 2000);
  129.       game.openTab(Game.TAB_STATS);
  130.       skills.doHover(Skills.INTERFACE_MAGIC);
  131.       sleep(1200, 2000);
  132.     } else if (i == 100) {
  133.       mouse.moveOffScreen();
  134.       sleep(500, 2000);
  135.     } else if (i == 500) {
  136.       camera.moveRandomly(3000);
  137.       sleep(500, 1000);
  138.     }
  139.    
  140.   }
  141.  
  142.   // onStart price and equipment check \\
  143.  
  144.   public boolean onStart() {
  145.     startExp = skills.getCurrentExp(Skills.MAGIC);
  146.     startTime = System.currentTimeMillis();
  147.     costBanana = grandExchange.getMarketPrice(BananaID);
  148.     costBone = grandExchange.getMarketPrice(BoneID);
  149.  
  150.     log.severe("Welcome to BlinkBots BonesToBanana's!");
  151.     if (inventory.containsAll(waterRuneID, earthRuneID, natureRuneID)) {
  152.       log("Good job, you got all the runes that we need in your Inventory!");
  153.     } else if (inventory.containsAll(natureRuneID, waterRuneID)
  154.         && equipment.containsAll(earthStaffID)) {
  155.       log("Good job, you got the right staff in your equipment and the right runes in your inventory!");
  156.     } else if (inventory.containsAll(natureRuneID, earthRuneID)
  157.         && equipment.containsAll(waterStaffID)) {
  158.       log("Good job, you got the right staff in your equipment and the right runes in your inventory!");
  159.     } else if (!inventory.containsOneOf(natureRuneID, earthRuneID,
  160.         waterRuneID)
  161.         && (!equipment.containsOneOf(waterStaffID, earthStaffID))) {
  162.       log.severe("You don't got the right staff in your equipment or runes in your inventory, script is ending now...");
  163.       stopScript(true);
  164.     } else if (!inventory.containsOneOf(natureRuneID, earthRuneID,
  165.         waterRuneID)
  166.         && (equipment.containsOneOf(waterStaffID, earthStaffID))) {
  167.       log.severe("You are missing runes in your inventory, script is ending now...");
  168.       stopScript(true);
  169.     }
  170.     return true;
  171.   }
  172.  
  173.   // finish \\
  174.  
  175.   public void onFinish() {
  176.     log("[ ---------------------------------------------------------------------------------------- ]");
  177.     sleep(1000);
  178.     log("  Thank you for using BlinkBots BonesToBanana's!");
  179.     sleep(1000);
  180.     log("  You Gained " + exp + " EXP, You Made " + bananaCount
  181.         + " Banana's And Earned " + profit + " Coins!");
  182.     sleep(1000);
  183.     log("  Bye!");
  184.     sleep(1000);
  185.     log("[ ---------------------------------------------------------------------------------------- ]");
  186.   }
  187.  
  188.   // paint \\
  189.  
  190.   private String abbreviateNum(int i) {
  191.     if (i < 1000)
  192.       return "" + i;
  193.     return "" + (i / 1000) + "K";
  194.   }
  195.  
  196.   private final Color color1 = new Color(0, 0, 0, 155);
  197.   private final Color color2 = new Color(0, 0, 0);
  198.   private final Color color3 = new Color(204, 0, 51);
  199.   private final Color color4 = new Color(204, 0, 51, 105);
  200.   private final Color color5 = new Color(255, 255, 255);
  201.   private final Color color6 = new Color(255, 255, 255, 80);
  202.  
  203.   private final BasicStroke stroke1 = new BasicStroke(1);
  204.  
  205.   private final Font font1 = new Font("Arial", 0, 10);
  206.  
  207.   @Override
  208.   public void onRepaint(Graphics g1) {
  209.  
  210.     if (game.isLoggedIn()) {
  211.  
  212.       long runTime = System.currentTimeMillis() - startTime;
  213.       long millis = System.currentTimeMillis() - startTime;
  214.       long hours = millis / (1000 * 60 * 60);
  215.       millis -= hours * (1000 * 60 * 60);
  216.       long minutes = millis / (1000 * 60);
  217.       millis -= minutes * (1000 * 60);
  218.       long seconds = millis / 1000;
  219.  
  220.       exp = skills.getCurrentExp(Skills.MAGIC) - startExp;
  221.       profit = (costBanana - costBone) * bananaCount;
  222.       bananaCount = bonesToBananas;
  223.  
  224.       if (runTime / 1000 > 0) {
  225.         expPerHour = (int) (3600000.0 / runTime * exp);
  226.         profitPerHour = (int) (3600000.0 / runTime * profit);
  227.         bananasPerHour = (int) (3600000.0 / runTime * bananaCount);
  228.  
  229.       }
  230.  
  231.       Graphics2D g = (Graphics2D) g1;
  232.  
  233.       g.setColor(color1);
  234.       g.fillRect(1, 324, 517, 14);
  235.       g.setColor(color2);
  236.       g.setStroke(stroke1);
  237.       g.drawRect(0, 323, 518, 15);
  238.       g.setColor(color3);
  239.       g.fillRect(1, 324, skills.getPercentToNextLevel(Skills.MAGIC), 14);
  240.       g.setColor(color4);
  241.       g.fillRect(1, 324, 100, 14);
  242.       g.setColor(color2);
  243.       g.drawRect(0, 323, 101, 15);
  244.       g.setFont(font1);
  245.       g.drawString("" + skills.getPercentToNextLevel(Skills.MAGIC) + "%",
  246.           41, 335);
  247.       g.setColor(color5);
  248.       g.drawString("EXP: " + abbreviateNum(exp), 114, 335);
  249.       g.drawString("P/h: " + abbreviateNum(expPerHour), 178, 335);
  250.       g.drawString("||", 233, 334);
  251.       g.drawString("||", 355, 334);
  252.       g.drawString("||", 479, 334);
  253.       g.drawString("P: " + abbreviateNum(profit), 250, 335);
  254.       g.drawString("P/h: " + abbreviateNum(profitPerHour), 300, 335);
  255.       g.drawString("B: " + abbreviateNum(bananaCount), 372, 335);
  256.       g.drawString("P/h : " + abbreviateNum(bananasPerHour), 422, 335);
  257.       g.drawString("BB ©", 490, 335);
  258.       g.setColor(color6);
  259.       g.fillRect(1, 324, 517, 7);
  260.       g.setColor(color2);
  261.       g.drawString("Time Running: " + hours + " : " + minutes + " : "
  262.           + seconds, 4, 319);
  263.     }
  264.   }
  265.  
  266.   // the loop \\
  267.  
  268.   @Override
  269.   public int loop() {
  270.     antiBan();
  271.     if (atBank() && inventory.contains(BoneID)) {
  272.       boneToBananas();
  273.     } else if (atBank() && inventory.contains(BananaID)) {
  274.       Bank();
  275.     } else if (atBank() && !inventory.containsOneOf(BananaID, BoneID)) {
  276.       Bank();
  277.     } else if (atBank() && bank.isOpen()) {
  278.       closeBank();
  279.     }
  280.     return (random(500, 1000));
  281.  
  282.   }
  283.  
  284.   public void serverMessageRecieved(ServerMessageEvent e) {
  285.     String serverString = e.getMessage();
  286.  
  287.     if (serverString
  288.         .contains("You do not have enough water runes to cast this spell.")) {
  289.       log.severe("You runned out of water runes, script is ending...");
  290.       stopScript(true);
  291.     }
  292.  
  293.     else if (serverString
  294.         .contains("You do not have enough nature runes to cast this spell.")) {
  295.       log.severe("You runned out of nature runes, script is ending...");
  296.       stopScript(true);
  297.     }
  298.  
  299.     else if (serverString
  300.         .contains("You do not have enough earth runes to cast this spell.")) {
  301.       log.severe("You runned out of earth runes, script is ending...");
  302.       stopScript(true);
  303.     }
  304.   }
  305. }
RAW Paste Data
Pastebin PRO Autumn Special!
Get 40% OFF on Pastebin PRO accounts!
Top