Jump to content

Pick up specific item after killing NPC


LagunaPreza

Recommended Posts

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));
			
		}

 

Link to comment
Share on other sites

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
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...