Jump to content

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


Recommended Posts

Posted (edited)

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
Posted

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

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