Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 25.48 KB | None | 0 0
  1. //Fixes in 1.02:
  2. //Double teleport 99% Eradicated even with massive lag
  3. //Path around the "Curve" tightened and shortened
  4. //Path at "ramp" sometimes high road.
  5.  
  6. import java.awt.Color;
  7. import java.awt.Graphics;
  8. import java.awt.Point;
  9. import java.text.NumberFormat;
  10. import java.util.Map;
  11.  
  12. import org.rsbot.bot.Bot;
  13. import org.rsbot.event.listeners.PaintListener;
  14. import org.rsbot.script.Calculations;
  15. import org.rsbot.script.Script;
  16. import org.rsbot.script.ScriptManifest;
  17. import org.rsbot.script.Skills;
  18. import org.rsbot.script.wrappers.RSTile;
  19. import org.rsbot.event.events.ServerMessageEvent;
  20. import org.rsbot.event.listeners.ServerMessageListener;
  21. import org.rsbot.script.wrappers.RSInterface;
  22. import org.rsbot.script.wrappers.RSInterfaceChild;
  23. import org.rsbot.script.wrappers.RSInterfaceComponent;
  24. import java.awt.Rectangle;
  25.  
  26. @ScriptManifest(authors = { "Garrett" }, category = "Runecraft", name = "Garrett's Astral Runecrafter", version = 1.02, description =
  27.     "<html><head>" +
  28.     "</head><body>" +
  29.     "<center><strong><h2>Garrett's Astral Runecrafter</h2></strong><br /><br />" +
  30.     "NOTE: Wearing a ring of life & turning off auto retaliate would be a good idea<br />" +
  31.     "Start the script anywhere along the runecrafting process<br />" +
  32.     "If you want to use teleport, have an earth staff equipped and laws in inventory</center><br />" +
  33.     "Food ID: <input name='FOODID' type='text' size='5' value='7946' /><br />" +
  34.     "Eat Food (Random): <input name='HEALTH1' type='text' size='3' value='70' /> to <input name='HEALTH2' type='text' size='3' value='90' /> HP %<br />" +
  35.     "<input name='USEPOTS' type='checkbox' value='1'>Use energy potions?" +
  36. "</body></html>")
  37.  
  38. public class GarrettsAstralRunecrafter extends Script implements PaintListener, ServerMessageListener {
  39.  
  40.     final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
  41.  
  42.     private long scriptStartTIME = 0;
  43.     int runEnergy = random(40, 95);
  44.     int randomDrink = 100;
  45.     int healthPercent = 0;
  46.     int drinkVars[] = new int[2];
  47.     int randomHealth[] = new int[2];
  48.     int failCount = 0;
  49.     int fatalCount = 0;
  50.     int startLVL = 0;
  51.     int startXP = 0;
  52.     boolean setAltitude = false;
  53.     //delete from here if needed
  54.     int smPouch = 5509;
  55.     int medPouch = 5510;
  56.     int medPouchd = 5511;
  57.     int largePouch = 5512;
  58.     int largePouchd = 5513;
  59.     int giantPouch = 5514;
  60.     int giantPouchd = 5515;
  61.     int airRune = 556;
  62.     int cosmicRune = 564;
  63.     public boolean checkPouch = true;
  64.     public boolean fullPouch = true;
  65.     public int pouchCheck = 0;
  66.     public int numPouches = 0;
  67.     public boolean decayedPouch = false;
  68.     public boolean giantFull=false;
  69.     public int pouchesFixxed = 0;
  70.     public boolean craftUp=false;
  71.     public boolean emptyInv=false;
  72.     public boolean smFull=false;
  73.     public boolean medFull=false;
  74.     public boolean largeFull=false;
  75.     public int moneyBanked=0;
  76.     public int moneyUsed=0;
  77.     public int profitMade=0;
  78.     public int essPrice=129;
  79.     public int astralPrice=214;
  80.     public int lawPrice=334;
  81.     public boolean craftSinceProfit=false;
  82.     public int tCashUsed = 0;
  83.  
  84.     boolean useFood = true;
  85.     boolean usePots = true;
  86.  
  87.     final int pureEssence = 7936;
  88.     final int astralRune = 9075;
  89.     final int lawRune = 563;
  90.     final int energyPots[] = {3014, 3012, 3010, 3008, 3022, 3020, 3018, 3016};
  91.     int foodID = 0;
  92.  
  93.     public RSTile PathToBank[] = { new RSTile(2113,3916), new RSTile(2106,3915), new RSTile(2100,3918)};
  94.     final RSTile bankBooth = new RSTile(2099, 3920);
  95.     final RSTile bankTile = new RSTile(2101, 3919);
  96.     final RSTile altar = new RSTile(2158, 3864);
  97.     final RSTile[] path = {new RSTile(2099, 3919), new RSTile(2104, 3915), new RSTile(2112, 3915), new RSTile(2113, 3901),
  98.             new RSTile(2113, 3897), new RSTile(2115,3885), new RSTile(2123, 3879), new RSTile(2128, 3874),
  99.             new RSTile(2134, 3864), new RSTile(2142, 3860), new RSTile(2147, 3863),
  100.             new RSTile(2153, 3864), new RSTile(2156, 3864)};
  101.  
  102.     private enum State { walkToAltar, walkToBank, craftRunes, teleport, drinkPotion, eatFood, bank, checkPouches, emptyPouch, repairPouches, error };
  103.  
  104.     private State getState() {
  105.         if (fatalCount > 20)
  106.             return State.error;
  107.         if (usePots)
  108.             if (getEnergy() < randomDrink)
  109.                 if (inventoryContainsOneOf(energyPots))
  110.                     return State.drinkPotion;
  111.         if (tileOnMap(bankTile)) {
  112.             if (useFood)
  113.                 if (getHPpercent() < healthPercent)
  114.                     if (inventoryContains(foodID))
  115.                         return State.eatFood;
  116.             if (usePots)
  117.                 if (!inventoryContainsOneOf(energyPots) && !isInventoryFull())
  118.                     return State.bank;
  119.             if (decayedPouch)
  120.                 return State.repairPouches;
  121.             if (checkPouch)
  122.                 return State.checkPouches;
  123.             if (!inventoryContains(pureEssence))
  124.                 return State.bank;
  125.             if (!isInventoryFull())
  126.                 return State.bank;
  127.         }
  128.         if (tileOnMap(altar)){
  129.             if (inventoryContains(pureEssence)){
  130.                 craftSinceProfit=true;
  131.                 return State.craftRunes;
  132.             }
  133.             if(craftUp){
  134.                 craftUp=false;
  135.                 return State.craftRunes;
  136.             }
  137.             if (fullPouch)
  138.                 return State.emptyPouch;
  139.         }
  140.         if (inventoryContains(pureEssence))
  141.             return State.walkToAltar;
  142.         else {
  143.             if (inventoryContains(lawRune) && distanceTo(bankTile) > 30)
  144.                 return State.teleport;
  145.             else
  146.                 return State.walkToBank;
  147.         }
  148.     }
  149.  
  150.     public boolean onStart( Map<String,String> args ) {
  151.         setCompass('w');
  152.         scriptStartTIME = System.currentTimeMillis();
  153.         usePots = args.get("USEPOTS") != null ? true : false;
  154.         randomHealth[0] = Integer.parseInt(args.get("HEALTH1"));
  155.         randomHealth[1] = Integer.parseInt(args.get("HEALTH2"));
  156.         drinkVars[0] = 40;
  157.         drinkVars[1] = 70;
  158.         randomDrink = random(drinkVars[0], drinkVars[1]);
  159.         healthPercent = random(randomHealth[0], randomHealth[1]);
  160.         foodID = Integer.parseInt(args.get("FOODID"));
  161.         return true;
  162.     }
  163.  
  164.     public int loop() {
  165.         if (!isLoggedIn())
  166.             return 1;
  167.  
  168.         if(!setAltitude) {
  169.             setCameraAltitude(true);
  170.             wait(random(250, 500));
  171.             setAltitude = true;
  172.             return 1;
  173.         }
  174.  
  175.         startRunning(runEnergy);
  176.         switch (getState()) {
  177.         case walkToAltar:
  178.             walkPath(path);
  179.             return 1;
  180.         case walkToBank:
  181.             walkPath(reversePath(path));
  182.             return 1;
  183.         case craftRunes:
  184.             int invCount = getInventoryCount(astralRune);
  185.             if (onTile(altar, "Craft", random(-0.25, 1.25), random(-0.25, 1.25), 0)) {
  186.                 fatalCount = 0;
  187.                 wait(random(200, 400));
  188.                 failCount = 0;
  189.                 while (invCount == getInventoryCount(astralRune) && failCount < 40) {
  190.                     wait(random(50, 100));
  191.                     failCount++;
  192.                 }
  193.             }
  194.             return 1;
  195.         case teleport:
  196.             log("Initiating teleport");
  197.             if (getCurrentTab() != TAB_MAGIC) {
  198.                 openTab(TAB_MAGIC);
  199.                 failCount = 0;
  200.                 while (getCurrentTab() != TAB_MAGIC && failCount < 10) {
  201.                     wait(random(50, 100));
  202.                     failCount++;
  203.                 }
  204.             }
  205.             RSTile location = getMyPlayer().getLocation();
  206.             RSTile location2 = location;
  207.             wait(random(100,250));
  208.             while(location == location2){
  209.                 log("While loop started loc=loc");
  210.                 if (atInterface(430, 42)) {
  211.                     wait(random(500, 750));
  212.                     failCount = 0;
  213.                     while (location == getMyPlayer().getLocation() && failCount < 40) {
  214.                         wait(random(100, 150));
  215.                         failCount++;
  216.                     }
  217.                     while (getMyPlayer().getAnimation() != -1) {
  218.                         wait(random(50, 100));
  219.                     }
  220.                     wait(random(800, 1200));
  221.                     moneyUsed= moneyUsed+lawPrice;
  222.                 } else {
  223.                     onTile(altar, "Pray", random(-0.25, 1.25), random(-0.25, 1.25), 0);
  224.                     wait(random(800, 1200));
  225.                 }
  226.                
  227.                 location2 = getMyPlayer().getLocation();
  228.                 log("while loop ended");
  229.             }
  230.             log("successfully registered tele");
  231.             return 1;
  232.         case drinkPotion:
  233.             if (bank.isOpen()) {
  234.                 if (bank.close()) {
  235.                     wait(random(100, 200));
  236.                     failCount = 0;
  237.                     while (bank.isOpen() && failCount < 20) {
  238.                         wait(random(50, 100));
  239.                         failCount++;
  240.                     }
  241.                 }  
  242.                 return 1;
  243.             }
  244.             for (int i = 0; i < energyPots.length; i++) {
  245.                 try {
  246.                     if (atInventoryItem(energyPots[i], "Drink")) {
  247.                         wait(random(100, 200));
  248.                         failCount = 0;
  249.                         while (inventoryContains(energyPots[i]) && failCount < 20) {
  250.                             wait(random(50, 100));
  251.                             failCount++;
  252.                         }
  253.                         randomDrink = random(drinkVars[0], drinkVars[1]);
  254.                         break;
  255.                     }
  256.                 } catch(Exception e) { }
  257.             }
  258.             return 1;
  259.         case eatFood:
  260.             if (inventoryContains(foodID)) {
  261.                 if (bank.isOpen()) {
  262.                     if (bank.close()) {
  263.                         wait(random(100, 200));
  264.                         failCount = 0;
  265.                         while (bank.isOpen() && failCount < 20) {
  266.                             wait(random(50, 100));
  267.                             failCount++;
  268.                         }
  269.                     }  
  270.                     return 1;
  271.                 }
  272.                 if (atInventoryItem(foodID, "Eat")) {
  273.                     wait(random(100, 200));
  274.                     failCount = 0;
  275.                     while (inventoryContains(foodID) && failCount < 30) {
  276.                         wait(random(50, 100));
  277.                         failCount++;
  278.                     }
  279.                     healthPercent = random(randomHealth[0], randomHealth[1]);
  280.                 }
  281.             }
  282.             return 1;
  283.         case repairPouches:
  284.             if(bank.isOpen()&&inventoryContains(airRune)&&inventoryContains(cosmicRune)&&inventoryContains(astralRune)){
  285.                 if (bank.close()) {
  286.                     wait(random(100, 200));
  287.                     failCount = 0;
  288.                     while (bank.isOpen() && failCount < 20) {
  289.                         wait(random(50, 100));
  290.                         failCount++;
  291.                     }
  292.                     return 1;
  293.                 }
  294.             }
  295.             if(inventoryContains(airRune)&&inventoryContains(cosmicRune)&&inventoryContains(astralRune)){
  296.                 if (getCurrentTab() != TAB_MAGIC) {
  297.                     openTab(TAB_MAGIC);
  298.                     failCount = 0;
  299.                     while (getCurrentTab() != TAB_MAGIC && failCount < 10) {
  300.                         wait(random(50, 100));
  301.                         failCount++;
  302.                     }
  303.                 }
  304.                
  305.                 atInterface(430, 26);
  306.                 wait(random(1500, 1750));
  307.                
  308.                 final RSInterfaceChild scrollBar = RSInterface.getChildInterface(88, 20);
  309.                 if (!scrollBar.isValid())
  310.                     return 1;
  311.                
  312.                 Rectangle pos = scrollBar.getArea();
  313.                 if (pos.x == -1 || pos.y == -1 || pos.width == -1 || pos.height == -1) {
  314.                     return 1;
  315.                 }
  316.                 moveMouse((int) random(458, 465), (int) random(257, 296));
  317.                 clickMouse(true);
  318.                 wait(random(500, 750));
  319.                 clickMouse(true);
  320.  
  321.                 final RSInterfaceChild darkMage = RSInterface.getChildInterface(88, 22);
  322.                 if (!darkMage.isValid())
  323.                     return 1;
  324.                 atComponent(darkMage,4,"Speak-to");
  325.                 //I know this looks a bit overkill but it seems to work out right... dont fix it if it ain't broke right?!?
  326.                 wait(random(500,1000));
  327.                 clickContinue();
  328.                 wait(random(500,1000));
  329.                 clickContinue();
  330.                 wait(random(500,1000));
  331.                 clickContinue();
  332.                 wait(random(500,1000));
  333.                 clickContinue();
  334.                 wait(random(500,1000));
  335.                 clickContinue();
  336.                 wait(random(500,1000));
  337.                 clickContinue();
  338.                 wait(random(500,1000));
  339.                 clickContinue();
  340.                 clickContinue();
  341.                 wait(random(500,1000));
  342.                 clickContinue();
  343.                 wait(random(500,1000));
  344.                 clickContinue();
  345.                 wait(random(500,1000));
  346.                 clickContinue();
  347.                 wait(random(500,1000));
  348.                 clickContinue();
  349.                 wait(random(500,1000));
  350.                 clickContinue();
  351.                 wait(random(500,1000));
  352.                 clickContinue();
  353.                 wait(random(500,1000));
  354.                 clickContinue();
  355.                 wait(random(500,1000));
  356.                 clickContinue();
  357.                 wait(random(500,1000));
  358.                 clickContinue();
  359.                 wait(random(500,1000));
  360.                 clickContinue();
  361.                 wait(random(500,1000));
  362.                 clickContinue();
  363.                 wait(random(500,1000));
  364.                 moveMouse((int) random(162, 352), (int) random(416, 423));
  365.                 clickMouse(true);
  366.                 moveMouse((int) random(162, 352), (int) random(416, 423));
  367.                 wait(random(500, 750));
  368.                 moveMouse((int) random(162, 352), (int) random(416, 423));
  369.                 clickMouse(true);
  370.                 wait(random(500,1000));
  371.                 clickContinue();
  372.                 wait(random(500,1000));
  373.                 clickContinue();
  374.                 wait(random(500,1000));
  375.                 clickContinue();
  376.                 wait(random(500,1000));
  377.                 clickContinue();
  378.                 wait(random(500,1000));
  379.                 clickContinue();
  380.                 wait(random(500,1000));
  381.                 clickContinue();
  382.                 wait(random(500,1000));
  383.                 clickContinue();
  384.                 wait(random(500,1000));
  385.             }
  386.             if(!inventoryContains(airRune)||!inventoryContains(cosmicRune)||!inventoryContains(astralRune)){
  387.                 if (getMyPlayer().isMoving())
  388.                     return 1;
  389.                 if (distanceTo(bankTile) > 10)
  390.                     walkTileMM(bankTile);
  391.                 if (!bank.isOpen()) {
  392.                     if (onTile(bankBooth, "Use-Quickly", 0.5, 0.5, 0)) {
  393.                         wait(random(1500, 2000));
  394.                         failCount = 0;
  395.                         while (!bank.isOpen() && failCount < 30) {
  396.                             wait(random(600, 800));
  397.                             if (getMyPlayer().isMoving())
  398.                                 failCount = 0;
  399.                             failCount++;
  400.                         }
  401.                     }
  402.                 }
  403.                     if (atInventoryItem(pureEssence, "Deposit-All")) {
  404.                         wait(random(600, 800));
  405.                         failCount = 0;
  406.                         while (inventoryContains(pureEssence) && failCount < 30) {
  407.                             wait(random(600, 800));
  408.                             failCount++;
  409.                         }
  410.                     } else fatalCount++;
  411.                     if (bank.atItem(airRune, "Withdraw-10")) {
  412.                         wait(random(600, 800));
  413.                         failCount = 0;
  414.                         while (!inventoryContains(airRune) && failCount < 30) {
  415.                             wait(random(600, 800));
  416.                             failCount++;
  417.                         }
  418.                     } else fatalCount++;
  419.                     if (bank.atItem(cosmicRune, "Withdraw-10")) {
  420.                         wait(random(600, 800));
  421.                         failCount = 0;
  422.                         while (!inventoryContains(cosmicRune) && failCount < 30) {
  423.                             wait(random(600, 800));
  424.                             failCount++;
  425.                         }
  426.                     } else fatalCount++;
  427.                     if (bank.atItem(astralRune, "Withdraw-10")) {
  428.                         wait(random(600, 800));
  429.                         failCount = 0;
  430.                         while (!inventoryContains(astralRune) && failCount < 30) {
  431.                             wait(random(600, 800));
  432.                             failCount++;
  433.                         }
  434.                     } else fatalCount++;
  435.                 return 1;
  436.             }
  437.             if(!inventoryContains(medPouchd)&&!inventoryContains(largePouchd)&&!inventoryContains(giantPouchd)){
  438.                 if (getMyPlayer().isMoving())
  439.                     return 1;
  440.                 if (distanceTo(bankTile) > 10)
  441.                     walkTileMM(bankTile);
  442.                 if (!bank.isOpen()) {
  443.                     if (onTile(bankBooth, "Use-Quickly", 0.5, 0.5, 0)) {
  444.                         wait(random(100, 200));
  445.                         failCount = 0;
  446.                         while (!bank.isOpen() && failCount < 30) {
  447.                             wait(random(50, 100));
  448.                             if (getMyPlayer().isMoving())
  449.                                 failCount = 0;
  450.                             failCount++;
  451.                         }
  452.                     }
  453.                 }
  454.                 bank.depositAllExcept(energyPots[0], energyPots[1], energyPots[2], energyPots[3], energyPots[4], energyPots[5], energyPots[6], energyPots[7], lawRune, pureEssence, smPouch, medPouch, largePouch, giantPouch);
  455.                 decayedPouch=false;
  456.                 checkPouch=true;
  457.                 pouchesFixxed++;
  458.                 giantFull=false;
  459.                 largeFull=false;
  460.                 medFull=false;
  461.                 smFull=false;
  462.                 return 1;
  463.             }
  464.         case emptyPouch:
  465.             wait(random(500,1000));
  466.             if (getMyPlayer().isMoving())
  467.                 return 1;
  468.             if(inventoryContains(giantPouch)&&!isInventoryFull()&&giantFull){
  469.                 atInventoryItem(giantPouch,"Empty");
  470.                 giantFull=false;
  471.                 wait(random(200,500));
  472.                 craftUp=true;
  473.                 return 1;
  474.             }
  475.            
  476.             if(inventoryContains(smPouch)&&!isInventoryFull())
  477.                 atInventoryItem(smPouch,"Empty");
  478.             wait(random(100,200));
  479.             if(inventoryContains(medPouch)&&!isInventoryFull())
  480.                 atInventoryItem(medPouch,"Empty");
  481.             wait(random(100,200));
  482.             if(inventoryContains(largePouch)&&!isInventoryFull())
  483.                 atInventoryItem(largePouch,"Empty");
  484.             wait(random(100,200));
  485.             if(!isInventoryFull()){
  486.                 checkPouch=true;
  487.                 fullPouch=false;
  488.                 smFull=false;
  489.                 medFull=false;
  490.                 largeFull=false;
  491.                 return 1;
  492.             }
  493.             return 1;
  494.         case checkPouches:
  495.             emptyInv=false;
  496.             if(inventoryContains(medPouchd)||inventoryContains(largePouchd)||inventoryContains(giantPouchd)){
  497.                 decayedPouch=true;
  498.                 return 1;
  499.             }
  500.             if(bank.isOpen()&&inventoryContains(pureEssence))
  501.                 if (bank.close()) {
  502.                     wait(random(100, 200));
  503.                     failCount = 0;
  504.                     while (bank.isOpen() && failCount < 20) {
  505.                         wait(random(50, 100));
  506.                         failCount++;
  507.                     }
  508.                     return 1;
  509.                 }
  510.             if(!inventoryContains(pureEssence)){
  511.                 if (getMyPlayer().isMoving())
  512.                     return 1;
  513.                 if (distanceTo(bankTile) > 10)
  514.                     walkTileMM(bankTile);
  515.                 if (!bank.isOpen()) {
  516.                     if (onTile(bankBooth, "Use-Quickly", 0.5, 0.5, 0)) {
  517.                         wait(random(100, 200));
  518.                         failCount = 0;
  519.                         while (!bank.isOpen() && failCount < 30) {
  520.                             wait(random(50, 100));
  521.                             if (getMyPlayer().isMoving())
  522.                                 failCount = 0;
  523.                             failCount++;
  524.                         }
  525.                     }
  526.                 }
  527.                 if(!isInventoryFull()&&!inventoryContains(astralRune)){
  528.                     if (bank.atItem(pureEssence, "Withdraw-All")) {
  529.                         wait(random(200, 400));
  530.                         failCount = 0;
  531.                         while (!inventoryContains(pureEssence) && failCount < 30) {
  532.                             wait(random(50, 100));
  533.                             failCount++;
  534.                         }
  535.                     } else fatalCount++;
  536.                 } else {
  537.                     if(craftSinceProfit){
  538.                         moneyBanked=moneyBanked+(getInventoryCount(astralRune)*astralPrice);
  539.                         craftSinceProfit=false;
  540.                     }
  541.                     bank.depositAllExcept(energyPots[0], energyPots[1], energyPots[2], energyPots[3], energyPots[4], energyPots[5], energyPots[6], energyPots[7], lawRune, pureEssence, smPouch, medPouch, largePouch, giantPouch);
  542.                 }
  543.                 return 1;
  544.             }
  545.             numPouches=0;
  546.             pouchCheck=0;
  547.             wait(random(200,400));
  548.             if(inventoryContains(smPouch)&&!smFull){
  549.                 numPouches++;
  550.                 while(numPouches>pouchCheck&&!emptyInv){
  551.                     atInventoryItem(smPouch, "Fill");
  552.                     wait(random(1000,2000));
  553.                 }
  554.                 if(numPouches<=pouchCheck&&!emptyInv){
  555.                     smFull=true;
  556.                 }
  557.             }
  558.             wait(random(200,400));
  559.             if(inventoryContains(medPouch)&&!medFull){
  560.                 numPouches++;
  561.                 while(numPouches>pouchCheck&&!emptyInv){
  562.                     atInventoryItem(medPouch, "Fill");
  563.                     wait(random(1000,2000));
  564.                 }
  565.                 if(numPouches<=pouchCheck&&!emptyInv){
  566.                     medFull=true;
  567.                 }
  568.             }
  569.             wait(random(200,400));
  570.             if(inventoryContains(largePouch)&&!largeFull){
  571.                 numPouches++;
  572.                 while(numPouches>pouchCheck&&!emptyInv){
  573.                     atInventoryItem(largePouch, "Fill");
  574.                     wait(random(1000,2000));
  575.                 }
  576.                 if(numPouches<=pouchCheck&&!emptyInv){
  577.                     largeFull=true;
  578.                 }
  579.             }
  580.             pouchCheck=0;
  581.             if(inventoryContains(giantPouch)&&!giantFull){
  582.                 atInventoryItem(giantPouch, "Fill");
  583.                 wait(random(1000,2000));
  584.                 if(pouchCheck>=1)
  585.                     giantFull=true;
  586.  
  587.                 return 1;
  588.             }
  589.             wait(random(300,600));
  590.             if(pouchCheck==numPouches&&!emptyInv){
  591.                 checkPouch=false;
  592.                 fullPouch=true;
  593.                 return 1;
  594.             }
  595.             if(numPouches<=0&&!emptyInv){
  596.                 checkPouch=false;
  597.                 fullPouch=false;
  598.                 return 1;
  599.             }
  600.             return 1;      
  601.         case bank:
  602.             if (getMyPlayer().isMoving())
  603.                 return 1;
  604.             if (distanceTo(bankTile) > 10)
  605.                 walkPathMM(PathToBank);
  606.             if (!bank.isOpen()) {
  607.                 if (onTile(bankBooth, "Use-Quickly", 0.5, 0.5, 0)) {
  608.                     wait(random(100, 200));
  609.                     failCount = 0;
  610.                     while (!bank.isOpen() && failCount < 30) {
  611.                         wait(random(50, 100));
  612.                         if (getMyPlayer().isMoving())
  613.                             failCount = 0;
  614.                         failCount++;
  615.                     }
  616.                 }  
  617.                 return 1;
  618.             }
  619.             if (inventoryContains(astralRune)) {
  620.                 if(inventoryContains(lawRune) || inventoryContains(pureEssence))
  621.                     bank.depositAllExcept(energyPots[0], energyPots[1], energyPots[2], energyPots[3], energyPots[4], energyPots[5], energyPots[6], energyPots[7], lawRune, pureEssence, smPouch, medPouch, largePouch, giantPouch);
  622.                 else
  623.                     bank.depositAll();
  624.             }
  625.             if (getEnergy() < randomDrink) {
  626.                 if (!inventoryContainsOneOf(energyPots) && !isInventoryFull()) {
  627.                     int usePotion = 0;
  628.                     for (int i = 0; i < energyPots.length; i++) {
  629.                         try {
  630.                             if (bank.getItemByID((energyPots[i])).isValid()) {
  631.                                 usePotion = energyPots[i];
  632.                                 break;
  633.                             }
  634.                         } catch(Exception e) { }
  635.                     }
  636.                     if (bank.atItem(usePotion, "Withdraw-1")) {
  637.                         failCount = 0;
  638.                         while (!inventoryContains(usePotion) && failCount < 30) {
  639.                             wait(random(50, 100));
  640.                             failCount++;
  641.                         }
  642.                     }
  643.                 }
  644.             }
  645.             if (getHPpercent() <= healthPercent) {
  646.                 if (!inventoryContains(foodID) && !isInventoryFull()) {
  647.                     if (bank.atItem(foodID, "Withdraw-1")) {
  648.                         failCount = 0;
  649.                         while (!inventoryContains(foodID) && failCount < 30) {
  650.                             wait(random(50, 100));
  651.                             failCount++;
  652.                         }
  653.                     } else fatalCount++;
  654.                 }
  655.                 return 1;
  656.             }
  657.             if (!inventoryContains(pureEssence) || !isInventoryFull()) {
  658.                 if (bank.atItem(pureEssence, "Withdraw-All")) {
  659.                     wait(random(200, 400));
  660.                     failCount = 0;
  661.                     while (!inventoryContains(pureEssence) && failCount < 30) {
  662.                         wait(random(50, 100));
  663.                         failCount++;
  664.                     }
  665.                 } else fatalCount++;
  666.             }
  667.             return 1;
  668.         case error:
  669.             return -1;
  670.         }
  671.  
  672.         return 1;
  673.     }
  674.    
  675.     public void serverMessageRecieved(final ServerMessageEvent arg0) {
  676.             final String serverString = arg0.getMessage();
  677.             if (serverString.toLowerCase().contains("full")) {
  678.                     pouchCheck++;
  679.  
  680.             }
  681.             if (serverString.toLowerCase().contains("fill")) {
  682.                  
  683.                     pouchCheck++;
  684.                 }
  685.             if (serverString.toLowerCase().contains("left")) {
  686.                    
  687.                     pouchCheck++;
  688.             }
  689.             if (serverString.toLowerCase().contains("decayed")) {
  690.                    
  691.                     decayedPouch=true;
  692.             }
  693.         if (serverString.toLowerCase().contains("have any more")) {
  694.            
  695.             emptyInv=true;
  696.         }
  697.         }
  698.    
  699.     private boolean onTile(final RSTile tile, final String action, final double dx, final double dy, final int height) {
  700.         if (!tile.isValid())
  701.             return false;
  702.  
  703.         Point checkScreen = null;
  704.  
  705.         try {
  706.             checkScreen = Calculations.tileToScreen(tile, dx, dy, height);
  707.             if (!pointOnScreen(checkScreen)) {
  708.                 if (getMyPlayer().isMoving())
  709.                     return false;
  710.                 if (walkTileMM(tile))
  711.                     wait(random(750, 1000));
  712.                 return false;
  713.             }
  714.         } catch(Exception e) { }
  715.  
  716.         try {
  717.             boolean stop = false;
  718.             for (int i = 0; i <= 50; i++) {
  719.                 checkScreen = Calculations.tileToScreen(tile, dx, dy, height);
  720.                 if (!pointOnScreen(checkScreen))
  721.                     return false;
  722.                 moveMouse(checkScreen);
  723.                 final Object[] menuItems = getMenuItems().toArray();
  724.                 for (int a = 0; a < menuItems.length; a++) {
  725.                     if (menuItems[a].toString().toLowerCase().contains(action.toLowerCase())) {
  726.                         stop = true;
  727.                         break;
  728.                     }
  729.                 }
  730.                 if (stop)
  731.                     break;
  732.             }
  733.         } catch(Exception e) { }
  734.  
  735.         try {
  736.             return atMenu(action);
  737.         } catch(Exception e) { }
  738.         return false;
  739.     }
  740.    
  741.     private double getHPpercent() {
  742.         final int health = Integer.parseInt(getInterface(748, 8).getText().trim());
  743.         final int totalHealth = skills.getRealSkillLevel(STAT_HITPOINTS) * 10;
  744.         return (int) (((double) health / (double) totalHealth) * 100.0);
  745.     }
  746.  
  747.     private void startRunning(final int energy) {
  748.         if (getEnergy() >= energy && !isRunning()) {
  749.             runEnergy = random(40, 95);
  750.             setRun(true);
  751.             wait(random(500, 750));
  752.         }
  753.     }
  754.  
  755.     private boolean walkPath(RSTile[] path) {
  756.         if(!getMyPlayer().isMoving() || distanceTo(getDestination()) <= 5)
  757.             return walkPathMM(path, 17);
  758.         return false;
  759.     }
  760.  
  761.     public void onFinish() {
  762.         Bot.getEventManager().removeListener( PaintListener.class, this );
  763.     }
  764.  
  765.     public void onRepaint(Graphics g) {
  766.         if (!isLoggedIn())
  767.             return;
  768.  
  769.         if (startLVL == 0) {
  770.             startXP = skills.getCurrentSkillExp(Skills.getStatIndex("runecrafting"));
  771.             startLVL = skills.getCurrentSkillLevel(Skills.getStatIndex("runecrafting"));
  772.         }
  773.  
  774.         if(getCurrentTab() != TAB_INVENTORY)
  775.             return;
  776.  
  777.         long seconds = 0;
  778.         long minutes = 0;
  779.         long hours = 0;
  780.         final NumberFormat nf = NumberFormat.getInstance();
  781.         nf.setMinimumIntegerDigits(2);
  782.         final long runTime = System.currentTimeMillis() - scriptStartTIME;
  783.         seconds = runTime / 1000;
  784.         if ( seconds >= 60 ) {
  785.             minutes = seconds / 60;
  786.             seconds -= (minutes * 60);
  787.         }
  788.         if ( minutes >= 60 ) {
  789.             hours = minutes / 60;
  790.             minutes -= (hours * 60);
  791.         }
  792.  
  793.         final int currentXP = skills.getCurrentSkillExp(Skills.getStatIndex("runecrafting"));
  794.         final int currentLVL = skills.getCurrentSkillLevel(Skills.getStatIndex("runecrafting"));
  795.         final int XPgained = currentXP - startXP;
  796.         final int LVLgained = currentLVL - startLVL;
  797.         final int xpTilNext = skills.getXPToNextLevel(Skills.getStatIndex("runecrafting"));
  798.         final int percentTilNext = skills.getPercentToNextLevel(Skills.getStatIndex("runecrafting"));
  799.         final int fillBar = (int) (1.65 * (double) percentTilNext);
  800.         final int essUsed = (int) ((double) XPgained / 8.7);
  801.         profitMade = moneyBanked - (moneyUsed + (essUsed * essPrice));
  802.         tCashUsed = moneyUsed + (essUsed * essPrice);
  803.         int essPerHour = 0;
  804.         int XPperHour = 0;
  805.         if ((runTime / 1000) > 0) {
  806.             essPerHour = (int) ((3600000.0 / (double) runTime) * essUsed);
  807.             XPperHour = (int) ((3600000.0 / (double) runTime) * XPgained);
  808.         }
  809.  
  810.         final int[] coords = new int[] {225, 240, 255, 270, 285, 300, 315, 330, 345, 360, 375, 390, 405, 420, 435, 450, 465, 480, 495, 510};
  811.  
  812.         g.setColor(new Color(0, 0, 0, 175));
  813.         g.fillRoundRect(555, 210, 175, 250, 10, 10);
  814.         g.setColor(Color.WHITE);
  815.         g.drawString(properties.name(), 561, coords[0]);
  816.         g.drawString("Version: " + properties.version(), 561, coords[1]);
  817.         g.drawString("Run Time: " + hours + ":" + nf.format(minutes) + ":" + nf.format(seconds), 561, coords[2]);
  818.         g.drawString("Essence Used: " + essUsed, 561, coords[4]);
  819.         g.drawString("EssUsed/Hour: " + essPerHour, 561, coords[5]);
  820.         g.drawString("Lvls Gained: " + LVLgained, 561, coords[6]);
  821.         g.drawString("XP Gained: " + XPgained, 561, coords[7]);
  822.         g.drawString("XP/Hour: " + XPperHour, 561, coords[8]);
  823.         g.drawString("XP To Next Level: " + xpTilNext, 561, coords[9]);
  824.         g.setColor(new Color(255, 0, 0, 175));
  825.         g.fillRect(560, coords[10] - 11, 165, 13);
  826.         g.setColor(new Color(0, 255, 0, 200));
  827.         g.fillRect(560, coords[10] - 11, fillBar, 13);
  828.         g.setColor(Color.WHITE);
  829.         g.drawString(percentTilNext + "%", 561, coords[10]);
  830.         g.drawString("Pouches Fixed "+pouchesFixxed+ " times.", 561, coords[11]);
  831.         g.drawString("Cash banked: " + moneyBanked, 561, coords[12]);
  832.         g.drawString("Cash used: " + tCashUsed, 561, coords[13]);
  833.         g.drawString("Profit made: " + profitMade, 561, coords[14]);
  834.     }
  835. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement