Guest User

Untitled

a guest
Nov 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 15.77 KB | None | 0 0
  1. import java.util.HashMap;
  2. import java.util.ArrayList;
  3. public class ChaosWarrior_highonly extends Script {
  4.  
  5.     boolean buryBones = true;
  6.  
  7.     Extension e;
  8.     public ChaosWarrior_highonly(Extension e) {
  9.         super(e);
  10.         this.e = e;
  11.     }
  12.    
  13.     int[] pickUpIds = {31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 46, 619, 825,
  14.             442, 441, 440, 439, 220, 438, 443,
  15.             566, 464, 381, 526, 527, 469, 220, 471, 997, 473, 997,
  16.             157, 158, 159, 160};   
  17.     String[] itemName = {"Fire-Rune", "Water-Rune", "Air-Rune", "Earth-Rune", "Mind-Rune", "Body-Rune", "Life-Rune", "Death-Rune", "Nature-Rune", "Chaos-Rune", "Law-Rune", "Cosmic-Rune", "Blood-Rune",
  18.         "Soul-Rune", "Muddy Cadantine", "Muddy Kwuarm", "Muddy Avantoe", "Muddy Irit Leaf", "Limpwurt Root", "Muddy Ranarr Weed", "Muddy Dwarf Weed",
  19.         "Cure Poison Potion", "Vial", "Feather", "Half of a Key", "Half of a Key", "Snape Grass", "Limpwurt Root", "White Berries", "Unicorn Horn", "Ground Unicorn Horn", "Unicorn Horn",
  20.         "Uncut Diamond", "Uncut Ruby", "Uncut Emerald", "Uncut Sapphire"}; 
  21.    
  22.    
  23.     public void init(String params) {
  24.         bankedItems = new HashMap<Integer, Integer>();
  25.         fightMode = getFightMode();
  26.         startTime = System.currentTimeMillis();
  27.         //loadIRCBot();
  28.     }
  29.    
  30.     long startTime = 0;
  31.    
  32.     int fightMode = 1;
  33.    
  34.     int batCounter = 0;
  35.     int sleepAt = 93;
  36.     int foodCount = 4;
  37.     boolean foodChanged = false;
  38.     HashMap<Integer, Integer> bankedItems;
  39.    
  40.     public int main() {
  41.         if(isSleeping()) {
  42.             return random(350, 550);
  43.         } else if(getFightMode() != fightMode) {
  44.             setFightMode(fightMode);
  45.             return random(50, 75);
  46.         }
  47.         else if(getInventoryCount(714) == 0) {
  48.             System.out.println("You need a picklock in your inventory for this script...");
  49.             stopScript();
  50.         }
  51.         else if(getFatigue()  >= sleepAt) { //sleep
  52.             sleepAt = random(85, 100);
  53.             useSleepingBag();
  54.             return random(650, 1000);
  55.         }
  56.         else if(bankWDWait) {
  57.             if(getInventoryCount(bankItemId) == bankItemInvCount && System.currentTimeMillis() - lastBankWDClick < bankLimit)
  58.                 return random(350, 500);
  59.             else {
  60.                 bankWDWait = false;
  61.                 return random(10, 50);
  62.             }
  63.         }    
  64.         else if(walkWait && !isBanking() && !isQuestMenu()) {
  65.             if(distanceTo(getX(), getY(), destX, destY) <= destDist) {
  66.                 walkWait = false;
  67.                 return random(50, 150);
  68.             } else if(curX != getX() && curY != getY() && System.currentTimeMillis() - lastWalk < walkWaitLimit) {
  69.                 return random(750, 1250);
  70.             } else
  71.                 walkWait = false;
  72.         }      
  73.         else if(!isQuestMenu() && questMenuWait && System.currentTimeMillis() - lastQuestMenuClick < questMenuLimit) {
  74.             return random(125, 200);
  75.         }
  76.         else if(!isBanking() && bankWait && System.currentTimeMillis() - lastBankClick < bankLimit) {
  77.             return random(125, 200);
  78.         }
  79.         else if(inArea(593, 3581, 608, 3563)) {//warrors area
  80.             if(getInventoryCount(373) > 0 && getLevel(3) - getCurrentLevel(3) > 12 && !inCombat()) {
  81.                 inventoryChange(373);
  82.                 useItem(getInventoryIndex(373));               
  83.                 return random(50, 150);
  84.             }
  85.             else if(getInventoryCount() == 30 || getCurrentLevel(3) < 15) {
  86.                 if(getFatigue() > 75)
  87.                     sleepAt = 0;
  88.                 if(getCurrentLevel(3) < 15 && getInventoryCount(373) == 0 && !foodChanged) {
  89.                     foodCount++;
  90.                     foodChanged = true;
  91.                     System.out.println("Increasing food count to " + foodCount);                   
  92.                 }
  93.                 if(distanceTo(593, 3589) > 10 || inCombat()) {
  94.                     if(getY() < 3572) {
  95.                         myWalkTo(600, 3574);
  96.                     }
  97.                     else if(getY() < 3577)
  98.                         myWalkTo(598, 3578);
  99.                     else
  100.                         myWalkTo(598, 3581);
  101.                     return random(750, 1250);              
  102.                 } else {
  103.                     atObject(598, 3582);
  104.                     return random(750, 1250);
  105.                 }
  106.             } else {
  107.                 int[] druid = getNpcById(new int[]{555});
  108.                 int[] items = getItemById(pickUpIds);
  109.                 int[] bones = getItemById(BONES);              
  110.                 if(inCombat()) {
  111.                     return random(120, 150);
  112.                 }
  113.                 else if(getInventoryCount(BONES) > 0) {
  114.                     useItem(getInventoryIndex(BONES));
  115.                     return random(50, 125);
  116.                 }
  117.                 else if(items[0] != -1 && inArea(items[1], items[2], 593, 3581, 608, 3563)) {
  118.                     pickupItem(items[0], items[1], items[2]);
  119.                     return random(550, 750);
  120.                 }              
  121.                 else if(druid[0] != -1 && inArea(druid[1], druid[2], 593, 3581, 608, 3563)) {
  122.                     attackNpc(druid[0]);
  123.                     return random(350, 750);
  124.                 }
  125.                 else if(buryBones && bones[0] != -1 && inArea(bones[1], bones[2], 593, 3581, 608, 3563)) {
  126.                     pickupItem(bones[0], bones[1], bones[2]);
  127.                     return random(250, 350);
  128.                 }
  129.             }
  130.         }
  131.         else if(inArea(576, 3584, 598, 3589)) { //druid area
  132.             batCounter = 0;
  133.             if(getInventoryCount(373) > 0 && getCurrentLevel(3) < 30) {
  134.                 inventoryChange(373);
  135.                 useItem(getInventoryIndex(373));               
  136.                 return random(50, 150);
  137.             }
  138.             else if(getInventoryCount() == 30 || getCurrentLevel(3) < 15) {
  139.                 if(getCurrentLevel(3) < 15 && getInventoryCount(373) == 0 && !foodChanged) {
  140.                     foodCount++;
  141.                     foodChanged = true;
  142.                     System.out.println("Increasing food count to " + foodCount);                   
  143.                 }
  144.                 if(distanceTo(593, 3589) > 10 || inCombat()) {
  145.                     myWalkTo(592, 3586);
  146.                     return random(750, 1250);              
  147.                 } else {
  148.                     atWallObject2(593, 3590);
  149.                     return random(750, 1250);
  150.                 }
  151.             } else {
  152.                 if(distanceTo(595, 3585) > 12) {
  153.                     myWalkTo(590, 3586);
  154.                 } else {
  155.                     if(getFatigue() > 75)
  156.                         sleepAt = 0;
  157.                     atObject(596, 3584);
  158.                     return random(2000, 3000);                 
  159.                 }
  160.             }
  161.         } else if(inArea(591, 3590, 596, 3597)) {//inside locked door
  162.             batCounter++;
  163.             if(inCombat()) {
  164.                 if(getInventoryCount() == 30 || getCurrentLevel(3) < 15) {
  165.                     myWalkTo(594,3593);
  166.                 } else
  167.                     myWalkTo(593,3590);
  168.                 return random(125, 200);
  169.             }
  170.             else if(batCounter > 500 && getCurrentLevel(3) >= 15) {
  171.                 int[] bat = getNpcById(new int[]{43});
  172.                 if(bat[0] != -1 && (bat[1] == 594 || bat[1] == 593) && (bat[2] <  3593)) {
  173.                     batCounter = 0;
  174.                     attackNpc(bat[0]);
  175.                     return random(350, 550);
  176.                 }
  177.                
  178.             }
  179.             else if(getInventoryCount() == 30 || getCurrentLevel(3) < 15) {
  180.                 atObject(591, 3593);
  181.                 updateWalk(591, 3593, 0);
  182.                 return random(1250, 2500);
  183.             } else {
  184.                 atWallObject2(593, 3590);
  185.                 return random(750, 1250);
  186.             }          
  187.         } else if(inArea(589, 761, 593, 764)) { //shack
  188.             batCounter = 0;
  189.             foodChanged = false;
  190.             if(getInventoryCount(pickUpIds) > 0 || getCurrentLevel(3) < 15) {
  191.                 if(getWallObjectIdFromCoords(591, 765) == 2) {
  192.                         updateWalk(591, 765, 0);
  193.                         atWallObject(591, 765);
  194.                         return random(1250, 1500);
  195.                     } else {
  196.                         myWalkTo(580, 765);
  197.                         return random(750, 1250);
  198.                     }
  199.             } else {
  200.                 updateWalk(591, 761, 0, 2500);
  201.                 atObject(591, 761);
  202.                 return random(1250, 2500);
  203.             }
  204.         } else if(inArea(590, 758, 585, 750)) { //bank
  205.             if(getInventoryCount(pickUpIds) > 0 || getCurrentLevel(3) < 15) {
  206.                 if(isBanking()) {
  207.                     if(getLevel(3) - getCurrentLevel(3) < 5 && getInventoryCount(373) > 0 && !foodChanged) {
  208.                         foodCount = foodCount > 0 ? foodCount - 1 : 0;
  209.                         foodChanged = true;
  210.                         System.out.println("Decreasing food count to " + foodCount);
  211.                     }
  212.                     for(int c = 0; c < pickUpIds.length; c++) {
  213.                         if(getInventoryCount(pickUpIds[c]) > 0) {
  214.                             myDeposit(pickUpIds[c], getInventoryCount(pickUpIds[c]));
  215.                             return random(250, 550);
  216.                         }
  217.                     }
  218.                     System.out.println("need " + (((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount) + " lobbies (" + foodCount + ")");
  219.                     if(getInventoryCount(373) < ((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount && ((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount > 1) {
  220.                         myWithdraw(373, ((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount - getInventoryCount(373));  
  221.                         return random(550, 750);
  222.                     }
  223.                     else {
  224.                         if(getInventoryCount(373) > 1 && foodCount < 1) {
  225.                             myDeposit(373, getInventoryCount(373) - foodCount);
  226.                             return random(250, 550);
  227.                         }
  228.                         closeBank();
  229.                     }
  230.                     System.out.println(print());                   
  231.                     return random(250, 550);
  232.                 } else if(isQuestMenu()) {
  233.                     answer(0);
  234.                     bankWait = true;
  235.                     questMenuWait = false;
  236.                     lastBankClick = System.currentTimeMillis();    
  237.                     return random(125, 150);
  238.                 } else {
  239.                     if(getInventoryCount(373) > 0 && getLevel(3) - getCurrentLevel(3) >= 12) {
  240.                         inventoryChange(373);
  241.                         useItem(getInventoryIndex(373));
  242.                         return random(100, 250);                       
  243.                     } else {               
  244.                         int[] banker = getNpcByIdNotTalk(BANKERS);
  245.                         bankLimit = 5000;                  
  246.                         if(banker[0] != -1) {
  247.                             updateWalk(banker[1], banker[2], 1);                   
  248.                             talkToNpc(banker[0]);
  249.                             questMenuWait = true;
  250.                             lastQuestMenuClick = System.currentTimeMillis();
  251.                             return random(1500, 2000);
  252.                         } else
  253.                             System.out.println("Cannot find bankers...");
  254.                     }
  255.                 }
  256.             } else {
  257.                 if(isBanking()) {
  258.                     System.out.println("need " + (((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount) + " lobbies (" + foodCount + ")");
  259.                     if(getInventoryCount(373) < (((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount)) {
  260.                         myWithdraw(373, ((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount);
  261.                         return random(550, 750);                       
  262.                     } else  {
  263.                         if(getInventoryCount(373) > (((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount)) {
  264.                             myDeposit(373, getInventoryCount(373) - ((((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount)));
  265.                             return random(550, 750);
  266.                         } else {
  267.                             System.out.println(print());
  268.                             closeBank();
  269.                         }
  270.                     }
  271.                     return random(250, 450);
  272.                 } else {
  273.                     if(getInventoryCount(373) > 0 && getLevel(3) - getCurrentLevel(3) >= 12) {
  274.                         inventoryChange(373);
  275.                         useItem(getInventoryIndex(373));
  276.                         return random(100, 250);                       
  277.                     }
  278.                     else if(distanceTo(591,764) > 15) {
  279.                         myWalkTo(585, 766);
  280.                         return random(750, 1250);
  281.                     } else if(getWallObjectIdFromCoords(591, 765) == 2) {
  282.                         updateWalk(591, 765, 0);
  283.                         atWallObject(591, 765);
  284.                         return random(1250, 1500);
  285.                     } else {
  286.                         myWalkTo(591,764);
  287.                         return random(750, 1250);
  288.                     }
  289.                 }
  290.             }
  291.         } else if(getY() < 3000) {
  292.             if(getInventoryCount(pickUpIds) > 0) {
  293.                 myWalkTo(587, 754);
  294.                 return random(750, 1250);
  295.             } else {
  296.                 if(getWallObjectIdFromCoords(591, 765) == 2) {
  297.                     atWallObject(591, 765);
  298.                     updateWalk(591, 765, 0);
  299.                     return random(1250, 1500);
  300.                 } else {
  301.                     myWalkTo(591, 764);                
  302.                     return random(750, 1250);
  303.                 }
  304.             }
  305.         }
  306.         return random(150, 250);
  307.     }
  308.    
  309.     boolean questMenuWait = false;
  310.     long lastQuestMenuClick = 0;
  311.     long questMenuLimit = 3000;
  312.      
  313.     boolean bankWait = false;
  314.     long lastBankClick = 0;
  315.     long bankLimit = 5000;   
  316.      
  317.     boolean bankWDWait = false;
  318.     long lastBankWDClick = 0;
  319.     long bankWDLimit = 4000;
  320.     int bankItemInvCount = 0;
  321.     int bankItemId = 0;
  322.    
  323.     public void inventoryChange(int id) {
  324.         bankWDWait = true;
  325.         lastBankWDClick = System.currentTimeMillis();
  326.         bankItemInvCount = getInventoryCount(id);
  327.         bankItemId = id;   
  328.     }
  329.    
  330.     public void myWithdraw(int id, int amount) {
  331.         bankedItems.put(id, bankedItems.get(id) == null ? amount : bankedItems.get(id) - amount);
  332.         inventoryChange(id);
  333.         withdraw(id, amount);
  334.     }
  335.     public void myDeposit(int id, int amount) {
  336.         bankedItems.put(id, bankedItems.get(id) == null ? amount : bankedItems.get(id) + amount);  
  337.         inventoryChange(id);
  338.         deposit(id, amount);
  339.     }  
  340.    
  341.    
  342.     public String print() {
  343.         StringBuilder thePrint = new StringBuilder();
  344.         thePrint.append("Items obtained in ");
  345.         thePrint.append((double)((double)(System.currentTimeMillis() - startTime))/(1000*60));
  346.         thePrint.append(" minutes.\n");    
  347.         thePrint.append("\tItem                         Amount\n");
  348.         int distanceAway = 25;
  349.         //Object[] ids = bankedItems.keySet().toArray();
  350.         for(int c = 0; c < pickUpIds.length; c++) {
  351.             if(bankedItems.get(pickUpIds[c]) != null && bankedItems.get(pickUpIds[c]) != 0) {
  352.                 thePrint.append("\t");
  353.                 thePrint.append(itemName[c]);
  354.                 for(int d = 0; d + itemName[c].length() < distanceAway; d++)
  355.                     thePrint.append(" ");      
  356.                 thePrint.append(bankedItems.get(pickUpIds[c]));
  357.                 thePrint.append("\n");         
  358.             }
  359.         }
  360.         return (thePrint.toString());  
  361.     }  
  362.  
  363.     public boolean inArea(int x1, int y1, int x2, int y2) {
  364.         return inArea(getX(), getY(), x1, y1, x2, y2);
  365.     }
  366.  
  367.     public boolean inArea(int myx, int myy, int x1, int y1, int x2, int y2) {
  368.         if(myx <= x1 && myx >= x2 && myy >= y1 && myy <= y2) {
  369.             return true;
  370.         } else if(myx <= x2 && myx >= x1 && myy >= y2 && myy <= y1) {
  371.             return true;
  372.         } else if(myx <= x1 && myx >= x2 && myy >= y2 && myy <= y1) {
  373.             return true;
  374.         } else if(myx <= x2 && myx >= x1 && myy >= y1 && myy <= y2) {
  375.             return true;
  376.         } else
  377.             return false;
  378.     }  
  379.    
  380.     public void myWalkTo(int x, int y) {
  381.         updateWalk(x, y, 3, 3000);
  382.         walkTo(x, y);
  383.     }
  384.  
  385.     long lastWalk = 0;
  386.     int walkWaitLimit = 3000;
  387.     int destX = -1;
  388.     int destY = -1;
  389.     int curX = -1;
  390.     int curY = -1;
  391.     int destDist = 3;
  392.     boolean walkWait = false;
  393.     public void updateWalk(int x, int y, int dist, int limit) {
  394.         //if(debug) System.out.println(x + ", " + y);
  395.         this.destDist = dist;
  396.         this.walkWaitLimit = limit;                
  397.         this.destX = x;
  398.         this.destY = y;
  399.         this.curX = getX();
  400.         this.curY = getY();
  401.         this.lastWalk = System.currentTimeMillis();
  402.         this.walkWait = true;
  403.     }
  404.    
  405.     public void updateWalk(int x, int y, int dist) {
  406.         //if(debug) System.out.println(x + ", " + y);  
  407.         this.destDist = dist;
  408.         this.walkWaitLimit = (distanceTo(getX(), getY(), x, y) * 1000) + 1000;                 
  409.         this.destX = x;
  410.         this.destY = y;
  411.         this.curX = getX();
  412.         this.curY = getY();
  413.         this.lastWalk = System.currentTimeMillis();
  414.         this.walkWait = true;
  415.     }  
  416.    
  417.     public int walkToNextCoord(int position, int[] x, int[] y) {
  418.         //if(position >= x.length || position < 0)
  419.         //  return -1;
  420.         int distance = 15;
  421.         int[] destination = {x[x.length - 1], y[y.length - 1]};
  422.         int[] nextCoords = {-1, -1};
  423.         for(int d = 0; d < 10; d++) { //&& nextCoords[0] != -1
  424.             //if(debug) System.out.println("Distance set to " + (distance + d));       
  425.             for(int c = x.length - 1; c >= 0; c--) {
  426.                 if(distanceTo(getX(), getY(), x[c], y[c]) < (distance + d) && (distanceTo(x[c], y[c], destination[0], destination[1]) < distanceTo(getX(), getY(), destination[0], destination[1]))) {
  427.                     nextCoords[0] = x[c];
  428.                     nextCoords[1] = y[c];
  429.                 }
  430.             }
  431.         }
  432.         if(nextCoords[0] == -1) {
  433.             System.out.println("lame sauce " + x[position] + ", " + y[position]);
  434.             for(int c = x.length - 1; c >= 0; c--) {
  435.                 if(distanceTo(getX(), getY(), x[c], y[c]) < 15) {
  436.                     nextCoords[0] = x[c];
  437.                     nextCoords[1] = y[c];
  438.                 }
  439.             }          
  440.         }
  441.         //if() {
  442.             //System.out.println(nextCoords[0] + ", " + nextCoords[1]);
  443.             if(nextCoords[0] != -1) {
  444.                 updateWalk(nextCoords[0], nextCoords[1], 5, 3000);
  445.                 walkTo(nextCoords[0], nextCoords[1]);
  446.             } else
  447.                 System.out.println("Error walking... currently at " + getX() + ", " + getY());
  448.             return position + 1;
  449.         //} else {
  450.         // return -1;
  451.         //}
  452.     }      
  453.    
  454.   /*public int[] getFreeNpcById(int[] paramArrayOfInt)
  455.   {
  456.     int[] arrayOfInt = { -1, -1, -1 };
  457.  
  458.     int i = Integer.MAX_VALUE;
  459.     for (int j = 0; j < e.countNpcs(); j++)
  460.     {
  461.       if ((!inArray(paramArrayOfInt, e.getNpcId(j))) || (e.isNpcInCombat(j)))
  462.         continue;
  463.       int k = (e.getNpcX(j) - 64) / e.getDivisor() + e.getTileX();
  464.       int m = (e.getNpcY(j) - 64) / e.getDivisor() + e.getTileY();
  465.       int n = distanceTo(k, m, getX(), getY());
  466.       if (n >= i)
  467.         continue;
  468.       arrayOfInt[0] = j;
  469.       arrayOfInt[1] = k;
  470.       arrayOfInt[2] = m;
  471.       i = n;
  472.     }
  473.  
  474.     return arrayOfInt;
  475.   } */
  476.  
  477.   /*public int countPlayersInArea(int x1, int y1, int x2, int y2) {
  478.     int ret = 0;
  479.     lb[] chars = e.getPlayerArray();
  480.     for(int c = 0; c < chars.length; c++)
  481.         if(chars[c] != null && inArea((chars[c].E - 64) / e.getDivisor() + e.getTileX(), (chars[c].j - 64) / e.getDivisor() + e.getTileY(), x1, y1, x2, y2))
  482.             ret++;
  483.     return ret;
  484.   }*/
  485.  
  486.  }
Add Comment
Please, Sign In to add comment