Titan Rs Posted July 13, 2018 Share Posted July 13, 2018 (edited) Hi guys watched a few java vids and chris's tutorials and wanted to try and make a chaos druid script that banks and loots, its works preety well froze an hour in. Theres a few things i cant get my head around. I understand the ways ive got to a solution are probably inefficient and anything that i can improve or read up on please tell me. 1. is there a better way to do my second conditional sleep in killDruids method. Atm it will kill a druid that drops desired loot, kill another and then pick it up. it skips the goLoop method before it appears on floor. 2. My do loop doensnt work in goloot() method, if i get a double herb drop itll only pick one up and then pick the next one up next kill. 3. In goLoot i can only loot things that decrease the free spaces in invent so arnt noted or runes due to the way i program the conditional statement. Chaos druids drop many runes and mith bolts that i cant find a way of picking up. I got 2months of nothing to do and want to put most of my time into scripting. At the end i want to be able to have a preety much fully auto script (lvl 3 to money making) with muling. So any help and things to read java and osbot related would be greatly appreciated. Thanks public class Main extends Script { private final Area chaosDruidPen = new Area(3104,9944,3120,9923); private final String[] GOOD_LOOT = {"Grimy ranarr weed", "Grimy dwarf weed", "Grimy cadantine", "Grimy lantadyme", "Grimy kwuarm", "Grimy avantoe"}; GroundItem loots; @Override public void onStart() throws InterruptedException { } @Override public int onLoop() throws InterruptedException { if (canKillDruids()) { log("Can kill druids"); killDruids(); } else { log("Cant kill druids need to bank"); goBank(); } return random(300, 600); } private boolean canKillDruids() { return !getInventory().isFull() && getInventory().contains("Lobster"); } private void killDruids() { if (myPlayer().getHealthPercent() > 50) { if (inChaosDruidPen()) { log("we are in the right area"); NPC druid = getNpcs().closest(cd -> cd != null && cd.getName().equals("Chaos druid") && (cd.getHealthPercent() > 0) && cd.isAttackable() && cd.exists() && getMap().canReach(cd)); if (druid != null && !getCombat().isFighting()) { log("Found a druid to attack"); druid.interact("Attack"); new ConditionalSleep(3000, 1000) { @Override public boolean condition() throws InterruptedException { return getCombat().isFighting(); } }.sleep(); new ConditionalSleep(20000, 2000) { @Override public boolean condition() throws InterruptedException { return druid.getHealthPercent() == 0; } }.sleep(); goLoot(); } } } else { int count2 = myPlayer().getHealthPercent() ; getInventory().interact("Eat", "Lobster"); new ConditionalSleep(2000) { @Override public boolean condition() throws InterruptedException { return myPlayer().getHealthPercent()> count2; } }.sleep(); } } private void goLoot() { do { GroundItem loots = getGroundItems().closest(l -> l != null && l.exists() && getMap().canReach(l) && Arrays.asList(GOOD_LOOT).contains(l.getName())); if (loots != null) { log("We've found some loot"); int count = getInventory().getEmptySlotCount(); loots.interact("Take"); new ConditionalSleep(5000, 1000) { @Override public boolean condition() throws InterruptedException { return getInventory().getEmptySlotCount() < count; } }.sleep(); } } while ( loots != null && !getInventory().isFull()); } private void goBank() throws InterruptedException { if (!Banks.EDGEVILLE.contains(myPosition())) { getWalking().webWalk(Banks.EDGEVILLE); }else if (!getBank().isOpen()) { getBank().open(); if (getInventory().isFull() || !getInventory().contains("Lobster")) { getBank().depositAllExcept("Air rune", "Mind rune"); if (getBank().contains("Lobster")) { log("Withdrawing Lobbies"); getBank().withdraw("Lobster", 15); } else { stop(true); } } } } private boolean inChaosDruidPen(){ if (!chaosDruidPen.contains(myPosition())) { log("Webwalking to druids"); getWalking().webWalk(chaosDruidPen); return true; }else{ return true; } } } p.s sorry dont know how to do the "reveal hidden contents thing" soz Edited July 13, 2018 by Luke Reading Quote Link to comment Share on other sites More sharing options...
dreameo Posted July 13, 2018 Share Posted July 13, 2018 There's a lot of things wrong lol but here's something I see a lot of people doing: interact method() // boolean New Conditional sleep... Your conditional sleep should only execute if the interact method is true. The way you have it written, the conditional sleep always runs regardless if the interact actually happened. It should always be like this: if (druid.interact("attack")){ insert conditiona sleep here... } It might be hard to get your head to wrap around it. You would think interacts should be a void right(void methods are usually actions and return nothing). Well if you interact, you want to know if it was successful. So that's why the action returns a boolean. 2 Quote Link to comment Share on other sites More sharing options...
Titan Rs Posted July 13, 2018 Author Share Posted July 13, 2018 23 minutes ago, dreameo said: There's a lot of things wrong lol but here's something I see a lot of people doing: interact method() // boolean New Conditional sleep... Your conditional sleep should only execute if the interact method is true. The way you have it written, the conditional sleep always runs regardless if the interact actually happened. It should always be like this: if (druid.interact("attack")){ insert conditiona sleep here... } It might be hard to get your head to wrap around it. You would think interacts should be a void right(void methods are usually actions and return nothing). Well if you interact, you want to know if it was successful. So that's why the action returns a boolean. Thanks dude for the help, ill implement this. 1 Quote Link to comment Share on other sites More sharing options...