Booshotti 0 Share Posted July 22, 2017 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 More sharing options...
Nex 2542 Share Posted July 22, 2017 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 More sharing options...
Booshotti 0 Author Share Posted July 22, 2017 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 More sharing options...
Manly 879 Share Posted July 22, 2017 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 More sharing options...
Soldtodie 76 Share Posted July 22, 2017 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 Link to comment Share on other sites More sharing options...
Booshotti 0 Author Share Posted July 22, 2017 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 More sharing options...
Manly 879 Share Posted July 22, 2017 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 More sharing options...
Booshotti 0 Author Share Posted July 22, 2017 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 More sharing options...
Manly 879 Share Posted July 22, 2017 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 More sharing options...
Booshotti 0 Author Share Posted July 22, 2017 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.