Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.ArrayList;
- public class ChaosWarrior_highonly extends Script {
- boolean buryBones = true;
- Extension e;
- public ChaosWarrior_highonly(Extension e) {
- super(e);
- this.e = e;
- }
- int[] pickUpIds = {31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 46, 619, 825,
- 442, 441, 440, 439, 220, 438, 443,
- 566, 464, 381, 526, 527, 469, 220, 471, 997, 473, 997,
- 157, 158, 159, 160};
- 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",
- "Soul-Rune", "Muddy Cadantine", "Muddy Kwuarm", "Muddy Avantoe", "Muddy Irit Leaf", "Limpwurt Root", "Muddy Ranarr Weed", "Muddy Dwarf Weed",
- "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",
- "Uncut Diamond", "Uncut Ruby", "Uncut Emerald", "Uncut Sapphire"};
- public void init(String params) {
- bankedItems = new HashMap<Integer, Integer>();
- fightMode = getFightMode();
- startTime = System.currentTimeMillis();
- //loadIRCBot();
- }
- long startTime = 0;
- int fightMode = 1;
- int batCounter = 0;
- int sleepAt = 93;
- int foodCount = 4;
- boolean foodChanged = false;
- HashMap<Integer, Integer> bankedItems;
- public int main() {
- if(isSleeping()) {
- return random(350, 550);
- } else if(getFightMode() != fightMode) {
- setFightMode(fightMode);
- return random(50, 75);
- }
- else if(getInventoryCount(714) == 0) {
- System.out.println("You need a picklock in your inventory for this script...");
- stopScript();
- }
- else if(getFatigue() >= sleepAt) { //sleep
- sleepAt = random(85, 100);
- useSleepingBag();
- return random(650, 1000);
- }
- else if(bankWDWait) {
- if(getInventoryCount(bankItemId) == bankItemInvCount && System.currentTimeMillis() - lastBankWDClick < bankLimit)
- return random(350, 500);
- else {
- bankWDWait = false;
- return random(10, 50);
- }
- }
- else if(walkWait && !isBanking() && !isQuestMenu()) {
- if(distanceTo(getX(), getY(), destX, destY) <= destDist) {
- walkWait = false;
- return random(50, 150);
- } else if(curX != getX() && curY != getY() && System.currentTimeMillis() - lastWalk < walkWaitLimit) {
- return random(750, 1250);
- } else
- walkWait = false;
- }
- else if(!isQuestMenu() && questMenuWait && System.currentTimeMillis() - lastQuestMenuClick < questMenuLimit) {
- return random(125, 200);
- }
- else if(!isBanking() && bankWait && System.currentTimeMillis() - lastBankClick < bankLimit) {
- return random(125, 200);
- }
- else if(inArea(593, 3581, 608, 3563)) {//warrors area
- if(getInventoryCount(373) > 0 && getLevel(3) - getCurrentLevel(3) > 12 && !inCombat()) {
- inventoryChange(373);
- useItem(getInventoryIndex(373));
- return random(50, 150);
- }
- else if(getInventoryCount() == 30 || getCurrentLevel(3) < 15) {
- if(getFatigue() > 75)
- sleepAt = 0;
- if(getCurrentLevel(3) < 15 && getInventoryCount(373) == 0 && !foodChanged) {
- foodCount++;
- foodChanged = true;
- System.out.println("Increasing food count to " + foodCount);
- }
- if(distanceTo(593, 3589) > 10 || inCombat()) {
- if(getY() < 3572) {
- myWalkTo(600, 3574);
- }
- else if(getY() < 3577)
- myWalkTo(598, 3578);
- else
- myWalkTo(598, 3581);
- return random(750, 1250);
- } else {
- atObject(598, 3582);
- return random(750, 1250);
- }
- } else {
- int[] druid = getNpcById(new int[]{555});
- int[] items = getItemById(pickUpIds);
- int[] bones = getItemById(BONES);
- if(inCombat()) {
- return random(120, 150);
- }
- else if(getInventoryCount(BONES) > 0) {
- useItem(getInventoryIndex(BONES));
- return random(50, 125);
- }
- else if(items[0] != -1 && inArea(items[1], items[2], 593, 3581, 608, 3563)) {
- pickupItem(items[0], items[1], items[2]);
- return random(550, 750);
- }
- else if(druid[0] != -1 && inArea(druid[1], druid[2], 593, 3581, 608, 3563)) {
- attackNpc(druid[0]);
- return random(350, 750);
- }
- else if(buryBones && bones[0] != -1 && inArea(bones[1], bones[2], 593, 3581, 608, 3563)) {
- pickupItem(bones[0], bones[1], bones[2]);
- return random(250, 350);
- }
- }
- }
- else if(inArea(576, 3584, 598, 3589)) { //druid area
- batCounter = 0;
- if(getInventoryCount(373) > 0 && getCurrentLevel(3) < 30) {
- inventoryChange(373);
- useItem(getInventoryIndex(373));
- return random(50, 150);
- }
- else if(getInventoryCount() == 30 || getCurrentLevel(3) < 15) {
- if(getCurrentLevel(3) < 15 && getInventoryCount(373) == 0 && !foodChanged) {
- foodCount++;
- foodChanged = true;
- System.out.println("Increasing food count to " + foodCount);
- }
- if(distanceTo(593, 3589) > 10 || inCombat()) {
- myWalkTo(592, 3586);
- return random(750, 1250);
- } else {
- atWallObject2(593, 3590);
- return random(750, 1250);
- }
- } else {
- if(distanceTo(595, 3585) > 12) {
- myWalkTo(590, 3586);
- } else {
- if(getFatigue() > 75)
- sleepAt = 0;
- atObject(596, 3584);
- return random(2000, 3000);
- }
- }
- } else if(inArea(591, 3590, 596, 3597)) {//inside locked door
- batCounter++;
- if(inCombat()) {
- if(getInventoryCount() == 30 || getCurrentLevel(3) < 15) {
- myWalkTo(594,3593);
- } else
- myWalkTo(593,3590);
- return random(125, 200);
- }
- else if(batCounter > 500 && getCurrentLevel(3) >= 15) {
- int[] bat = getNpcById(new int[]{43});
- if(bat[0] != -1 && (bat[1] == 594 || bat[1] == 593) && (bat[2] < 3593)) {
- batCounter = 0;
- attackNpc(bat[0]);
- return random(350, 550);
- }
- }
- else if(getInventoryCount() == 30 || getCurrentLevel(3) < 15) {
- atObject(591, 3593);
- updateWalk(591, 3593, 0);
- return random(1250, 2500);
- } else {
- atWallObject2(593, 3590);
- return random(750, 1250);
- }
- } else if(inArea(589, 761, 593, 764)) { //shack
- batCounter = 0;
- foodChanged = false;
- if(getInventoryCount(pickUpIds) > 0 || getCurrentLevel(3) < 15) {
- if(getWallObjectIdFromCoords(591, 765) == 2) {
- updateWalk(591, 765, 0);
- atWallObject(591, 765);
- return random(1250, 1500);
- } else {
- myWalkTo(580, 765);
- return random(750, 1250);
- }
- } else {
- updateWalk(591, 761, 0, 2500);
- atObject(591, 761);
- return random(1250, 2500);
- }
- } else if(inArea(590, 758, 585, 750)) { //bank
- if(getInventoryCount(pickUpIds) > 0 || getCurrentLevel(3) < 15) {
- if(isBanking()) {
- if(getLevel(3) - getCurrentLevel(3) < 5 && getInventoryCount(373) > 0 && !foodChanged) {
- foodCount = foodCount > 0 ? foodCount - 1 : 0;
- foodChanged = true;
- System.out.println("Decreasing food count to " + foodCount);
- }
- for(int c = 0; c < pickUpIds.length; c++) {
- if(getInventoryCount(pickUpIds[c]) > 0) {
- myDeposit(pickUpIds[c], getInventoryCount(pickUpIds[c]));
- return random(250, 550);
- }
- }
- System.out.println("need " + (((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount) + " lobbies (" + foodCount + ")");
- if(getInventoryCount(373) < ((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount && ((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount > 1) {
- myWithdraw(373, ((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount - getInventoryCount(373));
- return random(550, 750);
- }
- else {
- if(getInventoryCount(373) > 1 && foodCount < 1) {
- myDeposit(373, getInventoryCount(373) - foodCount);
- return random(250, 550);
- }
- closeBank();
- }
- System.out.println(print());
- return random(250, 550);
- } else if(isQuestMenu()) {
- answer(0);
- bankWait = true;
- questMenuWait = false;
- lastBankClick = System.currentTimeMillis();
- return random(125, 150);
- } else {
- if(getInventoryCount(373) > 0 && getLevel(3) - getCurrentLevel(3) >= 12) {
- inventoryChange(373);
- useItem(getInventoryIndex(373));
- return random(100, 250);
- } else {
- int[] banker = getNpcByIdNotTalk(BANKERS);
- bankLimit = 5000;
- if(banker[0] != -1) {
- updateWalk(banker[1], banker[2], 1);
- talkToNpc(banker[0]);
- questMenuWait = true;
- lastQuestMenuClick = System.currentTimeMillis();
- return random(1500, 2000);
- } else
- System.out.println("Cannot find bankers...");
- }
- }
- } else {
- if(isBanking()) {
- System.out.println("need " + (((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount) + " lobbies (" + foodCount + ")");
- if(getInventoryCount(373) < (((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount)) {
- myWithdraw(373, ((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount);
- return random(550, 750);
- } else {
- if(getInventoryCount(373) > (((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount)) {
- myDeposit(373, getInventoryCount(373) - ((((getLevel(3) - getCurrentLevel(3)) / 12) + foodCount)));
- return random(550, 750);
- } else {
- System.out.println(print());
- closeBank();
- }
- }
- return random(250, 450);
- } else {
- if(getInventoryCount(373) > 0 && getLevel(3) - getCurrentLevel(3) >= 12) {
- inventoryChange(373);
- useItem(getInventoryIndex(373));
- return random(100, 250);
- }
- else if(distanceTo(591,764) > 15) {
- myWalkTo(585, 766);
- return random(750, 1250);
- } else if(getWallObjectIdFromCoords(591, 765) == 2) {
- updateWalk(591, 765, 0);
- atWallObject(591, 765);
- return random(1250, 1500);
- } else {
- myWalkTo(591,764);
- return random(750, 1250);
- }
- }
- }
- } else if(getY() < 3000) {
- if(getInventoryCount(pickUpIds) > 0) {
- myWalkTo(587, 754);
- return random(750, 1250);
- } else {
- if(getWallObjectIdFromCoords(591, 765) == 2) {
- atWallObject(591, 765);
- updateWalk(591, 765, 0);
- return random(1250, 1500);
- } else {
- myWalkTo(591, 764);
- return random(750, 1250);
- }
- }
- }
- return random(150, 250);
- }
- boolean questMenuWait = false;
- long lastQuestMenuClick = 0;
- long questMenuLimit = 3000;
- boolean bankWait = false;
- long lastBankClick = 0;
- long bankLimit = 5000;
- boolean bankWDWait = false;
- long lastBankWDClick = 0;
- long bankWDLimit = 4000;
- int bankItemInvCount = 0;
- int bankItemId = 0;
- public void inventoryChange(int id) {
- bankWDWait = true;
- lastBankWDClick = System.currentTimeMillis();
- bankItemInvCount = getInventoryCount(id);
- bankItemId = id;
- }
- public void myWithdraw(int id, int amount) {
- bankedItems.put(id, bankedItems.get(id) == null ? amount : bankedItems.get(id) - amount);
- inventoryChange(id);
- withdraw(id, amount);
- }
- public void myDeposit(int id, int amount) {
- bankedItems.put(id, bankedItems.get(id) == null ? amount : bankedItems.get(id) + amount);
- inventoryChange(id);
- deposit(id, amount);
- }
- public String print() {
- StringBuilder thePrint = new StringBuilder();
- thePrint.append("Items obtained in ");
- thePrint.append((double)((double)(System.currentTimeMillis() - startTime))/(1000*60));
- thePrint.append(" minutes.\n");
- thePrint.append("\tItem Amount\n");
- int distanceAway = 25;
- //Object[] ids = bankedItems.keySet().toArray();
- for(int c = 0; c < pickUpIds.length; c++) {
- if(bankedItems.get(pickUpIds[c]) != null && bankedItems.get(pickUpIds[c]) != 0) {
- thePrint.append("\t");
- thePrint.append(itemName[c]);
- for(int d = 0; d + itemName[c].length() < distanceAway; d++)
- thePrint.append(" ");
- thePrint.append(bankedItems.get(pickUpIds[c]));
- thePrint.append("\n");
- }
- }
- return (thePrint.toString());
- }
- public boolean inArea(int x1, int y1, int x2, int y2) {
- return inArea(getX(), getY(), x1, y1, x2, y2);
- }
- public boolean inArea(int myx, int myy, int x1, int y1, int x2, int y2) {
- if(myx <= x1 && myx >= x2 && myy >= y1 && myy <= y2) {
- return true;
- } else if(myx <= x2 && myx >= x1 && myy >= y2 && myy <= y1) {
- return true;
- } else if(myx <= x1 && myx >= x2 && myy >= y2 && myy <= y1) {
- return true;
- } else if(myx <= x2 && myx >= x1 && myy >= y1 && myy <= y2) {
- return true;
- } else
- return false;
- }
- public void myWalkTo(int x, int y) {
- updateWalk(x, y, 3, 3000);
- walkTo(x, y);
- }
- long lastWalk = 0;
- int walkWaitLimit = 3000;
- int destX = -1;
- int destY = -1;
- int curX = -1;
- int curY = -1;
- int destDist = 3;
- boolean walkWait = false;
- public void updateWalk(int x, int y, int dist, int limit) {
- //if(debug) System.out.println(x + ", " + y);
- this.destDist = dist;
- this.walkWaitLimit = limit;
- this.destX = x;
- this.destY = y;
- this.curX = getX();
- this.curY = getY();
- this.lastWalk = System.currentTimeMillis();
- this.walkWait = true;
- }
- public void updateWalk(int x, int y, int dist) {
- //if(debug) System.out.println(x + ", " + y);
- this.destDist = dist;
- this.walkWaitLimit = (distanceTo(getX(), getY(), x, y) * 1000) + 1000;
- this.destX = x;
- this.destY = y;
- this.curX = getX();
- this.curY = getY();
- this.lastWalk = System.currentTimeMillis();
- this.walkWait = true;
- }
- public int walkToNextCoord(int position, int[] x, int[] y) {
- //if(position >= x.length || position < 0)
- // return -1;
- int distance = 15;
- int[] destination = {x[x.length - 1], y[y.length - 1]};
- int[] nextCoords = {-1, -1};
- for(int d = 0; d < 10; d++) { //&& nextCoords[0] != -1
- //if(debug) System.out.println("Distance set to " + (distance + d));
- for(int c = x.length - 1; c >= 0; c--) {
- 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]))) {
- nextCoords[0] = x[c];
- nextCoords[1] = y[c];
- }
- }
- }
- if(nextCoords[0] == -1) {
- System.out.println("lame sauce " + x[position] + ", " + y[position]);
- for(int c = x.length - 1; c >= 0; c--) {
- if(distanceTo(getX(), getY(), x[c], y[c]) < 15) {
- nextCoords[0] = x[c];
- nextCoords[1] = y[c];
- }
- }
- }
- //if() {
- //System.out.println(nextCoords[0] + ", " + nextCoords[1]);
- if(nextCoords[0] != -1) {
- updateWalk(nextCoords[0], nextCoords[1], 5, 3000);
- walkTo(nextCoords[0], nextCoords[1]);
- } else
- System.out.println("Error walking... currently at " + getX() + ", " + getY());
- return position + 1;
- //} else {
- // return -1;
- //}
- }
- /*public int[] getFreeNpcById(int[] paramArrayOfInt)
- {
- int[] arrayOfInt = { -1, -1, -1 };
- int i = Integer.MAX_VALUE;
- for (int j = 0; j < e.countNpcs(); j++)
- {
- if ((!inArray(paramArrayOfInt, e.getNpcId(j))) || (e.isNpcInCombat(j)))
- continue;
- int k = (e.getNpcX(j) - 64) / e.getDivisor() + e.getTileX();
- int m = (e.getNpcY(j) - 64) / e.getDivisor() + e.getTileY();
- int n = distanceTo(k, m, getX(), getY());
- if (n >= i)
- continue;
- arrayOfInt[0] = j;
- arrayOfInt[1] = k;
- arrayOfInt[2] = m;
- i = n;
- }
- return arrayOfInt;
- } */
- /*public int countPlayersInArea(int x1, int y1, int x2, int y2) {
- int ret = 0;
- lb[] chars = e.getPlayerArray();
- for(int c = 0; c < chars.length; c++)
- 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))
- ret++;
- return ret;
- }*/
- }
Add Comment
Please, Sign In to add comment