Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 22nd, 2010 | Syntax: None | Size: 54.41 KB | Hits: 59 | Expires: Never
Copy text to clipboard
  1. /*
  2.  
  3. This script has a requirement of crossing the log (like 37ish agility or something, i forget exactly) along with a requirement to picklock the door (47ish thieving).
  4.  
  5.  
  6.  
  7. I've used this script on my main, seems to work well... It sometimes got stuck in a door, though I've added some stuff so he should open it if he's stuck in it. If it still gives problems let me know.
  8.  
  9.  
  10.  
  11. Just a heads up, this place has objects that seem to change/getupdated frequently. I've done my best to get the script working reguardless of how the changes will be made.
  12.  
  13.  
  14.  
  15. The script sometimes does funny things, that aren't superhuman. Since I'm leaving for two years, i don't really have the time or motivation to fix right now.
  16.  
  17.  
  18.  
  19. Edit the pickup ids in pickupids array for it to pickup different items. Currently picks most herbs and runes n stuff.
  20.  
  21. */
  22.  
  23. /*
  24.  
  25.         ArdyDruids.java
  26.  
  27.        
  28.  
  29.         Author:  CamHart
  30.  
  31.         Fixers/Updaters/Improvers: Wolf
  32.  
  33.         Date Created: 5/03/09
  34.  
  35.         Date Modified: 22/03/09
  36.  
  37.         Version: 0.2
  38.  
  39.        
  40.  
  41.         Credits - Look throughout script
  42.  
  43.                
  44.  
  45.         Instructions:
  46.  
  47.                 *33 Agility and 46 Thieving required.  Doesn't eat.
  48.  
  49.                        
  50.  
  51.         Notes
  52.  
  53.                 *add special attack support
  54.  
  55.                
  56.  
  57.         Updates
  58.  
  59.         0.1 - Added auto update check feature.
  60.  
  61.                        
  62.  
  63. */
  64.  
  65.  
  66.  
  67. import java.awt.Color;
  68.  
  69. import java.awt.Graphics;
  70.  
  71. import java.awt.Point;
  72.  
  73. import java.util.List;
  74.  
  75. import java.util.ArrayList;
  76.  
  77. import java.util.Map;
  78.  
  79. import java.net.URL;
  80.  
  81. import java.io.*;
  82.  
  83.  
  84.  
  85.  
  86. import org.rsbot.script.Script;
  87.  
  88. import org.rsbot.script.wrappers.RSNPC;
  89.  
  90. import org.rsbot.script.Calculations;
  91. import org.rsbot.script.wrappers.RSObject;
  92.  
  93. import org.rsbot.script.wrappers.RSTile;
  94.  
  95. import org.rsbot.script.wrappers.RSItem;
  96.  
  97. import org.rsbot.bot.Bot;
  98. import org.rsbot.event.listeners.PaintListener;
  99. import org.rsbot.event.listeners.ServerMessageListener;
  100. import org.rsbot.event.events.ServerMessageEvent;
  101.  
  102. import org.rsbot.script.wrappers.RSItemTile;
  103. import org.rsbot.script.ScriptManifest;
  104.  
  105.  
  106.  
  107. @ScriptManifest(authors = {"CamHart"},
  108.         category = "Combat",
  109.         name = "Ardy Druids",
  110.         version = 1.2,
  111.         description = "<html><body><head><style type=\"text/css\"> hr {color: white} p {margin-left: 15px}</style></head>" +
  112.                 "<center><b>Ardy Druids</b> Fixed by waterwolf <b>1.2</b></center<br>" +
  113.                 "Kills druids n stuff.<br>" +
  114.                 "Must have 33 agility and 46 thieving.<br>" +
  115.                 "Picks up Herbs and anything else if value, if you want to change ids do so yourself." +
  116.                 "If pickup style 1 picks up bad items (bones, coins, etc), then change it to 2." +
  117.                 "<b>Instructions</b><br>" +
  118.                 "Start anywhere from Ardy North bank to druid tower. <br>" +
  119.                 "PickUp Style:<select name=\"pickup\"><option selected value=\"1\">Pickup Style 1</option>" +
  120.                 "<option value=\"2\">Pickup Style 2</option></select> [Change to style 2 if 1 picks bad items]<br>" +
  121.                 "<input type=\"checkbox\" name=\"antiban\" value=\"true\" checked=\"checked\">Use Script AntiBan<br>" +
  122.                 "<input type=\"checkbox\" name=\"update\" value=\"true\" checked=\"checked\">Check for Update<br>" +
  123.                 "Loop Delay:<input type=\"text\" name=\"slowCPU\" size=6>&nbsp [optional - increase if the script lags your computer (default 10)]" +
  124.                 "</body></html>")      
  125. public class ArdyDruids extends Script implements PaintListener,        ServerMessageListener { // Names the script
  126.  
  127.  
  128.  
  129.         long startTime = -1;
  130.  
  131.        
  132.  
  133.         int slowCPU = 10;
  134.  
  135.         int mouseSpeed = 10; //lower = faster
  136.  
  137.        
  138.  
  139.         int errorsFound = 0;
  140.  
  141.         long lastError = 0;
  142.  
  143.        
  144.  
  145.         double newestVersion = -0.1;
  146.  
  147.         boolean useAntiBan = true;     
  148.  
  149.         String status = "Starting up...";
  150.  
  151.         String debug = "";
  152.  
  153.         int valueOfBankedItems = 0;
  154.  
  155.        
  156.  
  157.         boolean pickUpOption = true;
  158.  
  159.        
  160.  
  161.         boolean canUpdate = false;
  162.  
  163.        
  164.  
  165.         public class GELoader extends Thread {
  166.  
  167.                 public GELoader() {
  168.  
  169.                        
  170.  
  171.                 }
  172.  
  173.                 @Override
  174.  
  175.                 public void run() {
  176.  
  177.                         debug = "Loading GE item values";
  178.  
  179.                         int loaddots = 0;
  180.  
  181.                         for(int c = 0; c < GEVALUES.length; c++) {
  182.  
  183.                                 GEVALUES[c] = grandExchange.loadItemInfo(PICKUPIDS[c]).getMarketPrice() ;
  184.  
  185.                                 debug += ".";
  186.  
  187.                                 loaddots++;
  188.  
  189.                                 if(loaddots > 3) {
  190.  
  191.                                         debug = "Loading GE item values (" + c + ")";          
  192.  
  193.                                         loaddots = 0;
  194.  
  195.                                 }
  196.  
  197.                         }
  198.  
  199.                         doneLoading = true;
  200.  
  201.                 }
  202.  
  203.                
  204.  
  205.         }
  206.  
  207.        
  208.  
  209.         boolean doneLoading = false;
  210.  
  211.  
  212.  
  213.         @Override
  214.  
  215.         public boolean onStart(Map<String, String> args) {
  216.  
  217.                 //newestVersion = ;     this doesnt work
  218.  
  219.                 GELoader theGE = new GELoader();
  220.  
  221.                 theGE.start();
  222.  
  223.                 startTime = System.currentTimeMillis();
  224.  
  225.         String temp = args.get("slowCPU").replaceAll(" ", "");         
  226.  
  227.         if(!temp.equals(null) && !temp.equals("")) {
  228.  
  229.                 if(isNumeric(temp)) {
  230.  
  231.                         slowCPU = Integer.parseInt(temp);
  232.  
  233.                         log("CPU slower set to " + slowCPU + ".");
  234.  
  235.                 }
  236.  
  237.                 else {
  238.  
  239.                         log("cpuSlow:" + temp.replaceAll(" ", "."));
  240.  
  241.                         log("Loop delay must be an integer value!");
  242.  
  243.                         return false;
  244.  
  245.                 }
  246.  
  247.         }
  248.  
  249.        
  250.  
  251.         temp = args.get("pickup");
  252.  
  253.         if(temp.contains("1"))
  254.  
  255.                 pickUpOption = true;
  256.  
  257.         else pickUpOption = false;
  258.  
  259.        
  260.  
  261.         if(args.get("antiban") !=  null) {
  262.  
  263.                 useAntiBan = true;
  264.  
  265.                 log("Antiban            enabled");
  266.  
  267.         } else {
  268.  
  269.                 useAntiBan = false;
  270.  
  271.                 log("Antiban            disabled");
  272.  
  273.         }              
  274.  
  275.         if(args.get("update") != null) {
  276.  
  277.                 canUpdate = true;
  278.  
  279.         } else {
  280.  
  281.                 canUpdate = false;
  282.  
  283.                 //log("Picking Priority   disabled");
  284.  
  285.         }      
  286.  
  287.         log("Ardy Druids has started...");
  288.  
  289.         return true;
  290.  
  291.         }
  292.  
  293.  
  294.  
  295.         @Override
  296.  
  297.         public void onFinish() {
  298.  
  299.                 //theAniWatch().stop();
  300.  
  301.                 Bot.getEventManager().removeListener(PaintListener.class, this);
  302.  
  303.                 Bot.getEventManager().removeListener(ServerMessageListener.class, this);
  304.  
  305.         }
  306.  
  307.  
  308.  
  309.         public void serverMessageRecieved(ServerMessageEvent e) {
  310.  
  311.         }
  312.  
  313.  
  314.  
  315.         public void onRepaint(Graphics g) {
  316.  
  317.                 if (isLoggedIn()) {
  318.  
  319.  
  320.  
  321.                         long millis = System.currentTimeMillis() - startTime;
  322.  
  323.                         long oMillis = millis;
  324.  
  325.                         long hours = millis / (1000 * 60 * 60);
  326.  
  327.                         millis -= hours * (1000 * 60 * 60);
  328.  
  329.                         long minutes = millis / (1000 * 60);
  330.  
  331.                         millis -= minutes * (1000 * 60);
  332.  
  333.                         long seconds = millis / 1000;
  334.  
  335.  
  336.  
  337.                         int theYspot = 332;
  338.  
  339.                         g.setColor(new Color(0, 0, 0));
  340.  
  341.                         //replace 4 w/ number of strings being printed
  342.  
  343.                         //g.fill3DRect(6, theYspot - (4 * 15) , 190, (4 * 15) + 6, true);
  344.  
  345.                        
  346.  
  347.                         g.setColor(new Color(255, 255, 255));
  348.  
  349.                         g.drawString("Ardy Druids v1.2", 9, theYspot); 
  350.  
  351.                         /*if(newestVersion > getVersion()) {   
  352.  
  353.                                 g.drawString("Please visit the link in the script description to update.", 9, theYspot-=15);                   
  354.  
  355.                                 g.drawString(getName() + " has been updated to version " + newestVersion + ", your " + (int)((newestVersion - getVersion()) * 10) + " updates behind!", 9, theYspot-=15);
  356.  
  357.                         }                               Theres no site to update this crap */  
  358.  
  359.                         g.drawString("RunTime: " + (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds), 9, theYspot-=15);     
  360.  
  361.                         if(doneLoading) {
  362.  
  363.                                 g.drawString("Estimated Profit:" + (valueOfBankedItems + getInventoryValue()), 9, theYspot-=15);
  364.  
  365.                                 g.drawString("Profit / hour:" + (int)((valueOfBankedItems + getInventoryValue()) * 3600000D / (double)oMillis), 9, theYspot-=15);
  366.  
  367.                         }
  368.  
  369.                         g.drawString("Status: " + status, 9, theYspot-=15);
  370.  
  371.                        
  372.  
  373.                         //g.drawString(((getMyPlayer().isInCombat() == true) ? "in combat" : " ---- ") + " : " + ((inCombat() == true) ? "in combat" : " ---- "), 9, theYspot-=15);
  374.  
  375.                        
  376.  
  377.                         g.drawString("Debug(" + getMouseSpeed() + "): " + debug, 9, theYspot-=15);
  378.  
  379.                 }
  380.  
  381.         }
  382.  
  383.  
  384.  
  385.         /* Credits to Ruski on these Ids */
  386.  
  387.         //If you add to the foodids add to the depositallexcept command also
  388.  
  389.         // UNCOMMENT BELOW to get foodids
  390.        
  391.         /*private final int[] FOODID = { 1895, 1893, 1891, 4293, 2142, 291, 2140,
  392.  
  393.                         3228, 9980, 7223, 6297, 6293, 6295, 6299, 7521, 9988, 7228, 2878,
  394.  
  395.                         7568, 2343, 1861, 13433, 315, 325, 319, 3144, 347, 355, 333, 339,
  396.  
  397.                         351, 329, 3381, 361, 10136, 5003, 379, 365, 373, 7946, 385, 397,
  398.  
  399.                         391, 3369, 3371, 3373, 2309, 2325, 2333, 2327, 2331, 2323, 2335,
  400.  
  401.                         7178, 7180, 7188, 7190, 7198, 7200, 7208, 7210, 7218, 7220, 2003,
  402.  
  403.                         2011, 2289, 2291, 2293, 2295, 2297, 2299, 2301, 2303, 1891, 1893,
  404.  
  405.                         1895, 1897, 1899, 1901, 7072, 7062, 7078, 7064, 7084, 7082, 7066,
  406.  
  407.                         7068, 1942, 6701, 6703, 7054, 6705, 7056, 7060, 2130, 1985, 1993,
  408.  
  409.                         1989, 1978, 5763, 5765, 1913, 5747, 1905, 5739, 1909, 5743, 1907,
  410.  
  411.                         1911, 5745, 2955, 5749, 5751, 5753, 5755, 5757, 5759, 5761, 2084,
  412.  
  413.                         2034, 2048, 2036, 2217, 2213, 2205, 2209, 2054, 2040, 2080, 2277,
  414.  
  415.                         2225, 2255, 2221, 2253, 2219, 2281, 2227, 2223, 2191, 2233, 2092,
  416.  
  417.                         2032, 2074, 2030, 2281, 2235, 2064, 2028, 2187, 2185, 2229, 6883,
  418.  
  419.                         1971, 4608, 1883, 1885 };
  420. */
  421.         private int[] NPCDEATHANIMATION = {836};
  422.  
  423.         //laws, vials = 227
  424.  
  425.         private int[] PICKUPIDS = {563, 556, 558, 561, 227, 2485, 2486, 3049, 3050,
  426.  
  427.                 3051, 3052, 12174, 12175, 199, 200, 201, 202, 203, 204, 205, 206, 207,
  428.  
  429.                 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220,    
  430.  
  431.                 830, 5647, 836, 5653, 5714, 5715, 5728, 5729, 1247, 1248, 1261, 1262,
  432.  
  433.                 3175, 5730, 5731, 1249, 1250, 1263, 1264, 3176, 5716, 5717, 5730, 5731,
  434.  
  435.                 554, 557, 562, 560, 985, 986, 987, 988, 1623, 1621, 1619, 1617, 1618,
  436.  
  437.                 2366, 2367, 2368, 2369, 231, 232, 1462, 1463, 1452, 1453};
  438.  
  439.                
  440.  
  441.         private int[] GEVALUES = new int[PICKUPIDS.length];
  442.  
  443.                        
  444.  
  445.         private final int[] BANKIDS = {34752};
  446.  
  447.                        
  448.  
  449.         private final RSTile[] TOLOG = {
  450.  
  451.                 new RSTile(2614, 3333), new RSTile(2609, 3337), new RSTile(2603, 3336)
  452.  
  453.         };
  454.  
  455.                
  456.  
  457.         private final RSTile[] TOTOWER = {
  458.  
  459.                 new RSTile(2598, 3336), new RSTile(2594, 3340), new RSTile(2587, 3343),
  460.  
  461.                 new RSTile(2582, 3345), new RSTile(2579, 3348), new RSTile(2575, 3351),
  462.  
  463.                 new RSTile(2571, 3355), new RSTile(2565, 3356)                 
  464.  
  465.         };
  466.  
  467.        
  468.  
  469.         private final RSTile[] TOTOWERCHKPTS = {
  470.  
  471.                 new RSTile(2598, 3336), new RSTile(2595, 3339), new RSTile(2585, 3344),
  472.  
  473.                 new RSTile(2576, 3350), new RSTile(2565, 3356)
  474.  
  475.         };
  476.  
  477.        
  478.  
  479.         int doorError = 0;
  480.  
  481.         long lastDoor = 0;
  482.  
  483.         int logError = 0;
  484.  
  485.         long lastLog = 0;
  486.  
  487.         int bankError = 0;
  488.  
  489.         long lastBank = 0;
  490.  
  491.        
  492.  
  493.         //See if upstairs
  494.  
  495.         int missClicks = 0;
  496.  
  497.         long lastMiss = 0;
  498.  
  499.        
  500.  
  501.         long badLadder = 0;
  502.  
  503.         //long Ladder = 0;
  504.  
  505.        
  506.  
  507.         @Override
  508.  
  509.         public int loop() {
  510.  
  511.        
  512.  
  513.                 if(skills.getCurrSkillLevel(3) <= 10) {
  514.  
  515.                         log("Your hitpoints are at, or below, 10.  Stopping script.");
  516.  
  517.                         stopScript();
  518.  
  519.                 }
  520.  
  521.                 /*if(System.currentTimeMillis() - badLadder > rand(60000, 60000 * 30) && ) {
  522.  
  523.                         setCameraAltitude(true);
  524.  
  525.                 }*/
  526.  
  527.                 if(getMyPlayer().getLocation().getY() > 8000) {
  528.  
  529.                         if(!getMyPlayer().isIdle())
  530.  
  531.                                 return antiBan(rand(1250, 1500));
  532.  
  533.                         if(System.currentTimeMillis() - badLadder > rand(3000, 8000))
  534.  
  535.                                 setCameraAltitude(true);
  536.  
  537.                         badLadder = System.currentTimeMillis();                        
  538.  
  539.                         RSObject theLadder = getNearestObjectByID(32015);
  540.  
  541.                         if(theLadder == null) {
  542.  
  543.                                 log("Couldn't find ladder to climb up, logging out...");
  544.  
  545.                                 stopScript();
  546.  
  547.                         }
  548.  
  549.                         else {
  550.  
  551.                                 if(random(0, 2) == 0)
  552.  
  553.                                         turnToObject(theLadder);
  554.  
  555.                                 else if(random(0, 3) == 3)
  556.  
  557.                                         setCameraRotation(getCameraAngle() + (random(0, 1) == 0 ? random(-4, -20) : random(4, 20)));
  558.  
  559.                                 wait(rand(150, 350));
  560.  
  561.                                 if(!atObject(theLadder, "Climb-up")) {
  562.  
  563.                                         myWalk(new RSTile(2562, 9757), 0, false);
  564.  
  565.                                         wait(rand(2000, 3000));
  566.  
  567.                                         turnToTile(new RSTile(2562, 9757));
  568.  
  569.                                 }
  570.  
  571.                         }
  572.  
  573.                 }
  574.  
  575.                 if(getPlane() == 1)     {  //getMyPlayer().getHeight() == 1) {
  576.  
  577.                         if(System.currentTimeMillis() - badLadder > rand(3000, 8000))
  578.  
  579.                                 setCameraAltitude(true);
  580.  
  581.                         badLadder = System.currentTimeMillis();                        
  582.  
  583.                         RSObject theLadder = getObjectAt(2560, 3356); //.findObject(1750);
  584.  
  585.                         if(theLadder == null) {
  586.  
  587.                                 log("You're lost, logging out...");
  588.  
  589.                                 stopScript();
  590.  
  591.                         }
  592.  
  593.                         else {
  594.  
  595.                                 if(random(0, 1) == 1)
  596.  
  597.                                         turnToObject(theLadder);
  598.  
  599.                                 if(random(0, 5) == 3)                          
  600.  
  601.                                         setCameraRotation(getCameraAngle() + (random(0, 1) == 0 ? random(-4, -20) : random(4, 20)));
  602.  
  603.                                 wait(rand(150, 350));
  604.  
  605.                                 atObject(theLadder, "Climb-down");
  606.  
  607.                         }
  608.  
  609.                 }
  610.  
  611.                 else if(getInventoryCount() < 28 && !atDruids()) {
  612.  
  613.                         log("a");
  614.  
  615.                         if(getMyPlayer().getLocation().getX() > 2600) { //2600 divides the river
  616.  
  617.                                 status = "Walking to log...";
  618.  
  619.                                 //bank to log
  620.  
  621.                                 //add door enterance                           
  622.  
  623.                                 int posHold = walkToNextTile(TOLOG, -1);
  624.  
  625.                                 if(posHold == 1 || distanceTo(TOLOG[TOLOG.length - 1]) < 15) {
  626.  
  627.                                         if(getMyPlayer().isMoving())
  628.  
  629.                                                 return antiBan(rand(150, 550));
  630.  
  631.                                         RSObject theLog = getNearestObjectByID(35999); //LOGID - bank to otherside
  632.  
  633.                                         if(theLog == null) {
  634.  
  635.                                                 logError++;
  636.  
  637.                                                 if(System.currentTimeMillis() - lastLog > 120000) {
  638.  
  639.                                                         logError = 1;
  640.  
  641.                                                 }
  642.  
  643.                                                 lastLog = System.currentTimeMillis();
  644.  
  645.                                                 if(logError > 60) {
  646.  
  647.                                                         log("Log cannot be found...  Stopping script.");
  648.  
  649.  
  650.                                                         stopScript();                                                  
  651.  
  652.                                                 }
  653.  
  654.                                         }
  655.  
  656.                                         else {
  657.  
  658.                                                 status = "Crossing log...";
  659.  
  660.                                                 if(getMyPlayer().isMoving()) {
  661.  
  662.                                                         wait(antiBan(rand(450, 750)));
  663.  
  664.                                                 }
  665.  
  666.                                                 if(distanceTo(TOLOG[TOLOG.length - 1]) > random(1, 4) && distanceTo(TOLOG[TOLOG.length - 1]) < 16)
  667.  
  668.                                                         myWalk(TOLOG[TOLOG.length - 1]);
  669.  
  670.                                                 if(atObject(theLog, "Walk-across")) {
  671.  
  672.                                                         logError = 0;
  673.  
  674.                                                         return antiBan(rand(1500, 3000));
  675.  
  676.                                                 }
  677.  
  678.                                                 else {
  679.  
  680.                                                         logError++;
  681.  
  682.                                                         if(System.currentTimeMillis() - lastLog > 120000) {
  683.  
  684.                                                                 logError = 1;
  685.  
  686.                                                         }
  687.  
  688.                                                         lastLog = System.currentTimeMillis();
  689.  
  690.                                                         if(logError > 1)
  691.  
  692.                                                                 turnToObject(theLog);
  693.  
  694.                                                         if(logError > 60) {
  695.  
  696.                                                                 log("Log cannot be found...  Stopping script.");
  697.  
  698.                                                                 log("If character got stuck please PM CamHart with a screen shot.");
  699.  
  700.                                                                 stopScript();                                                  
  701.  
  702.                                                         }                                              
  703.  
  704.                                                 }
  705.  
  706.                                         }
  707.  
  708.                                 }
  709.  
  710.                         } else if(getMyPlayer().getLocation().getX() < 2600) {
  711.  
  712.                                 status = "Walking to tower...";
  713.  
  714.                                 if(!canReach(new RSTile(2592, 3339),false) && canReach(new RSTile(2592, 3338), false)) {
  715.  
  716.                                         RSObject theDoor = getNearestObjectByID(2054);
  717.  
  718.                                         if(theDoor == null || !atObject(theDoor, "Open")) {
  719.  
  720.                                                 doorError++;
  721.  
  722.                                                 if(System.currentTimeMillis() - lastDoor > 120000) {
  723.  
  724.                                                         doorError = 1;
  725.  
  726.                                                 }
  727.  
  728.                                                 lastDoor = System.currentTimeMillis();
  729.  
  730.                                                 if(doorError > 5)
  731.  
  732.                                                         //turnToTile(new RSTile(getMyPlayer().getLocation().getX() + 1, getMyPlayer().getLocation().getY()));
  733.  
  734.                                                         turnToObject(theDoor);
  735.  
  736.                                                 if(doorError > 10)
  737.  
  738.                                                         //setCameraAltitude(false);
  739.  
  740.                                                         setCameraAltitude(random(20, 40));//setCamerAltitude(false)
  741.  
  742.                                                 if(doorError > 60) {
  743.  
  744.                                                         log("Door cannot be found...  Stopping script.");
  745.  
  746.  
  747.                                                         stopScript();                                                  
  748.  
  749.                                                 }      
  750.  
  751.                                         }                                              
  752.  
  753.                                 }
  754.  
  755.                                 int posHold = walkToNextTile(TOTOWER, TOTOWERCHKPTS, -1);//editout
  756.  
  757.                                 if(posHold == 1) {
  758.  
  759.                                         status = "Picking door...";
  760.  
  761.                                         if(getMyPlayer().isMoving()) {
  762.  
  763.                                                 wait(antiBan(rand(450, 750)));
  764.  
  765.                                         }                                      
  766.  
  767.                                         RSObject theDoor = null;
  768.  
  769.                                         try {
  770.  
  771.                                                 theDoor = getObjectAt(2564, 3356); //findObject(1623);
  772.  
  773.                                         } catch (Exception e) {}
  774.  
  775.                                         if(theDoor == null) {
  776.  
  777.                                                 log("null door...");
  778.  
  779.                                                 try {
  780.  
  781.                                                         //if(atObject(getObjectAt(2564, 3356), "Pick-lock")) {
  782.  
  783.                                                         if(openDoor(new RSTile(2565, 3356), "Pick-lock")) {
  784.  
  785.                                                                 doorError = 0;
  786.  
  787.                                                                 return antiBan(rand(1250, 1750));
  788.  
  789.                                                         }
  790.  
  791.                                                         else {
  792.  
  793.                                                                 doorError++;
  794.  
  795.                                                                 if(System.currentTimeMillis() - lastDoor > 120000) {
  796.  
  797.                                                                         doorError = 1;
  798.  
  799.                                                                 }
  800.  
  801.                                                                 lastDoor = System.currentTimeMillis();
  802.  
  803.                                                                 if(doorError > 5)
  804.  
  805.                                                                         turnToTile(new RSTile(getMyPlayer().getLocation().getX() + 1, getMyPlayer().getLocation().getY()));
  806.  
  807.                                                                 if(doorError > 10)
  808.  
  809.                                                                         //setCameraAltitude(false);
  810.  
  811.                                                                         setCameraAltitude(random(20, 40));//setCamerAltitude(false)
  812.  
  813.                                                                 if(doorError > 60) {
  814.  
  815.                                                                         log("Door cannot be found...  Stopping script.");
  816.  
  817.  
  818.                                                                         stopScript();                                          
  819.  
  820.                                                                 }                                      
  821.  
  822.                                                                 return antiBan(rand(350, 450));        
  823.  
  824.                                                         }
  825.  
  826.                                                 } catch (Exception e) {}                                       
  827.  
  828.                                                 doorError++;
  829.  
  830.                                                 if(System.currentTimeMillis() - lastDoor > 120000) {
  831.  
  832.                                                         doorError = 1;
  833.  
  834.                                                 }
  835.  
  836.                                                 lastDoor = System.currentTimeMillis();
  837.  
  838.                                                 if(doorError > 5)
  839.  
  840.                                                         turnToTile(new RSTile(getMyPlayer().getLocation().getX() + 1, getMyPlayer().getLocation().getY()));                                                    
  841.  
  842.                                                 if(doorError > 2)
  843.  
  844.                                                         //setCameraAltitude(false);
  845.  
  846.                                                         setCameraAltitude(random(20, 40));//setCamerAltitude(false)
  847.  
  848.                                                 if(doorError > 60) {
  849.  
  850.                                                         log("Door cannot be found...  Stopping script.");
  851.  
  852.  
  853.                                                         stopScript();                                  
  854.  
  855.                                                 }
  856.  
  857.                                         }
  858.  
  859.                                         else {
  860.  
  861.                                                 if(openDoor(theDoor.getLocation(), "Pick-lock")) {
  862.  
  863.                                                         doorError = 0;
  864.  
  865.                                                         return antiBan(rand(1250, 1750));
  866.  
  867.                                                 }
  868.  
  869.                                                 else {
  870.  
  871.                                                         doorError++;
  872.  
  873.                                                         if(System.currentTimeMillis() - lastDoor > 120000) {
  874.  
  875.                                                                 doorError = 1;
  876.  
  877.                                                         }
  878.  
  879.                                                         lastDoor = System.currentTimeMillis();
  880.  
  881.                                                         /*if(doorError > 1)
  882.  
  883.                                                                 turnToObject(theDoor, random(-5, 5));                                                   */
  884.  
  885.                                                         if(doorError > 5)
  886.  
  887.                                                                 turnToTile(new RSTile(getMyPlayer().getLocation().getX() + 1, getMyPlayer().getLocation().getY()));                                                                    
  888.  
  889.                                                         if(doorError > 3)
  890.  
  891.                                                                 //setCameraAltitude(false);
  892.  
  893.                                                                 setCameraAltitude(random(20, 40));//setCamerAltitude(false)
  894.  
  895.                                                         if(doorError > 60) {
  896.  
  897.                                                                 log("Door cannot be found...  Stopping script.");
  898.  
  899.                                                                 log("If character got stuck please PM CamHart with a screen shot.");
  900.  
  901.                                                                 stopScript();                                                  
  902.  
  903.                                                         }                                                      
  904.  
  905.                                                 }
  906.  
  907.                                         }
  908.  
  909.                                 }
  910.  
  911.                                 //log to tower
  912.  
  913.                         }
  914.  
  915.                 }
  916.  
  917.                 else if(getInventoryCount() == 28) {
  918.  
  919.                         if(atDruids()) {
  920.  
  921.                                 status = "Exiting door...";
  922.  
  923.                                 if(getMyPlayer().isMoving()) {
  924.  
  925.                                         wait(antiBan(rand(450, 750)));
  926.  
  927.                                 }                              
  928.  
  929.                                 RSObject theDoor = null;
  930.  
  931.                                 try {
  932.  
  933.                                         theDoor = getObjectAt(2564, 3356); //findObject(1623);
  934.  
  935.                                 } catch (Exception e) {}
  936.  
  937.                                 if(theDoor == null) {
  938.  
  939.                                         try {
  940.  
  941.                                                 //if(atObject(getObjectAt(2564, 3356), "Open")) {
  942.  
  943.                                                 if(openDoor(new RSTile(2564, 3356), "Open")) {//maybe 2563?
  944.  
  945.                                                         return antiBan(rand(1250, 1750));
  946.  
  947.                                                 }
  948.  
  949.                                                 else {
  950.  
  951.                                                         missClicks++;
  952.  
  953.                                                         lastMiss = System.currentTimeMillis();                                         
  954.  
  955.                                                         doorError++;
  956.  
  957.                                                         if(System.currentTimeMillis() - lastDoor > 120000) {
  958.  
  959.                                                                 doorError = 1;
  960.  
  961.                                                         }
  962.  
  963.                                                         lastDoor = System.currentTimeMillis();
  964.  
  965.                                                         if(doorError > 2)
  966.  
  967.                                                                 setCameraAltitude(random(20, 40));//setCamerAltitude(false)
  968.  
  969.                                                         if(doorError > 5)
  970.  
  971.                                                                 turnToTile(new RSTile(getMyPlayer().getLocation().getX() - 1, getMyPlayer().getLocation().getY()));
  972.  
  973.                                                         if(doorError > 60) {
  974.  
  975.                                                                 log("Door cannot be found...  Stopping script.");
  976.  
  977.                                                                 log("If character got stuck please PM CamHart with a screen shot.");
  978.  
  979.                                                                 stopScript();                                                  
  980.  
  981.                                                         }                                                      
  982.  
  983.                                                 }                                      
  984.  
  985.                                         } catch (Exception e) {}
  986.  
  987.                                         doorError++;
  988.  
  989.                                         if(System.currentTimeMillis() - lastDoor > 120000) {
  990.  
  991.                                                 doorError = 1;
  992.  
  993.                                         }
  994.  
  995.                                         lastDoor = System.currentTimeMillis();
  996.  
  997.                                         if(doorError > 60) {
  998.  
  999.                                                 log("Door cannot be found...  Stopping script.");
  1000.  
  1001.                                                 log("If character got stuck please PM CamHart with a screen shot.");
  1002.  
  1003.                                                 stopScript();                                                  
  1004.  
  1005.                                         }
  1006.  
  1007.                                 }
  1008.  
  1009.                                 else {
  1010.  
  1011.                                         if(openDoor(theDoor.getLocation(), "Open")) {
  1012.  
  1013.                                                 return antiBan(rand(1250, 1750));
  1014.  
  1015.                                         }
  1016.  
  1017.                                         else {
  1018.  
  1019.                                                 missClicks++;
  1020.  
  1021.                                                 lastMiss = System.currentTimeMillis();                                         
  1022.  
  1023.                                                 doorError++;
  1024.  
  1025.                                                 if(System.currentTimeMillis() - lastDoor > 120000) {
  1026.  
  1027.                                                         doorError = 1;
  1028.  
  1029.                                                 }
  1030.  
  1031.                                                 lastDoor = System.currentTimeMillis();
  1032.  
  1033.                                                 if(doorError > 2)
  1034.  
  1035.                                                         setCameraAltitude(random(20, 40));//setCamerAltitude(false)
  1036.  
  1037.                                                 if(doorError > 5)
  1038.  
  1039.                                                         turnToTile(new RSTile(getMyPlayer().getLocation().getX() - 1, getMyPlayer().getLocation().getY()));                                                    
  1040.  
  1041.                                                 if(doorError > 60) {
  1042.  
  1043.                                                         log("Door cannot be found...  Stopping script.");
  1044.  
  1045.                                                         log("If character got stuck please PM CamHart with a screen shot.");
  1046.  
  1047.                                                         stopScript();                                                  
  1048.  
  1049.                                                 }                                                      
  1050.  
  1051.                                         }
  1052.  
  1053.                                 }
  1054.  
  1055.                         }
  1056.  
  1057.                         else if(getMyPlayer().getLocation().getX() < 2600) {
  1058.  
  1059.                                 status = "Walking to log...";
  1060.  
  1061.                                 if(getMyPlayer().isMoving()) {
  1062.  
  1063.                                         wait(antiBan(rand(450, 750)));
  1064.  
  1065.                                 }                              
  1066.  
  1067.                                 if(!canReach(new RSTile(2592, 3339), false) && canReach(new RSTile(2592, 3338), false)) {
  1068.  
  1069.                                         RSObject theDoor = getNearestObjectByID(2054);
  1070.  
  1071.                                         if(theDoor == null || !atObject(theDoor, "Open")) {
  1072.  
  1073.                                                 doorError++;
  1074.  
  1075.                                                 if(System.currentTimeMillis() - lastDoor > 120000) {
  1076.  
  1077.                                                         doorError = 1;
  1078.  
  1079.                                                 }
  1080.  
  1081.                                                 lastDoor = System.currentTimeMillis();
  1082.  
  1083.                                                 if(doorError > 5)
  1084.  
  1085.                                                         //turnToTile(new RSTile(getMyPlayer().getLocation().getX() + 1, getMyPlayer().getLocation().getY()));
  1086.  
  1087.                                                         turnToObject(theDoor);
  1088.  
  1089.                                                 if(doorError > 10)
  1090.  
  1091.                                                         //setCameraAltitude(false);
  1092.  
  1093.                                                         setCameraAltitude(random(20, 40));//setCamerAltitude(false)
  1094.  
  1095.                                                 if(doorError > 60) {
  1096.  
  1097.                                                         log("Door cannot be found...  Stopping script.");
  1098.  
  1099.                                                         log("If character got stuck please PM CamHart with a screen shot.");
  1100.  
  1101.                                                         stopScript();                                                  
  1102.  
  1103.                                                 }      
  1104.  
  1105.                                         }                                              
  1106.  
  1107.                                 }                              
  1108.  
  1109.                                 int posHold = walkToNextTile(reversePath(TOTOWER), reversePath(TOTOWERCHKPTS), -1);
  1110.  
  1111.                                 if(posHold == 1 || distanceTo(reversePath(TOTOWER)[TOTOWER.length - 1]) < 15) {
  1112.  
  1113.                                         if(getMyPlayer().isMoving())
  1114.  
  1115.                                                 return antiBan(rand(150, 550));                        
  1116.  
  1117.                                         RSObject theLog = getNearestObjectByID(35997); //LOGID - tower to otherside
  1118.  
  1119.                                         if(theLog == null) {
  1120.  
  1121.                                                 logError++;
  1122.  
  1123.                                                 if(System.currentTimeMillis() - lastLog > 120000) {
  1124.  
  1125.                                                         logError = 1;
  1126.  
  1127.                                                 }
  1128.  
  1129.                                                 lastLog = System.currentTimeMillis();
  1130.  
  1131.                                                 if(logError > 60) {
  1132.  
  1133.                                                         log("Log cannot be found...  Stopping script.");
  1134.  
  1135.                                                         log("If character got stuck please PM CamHart with a screen shot.");
  1136.  
  1137.                                                         stopScript();                                                  
  1138.  
  1139.                                                 }
  1140.  
  1141.                                         }
  1142.  
  1143.                                         else {
  1144.  
  1145.                                                 status = "Crossing log...";
  1146.  
  1147.                                                 if(getMyPlayer().isMoving()) {
  1148.  
  1149.                                                         wait(antiBan(rand(450, 750)));
  1150.  
  1151.                                                 }                      
  1152.  
  1153.                                                 if(distanceTo(reversePath(TOLOG)[TOLOG.length - 1]) > random(1, 4) && distanceTo(reversePath(TOLOG)[TOLOG.length - 1]) < 16)
  1154.  
  1155.                                                         myWalk(reversePath(TOLOG)[TOLOG.length - 1]);                                                  
  1156.  
  1157.                                                 if(atObject(theLog, "Walk-across")) {
  1158.  
  1159.                                                         logError = 0;
  1160.  
  1161.                                                         return antiBan(rand(1500, 3000));
  1162.  
  1163.                                                 }
  1164.  
  1165.                                                 else {
  1166.  
  1167.                                                         logError++;
  1168.  
  1169.                                                         if(System.currentTimeMillis() - lastLog > 120000) {
  1170.  
  1171.                                                                 logError = 1;
  1172.  
  1173.                                                         }
  1174.  
  1175.                                                         lastLog = System.currentTimeMillis();
  1176.  
  1177.                                                         if(logError > 1)
  1178.  
  1179.                                                                 turnToObject(theLog);
  1180.  
  1181.                                                         if(logError > 60) {
  1182.  
  1183.                                                                 log("Log cannot be found...  Stopping script.");
  1184.  
  1185.                                                                 log("If character got stuck please PM CamHart with a screen shot.");
  1186.  
  1187.                                                                 stopScript();                                                  
  1188.  
  1189.                                                         }                                              
  1190.  
  1191.                                                 }
  1192.  
  1193.                                         }
  1194.  
  1195.                                         return 1000;
  1196.  
  1197.                                 }
  1198.  
  1199.                         }
  1200.  
  1201.                         else if(!atBank()) {
  1202.  
  1203.                                 walkToNextTile(reversePath(TOLOG), -1);                        
  1204.  
  1205.                         }
  1206.  
  1207.                         else if(atBank()) {
  1208.  
  1209.                                 status = "Banking...";
  1210.  
  1211.                                 RSObject theBank = getNearestObjectByID(BANKIDS);
  1212.  
  1213.                                 if(myDistanceBetween(2614, 3333) > 5) {
  1214.  
  1215.                                         myWalk(2614, 3333, 1);
  1216.  
  1217.                                         return antiBan(rand(750, 1250));
  1218.  
  1219.                                 }
  1220.  
  1221.                                 if(bank.isOpen()) {
  1222.  
  1223.                                         int tempValue = getInventoryValue();
  1224.  
  1225.                                         if(bank.depositAll()) {
  1226.  
  1227.                                                 valueOfBankedItems += tempValue;
  1228.  
  1229.                                                 wait(rand(150, 1250));
  1230.  
  1231.                                                 if(random(5, 15) > random(7, 8))
  1232.  
  1233.                                                         bank.close();
  1234.  
  1235.                                         }
  1236.  
  1237.                                 }
  1238.  
  1239.                                 else if(theBank != null) {
  1240.  
  1241.                                         if(atObject(theBank, "Use-quickly"))
  1242.  
  1243.                                                 return rand(550, 750);
  1244.  
  1245.                                         else {
  1246.  
  1247.                                                 bankError++;
  1248.  
  1249.                                                 if(System.currentTimeMillis() - lastBank > 120000) {
  1250.  
  1251.                                                         bankError = 1;
  1252.  
  1253.                                                 }
  1254.  
  1255.                                                 if(bankError > random(0, 3))
  1256.  
  1257.                                                         turnToObject(theBank);
  1258.  
  1259.                                                 if(bankError > 60) {
  1260.  
  1261.                                                         log("Problems clicking bank...  stopping script.");
  1262.  
  1263.                                                         stopScript();
  1264.  
  1265.                                                 }                                              
  1266.  
  1267.                                                 lastBank = System.currentTimeMillis();
  1268.  
  1269.                                         }
  1270.  
  1271.                                 }
  1272.  
  1273.                                 else {
  1274.  
  1275.                                         bankError++;
  1276.  
  1277.                                         if(System.currentTimeMillis() - lastBank > 120000) {
  1278.  
  1279.                                                 bankError = 1;
  1280.  
  1281.                                         }
  1282.  
  1283.                                         lastBank = System.currentTimeMillis();                                 
  1284.  
  1285.                                 }
  1286.  
  1287.                         }
  1288.  
  1289.                        
  1290.  
  1291.                 }
  1292.  
  1293.                 else if(atDruids()) {
  1294.  
  1295.                         //status = "At druids...";
  1296.  
  1297.                         if(getMyPlayer().isMoving())
  1298.  
  1299.                                 return antiBan(rand(450, 750));
  1300.  
  1301.                         RSItemTile theItem = getGroundItemByID(10, PICKUPIDS); //getNearestGroundItemByID
  1302.  
  1303.                         RSNPC theNpc = getNearestFreeNPCByID(181); //chaos druid id
  1304.  
  1305.                         if(theItem != null) {
  1306.  
  1307.                                 debug = "Picking!";
  1308.  
  1309.                                 if(isMenuOpen() && !inArray("Take", getMenuItems())) {
  1310.  
  1311.                                         debug = " [trashing bad menu]";
  1312.  
  1313.                                         moveMouse(random(0, 764), random(0, 502));
  1314.  
  1315.                                 }
  1316.  
  1317.                                 if(!atGroundItem(theItem)) {
  1318.  
  1319.                                         missClicks++;
  1320.  
  1321.                                         if(missClicks > 10) {
  1322.  
  1323.                                                 setCameraRotation(getCameraAngle() + (random(0, 1) == 1 ? random(-10, -30) : random(10, 30)));
  1324.  
  1325.                                                 missClicks = 0;
  1326.  
  1327.                                         }
  1328.  
  1329.                                         lastMiss = System.currentTimeMillis();
  1330.  
  1331.                                 }
  1332.  
  1333.                                 return antiBan(rand(150, 350));
  1334.  
  1335.                         } else if(theNpc != null && !inArray(theNpc.getAnimation(), NPCDEATHANIMATION) && !inCombat()) {
  1336.  
  1337.                                 status = "Killing druids...";
  1338.  
  1339.                                 if(clickNPC(theNpc, "Attack")) {
  1340.  
  1341.                                         debug = "Attacking!";
  1342.  
  1343.                                 }
  1344.  
  1345.                                 else {
  1346.  
  1347.                                         missClicks++;                          
  1348.  
  1349.                                         lastMiss = System.currentTimeMillis();                                 
  1350.  
  1351.                                 }
  1352.  
  1353.                         }
  1354.  
  1355.                 }
  1356.  
  1357.                 return antiBan(rand(350, 550));
  1358.  
  1359.         }
  1360.  
  1361.        
  1362.  
  1363.         public boolean openDoor(RSTile theDoor, String command) {
  1364.  
  1365.                 log("blah");
  1366.  
  1367.                 if(!pointOnScreen(Calculations.tileToScreen(theDoor))) {
  1368.  
  1369.                         log("asdf");
  1370.  
  1371.                         if(!tileOnMap(theDoor))
  1372.  
  1373.                                 log("Door not on map...");
  1374.  
  1375.                         else {
  1376.  
  1377.                                 log("wth");
  1378.  
  1379.                                 myWalk(theDoor, 1, true);
  1380.  
  1381.                                 return false;
  1382.  
  1383.                         }
  1384.  
  1385.                 } else {
  1386.  
  1387.                         log("moving...");
  1388.  
  1389.                         Point newPoint = Calculations.tileToScreen(theDoor);
  1390.  
  1391.                         newPoint.setLocation(newPoint.getX(), newPoint.getY() - random(35, 55));
  1392.  
  1393.                         moveMouse(newPoint);
  1394.  
  1395.                         if(inMenuOptions(command)) {
  1396.  
  1397.                                 log("donit");
  1398.  
  1399.                                 clickMouse(false);
  1400.  
  1401.                                 return atMenu(command);
  1402.  
  1403.                         }
  1404.  
  1405.                 }
  1406.  
  1407.                 return false;
  1408.  
  1409.         }
  1410.  
  1411.        
  1412.  
  1413.         public int getInventoryValue() {
  1414.  
  1415.                 int value = 0;
  1416.  
  1417.                 RSItem[] rsInvyItems = getInventoryItems();
  1418.  
  1419.                 int[] invyItems = getInventoryArray();
  1420.  
  1421.                 for(int c = 0; c < invyItems.length; c++) {
  1422.  
  1423.                         if(inArray(invyItems[c], PICKUPIDS)) {
  1424.  
  1425.                                 try {
  1426.  
  1427.                                         int index = getIndexInArray(invyItems[c], PICKUPIDS);
  1428.  
  1429.                                         if(index != -1)
  1430.  
  1431.                                                 value += (GEVALUES[index] * rsInvyItems[c].getStackSize());
  1432.  
  1433.                                         else if(debug.indexOf(" [bad item]") < 0)
  1434.  
  1435.                                                 debug += " [bad item]";
  1436.  
  1437.                                 } catch (NullPointerException e) {
  1438.  
  1439.                                         log("Something screwed up in getting item value...");
  1440.  
  1441.                                 }
  1442.  
  1443.                         }
  1444.  
  1445.                 }
  1446.  
  1447.                 return value;
  1448.  
  1449.         }
  1450.  
  1451.        
  1452.  
  1453.         /* returns -1 if not found*/   
  1454.  
  1455.         public int getIndexInArray(int value, int[] stuff) {
  1456.  
  1457.                 int retval = -1;
  1458.  
  1459.                 for(int c = 0; c < stuff.length; c++) {
  1460.  
  1461.                         if(stuff[c] == value) {
  1462.  
  1463.                                 retval = c;
  1464.  
  1465.                                 return retval;
  1466.  
  1467.                         }
  1468.  
  1469.                 }
  1470.  
  1471.                 return retval;
  1472.  
  1473.         }
  1474.  
  1475.        
  1476.  
  1477.         public boolean atDruids() {
  1478.  
  1479.                 return canReach(new RSTile(2564, 3356), false);
  1480.  
  1481.         }
  1482.  
  1483.        
  1484.  
  1485.         public boolean needToBank() {
  1486.  
  1487.                 return false;
  1488.  
  1489.         }
  1490.  
  1491.        
  1492.  
  1493.         public boolean atBank() {
  1494.  
  1495.                 int value = myDistanceBetween(2614, 3333);
  1496.  
  1497.                 return value != -1 && value <= 5;
  1498.  
  1499.         }
  1500.  
  1501.        
  1502.  
  1503.         /* Credits to Ruski - Stolen from RuskisFighterV2.java */
  1504.  
  1505.         public RSItemTile getNearestGroundItemByID(int range, int[] ids) {
  1506.  
  1507.                 int pX = getMyPlayer().getLocation().getX();
  1508.  
  1509.                 int pY = getMyPlayer().getLocation().getY();
  1510.  
  1511.                 int minX = pX - range;
  1512.  
  1513.                 int minY = pY - range;
  1514.  
  1515.                 int maxX = pX + range;
  1516.  
  1517.                 int maxY = pY + range;
  1518.  
  1519.                 int dist = 100;
  1520.  
  1521.                 RSItemTile nItem = null;
  1522.  
  1523.                 for (int x = minX; x <= maxX; x++) {
  1524.  
  1525.                         for (int y = minY; y <= maxY; y++) {
  1526.  
  1527.                                 if (Calculations.canReach(new RSTile(x, y), false)) {
  1528.  
  1529.                                         RSItemTile[] items = getGroundItemsAt(x, y);
  1530.  
  1531.                                         for (RSItemTile item : items) {
  1532.  
  1533.                                                 int iId = item.getItem().getID();
  1534.  
  1535.                                                 for (int id : ids) {
  1536.  
  1537.                                                         if (iId == id) {
  1538.  
  1539.                                                                 if (distanceTo(new RSTile(x, y)) < dist) {
  1540.  
  1541.                                                                         dist = distanceTo(new RSTile(x, y));
  1542.  
  1543.                                                                         nItem = item;
  1544.  
  1545.                                                                 }
  1546.  
  1547.                                                         }
  1548.  
  1549.                                                 }
  1550.  
  1551.                                         }
  1552.  
  1553.                                 }
  1554.  
  1555.                         }
  1556.  
  1557.                 }
  1558.  
  1559.                 return nItem;
  1560.  
  1561.         }      
  1562.  
  1563.        
  1564.  
  1565.         /* Also stolen from Ruski*/
  1566.  
  1567.         private RSNPC[] getInteractingNPCs() {
  1568.  
  1569.                 ArrayList<RSNPC> npcList = new ArrayList<RSNPC>();
  1570.  
  1571.                 org.rsbot.accessors.RSNPC[] npcs = Bot.getClient().getRSNPCArray();
  1572.  
  1573.                 for (int a = 0; a < npcs.length; a++) {
  1574.  
  1575.                         RSNPC npc = new RSNPC(npcs[a]);
  1576.  
  1577.                         if (!npc.isValid()) {
  1578.  
  1579.                                 continue;
  1580.  
  1581.                         }
  1582.  
  1583.                         if (npc.isInteractingWithLocalPlayer()) {
  1584.  
  1585.                                 npcList.add(npc);
  1586.  
  1587.                         }
  1588.  
  1589.                 }
  1590.  
  1591.                 return npcList.toArray(new RSNPC[npcList.size()]);
  1592.  
  1593.         }
  1594.  
  1595.  
  1596.  
  1597.         public boolean inCombat() {
  1598.  
  1599.                 if(getMyPlayer().isInCombat())
  1600.  
  1601.                         return true;
  1602.  
  1603.                 else if(getMyPlayer().getInteracting() != null) {
  1604.  
  1605.                         RSNPC[] interactingNpcs = getInteractingNPCs();
  1606.  
  1607.                         if(interactingNpcs.length > 0) {
  1608.  
  1609.                                 if(interactingNpcs[0].getHPPercent() != 0)
  1610.  
  1611.                                         return true;
  1612.  
  1613.                         }
  1614.  
  1615.                 }
  1616.  
  1617.                 return false;
  1618.  
  1619.         }
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.         /*  Updated May 08, 2009 */
  1626.  
  1627.         public boolean atGroundItem(RSItemTile theItemTile) {
  1628.  
  1629.                 RSItemTile[] itemsOnGround = getGroundItemsAt(new RSTile(theItemTile.getX(), theItemTile.getY()));
  1630.  
  1631.                 int itemIndex = -1;
  1632.  
  1633.                 //boolean foundBones = false;
  1634.  
  1635.                 for(int q = 0; q < itemsOnGround.length; q++) {
  1636.  
  1637.                         if(itemsOnGround[q].getItem().getID() == theItemTile.getItem().getID()) {
  1638.  
  1639.                                 if(pickUpOption) {
  1640.  
  1641.                                         log("a");
  1642.  
  1643.                                         itemIndex = (itemsOnGround.length - 1) - q; //itemsOnGround.length - 1 - q; q;
  1644.  
  1645.                                 }
  1646.  
  1647.                                 else {
  1648.  
  1649.                                         log("b");
  1650.  
  1651.                                         itemIndex = q;
  1652.  
  1653.                                 }
  1654.  
  1655.                                 break;
  1656.  
  1657.                         }
  1658.  
  1659.                 }
  1660.  
  1661.                 if(itemIndex == -1)
  1662.  
  1663.                         return false;
  1664.  
  1665.                 moveMouse(Calculations.tileToScreen(new RSTile(theItemTile.getX(), theItemTile.getY())), random(-5, 5), random(-5, 5));
  1666.  
  1667.                 ArrayList<String> menuOptions = getMenuItems();
  1668.  
  1669.                 for(int q = 0; q < menuOptions.size(); q++) {
  1670.  
  1671.                         if(menuOptions.get(q).startsWith("Take")) {
  1672.  
  1673.                                 clickMouse(false);                             
  1674.  
  1675.                                 return  atMenuItem(q + itemIndex);
  1676.  
  1677.                         }
  1678.  
  1679.                 }
  1680.  
  1681.                 return false;
  1682.  
  1683.         }              
  1684.  
  1685.        
  1686.  
  1687.         public int findFood(int[] foods) {
  1688.  
  1689.                 int[] invy = getInventoryArray();
  1690.  
  1691.                 for(int q = 0; q < invy.length; q++) {
  1692.  
  1693.                         if(inArray(invy[q], foods))
  1694.  
  1695.                                 return invy[q];
  1696.  
  1697.                 }
  1698.  
  1699.                 return -1;
  1700.  
  1701.         }
  1702.  
  1703.        
  1704.  
  1705.         /*
  1706.  
  1707.                 if TrickFood = true, then that means your
  1708.  
  1709.                         TrickFood = 0 after banking
  1710.  
  1711.                         TrickFood = 1 once fighting
  1712.  
  1713.         */
  1714.  
  1715.        
  1716.  
  1717.        
  1718.  
  1719.     public boolean inArray(int a, int[] lots) {
  1720.  
  1721.         for(int c = 0; c < lots.length; c++) {
  1722.  
  1723.                 if(lots[c] == a)
  1724.  
  1725.                         return true;
  1726.  
  1727.         }
  1728.  
  1729.         return false;
  1730.  
  1731.     }  
  1732.  
  1733.    
  1734.  
  1735.     public boolean inArray(String a, ArrayList<String> lots) {
  1736.  
  1737.         for(int c = 0; c < lots.size(); c++) {
  1738.  
  1739.                 if(lots.get(c).contains(a))
  1740.  
  1741.                         return true;
  1742.  
  1743.         }
  1744.  
  1745.         return false;
  1746.  
  1747.     }      
  1748.  
  1749.  
  1750.  
  1751.        
  1752.  
  1753.     public boolean atMenuCheck(String command) {
  1754.  
  1755.         ArrayList<String> options = getMenuItems();
  1756.  
  1757.         for(int c = 0; c < options.size(); c++) {
  1758.  
  1759.                 if(options.get(c).contains(command)) {
  1760.  
  1761.                         if(atMenuItem(c))
  1762.  
  1763.                                 return true;
  1764.  
  1765.                 }
  1766.  
  1767.         }
  1768.  
  1769.         return false;
  1770.  
  1771.     }
  1772.  
  1773.    
  1774.  
  1775.     public boolean inMenuOptions(String command) {
  1776.  
  1777.         ArrayList<String> options = getMenuItems();
  1778.  
  1779.         for(int c = 0; c < options.size(); c++) {
  1780.  
  1781.                 if(options.get(c).contains(command)) {
  1782.  
  1783.                                 return true;
  1784.  
  1785.                 }
  1786.  
  1787.         }
  1788.  
  1789.         return false;    
  1790.  
  1791.     }
  1792.  
  1793.    
  1794.  
  1795.    
  1796.  
  1797.     /*
  1798.  
  1799.         This doesn't support doors, if a door is closed or somehow
  1800.  
  1801.         a spot becomes unreachable it screws up.  Only use when
  1802.  
  1803.         walking places that will not be blocked.
  1804.  
  1805.        
  1806.  
  1807.         *checkPts need to be points in an almost straight line from start to destination, no turns.
  1808.  
  1809.                 (if you need turns just do several of these walks ending/starting at the turn points)
  1810.  
  1811.        
  1812.  
  1813.         return values
  1814.  
  1815.                 1 = at destination
  1816.  
  1817.                 750+ = still have walking to do
  1818.  
  1819.                 -1 = unreachable / error
  1820.  
  1821.     */
  1822.  
  1823.    
  1824.  
  1825.     int chkptIndex = 0;
  1826.  
  1827.     int pathIndex = 0;
  1828.  
  1829.    
  1830.  
  1831.     public int walkToNextTile(RSTile[] thePath, int randomValue) {
  1832.  
  1833.         RSTile[] checkPts = new RSTile[] {thePath[0], thePath[thePath.length - 1]};
  1834.  
  1835.         return walkToNextTile(thePath, checkPts, randomValue);
  1836.  
  1837.     }
  1838.  
  1839.    
  1840.  
  1841.    
  1842.  
  1843.     /* If randomValue is negative then it uses 3 for all points except the last where it'll use 1. */
  1844.  
  1845.    /* public int walkToNextTile(RSTile[] thePath, RSTile[] checkPts, int randomValue) {
  1846.  
  1847.         if(getMyPlayer().isMoving() && distanceTo(getDestination()) > random(2, 8))
  1848.  
  1849.                         return rand(400, 1250);
  1850.  
  1851.         /* Checks if players not moving but has destination
  1852.  
  1853.         RSTile tempCheck = null;
  1854.  
  1855.         try {
  1856.  
  1857.                 tempCheck = getDestination();
  1858.  
  1859.         } catch (NullPointerException e) {}
  1860.  
  1861.         if(!getMyPlayer().isMoving() && tempCheck != null) {
  1862.  
  1863.                 wait(antiBan(rand(750, 1250)));
  1864.  
  1865.                 if(!getMyPlayer().isMoving()) {        
  1866.  
  1867.                         log("no dist at player walk");
  1868.  
  1869.                                 if(random(0, 9) < random(0, 2))
  1870.  
  1871.                                         myWalk(getMyPlayer().getLocation(), 2);
  1872.  
  1873.                                 else {
  1874.  
  1875.                                         moveMouse(Calculations.tileToScreen(getMyPlayer().getLocation()), random(-3, 3), random(-3, 3));
  1876.  
  1877.                                         wait(rand(0, 10));
  1878.  
  1879.                                         clickMouse(true);
  1880.  
  1881.                                 }
  1882.  
  1883.                         }
  1884.  
  1885.                 return rand(150, 350);
  1886.  
  1887.         }
  1888.  
  1889.         RSTile nextTile = null;
  1890.  
  1891.         int leastDist = 9999;
  1892.  
  1893.         RSTile curCheckPt = null;
  1894.  
  1895.         //if player is within rand of end
  1896.  
  1897.         if(!isLoggedIn())
  1898.  
  1899.                 return -1;
  1900.  
  1901.                 int tempDist1 = myDistanceBetween(getMyPlayer().getLocation(), thePath[thePath.length - 1]);            
  1902.  
  1903.                 log("dist:" + tempDist1);
  1904.  
  1905.                 if(tempDist1 < random(2, 4) && tempDist1 != -1)
  1906.  
  1907.                         return 1;
  1908.  
  1909.                 if(tempDist1 == -1 || tempDist1 > 15) {
  1910.  
  1911.                 for(int c = 0; c < checkPts.length; c++) {
  1912.  
  1913.                         if(myDistanceBetween(getMyPlayer().getLocation(), checkPts[c]) != -1 && (distanceBetween(checkPts[c], checkPts[checkPts.length - 1]) < distanceBetween(getMyPlayer().getLocation(), checkPts[checkPts.length - 1])) && (distanceBetween(checkPts[c], checkPts[checkPts.length - 1]) < leastDist)) {
  1914.  
  1915.                                 leastDist = distanceBetween(checkPts[c], checkPts[checkPts.length - 1]);
  1916.  
  1917.                                 curCheckPt = checkPts[c];
  1918.  
  1919.                                 chkptIndex = c;
  1920.  
  1921.                                 wait(slowCPU);;
  1922.  
  1923.                         }
  1924.  
  1925.                 }              
  1926.  
  1927.         } else {
  1928.  
  1929.                 curCheckPt = thePath[thePath.length - 1];
  1930.  
  1931.         }
  1932.  
  1933.         tempDist1 = myDistanceBetween(getMyPlayer().getLocation(), curCheckPt);
  1934.  
  1935.         leastDist = 9999;      
  1936.  
  1937.         for(int c = 0; c < thePath.length; c++) {      
  1938.  
  1939.                         boolean tempBool = false;
  1940.  
  1941.                         try {
  1942.  
  1943.                                  tempBool = canReach(thePath[c], false);
  1944.  
  1945.                          }
  1946.  
  1947.                         catch(Exception e) {
  1948.  
  1949.                                 log("printstacktrace");
  1950.  
  1951.                                 e.printStackTrace();
  1952.  
  1953.                         }
  1954.  
  1955.                         RSTile tempTile = getDestination();
  1956.  
  1957.                         int tempDist = 0;
  1958.  
  1959.                         if(tempTile == null) {
  1960.  
  1961.                                 tempTile = getMyPlayer().getLocation();
  1962.  
  1963.                                 tempDist = 99;
  1964.  
  1965.                         }
  1966.  
  1967.                         else
  1968.  
  1969.                                 tempDist = distanceBetween(thePath[c], tempTile);
  1970.  
  1971.                         if(tempBool && tempDist > 4) {
  1972.  
  1973.                         int tempDist2 = myDistanceBetween(getMyPlayer().getLocation(), thePath[c]);
  1974.  
  1975.                                 if(tempDist2 < leastDist && distanceTo(thePath[c]) < 15) {
  1976.  
  1977.                                         int tempDist3 = myDistanceBetween(thePath[c], curCheckPt);
  1978.  
  1979.                                         if(tempDist1 >= tempDist3) {
  1980.  
  1981.                                                 pathIndex = c;
  1982.  
  1983.                                                 leastDist = tempDist3;
  1984.  
  1985.                                                 nextTile = thePath[c];
  1986.  
  1987.                                         }
  1988.  
  1989.                                 }
  1990.  
  1991.                         }
  1992.  
  1993.                         wait(slowCPU);;                        
  1994.  
  1995.                        
  1996.  
  1997.                 }
  1998.  
  1999.                 if(nextTile != null) {
  2000.  
  2001.                         if(canReach(nextTile, false)) {
  2002.  
  2003.                                 int randVal = randomValue;
  2004.  
  2005.                                 if(randomValue < 0)
  2006.  
  2007.                                         randVal = (distanceTo(thePath[thePath.length - 1]) < 10) ? 1 : 3;
  2008.  
  2009.                                 myWalk(nextTile, randVal);
  2010.  
  2011.                                 return rand(750, 1500);
  2012.  
  2013.                         } else {               
  2014.  
  2015.                                 errorsFound++;
  2016.  
  2017.                                 if((System.currentTimeMillis() - lastError) > 10000) {
  2018.  
  2019.                                         errorsFound = 0;
  2020.  
  2021.                                         lastError = 0;
  2022.  
  2023.                                 }                              
  2024.  
  2025.                         }
  2026.  
  2027.                 } else {
  2028.  
  2029.                         errorsFound++;
  2030.  
  2031.                         log("walking error: " + errorsFound);
  2032.  
  2033.                         if((System.currentTimeMillis() - lastError) > 30000) {
  2034.  
  2035.                                 errorsFound = 1;
  2036.  
  2037.                         }
  2038.  
  2039.                         lastError = System.currentTimeMillis();
  2040.  
  2041.                 }
  2042.  
  2043.                 if(errorsFound > 100) {
  2044.  
  2045.                         log("100+ errors have been found.  Script killing.");
  2046.  
  2047.                         log("Please supply the following information to CamHart:");
  2048.  
  2049.                         log(gatherInfo());
  2050.  
  2051.                         log("Sorry for any inconvience.  I'll get on a fix asap.");
  2052.  
  2053.                         stopScript();
  2054.  
  2055.                 }
  2056.  
  2057.                 return rand(250, 500);         
  2058.  
  2059.     }*/
  2060.  
  2061.    
  2062.  
  2063.     public int walkToNextTile(RSTile[] thePath, RSTile[] checkPts, int randomValue) {
  2064.  
  2065.         if(getMyPlayer().isMoving() && distanceTo(getDestination()) > random(2, 8))
  2066.  
  2067.                         return rand(400, 1250);
  2068.  
  2069.         /* Checks if players not moving but has destination */
  2070.  
  2071.         RSTile tempCheck = null;
  2072.  
  2073.         try {
  2074.  
  2075.                 tempCheck = getDestination();
  2076.  
  2077.         } catch (NullPointerException e) {}
  2078.  
  2079.         if(!getMyPlayer().isMoving() && tempCheck != null) {
  2080.  
  2081.                 wait(antiBan(rand(750, 1250)));
  2082.  
  2083.                 if(!getMyPlayer().isMoving()) {        
  2084.  
  2085.                                 if(random(0, 9) < random(0, 2) || !pointOnScreen(Calculations.tileToScreen(getMyPlayer().getLocation())))
  2086.  
  2087.                                         myWalk(getMyPlayer().getLocation(), 2);
  2088.  
  2089.                                 else {
  2090.  
  2091.                                         moveMouse(Calculations.tileToScreen(getMyPlayer().getLocation()), random(-3, 3), random(-3, 3));
  2092.  
  2093.                                         wait(rand(0, 10));
  2094.  
  2095.                                         clickMouse(true);
  2096.  
  2097.                                 }
  2098.  
  2099.                         }
  2100.  
  2101.                 return rand(150, 350);
  2102.  
  2103.         }
  2104.  
  2105.         RSTile nextTile = null;
  2106.  
  2107.         int leastDist = 9999;
  2108.  
  2109.         RSTile curCheckPt = null;
  2110.  
  2111.         //if player is within rand of end
  2112.  
  2113.         if(!isLoggedIn())
  2114.  
  2115.                 return -1;
  2116.  
  2117.                 int tempDist1 = myDistanceBetween(getMyPlayer().getLocation(), thePath[thePath.length - 1]);            
  2118.  
  2119.                 if(tempDist1 < random(2, 4) && tempDist1 != -1)
  2120.  
  2121.                         return 1;
  2122.  
  2123.                 if(tempDist1 == -1 || tempDist1 > 15) {
  2124.  
  2125.                 for(int c = 0; c < checkPts.length; c++) {
  2126.  
  2127.                         if(myDistanceBetween(getMyPlayer().getLocation(), checkPts[c]) != -1 && (distanceBetween(checkPts[c], checkPts[checkPts.length - 1]) < distanceBetween(getMyPlayer().getLocation(), checkPts[checkPts.length - 1])) && (distanceBetween(checkPts[c], checkPts[checkPts.length - 1]) < leastDist)) {                    
  2128.  
  2129.                                 leastDist = distanceBetween(checkPts[c], checkPts[checkPts.length - 1]);
  2130.  
  2131.                                 curCheckPt = checkPts[c];
  2132.  
  2133.                                         log("dist:" + myDistanceBetween(getMyPlayer().getLocation(), curCheckPt));                             
  2134.  
  2135.                                 wait(slowCPU);;
  2136.  
  2137.                         }
  2138.  
  2139.                 }              
  2140.  
  2141.         } else {
  2142.  
  2143.                 curCheckPt = thePath[thePath.length - 1];
  2144.  
  2145.         }
  2146.  
  2147.         tempDist1 = myDistanceBetween(getMyPlayer().getLocation(), curCheckPt);
  2148.  
  2149.         leastDist = 9999;      
  2150.  
  2151.         for(int c = 0; c < thePath.length; c++) {      
  2152.  
  2153.                         boolean tempBool = false;
  2154.  
  2155.                         try {
  2156.  
  2157.                                  tempBool = canReach(thePath[c], false);
  2158.  
  2159.                          }
  2160.  
  2161.                         catch(Exception e) {
  2162.  
  2163.                                 log("printstacktrace");
  2164.  
  2165.                                 e.printStackTrace();
  2166.  
  2167.                         }
  2168.  
  2169.                         RSTile tempTile = getDestination();
  2170.  
  2171.                         int tempDist = 0;
  2172.  
  2173.                         if(tempTile == null) {
  2174.  
  2175.                                 tempTile = getMyPlayer().getLocation();
  2176.  
  2177.                                 tempDist = 99;
  2178.  
  2179.                         }
  2180.  
  2181.                         else
  2182.  
  2183.                                 tempDist = distanceBetween(thePath[c], tempTile);
  2184.  
  2185.                         if(tempBool && tempDist > 4) {
  2186.  
  2187.                         int tempDist2 = myDistanceBetween(getMyPlayer().getLocation(), thePath[c]);
  2188.  
  2189.                                 if(tempDist2 < leastDist && distanceTo(thePath[c]) < 15) {
  2190.  
  2191.                                         int tempDist3 = myDistanceBetween(thePath[c], curCheckPt);
  2192.  
  2193.                                         if(tempDist1 >= tempDist3) {
  2194.  
  2195.                                                 leastDist = tempDist3;
  2196.  
  2197.                                                 nextTile = thePath[c];
  2198.  
  2199.                                         }
  2200.  
  2201.                                 }
  2202.  
  2203.                         }
  2204.  
  2205.                         wait(slowCPU);;                        
  2206.  
  2207.                        
  2208.  
  2209.                 }
  2210.  
  2211.                 if(nextTile != null) {
  2212.  
  2213.                         if(canReach(nextTile, false)) {
  2214.  
  2215.                                 int randVal = randomValue;
  2216.  
  2217.                                 if(randomValue < 0)
  2218.  
  2219.                                         randVal = (distanceTo(thePath[thePath.length - 1]) < 10) ? 1 : 3;
  2220.  
  2221.                                 myWalk(nextTile, randVal);
  2222.  
  2223.                                 return rand(750, 1500);
  2224.  
  2225.                         } else {               
  2226.  
  2227.                                 errorsFound++;
  2228.  
  2229.                                 if((System.currentTimeMillis() - lastError) > 10000) {
  2230.  
  2231.                                         errorsFound = 0;
  2232.  
  2233.                                         lastError = 0;
  2234.  
  2235.                                 }                              
  2236.  
  2237.                         }
  2238.  
  2239.                 } else {
  2240.  
  2241.                         errorsFound++;
  2242.  
  2243.                         log("walking error: " + errorsFound);
  2244.  
  2245.                         if((System.currentTimeMillis() - lastError) > 180000) {
  2246.  
  2247.                                 errorsFound = 1;
  2248.  
  2249.                         }
  2250.  
  2251.                         lastError = System.currentTimeMillis();
  2252.  
  2253.                 }
  2254.  
  2255.                 if(errorsFound > 50) {
  2256.  
  2257.                         log("Trying to get back on path...");
  2258.  
  2259.                         if(!getMyPlayer().isMoving()) {
  2260.  
  2261.                                 if(myWalkTo(thePath[thePath.length - 1]))
  2262.  
  2263.                                         wait(rand(1250, 1500));
  2264.  
  2265.                         }
  2266.  
  2267.                 }      
  2268.  
  2269.                 if(errorsFound > 100) {
  2270.  
  2271.                         log("100+ errors have been found.  Script killing.");
  2272.  
  2273.                         log("Please supply the following information to CamHart:");
  2274.  
  2275.                         log(gatherInfo());
  2276.  
  2277.                         log("Sorry for any inconvience.  I'll get on a fix asap.");
  2278.  
  2279.                         stopScript();
  2280.  
  2281.                 }
  2282.  
  2283.                 return rand(250, 500);         
  2284.  
  2285.     }    
  2286.  
  2287.    
  2288.  
  2289.     public boolean myWalkTo(RSTile blah) {
  2290.  
  2291.         return myWalkTo(blah.getX(), blah.getY());
  2292.  
  2293.     }
  2294.  
  2295.         public boolean myWalkTo(final int x, final int y) {
  2296.  
  2297.                 final RSTile[] path = generateProperPath(x, y);
  2298.  
  2299.                 if (path == null) {
  2300.  
  2301.                         return false;
  2302.  
  2303.                 }
  2304.  
  2305.                 //while (true) {
  2306.  
  2307.                         if (!getMyPlayer().isMoving() || distanceTo(getDestination()) > 4) {
  2308.  
  2309.                                 if (myWalkPathMM(randomizePath(path, 2, 2), 17)) {
  2310.  
  2311.                                         errorsFound++;
  2312.  
  2313.                                         wait(random(750, 1250));
  2314.  
  2315.                                         return true;
  2316.  
  2317.                                 }
  2318.  
  2319.                         }
  2320.  
  2321.                 //}
  2322.  
  2323.                 return false;
  2324.  
  2325.         }      
  2326.  
  2327.        
  2328.  
  2329.        
  2330.  
  2331.     int tooShort = 0;
  2332.  
  2333.         private static RSTile myCurrent = new RSTile(0, 0);    
  2334.  
  2335.         public boolean myWalkPathMM(final RSTile[] path, final int maxDist) {
  2336.  
  2337.                 try {
  2338.  
  2339.                         final RSTile next = nextTile(path, maxDist);
  2340.  
  2341.                         if(distanceTo(next) < 4) {
  2342.  
  2343.                                 errorsFound++;
  2344.  
  2345.                                 tooShort++;
  2346.  
  2347.                                 if(tooShort > 10)
  2348.  
  2349.                                         return false;
  2350.  
  2351.                         }
  2352.  
  2353.                         if (next != null && !next.equals(myCurrent)) {
  2354.  
  2355.                                 walkTileMM(next);
  2356.  
  2357.                                 wait(random(750, 1250));
  2358.  
  2359.                                 myCurrent = next;
  2360.  
  2361.                                 return false;
  2362.  
  2363.                         } else if (next != null && next.equals(myCurrent)) {
  2364.  
  2365.                                 return false;
  2366.  
  2367.                         }
  2368.  
  2369.                 } catch (final Exception e) {
  2370.  
  2371.                         return false;
  2372.  
  2373.                 }
  2374.  
  2375.                 return true;
  2376.  
  2377.         }    
  2378.  
  2379.    
  2380.  
  2381.    
  2382.  
  2383.         /*
  2384.  
  2385.                 Stole this from PowerChopper by Megaalgos.  Touched it up to work how I wanted it to.  
  2386.  
  2387.         */
  2388.  
  2389.         public int antiBan(int retval) {
  2390.  
  2391.                 int gamble = random(1, random(75, 100));
  2392.  
  2393.                 int x = random(0, 750);
  2394.  
  2395.                 int y = random(0, 500);
  2396.  
  2397.                 int xx = random(554, 710);
  2398.  
  2399.                 int yy = random(230, 444);
  2400.  
  2401.                 int screenx = random(1, 510);
  2402.  
  2403.                 int screeny = random(1, 450);
  2404.  
  2405.                 debug += "#";
  2406.  
  2407.                 if(!useAntiBan)
  2408.  
  2409.                         return retval;
  2410.  
  2411.                 switch (gamble) {
  2412.  
  2413.                 case 1:
  2414.  
  2415.                         return retval;
  2416.  
  2417.                 case 2:
  2418.  
  2419.                         moveMouse(x, y);
  2420.  
  2421.                         return retval;
  2422.  
  2423.                 case 3:
  2424.  
  2425.                         openTab(TAB_INVENTORY);
  2426.  
  2427.                         return retval;
  2428.  
  2429.                 case 4:
  2430.  
  2431.                         if (getMyPlayer().isMoving()) {
  2432.  
  2433.                         return retval;
  2434.  
  2435.                         }
  2436.  
  2437.                 case 5:
  2438.  
  2439.                         openTab(TAB_STATS);
  2440.  
  2441.                         moveMouse(random(663, 711), random(325, 348));                  //663, 325 711, 348            
  2442.  
  2443.                         return retval;
  2444.  
  2445.                 case 6:
  2446.  
  2447.                         if (getCurrentTab() != TAB_STATS) {
  2448.  
  2449.                                 openTab(TAB_STATS);
  2450.  
  2451.                                 moveMouse(xx, yy);
  2452.  
  2453.                         return retval;
  2454.  
  2455.  
  2456.  
  2457.                         }
  2458.  
  2459.                 case 7:
  2460.  
  2461.                         if (random(1, 8) == 2) {
  2462.  
  2463.                                 int angle = getCameraAngle() + random(-90, 90);
  2464.  
  2465.                                 if (angle < 0) {
  2466.  
  2467.                                         angle = 0;
  2468.  
  2469.                                 }
  2470.  
  2471.                                 if (angle > 359) {
  2472.  
  2473.                                         angle = 0;
  2474.  
  2475.                                 }
  2476.  
  2477.  
  2478.  
  2479.                                 setCameraRotation(angle);
  2480.  
  2481.                         }
  2482.  
  2483.                         return retval;
  2484.  
  2485.                 case 8:
  2486.  
  2487.                         moveMouse(screenx, screeny);
  2488.  
  2489.                         return retval;
  2490.  
  2491.                 case 9:
  2492.  
  2493.                         moveMouse(screenx, screeny);
  2494.  
  2495.                         return retval;
  2496.  
  2497.                 case 10:
  2498.  
  2499.                         randomTab();
  2500.  
  2501.                         wait(rand(0, 250));
  2502.  
  2503.                         return retval;
  2504.  
  2505.                 case 11:
  2506.  
  2507.                         wait(rand(0, 250));
  2508.  
  2509.                         moveMouse(screenx, screeny);
  2510.  
  2511.                         return retval;
  2512.  
  2513.                 case 12:
  2514.  
  2515.                         wait(rand(0, 250));
  2516.  
  2517.                         moveMouse(screenx, screeny);
  2518.  
  2519.                         return retval;
  2520.  
  2521.                 case 13:
  2522.  
  2523.                         wait(rand(0, 250));
  2524.  
  2525.                         moveMouse(screenx, screeny);
  2526.  
  2527.                         return retval;
  2528.  
  2529.                 case 14:
  2530.  
  2531.                         //log("moving mouse off screen...");
  2532.  
  2533.                         wait(rand(100, 1000));
  2534.  
  2535.                         moveMouse(random(-800, 800), random(-800, 800));
  2536.  
  2537.                         return retval;
  2538.  
  2539.                 case 15:
  2540.  
  2541.                         //log("moving mouse off screen...");
  2542.  
  2543.                         wait(rand(100, 1000));
  2544.  
  2545.                         moveMouse(random(-200, 800), random(-100, 800));
  2546.  
  2547.                         return retval;                 
  2548.  
  2549.  
  2550.  
  2551.                 }
  2552.  
  2553.                 return retval;
  2554.  
  2555.         }          
  2556.  
  2557.    
  2558.  
  2559.     /* Also taken from PowerChopper.java*/
  2560.  
  2561.         public int randomTab() {
  2562.  
  2563.                 int random1 = random(1, random(23, 28));
  2564.  
  2565.                 switch (random1) {
  2566.  
  2567.                 case 1:
  2568.  
  2569.                         openTab(TAB_STATS);
  2570.  
  2571.                         return random(100, 500);
  2572.  
  2573.                 case 2:
  2574.  
  2575.                         openTab(TAB_ATTACK);
  2576.  
  2577.                         return random(100, 500);
  2578.  
  2579.  
  2580.  
  2581.                 case 3:
  2582.  
  2583.                         openTab(TAB_QUESTS);
  2584.  
  2585.                         return random(100, 500);
  2586.  
  2587.  
  2588.  
  2589.                 case 4:
  2590.  
  2591.                         openTab(TAB_EQUIPMENT);
  2592.  
  2593.                         return random(100, 500);
  2594.  
  2595.  
  2596.  
  2597.                 case 5:
  2598.  
  2599.                         openTab(TAB_INVENTORY);
  2600.  
  2601.                         return random(100, 500);
  2602.  
  2603.                 case 6:
  2604.  
  2605.                         openTab(TAB_PRAYER);
  2606.  
  2607.                         return random(100, 500);
  2608.  
  2609.                 case 7:
  2610.  
  2611.                         openTab(TAB_MAGIC);
  2612.  
  2613.                         return random(100, 500);
  2614.  
  2615.  
  2616.  
  2617.                 case 8:
  2618.  
  2619.                         openTab(TAB_SUMMONING);
  2620.  
  2621.                         return random(100, 500);
  2622.  
  2623.  
  2624.  
  2625.                 case 9:
  2626.  
  2627.                         openTab(TAB_FRIENDS);
  2628.  
  2629.                         return random(100, 500);
  2630.  
  2631.                 case 10:
  2632.  
  2633.                         openTab(TAB_IGNORE);
  2634.  
  2635.                         return random(100, 500);
  2636.  
  2637.  
  2638.  
  2639.                 case 11:
  2640.  
  2641.                         openTab(TAB_CLAN);
  2642.  
  2643.                         return random(100, 500);
  2644.  
  2645.  
  2646.  
  2647.                 case 12:
  2648.  
  2649.                         openTab(TAB_CONTROLS);
  2650.  
  2651.                         return random(100, 500);
  2652.  
  2653.                 case 13:
  2654.  
  2655.                         openTab(TAB_MUSIC);
  2656.  
  2657.                         return random(100, 500);
  2658.  
  2659.                 case 14:
  2660.  
  2661.                         openTab(TAB_OPTIONS);
  2662.  
  2663.                         return random(100, 500);
  2664.  
  2665.                 case 15:
  2666.  
  2667.                         openTab(TAB_STATS);
  2668.  
  2669.                         return random(100, 500);
  2670.  
  2671.                 case 16:
  2672.  
  2673.                         openTab(TAB_STATS);
  2674.  
  2675.                         return random(100, 500);                                               
  2676.  
  2677.                 case 17:
  2678.  
  2679.                         openTab(TAB_INVENTORY);
  2680.  
  2681.                         return random(100, 500);       
  2682.  
  2683.                 case 18:
  2684.  
  2685.                         openTab(TAB_INVENTORY);
  2686.  
  2687.                         return random(100, 500);
  2688.  
  2689.                 case 19:
  2690.  
  2691.                         openTab(TAB_INVENTORY);
  2692.  
  2693.                         return random(100, 500);                                                               
  2694.  
  2695.                 }
  2696.  
  2697.                 return random(100, 300);
  2698.  
  2699.         }    
  2700.  
  2701.    
  2702.  
  2703.     public String gatherInfo() {
  2704.  
  2705.         String ret = "Location:" + getMyPlayer().getLocation().getX() + ", " + getMyPlayer().getLocation().getY() + "\n";
  2706.  
  2707.         ret += "Along with a screenshot of your character and a description of what was occuring (if you can).";
  2708.  
  2709.        
  2710.  
  2711.         return ret;
  2712.  
  2713.     }
  2714.  
  2715.    
  2716.  
  2717.     public boolean myWalk(int x, int y) {
  2718.  
  2719.         return myWalk(new RSTile(x, y), 3);
  2720.  
  2721.     }
  2722.  
  2723.    
  2724.  
  2725.     public boolean myWalk(int x, int y, int randVal) {
  2726.  
  2727.         return myWalk(new RSTile(x, y), randVal);
  2728.  
  2729.     }    
  2730.  
  2731.    
  2732.  
  2733.     public boolean myWalk(RSTile walkTo) {
  2734.  
  2735.         return myWalk(walkTo, 3);
  2736.  
  2737.     }
  2738.  
  2739.    
  2740.  
  2741.     public boolean myWalk(RSTile walkTo, int val) {
  2742.  
  2743.         return myWalk(walkTo, val, false);
  2744.  
  2745.     }    
  2746.  
  2747.    
  2748.  
  2749.         public boolean myWalk(RSTile walkTo, int randVal, boolean isObject) {
  2750.  
  2751.         if(getEnergy() >= random(random(30, 60), random(61, 100)))
  2752.  
  2753.                 setRun(true);
  2754.  
  2755.         int randX = random(-randVal, randVal);
  2756.  
  2757.         int randY = random(-randVal, randVal);
  2758.  
  2759.         for(int c = 0; c < 5; c++) {
  2760.  
  2761.                 RSTile tempTile = new RSTile(walkTo.getX() + randX, walkTo.getY() + randY);
  2762.  
  2763.                 if(canReach(tempTile, isObject)) {
  2764.  
  2765.                         if(Math.abs(myDistanceBetween(getMyPlayer().getLocation(), tempTile) - myDistanceBetween(getMyPlayer().getLocation(), walkTo)) <= 4) {
  2766.  
  2767.                                 //log("  walking to " + tempTile.getX() + "," + tempTile.getY());
  2768.  
  2769.                                 Point thePoint = Calculations.tileToScreen(tempTile);
  2770.  
  2771.                                 thePoint.setLocation(thePoint.getX() + random(-(randVal * 10), (randVal * 10)), thePoint.getY() + random(-(randVal * 10), (randVal * 10)));
  2772.  
  2773.                                 if(pointOnScreen(thePoint) && random(0, 10) > 3){
  2774.  
  2775.                                         moveMouse(thePoint);
  2776.  
  2777.                                         log("fancy walk :" + tempTile);
  2778.  
  2779.                                         return atMenu("Walk here");
  2780.  
  2781.                                 }
  2782.  
  2783.                                 else if(tileOnMap(tempTile)){
  2784.  
  2785.                                         boolean retVal = false;
  2786.  
  2787.                                         try{
  2788.  
  2789.                                                 retVal = walkTileMM(tempTile);
  2790.  
  2791.                                         } catch(Exception e) {
  2792.  
  2793.                                                         e.printStackTrace();
  2794.  
  2795.                                         }
  2796.  
  2797.                                         return retVal;
  2798.  
  2799.                                 } else {
  2800.  
  2801.                                         log("Error with coord: " + tempTile);
  2802.  
  2803.                                 }
  2804.  
  2805.                         }
  2806.  
  2807.                 }
  2808.  
  2809.                 randX = random(-randVal, randVal);
  2810.  
  2811.                 randY = random(-randVal, randVal);             
  2812.  
  2813.         }
  2814.  
  2815.         if(canReach(walkTo, isObject)) {       
  2816.  
  2817.                 return walkTileMM(walkTo);
  2818.  
  2819.         }
  2820.  
  2821.         return false;
  2822.  
  2823.     }        
  2824.  
  2825.    
  2826.  
  2827.         /*public boolean myWalk(RSTile walkTo, int randVal) {
  2828.  
  2829.         if(getEnergy() >= random(random(30, 60), random(61, 100)))
  2830.  
  2831.                 setRun(true);
  2832.  
  2833.         int randX = random(-randVal, randVal);
  2834.  
  2835.         int randY = random(-randVal, randVal);
  2836.  
  2837.         for(int c = 0; c < 5; c++) {
  2838.  
  2839.                 RSTile tempTile = new RSTile(walkTo.getX() + randX, walkTo.getY() + randY);
  2840.  
  2841.                 if(canReach(tempTile, false)) {
  2842.  
  2843.                         if(Math.abs(myDistanceBetween(getMyPlayer().getLocation(), tempTile) - myDistanceBetween(getMyPlayer().getLocation(), walkTo)) <= 4) {
  2844.  
  2845.                                 //log("  walking to " + tempTile.getX() + "," + tempTile.getY());
  2846.  
  2847.                                 Point thePoint = Calculations.tileToScreen(tempTile);
  2848.  
  2849.                                 thePoint.setLocation(thePoint.getX() + random(-(randVal * 10), (randVal * 10)), thePoint.getY() + random(-(randVal * 10), (randVal * 10)));
  2850.  
  2851.                                 if(pointOnScreen(thePoint) && distanceTo(tempTile) < random(3, 5)){
  2852.  
  2853.                                         moveMouse(thePoint);
  2854.  
  2855.                                         log("fancy walk :" + tempTile);
  2856.  
  2857.                                         return atMenu("Walk here");
  2858.  
  2859.                                 }
  2860.  
  2861.                                 else {
  2862.  
  2863.                                         boolean retVal = false;
  2864.  
  2865.                                         try{
  2866.  
  2867.                                                 retVal = walkTileMM(tempTile);
  2868.  
  2869.                                         } catch(Exception e) {
  2870.  
  2871.                                                         e.printStackTrace();
  2872.  
  2873.                                         }
  2874.  
  2875.                                         return retVal;
  2876.  
  2877.                                 }
  2878.  
  2879.                         }
  2880.  
  2881.                 }
  2882.  
  2883.                 randX = random(-randVal, randVal);
  2884.  
  2885.                 randY = random(-randVal, randVal);             
  2886.  
  2887.         }
  2888.  
  2889.         if(canReach(walkTo, false)) {          
  2890.  
  2891.                 return walkTileMM(walkTo);
  2892.  
  2893.         }
  2894.  
  2895.         return false;
  2896.  
  2897.     }  */  
  2898.  
  2899.    
  2900.  
  2901.    
  2902.  
  2903.     public int myDistanceBetween(int sx, int sy, int ex, int ey) {
  2904.  
  2905.         return myDistanceBetween(new RSTile(sx, sy), new RSTile(ex, ey));
  2906.  
  2907.     }
  2908.  
  2909.    
  2910.  
  2911.    
  2912.  
  2913.     public int myDistanceBetween(RSTile end) {
  2914.  
  2915.         return myDistanceBetween(getMyPlayer().getLocation(), end);
  2916.  
  2917.     }    
  2918.  
  2919.    
  2920.  
  2921.     public int myDistanceBetween(int s, int e) {
  2922.  
  2923.         return myDistanceBetween(new RSTile(s, e));
  2924.  
  2925.     }    
  2926.  
  2927.    
  2928.  
  2929.     public int myDistanceBetween(RSTile start, RSTile end) {
  2930.  
  2931.         int ret;
  2932.  
  2933.         if(start == null || end == null)
  2934.  
  2935.                 return -1;
  2936.  
  2937.         try {
  2938.  
  2939.                         ret = Calculations.getRealDistanceTo(start.getX() - Bot.getClient().getBaseX(), start.getY() - Bot.getClient().getBaseY(), end.getX() - Bot.getClient().getBaseX(), end.getY() - Bot.getClient().getBaseY(), false);           
  2940.  
  2941.         } catch (ArrayIndexOutOfBoundsException e) {
  2942.  
  2943.                 log("  ERROR:" + e);
  2944.  
  2945.                 ret = -1;      
  2946.  
  2947.         }
  2948.  
  2949.         return ret;
  2950.  
  2951.     }
  2952.  
  2953.    
  2954.  
  2955.     public int distanceTo(int s, int e) {
  2956.  
  2957.         return distanceTo(new RSTile(s, e));
  2958.  
  2959.     }    
  2960.  
  2961.    
  2962.  
  2963.     public int rand(int a, int b) {
  2964.  
  2965.         int ret = 0;
  2966.  
  2967.         int temp = random(0, random(10, 20));
  2968.  
  2969.         if(temp == 4)
  2970.  
  2971.                 ret = random(a, b) * random(1, random(1, 5));
  2972.  
  2973.         else
  2974.  
  2975.                 ret = random(a, b);
  2976.  
  2977.         //log("RandWait: " + ret);
  2978.  
  2979.         return ret;
  2980.  
  2981.     }
  2982.  
  2983.    
  2984.  
  2985.    
  2986.  
  2987.         public boolean isNumeric(String str) {
  2988.  
  2989.                 try {
  2990.  
  2991.                         Integer.parseInt(str);
  2992.  
  2993.                         return true;
  2994.  
  2995.                 }
  2996.  
  2997.                 catch (Exception e)     {
  2998.  
  2999.                         return false;
  3000.  
  3001.                 }
  3002.  
  3003.         }      
  3004.  
  3005.        
  3006.  
  3007.         @Override
  3008.  
  3009.         public int getMouseSpeed() {
  3010.  
  3011.                 return mouseSpeed;
  3012.  
  3013.         }
  3014.  
  3015.        
  3016.  
  3017.         public double getCorrectVersion(String scriptName) {
  3018.  
  3019.                 if(!canUpdate)
  3020.  
  3021.                         return 0.0;    
  3022.  
  3023.                 try {
  3024.  
  3025.                         URL link = new URL("http://camhart.com/Scripts/ScriptVersions.txt");
  3026.  
  3027.                         BufferedReader br = new BufferedReader(new InputStreamReader(new BufferedInputStream(link.openConnection().getInputStream())));
  3028.  
  3029.                         int charRead = 0;
  3030.  
  3031.                         double version = -0.1;
  3032.  
  3033.                         String data = "";
  3034.  
  3035.                         while(charRead != -1) {
  3036.  
  3037.                                 charRead = br.read();
  3038.  
  3039.                                 data += (char)charRead;
  3040.  
  3041.                                 //log("Character Read Was: " + charRead);
  3042.  
  3043.                         }
  3044.  
  3045.                         //log("String: " + data);
  3046.  
  3047.                         ArrayList<String> lineByLine = split(data, 10);//13 = carriage return, 10 = line feed
  3048.  
  3049.                         for(int c = 0; c < lineByLine.size(); c++) {
  3050.  
  3051.                                 //log("LineByLine: " + lineByLine.get(c));
  3052.  
  3053.                                 if(lineByLine.get(c).startsWith(scriptName)) {
  3054.  
  3055.                                         version = Double.parseDouble(lineByLine.get(c).substring(lineByLine.get(c).indexOf(':') + 1, lineByLine.get(c).lastIndexOf(';')));
  3056.  
  3057.                                 }
  3058.  
  3059.                         }
  3060.  
  3061.                         br.close();
  3062.  
  3063.                         //log(scriptName + " version is " + version);
  3064.  
  3065.                         return version;
  3066.  
  3067.                 } catch (IOException e) {
  3068.  
  3069.                         log("Problems checking for updates.");
  3070.  
  3071.                         throw new RuntimeException(e);
  3072.  
  3073.                 }
  3074.  
  3075.         }
  3076.  
  3077.        
  3078.  
  3079.         public ArrayList<String> split(String list, int splitChar) {
  3080.  
  3081.                 return split(list, (char)splitChar);
  3082.  
  3083.         }
  3084.  
  3085.        
  3086.  
  3087.         public ArrayList<String> split(String list, char splitChar) {
  3088.  
  3089.                 ArrayList<String> ret = new ArrayList<String>();
  3090.  
  3091.                 int prevCut = 0;
  3092.  
  3093.                 for(int c = 0; c < list.length(); c++) {
  3094.  
  3095.                         if(list.charAt(c) == splitChar) {
  3096.  
  3097.                                 ret.add(list.substring(prevCut, c).trim());
  3098.  
  3099.                                 prevCut = c;
  3100.  
  3101.                         }
  3102.  
  3103.                 }
  3104.  
  3105.                 return ret;
  3106.  
  3107.         }
  3108.  
  3109.        
  3110.  
  3111.          /* Ruskis */
  3112.  
  3113.         private boolean clickNPC(final RSNPC npc, final String action) {
  3114.  
  3115.                 try {
  3116.  
  3117.                         int a;
  3118.  
  3119.                         final StringBuffer npcCommandBuf = new StringBuffer();
  3120.  
  3121.                         npcCommandBuf.append(action);
  3122.  
  3123.                         npcCommandBuf.append(" ");
  3124.  
  3125.                         npcCommandBuf.append(npc.getName());
  3126.  
  3127.                         final String npcCommand = npcCommandBuf.toString();
  3128.  
  3129.                         for (a = 10; a-- >= 0;) {
  3130.  
  3131.                                 if (npc.getInteracting() != null
  3132.  
  3133.                                                 && !npc.isInteractingWithLocalPlayer()) {
  3134.  
  3135.                                         return false;
  3136.  
  3137.                                 }
  3138.  
  3139.                                 final List<String> menuItems = getMenuItems();
  3140.  
  3141.                                 if (menuItems.size() > 1) {
  3142.  
  3143.                                         if (listContainsString(menuItems, npcCommand)) {
  3144.  
  3145.                                                 if (menuItems.get(0).contains(npcCommand)) {
  3146.  
  3147.                                                         clickMouse(true);
  3148.  
  3149.                                                         return true;
  3150.  
  3151.                                                 } else {
  3152.  
  3153.                                                         // clickMouse(false);
  3154.  
  3155.                                                         wait(random(230, 520));
  3156.  
  3157.                                                         return atMenu(npcCommand);
  3158.  
  3159.                                                 }
  3160.  
  3161.                                         }
  3162.  
  3163.                                 }
  3164.  
  3165.                                 final Point screenLoc = npc.getScreenLocation();
  3166.  
  3167.                                 if (!pointOnScreen(screenLoc)) {
  3168.  
  3169.                                         return false;
  3170.  
  3171.                                 }
  3172.  
  3173.                                 final Point randomP = new Point(random(screenLoc.x - 15,
  3174.  
  3175.                                                 screenLoc.x + 15), random(screenLoc.y - 15,
  3176.  
  3177.                                                                 screenLoc.y + 15));
  3178.  
  3179.                                 if (randomP.x >= 0 && randomP.y >= 0) {
  3180.  
  3181.                                         moveMouse(randomP);
  3182.  
  3183.                                 }
  3184.  
  3185.                         }
  3186.  
  3187.                         return false;
  3188.  
  3189.                 } catch (final Exception e) {
  3190.  
  3191.                         //log.log(Level.SEVERE, "clickNPC(RSNPC, String) error: ", e);
  3192.  
  3193.                         return false;
  3194.  
  3195.                 }
  3196.  
  3197.         }        
  3198.  
  3199.        
  3200.  
  3201.         // Optimized version of array contains string
  3202.  
  3203.         private boolean listContainsString(final List<String> list,
  3204.  
  3205.                         final String string) {
  3206.  
  3207.                 try {
  3208.  
  3209.                         int a;
  3210.  
  3211.                         for (a = list.size() - 1; a-- >= 0;) {
  3212.  
  3213.                                 if (list.get(a).contains(string)) {
  3214.  
  3215.                                         return true;
  3216.  
  3217.                                 }
  3218.  
  3219.                         }
  3220.  
  3221.                 } catch (final Exception e) {
  3222.  
  3223.                 }
  3224.  
  3225.                 return false;
  3226.  
  3227.         }              
  3228.  
  3229.          
  3230.  
  3231. }