Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • NPC onScreen but down a hill


    Booshotti

    Recommended Posts

    Hello,

     

    I am creating a Rock Crabs script and when I go to a specific spot the Crab is down a hill so when the tile is clicked my player does not move down the hill, How could I easily combat this? 

     

    I've tried if(!onScreen.....) { turn camera}  but this will always be false because the NPC is on the screen but just behind the terrain.

     

     

    Thanks ;)

    Link to comment
    Share on other sites

    aint got acces to eclipse rn, but best to go by area gonna be something like this:

    if (crabArea.contains(getLocalPlayer) && crab.isOnScreen() && crab.isReachable()) { 
       if (crab !=null {
           crab.interact("Attack")
      }
    }
    
    Link to comment
    Share on other sites

     

    aint got acces to eclipse rn, but best to go by area gonna be something like this:

    if (crabArea.contains(getLocalPlayer) && crab.isOnScreen() && crab.isReachable()) { 
       if (crab !=null {
           crab.interact("Attack")
      }
    }
    

    Awesome! Will test this out now.

     

     

    Another question... I want to make sure more than one crab is attacking me so I am assuming I can count the getID(); values for the crabs.

    If(crabCount >= 4){
    attack crabs
    minus index on dead crab
    }
    
    if(crabCount == 0){
    walk to crabs
    add index
    repeat above
    }

    I can't think of a good way to track if 4 or more crabs are attacking me at one time?

    Link to comment
    Share on other sites

    Awesome! Will test this out now.

     

     

    Another question... I want to make sure more than one crab is attacking me so I am assuming I can count the getID(); values for the crabs.

    If(crabCount >= 4){
    attack crabs
    minus index on dead crab
    }
    
    if(crabCount == 0){
    walk to crabs
    add index
    repeat above
    }

    I can't think of a good way to track if 4 or more crabs are attacking me at one time?

     

    You can get all npcs interacting with you and count them.

     

    Also I suggest dont check if crab is not null before using the object.

    Link to comment
    Share on other sites

     

    aint got acces to eclipse rn, but best to go by area gonna be something like this:

    if (crabArea.contains(getLocalPlayer) && crab.isOnScreen() && crab.isReachable()) { 
       if (crab !=null {
           crab.interact("Attack")
      }
    }
    

    This logic :D

    Link to comment
    Share on other sites

    You can get all npcs interacting with you and count them.

     

    Also I suggest dont check if crab is not null before using the object.

    if (RockCrab.isInteracting(getLocalPlayer()) && interactionCount <= 4) {
    interactionCount+=1;
    log("Count + 1");

    This doesn't seem to work? It counts 4 on each tick that any rock crab attacks me, Is there another way to count?

    Link to comment
    Share on other sites

    if (RockCrab.isInteracting(getLocalPlayer()) && interactionCount <= 4) {
    interactionCount+=1;
    log("Count + 1");

    This doesn't seem to work? It counts 4 on each tick that any rock crab attacks me, Is there another way to count?

     

     

    I'm assuming something like this would work:

    final int interactionCount = getNpcs().all(npc -> npc != null && npc.isInteracting(getLocalPlayer()) && npc.isInCombat()).size();
    Link to comment
    Share on other sites

     

    I'm assuming something like this would work:

    final int interactionCount = getNpcs().all(npc -> npc != null && npc.isInteracting(getLocalPlayer()) && npc.isInCombat()).size();

     

    Ahhh that helped me understand to make a lot of my script smaller using lambda however... It says Override method in org.dreambot.api.methods.filter.Filter

    Link to comment
    Share on other sites

    Ahhh that helped me understand to make a lot of my script smaller using lambda however... It says Override method in org.dreambot.api.methods.filter.Filter

     

    Uhh not sure. You must not be using Java 8.

    Link to comment
    Share on other sites

    Uhh not sure. You must not be using Java 8.

     

    Strange... I am using Java 8 though (jdk1.8.0_141)

     

     

    Edit: You are the man! ;) It's apparently just a warning on IntelliJ, It works though.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.