Jump to content

Pick up specific item after killing NPC


Recommended Posts

Posted

Hey all, 

I recently started with Java coding and I'm fooling around now for my own learning purposes, I'm trying to make an easy Imp killer/looter but the looting part isn't working..

The imps will get killed, however when they drop a bead (either black white yellow or red) it just wont pick it up.. Why ?

 

I have this code in the onLoop: (Yes I know I should probably be using cases)

if(!inventory.isFull() && getGroundItems().closest("Black bead", "White bead", "Red bead", "Yellow bead") != null) {
			
			getGroundItems().closest("Black bead").interact("Take");
			getGroundItems().closest("White bead").interact("Take");
			getGroundItems().closest("Red bead").interact("Take");
			getGroundItems().closest("Yellow bead").interact("Take");
			
		} else if(!inventory.isFull() && getNpcs().closest("Imp") != null && !myPlayer().isUnderAttack()) {
			
			getNpcs().closest("Imp").interact("Attack");
			sleep(random(300, 700));
			
		}

 

Posted (edited)

This is a code from my scheme bot .

 

                arr= {"Black bead", "White bead", "Red bead", "Yellow bead"}

                GroundItem ff = Scheme.scemeBot.getGroundItems().closest(arr);
                int emptySlots = Scheme.scemeBot.getInventory().getEmptySlots();
                if (ff!=null&&ff.interact("Take")) {
                    Sleep.sleepUntil(() -> {
                        return Scheme.scemeBot.getInventory().getEmptySlots() < emptySlots || Scheme.scemeBot.getGroundItems().closest(arr) == null;
                    }, 5000);
                }

             

 

 

 

P.S.

You should always null check Things that return objects

getNpcs().closest()

 

Look in to condition sleeps

 

 

 

Edited by Nbacon

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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