November 3, 20187 yr Simultaneous intro and script submission -- CS student, adept understanding of programming logic, but with little Java knowledge/experience I made this Master Farmer thieving script and want to see what criticism it receives.. NPC masterFarmer = getNpcs().closest("Master Farmer"); int lastCount = getInventory().getEmptySlotCount(); int randReturn = random(40, 138); int randSleep = random(450, 850); int corblimeySleep = random(1800, 2000); RS2Object bankBooth = getObjects().closest("Bank booth"); InteractionEvent useBank = new InteractionEvent(bankBooth, "Bank"); // log(randReturn); if(myPlayer().getHealthPercent() < 40){ getInventory().interact("Eat", "Swordfish"); log("Hungry, eating now"); if(!getInventory().contains("Swordfish")) { if (bankBooth.exists()) { execute(useBank); sleep(randSleep); log("Sleeping for: " + randSleep); useBank.setOperateCamera(false); useBank.setWalkTo(true); log("The Bank is open"); if (getBank().depositAll()) { // we will deposit all .. log("We deposit all"); if (getBank().withdraw("Swordfish", 7)) { new ConditionalSleep(2000, 1000) { //sleep until the inv is empty @Override public boolean condition() throws InterruptedException { return !getInventory().isFull(); } }.sleep(); } } } } } if (!getInventory().isFull() && getInventory().contains("Swordfish")) { InteractionEvent pickEvent = new InteractionEvent(masterFarmer, "Pickpocket"); pickEvent.setOperateCamera(false); pickEvent.setWalkTo(true); if (masterFarmer.exists()) { log("Master Farmer found"); execute(pickEvent); log("Picking pocket"); if(myPlayer().isHitBarVisible()){ sleep(2000); log("Cor Blimey!!"); } new ConditionalSleep(100,25) { @Override public boolean condition() throws InterruptedException { return getInventory().getEmptySlotCount() < lastCount; } }.sleep(); } else{ log("Can not find"); } } else { log("Inventory is full"); if(bankBooth.exists()){ execute(useBank); sleep(randSleep); log("Sleeping for: " + randSleep); useBank.setOperateCamera(false); useBank.setWalkTo(true); log("The Bank is open"); if (getBank().depositAll()) { // we will deposit all .. log("We deposit all"); if (getBank().withdraw("Swordfish", 5)) { new ConditionalSleep(2000, 1000) { @Override public boolean condition() throws InterruptedException { return !getInventory().isFull(); } }.sleep(); } } } else { log("The bank is closed"); if (getBank().open()) { //open the bank log("We opened the bank"); new ConditionalSleep(3000, 1500) { @Override public boolean condition() throws InterruptedException { return getBank().isOpen(); } }.sleep(); } } } return randReturn;} Edited November 3, 20187 yr by ohdonpiano im a nub
November 4, 20187 yr I would extract it to methods to improve readability. And try to make it as generic as possible to reduce duplicate code. Edited November 4, 20187 yr by KEVzilla
Create an account or sign in to comment