Jump to content

Logger says NPC is null but in reality it isn't?


Acerd

Recommended Posts

This has never happened to me so I'm kind of confused why this is happening; basically it walks to an area and interacts with NPC and logs that npc isnt null, goes to bank and then goes back to the area , however this time it logs that the NPC is null.

What am I doing wrong?

code:

NPC npc = getNpcs().closest("NPC"); // onloop
     if (!area.contains(myPlayer()) {
       getWalking().webWalk(area);
            } else {
          if (npc != null) {
       log("npc is not null");
         npc.interact();
          } else {
    log("npc is null");
        }
}
Edited by Acerd
Link to comment
Share on other sites

why not try 

 

  1.    NPC Goblin = npcs.closest("Goblin");
  2.             if (Goblin != null && !(Goblin.isUnderAttack())) //getMap().canReach(Goblin)
  3.             {
  4.                 if (Goblin.isVisible())
  5.                 {
  6.                     Goblin.interact(new String[]{"Attack"});
  7.                     new ConditionalSleep(3000)
  8.                     {                  
  9.                         @Override
  10.                         public boolean condition() throws InterruptedException
  11.                         {
  12.                             return myPlayer().isAnimating() || myPlayer().getInteracting() != null;
  13.                         }
  14.                     }.sleep();
  15.                     }
  16.                 }
  17.                 else if (!Goblin.isVisible())
  18.                 {
  19.                      this.camera.toEntity((Entity) Goblin);
  20.                      if (Goblin.exists() && !Goblin.isVisible())
  21.                      {
  22.                          walking.walk(Goblin);
  23.                          while(myPlayer().isMoving()) {
  24.                                sleep(250);
  25.                            }
  26.                 }
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...