Jump to content

My first OSBot Script


ohdonpiano

Recommended Posts

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 by ohdonpiano
im a nub
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...