November 18, 20169 yr So im making a bot that safespots npcs and therefore wont be in combat, i tried isAnimating but it doesn't really work. Any ideas what i could use for this?
November 18, 20169 yr Author http://osbot.org/api/org/osbot/rs07/api/Combat.html#isFighting-- Err could you give me an example how to use that?
November 18, 20169 yr Not sure I feel this would work but won't npc.isIntwracting(myaplayer) not work? Or jus the check that npc.isUnderAttack() and that we're in combat grtCombat().isFIghting(); it's 9am forgive me for typos I'm also on my phone
November 18, 20169 yr If you want to know if your player is interacting with an NPC you can do: myPlayer().getInteracting() != null Edited November 18, 20169 yr by Explv
November 18, 20169 yr Author If you want to know if your player is interacting with an NPC you can do: myPlayer().getInteracting() != null Works perfectly, thanks alot bro.
November 18, 20169 yr Works perfectly, thanks alot bro. You could extend it further to make sure you are attacking the correct NPC, and that the NPC is still alive like so: public final boolean isAttacking(final String npcName) { final Character character = myPlayer().getInteracting(); return character != null && character.getName().equals(npcName) && character.getHealthPercent() > 0 && character.isHitBarVisible(); } Edited November 18, 20169 yr by Explv
November 18, 20169 yr You could extend it further to make sure you are attacking the correct NPC, and that the NPC is still alive like so: public final boolean isAttacking(final String npcName) { final Character character = myPlayer().getInteracting(); return character != null && character.getName().equals(npcName) && character.isUnderAttack() && character.getHealthPercent() > 0; } character.isUnderAttack() returns false when you are not being hit by a player/npc
November 18, 20169 yr character.isUnderAttack() returns false when you are not being hit by a player/npc No that is not true. character.isUnderAttack() Will return true if the character's hit bar is visible and if another NPC or Player is interacting with it: public boolean isUnderAttack() { if(!this.isHitBarVisible()) { return false; } else { List<Character> allCharacters = new ArrayList<>(); allCharacters.addAll(getMethods().getNpcs().getAll()); allCharacters.addAll(getMethods().getPlayers().getAll()); for(final Character character : allCharacters) { if(character.isInteracting(this)) return true; } } return false; } Because OP's bot is interacting with the character, the method would return true if the NPC's hit bar is visible. I have replace the isUnderAttack() method with isHitBarVisible() because we already know that the player is interacting with that NPC, so we only need to check if the hit bar is visible. Edited November 18, 20169 yr by Explv
November 18, 20169 yr No that is not true. character.isUnderAttack() Will return true if the character's hit bar is visible and if the character is interacting with another NPC or Player. Because OP's bot is interacting with the character, the method would return true if the NPC's hit bar is visible. I have replace the isUnderAttack() method with isHitBarVisible() because we already know that the player is interacting with that NPC, so we only need to check if the hit bar is visible. You just said it yourself... "Will return true if the character's hit bar is visible AND if the character is interacting" If you're safe spacing an NPC it'll return false. Edit: Zapps retarded Edited November 18, 20169 yr by Zappster
November 18, 20169 yr You just said it yourself... "Will return true if the character's hit bar is visible AND if the character is interacting" If you're safe spacing an NPC it'll return false. Sorry I meant to say, if any character is interacting with it. See the code I posted. Edited November 18, 20169 yr by Explv