October 30, 20169 yr http://i.imgur.com/3koWI1R.png http://i.imgur.com/db6O1P4.png dunno why this is happening to me.. My friend says it works for him but for me it doesnt ;c Any tips?
October 30, 20169 yr http://i.imgur.com/3koWI1R.png http://i.imgur.com/db6O1P4.png dunno why this is happening to me.. My friend says it works for him but for me it doesnt ;c Any tips? edit: my bad didnt see 2nd image. looking now >> what @@Manner said Edited October 30, 20169 yr by Imateamcape
October 30, 20169 yr Make sure you are using the java 1.8 compiler, so that it supports lambda expressions. http://stackoverflow.com/questions/22544064/java-8-lambdas-dont-work-everything-else-from-java-8-works-though
October 30, 20169 yr Author Make sure you are using the java 1.8 compiler, so that it supports lambda expressions. http://stackoverflow.com/questions/22544064/java-8-lambdas-dont-work-everything-else-from-java-8-works-though I don't have 1.8 tho.. I can only see 1.7 Edit: downloading the update now, ill let u know how it goes Edited October 30, 20169 yr by PuppyLover101
October 30, 20169 yr Getting yellow lines now http://i.imgur.com/lxK4y4Y.png Yellow lines are warnings. Also that could be simplified to: NPC cow = getNpcs().closest(npc -> npc.getName().startsWith("Cow") && npc.isAttackable() && cowArea.contains(npc));
October 30, 20169 yr Author Yellow lines are warnings. Also that could be simplified to: NPC cow = getNpcs().closest(npc -> npc.getName().startsWith("Cow") && npc.isAttackable() && cowArea.contains(npc)); Hmmm thanks, but it shows this still:- http://i.imgur.com/t8rwK0l.png
October 30, 20169 yr Hmmm thanks, but it shows this still:- http://i.imgur.com/t8rwK0l.png can you please hover over the warning and tell use what it says?
October 30, 20169 yr NPCs closest returns a single NPC, not a collection of NPCs for you to filter. You want something like: Optional<NPC> suitableNpc = getNpcs().getAll().stream().filter(npc -> npc.getHealthPercent() > 1).findFirst(); if (suitableNpc.isPresent()) { suitableNpc.get().interact("examine"); } You may want to look a little bit into Java 8 streams before using them. Edit:Or better yet you can use the FilterAPI way which is native to OSBot getNpcs().closest(new Filter<NPC>() { @[member='Override'] public boolean match(NPC obj) { return obj.getHealthPercent() > 1; } }) ; EntityAPI: http://osbot.org/api/org/osbot/rs07/api/EntityAPI.html
October 30, 20169 yr Author Thanks alot guys~ if(cowArea.contains(myPlayer())) { NPC cow = getNpcs().closest("Cow", "Cow calf"); if (cow != null && !combat.isFighting() && !cow.isUnderAttack()) { cow.interact("Attack"); new ConditionalSleep(5000) { @@Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating() || myPlayer().isInteracting(cow); } }.sleep(); } is what i used. I have one last problem. For some reason it takes a LONG time to loot cowhide/choose a different NPC (after killing cow, finding out someone already attking it or if it's under attk.) thanks
October 30, 20169 yr Thanks alot guys~ if(cowArea.contains(myPlayer())) { NPC cow = getNpcs().closest("Cow", "Cow calf"); if (cow != null && !combat.isFighting() && !cow.isUnderAttack()) { cow.interact("Attack"); new ConditionalSleep(5000) { @@Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating() || myPlayer().isInteracting(cow); } }.sleep(); } is what i used. I have one last problem. For some reason it takes a LONG time to loot cowhide/choose a different NPC (after killing cow, finding out someone already attking it or if it's under attk.) thanks Think about it logically, you're using "closest". It will always return the closest cow to you and if that closest cow is under attack then you are going to be waiting until that cow is killed. Use one of the methods above to filter cows by distance/area, health > 0, not under attack, etc. After that you're going to want to sort those results by distance. This way you only get cows which you can attack, ordered by distance (instead of all cows which you don't know if you can attack or not).
October 31, 20169 yr Author Think about it logically, you're using "closest". It will always return the closest cow to you and if that closest cow is under attack then you are going to be waiting until that cow is killed. Use one of the methods above to filter cows by distance/area, health > 0, not under attack, etc. After that you're going to want to sort those results by distance. This way you only get cows which you can attack, ordered by distance (instead of all cows which you don't know if you can attack or not). if (cowArea.contains(myPlayer())) { NPC cow = getNpcs().closest("Cow", "Cow calf"); if (cow != null && !combat.isFighting() && !cow.isUnderAttack()) { cow.interact("Attack"); new ConditionalSleep(5000) { @@Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating() || myPlayer().isInteracting(cow); } }.sleep(); } if (cow.getHealthPercent() == 0) { sleep(1000); GroundItem cowhide = groundItems.closest("Cowhide"); if (cowhide != null && cowhide.interact("Take")) { new ConditionalSleep(5000) { @@Override public boolean condition() throws InterruptedException { return cowhide == null; } }.sleep(); } } } else { getWalking().webWalk(cowArea); } I have it like this. I'm tlaking about after the cow is dead too. For some reason it takes too long to find another cow/simply loot cowhide. Is there a way to prioritize looting cowhide over killing? so i can find cowhide on the ground and pick itup. thanks
October 31, 20169 yr if (cowArea.contains(myPlayer())) { NPC cow = getNpcs().closest("Cow", "Cow calf"); if (cow != null && !combat.isFighting() && !cow.isUnderAttack()) { cow.interact("Attack"); new ConditionalSleep(5000) { @@Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating() || myPlayer().isInteracting(cow); } }.sleep(); } if (cow.getHealthPercent() == 0) { sleep(1000); GroundItem cowhide = groundItems.closest("Cowhide"); if (cowhide != null && cowhide.interact("Take")) { new ConditionalSleep(5000) { @@Override public boolean condition() throws InterruptedException { return cowhide == null; } }.sleep(); } } } else { getWalking().webWalk(cowArea); } I have it like this. I'm tlaking about after the cow is dead too. For some reason it takes too long to find another cow/simply loot cowhide. Is there a way to prioritize looting cowhide over killing? so i can find cowhide on the ground and pick itup. thanks For the love of god please use the code formatting
October 31, 20169 yr NPCs closest returns a single NPC, not a collection of NPCs for you to filter. You want something like: Optional<NPC> suitableNpc = getNpcs().getAll().stream().filter(npc -> npc.getHealthPercent() > 1).findFirst(); if (suitableNpc.isPresent()) { suitableNpc.get().interact("examine"); } You may want to look a little bit into Java 8 streams before using them. Edit: Or better yet you can use the FilterAPI way which is native to OSBot getNpcs().closest(new Filter<NPC>() { @[member='Override'] public boolean match(NPC obj) { return obj.getHealthPercent() > 1; } }) ; EntityAPI: http://osbot.org/api/org/osbot/rs07/api/EntityAPI.html He was using the shorthand lambda expression, for the Filter<NPC> before. I don't know why he changed it to what he has now. getNpcs().closest(new Filter<NPC>() { @[member='Override'] public boolean match(NPC obj) { return obj.getHealthPercent() > 1; } }) ; is the same as getNpcs().closest(npc -> npc.getHealthPercent() > 1); @@PuppyLover101, change it back to what you had before, where you had the yellow lines. The yellow lines just means there is a warning. It will still compile and run. In eclipse, you can hover over the underlined lines of code and it will tell you what the warning is. It will also give you suggestions on how to fix it. If you can screenshot the warning tool tip, we can help you get rid of it. Edited October 31, 20169 yr by Manner
Create an account or sign in to comment